From c0e8c47e202ef604b449e72556c8757764744f7d Mon Sep 17 00:00:00 2001 From: Venkata Harish K Kajur Date: Fri, 12 May 2017 17:28:40 -0400 Subject: Add all of the resources repo Change-Id: If2a9c584621f6d01eb70e9c51e05e054ef3486c4 Signed-off-by: Venkata Harish K Kajur --- .classpath | 6 + .gitignore | 10 + .gitreview | 4 + LICENSE.TXT | 23 + aai-resources/.classpath | 18 + aai-resources/.gitignore | 10 + .../ajsc-shared-config/etc/aft.properties | 13 + .../etc/basic-logback_root_logger_level_off.xml | 84 + .../etc/csm-config-app.properties | 185 + .../etc/csm-framework-app.properties | 11 + .../etc/localhost-access-logback.xml | 38 + aai-resources/ajsc-shared-config/etc/logback.xml | 345 ++ aai-resources/antBuild/build.xml | 231 + aai-resources/bundleconfig-local/README.txt | 10 + aai-resources/bundleconfig-local/RELEASE_NOTES.txt | 1 + .../etc/appprops/Introscope.properties | 8 + .../appprops/PostProcessorInterceptors.properties | 3 + .../appprops/PreProcessorInterceptors.properties | 3 + .../etc/appprops/aaiEventDMaaPPublisher.properties | 28 + .../etc/appprops/aaiconfig.properties | 123 + .../etc/appprops/app-intercepts.properties | 6 + .../etc/appprops/caet.properties | 0 .../etc/appprops/createDBSchema-logback.xml | 108 + .../etc/appprops/dataGrooming-logback.xml | 115 + .../etc/appprops/dataSnapshot-logback.xml | 116 + .../etc/appprops/default-logback.xml | 20 + .../etc/appprops/deltool-logback.xml | 100 + .../etc/appprops/dupeTool-logback.xml | 62 + .../etc/appprops/error.properties | 163 + .../etc/appprops/forceDelete-logback.xml | 62 + .../etc/appprops/getres-logback.xml | 100 + .../etc/appprops/loadDataForDHV-logback.xml | 93 + .../etc/appprops/logging.properties | 128 + .../etc/appprops/methodMapper.properties | 24 + .../etc/appprops/migration-logback.xml | 62 + .../etc/appprops/notifysdnctool-logback.xml | 93 + .../etc/appprops/posttool-logback.xml | 100 + .../etc/appprops/preferredRoute.txt | 1 + .../etc/appprops/prov-logback.xml | 100 + .../etc/appprops/pullInvData-logback.xml | 105 + .../etc/appprops/puttool-logback.xml | 100 + .../etc/appprops/rshiptool-logback.xml | 100 + .../etc/appprops/schemaMod-logback.xml | 62 + .../etc/appprops/titan-cached.properties | 17 + .../etc/appprops/titan-realtime.properties | 14 + .../etc/appprops/uniquePropertyCheck-logback.xml | 62 + .../etc/appprops/updtool-logback.xml | 100 + .../bundleconfig-local/etc/auth/aai_keystore | Bin 0 -> 4002 bytes .../etc/service-file-monitor.properties | 5 + .../etc/sysprops/sys-props.properties | 138 + .../etc/sysprops/template.sys-props.properties | 115 + aai-resources/bundleconfig-local/symlinks.txt | 6 + aai-resources/pom.xml | 718 +++ .../ajsc-aai/v1/conf/FileMonitorBeans.xml | 20 + .../ajsc-aai_v1/ajsc-aai/v1/conf/jaxrsBeans.groovy | 28 + .../ajsc-aai_v1/ajsc-aai/v1/conf/serviceBeans.xml | 100 + .../ajsc/ajsc-aai_v1/ajsc-aai/v1/docs/README.txt | 1 + .../ajsc/ajsc-aai_v1/ajsc-aai/v1/lib/README.txt | 1 + .../ajsc-aai_v1/ajsc-aai/v1/props/module.props | 1 + .../ajsc/ajsc-aai_v1/ajsc-aai/v1/routes/aai.route | 4 + .../src/main/assemble/ajsc_module_assembly.xml | 66 + .../src/main/assemble/ajsc_props_assembly.xml | 23 + .../src/main/assemble/ajsc_runtime_assembly.xml | 44 + aai-resources/src/main/config/ajsc-jetty.xml | 155 + .../src/main/config/ajsc-jolokia-override-web.xml | 46 + .../src/main/config/ajsc-override-web.xml | 41 + aai-resources/src/main/config/ajsc-request.xml | 49 + aai-resources/src/main/config/caet.properties | 0 .../src/main/config/hazelcast-client.properties | 25 + .../src/main/config/jul-redirect.properties | 13 + aai-resources/src/main/config/keyfile | 27 + aai-resources/src/main/config/realm.properties | 11 + aai-resources/src/main/config/runner-web.xml | 106 + .../ajsc_aai/JaxrsErrorMessageLookupService.java | 98 + .../openecomp/aai/ajsc_aai/JaxrsUserService.java | 54 + .../filemonitor/ServicePropertiesListener.java | 37 + .../ajsc_aai/filemonitor/ServicePropertiesMap.java | 126 + .../filemonitor/ServicePropertyService.java | 218 + .../ajsc_aai/util/ServicePropertiesMapBean.java | 37 + .../org/openecomp/aai/db/schema/ScriptDriver.java | 95 + .../aai/dmaap/AAIDmaapEventJMSConsumer.java | 198 + .../aai/dmaap/AAIDmaapEventJMSProducer.java | 44 + .../aai/interceptors/AAIHeaderProperties.java | 26 + .../aai/interceptors/AAILogJAXRSInInterceptor.java | 283 + .../interceptors/AAILogJAXRSOutInterceptor.java | 323 ++ .../aai/interceptors/PostAaiAjscInterceptor.java | 63 + .../aai/interceptors/PreAaiAjscInterceptor.java | 54 + .../org/openecomp/aai/rest/BulkAddConsumer.java | 42 + .../java/org/openecomp/aai/rest/BulkConsumer.java | 484 ++ .../openecomp/aai/rest/BulkProcessConsumer.java | 42 + .../org/openecomp/aai/rest/ExampleConsumer.java | 104 + .../org/openecomp/aai/rest/ExceptionHandler.java | 129 + .../org/openecomp/aai/rest/LegacyMoxyConsumer.java | 583 ++ .../aai/rest/URLFromVertexIdConsumer.java | 120 + .../org/openecomp/aai/rest/VertexIdConsumer.java | 145 + .../java/org/openecomp/aai/rest/db/DBRequest.java | 251 + .../java/org/openecomp/aai/rest/db/HttpEntry.java | 570 ++ .../aai/rest/retired/RetiredConsumer.java | 143 + .../aai/rest/retired/V3ThroughV7Consumer.java | 28 + .../openecomp/aai/rest/ueb/NotificationEvent.java | 96 + .../openecomp/aai/rest/ueb/UEBNotification.java | 178 + .../org/openecomp/aai/rest/util/EchoResponse.java | 121 + .../openecomp/aai/rest/util/LogFormatTools.java | 36 + .../openecomp/aai/rest/util/ValidateEncoding.java | 160 + .../org/openecomp/aai/transforms/Converter.java | 25 + .../LowerCamelToLowerHyphenConverter.java | 34 + .../LowerHyphenToLowerCamelConverter.java | 81 + .../org/openecomp/aai/transforms/MapTraverser.java | 87 + .../aai/util/AAIAppServletContextListener.java | 104 + .../openecomp/aai/util/GenerateMethodMapper.java | 142 + .../java/org/openecomp/aai/util/MergeResource.java | 205 + .../java/org/openecomp/aai/util/PojoUtils.java | 738 +++ .../openecomp/aai/util/StoreNotificationEvent.java | 283 + .../openecomp/aai/util/UniquePropertyCheck.java | 264 + aai-resources/src/main/resources/docker/Dockerfile | 85 + .../src/main/resources/docker/Dockerfile.ext | 76 + aai-resources/src/main/resources/docker/aai.sh | 42 + .../src/main/resources/docker/commonLibs/README | 1 + .../src/main/resources/docker/docker-entrypoint.sh | 34 + .../src/main/resources/docker/init-chef.sh | 32 + .../src/main/resources/schema/UebEventLogEntry.xsd | 20 + ...ame__#__module.ajsc.namespace.version__.context | 1 + .../src/main/runtime/context/default#0.context | 1 + ...e.name__#__module.ajsc.namespace.version__.json | 1 + .../src/main/runtime/shiroRole/ajscadmin.json | 1 + ...ontextadmin#__module.ajsc.namespace.name__.json | 1 + .../runtime/shiroRole/contextadmin#default.json | 1 + aai-resources/src/main/runtime/shiroUser/ajsc.json | 1 + .../main/runtime/shiroUserRole/ajsc#ajscadmin.json | 1 + ...ontextadmin#__module.ajsc.namespace.name__.json | 1 + .../shiroUserRole/ajsc#contextadmin#default.json | 1 + aai-resources/src/main/scripts/createDBSchema.sh | 52 + .../src/main/scripts/install/updateQueryData.sh | 105 + aai-resources/src/main/xjb/bindings.xjb | 46 + .../aai/query/builder/TraversalQueryTest.java | 105 + .../aai/rest/util/ValidateEncodingTest.java | 101 + .../org/openecomp/aai/schema/db/AuditOXMTest.java | 94 + .../openecomp/aai/schema/db/ManageSchemaTest.java | 120 + .../aai/util/AAIApiServerURLBaseTest.java | 85 + .../org/openecomp/aai/util/AAIApiVersionTest.java | 90 + .../aai/util/AAIAppServletContextListenerTest.java | 178 + .../org/openecomp/aai/util/AAICSVWriterTest.java | 177 + .../aai/util/AAIConfigPasswordDecodingTest.java | 53 + .../openecomp/aai/util/AAIRSyncUtilityTest.java | 221 + .../java/org/openecomp/aai/util/AAIUtilsTest.java | 112 + .../java/org/openecomp/aai/util/CNNameTest.java | 138 + .../aai/util/CustomLogPatternLayoutTest.java | 51 + .../java/org/openecomp/aai/util/DbTestConfig.java | 303 + .../org/openecomp/aai/util/DbTestFileWatcher.java | 64 + .../org/openecomp/aai/util/DbTestGetFileTime.java | 55 + .../openecomp/aai/util/DbTestProcessBuilder.java | 218 + .../openecomp/aai/util/HbaseSaltPrefixerTest.java | 39 + .../aai/workarounds/LegacyURITransformerTest.java | 104 + .../etc/appprops/aaiconfig.properties | 140 + .../etc/appprops/error.properties | 163 + .../bundleconfig-local/etc/auth/aai_policy.json | 37 + .../bundleconfig-local/etc/oxm/aai_oxm_v10.xml | 5534 ++++++++++++++++++ .../bundleconfig-local/etc/oxm/aai_oxm_v8.xml | 4797 ++++++++++++++++ .../bundleconfig-local/etc/oxm/aai_oxm_v9.xml | 5469 ++++++++++++++++++ .../com/att/aai/introspection/aai_oxm_v10.xml | 5933 ++++++++++++++++++++ .../com/att/aai/introspection/aai_oxm_v8.xml | 85 + .../com/att/aai/introspection/aai_oxm_v9.xml | 596 ++ .../aai/introspection/sideeffect/nested-case.json | 18 + .../queryformats/graphson/resource.graphson | 2 + .../queryformats/resource-format.json | 13 + .../queryformats/resource_and_url-format.json | 16 + .../serialization/queryformats/simple-format.json | 43 + .../src/test/resources/inmemory_titan.properties | 21 + aai-resources/src/test/resources/log4j.properties | 3 + aai-resources/src/test/resources/logback.xml | 255 + .../resources/maputils/testcases/TestCase1.json | 32 + .../resources/maputils/testcases/TestCase2.json | 40 + .../src/test/resources/test_aaiconfig.properties | 118 + deploy.sh | 55 + docker-compose.yml | 56 + pom.xml | 343 ++ set-debug-port.bat | 1 + start-cassandra-service.bat | 33 + stop-cassandra-service.bat | 33 + version.properties | 14 + 180 files changed, 38422 insertions(+) create mode 100644 .classpath create mode 100644 .gitignore create mode 100644 .gitreview create mode 100644 LICENSE.TXT create mode 100644 aai-resources/.classpath create mode 100644 aai-resources/.gitignore create mode 100644 aai-resources/ajsc-shared-config/etc/aft.properties create mode 100644 aai-resources/ajsc-shared-config/etc/basic-logback_root_logger_level_off.xml create mode 100644 aai-resources/ajsc-shared-config/etc/csm-config-app.properties create mode 100644 aai-resources/ajsc-shared-config/etc/csm-framework-app.properties create mode 100644 aai-resources/ajsc-shared-config/etc/localhost-access-logback.xml create mode 100644 aai-resources/ajsc-shared-config/etc/logback.xml create mode 100644 aai-resources/antBuild/build.xml create mode 100644 aai-resources/bundleconfig-local/README.txt create mode 100644 aai-resources/bundleconfig-local/RELEASE_NOTES.txt create mode 100644 aai-resources/bundleconfig-local/etc/appprops/Introscope.properties create mode 100644 aai-resources/bundleconfig-local/etc/appprops/PostProcessorInterceptors.properties create mode 100644 aai-resources/bundleconfig-local/etc/appprops/PreProcessorInterceptors.properties create mode 100644 aai-resources/bundleconfig-local/etc/appprops/aaiEventDMaaPPublisher.properties create mode 100644 aai-resources/bundleconfig-local/etc/appprops/aaiconfig.properties create mode 100644 aai-resources/bundleconfig-local/etc/appprops/app-intercepts.properties create mode 100644 aai-resources/bundleconfig-local/etc/appprops/caet.properties create mode 100644 aai-resources/bundleconfig-local/etc/appprops/createDBSchema-logback.xml create mode 100644 aai-resources/bundleconfig-local/etc/appprops/dataGrooming-logback.xml create mode 100644 aai-resources/bundleconfig-local/etc/appprops/dataSnapshot-logback.xml create mode 100644 aai-resources/bundleconfig-local/etc/appprops/default-logback.xml create mode 100644 aai-resources/bundleconfig-local/etc/appprops/deltool-logback.xml create mode 100644 aai-resources/bundleconfig-local/etc/appprops/dupeTool-logback.xml create mode 100644 aai-resources/bundleconfig-local/etc/appprops/error.properties create mode 100644 aai-resources/bundleconfig-local/etc/appprops/forceDelete-logback.xml create mode 100644 aai-resources/bundleconfig-local/etc/appprops/getres-logback.xml create mode 100644 aai-resources/bundleconfig-local/etc/appprops/loadDataForDHV-logback.xml create mode 100644 aai-resources/bundleconfig-local/etc/appprops/logging.properties create mode 100644 aai-resources/bundleconfig-local/etc/appprops/methodMapper.properties create mode 100644 aai-resources/bundleconfig-local/etc/appprops/migration-logback.xml create mode 100644 aai-resources/bundleconfig-local/etc/appprops/notifysdnctool-logback.xml create mode 100644 aai-resources/bundleconfig-local/etc/appprops/posttool-logback.xml create mode 100644 aai-resources/bundleconfig-local/etc/appprops/preferredRoute.txt create mode 100644 aai-resources/bundleconfig-local/etc/appprops/prov-logback.xml create mode 100644 aai-resources/bundleconfig-local/etc/appprops/pullInvData-logback.xml create mode 100644 aai-resources/bundleconfig-local/etc/appprops/puttool-logback.xml create mode 100644 aai-resources/bundleconfig-local/etc/appprops/rshiptool-logback.xml create mode 100644 aai-resources/bundleconfig-local/etc/appprops/schemaMod-logback.xml create mode 100644 aai-resources/bundleconfig-local/etc/appprops/titan-cached.properties create mode 100644 aai-resources/bundleconfig-local/etc/appprops/titan-realtime.properties create mode 100644 aai-resources/bundleconfig-local/etc/appprops/uniquePropertyCheck-logback.xml create mode 100644 aai-resources/bundleconfig-local/etc/appprops/updtool-logback.xml create mode 100644 aai-resources/bundleconfig-local/etc/auth/aai_keystore create mode 100644 aai-resources/bundleconfig-local/etc/service-file-monitor.properties create mode 100644 aai-resources/bundleconfig-local/etc/sysprops/sys-props.properties create mode 100644 aai-resources/bundleconfig-local/etc/sysprops/template.sys-props.properties create mode 100644 aai-resources/bundleconfig-local/symlinks.txt create mode 100644 aai-resources/pom.xml create mode 100644 aai-resources/src/main/ajsc/ajsc-aai_v1/ajsc-aai/v1/conf/FileMonitorBeans.xml create mode 100644 aai-resources/src/main/ajsc/ajsc-aai_v1/ajsc-aai/v1/conf/jaxrsBeans.groovy create mode 100644 aai-resources/src/main/ajsc/ajsc-aai_v1/ajsc-aai/v1/conf/serviceBeans.xml create mode 100644 aai-resources/src/main/ajsc/ajsc-aai_v1/ajsc-aai/v1/docs/README.txt create mode 100644 aai-resources/src/main/ajsc/ajsc-aai_v1/ajsc-aai/v1/lib/README.txt create mode 100644 aai-resources/src/main/ajsc/ajsc-aai_v1/ajsc-aai/v1/props/module.props create mode 100644 aai-resources/src/main/ajsc/ajsc-aai_v1/ajsc-aai/v1/routes/aai.route create mode 100644 aai-resources/src/main/assemble/ajsc_module_assembly.xml create mode 100644 aai-resources/src/main/assemble/ajsc_props_assembly.xml create mode 100644 aai-resources/src/main/assemble/ajsc_runtime_assembly.xml create mode 100644 aai-resources/src/main/config/ajsc-jetty.xml create mode 100644 aai-resources/src/main/config/ajsc-jolokia-override-web.xml create mode 100644 aai-resources/src/main/config/ajsc-override-web.xml create mode 100644 aai-resources/src/main/config/ajsc-request.xml create mode 100644 aai-resources/src/main/config/caet.properties create mode 100644 aai-resources/src/main/config/hazelcast-client.properties create mode 100644 aai-resources/src/main/config/jul-redirect.properties create mode 100644 aai-resources/src/main/config/keyfile create mode 100644 aai-resources/src/main/config/realm.properties create mode 100644 aai-resources/src/main/config/runner-web.xml create mode 100644 aai-resources/src/main/java/org/openecomp/aai/ajsc_aai/JaxrsErrorMessageLookupService.java create mode 100644 aai-resources/src/main/java/org/openecomp/aai/ajsc_aai/JaxrsUserService.java create mode 100644 aai-resources/src/main/java/org/openecomp/aai/ajsc_aai/filemonitor/ServicePropertiesListener.java create mode 100644 aai-resources/src/main/java/org/openecomp/aai/ajsc_aai/filemonitor/ServicePropertiesMap.java create mode 100644 aai-resources/src/main/java/org/openecomp/aai/ajsc_aai/filemonitor/ServicePropertyService.java create mode 100644 aai-resources/src/main/java/org/openecomp/aai/ajsc_aai/util/ServicePropertiesMapBean.java create mode 100644 aai-resources/src/main/java/org/openecomp/aai/db/schema/ScriptDriver.java create mode 100644 aai-resources/src/main/java/org/openecomp/aai/dmaap/AAIDmaapEventJMSConsumer.java create mode 100644 aai-resources/src/main/java/org/openecomp/aai/dmaap/AAIDmaapEventJMSProducer.java create mode 100644 aai-resources/src/main/java/org/openecomp/aai/interceptors/AAIHeaderProperties.java create mode 100644 aai-resources/src/main/java/org/openecomp/aai/interceptors/AAILogJAXRSInInterceptor.java create mode 100644 aai-resources/src/main/java/org/openecomp/aai/interceptors/AAILogJAXRSOutInterceptor.java create mode 100644 aai-resources/src/main/java/org/openecomp/aai/interceptors/PostAaiAjscInterceptor.java create mode 100644 aai-resources/src/main/java/org/openecomp/aai/interceptors/PreAaiAjscInterceptor.java create mode 100644 aai-resources/src/main/java/org/openecomp/aai/rest/BulkAddConsumer.java create mode 100644 aai-resources/src/main/java/org/openecomp/aai/rest/BulkConsumer.java create mode 100644 aai-resources/src/main/java/org/openecomp/aai/rest/BulkProcessConsumer.java create mode 100644 aai-resources/src/main/java/org/openecomp/aai/rest/ExampleConsumer.java create mode 100644 aai-resources/src/main/java/org/openecomp/aai/rest/ExceptionHandler.java create mode 100644 aai-resources/src/main/java/org/openecomp/aai/rest/LegacyMoxyConsumer.java create mode 100644 aai-resources/src/main/java/org/openecomp/aai/rest/URLFromVertexIdConsumer.java create mode 100644 aai-resources/src/main/java/org/openecomp/aai/rest/VertexIdConsumer.java create mode 100644 aai-resources/src/main/java/org/openecomp/aai/rest/db/DBRequest.java create mode 100644 aai-resources/src/main/java/org/openecomp/aai/rest/db/HttpEntry.java create mode 100644 aai-resources/src/main/java/org/openecomp/aai/rest/retired/RetiredConsumer.java create mode 100644 aai-resources/src/main/java/org/openecomp/aai/rest/retired/V3ThroughV7Consumer.java create mode 100644 aai-resources/src/main/java/org/openecomp/aai/rest/ueb/NotificationEvent.java create mode 100644 aai-resources/src/main/java/org/openecomp/aai/rest/ueb/UEBNotification.java create mode 100644 aai-resources/src/main/java/org/openecomp/aai/rest/util/EchoResponse.java create mode 100644 aai-resources/src/main/java/org/openecomp/aai/rest/util/LogFormatTools.java create mode 100644 aai-resources/src/main/java/org/openecomp/aai/rest/util/ValidateEncoding.java create mode 100644 aai-resources/src/main/java/org/openecomp/aai/transforms/Converter.java create mode 100644 aai-resources/src/main/java/org/openecomp/aai/transforms/LowerCamelToLowerHyphenConverter.java create mode 100644 aai-resources/src/main/java/org/openecomp/aai/transforms/LowerHyphenToLowerCamelConverter.java create mode 100644 aai-resources/src/main/java/org/openecomp/aai/transforms/MapTraverser.java create mode 100644 aai-resources/src/main/java/org/openecomp/aai/util/AAIAppServletContextListener.java create mode 100644 aai-resources/src/main/java/org/openecomp/aai/util/GenerateMethodMapper.java create mode 100644 aai-resources/src/main/java/org/openecomp/aai/util/MergeResource.java create mode 100644 aai-resources/src/main/java/org/openecomp/aai/util/PojoUtils.java create mode 100644 aai-resources/src/main/java/org/openecomp/aai/util/StoreNotificationEvent.java create mode 100644 aai-resources/src/main/java/org/openecomp/aai/util/UniquePropertyCheck.java create mode 100644 aai-resources/src/main/resources/docker/Dockerfile create mode 100644 aai-resources/src/main/resources/docker/Dockerfile.ext create mode 100644 aai-resources/src/main/resources/docker/aai.sh create mode 100644 aai-resources/src/main/resources/docker/commonLibs/README create mode 100644 aai-resources/src/main/resources/docker/docker-entrypoint.sh create mode 100644 aai-resources/src/main/resources/docker/init-chef.sh create mode 100644 aai-resources/src/main/resources/schema/UebEventLogEntry.xsd create mode 100644 aai-resources/src/main/runtime/context/__module.ajsc.namespace.name__#__module.ajsc.namespace.version__.context create mode 100644 aai-resources/src/main/runtime/context/default#0.context create mode 100644 aai-resources/src/main/runtime/deploymentPackage/__module.ajsc.namespace.name__#__module.ajsc.namespace.version__.json create mode 100644 aai-resources/src/main/runtime/shiroRole/ajscadmin.json create mode 100644 aai-resources/src/main/runtime/shiroRole/contextadmin#__module.ajsc.namespace.name__.json create mode 100644 aai-resources/src/main/runtime/shiroRole/contextadmin#default.json create mode 100644 aai-resources/src/main/runtime/shiroUser/ajsc.json create mode 100644 aai-resources/src/main/runtime/shiroUserRole/ajsc#ajscadmin.json create mode 100644 aai-resources/src/main/runtime/shiroUserRole/ajsc#contextadmin#__module.ajsc.namespace.name__.json create mode 100644 aai-resources/src/main/runtime/shiroUserRole/ajsc#contextadmin#default.json create mode 100644 aai-resources/src/main/scripts/createDBSchema.sh create mode 100644 aai-resources/src/main/scripts/install/updateQueryData.sh create mode 100644 aai-resources/src/main/xjb/bindings.xjb create mode 100644 aai-resources/src/test/java/org/openecomp/aai/query/builder/TraversalQueryTest.java create mode 100644 aai-resources/src/test/java/org/openecomp/aai/rest/util/ValidateEncodingTest.java create mode 100644 aai-resources/src/test/java/org/openecomp/aai/schema/db/AuditOXMTest.java create mode 100644 aai-resources/src/test/java/org/openecomp/aai/schema/db/ManageSchemaTest.java create mode 100644 aai-resources/src/test/java/org/openecomp/aai/util/AAIApiServerURLBaseTest.java create mode 100644 aai-resources/src/test/java/org/openecomp/aai/util/AAIApiVersionTest.java create mode 100644 aai-resources/src/test/java/org/openecomp/aai/util/AAIAppServletContextListenerTest.java create mode 100644 aai-resources/src/test/java/org/openecomp/aai/util/AAICSVWriterTest.java create mode 100644 aai-resources/src/test/java/org/openecomp/aai/util/AAIConfigPasswordDecodingTest.java create mode 100644 aai-resources/src/test/java/org/openecomp/aai/util/AAIRSyncUtilityTest.java create mode 100644 aai-resources/src/test/java/org/openecomp/aai/util/AAIUtilsTest.java create mode 100644 aai-resources/src/test/java/org/openecomp/aai/util/CNNameTest.java create mode 100644 aai-resources/src/test/java/org/openecomp/aai/util/CustomLogPatternLayoutTest.java create mode 100644 aai-resources/src/test/java/org/openecomp/aai/util/DbTestConfig.java create mode 100644 aai-resources/src/test/java/org/openecomp/aai/util/DbTestFileWatcher.java create mode 100644 aai-resources/src/test/java/org/openecomp/aai/util/DbTestGetFileTime.java create mode 100644 aai-resources/src/test/java/org/openecomp/aai/util/DbTestProcessBuilder.java create mode 100644 aai-resources/src/test/java/org/openecomp/aai/util/HbaseSaltPrefixerTest.java create mode 100644 aai-resources/src/test/java/org/openecomp/aai/workarounds/LegacyURITransformerTest.java create mode 100644 aai-resources/src/test/resources/bundleconfig-local/etc/appprops/aaiconfig.properties create mode 100644 aai-resources/src/test/resources/bundleconfig-local/etc/appprops/error.properties create mode 100644 aai-resources/src/test/resources/bundleconfig-local/etc/auth/aai_policy.json create mode 100644 aai-resources/src/test/resources/bundleconfig-local/etc/oxm/aai_oxm_v10.xml create mode 100644 aai-resources/src/test/resources/bundleconfig-local/etc/oxm/aai_oxm_v8.xml create mode 100644 aai-resources/src/test/resources/bundleconfig-local/etc/oxm/aai_oxm_v9.xml create mode 100644 aai-resources/src/test/resources/com/att/aai/introspection/aai_oxm_v10.xml create mode 100644 aai-resources/src/test/resources/com/att/aai/introspection/aai_oxm_v8.xml create mode 100644 aai-resources/src/test/resources/com/att/aai/introspection/aai_oxm_v9.xml create mode 100644 aai-resources/src/test/resources/com/att/aai/introspection/sideeffect/nested-case.json create mode 100644 aai-resources/src/test/resources/com/att/aai/serialization/queryformats/graphson/resource.graphson create mode 100644 aai-resources/src/test/resources/com/att/aai/serialization/queryformats/resource-format.json create mode 100644 aai-resources/src/test/resources/com/att/aai/serialization/queryformats/resource_and_url-format.json create mode 100644 aai-resources/src/test/resources/com/att/aai/serialization/queryformats/simple-format.json create mode 100644 aai-resources/src/test/resources/inmemory_titan.properties create mode 100644 aai-resources/src/test/resources/log4j.properties create mode 100644 aai-resources/src/test/resources/logback.xml create mode 100644 aai-resources/src/test/resources/maputils/testcases/TestCase1.json create mode 100644 aai-resources/src/test/resources/maputils/testcases/TestCase2.json create mode 100644 aai-resources/src/test/resources/test_aaiconfig.properties create mode 100755 deploy.sh create mode 100644 docker-compose.yml create mode 100644 pom.xml create mode 100644 set-debug-port.bat create mode 100644 start-cassandra-service.bat create mode 100644 stop-cassandra-service.bat create mode 100644 version.properties diff --git a/.classpath b/.classpath new file mode 100644 index 0000000..c0592e8 --- /dev/null +++ b/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..1da6a7a --- /dev/null +++ b/.gitignore @@ -0,0 +1,10 @@ +.settings +.project +target/ +**/logs/ +bundleconfig-local/etc/auth/aai-client-cert.p12 +bundleconfig-local/etc/logback.xml +/.pydevproject +/bin/ +fitnesse/ +test_csvWriter.csv \ No newline at end of file diff --git a/.gitreview b/.gitreview new file mode 100644 index 0000000..6a2b70e --- /dev/null +++ b/.gitreview @@ -0,0 +1,4 @@ +[gerrit] +host=gerrit.onap.org +port=29418 +project=resources.git diff --git a/LICENSE.TXT b/LICENSE.TXT new file mode 100644 index 0000000..32bbcba --- /dev/null +++ b/LICENSE.TXT @@ -0,0 +1,23 @@ +/*- + * ============LICENSE_START======================================================= + * org.openecomp.aai + * ================================================================================ + * 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/aai-resources/.classpath b/aai-resources/.classpath new file mode 100644 index 0000000..9dedccc --- /dev/null +++ b/aai-resources/.classpath @@ -0,0 +1,18 @@ + + + + + + + + + + + + + + + + + + diff --git a/aai-resources/.gitignore b/aai-resources/.gitignore new file mode 100644 index 0000000..cd21128 --- /dev/null +++ b/aai-resources/.gitignore @@ -0,0 +1,10 @@ +.settings +target/ +**/logs/ +bundleconfig-local/etc/auth/aai-client-cert.p12 +bundleconfig-local/etc/oxm +src/main/aai_schema +bundleconfig-local/etc/logback.xml +/.pydevproject +/test_csvWriter.csv +/bin/ diff --git a/aai-resources/ajsc-shared-config/etc/aft.properties b/aai-resources/ajsc-shared-config/etc/aft.properties new file mode 100644 index 0000000..43e896d --- /dev/null +++ b/aai-resources/ajsc-shared-config/etc/aft.properties @@ -0,0 +1,13 @@ + +# Flow test 319 +com.att.aft.discovery.client.environment=AFTUAT +com.att.aft.discovery.client.latitude=35.318900 +com.att.aft.discovery.client.longitude=-80.762200 +com.att.aft.alias=ecomp-aai +#com.att.aft.keyStore=ajsc-shared-config/etc/spm2.jks +com.att.aft.keyStore=/opt/app/aai/bundleconfig/etc/m04353t.jks +com.att.aft.keyStorePassword=its4test +#com.att.aft.trustStore=ajsc-shared-config/etc/spm2.jks +com.att.aft.trustStore=/opt/app/aai/bundleconfig/etc/m04353t.jks +com.att.aft.trustStorePassword=its4test + diff --git a/aai-resources/ajsc-shared-config/etc/basic-logback_root_logger_level_off.xml b/aai-resources/ajsc-shared-config/etc/basic-logback_root_logger_level_off.xml new file mode 100644 index 0000000..326c8cb --- /dev/null +++ b/aai-resources/ajsc-shared-config/etc/basic-logback_root_logger_level_off.xml @@ -0,0 +1,84 @@ + + + + + ERROR + + + %d{HH:mm:ss.SSS} [%thread] %-5level %logger{1024} - %msg%n + + + + + + + DEBUG + + ${logDirectory}/info_ajsc.log + + ${logDirectory}/info_ajsc.%i.log.zip + + 1 + 9 + + + 5MB + + + "%d [%thread] %-5level %logger{1024} - %msg%n" + + + + + ERROR + + ${logDirectory}/error_ajsc.log + + ${logDirectory}/error_ajsc.%i.log.zip + + 1 + 9 + + + 5MB + + + + "%d [%thread] %-5level %logger{1024} - %msg%n" + + + + + + INFO + + localhost + USER + + AJSC_AUDIT: [%thread] [%logger] %msg + + + + INFO + + localhost + USER + + AJSC_AUDIT: [%thread] [%logger] mdc:[%mdc] %msg + + + + + + + + + diff --git a/aai-resources/ajsc-shared-config/etc/csm-config-app.properties b/aai-resources/ajsc-shared-config/etc/csm-config-app.properties new file mode 100644 index 0000000..0aebe00 --- /dev/null +++ b/aai-resources/ajsc-shared-config/etc/csm-config-app.properties @@ -0,0 +1,185 @@ +Global.ExtendedProperty.AuthoritativeServers=${ChangeMe_csm.acfshost}:${ChangeMe_csm.acfsport} + +#Possible working server for troubleshooting csm related items (used when testing/using invokeService or invokeAdapter components) +#Global.ExtendedProperty.AuthoritativeServers=ONAPserverTBD +# +# The settings in this file control the behavior of the CSM Framework. +# The majority of the settings in this file adhere to the following +# pattern: +# +# [EntityType].[EntityId].[PropertyName]=[PropertyValue] +# +# Where: +# +# [EntityType] Identifies the type of entity (service or +# service group) that's being configured. +# [EntityId] Identifies the individual entity. +# [PropertyName] Identifies the property that is being set. +# [PropertyValue] Is the actual property value. +# +# In the formatting sample above, the EntityType can be setto one of the +# following values: +# +# * 'Service' if an individual service is being configured. +# * 'Group 'if a service group is being configured. +# +# The reference to 'entity' in the above description is intentionally +# generic. The CSM Framework supports the configuration of individual +# services as well as groups of services. The type of entity that is +# actually being configured is determined by the value of the +# [EntityType] portion of the property. +# +# There are two values for [EntityId] that have a special meaning within +# the CSM Framework: +# +# +# DefaultService - Identifies the default configuration for any service +# that is not explicitly configured elsewhere in this file. +# +# DefaultServiceGroup - This identifies the entity that provides the +# default configuration for any service group that is not explicitly +# configured elsewhere in this file. +# +# DO NOT use either of these as the identifier for any of your +# application-specific services or service groups. +# +# The CSM Framework treats all entity identifiers in a case-insensitive +# manner. The entity ids 'Service1' and 'SERVICE1' are equivalant. All +# properties with the same [EntityId] will be applied to the same +# configuration. The CSM Framework framework also treats property names +# in a case-insensitive manner. 'MaxRequestCount' and 'MAXREQUESTCOUNT' +# are considered equivalent within the CSM framework. +# +# The following properties are supported by the CSM Framework. Any +# properties that are entity-specific will include the '[EntityId].' +# prefix. +# +# [EntityType].[EntityId].Enabled - Indicates if the entity is enabled +# or disabled by default. The value of this property must be either +# 'true' or 'false'. +# +# [EntityType].[EntityId].MaxRequestCount - The maximum number of +# requests that can be running at any point in time. Once this limit is +# reached, the service is considered to be 'flooded', and subsequent +# requests are refused until the request count drops to the level +# specified by the RestartThreshold property. Once the restart +# threshold is reached, the service will be 'restarted' based on the +# values of the 'RestartFrequency' and 'RestartIncrement' properties. +# The value of this property must be a numeric value. +# The default value for this property is 20. +# +# [EntityType].[EntityId].MaxStalledRequestCount - the maximum number of +# 'stalled' requests that are allowed before subsequent requests are +# refused +# The value of this property must be a numeric value. +# The default value for this property is 10. +# +# [EntityType].[EntityId].RestartThreshold - the process count level at +# which requests will be allowed to proceed whenever a service becomes +# 'flooded'. This property is only used if the total process count +# reaches the level set by the 'MaxRequestCount' property. Once that +# occurs, subsequent requests will be refused until the active request +# count drops to the level specified by this property. Once the active +# request count drops to the level specified by this property, the +# service will be 'restarted' based on the values of the +# 'RestartFrequency' and 'RestartIncrement' properties. To cause the +# CSM framework to allow subsequent requests to proceed as soon as the +# active request count drops below level level set by the +# 'MaxRequestCount' property, just set this property to either -1 or 1 +# less than the value of the 'MaxRequestCount' property. +# The value of this property must be a numeric value. +# The default value for this property is -1. +# +# [EntityType].[EntityId].RestartIncrement - This property, along with +# the 'RestartFrequency' property helps determine how quickly the active +# request count will rise to the 'maximum request count' whenever a +# service is 'restarted' after becoming 'flooded'. The +# 'RestartFrequency' property determines how frequenty the permissable +# number of active requests will be increased. This property determines +# how much the permissible number of active requests will increase by +# whenever it is raised. If this property is set to a positive value, +# then the 'RestartFrequency' property must also be set to a positive +# value. If this property is set to 0, then the 'RestartFrequency' +# property must also be set to 0. In other words, either both +# properties are 0 or both properties are greater than 0. When both +# properties are set to 0, then the permissable number of active +# requests immediately rises back up to the maximum request count once +# it has droppedback down to the 'restart threshold'. When both +# properties are greater than 0, then the permissable number of active +# requests gradually rises to the maximum request count. +# The value of this property must be a numeric value greater than or equal to 0. +# The default value for this property is 0. +# +# [EntityType].[EntityId].RestartFrequency - This property, along with +# the 'RestartIncrement' property helps determine how quickly the active +# request count will rise to the 'maximum request count' whenever a +# service is 'restarted' after becoming 'flooded'. The +# 'RestartIncrement' property determines how quickly the permissable +# number of active requests will be increased. This property determines +# how frequently that increase will occur. If this property is set to +# a positive value, then the 'RestartIncrement' property must also be +# set to a positive value. If this property is set to 0, then the +# 'RestartIncrement' property must also be set to 0. In other words, +# either both properties are 0 or both properties are greater than 0. +# When both properties are set to 0, then the permissable number of +# active requests immediately rises back up to the maximum request count +# once it has droppedback down to the 'restart threshold'. When both +# properties are greater than 0, then the permissable number of active +# requests gradually rises to the maximum request count. +# The value of this property must be a numeric value greater than or equal to 0. +# The default value for this property is 0. +# +# [EntityType].[EntityId].ServiceGroupId - This property is only +# relevant for entities that are configured as services (i.e. the +# [EntityType] portion of the property is set to 'Service'). When the +# 'ServiceGroupId' property is set to a non-blank value, the behavior of +# the service is controled by the configuration of the corresponding +# service group. There is no default value for this property. +# +# [EntityType].[EntityId].Timeout - the timeout, in milliseconds, for +# each process that is controlled by this configuration. Once the +# duration of a process exceeds this value, the process will be +# considered to have entered a 'stalled' state. The default value for +# this property is 10000. +# +# FrameworkEnabled: - This is the one property that is not specific to a +# single entity. This property determines whether the entire CSM +# Framework is enabled or disabled. When disabled, the CSM Framework +# does not track any process counts. All requests to access a service +# are allowed, regardless of the current level of activity. The value +# of this property must be either 'true' or 'false'. +# + +# +# Enables the CSM Framework so that it can manage interactions with external +# services and/or resources. To disable the CSM Framework, simply set +# this property to false. +# +FrameworkEnabled=true + +# +# These are the default settings for any service that is no explicitly configured +# below. A few things to note about this configuration: +# 1) The "Enabled" property is not explicitly set. Instead, we are relying +# on the default value of 'true'. +# 2) The Timeout and Type properties are also not explicitly set. Again, we +# are relying on the default values for these properties. +# +Service.DefaultService.Enabled=true +Service.DefaultService.MaxRequestCount=30 +Service.DefaultService.MaxStalledRequestCount=20 +Service.DefaultService.Timeout=30000 +Service.DefaultService.RestartThreshold=-1 +Service.DefaultService.AutoPurgeAfter=150000 + + +# +# These are the default settings for any service group that is referenced in +# a service configuration but not configured below. +# +# Currently CSI does not use any service group configurations! +# +#Group.DefaultGroup.MaxRequestCount=-1 +#Group.DefaultGroup.MaxStalledRequestCount=-1 +#Group.DefaultGroup.RestartThreshold=-1 +#Group.DefaultGroup.Timeout=-1 diff --git a/aai-resources/ajsc-shared-config/etc/csm-framework-app.properties b/aai-resources/ajsc-shared-config/etc/csm-framework-app.properties new file mode 100644 index 0000000..140fde3 --- /dev/null +++ b/aai-resources/ajsc-shared-config/etc/csm-framework-app.properties @@ -0,0 +1,11 @@ +# The csm-persist-to property identifies the file that the CSM Framework +# will write the current configuration to whenever it is told to save it's +# configuration. +# +#csm-persist-to=/opt/app/myapplication/csm.properties.persisted + +#Important . Please specify absolute path starting from the root directory for Property csm-persist-to +#(Giving relative path may result in undesired results in case the applcation is restarted from a different directory than the original start directory ) +#In the following example , relative path is specfied since the directory structure varies on diff env + +csm-persist-to=/opt/app/q103csi1m8/DATA/${ChangeMe_RELEASE}/${ChangeMe_CLUSTER}_ACFS_csm.properties.persisted diff --git a/aai-resources/ajsc-shared-config/etc/localhost-access-logback.xml b/aai-resources/ajsc-shared-config/etc/localhost-access-logback.xml new file mode 100644 index 0000000..5186d55 --- /dev/null +++ b/aai-resources/ajsc-shared-config/etc/localhost-access-logback.xml @@ -0,0 +1,38 @@ + + + ${AJSC_HOME}/logs/ajsc-jetty/localhost_access.log + + ${AJSC_HOME}/logs/ajsc-jetty/localhost_access.log.%d{yyyy-MM-dd} + + + + %a %u %z [%t] "%m %U" %s %b %y %i{X-TransactionId} %i{X-FromAppId} %i{X-Forwarded-For} %i{X-AAI-SSL-Client-CN} %i{X-AAI-SSL-Client-OU} %i{X-AAI-SSL-Client-O} %i{X-AAI-SSL-Client-L} %i{X-AAI-SSL-Client-ST} %i{X-AAI-SSL-Client-C} %i{X-AAI-SSL-Client-NotBefore} %i{X-AAI-SSL-Client-NotAfter} %i{X-AAI-SSL-Client-DN} %D + + + + + + diff --git a/aai-resources/ajsc-shared-config/etc/logback.xml b/aai-resources/ajsc-shared-config/etc/logback.xml new file mode 100644 index 0000000..4c4e774 --- /dev/null +++ b/aai-resources/ajsc-shared-config/etc/logback.xml @@ -0,0 +1,345 @@ + + ${module.ajsc.namespace.name} + + + + + + + + + ERROR + ACCEPT + DENY + + + %d{HH:mm:ss.SSS} [%thread] %-5level %logger{1024} - %msg%n + + + + + + ${logDirectory}/rest/sane.log + + ${logDirectory}/rest/sane.log.%d{yyyy-MM-dd} + + + %d{HH:mm:ss.SSS} [%thread] %-5level %logger{1024} - %msg%n + + + + + + 1000 + true + + + + + + INFO + ACCEPT + DENY + + ${logDirectory}/rest/metrics.log + + ${logDirectory}/rest/metrics.log.%d{yyyy-MM-dd} + + + + ${eelfMetricLogPattern} + + + + 1000 + true + + + + + + DEBUG + ACCEPT + DENY + + ${logDirectory}/rest/debug.log + + ${logDirectory}/rest/debug.log.%d{yyyy-MM-dd} + + + + ${eelfLogPattern} + + + + + 1000 + true + + + + + + WARN + + ${logDirectory}/rest/error.log + + ${logDirectory}/rest/error.log.%d{yyyy-MM-dd} + + + + ${eelfLogPattern} + + + + + 1000 + true + + + + + ${logDirectory}/rest/audit.log + + ${logDirectory}/rest/audit.log.%d{yyyy-MM-dd} + + + + ${eelfAuditLogPattern} + + + + + 1000 + true + + + + + + DEBUG + ACCEPT + DENY + + ${logDirectory}/rest/translog.log + + ${logDirectory}/rest/translog.log.%d{yyyy-MM-dd} + + + + ${eelfLogPattern} + + + + + 1000 + true + + + + + + WARN + + ${logDirectory}/dmaapAAIEventConsumer/error.log + + ${logDirectory}/dmaapAAIEventConsumer/error.log.%d{yyyy-MM-dd} + + + + ${eelfLogPattern} + + + + + + DEBUG + ACCEPT + DENY + + ${logDirectory}/dmaapAAIEventConsumer/debug.log + + ${logDirectory}/dmaapAAIEventConsumer/debug.log.%d{yyyy-MM-dd} + + + + ${eelfLogPattern} + + + + + INFO + ACCEPT + DENY + + ${logDirectory}/dmaapAAIEventConsumer/metrics.log + + ${logDirectory}/dmaapAAIEventConsumer/metrics.log.%d{yyyy-MM-dd} + + + + ${eelfLogPattern} + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + ${logDirectory}/perf-audit/Audit.log + + + ${logDirectory}/perf-audit/Audit.%i.log.zip + + 1 + 9 + + + 5MB + + + "%d [%thread] %-5level %logger{1024} - %msg%n" + + + + + ${logDirectory}/perf-audit/Perform.log + + + ${logDirectory}/perf-audit/Perform.%i.log.zip + + 1 + 9 + + + 5MB + + + "%d [%thread] %-5level %logger{1024} - %msg%n" + + + + 1000 + true + 0 + + + + 1000 + true + 0 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/aai-resources/antBuild/build.xml b/aai-resources/antBuild/build.xml new file mode 100644 index 0000000..5875c06 --- /dev/null +++ b/aai-resources/antBuild/build.xml @@ -0,0 +1,231 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/aai-resources/bundleconfig-local/README.txt b/aai-resources/bundleconfig-local/README.txt new file mode 100644 index 0000000..82a355f --- /dev/null +++ b/aai-resources/bundleconfig-local/README.txt @@ -0,0 +1,10 @@ +The bundleconfig-local directory contains the necessary configuration files to be used for running locally. When running +locally, the "mvn -P runLocal" or the "mvn -P runAjsc" profiles will be using this bundleconfig-local directory as the AJSC_CONF +directory. When deploying to a CSI env, the bundleconfig-csi directory will be copied to the ultimate installation/bundleconfig +directory and will be used for your AJSC service once installed. If you are not deploying to a CSI env, please look at the +antBuild/build.xml file for help in some simple copying of the appropriate folders/files for a NON-CSI env. + + +The ajsc-shared-config directory houses the shared configurations that will be used in CSI envs. This includes the logging +functionality of the logback.xml and some csm related artifacts that may be necessary to use while running locally. +When running locally, the system property, "AJSC_SHARED_CONFIG", will point to this location to utilize the logback.xml. diff --git a/aai-resources/bundleconfig-local/RELEASE_NOTES.txt b/aai-resources/bundleconfig-local/RELEASE_NOTES.txt new file mode 100644 index 0000000..a567d9b --- /dev/null +++ b/aai-resources/bundleconfig-local/RELEASE_NOTES.txt @@ -0,0 +1 @@ +Place Release Notes here to provide updated Release information for CSTEM to better help manage your service in the CSI environment. \ No newline at end of file diff --git a/aai-resources/bundleconfig-local/etc/appprops/Introscope.properties b/aai-resources/bundleconfig-local/etc/appprops/Introscope.properties new file mode 100644 index 0000000..319381e --- /dev/null +++ b/aai-resources/bundleconfig-local/etc/appprops/Introscope.properties @@ -0,0 +1,8 @@ +#CSI environment uses the Introscope java agent for monitoring services. The AJSC has provided an implementation class that +#provides basic information to the Introscope Enterprise Manager for each http request/response. + +introscopeEventClass=com.att.ajsc.introscope.IntroscopeEventNotifierImpl +serviceName=N/A +conversationId=N/A +uniqueID=N/A +userID=N/A diff --git a/aai-resources/bundleconfig-local/etc/appprops/PostProcessorInterceptors.properties b/aai-resources/bundleconfig-local/etc/appprops/PostProcessorInterceptors.properties new file mode 100644 index 0000000..29f5f7c --- /dev/null +++ b/aai-resources/bundleconfig-local/etc/appprops/PostProcessorInterceptors.properties @@ -0,0 +1,3 @@ +#This properties file is for defining any PostProcessorInterceptors that have been created for your AJSC service. + +/**=org.openecomp.aai.interceptors.PostAaiAjscInterceptor diff --git a/aai-resources/bundleconfig-local/etc/appprops/PreProcessorInterceptors.properties b/aai-resources/bundleconfig-local/etc/appprops/PreProcessorInterceptors.properties new file mode 100644 index 0000000..e803374 --- /dev/null +++ b/aai-resources/bundleconfig-local/etc/appprops/PreProcessorInterceptors.properties @@ -0,0 +1,3 @@ +#This properties file is for defining any PreProcessorInterceptors that have been created for your AJSC service. + +/**=com.att.ajsc.csi.restmethodmap.RestMethodMapInterceptor,org.openecomp.aai.interceptors.PreAaiAjscInterceptor diff --git a/aai-resources/bundleconfig-local/etc/appprops/aaiEventDMaaPPublisher.properties b/aai-resources/bundleconfig-local/etc/appprops/aaiEventDMaaPPublisher.properties new file mode 100644 index 0000000..6245f84 --- /dev/null +++ b/aai-resources/bundleconfig-local/etc/appprops/aaiEventDMaaPPublisher.properties @@ -0,0 +1,28 @@ +TransportType=DME2 +Latitude=39.099727 +Longitude=-94.578567 +Version=1.0 +ServiceName=ONAPserverTBD/events +Environment=TEST +routeOffer=MR1SBKCD +SubContextPath=/ +Protocol=http +MethodType=POST +username=ONAPserverTBD +password= +contenttype=application/json +host=ONAPserverTBD:3904 +topic=AAI-EVENT +partition=AAI +maxBatchSize=100 +maxAgeMs=250 +AFT_DME2_EXCHANGE_REQUEST_HANDLERS=com.att.nsa.test.PreferredRouteRequestHandler +AFT_DME2_EXCHANGE_REPLY_HANDLERS=com.att.nsa.test.PreferredRouteReplyHandler +AFT_DME2_REQ_TRACE_ON=true +AFT_ENVIRONMENT=AFTUAT +AFT_DME2_EP_CONN_TIMEOUT=15000 +AFT_DME2_ROUNDTRIP_TIMEOUT_MS=240000 +AFT_DME2_EP_READ_TIMEOUT_MS=50000 +sessionstickinessrequired=NO +DME2preferredRouterFilePath=preferredRoute.txt +MessageSentThreadOccurance=50 diff --git a/aai-resources/bundleconfig-local/etc/appprops/aaiconfig.properties b/aai-resources/bundleconfig-local/etc/appprops/aaiconfig.properties new file mode 100644 index 0000000..46f9856 --- /dev/null +++ b/aai-resources/bundleconfig-local/etc/appprops/aaiconfig.properties @@ -0,0 +1,123 @@ +#################################################################### +# REMEMBER TO THINK ABOUT ENVIRONMENTAL DIFFERENCES AND CHANGE THE +# TEMPLATE AND *ALL* DATAFILES +#################################################################### + +aai.config.checktime=1000 + +# this could come from siteconfig.pl? +aai.config.nodename=AutomaticallyOverwritten + +aai.logging.hbase.interceptor=true +aai.logging.hbase.enabled=true +aai.logging.hbase.logrequest=true +aai.logging.hbase.logresponse=true + +aai.logging.trace.enabled=true +aai.logging.trace.logrequest=false +aai.logging.trace.logresponse=false + +aai.transaction.logging=true +aai.transaction.logging.get=true +aai.transaction.logging.post=true + + +ecm.openstack.tenantid=b0a529aba48440a39e0caf1aea9b27e3 + +aai.avpn.interim.laginterface=ae0 + +aai.server.url.base=https://localhost:8443/aai/ +aai.server.url=https://localhost:8443/aai/v10/ +aai.global.callback.url=https://localhost:8443/aai/ + +aai.auth.cspcookies_on=false +aai.dbmodel.filename=ex5.json +aai.truststore.filename=aai_keystore +aai.truststore.passwd.x=OBF:1vn21ugu1saj1v9i1v941sar1ugw1vo0 +aai.keystore.filename=aai-client-cert.p12 +aai.keystore.passwd.x= + +# for transaction log +hbase.table.name=aailogging-dev1.dev +hbase.notificationTable.name=aainotification-dev1.dev +hbase.table.timestamp.format=YYYYMMdd-HH:mm:ss:SSS +hbase.zookeeper.quorum=ONAPserverTBD +hbase.zookeeper.property.clientPort=2181 +hbase.zookeeper.znode.parent=/hbase + +# pin up a skeleton if it's not found + +aai.precheck.cloudinfrastructure.complex.defaults.physicalLocationType=AAIDefault +aai.precheck.cloudinfrastructure.complex.defaults.street1=AAIDefault +aai.precheck.cloudinfrastructure.complex.defaults.city=AAIDefault +aai.precheck.cloudinfrastructure.complex.defaults.state=NJ +aai.precheck.cloudinfrastructure.complex.defaults.postalCode=07748 +aai.precheck.cloudinfrastructure.complex.defaults.country=USA +aai.precheck.cloudinfrastructure.complex.defaults.region=US + +# single primary server +aai.primary.filetransfer.serverlist=ONAPserverTBD +aai.primary.filetransfer.primarycheck=echo:8443/aai/util/echo +aai.primary.filetransfer.pingtimeout=5000 +aai.primary.filetransfer.pingcount=5 + +#rsync properties +aai.rsync.command=rsync +aai.rsync.options.list=-v|-t +aai.rsync.remote.user=aaiadmin +aai.rsync.enabled=y + +#Service Specific Data Values +aai.servicedescription.hostedcomm=HOSTED COMMUNICATIONS +aai.servicedescription.mobility=MOBILITY +aai.servicedescription.vusp=VIRTUAL USP +aai.servicedescription.vvig=vVIGaaS +aai.servicedescription.lrsi=LRSI-OSPF + +aai.notification.current.version=v10 +aai.notificationEvent.default.status=UNPROCESSED +aai.notificationEvent.default.eventType=AAI-EVENT +aai.notificationEvent.default.domain=devINT1 +aai.notificationEvent.default.sourceName=aai +aai.notificationEvent.default.sequenceNumber=0 +aai.notificationEvent.default.severity=NORMAL +aai.notificationEvent.default.version=v10 +# This one lets us enable/disable resource-version checking on updates/deletes +aai.resourceversion.enableflag=true +aai.logging.maxStackTraceEntries=10 +aai.default.api.version=v10 + +# Used by Model-processing code +aai.model.delete.sleep.per.vtx.msec=500 +aai.model.query.resultset.maxcount=50 +aai.model.query.timeout.sec=90 + +# Used by Data Grooming +aai.grooming.default.max.fix=150 +aai.grooming.default.sleep.minutes=7 + +# Used by DupeTool +aai.dupeTool.default.max.fix=25 +aai.dupeTool.default.sleep.minutes=7 + +aai.model.proc.max.levels=50 +aai.edgeTag.proc.max.levels=50 + +# Used by the ForceDelete tool +aai.forceDel.protected.nt.list=cloud-region +aai.forceDel.protected.edge.count=10 +aai.forceDel.protected.descendant.count=10 + +# Used for CTAG-Pool generation +aai.ctagPool.rangeString.vplsPe1=2001-2500 +aai.ctagPool.rangeString.vplsPe2=2501-3000 +aai.ctagPool.rangeString.vpe=3001-3500 + +aai.dmaap.workload.enableEventProcessing=true + +aai.realtime.clients=RO,SDNC,MSO + +aai.server.rebind=g + +# This is a fake one just for test so please ignore +ecm.auth.password.x=OBF:1igd1i9a1jnb1yte1vv11vu91yt81jk71i6o1idt diff --git a/aai-resources/bundleconfig-local/etc/appprops/app-intercepts.properties b/aai-resources/bundleconfig-local/etc/appprops/app-intercepts.properties new file mode 100644 index 0000000..3230921 --- /dev/null +++ b/aai-resources/bundleconfig-local/etc/appprops/app-intercepts.properties @@ -0,0 +1,6 @@ +#This is where all your application intercept strategies must be configured. AJSC reads this property file and adds +#the list of intercepts specified here to the camel context. This can be useful for accessing every exchange object transferred from/to +#each endpoint in the request/response flow and can allow for more precise debugging and/or processing of the exchange. + +#e.g. +#intercepts=org.openecomp.aai.ajsc_aai.JaxrsEchoService,packagename.class1name,packagename.class2name diff --git a/aai-resources/bundleconfig-local/etc/appprops/caet.properties b/aai-resources/bundleconfig-local/etc/appprops/caet.properties new file mode 100644 index 0000000..e69de29 diff --git a/aai-resources/bundleconfig-local/etc/appprops/createDBSchema-logback.xml b/aai-resources/bundleconfig-local/etc/appprops/createDBSchema-logback.xml new file mode 100644 index 0000000..937324e --- /dev/null +++ b/aai-resources/bundleconfig-local/etc/appprops/createDBSchema-logback.xml @@ -0,0 +1,108 @@ + + + + + + + + WARN + + ${logDirectory}/createDBSchema/error.log + + ${logDirectory}/createDBSchema/error.log.%d{yyyy-MM-dd} + + + ${eelfLogPattern} + + + + + + DEBUG + ACCEPT + DENY + + ${logDirectory}/createDBSchema/debug.log + + ${logDirectory}/createDBSchema/debug.log.%d{yyyy-MM-dd} + + + ${eelfLogPattern} + + + + + + INFO + ACCEPT + DENY + + ${logDirectory}/createDBSchema/metrics.log + + ${logDirectory}/createDBSchema/metrics.log.%d{yyyy-MM-dd} + + + ${eelfMetricLogPattern} + + + + + %-4relative [%thread] %-5level %logger{35} - %msg %n + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/aai-resources/bundleconfig-local/etc/appprops/dataGrooming-logback.xml b/aai-resources/bundleconfig-local/etc/appprops/dataGrooming-logback.xml new file mode 100644 index 0000000..966ec4c --- /dev/null +++ b/aai-resources/bundleconfig-local/etc/appprops/dataGrooming-logback.xml @@ -0,0 +1,115 @@ + + + + + + + + WARN + + ${logDirectory}/dataGrooming/error.log + + ${logDirectory}/dataGrooming/error.log.%d{yyyy-MM-dd} + + + ${eelfLogPattern} + + + + + + DEBUG + ACCEPT + DENY + + ${logDirectory}/dataGrooming/debug.log + + ${logDirectory}/dataGrooming/debug.log.%d{yyyy-MM-dd} + + + ${eelfLogPattern} + + + + + + INFO + ACCEPT + DENY + + ${logDirectory}/dataGrooming/metrics.log + + ${logDirectory}/dataGrooming/metrics.log.%d{yyyy-MM-dd} + + + ${eelfMetricLogPattern} + + + + + %-4relative [%thread] %-5level %logger{35} - %msg %n + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/aai-resources/bundleconfig-local/etc/appprops/dataSnapshot-logback.xml b/aai-resources/bundleconfig-local/etc/appprops/dataSnapshot-logback.xml new file mode 100644 index 0000000..40e729a --- /dev/null +++ b/aai-resources/bundleconfig-local/etc/appprops/dataSnapshot-logback.xml @@ -0,0 +1,116 @@ + + + + + + + + WARN + + ${logDirectory}/dataSnapshot/error.log + + ${logDirectory}/dataSnapshot/error.log.%d{yyyy-MM-dd} + + + ${eelfLogPattern} + + + + + + DEBUG + ACCEPT + DENY + + ${logDirectory}/dataSnapshot/debug.log + + ${logDirectory}/dataSnapshot/debug.log.%d{yyyy-MM-dd} + + + ${eelfLogPattern} + + + + + + INFO + ACCEPT + DENY + + ${logDirectory}/dataSnapshot/metrics.log + + ${logDirectory}/dataSnapshot/metrics.log.%d{yyyy-MM-dd} + + + ${eelfMetricLogPattern} + + + + + %-4relative [%thread] %-5level %logger{35} - %msg %n + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/aai-resources/bundleconfig-local/etc/appprops/default-logback.xml b/aai-resources/bundleconfig-local/etc/appprops/default-logback.xml new file mode 100644 index 0000000..0dc841d --- /dev/null +++ b/aai-resources/bundleconfig-local/etc/appprops/default-logback.xml @@ -0,0 +1,20 @@ + + + + + + ${defaultPattern} + + + + + + + + + + + + + + diff --git a/aai-resources/bundleconfig-local/etc/appprops/deltool-logback.xml b/aai-resources/bundleconfig-local/etc/appprops/deltool-logback.xml new file mode 100644 index 0000000..8a138c6 --- /dev/null +++ b/aai-resources/bundleconfig-local/etc/appprops/deltool-logback.xml @@ -0,0 +1,100 @@ + + + + + + + + WARN + + ${logDirectory}/delTool/error.log + + ${logDirectory}/delTool/error.log.%d{yyyy-MM-dd} + + + ${eelfLogPattern} + + + + + + DEBUG + ACCEPT + DENY + + ${logDirectory}/delTool/debug.log + + ${logDirectory}/delTool/debug.log.%d{yyyy-MM-dd} + + + ${eelfLogPattern} + + + + + + INFO + ACCEPT + DENY + + ${logDirectory}/delTool/metrics.log + + ${logDirectory}/delTool/metrics.log.%d{yyyy-MM-dd} + + + ${eelfMetricLogPattern} + + + + + %-4relative [%thread] %-5level %logger{35} - %msg %n + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/aai-resources/bundleconfig-local/etc/appprops/dupeTool-logback.xml b/aai-resources/bundleconfig-local/etc/appprops/dupeTool-logback.xml new file mode 100644 index 0000000..aa5bd2e --- /dev/null +++ b/aai-resources/bundleconfig-local/etc/appprops/dupeTool-logback.xml @@ -0,0 +1,62 @@ + + + + + + INFO + ACCEPT + DENY + + + + + logFilenameAppender + undefined + + + + + ${logDirectory}/dupeTool/${logFilenameAppender}.log + + ${logDirectory}/dupeTool/${logFilenameAppender}.log.%d{yyyy-MM-dd} + + + + %d{yyyy-MM-dd'T'HH:mm:ss.SSSXXX}|%m%n + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/aai-resources/bundleconfig-local/etc/appprops/error.properties b/aai-resources/bundleconfig-local/etc/appprops/error.properties new file mode 100644 index 0000000..4e98d62 --- /dev/null +++ b/aai-resources/bundleconfig-local/etc/appprops/error.properties @@ -0,0 +1,163 @@ +# Adding comment trying to trigger a build +#------------------------------------------------------------------------------- ---------- +#Key=Disposition:Category:Severity:Error Code:HTTP ResponseCode:RESTError Code:Error Message +#------------------------------------------------------------------------------- ---------- +# testing code, please don't change unless error utility source code changes +AAI_TESTING=5:2:WARN:0000:400:0001:Error code for testing + +# General success +AAI_0000=0:0:INFO:0000:200:0000:Success + +# health check success +AAI_0001=0:0:INFO:0001:200:0001:Success X-FromAppId=%1 X-TransactionId=%2 +AAI_0002=0:0:INFO:0002:200:0001:Successful health check + +# Success with additional info +AAI_0003=0:3:INFO:0003:202:0003:Success with additional info performing %1 on %2. Added %3 with key %4 +AAI_0004=0:3:INFO:0004:202:0003:Added prerequisite object to db + +#--- aairest: 3000-3299 +# svc errors +AAI_3000=5:2:INFO:3000:400:3000:Invalid input performing %1 on %2 +AAI_3001=5:6:INFO:3001:404:3001:Resource not found for %1 using id %2 +AAI_3002=5:1:WARN:3002:400:3002:Error writing output performing %1 on %2 +AAI_3003=5:1:WARN:3003:400:3003:Failed to make edge to missing target node of type %3 with keys %4 performing %1 on %2 +AAI_3005=5:6:WARN:3005:404:3001:Node cannot be directly accessed for read, must be accessed via ancestor(s) +AAI_3006=5:6:WARN:3006:404:3001:Node cannot be directly accessed for write, must be accessed via ancestor(s) +AAI_3007=5:6:INFO:3007:410:3007:This version (%1) of the API is retired, please migrate to %2 +AAI_3008=5:6:ERROR:3008:400:3008:URI is not encoded in UTF-8 +AAI_3009=5:6:ERROR:3009:400:3002:Malformed URL +# pol errors +AAI_3100=5:1:WARN:3100:400:3100:Unsupported operation %1 +AAI_3101=5:1:WARN:3101:403:3101:Attempt by client %1 to execute API %2 +AAI_3102=5:1:WARN:3102:400:3102:Error parsing input performing %1 on %2 +AAI_3300=5:1:WARN:3300:403:3300:Unauthorized +AAI_3301=5:1:WARN:3301:401:3301:Stale credentials +AAI_3302=5:1:WARN:3302:401:3301:Not authenticated +AAI_3303=5:1:ERROR:3303:403:3300:Too many objects would be returned by this request, please refine your request and retry + +#--- aaigen: 4000-4099 +AAI_4000=5:4:ERROR:4000:500:3002:Internal Error +AAI_4001=5:4:FATAL:4001:500:3002:Configuration file not found +AAI_4002=5:4:FATAL:4002:500:3002:Error reading Configuration file +AAI_4003=5:4:ERROR:4003:500:3002:Error writing to log file +AAI_4004=5:4:FATAL:4004:500:3002:Error reading/parsing the error properties file +AAI_4005=5:4:FATAL:4005:500:3002:Missing or invalid configuration parameter +AAI_4006=5:4:FATAL:4006:500:3002:Unexpected error in service +AAI_4007=5:4:ERROR:4007:500:3102:Input parsing error +AAI_4008=5:4:ERROR:4008:500:3002:Output parsing error +AAI_4009=4:0:ERROR:4009:400:3000:Invalid X-FromAppId in header +AAI_4010=4:0:ERROR:4010:400:3000:Invalid X-TransactionId in header +AAI_4011=5:4:ERROR:4011:500:3002:Missing data for REST error response +AAI_4012=5:4:ERROR:4012:500:3002:Bad rule data in RestRules +AAI_4013=5:4:ERROR:4013:500:3002:Error connecting to AAI REST API +AAI_4014=4:0:ERROR:4014:400:3000:Invalid Accept header +AAI_4015=4:0:ERROR:4015:400:3000:You must provide at least one indexed property +AAI_4016=4:0:ERROR:4016:400:3000:The depth parameter must be a number or the string "all" +AAI_4017=5:2:INFO:4017:400:3000:Could not set property +AAI_4018=5:2:ERROR:4018:400:3000:Unable to convert the string to integer +#--- aaidbmap: 5101-5199 +AAI_5101=5:4:FATAL:5101:500:3002:Could not connect to database +AAI_5102=5:4:FATAL:5102:500:3002:Graph database is null after open +AAI_5103=5:4:ERROR:5103:500:3002:Unexpected error during commit +AAI_5104=5:4:ERROR:5104:500:3002:Unexpected error during rollback +AAI_5105=5:4:ERROR:5105:500:3002:Unexpected error reading/updating database +AAI_5106=5:4:WARN:5106:404:3001:Node not found +AAI_5107=5:2:WARN:5107:400:3000:Required information missing +AAI_5108=5:2:WARN:5108:200:0:Unexpected information in request being ignored + +#--- aaidbgen: 6101-6199 +AAI_6101=5:4:ERROR:6101:500:3002:null TitanGraph object passed +AAI_6102=5:4:WARN:6102:400:3000:Passed-in property is not valid for this nodeType +AAI_6103=5:4:WARN:6103:400:3000:Required Node-property not found in input data +AAI_6104=5:4:WARN:6104:400:3000:Required Node-property was passed with no data +AAI_6105=5:4:WARN:6105:400:3000:Node-Key-Property not defined in DbMaps +AAI_6106=5:4:WARN:6106:400:3000:Passed-in property is not valid for this edgeType +AAI_6107=5:4:WARN:6107:400:3000:Required Edge-property not found in input data +AAI_6108=5:4:WARN:6108:400:3000:Required Edge-property was passed with no data +AAI_6109=5:4:WARN:6109:400:3000:Bad dependent Node value +AAI_6110=5:4:ERROR:6110:400:3100:Node cannot be deleted +AAI_6111=5:4:ERROR:6111:400:3000:JSON processing error +AAI_6112=5:4:ERROR:6112:400:3000:More than one node found by getUniqueNode() +AAI_6114=5:4:INFO:6114:404:3001:Node Not Found +AAI_6115=5:4:ERROR:6115:400:3000:Unrecognized NodeType +AAI_6116=5:4:ERROR:6116:400:3000:Unrecognized Property +AAI_6117=5:4:ERROR:6117:400:3000:Uniqueness constraint violated +AAI_6118=5:4:ERROR:6118:400:3000:Required Field not passed. +AAI_6120=5:4:ERROR:6120:400:3000:Bad Parameter Passed +AAI_6121=5:4:ERROR:6121:400:3000:Problem with internal AAI reference data +AAI_6122=5:4:ERROR:6122:400:3000:Data Set not complete in DB for this request +AAI_6123=5:4:ERROR:6123:500:3000:Bad Data found by DataGrooming Tool - Investigate +AAI_6124=5:4:ERROR:6124:500:3000:File read/write error +AAI_6125=5:4:WARN:6125:500:3000:Problem Pulling Data Set +AAI_6126=5:4:ERROR:6126:400:3000:Edge cannot be deleted +AAI_6127=5:4:INFO:6127:404:3001:Edge Not Found +AAI_6128=5:4:INFO:6128:500:3000:Unexpected error +AAI_6129=5:4:INFO:6129:404:3003:Error making edge to target node +AAI_6130=5:4:WARN:6130:412:3000:Precondition Required +AAI_6131=5:4:WARN:6131:412:3000:Precondition Failed +AAI_6132=5:4:WARN:6132:400:3000:Bad Model Definition +AAI_6133=5:4:WARN:6133:400:3000:Bad Named Query Definition +AAI_6134=5:4:ERROR:6134:500:6134:Could not persist transaction to storage back end. Exhausted retry amount +AAI_6135=5:4:WARN:6135:412:3000:Resource version specified on create +AAI_6136=5:4:ERROR:6136:400:3000:Object cannot hold multiple items +AAI_6137=5:4:ERROR:6137:400:3000:Cannot perform writes on multiple vertices +AAI_6138=5:4:ERROR:6138:400:3000:Cannot delete multiple vertices +AAI_6139=5:4:ERROR:6139:404:3000:Attempted to add edge to vertex that does not exist +AAI_6140=5:4:ERROR:6140:400:3000:Edge multiplicity violated +AAI_6141=5:4:WARN:6141:400:3000:Please Refine Query +AAI_6142=5:4:INFO:6142:400:3000:Retrying transaction +AAI_6143=5:4:INFO:6143:400:3000:Ghost vertex found +AAI_6144=5:4:WARN:6144:400:3000:Cycle found in graph +AAI_6145=5:4:ERROR:6145:400:3000:Cannot create a nested/containment edge via relationship + +#--- aaicsvp: 7101-7199 +AAI_7101=5:4:ERROR:7101:500:3002:Unexpected error in CSV file processing +AAI_7102=5:4:ERROR:7102:500:3002:Error in cleanup temporary directory +#AAI_7103=4:2:ERROR:7103:500:3002:Unsupported user +AAI_7104=5:4:ERROR:7104:500:3002:Failed to create directory +AAI_7105=5:4:ERROR:7105:500:3002:Temporary directory exists +AAI_7106=5:4:ERROR:7106:500:3002:Cannot delete +AAI_7107=5:4:ERROR:7107:500:3002:Input file does not exist +AAI_7108=5:4:ERROR:7108:500:3002:Output file does not exist +AAI_7109=5:4:ERROR:7109:500:3002:Error closing file +AAI_7110=5:4:ERROR:7110:500:3002:Error loading/reading properties file +AAI_7111=5:4:ERROR:7111:500:3002:Error executing shell script +AAI_7112=5:4:ERROR:7112:500:3002:Error creating output file +AAI_7113=5:4:ERROR:7113:500:3002:Trailer record error +AAI_7114=5:4:ERROR:7114:500:3002:Input file error +AAI_7115=5:4:ERROR:7115:500:3002:Unexpected error +AAI_7116=5:4:ERROR:7116:500:3002:Request error +AAI_7117=5:4:ERROR:7117:500:3002:Error in get http client object +AAI_7118=5:4:ERROR:7118:500:3002:Script Error +AAI_7119=5:4:ERROR:7119:500:3002:Unknown host + +#--- aaisdnc: 7201-7299 +AAI_7202=5:4:ERROR:7202:500:3002:Error getting connection to odl +AAI_7203=5:4:ERROR:7203:500:3002:Unexpected error calling DataChangeNotification API +AAI_7204=5:4:ERROR:7204:500:3002:Error returned by DataChangeNotification API +AAI_7205=5:4:ERROR:7205:500:3002:Unexpected error running notifySDNCOnUpdate +AAI_7206=5:4:ERROR:7206:500:3002:Invalid data returned from ODL + +#--- NotificationEvent, using UEB space +AAI_7350=5:4:ERROR:7305:500:3002:Notification event creation failed + +#--- aairestctlr: 7401-7499 +AAI_7401=5:4:ERROR:7401:500:3002:Error connecting to AAI REST API +AAI_7402=5:4:ERROR:7402:500:3002:Unexpected error +AAI_7403=5:4:WARN:7403:400:3001:Request error +AAI_7404=5:4:INFO:7404:404:3001:Node not found + +#--- aaiauth: 9101-9199 +AAI_9101=5:0:WARN:9101:403:3300:User is not authorized to perform function +AAI_9102=5:0:WARN:9102:401:3301:Refresh credentials from source +AAI_9103=5:0:WARN:9103:403:3300:User not found +AAI_9104=5:0:WARN:9104:401:3302:Authentication error +AAI_9105=5:0:WARN:9105:403:3300:Authorization error +AAI_9106=5:0:WARN:9106:403:3300:Invalid AppId +#AAI_9107=5:0:WARN:9107:403:3300:No Username in Request +AAI_9107=5:0:WARN:9107:403:3300:SSL is not provided in request, please contact admin + +#--- aaiinstar: 9201-9299 +AAI_9201=5:4:ERROR:9201:500:3002:Unable to send notification +AAI_9202=5:4:ERROR:9202:500:3002:Unable to start a thread diff --git a/aai-resources/bundleconfig-local/etc/appprops/forceDelete-logback.xml b/aai-resources/bundleconfig-local/etc/appprops/forceDelete-logback.xml new file mode 100644 index 0000000..7a31f8a --- /dev/null +++ b/aai-resources/bundleconfig-local/etc/appprops/forceDelete-logback.xml @@ -0,0 +1,62 @@ + + + + + + INFO + ACCEPT + DENY + + + + + logFilenameAppender + undefined + + + + + ${logDirectory}/forceDelete/${logFilenameAppender}.log + + ${logDirectory}/forceDelete/${logFilenameAppender}.log.%d{yyyy-MM-dd} + + + + %d{yyyy-MM-dd'T'HH:mm:ss.SSSXXX}|%m%n + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/aai-resources/bundleconfig-local/etc/appprops/getres-logback.xml b/aai-resources/bundleconfig-local/etc/appprops/getres-logback.xml new file mode 100644 index 0000000..3f05c17 --- /dev/null +++ b/aai-resources/bundleconfig-local/etc/appprops/getres-logback.xml @@ -0,0 +1,100 @@ + + + + + + + + WARN + + ${logDirectory}/getTool/error.log + + ${logDirectory}/getTool/error.log.%d{yyyy-MM-dd} + + + ${eelfLogPattern} + + + + + + DEBUG + ACCEPT + DENY + + ${logDirectory}/getTool/debug.log + + ${logDirectory}/getTool/debug.log.%d{yyyy-MM-dd} + + + ${eelfLogPattern} + + + + + + INFO + ACCEPT + DENY + + ${logDirectory}/getTool/metrics.log + + ${logDirectory}/getTool/metrics.log.%d{yyyy-MM-dd} + + + ${eelfMetricLogPattern} + + + + + %-4relative [%thread] %-5level %logger{35} - %msg %n + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/aai-resources/bundleconfig-local/etc/appprops/loadDataForDHV-logback.xml b/aai-resources/bundleconfig-local/etc/appprops/loadDataForDHV-logback.xml new file mode 100644 index 0000000..aa83408 --- /dev/null +++ b/aai-resources/bundleconfig-local/etc/appprops/loadDataForDHV-logback.xml @@ -0,0 +1,93 @@ + + + + + + WARN + + ${logDirectory}/loadDataForDHV/error.log + + ${logDirectory}/loadDataForDHV/error.log.%d{yyyy-MM-dd} + + + %m%n + + + + + + DEBUG + ACCEPT + DENY + + ${logDirectory}/loadDataForDHV/debug.log + + ${logDirectory}/loadDataForDHV/debug.log.%d{yyyy-MM-dd} + + + %m%n + + + + + + INFO + ACCEPT + DENY + + ${logDirectory}/loadDataForDHV/metrics.log + + ${logDirectory}/loadDataForDHV/metrics.log.%d{yyyy-MM-dd} + + + %m%n + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/aai-resources/bundleconfig-local/etc/appprops/logging.properties b/aai-resources/bundleconfig-local/etc/appprops/logging.properties new file mode 100644 index 0000000..e029cc4 --- /dev/null +++ b/aai-resources/bundleconfig-local/etc/appprops/logging.properties @@ -0,0 +1,128 @@ +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +handlers = 1catalina.org.apache.juli.FileHandler, 2localhost.org.apache.juli.FileHandler, 3manager.org.apache.juli.FileHandler, 4host-manager.org.apache.juli.FileHandler, java.util.logging.ConsoleHandler + +.handlers = 1catalina.org.apache.juli.FileHandler, java.util.logging.ConsoleHandler + +############################################################ +# Handler specific properties. +# Describes specific configuration info for Handlers. +############################################################ + +# this is where we will limit logging on components +org.apache.hadoop.level=WARNING +org.apache.zookeeper.level=WARNING +org.reflections.level=WARNING +com.thinkaurelius.level=WARNING + +1catalina.org.apache.juli.FileHandler.level = FINE +1catalina.org.apache.juli.FileHandler.directory = ${catalina.base}/logs +1catalina.org.apache.juli.FileHandler.prefix = catalina. + +2localhost.org.apache.juli.FileHandler.level = FINE +2localhost.org.apache.juli.FileHandler.directory = ${catalina.base}/logs +2localhost.org.apache.juli.FileHandler.prefix = localhost. + +3manager.org.apache.juli.FileHandler.level = FINE +3manager.org.apache.juli.FileHandler.directory = ${catalina.base}/logs +3manager.org.apache.juli.FileHandler.prefix = manager. + +4host-manager.org.apache.juli.FileHandler.level = FINE +4host-manager.org.apache.juli.FileHandler.directory = ${catalina.base}/logs +4host-manager.org.apache.juli.FileHandler.prefix = host-manager. + +java.util.logging.ConsoleHandler.level = INFO +java.util.logging.ConsoleHandler.formatter = java.util.logging.SimpleFormatter + + + +############################################################ +# Facility specific properties. +# Provides extra control for each logger. +############################################################ + +org.apache.catalina.core.ContainerBase.[Catalina].[localhost].level = INFO +org.apache.catalina.core.ContainerBase.[Catalina].[localhost].handlers = 2localhost.org.apache.juli.FileHandler + +org.apache.catalina.core.ContainerBase.[Catalina].[localhost].[/manager].level = INFO +org.apache.catalina.core.ContainerBase.[Catalina].[localhost].[/manager].handlers = 3manager.org.apache.juli.FileHandler + +org.apache.catalina.core.ContainerBase.[Catalina].[localhost].[/host-manager].level = INFO +org.apache.catalina.core.ContainerBase.[Catalina].[localhost].[/host-manager].handlers = 4host-manager.org.apache.juli.FileHandler + +# For example, set the org.apache.catalina.util.LifecycleBase logger to log +# each component that extends LifecycleBase changing state: +#org.apache.catalina.util.LifecycleBase.level = FINE + +# To see debug messages in TldLocationsCache, uncomment the following line: +#org.apache.jasper.compiler.TldLocationsCache.level = FINE + + +################################ +# OpenEJB/TomEE specific loggers +################################ +# +# ACTIVATE LEVEL/HANDLERS YOU WANT +# IF YOU ACTIVATE 5tomee.org.apache.juli.FileHandler +# ADD IT TO handlers LINE LIKE: +# +# handlers = 1catalina.org.apache.juli.FileHandler, 2localhost.org.apache.juli.FileHandler, 3manager.org.apache.juli.FileHandler, 4host-manager.org.apache.juli.FileHandler, 5tomee.org.apache.juli.FileHandler, java.util.logging.ConsoleHandler +# +# LEVELS: +# ======= +# +# OpenEJB.level = WARNING +# OpenEJB.options.level = INFO +# OpenEJB.server.level = INFO +# OpenEJB.startup.level = INFO +# OpenEJB.startup.service.level = WARNING +# OpenEJB.startup.config.level = INFO +# OpenEJB.hsql.level = INFO +# CORBA-Adapter.level = WARNING +# Transaction.level = WARNING +# org.apache.activemq.level = SEVERE +# org.apache.geronimo.level = SEVERE +# openjpa.level = WARNING +# OpenEJB.cdi.level = INFO +# org.apache.webbeans.level = INFO +# org.apache.openejb.level = FINE +# +# HANDLERS: +# ========= +# +# OpenEJB.handlers = 5tomee.org.apache.juli.FileHandler, java.util.logging.ConsoleHandler +# OpenEJB.options.handlers = 5tomee.org.apache.juli.FileHandler, java.util.logging.ConsoleHandler +# OpenEJB.server.handlers = 5tomee.org.apache.juli.FileHandler, java.util.logging.ConsoleHandler +# OpenEJB.startup.handlers = 5tomee.org.apache.juli.FileHandler, java.util.logging.ConsoleHandler +# OpenEJB.startup.service.handlers = 5tomee.org.apache.juli.FileHandler, java.util.logging.ConsoleHandler +# OpenEJB.startup.config.handlers = 5tomee.org.apache.juli.FileHandler, java.util.logging.ConsoleHandler +# OpenEJB.hsql.handlers = 5tomee.org.apache.juli.FileHandler, java.util.logging.ConsoleHandler +# CORBA-Adapter.handlers = 5tomee.org.apache.juli.FileHandler, java.util.logging.ConsoleHandler +# Transaction.handlers = 5tomee.org.apache.juli.FileHandler, java.util.logging.ConsoleHandler +# org.apache.activemq.handlers = 5tomee.org.apache.juli.FileHandler, java.util.logging.ConsoleHandler +# org.apache.geronimo.handlers = 5tomee.org.apache.juli.FileHandler, java.util.logging.ConsoleHandler +# openjpa.handlers = 5tomee.org.apache.juli.FileHandler, java.util.logging.ConsoleHandler +# OpenEJB.cdi.handlers = 5tomee.org.apache.juli.FileHandler, java.util.logging.ConsoleHandler +# org.apache.webbeans.handlers = 5tomee.org.apache.juli.FileHandler, java.util.logging.ConsoleHandler +# org.apache.openejb.handlers = 5tomee.org.apache.juli.FileHandler, java.util.logging.ConsoleHandler +# +# TOMEE HANDLER SAMPLE: +# ===================== +# +# 5tomee.org.apache.juli.FileHandler.level = FINEST +# 5tomee.org.apache.juli.FileHandler.directory = ${catalina.base}/logs +# 5tomee.org.apache.juli.FileHandler.prefix = tomee. + diff --git a/aai-resources/bundleconfig-local/etc/appprops/methodMapper.properties b/aai-resources/bundleconfig-local/etc/appprops/methodMapper.properties new file mode 100644 index 0000000..bcacfa6 --- /dev/null +++ b/aai-resources/bundleconfig-local/etc/appprops/methodMapper.properties @@ -0,0 +1,24 @@ +{ + "ActiveAndAvailableInventory-CloudNetwork" : [{ + "logicalName" : "getAAIResource", + "method" : "get", + "url" : "/aai/*" + }, { + "logicalName" : "putAAIResource", + "method" : "put", + "url" : "/aai/*" + }, { + "logicalName" : "deleteAAIResource", + "method" : "delete", + "url" : "/aai/*" + }, { + "logicalName" : "postAAIResource", + "method" : "post", + "url" : "/aai/*" + }, { + "logicalName" : "patchAAIResource", + "method" : "patch", + "url" : "/aai/*" + } + ] +} diff --git a/aai-resources/bundleconfig-local/etc/appprops/migration-logback.xml b/aai-resources/bundleconfig-local/etc/appprops/migration-logback.xml new file mode 100644 index 0000000..27626aa --- /dev/null +++ b/aai-resources/bundleconfig-local/etc/appprops/migration-logback.xml @@ -0,0 +1,62 @@ + + + + + + INFO + ACCEPT + DENY + + + + + logFilenameAppender + undefined + + + + + ${logDirectory}/migration/${logFilenameAppender}.log + + ${logDirectory}/migration/${logFilenameAppender}.log.%d{yyyy-MM-dd} + + + + %d{yyyy-MM-dd'T'HH:mm:ss.SSSXXX}|%m%n + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/aai-resources/bundleconfig-local/etc/appprops/notifysdnctool-logback.xml b/aai-resources/bundleconfig-local/etc/appprops/notifysdnctool-logback.xml new file mode 100644 index 0000000..4559557 --- /dev/null +++ b/aai-resources/bundleconfig-local/etc/appprops/notifysdnctool-logback.xml @@ -0,0 +1,93 @@ + + + + + + WARN + + ${logDirectory}/notifySDNCTool/error.log + + ${logDirectory}/notifySDNCTool/error.log.%d{yyyy-MM-dd} + + + %m%n + + + + + + DEBUG + ACCEPT + DENY + + ${logDirectory}/notifySDNCTool/debug.log + + ${logDirectory}/notifySDNCTool/debug.log.%d{yyyy-MM-dd} + + + %m%n + + + + + + INFO + ACCEPT + DENY + + ${logDirectory}/notifySDNCTool/metrics.log + + ${logDirectory}/notifySDNCTool/metrics.log.%d{yyyy-MM-dd} + + + %m%n + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/aai-resources/bundleconfig-local/etc/appprops/posttool-logback.xml b/aai-resources/bundleconfig-local/etc/appprops/posttool-logback.xml new file mode 100644 index 0000000..5ba965f --- /dev/null +++ b/aai-resources/bundleconfig-local/etc/appprops/posttool-logback.xml @@ -0,0 +1,100 @@ + + + + + + + + WARN + + ${logDirectory}/postTool/error.log + + ${logDirectory}/postTool/error.log.%d{yyyy-MM-dd} + + + ${eelfLogPattern} + + + + + + DEBUG + ACCEPT + DENY + + ${logDirectory}/postTool/debug.log + + ${logDirectory}/postTool/debug.log.%d{yyyy-MM-dd} + + + ${eelfLogPattern} + + + + + + INFO + ACCEPT + DENY + + ${logDirectory}/postTool/metrics.log + + ${logDirectory}/postTool/metrics.log.%d{yyyy-MM-dd} + + + ${eelfMetricLogPattern} + + + + + %-4relative [%thread] %-5level %logger{35} - %msg %n + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/aai-resources/bundleconfig-local/etc/appprops/preferredRoute.txt b/aai-resources/bundleconfig-local/etc/appprops/preferredRoute.txt new file mode 100644 index 0000000..662b0aa --- /dev/null +++ b/aai-resources/bundleconfig-local/etc/appprops/preferredRoute.txt @@ -0,0 +1 @@ +preferredRouteKey=MR1 \ No newline at end of file diff --git a/aai-resources/bundleconfig-local/etc/appprops/prov-logback.xml b/aai-resources/bundleconfig-local/etc/appprops/prov-logback.xml new file mode 100644 index 0000000..6a280ad --- /dev/null +++ b/aai-resources/bundleconfig-local/etc/appprops/prov-logback.xml @@ -0,0 +1,100 @@ + + + + + + + + WARN + + ${logDirectory}/provTool/error.log + + ${logDirectory}/provTool/error.log.%d{yyyy-MM-dd} + + + ${eelfLogPattern} + + + + + + DEBUG + ACCEPT + DENY + + ${logDirectory}/provTool/debug.log + + ${logDirectory}/provTool/debug.log.%d{yyyy-MM-dd} + + + ${eelfLogPattern} + + + + + + INFO + ACCEPT + DENY + + ${logDirectory}/provTool/metrics.log + + ${logDirectory}/provTool/metrics.log.%d{yyyy-MM-dd} + + + ${eelfMetricLogPattern} + + + + + %-4relative [%thread] %-5level %logger{35} - %msg %n + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/aai-resources/bundleconfig-local/etc/appprops/pullInvData-logback.xml b/aai-resources/bundleconfig-local/etc/appprops/pullInvData-logback.xml new file mode 100644 index 0000000..3cab017 --- /dev/null +++ b/aai-resources/bundleconfig-local/etc/appprops/pullInvData-logback.xml @@ -0,0 +1,105 @@ + + + + + + + + WARN + + ${logDirectory}/pullInvData/error.log + + ${logDirectory}/pullInvData/error.log.%d{yyyy-MM-dd} + + + ${eelfLogPattern} + + + + + + DEBUG + ACCEPT + DENY + + ${logDirectory}/pullInvData/debug.log + + ${logDirectory}/pullInvData/debug.log.%d{yyyy-MM-dd} + + + ${eelfLogPattern} + + + + + + INFO + ACCEPT + DENY + + ${logDirectory}/pullInvData/metrics.log + + ${logDirectory}/pullInvData/metrics.log.%d{yyyy-MM-dd} + + + ${eelfMetricLogPattern} + + + + + %-4relative [%thread] %-5level %logger{35} - %msg %n + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/aai-resources/bundleconfig-local/etc/appprops/puttool-logback.xml b/aai-resources/bundleconfig-local/etc/appprops/puttool-logback.xml new file mode 100644 index 0000000..45fafee --- /dev/null +++ b/aai-resources/bundleconfig-local/etc/appprops/puttool-logback.xml @@ -0,0 +1,100 @@ + + + + + + + + WARN + + ${logDirectory}/putTool/error.log + + ${logDirectory}/putTool/error.log.%d{yyyy-MM-dd} + + + ${eelfLogPattern} + + + + + + DEBUG + ACCEPT + DENY + + ${logDirectory}/putTool/debug.log + + ${logDirectory}/putTool/debug.log.%d{yyyy-MM-dd} + + + ${eelfLogPattern} + + + + + + INFO + ACCEPT + DENY + + ${logDirectory}/putTool/metrics.log + + ${logDirectory}/putTool/metrics.log.%d{yyyy-MM-dd} + + + ${eelfMetricLogPattern} + + + + + %-4relative [%thread] %-5level %logger{35} - %msg %n + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/aai-resources/bundleconfig-local/etc/appprops/rshiptool-logback.xml b/aai-resources/bundleconfig-local/etc/appprops/rshiptool-logback.xml new file mode 100644 index 0000000..a10ffd1 --- /dev/null +++ b/aai-resources/bundleconfig-local/etc/appprops/rshiptool-logback.xml @@ -0,0 +1,100 @@ + + + + + + + + WARN + + ${logDirectory}/rshipTool/error.log + + ${logDirectory}/rshipTool/error.log.%d{yyyy-MM-dd} + + + ${eelfLogPattern} + + + + + + DEBUG + ACCEPT + DENY + + ${logDirectory}/rshipTool/debug.log + + ${logDirectory}/rshipTool/debug.log.%d{yyyy-MM-dd} + + + ${eelfLogPattern} + + + + + + INFO + ACCEPT + DENY + + ${logDirectory}/rshipTool/metrics.log + + ${logDirectory}/rshipTool/metrics.log.%d{yyyy-MM-dd} + + + ${eelfMetricLogPattern} + + + + + %-4relative [%thread] %-5level %logger{35} - %msg %n + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/aai-resources/bundleconfig-local/etc/appprops/schemaMod-logback.xml b/aai-resources/bundleconfig-local/etc/appprops/schemaMod-logback.xml new file mode 100644 index 0000000..415a640 --- /dev/null +++ b/aai-resources/bundleconfig-local/etc/appprops/schemaMod-logback.xml @@ -0,0 +1,62 @@ + + + + + + INFO + ACCEPT + DENY + + + + + logFilenameAppender + undefined + + + + + ${logDirectory}/schemaMod/${logFilenameAppender}.log + + ${logDirectory}/schemaMod/${logFilenameAppender}.log.%d{yyyy-MM-dd} + + + + %d{yyyy-MM-dd'T'HH:mm:ss.SSSXXX}|%m%n + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/aai-resources/bundleconfig-local/etc/appprops/titan-cached.properties b/aai-resources/bundleconfig-local/etc/appprops/titan-cached.properties new file mode 100644 index 0000000..c866a9c --- /dev/null +++ b/aai-resources/bundleconfig-local/etc/appprops/titan-cached.properties @@ -0,0 +1,17 @@ +query.fast-property=true +# the following parameters are not reloaded automatically and require a manual bounce +storage.backend=inmemory +storage.hostname=localhost + +#schema.default=none +storage.lock.wait-time=300 +storage.hbase.table=aaigraph-dev1.dev +storage.hbase.ext.zookeeper.znode.parent=/hbase +#caching on +cache.db-cache = true +cache.db-cache-clean-wait = 20 +cache.db-cache-time = 180000 +cache.db-cache-size = 0.3 + +#load graphson file on startup +load.snapshot.file=false diff --git a/aai-resources/bundleconfig-local/etc/appprops/titan-realtime.properties b/aai-resources/bundleconfig-local/etc/appprops/titan-realtime.properties new file mode 100644 index 0000000..8acd0bd --- /dev/null +++ b/aai-resources/bundleconfig-local/etc/appprops/titan-realtime.properties @@ -0,0 +1,14 @@ +query.fast-property=true +# the following parameters are not reloaded automatically and require a manual bounce +storage.backend=inmemory +storage.hostname=localhost + +#schema.default=none +storage.lock.wait-time=300 +storage.hbase.table=aaigraph-dev1.dev +storage.hbase.ext.zookeeper.znode.parent=/hbase +# Setting db-cache to false ensure the fastest propagation of changes across servers +cache.db-cache = false + +#load graphson file on startup +load.snapshot.file=false diff --git a/aai-resources/bundleconfig-local/etc/appprops/uniquePropertyCheck-logback.xml b/aai-resources/bundleconfig-local/etc/appprops/uniquePropertyCheck-logback.xml new file mode 100644 index 0000000..b710b1c --- /dev/null +++ b/aai-resources/bundleconfig-local/etc/appprops/uniquePropertyCheck-logback.xml @@ -0,0 +1,62 @@ + + + + + + INFO + ACCEPT + DENY + + + + + logFilenameAppender + undefined + + + + + ${logDirectory}/uniquePropertyCheck/${logFilenameAppender}.log + + ${logDirectory}/uniquePropertyCheck/${logFilenameAppender}.log.%d{yyyy-MM-dd} + + + + %d{yyyy-MM-dd'T'HH:mm:ss.SSSXXX}|%m%n + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/aai-resources/bundleconfig-local/etc/appprops/updtool-logback.xml b/aai-resources/bundleconfig-local/etc/appprops/updtool-logback.xml new file mode 100644 index 0000000..ef6a9b2 --- /dev/null +++ b/aai-resources/bundleconfig-local/etc/appprops/updtool-logback.xml @@ -0,0 +1,100 @@ + + + + + + + + WARN + + ${logDirectory}/updTool/error.log + + ${logDirectory}/updTool/error.log.%d{yyyy-MM-dd} + + + ${eelfLogPattern} + + + + + + DEBUG + ACCEPT + DENY + + ${logDirectory}/updTool/debug.log + + ${logDirectory}/updTool/debug.log.%d{yyyy-MM-dd} + + + ${eelfLogPattern} + + + + + + INFO + ACCEPT + DENY + + ${logDirectory}/updTool/metrics.log + + ${logDirectory}/updTool/metrics.log.%d{yyyy-MM-dd} + + + ${eelfMetricLogPattern} + + + + + %-4relative [%thread] %-5level %logger{35} - %msg %n + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/aai-resources/bundleconfig-local/etc/auth/aai_keystore b/aai-resources/bundleconfig-local/etc/auth/aai_keystore new file mode 100644 index 0000000..3eef135 Binary files /dev/null and b/aai-resources/bundleconfig-local/etc/auth/aai_keystore differ diff --git a/aai-resources/bundleconfig-local/etc/service-file-monitor.properties b/aai-resources/bundleconfig-local/etc/service-file-monitor.properties new file mode 100644 index 0000000..4d9bee9 --- /dev/null +++ b/aai-resources/bundleconfig-local/etc/service-file-monitor.properties @@ -0,0 +1,5 @@ +#This properties file is used for defining any file paths that you would like to have monitored. + +#user config file paths go here as (key-value) pairs. File extension will have to be either .properties or .json in order for it to be monitored. +#file1=/opt/app/yourService/file.properties + diff --git a/aai-resources/bundleconfig-local/etc/sysprops/sys-props.properties b/aai-resources/bundleconfig-local/etc/sysprops/sys-props.properties new file mode 100644 index 0000000..8ae26b7 --- /dev/null +++ b/aai-resources/bundleconfig-local/etc/sysprops/sys-props.properties @@ -0,0 +1,138 @@ +#This file is used for defining AJSC system properties for different configuration schemes and is necessary for the AJSC to run properly. +#The sys-props.properties file is used for running locally. The template.sys-props.properties file will be used when deployed +#to a SOA/CSI Cloud node. + +#AJSC System Properties. The following properties are required for ALL AJSC services. If you are adding System Properties for your +#particular service, please add them AFTER all AJSC related System Properties. + +#For Cadi Authorization, use value="authentication-scheme-1 +CadiAuthN=authentication-scheme-1 + +#For Basic Authorization, use value="authentication-scheme-1 +authN=authentication-scheme-2 + +#Persistence used for AJSC meta-data storage. For most environments, "file" should be used. +ajscPersistence=file + +# If using hawtio for local development, these properties will allow for faster server startup and usage for local development +hawtio.authenticationEnabled=false +hawtio.config.pullOnStartup=false + +#Removes the extraneous restlet console output +org.restlet.engine.loggerFacadeClass=org.restlet.ext.slf4j.Slf4jLoggerFacade + +#server.host property to be enabled for local DME2 related testing +#server.host= + +#Enable/disable SSL (values=true/false). This property also determines which protocol to use (https if true, http otherwise), to register services into GRM through DME2. +enableSSL=false + +#Enable/disable csi logging (values=true/false). This can be disabled during local development +csiEnable=false + +#Enable/disable EJB Container +ENABLE_EJB=false + +#Enable/disable OSGI +isOSGIEnable=false + +#Configure JMS Queue (WMQ/TIBCO) +JMS_BROKER=WMQ + +#JMS properties needed for CSI Logging +JMS_TIBCO_PROVIDER_URL=ONAPserverTBD +JMS_LOGGER_USER_NAME=spm2 +JMS_LOGGER_PASSWORD=its4test +JMS_LOGGER_AUDIT_QUEUE_BINDING=pub.m2e.audit.logger.queue +JMS_LOGGER_PERF_QUEUE_BINDING=log.csi.performance02 + +#WMQ connectivity +JMS_WMQ_PROVIDER_URL=aftdsc://AFTUAT/34.07/-84.28 +JMS_WMQ_CONNECTION_FACTORY_NAME=aftdsc://AFTUAT/?service=CSILOG,version=1.0,bindingType=fusionBus,envContext=Q,Q25A=YES +JMS_WMQ_INITIAL_CONNECTION_FACTORY_NAME=com.att.aft.jms.FusionCtxFactory +JMS_WMQ_AUDIT_DESTINATION_NAME=queue:///CSILOGQL.M2E.DASHBOARD01.NOT.Q25A +JMS_WMQ_PERF_DESTINATION_NAME=queue:///CSILOGQL.M2E.PERFORMANCE01.NOT.Q25A + +server.port=8087 + +#CSI related variables for CSM framework +csm.hostname=d1a-m2e-q112m2e1.edc.cingular.net + +#Enable/disable endpoint level logging (values=true/false). This can be disabled during local development +endpointLogging=false + +#SOA_CLOUD_ENV is used to register your service with dme2 and can be turned off for local development (values=true/false). +SOA_CLOUD_ENV=false + +#CONTINUE_ON_LISTENER_EXCEPTION will exit the application if there is a DME2 exception at the time of registration. +CONTINUE_ON_LISTENER_EXCEPTION=false + +#Jetty Container ThreadCount Configuration Variables +AJSC_JETTY_ThreadCount_MIN=10 +AJSC_JETTY_ThreadCount_MAX=500 +AJSC_JETTY_IDLETIME_MAX=60000 +AJSC_JETTY_BLOCKING_QUEUE_SIZE=100 + +#Camel Context level default threadPool Profile configuration +CAMEL_POOL_SIZE=10 +CAMEL_MAX_POOL_SIZE=20 +CAMEL_KEEP_ALIVE_TIME=60 +CAMEL_MAX_QUEUE_SIZE=1000 + +#File Monitor configurations +ssf_filemonitor_polling_interval=5 +ssf_filemonitor_threadpool_size=10 + +#GRM/DME2 System Properties +AFT_DME2_CONN_IDLE_TIMEOUTMS=5000 +AJSC_ENV=SOACLOUD + +SOACLOUD_NAMESPACE=com.att.ajsc +SOACLOUD_ENV_CONTEXT=DEV +SOACLOUD_PROTOCOL=https +SOACLOUD_ROUTE_OFFER=DEFAULT + +AFT_LATITUDE=23.4 +AFT_LONGITUDE=33.6 +AFT_ENVIRONMENT=AFTUAT + +#Restlet Component Default Properties +RESTLET_COMPONENT_CONTROLLER_DAEMON=true +RESTLET_COMPONENT_CONTROLLER_SLEEP_TIME_MS=100 +RESTLET_COMPONENT_INBOUND_BUFFER_SIZE=8192 +RESTLET_COMPONENT_MIN_THREADS=1 +RESTLET_COMPONENT_MAX_THREADS=10 +RESTLET_COMPONENT_LOW_THREADS=8 +RESTLET_COMPONENT_MAX_QUEUED=0 +RESTLET_COMPONENT_MAX_CONNECTIONS_PER_HOST=-1 +RESTLET_COMPONENT_MAX_TOTAL_CONNECTIONS=-1 +RESTLET_COMPONENT_OUTBOUND_BUFFER_SIZE=8192 +RESTLET_COMPONENT_PERSISTING_CONNECTIONS=true +RESTLET_COMPONENT_PIPELINING_CONNECTIONS=false +RESTLET_COMPONENT_THREAD_MAX_IDLE_TIME_MS=60000 +RESTLET_COMPONENT_USE_FORWARDED_HEADER=false +RESTLET_COMPONENT_REUSE_ADDRESS=true + +#Externalized jar and properties file location. In CSI environments, there are a few libs that have been externalized to aid +#in CSTEM maintenance of the versions of these libs. The most important to the AJSC is the DME2 lib. Not only is this lib necessary +#for proper registration of your AJSC service on a node, but it is also necessary for running locally as well. Another framework +#used in CSI envs is the CSM framework. These 2 framework libs are shown as "provided" dependencies within the pom.xml. These +#dependencies will be copied into the target/commonLibs folder with the normal "mvn clean package" goal of the AJSC. They will +#then be added to the classpath via AJSC_EXTERNAL_LIB_FOLDERS system property. Any files (mainly property files) that need +#to be on the classpath should be added to the AJSC_EXTERNAL_PROPERTIES_FOLDERS system property. The default scenario when +#testing your AJSC service locally will utilize the target/commonLibs directory for DME2 and CSM related artifacts and 2 +#default csm properties files will be used for local testing with anything CSM knorelated. +#NOTE: we are using maven-replacer-plugin to replace "(doubleUnderscore)basedir(doubleUnderscore)" with ${basedir} within the +#target directory for running locally. Multiple folder locations can be separated by the pipe ("|") character. +#Please, NOTE: for running locally, we are setting this system property in the antBuild/build.xml "runLocal" target and in the +#"runAjsc" profile within the pom.xml. This is to most effectively use maven variables (${basedir}, most specifically. Therefore, +#when running locally, the following 2 properties should be set within the profile(s) themselves. +#Example: target/commonLibs|target/otherLibs +#AJSC_EXTERNAL_LIB_FOLDERS=__basedir__/target/commonLibs +#AJSC_EXTERNAL_PROPERTIES_FOLDERS=__basedir__/ajsc-shared-config/etc +#End of AJSC System Properties + +#Service System Properties. Please, place any Service related System Properties below. +KEY_STORE_PASSWORD=OBF:1vn21ugu1saj1v9i1v941sar1ugw1vo0 +KEY_MANAGER_PASSWORD=OBF:1vn21ugu1saj1v9i1v941sar1ugw1vo0 +AAI_CORE_VERSION=1.1.0-SNAPSHOT diff --git a/aai-resources/bundleconfig-local/etc/sysprops/template.sys-props.properties b/aai-resources/bundleconfig-local/etc/sysprops/template.sys-props.properties new file mode 100644 index 0000000..2239ecd --- /dev/null +++ b/aai-resources/bundleconfig-local/etc/sysprops/template.sys-props.properties @@ -0,0 +1,115 @@ +#This file is used for defining AJSC system properties for different configuration schemes and is necessary for the AJSC to run properly. +#The sys-props.properties file is used for running locally. + +#For Cadi Authorization, use value="authentication-scheme-1" +CadiAuthN=__AJSC_CADI_AUTHN__ + +#For Basic Authorization, use value="authentication-scheme-1" +authN=__AJSC_AUTH_SCHEME__ + +#Persistence used for AJSC meta-data storage. For most environments, "file" should be used. +ajscPersistence=__AJSC_PERSISTENCE__ + +#Configure externalized logback location +logback.configurationFile=__LOGBACK_CONFIG_FILE__ + +# If using hawtio for local development, these properties will allow for faster server startup and usage for local development. +# You may wish to deploy hawtio.war to dev/test environments to help debugging as well, but should not be used in PROD env. +hawtio.authenticationEnabled=__HAWTIO_AUTHENTICATION_ENABLED__ +hawtio.config.pullOnStartup=__HAWTIO_CONFIG_PULLONSTARTUP__ + +#Removes the extraneous restlet console output +org.restlet.engine.loggerFacadeClass=org.restlet.ext.slf4j.Slf4jLoggerFacade + +#Enable/disable SSL (values=true/false). +enableSSL=__AJSC_ENABLE_SSL__ + +#Enable/disable csi logging (values=true/false). +csiEnable=__CSI_ENABLE__ + +#Enable/disable EJB Container +ENABLE_EJB=__ENABLE_EJB__ + +#Enable/disable OSGI +isOSGIEnable=__OSGI_ENABLE__ + +#Configure JMS Queue (WMQ/TIBCO) +JMS_BROKER=WMQ + +#JMS properties needed for CSI Logging +JMS_TIBCO_PROVIDER_URL=ONAPserverTBD +JMS_LOGGER_USER_NAME=spm2 +JMS_LOGGER_PASSWORD=its4test +JMS_LOGGER_AUDIT_QUEUE_BINDING=pub.m2e.audit.logger.queue +JMS_LOGGER_PERF_QUEUE_BINDING=log.csi.performance02 + +#WMQ connectivity +JMS_WMQ_PROVIDER_URL=__JMS_WMQ_PROVIDER_URL__ +JMS_WMQ_CONNECTION_FACTORY_NAME=__JMS_WMQ_CONNECTION_FACTORY_NAME__ +JMS_WMQ_INITIAL_CONNECTION_FACTORY_NAME=__JMS_WMQ_INITIAL_CONNECTION_FACTORY_NAME__ +JMS_WMQ_AUDIT_DESTINATION_NAME=__JMS_WMQ_AUDIT_DESTINATION_NAME__ +JMS_WMQ_PERF_DESTINATION_NAME=__JMS_WMQ_PERF_DESTINATION_NAME__ + +#CSI related variables for CSM framework +csm.hostname=d1a-m2e-q112m2e1.edc.cingular.net + +#Enable/disable endpoint level logging (values=true/false). +endpointLogging=__END_POINT_LEVEL_LOGGING__ + +#SOA_CLOUD_ENV is used to register your service with dme2 (values=true/false). +SOA_CLOUD_ENV=__SOA_CLOUD_ENV__ + +#Jetty Container ThreadCount Configuration Variables +AJSC_JETTY_ThreadCount_MAX=__AJSC_JETTY_ThreadCount_MAX__ +AJSC_JETTY_ThreadCount_MIN=__AJSC_JETTY_ThreadCount_MIN__ +AJSC_JETTY_IDLETIME_MAX=__AJSC_JETTY_IDLETIME_MAX__ +AJSC_SERVICE_NAMESPACE=__AJSC_SERVICE_NAMESPACE__ +AJSC_SERVICE_VERSION=__AJSC_SERVICE_VERSION__ +AJSC_JETTY_BLOCKING_QUEUE_SIZE=100 + +#Camel Context level default threadPool Profile configuration +CAMEL_POOL_SIZE=__CAMEL_POOL_SIZE__ +CAMEL_MAX_POOL_SIZE=__CAMEL_MAX_POOL_SIZE__ +CAMEL_KEEP_ALIVE_TIME=__CAMEL_KEEP_ALIVE_TIME__ +CAMEL_MAX_QUEUE_SIZE=__CAMEL_MAX_QUEUE_SIZE__ + +#File Monitor configurations +ssf_filemonitor_polling_interval=__AJSC_SSF_FILE_MONITOR_POLLING_INTERVAL__ +ssf_filemonitor_threadpool_size=__AJSC_SSF_FILE_MONITOR_THREAD_POOL_SIZE__ + +#GRM/DME2 System Properties below +AFT_DME2_CONN_IDLE_TIMEOUTMS=__AFT_DME2_CONN_IDLE_TIMEOUTMS__ +AJSC_ENV=__AJSC_ENV__ +SOACLOUD_NAMESPACE=__SOA_CLOUD_NAMESPACE__ +SOACLOUD_ENV_CONTEXT=__SCLD_ENV__ +SOACLOUD_PROTOCOL=https +SOACLOUD_ROUTE_OFFER=__AAIENV__ +sslport=__AJSC_SSL_PORT__ +server.port=8087 +AFT_LATITUDE=__LATITUDE__ +AFT_LONGITUDE=__LONGITUDE__ +AFT_ENVIRONMENT=__AFT_ENVIRONMENT__ + +#Restlet Component Properties +RESTLET_COMPONENT_CONTROLLER_DAEMON=__RESTLET_COMPONENT_CONTROLLER_DAEMON__ +RESTLET_COMPONENT_CONTROLLER_SLEEP_TIME_MS=__RESTLET_COMPONENT_CONTROLLER_SLEEP_TIME_MS__ +RESTLET_COMPONENT_INBOUND_BUFFER_SIZE=__RESTLET_COMPONENT_INBOUND_BUFFER_SIZE__ +RESTLET_COMPONENT_MIN_THREADS=__RESTLET_COMPONENT_MIN_THREADS__ +RESTLET_COMPONENT_MAX_THREADS=__RESTLET_COMPONENT_MAX_THREADS__ +RESTLET_COMPONENT_LOW_THREADS=__RESTLET_COMPONENT_LOW_THREADS__ +RESTLET_COMPONENT_MAX_QUEUED=__RESTLET_COMPONENT_MAX_QUEUED__ +RESTLET_COMPONENT_MAX_CONNECTIONS_PER_HOST=__RESTLET_COMPONENT_MAX_CONNECTIONS_PER_HOST__ +RESTLET_COMPONENT_MAX_TOTAL_CONNECTIONS=__RESTLET_COMPONENT_MAX_TOTAL_CONNECTIONS__ +RESTLET_COMPONENT_OUTBOUND_BUFFER_SIZE=__RESTLET_COMPONENT_OUTBOUND_BUFFER_SIZE__ +RESTLET_COMPONENT_PERSISTING_CONNECTIONS=__RESTLET_COMPONENT_PERSISTING_CONNECTIONS__ +RESTLET_COMPONENT_PIPELINING_CONNECTIONS=__RESTLET_COMPONENT_PIPELINING_CONNECTIONS__ +RESTLET_COMPONENT_THREAD_MAX_IDLE_TIME_MS=__RESTLET_COMPONENT_THREAD_MAX_IDLE_TIME_MS__ +RESTLET_COMPONENT_USE_FORWARDED_HEADER=__RESTLET_COMPONENT_USE_FORWARDED_HEADER__ +RESTLET_COMPONENT_REUSE_ADDRESS=__RESTLET_COMPONENT_REUSE_ADDRESS__ + +AJSC_EXTERNAL_LIB_FOLDERS=__CSM_LIB__|__DME2_LIB__|__AJSC_EXTERNAL_LIB_FOLDERS__ +AJSC_EXTERNAL_PROPERTIES_FOLDERS=__AJSC_SHARED_CONFIG__|__AJSC_EXTERNAL_PROPERTIES_FOLDERS__ + +KEY_STORE_PASSWORD=__KEY_STORE_PASSWORD__ +KEY_MANAGER_PASSWORD=__KEY_MANAGER_PASSWORD__ +AAI_CORE_VERSION=1.1.0-SNAPSHOT diff --git a/aai-resources/bundleconfig-local/symlinks.txt b/aai-resources/bundleconfig-local/symlinks.txt new file mode 100644 index 0000000..70f2c0d --- /dev/null +++ b/aai-resources/bundleconfig-local/symlinks.txt @@ -0,0 +1,6 @@ +#This file provides the definitions of sym-links to CSTEM that will be used by your project once installed on a CSI node. + +link_jre=ajsc-shared-config +link_csi-csm=ajsc-shared-config +link_csi-dme=ajsc-shared-config +link_introscope=ajsc-shared-config diff --git a/aai-resources/pom.xml b/aai-resources/pom.xml new file mode 100644 index 0000000..e66b72b --- /dev/null +++ b/aai-resources/pom.xml @@ -0,0 +1,718 @@ + + + 4.0.0 + + org.openecomp.aai + aai-resources-service + 1.1.0-SNAPSHOT + + aai-resources + ajsc + http://maven.apache.org + + UTF-8 + 1.0.2 + + ${basedir}/target/swm/package/nix/dist_files/ + yyyyMMdd'T'HHmmss + 1.0.0 + 1.1.0-SNAPSHOT + java + jacoco + ${project.build.directory}/surefire-reports + ${project.build.directory}/coverage-reports/jacoco.exec + false + ${project.version} + + + + + org.openecomp.aai + aai-core + ${aai-core.version} + + + ajsc-runner + com.att.ajsc + + + + + org.openecomp.aai + aai-schema + ${aai-schema.version} + + + ajsc-runner + com.att.ajsc + + + + + com.rabbitmq + amqp-client + 3.6.1 + + + log4j + apache-log4j-extras + 1.2.17 + + + log4j + log4j + + + + + + commons-beanutils + commons-beanutils + 1.9.2 + + + + org.apache.commons + commons-compress + 1.10 + + + + commons-configuration + commons-configuration + 1.9 + + + commons-lang + commons-lang + + + + + + com.googlecode.java-diff-utils + diffutils + 1.3.0 + + + + org.codehaus.jackson + jackson-core-asl + 1.9.13 + + + + org.codehaus.jackson + jackson-mapper-asl + 1.9.13 + + + + com.thinkaurelius.titan + titan-cassandra + 0.5.3 + + + org.slf4j + slf4j-log4j12 + + + + + + + org.apache.httpcomponents + httpmime + 4.5.2 + + + + + com.att.ajsc + ajsc-runner + ${ajscRuntimeVersion} + + + com.att.ajsc + ajsc-core + ${ajscRuntimeVersion} + provided + + + + + + + dom4j + dom4j + 1.6.1 + + + + commons-lang + commons-lang + 2.6 + + + + + com.att.eelf + eelf-core + 1.0.0 + + + + ch.qos.logback + logback-core + 1.1.7 + + + + ch.qos.logback + logback-classic + 1.1.7 + + + + ch.qos.logback + logback-access + 1.1.7 + + + + org.hamcrest + hamcrest-junit + 2.0.0.0 + + + org.codehaus.janino + janino + 2.7.8 + + + commons-collections + commons-collections + + + + jdk.tools + jdk.tools + 1.8.0_101 + system + ${JAVA_HOME}/lib/tools.jar + + + + junit + junit + test + + + com.google.guava + guava + 16.0 + + + com.thinkaurelius.titan + titan-core + 1.0.0 + + + org.slf4j + slf4j-log4j12 + + + + + com.thinkaurelius.titan + titan-cassandra + 1.0.0 + + + org.slf4j + slf4j-log4j12 + + + + + com.thinkaurelius.titan + titan-hbase + 1.0.0 + + + org.slf4j + slf4j-log4j12 + + + + + + org.apache.tinkerpop + gremlin-driver + 3.0.1-incubating + + + org.apache.hbase + hbase-client + ${hbase.version} + + + org.slf4j + slf4j-log4j12 + + + log4j + log4j + + + + + org.apache.hbase + hbase-protocol + ${hbase.version} + + + log4j + log4j + + + + + org.apache.hbase + hbase-common + ${hbase.version} + + + log4j + log4j + + + + + com.opencsv + opencsv + 3.1 + + + jivesoftware + smack + 3.0.4 + + + + com.fasterxml.jackson.jaxrs + jackson-jaxrs-json-provider + 2.1.4 + + + com.googlecode.json-simple + json-simple + 1.1.1 + + + com.sun.jersey + jersey-client + 1.18 + + + org.springframework + spring-web + + + org.springframework.ws + spring-ws + 1.5.2 + + + + org.springframework + spring-core + 4.2.5.RELEASE + + + org.mockito + mockito-all + 1.10.19 + test + + + org.powermock + powermock-module-junit4 + 1.6.2 + test + + + org.powermock + powermock-api-mockito + 1.6.2 + test + + + com.beust + jcommander + 1.48 + + + org.json + json + 20090211 + + + org.freemarker + freemarker + 2.3.14 + + + javax.xml.bind + jaxb-api + 2.2.11 + + + com.sun.xml.bind + jaxb-impl + 2.2.11 + + + com.sun.xml.bind + jaxb-core + 2.2.11 + + + com.sun.xml.bind + jaxb-xjc + 2.2.11 + + + org.eclipse.persistence + eclipselink + 2.6.2 + + + org.eclipse.persistence + org.eclipse.persistence.moxy + 2.6.2 + compile + + + org.powermock + powermock-module-javaagent + 1.6.2 + test + + + org.powermock + powermock-module-junit4-rule-agent + 1.6.2 + test + + + com.github.fge + json-patch + 1.9 + + + org.javatuples + javatuples + 1.2 + compile + + + com.google.code.gson + gson + 2.7 + + + com.att.nsa + dmaapClient + 0.2.12 + + + org.apache.httpcomponents + httpcore + 4.4 + + + com.bazaarvoice.jolt + jolt-complete + 0.0.24 + + + com.jayway.jsonpath + json-path + 2.0.0 + + + + aai-resources + + + + org.jsonschema2pojo + jsonschema2pojo-maven-plugin + 0.4.13 + + jsonschema + src/main/resources/json + ${project.build.directory}/generated-sources + jackson2 + true + + + + org.apache.maven.plugins + maven-dependency-plugin + 2.8 + + + copy-agent + process-test-classes + + copy + + + + + org.powermock + powermock-module-javaagent + 1.6.2 + ${project.build.directory}/agents + powermock-javaagent.jar + + + + + + unpack-schema-dependency + initialize + + unpack + + + + + + + org.openecomp.aai + aai-schema + ${aai-schema.version} + bundleconfig-local/etc + oxm/*.xml + + + + + + + org.apache.maven.plugins + maven-surefire-plugin + 2.12.4 + + -javaagent:${project.build.directory}/agents/powermock-javaagent.jar + -noverify + + . + bundleconfig-local + + + + + org.codehaus.groovy.maven + gmaven-plugin + + + validate + + execute + + + + println project.properties['aai.project.version']; + def versionArray; + if ( project.properties['aai.project.version'] != null ) { + versionArray = project.properties['aai.project.version'].split('\\.'); + } + + if ( project.properties['aai.project.version'].endsWith("-SNAPSHOT") ) { + project.properties['project.docker.latesttag.version']=versionArray[0] + '.' + versionArray[1] + "-SNAPSHOT-latest"; + } else { + project.properties['project.docker.latesttag.version']=versionArray[0] + '.' + versionArray[1] + "-STAGING-latest"; + } + + println 'New Tag for docker:' + project.properties['project.docker.latesttag.version']; + + + + + + + org.apache.maven.plugins + maven-resources-plugin + 2.7 + + + copy-docker-file + package + + copy-resources + + + ${dockerLocation} + true + + + ${basedir}/src/main/resources/docker + true + + **/* + + + + + + + copy-commonlibs-file + package + + copy-resources + + + ${dockerLocation}/commonLibs + true + + + ${basedir}/target/commonLibs + false + + *.jar + + + + + + + + + io.fabric8 + docker-maven-plugin + 0.16.5 + + true + 1.23 + + + ${docker.push.registry}/openecomp/aai-resources:%l + + + ${project.docker.latesttag.version} + ${project.version}-STAGING-${maven.build.timestamp} + + try + ${dockerLocation} + ${dockerLocation}/Dockerfile + + + + + + + clean-images + pre-clean + + remove + + + true + openecomp/aai-resources:%l + + + + generate-images + generate-sources + + build + + + + push-images + deploy + + build + push + + + openecomp/aai-resources:%l + + + + + + + + + org.codehaus.mojo + sonar-maven-plugin + 3.2 + + + org.jacoco + jacoco-maven-plugin + 0.7.7.201606060606 + + true + + + + jacoco-initialize-unit-tests + + prepare-agent + + + ${project.build.directory}/coverage-reports/jacoco.exec + + + + + + + + + + + passwordGenerator + + initialize + + + org.codehaus.mojo + exec-maven-plugin + 1.3.2 + + + initialize + + java + + + org.eclipse.jetty.util.security.Password + + user + aaiDomain2 + + + + + + java + + + + + + + diff --git a/aai-resources/src/main/ajsc/ajsc-aai_v1/ajsc-aai/v1/conf/FileMonitorBeans.xml b/aai-resources/src/main/ajsc/ajsc-aai_v1/ajsc-aai/v1/conf/FileMonitorBeans.xml new file mode 100644 index 0000000..9e3e060 --- /dev/null +++ b/aai-resources/src/main/ajsc/ajsc-aai_v1/ajsc-aai/v1/conf/FileMonitorBeans.xml @@ -0,0 +1,20 @@ + + + + + + + + + + + + + + + + + + diff --git a/aai-resources/src/main/ajsc/ajsc-aai_v1/ajsc-aai/v1/conf/jaxrsBeans.groovy b/aai-resources/src/main/ajsc/ajsc-aai_v1/ajsc-aai/v1/conf/jaxrsBeans.groovy new file mode 100644 index 0000000..a54da81 --- /dev/null +++ b/aai-resources/src/main/ajsc/ajsc-aai_v1/ajsc-aai/v1/conf/jaxrsBeans.groovy @@ -0,0 +1,28 @@ +beans{ + xmlns cxf: "http://camel.apache.org/schema/cxf" + xmlns jaxrs: "http://cxf.apache.org/jaxrs" + xmlns util: "http://www.springframework.org/schema/util" + + LegacyMoxyConsumer(org.openecomp.aai.rest.LegacyMoxyConsumer) + URLFromVertexIdConsumer(org.openecomp.aai.rest.URLFromVertexIdConsumer) + VertexIdConsumer(org.openecomp.aai.rest.VertexIdConsumer) + BulkAddConsumer(org.openecomp.aai.rest.BulkAddConsumer) + BulkProcessConsumer(org.openecomp.aai.rest.BulkProcessConsumer) + ExampleConsumer(org.openecomp.aai.rest.ExampleConsumer) + V3ThroughV7Consumer(org.openecomp.aai.rest.retired.V3ThroughV7Consumer) + EchoResponse(org.openecomp.aai.rest.util.EchoResponse) + + + util.list(id: 'jaxrsServices') { + + ref(bean:'ExampleConsumer') + ref(bean:'LegacyMoxyConsumer') + ref(bean:'VertexIdConsumer') + ref(bean:'URLFromVertexIdConsumer') + ref(bean:'BulkAddConsumer') + ref(bean:'BulkProcessConsumer') + ref(bean:'V3ThroughV7Consumer') + + ref(bean:'EchoResponse') + } +} diff --git a/aai-resources/src/main/ajsc/ajsc-aai_v1/ajsc-aai/v1/conf/serviceBeans.xml b/aai-resources/src/main/ajsc/ajsc-aai_v1/ajsc-aai/v1/conf/serviceBeans.xml new file mode 100644 index 0000000..79fe736 --- /dev/null +++ b/aai-resources/src/main/ajsc/ajsc-aai_v1/ajsc-aai/v1/conf/serviceBeans.xml @@ -0,0 +1,100 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + JMS.BROKER.URL=tcp://localhost:61447 + JMS.QUEUE.NAME=IN_QUEUE + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/aai-resources/src/main/ajsc/ajsc-aai_v1/ajsc-aai/v1/docs/README.txt b/aai-resources/src/main/ajsc/ajsc-aai_v1/ajsc-aai/v1/docs/README.txt new file mode 100644 index 0000000..3707179 --- /dev/null +++ b/aai-resources/src/main/ajsc/ajsc-aai_v1/ajsc-aai/v1/docs/README.txt @@ -0,0 +1 @@ +Place any docs here that you want to access within the ajsc upon deployment of your service. diff --git a/aai-resources/src/main/ajsc/ajsc-aai_v1/ajsc-aai/v1/lib/README.txt b/aai-resources/src/main/ajsc/ajsc-aai_v1/ajsc-aai/v1/lib/README.txt new file mode 100644 index 0000000..639e21b --- /dev/null +++ b/aai-resources/src/main/ajsc/ajsc-aai_v1/ajsc-aai/v1/lib/README.txt @@ -0,0 +1 @@ +3rd party JAR's needed by your jars (if any) for a ajsc deployment package go here... \ No newline at end of file diff --git a/aai-resources/src/main/ajsc/ajsc-aai_v1/ajsc-aai/v1/props/module.props b/aai-resources/src/main/ajsc/ajsc-aai_v1/ajsc-aai/v1/props/module.props new file mode 100644 index 0000000..17ebc08 --- /dev/null +++ b/aai-resources/src/main/ajsc/ajsc-aai_v1/ajsc-aai/v1/props/module.props @@ -0,0 +1 @@ +EXAMPLE.PROPERTY=EXAMLE_VALUE \ No newline at end of file diff --git a/aai-resources/src/main/ajsc/ajsc-aai_v1/ajsc-aai/v1/routes/aai.route b/aai-resources/src/main/ajsc/ajsc-aai_v1/ajsc-aai/v1/routes/aai.route new file mode 100644 index 0000000..6a86246 --- /dev/null +++ b/aai-resources/src/main/ajsc/ajsc-aai_v1/ajsc-aai/v1/routes/aai.route @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/aai-resources/src/main/assemble/ajsc_module_assembly.xml b/aai-resources/src/main/assemble/ajsc_module_assembly.xml new file mode 100644 index 0000000..4ec4e28 --- /dev/null +++ b/aai-resources/src/main/assemble/ajsc_module_assembly.xml @@ -0,0 +1,66 @@ + + ${version} + false + + zip + + + + ${project.basedir}/target/versioned-ajsc/routes/ + ${module.ajsc.namespace.name}/${module.ajsc.namespace.version}/routes/ + + *.route + + + + + + ${project.basedir}/target/versioned-ajsc/docs/ + ${module.ajsc.namespace.name}/${module.ajsc.namespace.version}/docs/ + + *.* + + + + + + + ${project.basedir}/target/versioned-ajsc/lib/ + ${module.ajsc.namespace.name}/${module.ajsc.namespace.version}/lib/ + + *.jar + + + + + ${project.basedir}/target/versioned-ajsc/extJars/ + ${module.ajsc.namespace.name}/${module.ajsc.namespace.version}/extJars/ + + *.jar + + + + + + ${project.basedir}/target/ + ${module.ajsc.namespace.name}/${module.ajsc.namespace.version}/lib/ + + *.jar + + + + + ${project.basedir}/target/versioned-ajsc/conf/ + ${module.ajsc.namespace.name}/${module.ajsc.namespace.version}/conf/ + + *.* + + + + + + + diff --git a/aai-resources/src/main/assemble/ajsc_props_assembly.xml b/aai-resources/src/main/assemble/ajsc_props_assembly.xml new file mode 100644 index 0000000..5b8a6fa --- /dev/null +++ b/aai-resources/src/main/assemble/ajsc_props_assembly.xml @@ -0,0 +1,23 @@ + + ${version}_properties + false + + zip + + + + ${project.basedir}/target/versioned-ajsc/props + ${module.ajsc.namespace.name}/${module.ajsc.namespace.version}/props/ + + *.props + + + + + + + + diff --git a/aai-resources/src/main/assemble/ajsc_runtime_assembly.xml b/aai-resources/src/main/assemble/ajsc_runtime_assembly.xml new file mode 100644 index 0000000..e37d366 --- /dev/null +++ b/aai-resources/src/main/assemble/ajsc_runtime_assembly.xml @@ -0,0 +1,44 @@ + + runtimeEnvironment + false + + zip + + + + ${project.basedir}/target/versioned-runtime/context/ + runtime/context/ + + *.context + + + + ${project.basedir}/target/versioned-runtime/serviceProperties/ + runtime/serviceProperties/ + + *.props + + + ${project.basedir}/target/versioned-runtime/shiroRole + runtime/shiroRole/ + + *.json + + + ${project.basedir}/target/versioned-runtime/shiroUser + runtime/shiroUser/ + + *.json + + + ${project.basedir}/target/versioned-runtime/shiroUserRole + runtime/shiroUserRole + + *.json + + + + \ No newline at end of file diff --git a/aai-resources/src/main/config/ajsc-jetty.xml b/aai-resources/src/main/config/ajsc-jetty.xml new file mode 100644 index 0000000..0bba44b --- /dev/null +++ b/aai-resources/src/main/config/ajsc-jetty.xml @@ -0,0 +1,155 @@ + + + + + + + true + + + /etc/runner-web.xml + /etc/ajsc-override-web.xml + true + + + false + + + + /extJars/aai-core-.jar, + /extJars/aai-resources.jar, + /extJars/logback-core-1.1.7.jar, + /extJars/logback-access-1.1.7.jar, + /extJars/eelf-core-1.0.0.jar, + /extJars/slf4j-api-1.7.21.jar + + + + + + + + + + + + + + + + + + + + + + + + /bundleconfig/etc/localhost-access-logback.xml + + + + + + + + + + + + + + + + + + + /extApps + 10 + true + + + + + + + + + + + + + + + + + + + + http/1.1 + + + file:/bundleconfig/etc/auth/aai_keystore + + + + + + + + + + + false + + + + + + + + + + + + + + + + + + + + + 30000 + + + + + + + + + false + + + + + Test Realm + /etc/realm.properties + 5 + + + + + diff --git a/aai-resources/src/main/config/ajsc-jolokia-override-web.xml b/aai-resources/src/main/config/ajsc-jolokia-override-web.xml new file mode 100644 index 0000000..b242129 --- /dev/null +++ b/aai-resources/src/main/config/ajsc-jolokia-override-web.xml @@ -0,0 +1,46 @@ + + + + + InterceptorFilter + /services/* + + + InterceptorFilter + /rest/* + + + + springSecurityFilterChain + /* + + + + ManagementServlet + /mgmt + + + + RestletServlet + /rest/* + + + + CamelServlet + /services/* + + + + jolokia-agent + org.jolokia.http.AgentServlet + 2 + + + + jolokia-agent + /jolokia/* + + + \ No newline at end of file diff --git a/aai-resources/src/main/config/ajsc-override-web.xml b/aai-resources/src/main/config/ajsc-override-web.xml new file mode 100644 index 0000000..61e2836 --- /dev/null +++ b/aai-resources/src/main/config/ajsc-override-web.xml @@ -0,0 +1,41 @@ + + + + + WriteableRequestFilter + /* + + + InterceptorFilter + /* + + + InterceptorFilter + /rest/* + + + + springSecurityFilterChain + /* + + + + ManagementServlet + /mgmt + + + + RestletServlet + /rest/* + + + + CamelServlet + /* + + + + + \ No newline at end of file diff --git a/aai-resources/src/main/config/ajsc-request.xml b/aai-resources/src/main/config/ajsc-request.xml new file mode 100644 index 0000000..5d09b7a --- /dev/null +++ b/aai-resources/src/main/config/ajsc-request.xml @@ -0,0 +1,49 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/aai-resources/src/main/config/caet.properties b/aai-resources/src/main/config/caet.properties new file mode 100644 index 0000000..e69de29 diff --git a/aai-resources/src/main/config/hazelcast-client.properties b/aai-resources/src/main/config/hazelcast-client.properties new file mode 100644 index 0000000..2624d3f --- /dev/null +++ b/aai-resources/src/main/config/hazelcast-client.properties @@ -0,0 +1,25 @@ +# +# Copyright (c) 2008-2013, Hazelcast, Inc. All Rights Reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +hazelcast.client.group.name = ajsc +hazelcast.client.group.pass = ajscpass +hazelcast.client.connection.timeout = 30000 +hazelcast.client.connection.attempts.limit = 3 +hazelcast.client.reconnection.timeout = 5000 +hazelcast.client.reconnection.attempts.limit= 5 +hazelcast.client.shuffle.addresses = false +hazelcast.client.update.automatic = true +hazelcast.client.addresses = localhost, 127.0.0.1 \ No newline at end of file diff --git a/aai-resources/src/main/config/jul-redirect.properties b/aai-resources/src/main/config/jul-redirect.properties new file mode 100644 index 0000000..8b6624d --- /dev/null +++ b/aai-resources/src/main/config/jul-redirect.properties @@ -0,0 +1,13 @@ + +# Bridge JUL->slf4j Logging Configuration File +# +# This file bridges the JUL logging infrastructure into +# SLF4J so JUL logs go to logback implementation provided +# in this project. SLF4J also captures log4j and has +# other framework options as well providing a common +# logging infrastructure for capturing all logs from different +# libraries using different frameworks in one place. + +# Global properties +handlers=org.slf4j.bridge.SLF4JBridgeHandler +.level= ALL diff --git a/aai-resources/src/main/config/keyfile b/aai-resources/src/main/config/keyfile new file mode 100644 index 0000000..6a1657e --- /dev/null +++ b/aai-resources/src/main/config/keyfile @@ -0,0 +1,27 @@ +ctRt8XTd7N57kcm0npZOWSDF5I69w9K97cQS_ep0AgxgHmYB0WtYblsrMGuHfyS1o4697zLiIeoS +Nn5kE1kedl4c4HevfuwfoJpWyiugYusNOqbTGQJ1MHOwqiBEJnjXepZEoz1btaW_hDO7uz-BoD4t +SxwNRwVQpcg0_CmBX-yIW2YCIECoxZH9_X_8fcXYHP2VgFxxBpvjgycNQlyN15_VSuLwn3Wj0W8_ +8chRxGURyhp8iEBSb4tIdN5jXkhCma7AP7wreMufFQqXjdfWqIisJPfIpS3znl5IiTOZP22XhHay +gq2KFwABVqjM71m5czEz1ojGkbFEAGImrY-VFHuug2u4ss4VW7TGeJst0z7I5vrn5M6i9Eb6xiGh +jNUebRCV3cYGrtD9SlvjJBVVeP_3OrkxlD4oktx-JTRJzYtXADB5if2gtpYxy84kqrz7ltr5rXUH +zSG7ujKCXOOE_Wk6vQPSjYPnum6R_mxOorCNCvtf6ne85Xd81DZlJM-CleVNdOU7g1xie-gBZPAX +bOvWf6p_pVNmH76v-m4XLAAUqEzt-9PvNmirODiDiY5bNz6l-1ejw8IyQYb37e_3sN_LjF7A9HgB +Dia7kNjsfB7_2vB7R4qjwNLsmTMnQCDANnNpl9VpotZ4blPhhOWhB1Tg3lxc-z-VRV7GBbl_2eQd +3eYUT1Z5Li184W4-pft_TCaDJ1NyaJd1CQxQEuIORdq5B6Q2L9SMmmOOh82Czu5_Ro80IGikHXHp +Lqf2fIaceY_IBAeGp2iPjtXdkghV24vIT49oRfqf6sBKAPy-88xILnMWM6M5bMCETKn7UvM1kV5y +ZQYlsi-36n73ETZyiFs1PLqe8D6dRURrcBG_B9i1MafNiWa-elG6E0X0pSK9CadchSA0KRMaKtfE +6-iyUqE-bx-0ELTbV2y7gLdu5MVtjRmQB5ozoaBq8ik4-jAWAsKpTv4DfWoMp9DkRENlKeauayuT +j_VAGhqy07pIntQKtbK9EP0tndSKtF3WLwHel1I5C3lthhkxxfzpxURBxO1ZJMFJZ6rLu1Ku03zw +LJ7nFFR_YfJ7tnGZE4PEt7MOZNiNoD3__9PthO5HmZdk1gPMrKlojU1hyR3IlbVShUst6rA3MkWk +MD-zlw9mhNgaV3xvPJ945pYPe4C6qIwxXoiXGHyhv_0MpcvuMW-pUuAZXfkuiqNwQnpUTLBD0YJw +uwMbE7sN40e6-BSxEiMOab7s2gShbaK9JjCMQUH_vAuQSZjU4sn53jsS7U4DHntzgxVYttIwGZaU +b-1R7jYphNJnCI8rPB_xjJ0OMssNKT7lYRgG_ZuKvifYvJWt-NwD0z2qoePcRGExXuioRDNR4SlB +-RN33dYhp6vRsHKT1oLpl-UJB6dqJlZ2dCsfc7vT1Vs0SYidRYXCUJNBSePI4-1LMlHKOqGASBcg +pl589601-EtO7ch3RoaL26rNXzA-umUWYRPQPZ76wcgK2j4k5Ndub5dWK9jI6UW3RbF6ixe0Yw2j +_Pipt4EX8R6-sb87D69JOOnZlFVB6EcCO07Q7j6DavpUNHlLmDmPgArqODh002scvW1ryMxBR2XE +m3kGQh2IFh5Qru8duxblEYE-lmHGxXVgDtKiKgHwPTkaxcquEtZTEJxaIJIgoKj7SgMzdfbeLlJM +RwbdvExmnRT9ivFImeIV7ACPnfBP3URd82kTG8FyiMvSpdCLL16FWOd9gjZuMstqZrmIVF8tO2WT +COMIx-jqvQD2zS1Ul5p0szJaf-CxBjy7-cJIaAyEToR1T5bBFtQt4sEFxG7XG0cCoXShqclL70TV +W13X5pY55YwHkCR4mRjc0o0ZKStY3OADVLFom1bC9AmMBqU4PsKNAX29LT37WE-I23tQgzid0Ix9 +JuVzlbOTvi19uLYbltrHavU3UbVhYxNNI7Y7tM02xfq3LhGqZG5EPS-WAB9bBixHQqw78cd9iqIr +hHlZW80l1kgs1ezMqgxfwDuiFOZIu9UWQ6vSnTAvfhwJhcr77gSk5Gu957uxzleaS4gVwTYU diff --git a/aai-resources/src/main/config/realm.properties b/aai-resources/src/main/config/realm.properties new file mode 100644 index 0000000..88d9e56 --- /dev/null +++ b/aai-resources/src/main/config/realm.properties @@ -0,0 +1,11 @@ +# format : username: password[,rolename ...] +# default username/password: AAI/AAI, MSO/MSO, ModelLoader/ModelLoader... +AAI:OBF:1gfr1ev31gg7,admin +MSO:OBF:1jzx1lz31k01,admin +SDNC:OBF:1itr1i0l1i151isv,admin +DCAE:OBF:1g8u1f9d1f991g8w,admin +POLICY:OBF:1mk61i171ima1im41i0j1mko,admin +ASDC:OBF:1f991j0u1j001f9d,admin +VID:OBF:1jm91i0v1jl9,admin +APPC:OBF:1f991ksf1ksf1f9d,admin +ModelLoader:OBF:1qvu1v2h1sov1sar1wfw1j7j1wg21saj1sov1v1x1qxw,admin diff --git a/aai-resources/src/main/config/runner-web.xml b/aai-resources/src/main/config/runner-web.xml new file mode 100644 index 0000000..669cd1f --- /dev/null +++ b/aai-resources/src/main/config/runner-web.xml @@ -0,0 +1,106 @@ + + + + + contextConfigLocation + /WEB-INF/spring-servlet.xml, + classpath:applicationContext.xml + + + + + spring.profiles.default + nooauth + + + + org.springframework.web.context.ContextLoaderListener + + + + ManagementServlet + ajsc.ManagementServlet + + + + WriteableRequestFilter + com.att.ajsc.csi.writeablerequestfilter.WriteableRequestFilter + + + + InterceptorFilter + ajsc.filters.InterceptorFilter + + preProcessor_interceptor_config_file + /etc/PreProcessorInterceptors.properties + + + postProcessor_interceptor_config_file + /etc/PostProcessorInterceptors.properties + + + + + + RestletServlet + ajsc.restlet.RestletSpringServlet + + org.restlet.component + restletComponent + + + + + CamelServlet + ajsc.servlet.AjscCamelServlet + + + + + springSecurityFilterChain + org.springframework.web.filter.DelegatingFilterProxy + + + + spring + org.springframework.web.servlet.DispatcherServlet + 1 + + + + + + spring + / + + + + + org.openecomp.aai.util.AAIAppServletContextListener + + + + + + Open Source + /aai/* + + + admin + + + CONFIDENTIAL + + + + + BASIC + Test Realm + + + + admin + + diff --git a/aai-resources/src/main/java/org/openecomp/aai/ajsc_aai/JaxrsErrorMessageLookupService.java b/aai-resources/src/main/java/org/openecomp/aai/ajsc_aai/JaxrsErrorMessageLookupService.java new file mode 100644 index 0000000..30dfced --- /dev/null +++ b/aai-resources/src/main/java/org/openecomp/aai/ajsc_aai/JaxrsErrorMessageLookupService.java @@ -0,0 +1,98 @@ +/*- + * ============LICENSE_START======================================================= + * org.openecomp.aai + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF 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.aai.ajsc_aai; + +//import java.util.HashMap; +//import java.util.Map; + +//import javax.ws.rs.GET; +//import javax.ws.rs.HeaderParam; +//import javax.ws.rs.Path; +//import javax.ws.rs.PathParam; +//import javax.ws.rs.Produces; + +//import org.slf4j.Logger; +//import org.slf4j.LoggerFactory; +//import org.springframework.web.context.ContextLoader; +//import org.springframework.web.context.WebApplicationContext; + +//import ajsc.ErrorMessageLookupService; + +//@Path("/errormessage") +//public class JaxrsErrorMessageLookupService { + + //private final static Logger logger = LoggerFactory + //.getLogger(ErrorMessageLookupService.class); + + /** + * Gets the message. + * + * @param input the input + * @param errorCode the error code + * @param appId the app id + * @param operation the operation + * @param messageText the message text + * @param isRESTService the is REST service + * @param faultEntity the fault entity + * @param ConvID the conv ID + * @return the message + */ + //@GET + //@Path("/emls") + //@Produces("text/plain") + //public String getMessage(@PathParam("input") String input, + //@HeaderParam("errorCode") String errorCode, + //@HeaderParam("appId") String appId, + //@HeaderParam("operation") String operation, + //@HeaderParam("messageText") String messageText, + //@HeaderParam("isRESTService") String isRESTService, + //@HeaderParam("faultEntity") String faultEntity, + //@HeaderParam("ConvID") String ConvID) { + + //Map headers = new HashMap(); + //headers.put(errorCode, errorCode); + //headers.put(appId, appId); + //headers.put(operation, operation); + //headers.put(messageText, messageText); + //headers.put(isRESTService, isRESTService); + //headers.put(faultEntity, faultEntity); + //headers.put(ConvID, ConvID); + + //WebApplicationContext applicationContext = ContextLoader + //.getCurrentWebApplicationContext(); + + //ErrorMessageLookupService e = (ErrorMessageLookupService) applicationContext + //.getBean("errorMessageLookupService"); + + //String message = e.getExceptionDetails(appId, operation, errorCode, + //messageText,isRESTService, faultEntity, ConvID); + + //System.out.println("Error code = " + errorCode); + //System.out.println("appId = " + appId); + //System.out.println("operation = " + operation); + //System.out.println("messageText = " + messageText); + //System.out.println("isRESTService = " + isRESTService); + //System.out.println("faultEntity = " + faultEntity); + //System.out.println("ConvID = " + ConvID); + //return "The exception message is:\n " + message; + //} + +//} diff --git a/aai-resources/src/main/java/org/openecomp/aai/ajsc_aai/JaxrsUserService.java b/aai-resources/src/main/java/org/openecomp/aai/ajsc_aai/JaxrsUserService.java new file mode 100644 index 0000000..39c78f6 --- /dev/null +++ b/aai-resources/src/main/java/org/openecomp/aai/ajsc_aai/JaxrsUserService.java @@ -0,0 +1,54 @@ +/*- + * ============LICENSE_START======================================================= + * org.openecomp.aai + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF 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.aai.ajsc_aai; + +import javax.ws.rs.GET; +import javax.ws.rs.Path; +import javax.ws.rs.PathParam; +import javax.ws.rs.Produces; +import java.util.Map; +import java.util.HashMap; + +@Path("/user") +public class JaxrsUserService { + + private static final Map userIdToNameMap; + static { + userIdToNameMap = new HashMap(); + userIdToNameMap.put("userID1","Name1"); + userIdToNameMap.put("userID2","Name2"); + } + + /** + * Lookup user. + * + * @param userId the user id + * @return the string + */ + @GET + @Path("/{userId}") + @Produces("text/plain") + public String lookupUser(@PathParam("userId") String userId) { + String name = userIdToNameMap.get(userId); + return name != null ? name : "unknown id"; + } + +} diff --git a/aai-resources/src/main/java/org/openecomp/aai/ajsc_aai/filemonitor/ServicePropertiesListener.java b/aai-resources/src/main/java/org/openecomp/aai/ajsc_aai/filemonitor/ServicePropertiesListener.java new file mode 100644 index 0000000..1520722 --- /dev/null +++ b/aai-resources/src/main/java/org/openecomp/aai/ajsc_aai/filemonitor/ServicePropertiesListener.java @@ -0,0 +1,37 @@ +/*- + * ============LICENSE_START======================================================= + * org.openecomp.aai + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF 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.aai.ajsc_aai.filemonitor; + +import java.io.File; + +//import com.att.ssf.filemonitor.FileChangedListener; + +//public class ServicePropertiesListener implements FileChangedListener { + + /** + * {@inheritDoc} + */ + //@Override + //public void update(File file) throws Exception + //{ + //ServicePropertiesMap.refresh(file); + //} +//} diff --git a/aai-resources/src/main/java/org/openecomp/aai/ajsc_aai/filemonitor/ServicePropertiesMap.java b/aai-resources/src/main/java/org/openecomp/aai/ajsc_aai/filemonitor/ServicePropertiesMap.java new file mode 100644 index 0000000..656b290 --- /dev/null +++ b/aai-resources/src/main/java/org/openecomp/aai/ajsc_aai/filemonitor/ServicePropertiesMap.java @@ -0,0 +1,126 @@ +/*- + * ============LICENSE_START======================================================= + * org.openecomp.aai + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF 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.aai.ajsc_aai.filemonitor; + +import java.io.File; +import java.io.FileInputStream; +import java.util.HashMap; +import java.util.Map; +import java.util.Properties; + +import com.att.eelf.configuration.EELFLogger; +import com.att.eelf.configuration.EELFManager; +import com.fasterxml.jackson.core.type.TypeReference; +import com.fasterxml.jackson.databind.ObjectMapper; + +public class ServicePropertiesMap +{ + private static HashMap> mapOfMaps = new HashMap>(); + private static final EELFLogger LOGGER = EELFManager.getInstance().getLogger(ServicePropertiesMap.class); + + /** + * Refresh. + * + * @param file the file + * @throws Exception the exception + */ + public static void refresh(File file) throws Exception + { + try + { + LOGGER.info("Loading properties - " + (file != null?file.getName():"")); + + //Store .json & .properties files into map of maps + String filePath = file.getPath(); + + if(filePath.lastIndexOf(".json")>0){ + + ObjectMapper om = new ObjectMapper(); + TypeReference> typeRef = new TypeReference>() {}; + HashMap propMap = om.readValue(file, typeRef); + HashMap lcasePropMap = new HashMap(); + for (String key : propMap.keySet() ) + { + String lcaseKey = ifNullThenEmpty(key); + lcasePropMap.put(lcaseKey, propMap.get(key)); + } + + mapOfMaps.put(file.getName(), lcasePropMap); + + + }else if(filePath.lastIndexOf(".properties")>0){ + Properties prop = new Properties(); + FileInputStream fis = new FileInputStream(file); + prop.load(fis); + + @SuppressWarnings("unchecked") + HashMap propMap = new HashMap((Map)prop); + + mapOfMaps.put(file.getName(), propMap); + } + + LOGGER.info("File - " + file.getName() + " is loaded into the map and the corresponding system properties have been refreshed"); + } + catch (Exception e) + { + LOGGER.error("File " + (file != null?file.getName():"") + " cannot be loaded into the map ", e); + throw new Exception("Error reading map file " + (file != null?file.getName():""), e); + } + } + + /** + * Gets the property. + * + * @param fileName the file name + * @param propertyKey the property key + * @return the property + */ + public static String getProperty(String fileName, String propertyKey) + { + HashMap propMap = mapOfMaps.get(fileName); + return propMap!=null?propMap.get(ifNullThenEmpty(propertyKey)):""; + } + + /** + * Gets the properties. + * + * @param fileName the file name + * @return the properties + */ + public static HashMap getProperties(String fileName){ + return mapOfMaps.get(fileName); + } + + /** + * If null then empty. + * + * @param key the key + * @return the string + */ + private static String ifNullThenEmpty(String key) { + if (key == null) { + return ""; + } else { + return key; + } + } + +} diff --git a/aai-resources/src/main/java/org/openecomp/aai/ajsc_aai/filemonitor/ServicePropertyService.java b/aai-resources/src/main/java/org/openecomp/aai/ajsc_aai/filemonitor/ServicePropertyService.java new file mode 100644 index 0000000..98426ad --- /dev/null +++ b/aai-resources/src/main/java/org/openecomp/aai/ajsc_aai/filemonitor/ServicePropertyService.java @@ -0,0 +1,218 @@ +/*- + * ============LICENSE_START======================================================= + * org.openecomp.aai + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF 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.aai.ajsc_aai.filemonitor; + +//import java.io.File; +//import java.io.FileInputStream; +//import java.io.IOException; +//import java.lang.reflect.Method; +//import java.util.ArrayList; +//import java.util.List; +//import java.util.Properties; + +//import javax.annotation.PostConstruct; + +//import org.slf4j.Logger; +//import org.slf4j.LoggerFactory; + +//import com.att.ssf.filemonitor.FileChangedListener; +//import com.att.ssf.filemonitor.FileMonitor; + +//public class ServicePropertyService { + //private boolean loadOnStartup; + //private ServicePropertiesListener fileChangedListener; + //private ServicePropertiesMap filePropertiesMap; + //private String ssfFileMonitorPollingInterval; + //private String ssfFileMonitorThreadpoolSize; + //private List fileList; + //private static final String FILE_CHANGE_LISTENER_LOC = System + //.getProperty("AJSC_CONF_HOME") + "/etc"; + //private static final String USER_CONFIG_FILE = "service-file-monitor.properties"; + //static final Logger logger = LoggerFactory + //.getLogger(ServicePropertyService.class); + + //// do not remove the postConstruct annotation, init method will not be + //// called after constructor + /** + * Inits the. + * + * @throws Exception the exception + */ + //@PostConstruct + //public void init() throws Exception { + + //try { + //getFileList(FILE_CHANGE_LISTENER_LOC); + + //for (File file : fileList) { + //try { + //FileChangedListener fileChangedListener = this.fileChangedListener; + //Object filePropertiesMap = this.filePropertiesMap; + //Method m = filePropertiesMap.getClass().getMethod( + //"refresh", File.class); + //m.invoke(filePropertiesMap, file); + //FileMonitor fm = FileMonitor.getInstance(); + //fm.addFileChangedListener(file, fileChangedListener, + //loadOnStartup); + //} catch (Exception ioe) { + //logger.error("Error in the file monitor block", ioe); + //} + //} + //} catch (Exception ex) { + //logger.error("Error creating property map ", ex); + //} + + //} + + /** + * Gets the file list. + * + * @param dirName the dir name + * @return the file list + * @throws IOException Signals that an I/O exception has occurred. + */ + //private void getFileList(String dirName) throws IOException { + //File directory = new File(dirName); + //FileInputStream fis = null; + + //if (fileList == null) + //fileList = new ArrayList(); + + //// get all the files that are ".json" or ".properties", from a directory + //// & it's sub-directories + //File[] fList = directory.listFiles(); + + //for (File file : fList) { + //// read service property files from the configuration file + //if (file.isFile() && file.getPath().endsWith(USER_CONFIG_FILE)) { + //try { + //fis = new FileInputStream(file); + //Properties prop = new Properties(); + //prop.load(fis); + + //for (String filePath : prop.stringPropertyNames()) { + //fileList.add(new File(prop.getProperty(filePath))); + //} + //} catch (Exception ioe) { + //logger.error("Error reading the file stream ", ioe); + //} finally { + //fis.close(); + //} + //} else if (file.isDirectory()) { + //getFileList(file.getPath()); + //} + //} + + //} + + /** + * Sets the load on startup. + * + * @param loadOnStartup the new load on startup + */ + //public void setLoadOnStartup(boolean loadOnStartup) { + //this.loadOnStartup = loadOnStartup; + //} + + /** + * Sets the ssf file monitor polling interval. + * + * @param ssfFileMonitorPollingInterval the new ssf file monitor polling interval + */ + //public void setSsfFileMonitorPollingInterval( + //String ssfFileMonitorPollingInterval) { + //this.ssfFileMonitorPollingInterval = ssfFileMonitorPollingInterval; + //} + + /** + * Sets the ssf file monitor threadpool size. + * + * @param ssfFileMonitorThreadpoolSize the new ssf file monitor threadpool size + */ + //public void setSsfFileMonitorThreadpoolSize( + //String ssfFileMonitorThreadpoolSize) { + //this.ssfFileMonitorThreadpoolSize = ssfFileMonitorThreadpoolSize; + //} + + /** + * Gets the load on startup. + * + * @return the load on startup + */ + //public boolean getLoadOnStartup() { + //return loadOnStartup; + //} + + /** + * Gets the ssf file monitor polling interval. + * + * @return the ssf file monitor polling interval + */ + //public String getSsfFileMonitorPollingInterval() { + //return ssfFileMonitorPollingInterval; + //} + + /** + * Gets the ssf file monitor threadpool size. + * + * @return the ssf file monitor threadpool size + */ + //public String getSsfFileMonitorThreadpoolSize() { + //return ssfFileMonitorThreadpoolSize; + //} + + /** + * Gets the file changed listener. + * + * @return the file changed listener + */ + //public ServicePropertiesListener getFileChangedListener() { + //return fileChangedListener; + //} + + /** + * Sets the file changed listener. + * + * @param fileChangedListener the new file changed listener + */ + //public void setFileChangedListener( + //ServicePropertiesListener fileChangedListener) { + //this.fileChangedListener = fileChangedListener; + //} + + /** + * Gets the file properties map. + * + * @return the file properties map + */ + //public ServicePropertiesMap getFilePropertiesMap() { + //return filePropertiesMap; + //} + + /** + * Sets the file properties map. + * + * @param filePropertiesMap the new file properties map + */ + //public void setFilePropertiesMap(ServicePropertiesMap filePropertiesMap) { + //this.filePropertiesMap = filePropertiesMap; + //} +//} diff --git a/aai-resources/src/main/java/org/openecomp/aai/ajsc_aai/util/ServicePropertiesMapBean.java b/aai-resources/src/main/java/org/openecomp/aai/ajsc_aai/util/ServicePropertiesMapBean.java new file mode 100644 index 0000000..7577de7 --- /dev/null +++ b/aai-resources/src/main/java/org/openecomp/aai/ajsc_aai/util/ServicePropertiesMapBean.java @@ -0,0 +1,37 @@ +/*- + * ============LICENSE_START======================================================= + * org.openecomp.aai + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF 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.aai.ajsc_aai.util; + +import org.openecomp.aai.ajsc_aai.filemonitor.ServicePropertiesMap; + +public class ServicePropertiesMapBean { + + /** + * Gets the property. + * + * @param propFileName the prop file name + * @param propertyKey the property key + * @return the property + */ + public static String getProperty(String propFileName, String propertyKey) { + return ServicePropertiesMap.getProperty(propFileName, propertyKey); + } +} diff --git a/aai-resources/src/main/java/org/openecomp/aai/db/schema/ScriptDriver.java b/aai-resources/src/main/java/org/openecomp/aai/db/schema/ScriptDriver.java new file mode 100644 index 0000000..458c4c9 --- /dev/null +++ b/aai-resources/src/main/java/org/openecomp/aai/db/schema/ScriptDriver.java @@ -0,0 +1,95 @@ +/*- + * ============LICENSE_START======================================================= + * org.openecomp.aai + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF 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.aai.db.schema; + +import java.io.IOException; + +import org.codehaus.jackson.JsonGenerationException; +import org.codehaus.jackson.map.JsonMappingException; +import org.codehaus.jackson.map.ObjectMapper; + +import org.openecomp.aai.exceptions.AAIException; +import org.openecomp.aai.introspection.Version; +import org.openecomp.aai.util.AAIConfig; +import com.beust.jcommander.JCommander; +import com.beust.jcommander.Parameter; +import com.thinkaurelius.titan.core.TitanFactory; +import com.thinkaurelius.titan.core.TitanGraph; + +public class ScriptDriver { + + + /** + * The main method. + * + * @param args the arguments + * @throws AAIException the AAI exception + * @throws JsonGenerationException the json generation exception + * @throws JsonMappingException the json mapping exception + * @throws IOException Signals that an I/O exception has occurred. + */ + public static void main (String[] args) throws AAIException, JsonGenerationException, JsonMappingException, IOException { + CommandLineArgs cArgs = new CommandLineArgs(); + + new JCommander(cArgs, args); + + if (cArgs.help) { + System.out.println("-c [path to graph configuration] -type [what you want to audit - oxm or graph]"); + } + String config = cArgs.config; + AAIConfig.init(); + TitanGraph graph = TitanFactory.open(config); + if (!(cArgs.type.equals("oxm") || cArgs.type.equals("graph"))) { + System.out.println("type: " + cArgs.type + " not recognized."); + System.exit(1); + } + + Auditor a = null; + if (cArgs.type.equals("oxm")) { + a = AuditorFactory.getOXMAuditor(Version.v8); + } else if (cArgs.type.equals("graph")) { + a = AuditorFactory.getGraphAuditor(graph); + } + + AuditDoc doc = a.getAuditDoc(); + + ObjectMapper mapper = new ObjectMapper(); + + String json = mapper.writerWithDefaultPrettyPrinter().writeValueAsString(doc); + System.out.println(json); + + } + +} + +class CommandLineArgs { + + @Parameter(names = "--help", description = "Help") + public boolean help = false; + + @Parameter(names = "-c", description = "Configuration", required=true) + public String config; + + @Parameter(names = "-type", description = "Type", required=true) + public String type = "graph"; + + +} diff --git a/aai-resources/src/main/java/org/openecomp/aai/dmaap/AAIDmaapEventJMSConsumer.java b/aai-resources/src/main/java/org/openecomp/aai/dmaap/AAIDmaapEventJMSConsumer.java new file mode 100644 index 0000000..fc11e5d --- /dev/null +++ b/aai-resources/src/main/java/org/openecomp/aai/dmaap/AAIDmaapEventJMSConsumer.java @@ -0,0 +1,198 @@ +/*- + * ============LICENSE_START======================================================= + * org.openecomp.aai + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF 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.aai.dmaap; + +import java.io.File; +import java.io.FileReader; +import java.io.IOException; +import java.util.Properties; + +import javax.jms.JMSException; +import javax.jms.Message; +import javax.jms.MessageListener; +import javax.jms.TextMessage; +import javax.ws.rs.core.MediaType; + +import org.apache.log4j.MDC; +import org.eclipse.jetty.util.security.Password; +import org.json.JSONException; +import org.json.JSONObject; + +import org.openecomp.aai.logging.ErrorLogHelper; +import org.openecomp.aai.util.AAIConstants; +import com.att.eelf.configuration.EELFLogger; +import com.att.eelf.configuration.EELFManager; +//import com.att.nsa.mr.client.MRBatchingPublisher; +//import com.att.nsa.mr.client.MRClientFactory; +import com.sun.jersey.api.client.Client; +import com.sun.jersey.api.client.ClientResponse; +import com.sun.jersey.api.client.WebResource; +import com.sun.jersey.api.client.filter.HTTPBasicAuthFilter; + +public class AAIDmaapEventJMSConsumer implements MessageListener { + + private static final EELFLogger LOGGER = EELFManager.getInstance().getLogger(AAIDmaapEventJMSConsumer.class); + + private Client httpClient; + + //private MRBatchingPublisher aaiEventPublisher = null; + private Properties aaiEventProps; + private String aaiEventUrl = ""; + + //private MRBatchingPublisher aaiVceEventPublisher = null; + private Properties aaiVceEventProps; + private String aaiVceEventUrl = ""; + + public AAIDmaapEventJMSConsumer() throws org.apache.commons.configuration.ConfigurationException { + //super(); + //try { + + //if (this.aaiEventPublisher == null) { + //FileReader reader = new FileReader(new File(AAIConstants.AAI_EVENT_DMAAP_PROPS)); + //aaiEventProps = new Properties(); + //aaiEventProps.load(reader); + //reader.close(); + //aaiEventProps.setProperty("DME2preferredRouterFilePath", + //AAIConstants.AAI_HOME_ETC_APP_PROPERTIES + "preferredRoute.txt"); + //if (aaiEventProps.getProperty("password") != null + //&& aaiEventProps.getProperty("password").startsWith("OBF:")) { + //aaiEventProps.setProperty("password", Password.deobfuscate(aaiEventProps.getProperty("password"))); + //} + + //this.aaiEventPublisher = MRClientFactory.createBatchingPublisher(aaiEventProps); + + //String host = aaiEventProps.getProperty("host"); + //String topic = aaiEventProps.getProperty("topic"); + //String protocol = aaiEventProps.getProperty("Protocol"); + + //String username = aaiEventProps.getProperty("username"); + //String password = aaiEventProps.getProperty("password"); + + //aaiEventUrl = protocol + "://" + host + "/events/" + topic; + //httpClient = Client.create(); + //httpClient.addFilter(new HTTPBasicAuthFilter(username, password)); + //} + + //if (this.aaiVceEventProps == null) { + //FileReader reader = new FileReader(new File(AAIConstants.AAI_EVENT_DMAAP_PROPS)); + //aaiVceEventProps = new Properties(); + //aaiVceEventProps.load(reader); + //reader.close(); + //aaiVceEventProps.setProperty("DME2preferredRouterFilePath", + //AAIConstants.AAI_HOME_ETC_APP_PROPERTIES + "preferredRoute.txt"); + //if (aaiVceEventProps.getProperty("password") != null + //&& aaiVceEventProps.getProperty("password").startsWith("OBF:")) { + //aaiVceEventProps.setProperty("password", + //Password.deobfuscate(aaiVceEventProps.getProperty("password"))); + //} + //aaiVceEventProps.setProperty("topic", "AAI-VCE-INTERFACE-DATA"); + //this.aaiVceEventPublisher = MRClientFactory.createBatchingPublisher(aaiVceEventProps); + + //String host = aaiVceEventProps.getProperty("host"); + //String topic = aaiVceEventProps.getProperty("topic"); + //String protocol = aaiVceEventProps.getProperty("Protocol"); + + //aaiVceEventUrl = protocol + "://" + host + "/events/" + topic; + + //} + //} catch (IOException e) { + //ErrorLogHelper.logError("AAI_4000", "Error updating dmaap config file for aai event."); + //} + + } + + @Override + public void onMessage(Message message) { + + //String jsmMessageTxt = ""; + //String aaiEvent = ""; + //String eventName = ""; + + + //String environment = ""; + + //if (message instanceof TextMessage) { + //try { + //jsmMessageTxt = ((TextMessage) message).getText(); + //JSONObject jo = new JSONObject(jsmMessageTxt); + + //if (jo.has("aaiEventPayload")) { + //aaiEvent = jo.getJSONObject("aaiEventPayload").toString(); + //} else { + //return; + //} + //if (jo.getString("transId") != null) { + //MDC.put("requestId", jo.getString("transId")); + //} + //if (jo.getString("fromAppId") != null) { + //MDC.put("partnerName", jo.getString("fromAppId")); + //} + //if (jo.getString("event-topic") != null) { + //eventName = jo.getString("event-topic"); + //} + + //LOGGER.info(eventName + "|" + aaiEvent); + //if (eventName.equals("AAI-EVENT")) { + //if (!this.sentWithHttp(environment, this.httpClient, this.aaiEventUrl, aaiEvent)) { + //this.aaiEventPublisher.send(aaiEvent); + //} + //LOGGER.info(eventName + "|Event sent."); + //} else if (eventName.equals("AAI-VCE-INTERFACE-DATA")) { + //String msg = ""; + //if (!this.sentWithHttp(environment, this.httpClient, this.aaiVceEventUrl, aaiEvent)) { + //this.aaiVceEventPublisher.send(aaiEvent); + //msg = this.aaiVceEventPublisher.sendBatchWithResponse().getResponseMessage(); + //} + //LOGGER.info(eventName + "|Event sent. " + msg); + //} else { + //LOGGER.error(eventName + "|Event Topic invalid."); + //} + //} catch (java.net.SocketException e) { + //if (!e.getMessage().contains("Connection reset")) { + //LOGGER.error("AAI_7304 Error reaching DMaaP to send event. " + aaiEvent, e); + //} + //} catch (IOException e) { + //LOGGER.error("AAI_7304 Error reaching DMaaP to send event. " + aaiEvent, e); + //} catch (JMSException | JSONException e) { + //LOGGER.error("AAI_7350 Error parsing aaievent jsm message for sending to dmaap. " + jsmMessageTxt, e); + //} catch (Exception e) { + //LOGGER.error("AAI_7350 Error sending message to dmaap. " + jsmMessageTxt, e); + //} + //} + + } + + private boolean sentWithHttp(String environment, Client client, String url, String aaiEvent) throws IOException { + //if (environment.startsWith("dev") || environment.startsWith("testINT") || environment.startsWith("testEXT")) { + + //WebResource webResource = client.resource(url); + //ClientResponse response = webResource.accept(MediaType.APPLICATION_JSON).type(MediaType.APPLICATION_JSON) + //.post(ClientResponse.class, aaiEvent); + //if (response.getStatus() != 200) { + //LOGGER.info("Failed : HTTP error code : " + response.getStatus()); + //return false; + //} + //} else { + //return false; + //} + return true; + } +} diff --git a/aai-resources/src/main/java/org/openecomp/aai/dmaap/AAIDmaapEventJMSProducer.java b/aai-resources/src/main/java/org/openecomp/aai/dmaap/AAIDmaapEventJMSProducer.java new file mode 100644 index 0000000..eef852a --- /dev/null +++ b/aai-resources/src/main/java/org/openecomp/aai/dmaap/AAIDmaapEventJMSProducer.java @@ -0,0 +1,44 @@ +/*- + * ============LICENSE_START======================================================= + * org.openecomp.aai + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF 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.aai.dmaap; + +import org.apache.activemq.ActiveMQConnectionFactory; +import org.apache.activemq.command.ActiveMQQueue; +import org.json.JSONObject; +import org.springframework.jms.connection.CachingConnectionFactory; +import org.springframework.jms.core.JmsTemplate; + +public class AAIDmaapEventJMSProducer { + + private JmsTemplate jmsTemplate; + + public AAIDmaapEventJMSProducer() { + //this.jmsTemplate = new JmsTemplate(); + //this.jmsTemplate.setConnectionFactory(new CachingConnectionFactory(new ActiveMQConnectionFactory("tcp://localhost:61447"))); + //this.jmsTemplate.setDefaultDestination(new ActiveMQQueue("IN_QUEUE")); + } + + public void sendMessageToDefaultDestination(JSONObject finalJson) { + //jmsTemplate.convertAndSend(finalJson.toString()); + //CachingConnectionFactory ccf = (CachingConnectionFactory)this.jmsTemplate.getConnectionFactory(); + //ccf.destroy(); + } +} diff --git a/aai-resources/src/main/java/org/openecomp/aai/interceptors/AAIHeaderProperties.java b/aai-resources/src/main/java/org/openecomp/aai/interceptors/AAIHeaderProperties.java new file mode 100644 index 0000000..4798d90 --- /dev/null +++ b/aai-resources/src/main/java/org/openecomp/aai/interceptors/AAIHeaderProperties.java @@ -0,0 +1,26 @@ +/*- + * ============LICENSE_START======================================================= + * org.openecomp.aai + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF 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.aai.interceptors; + +public class AAIHeaderProperties { + + public static final String REQUEST_CONTEXT = "aai-request-context"; +} diff --git a/aai-resources/src/main/java/org/openecomp/aai/interceptors/AAILogJAXRSInInterceptor.java b/aai-resources/src/main/java/org/openecomp/aai/interceptors/AAILogJAXRSInInterceptor.java new file mode 100644 index 0000000..80127d0 --- /dev/null +++ b/aai-resources/src/main/java/org/openecomp/aai/interceptors/AAILogJAXRSInInterceptor.java @@ -0,0 +1,283 @@ +/*- + * ============LICENSE_START======================================================= + * org.openecomp.aai + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF 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.aai.interceptors; + +import java.io.InputStream; +import java.text.DateFormat; +import java.text.SimpleDateFormat; +import java.util.ArrayList; +import java.util.Collections; +import java.util.Date; +import java.util.List; +import java.util.Map; +import java.util.UUID; +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +import javax.ws.rs.core.MediaType; + +import org.apache.commons.io.IOUtils; +import org.apache.cxf.helpers.CastUtils; +import org.apache.cxf.interceptor.LoggingMessage; +import org.apache.cxf.jaxrs.interceptor.JAXRSInInterceptor; +import org.apache.cxf.message.Message; + +import org.openecomp.aai.exceptions.AAIException; +import org.openecomp.aai.logging.ErrorLogHelper; +import org.openecomp.aai.rest.util.EchoResponse; +import org.openecomp.aai.util.AAIConfig; +import org.openecomp.aai.util.AAIConstants; +import org.openecomp.aai.util.HbaseSaltPrefixer; +import com.att.eelf.configuration.EELFLogger; +import com.att.eelf.configuration.EELFManager; + +public class AAILogJAXRSInInterceptor extends JAXRSInInterceptor { + + protected final String COMPONENT = "aairest"; + protected final String CAMEL_REQUEST ="CamelHttpUrl"; + private static final Pattern uuidPattern = Pattern.compile("^[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$"); + private static final EELFLogger LOGGER = EELFManager.getInstance().getLogger(AAILogJAXRSInInterceptor.class); + + /** + * {@inheritDoc} + */ + public void handleMessage(Message message) { + + boolean go = false; + String uri = null; + String query = null; + try { + + uri = (String)message.get(CAMEL_REQUEST); + if (uri != null) { + query = (String)message.get(Message.QUERY_STRING); + } + + if (AAIConfig.get(AAIConstants.AAI_LOGGING_HBASE_INTERCEPTOR).equalsIgnoreCase("true") && + AAIConfig.get(AAIConstants.AAI_LOGGING_HBASE_ENABLED).equalsIgnoreCase("true")) { + go = true; + message.getExchange().put("AAI_LOGGING_HBASE_ENABLED", 1); + if (AAIConfig.get(AAIConstants.AAI_LOGGING_HBASE_LOGREQUEST).equalsIgnoreCase("true") ) { + message.getExchange().put("AAI_LOGGING_HBASE_LOGREQUEST", 1); + } + if (AAIConfig.get(AAIConstants.AAI_LOGGING_HBASE_LOGRESPONSE).equalsIgnoreCase("true") ) { + message.getExchange().put("AAI_LOGGING_HBASE_LOGRESPONSE", 1); + } + } + if (AAIConfig.get(AAIConstants.AAI_LOGGING_TRACE_ENABLED).equalsIgnoreCase("true") ) { + go = true; + message.getExchange().put("AAI_LOGGING_TRACE_ENABLED", 1); + if (AAIConfig.get(AAIConstants.AAI_LOGGING_TRACE_LOGREQUEST).equalsIgnoreCase("true") ) { + message.getExchange().put("AAI_LOGGING_TRACE_LOGREQUEST", 1); + } + if (AAIConfig.get(AAIConstants.AAI_LOGGING_TRACE_LOGRESPONSE).equalsIgnoreCase("true") ) { + message.getExchange().put("AAI_LOGGING_TRACE_LOGRESPONSE", 1); + } + } + } catch (AAIException e1) { + ErrorLogHelper.logException(e1); + } + + if (uri.contains(EchoResponse.echoPath)) { + // if it's a health check, we don't want to log ANYTHING if it's a lightweight one + if (query == null) { + if (message.getExchange().containsKey("AAI_LOGGING_HBASE_ENABLED")) { + message.getExchange().remove("AAI_LOGGING_HBASE_ENABLED"); + } + if (message.getExchange().containsKey("AAI_LOGGING_TRACE_ENABLED")) { + message.getExchange().remove("AAI_LOGGING_TRACE_ENABLED"); + } + go = false; + } + } + else if (uri.contains("/translog/")) { + // if it's a translog query, we don't want to log the responses + if (message.getExchange().containsKey("AAI_LOGGING_HBASE_LOGRESPONSE")) { + message.getExchange().remove("AAI_LOGGING_HBASE_LOGRESPONSE"); + } + if (message.getExchange().containsKey("AAI_LOGGING_TRACE_LOGRESPONSE")) { + message.getExchange().remove("AAI_LOGGING_TRACE_LOGRESPONSE"); + } + } + + if (go == false) { // there's nothing to do + return; + } + + // DONE: get a TXID based on hostname, time (YYYYMMDDHHMMSSMILLIS, and LoggingMessage.nextId(); 20150326145301-1 + String now = genDate(); + + message.getExchange().put("AAI_RQST_TM", now); + + String id = (String)message.getExchange().get(LoggingMessage.ID_KEY); + + String fullId = null; + try { + if (id == null) { + id = LoggingMessage.nextId(); + } + fullId = AAIConfig.get(AAIConstants.AAI_NODENAME) + "-" + now + "-" + id; + fullId = HbaseSaltPrefixer.getInstance().prependSalt(fullId); + message.getExchange().put(LoggingMessage.ID_KEY, fullId); + } catch (AAIException e1) { + LOGGER.debug("config problem", e1); + } + + if (fullId == null) { + fullId = now + "-" + id; + fullId = HbaseSaltPrefixer.getInstance().prependSalt(fullId); + } + message.put(LoggingMessage.ID_KEY, fullId); + final LoggingMessage buffer = new LoggingMessage("Message", fullId); + + Integer responseCode = (Integer)message.get(Message.RESPONSE_CODE); + if (responseCode != null) { + buffer.getResponseCode().append(responseCode); + } + + String encoding = (String)message.get(Message.ENCODING); + + if (encoding != null) { + buffer.getEncoding().append(encoding); + } + String httpMethod = (String)message.get(Message.HTTP_REQUEST_METHOD); + if (httpMethod != null) { + buffer.getHttpMethod().append(httpMethod); + } + + String ct = (String)message.get(Message.CONTENT_TYPE); + if (ct != null) { + if ("*/*".equals(ct)) { + message.put(Message.CONTENT_TYPE, MediaType.APPLICATION_JSON); + ct = MediaType.APPLICATION_JSON; + } + buffer.getContentType().append(ct); + + } + Object headers = message.get(Message.PROTOCOL_HEADERS); + if (headers != null) { + buffer.getHeader().append(headers); + + Map> headersList = CastUtils.cast((Map)message.get(Message.PROTOCOL_HEADERS)); + String transId = ""; + List xt = headersList.get("X-TransactionId"); + String newTransId = transId; + boolean missingTransId = false; + boolean replacedTransId = false; + String logMsg = null; + if (xt != null) { + for (String transIdValue : xt) { + transId = transIdValue; + } + Matcher matcher = uuidPattern.matcher(transId); + if (!matcher.find()) { + replacedTransId = true; + // check if there's a colon, and check the first group? + if (transId.contains(":")) { + String[] uuidParts = transId.split(":"); + Matcher matcher2 = uuidPattern.matcher(uuidParts[0]); + if (matcher2.find()) { + newTransId = uuidParts[0]; + } else { + // punt, we tried to find it, it has a colon but no UUID-1 + newTransId = UUID.randomUUID().toString(); + } + } else { + newTransId = UUID.randomUUID().toString(); + } + } + } else { + newTransId = UUID.randomUUID().toString(); + missingTransId = true; + } + + if (missingTransId || replacedTransId) { + List txList = new ArrayList(); + txList.add(newTransId); + headersList.put("X-TransactionId", txList); + if (missingTransId) { + logMsg = "Missing requestID. Assigned " + newTransId; + } else if (replacedTransId) { + logMsg = "Replaced invalid requestID of " + transId + " Assigned " + newTransId; + } + } + + List contentType = headersList.get("Content-Type"); + if (contentType == null) { + ct = (String)message.get(Message.CONTENT_TYPE); + headersList.put(Message.CONTENT_TYPE, Collections.singletonList(ct)); + } + + LOGGER.auditEvent("REST " + httpMethod + " " + ((query != null)? uri+"?"+query : uri) + " HbaseTxId=" + fullId); + LOGGER.info(logMsg); + } + + + if (uri != null) { + buffer.getAddress().append(uri); + if (query != null) { + buffer.getAddress().append("?").append(query); + } + } + + InputStream is = message.getContent(InputStream.class); + if (is != null) { + try { + String currentPayload = IOUtils.toString(is, "UTF-8"); + IOUtils.closeQuietly(is); + buffer.getPayload().append(currentPayload); + is = IOUtils.toInputStream(currentPayload, "UTF-8"); + message.setContent(InputStream.class, is); + IOUtils.closeQuietly(is); + } catch (Exception e) { + // It's ok to not have request input content + // throw new Fault(e); + } + } + + // this will be saved in the message exchange, and can be pulled out later... + message.getExchange().put(fullId + "_REQUEST", buffer.toString()); + } + + /** + * Gen date. + * + * @param aaiLogger the aai logger + * @param logline the logline + * @return the string + */ + protected String genDate() { + Date date = new Date(); + DateFormat formatter = null; + try { + formatter = new SimpleDateFormat(AAIConfig.get(AAIConstants.HBASE_TABLE_TIMESTAMP_FORMAT)); + } catch (AAIException ex) { + ErrorLogHelper.logException(ex); + } finally { + if (formatter == null) { + formatter = new SimpleDateFormat("YYMMdd-HH:mm:ss:SSS"); + } + } + + return formatter.format(date); + } + +} diff --git a/aai-resources/src/main/java/org/openecomp/aai/interceptors/AAILogJAXRSOutInterceptor.java b/aai-resources/src/main/java/org/openecomp/aai/interceptors/AAILogJAXRSOutInterceptor.java new file mode 100644 index 0000000..0f5e457 --- /dev/null +++ b/aai-resources/src/main/java/org/openecomp/aai/interceptors/AAILogJAXRSOutInterceptor.java @@ -0,0 +1,323 @@ +/*- + * ============LICENSE_START======================================================= + * org.openecomp.aai + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF 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.aai.interceptors; + +import java.io.OutputStream; +import java.text.DateFormat; +import java.text.SimpleDateFormat; +import java.util.Collections; +import java.util.Date; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import org.apache.cxf.helpers.CastUtils; +import org.apache.cxf.interceptor.LoggingMessage; +import org.apache.cxf.io.CacheAndWriteOutputStream; +import org.apache.cxf.io.CachedOutputStream; +import org.apache.cxf.io.CachedOutputStreamCallback; +import org.apache.cxf.jaxrs.interceptor.JAXRSOutInterceptor; +import org.apache.cxf.message.Message; + +import org.openecomp.aai.exceptions.AAIException; +import org.openecomp.aai.logging.ErrorLogHelper; +import org.openecomp.aai.util.AAIConfig; +import org.openecomp.aai.util.AAIConstants; +import com.att.eelf.configuration.EELFLogger; +import com.att.eelf.configuration.EELFManager; + +// right after the request is complete, there may be content +public class AAILogJAXRSOutInterceptor extends JAXRSOutInterceptor { + + private static final EELFLogger LOGGER = EELFManager.getInstance().getLogger(AAILogJAXRSOutInterceptor.class); + + protected final String COMPONENT = "aairest"; + protected final String CAMEL_REQUEST = "CamelHttpUrl"; + + /** + * {@inheritDoc} + */ + public void handleMessage(Message message) { + + String fullId = (String) message.getExchange().get(LoggingMessage.ID_KEY); + + Map> headers = CastUtils.cast((Map) message.get(Message.PROTOCOL_HEADERS)); + if (headers == null) { + headers = new HashMap>(); + } + + headers.put("X-AAI-TXID", Collections.singletonList(fullId)); + message.put(Message.PROTOCOL_HEADERS, headers); + + Message outMessage = message.getExchange().getOutMessage(); + final OutputStream os = outMessage.getContent(OutputStream.class); + if (os == null) { + return; + } + + // we only want to register the callback if there is good reason for it. + if (message.getExchange().containsKey("AAI_LOGGING_HBASE_ENABLED") || message.getExchange().containsKey("AAI_LOGGING_TRACE_ENABLED")) { + + final CacheAndWriteOutputStream newOut = new CacheAndWriteOutputStream(os); + message.setContent(OutputStream.class, newOut); + newOut.registerCallback(new LoggingCallback(message, os)); + } + + } + + class LoggingCallback implements CachedOutputStreamCallback { + + private final Message message; + private final OutputStream origStream; + + public LoggingCallback(final Message msg, final OutputStream os) { + this.message = msg; + this.origStream = os; + } + + public void onFlush(CachedOutputStream cos) { + + } + + public void onClose(CachedOutputStream cos) { + + String getValue = ""; + String postValue = ""; + String logValue = ""; + + try { + logValue = AAIConfig.get("aai.transaction.logging"); + getValue = AAIConfig.get("aai.transaction.logging.get"); + postValue = AAIConfig.get("aai.transaction.logging.post"); + } catch (AAIException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + + if (!message.getExchange().containsKey("AAI_LOGGING_HBASE_ENABLED") && !message.getExchange().containsKey("AAI_LOGGING_TRACE_ENABLED")) { + return; + } + + String fullId = (String) message.getExchange().get(LoggingMessage.ID_KEY); + + Message inMessage = message.getExchange().getInMessage(); + String transId = null; + String fromAppId = null; + + Map> headersList = CastUtils.cast((Map) inMessage.get(Message.PROTOCOL_HEADERS)); + if (headersList != null) { + List xt = headersList.get("X-TransactionId"); + if (xt != null) { + for (String transIdValue : xt) { + transId = transIdValue; + } + } + List fa = headersList.get("X-FromAppId"); + if (fa != null) { + for (String fromAppIdValue : fa) { + + fromAppId = fromAppIdValue; + } + } + } + + String httpMethod = (String) inMessage.get(Message.HTTP_REQUEST_METHOD); + + String uri = (String) inMessage.get(CAMEL_REQUEST); + String fullUri = uri; + if (uri != null) { + String query = (String) message.get(Message.QUERY_STRING); + if (query != null) { + fullUri = uri + "?" + query; + } + } + + String request = (String) message.getExchange().get(fullId + "_REQUEST"); + + Message outMessage = message.getExchange().getOutMessage(); + + final LoggingMessage buffer = new LoggingMessage("OUTMessage", fullId); + + // should we check this, and make sure it's not an error? + Integer responseCode = (Integer) outMessage.get(Message.RESPONSE_CODE); + if (responseCode == null) { + responseCode = 200; // this should never happen, but just in + // case we don't get one + } + buffer.getResponseCode().append(responseCode); + + String encoding = (String) outMessage.get(Message.ENCODING); + + if (encoding != null) { + buffer.getEncoding().append(encoding); + } + + String ct = (String) outMessage.get(Message.CONTENT_TYPE); + if (ct != null) { + buffer.getContentType().append(ct); + } + + Object headers = outMessage.get(Message.PROTOCOL_HEADERS); + if (headers != null) { + buffer.getHeader().append(headers); + } + + Boolean ss = false; + if (responseCode >= 200 && responseCode <= 299) { + ss = true; + } + String response = buffer.toString(); + + // this should have been set by the in interceptor + String rqstTm = (String) message.getExchange().get("AAI_RQST_TM"); + + // just in case it wasn't, we'll put this here. not great, but it'll + // have a val. + if (rqstTm == null) { + rqstTm = genDate(); + } + + + String respTm = genDate(); + + try { + String actualRequest = request; + StringBuilder builder = new StringBuilder(); + cos.writeCacheTo(builder, 100000); + // here comes my xml: + String payload = builder.toString(); + + String actualResponse = response; + if (payload == null) { + + } else { + actualResponse = response + payload; + } + + // we only log to AAI log if it's eanbled in the config props + // file + if (message.getExchange().containsKey("AAI_LOGGING_TRACE_ENABLED")) { + + if (message.getExchange().containsKey("AAI_LOGGING_TRACE_LOGREQUEST")) { + + // strip newlines from request + String traceRequest = actualRequest; + traceRequest = traceRequest.replace("\n", " "); + traceRequest = traceRequest.replace("\r", ""); + traceRequest = traceRequest.replace("\t", ""); + LOGGER.debug(traceRequest); + } + if (message.getExchange().containsKey("AAI_LOGGING_TRACE_LOGRESPONSE")) { + // strip newlines from response + String traceResponse = actualResponse; + traceResponse = traceResponse.replace("\n", " "); + traceResponse = traceResponse.replace("\r", ""); + traceResponse = traceResponse.replace("\t", ""); + + LOGGER.debug(traceResponse); + } + } + + // we only log to HBASE if it's enabled in the config props file + // TODO: pretty print XML/JSON. we might need to get the payload + // and envelope seperately + if (message.getExchange().containsKey("AAI_LOGGING_HBASE_ENABLED")) { + if (!message.getExchange().containsKey("AAI_LOGGING_HBASE_LOGREQUEST")) { + actualRequest = "loggingDisabled"; + } + if (!message.getExchange().containsKey("AAI_LOGGING_HBASE_LOGRESPONSE")) { + actualResponse = "loggingDisabled"; + } + + LOGGER.debug("action={}, urlin={}, HbTransId={}", httpMethod, fullUri, fullId); + + if (logValue.equals("false")) { + } else if (getValue.equals("false") && httpMethod.equals("GET")) { + } else if (postValue.equals("false") && httpMethod.equals("POST")) { + } else { + putTransaction(transId, responseCode.toString(), rqstTm, respTm, fromAppId + ":" + transId, fullUri, httpMethod, request, response, actualResponse); + + } + } + } catch (Exception ex) { + // ignore + } + + message.setContent(OutputStream.class, origStream); + + LOGGER.auditEvent("HTTP Response Code: {}", responseCode.toString()); + } + + } + + protected String genDate() { + Date date = new Date(); + DateFormat formatter = null; + try { + formatter = new SimpleDateFormat(AAIConfig.get(AAIConstants.HBASE_TABLE_TIMESTAMP_FORMAT)); + } catch (AAIException ex) { + ErrorLogHelper.logException(ex); + } finally { + if (formatter == null) { + formatter = new SimpleDateFormat("YYMMdd-HH:mm:ss:SSS"); + } + } + return formatter.format(date); + } + + public String putTransaction(String tid, String status, String rqstTm, String respTm, String srcId, String rsrcId, String rsrcType, String rqstBuf, String respBuf, String actualResponse) { + String tm = null; + String fromAppId = srcId.substring(0, srcId.indexOf(':')); + String transId = srcId.substring(srcId.indexOf(':') + 1); + + if (tid == null || "".equals(tid)) { + Date date = new Date(); + DateFormat formatter = null; + try { + formatter = new SimpleDateFormat(AAIConfig.get(AAIConstants.HBASE_TABLE_TIMESTAMP_FORMAT)); + } catch (Exception e) { + formatter = new SimpleDateFormat("YYYYMMdd-HH:mm:ss:SSS"); + } + tm = formatter.format(date); + tid = tm + "-"; + } + + String htid = tid; + + if (rqstTm == null || "".equals(rqstTm)) { + rqstTm = tm; + } + + if (respTm == null || "".equals(respTm)) { + respTm = tm; + } + + try { + LOGGER.debug(" transactionId:" + tid + " status: " + status + " rqstDate: " + rqstTm + " respDate: " + respTm + " sourceId: " + srcId + " resourceId: " + + rsrcId + " resourceType: " + rsrcType + " payload rqstBuf: " + rqstBuf + " payload respBuf: " + respBuf + " Payload Error Messages: " + actualResponse); + return htid; + } catch (Exception e) { + ErrorLogHelper.logError("AAI_4000", "Exception updating HBase:"); + return htid; + } + + } +} diff --git a/aai-resources/src/main/java/org/openecomp/aai/interceptors/PostAaiAjscInterceptor.java b/aai-resources/src/main/java/org/openecomp/aai/interceptors/PostAaiAjscInterceptor.java new file mode 100644 index 0000000..3a4f899 --- /dev/null +++ b/aai-resources/src/main/java/org/openecomp/aai/interceptors/PostAaiAjscInterceptor.java @@ -0,0 +1,63 @@ +/*- + * ============LICENSE_START======================================================= + * org.openecomp.aai + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF 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.aai.interceptors; + +import java.util.Map; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +import org.openecomp.aai.logging.LoggingContext; +import org.openecomp.aai.logging.LoggingContext.StatusCode; +import com.att.eelf.configuration.EELFLogger; +import com.att.eelf.configuration.EELFManager; + +import ajsc.beans.interceptors.AjscInterceptor; + +public class PostAaiAjscInterceptor implements AjscInterceptor { + + private static final EELFLogger LOGGER = EELFManager.getInstance().getLogger(PostAaiAjscInterceptor.class); + + private static class LazyAaiAjscInterceptor { + public static final PostAaiAjscInterceptor INSTANCE = new PostAaiAjscInterceptor(); + } + + public static PostAaiAjscInterceptor getInstance() { + return LazyAaiAjscInterceptor.INSTANCE; + } + + @Override + public boolean allowOrReject(HttpServletRequest req, HttpServletResponse resp, Map paramMap) + throws Exception { + final String responseCode = LoggingContext.responseCode(); + + if (responseCode != null && responseCode.startsWith("ERR.")) { + LoggingContext.statusCode(StatusCode.ERROR); + LOGGER.error(req.getRequestURL() + " call failed with responseCode=" + responseCode); + } else { + LoggingContext.statusCode(StatusCode.COMPLETE); + LOGGER.info(req.getRequestURL() + " call succeeded"); + } + + LoggingContext.clear(); + return true; + } +} diff --git a/aai-resources/src/main/java/org/openecomp/aai/interceptors/PreAaiAjscInterceptor.java b/aai-resources/src/main/java/org/openecomp/aai/interceptors/PreAaiAjscInterceptor.java new file mode 100644 index 0000000..a2c56d0 --- /dev/null +++ b/aai-resources/src/main/java/org/openecomp/aai/interceptors/PreAaiAjscInterceptor.java @@ -0,0 +1,54 @@ +/*- + * ============LICENSE_START======================================================= + * org.openecomp.aai + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF 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.aai.interceptors; + +import java.util.Map; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +import org.openecomp.aai.logging.LoggingContext; + +import ajsc.beans.interceptors.AjscInterceptor; + +public class PreAaiAjscInterceptor implements AjscInterceptor { + + private static class LazyAaiAjscInterceptor { + public static final PreAaiAjscInterceptor INSTANCE = new PreAaiAjscInterceptor(); + } + + public static PreAaiAjscInterceptor getInstance() { + return LazyAaiAjscInterceptor.INSTANCE; + } + + @Override + public boolean allowOrReject(HttpServletRequest req, HttpServletResponse resp, Map paramMap) + throws Exception { + + LoggingContext.init(); + + LoggingContext.requestId(req.getHeader("X-TransactionId")); + LoggingContext.partnerName(req.getHeader("X-FromAppId")); + LoggingContext.serviceName(req.getMethod() + " " + req.getRequestURI().toString()); + + return true; + } +} diff --git a/aai-resources/src/main/java/org/openecomp/aai/rest/BulkAddConsumer.java b/aai-resources/src/main/java/org/openecomp/aai/rest/BulkAddConsumer.java new file mode 100644 index 0000000..f8c34c2 --- /dev/null +++ b/aai-resources/src/main/java/org/openecomp/aai/rest/BulkAddConsumer.java @@ -0,0 +1,42 @@ +/*- + * ============LICENSE_START======================================================= + * org.openecomp.aai + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF 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.aai.rest; + +import javax.ws.rs.Path; + +import org.openecomp.aai.restcore.HttpMethod; + +@Path("{version: v[8-9]|v1[0]}/bulkadd") +public class BulkAddConsumer extends BulkConsumer { + + @Override + protected boolean functionAllowed(HttpMethod method) { + + return method.equals(HttpMethod.PUT); + + } + + @Override + protected boolean enableResourceVersion() { + return true; + } + +} diff --git a/aai-resources/src/main/java/org/openecomp/aai/rest/BulkConsumer.java b/aai-resources/src/main/java/org/openecomp/aai/rest/BulkConsumer.java new file mode 100644 index 0000000..951c9ff --- /dev/null +++ b/aai-resources/src/main/java/org/openecomp/aai/rest/BulkConsumer.java @@ -0,0 +1,484 @@ +/*- + * ============LICENSE_START======================================================= + * org.openecomp.aai + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF 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.aai.rest; + +import java.io.UnsupportedEncodingException; +import java.net.URI; +import java.util.ArrayList; +import java.util.List; + +import javax.servlet.http.HttpServletRequest; +import javax.ws.rs.Consumes; +import javax.ws.rs.PUT; +import javax.ws.rs.PathParam; +import javax.ws.rs.Produces; +import javax.ws.rs.core.Context; +import javax.ws.rs.core.HttpHeaders; +import javax.ws.rs.core.MediaType; +import javax.ws.rs.core.Response; +import javax.ws.rs.core.Response.Status; +import javax.ws.rs.core.UriBuilder; +import javax.ws.rs.core.UriInfo; + +import org.javatuples.Pair; +import org.javatuples.Triplet; + +import org.openecomp.aai.dbmap.DBConnectionType; +import org.openecomp.aai.exceptions.AAIException; +import org.openecomp.aai.introspection.Introspector; +import org.openecomp.aai.introspection.Loader; +import org.openecomp.aai.introspection.ModelType; +import org.openecomp.aai.introspection.Version; +import org.openecomp.aai.introspection.exceptions.AAIUnmarshallingException; +import org.openecomp.aai.logging.ErrorObjectNotFoundException; +import org.openecomp.aai.parsers.query.QueryParser; +import org.openecomp.aai.rest.db.DBRequest; +import org.openecomp.aai.rest.db.HttpEntry; +import org.openecomp.aai.rest.util.ValidateEncoding; +import org.openecomp.aai.restcore.HttpMethod; +import org.openecomp.aai.restcore.RESTAPI; +import org.openecomp.aai.serialization.engines.QueryStyle; +import org.openecomp.aai.serialization.engines.TransactionalGraphEngine; +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParser; +import com.google.gson.JsonSyntaxException; + +/** + * The Class BulkAddConsumer. + */ +/* + * The purpose of this endpoint is to allow a client to add + * multiple objects with one request. It may take + * one or more transaction objects containing one or more + * objects to add. + * The transactions are independent of each other - + * if one fails, its effects are rolled back, but the others' aren't. + * Within a single transaction, if adding one object fails, all the others' + * changes are rolled back. + */ +public abstract class BulkConsumer extends RESTAPI { + + /** The introspector factory type. */ + private ModelType introspectorFactoryType = ModelType.MOXY; + + /** The query style. */ + private QueryStyle queryStyle = QueryStyle.TRAVERSAL; + + /** + * Bulk add. + * + * @param content the content + * @param versionParam the version param + * @param uri the uri + * @param headers the headers + * @param info the info + * @param req the req + * @return the response + */ + @PUT + @Consumes({ MediaType.APPLICATION_JSON}) + @Produces({ MediaType.APPLICATION_JSON}) + public Response bulkAdd(String content, @PathParam("version")String versionParam, @Context HttpHeaders headers, @Context UriInfo info, @Context HttpServletRequest req){ + + String transId = headers.getRequestHeaders().getFirst("X-TransactionId"); + String sourceOfTruth = headers.getRequestHeaders().getFirst("X-FromAppId"); + String realTime = headers.getRequestHeaders().getFirst("Real-Time"); + String outputMediaType = getMediaType(headers.getAcceptableMediaTypes()); + Version version = Version.valueOf(versionParam); + DBConnectionType type = this.determineConnectionType(sourceOfTruth, realTime); + + Response response = null; + + /* A Response will be generated for each object in each transaction. + * To keep track of what came from where to give organized feedback to the client, + * we keep responses from a given transaction together in one list (hence all being a list of lists) + * and pair each response with its matching URI (which will be null if there wasn't one). + */ + List>> allResponses = new ArrayList>>(); + + try { + //TODO add auth check when this endpoint added to that auth properties files + + + JsonArray transactions = getTransactions(content); + + for (int i = 0; i < transactions.size(); i++){ + HttpEntry httpEntry = new HttpEntry(version, introspectorFactoryType, queryStyle, type); + Loader loader = httpEntry.getLoader(); + TransactionalGraphEngine dbEngine = httpEntry.getDbEngine(); + URI thisUri = null; + List> triplet = new ArrayList>(); + HttpMethod method = null; + try { + JsonElement transObj = transactions.get(i); + if (!(transObj instanceof JsonObject)) { + throw new AAIException("AAI_6111", "input payload does not follow bulk add interface"); + } + //JsonObject transaction = transObj.getAsJsonObject(); + + fillObjectTuplesFromTransaction(triplet, transObj.getAsJsonObject(), loader, dbEngine, outputMediaType); + if (triplet.size() == 0) { + //case where user sends a validly formatted transactions object but + //which has no actual things in it for A&AI to do anything with + //assuming we should count this as a user error + throw new AAIException("AAI_6118", "payload had no objects to operate on"); + } + + List requests = new ArrayList<>(); + for (Triplet tuple : triplet){ + thisUri = tuple.getValue0(); + method = tuple.getValue2(); + QueryParser uriQuery = dbEngine.getQueryBuilder().createQueryFromURI(thisUri); + DBRequest request = new DBRequest.Builder(method, thisUri, uriQuery, tuple.getValue1(), headers, info, transId).build(); + requests.add(request); + } + + Pair>> results = httpEntry.process(requests, sourceOfTruth, this.enableResourceVersion()); + List> responses = results.getValue1(); + allResponses.add(responses); + if (results.getValue0()) { //everything was processed without error + dbEngine.commit(); + } else { //something failed + dbEngine.rollback(); + } + } catch (Exception e) { + /* While httpEntry.process handles its exceptions, exceptions thrown in earlier helpers + * bubbles up to here. As we want to tie error messages to the URI of the object that caused + * them, we catch here, generate a Response, bundle it with that URI, and move on. + */ + method = HttpMethod.PUT; + if (triplet.size() != 0) { //failed somewhere in the middle of tuple-filling + Triplet lastTuple = triplet.get(triplet.size()-1); //last one in there was the problem + if (lastTuple.getValue1() == null){ + //failed out before thisUri could be set but after tuples started being filled + thisUri = lastTuple.getValue0(); + method = lastTuple.getValue2(); + } + } //else failed out on empty payload so tuples never filled (or failed out even earlier than tuple-filling) + addExceptionCaseFailureResponse(allResponses, e, i, thisUri, headers, info, method); + dbEngine.rollback(); + continue; /* if an exception gets thrown within a transaction we want to keep going to + the next transaction, not break out of the whole request */ + } + } + + String returnPayload = generateResponsePayload(allResponses); + + //unless a top level error gets thrown, we want to 201 bc the client wanted a "fire and forget" kind of setup + response = Response + .status(Status.CREATED) + .entity(returnPayload) + .build(); + } catch (AAIException e) { //these catches needed for handling top level errors in payload parsing where the whole request must fail out + response = consumerExceptionResponseGenerator(headers, info, HttpMethod.PUT, e); + } catch(JsonSyntaxException e) { + AAIException ex = new AAIException("AAI_6111"); + response = consumerExceptionResponseGenerator(headers, info, HttpMethod.PUT, ex); + } catch (Exception e ) { + AAIException ex = new AAIException("AAI_4000", e); + response = consumerExceptionResponseGenerator(headers, info, HttpMethod.PUT, ex); + } + + return response; + } + + + /** + * Gets the transactions. + * + * @param content - input JSON payload string + * @return JsonArray - the array of transactions + * @throws AAIException the AAI exception + * @throws JsonSyntaxException Parses and breaks the single payload into an array of individual transaction + * bodies to be processed. + */ + private JsonArray getTransactions(String content) throws AAIException, JsonSyntaxException { + JsonParser parser = new JsonParser(); + + JsonObject input = parser.parse(content).getAsJsonObject(); + + if (!(input.has("transactions"))) { + throw new AAIException("AAI_6118", "input payload does not follow bulk add interface - missing \"transactions\""); + } + JsonElement transactionsObj = input.get("transactions"); + + if (!(transactionsObj.isJsonArray())){ + throw new AAIException("AAI_6111", "input payload does not follow bulk add interface"); + } + JsonArray transactions = transactionsObj.getAsJsonArray(); + if (transactions.size() == 0) { + //case where user sends a validly formatted transactions object but + //which has no actual things in it for A&AI to do anything with + //assuming we should count this as a user error + throw new AAIException("AAI_6118", "payload had no objects to operate on"); + } + return transactions; + } + + /** + * Fill object tuples from transaction. + * + * @param tuples the tuples + * @param transaction - JSON body containing the objects to be added + * each object must have a URI and an object body + * @param loader the loader + * @param dbEngine the db engine + * @param inputMediaType the input media type + * @return list of tuples containing each introspector-wrapped object and its given URI + * @throws AAIException the AAI exception + * @throws JsonSyntaxException the json syntax exception + * @throws UnsupportedEncodingException Walks through the given transaction and unmarshals each object in it, then bundles each + * with its URI. + */ + private void fillObjectTuplesFromTransaction(List> triplet, + JsonObject transaction, Loader loader, TransactionalGraphEngine dbEngine, String inputMediaType) + throws AAIException, JsonSyntaxException, UnsupportedEncodingException { + + + if (transaction.has("put") && this.functionAllowed(HttpMethod.PUT)) { + pairUp(triplet, transaction, loader, dbEngine, inputMediaType, HttpMethod.PUT); + } + else if (transaction.has("delete") && this.functionAllowed(HttpMethod.DELETE)) { + pairUp(triplet, transaction, loader, dbEngine, inputMediaType, HttpMethod.DELETE); + } + else if (transaction.has("patch") && this.functionAllowed(HttpMethod.MERGE_PATCH)) { + pairUp(triplet, transaction, loader, dbEngine, inputMediaType, HttpMethod.MERGE_PATCH); + } + + else{ + + throw new AAIException("AAI_6118", "input payload does not follow bulk add interface - missing put delete or patch"); + } + + + + } + + + + private void pairUp(List> triplet, JsonObject item, Loader loader, TransactionalGraphEngine dbEngine, String inputMediaType, HttpMethod method) throws AAIException, JsonSyntaxException, UnsupportedEncodingException{ + + + for (int i=0; i tuple = Triplet.with(null, null,null); + + tuple = tuple.setAt2(method); + try { + if (!(item.isJsonObject())) { + throw new AAIException("AAI_6111", "input payload does not follow bulk add interface"); + } + + + JsonElement actionElement = null; + + if(item.has("put")){ + actionElement = item.get("put"); + } else if(item.has("patch")){ + actionElement = item.get("patch"); + } else if(item.has("delete")){ + actionElement = item.get("delete"); + } + + if (!actionElement.isJsonArray()) { + throw new AAIException("AAI_6111", "input payload does not follow bulk add interface"); + } + JsonArray httpArray = actionElement.getAsJsonArray(); + for(int j = 0; j < httpArray.size(); ++j){ + JsonObject it = httpArray.get(j).getAsJsonObject(); + JsonElement itemURIfield = it.get("uri"); + if (itemURIfield == null) { + throw new AAIException("AAI_6118", "must include object uri"); + } + String uriStr = itemURIfield.getAsString(); + if (uriStr.endsWith("/relationship-list/relationship")) { + if (method.equals(HttpMethod.PUT)) { + tuple = tuple.setAt2(HttpMethod.PUT_EDGE); + } else if (method.equals(HttpMethod.DELETE)) { + tuple = tuple.setAt2(HttpMethod.DELETE_EDGE); + } + } else { + tuple = tuple.setAt2(method); + } + + URI uri = UriBuilder.fromPath(uriStr).build(); + + /* adding the uri as soon as we have one (valid or not) lets us + * keep any errors with their corresponding uris for client feedback + */ + tuple = tuple.setAt0(uri); + + if (!ValidateEncoding.getInstance().validate(uri)) { + throw new AAIException("AAI_3008", "uri=" + uri.getPath()); + } + + if (!(it.has("body"))){ + throw new AAIException("AAI_6118", "input payload does not follow bulk add interface - missing \"body\""); + } + JsonElement bodyObj = it.get("body"); + if (!(bodyObj.isJsonObject())) { + throw new AAIException("AAI_6111", "input payload does not follow bulk add interface"); + } + + Gson gson = new Gson(); + + String bodyStr = gson.toJson(bodyObj); + + if (tuple.getValue2().equals(HttpMethod.PUT_EDGE)) { + Introspector obj; + try { + obj = loader.unmarshal("relationship", bodyStr, org.openecomp.aai.restcore.MediaType.getEnum(inputMediaType)); + } catch (AAIUnmarshallingException e) { + throw new AAIException("AAI_3000", "object could not be unmarshalled:" + bodyStr); + + } + + + tuple = tuple.setAt1(obj); + + } else { + QueryParser uriQuery = dbEngine.getQueryBuilder().createQueryFromURI(uri); + String objName = uriQuery.getResultType(); + + Introspector obj; + try { + obj = loader.unmarshal(objName, bodyStr, org.openecomp.aai.restcore.MediaType.getEnum(inputMediaType)); + } catch (AAIUnmarshallingException e) { + throw new AAIException("AAI_3000", "object could not be unmarshalled:" + bodyStr); + + } + + this.validateIntrospector(obj, loader, uri, tuple.getValue2()); + tuple = tuple.setAt1(obj); + } + triplet.add(tuple); + } +// JsonElement itemURIfield = item.get("uri"); + + } catch (AAIException e) { + // even if tuple doesn't have a uri or body, this way we keep all information associated with this error together + // even if both are null, that indicates how the input was messed up, so still useful to carry around like this + triplet.add(tuple); + throw e; //rethrow so the right response is generated on the level above + } + } + } + + + + /** + * Generate response payload. + * + * @param allResponses - the list of the lists of responses from every action in every transaction requested + * @return A json string of similar format to the bulk add interface which for each response includes + * the original URI and a body with the status code of the response and the error message. + * + * Creates the payload for a single unified response from all responses generated + */ + private String generateResponsePayload(List>> allResponses){ + JsonObject ret = new JsonObject(); + JsonArray retArr = new JsonArray(); + + for(List> responses : allResponses){ + JsonObject tResp = new JsonObject(); + JsonArray tArrResp = new JsonArray(); + + for (Pair r : responses) { + JsonObject indPayload = new JsonObject(); + + URI origURI = r.getValue0(); + if (origURI != null) { + indPayload.addProperty("uri", origURI.getPath()); + } else { + indPayload.addProperty("uri", (String)null); + } + + JsonObject body = new JsonObject(); + + int rStatus = r.getValue1().getStatus(); + String rContents = null; + + rContents = (String)r.getValue1().getEntity(); + + body.addProperty(new Integer(rStatus).toString(), rContents); + indPayload.add("body", body); + + tArrResp.add(indPayload); + } + + tResp.add("put", tArrResp); + retArr.add(tResp); + } + ret.add("transaction", retArr); + Gson gson = new GsonBuilder().serializeNulls().create(); + String jsonStr = gson.toJson(ret); + return jsonStr; + } + + /** + * Adds the exception case failure response. + * + * @param allResponses the all responses + * @param e the e + * @param index - index of which transaction was being processed when the exception was thrown + * @param thisUri the this uri + * @param headers the headers + * @param info the info + * @param templateAction the template action + * @param logline Generates a Response based on the given exception and adds it to the collection of responses for this request. + * @throws ErrorObjectNotFoundException + */ + private void addExceptionCaseFailureResponse(List>> allResponses, Exception e, int index, URI thisUri, HttpHeaders headers, UriInfo info, HttpMethod templateAction) { + AAIException ex = null; + + if (!(e instanceof AAIException)){ + ex = new AAIException("AAI_4000", e); + } else { + ex = (AAIException)e; + } + + if (allResponses.size() != (index+1)) { + //index+1 bc if all transactions thus far have had a response list added + //the size will be one more than the current index (since those are offset by 1) + + //this transaction doesn't have a response list yet, so create one + Response failResp = consumerExceptionResponseGenerator(headers, info, templateAction, ex); + Pair uriResp = Pair.with(thisUri, failResp); + List> transRespList = new ArrayList>(); + transRespList.add(uriResp); + allResponses.add(transRespList); + } else { + //this transaction already has a response list, so add this failure response to it + Response failResp = consumerExceptionResponseGenerator(headers, info, templateAction, ex); + Pair uriResp = Pair.with(thisUri, failResp); + List> tResps = allResponses.get(index); + tResps.add(uriResp); + } + } + + protected abstract boolean functionAllowed(HttpMethod method); + + protected abstract boolean enableResourceVersion(); + +} diff --git a/aai-resources/src/main/java/org/openecomp/aai/rest/BulkProcessConsumer.java b/aai-resources/src/main/java/org/openecomp/aai/rest/BulkProcessConsumer.java new file mode 100644 index 0000000..91867ef --- /dev/null +++ b/aai-resources/src/main/java/org/openecomp/aai/rest/BulkProcessConsumer.java @@ -0,0 +1,42 @@ +/*- + * ============LICENSE_START======================================================= + * org.openecomp.aai + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF 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.aai.rest; + +import javax.ws.rs.Path; + +import org.openecomp.aai.restcore.HttpMethod; + +@Path("{version: v[2789]|v1[0]}/bulkprocess") +public class BulkProcessConsumer extends BulkConsumer { + + @Override + protected boolean functionAllowed(HttpMethod method) { + + return method.equals(HttpMethod.PUT) || method.equals(HttpMethod.DELETE) || method.equals(HttpMethod.MERGE_PATCH); + } + + @Override + protected boolean enableResourceVersion() { + // TODO Auto-generated method stub + return true; + } + +} diff --git a/aai-resources/src/main/java/org/openecomp/aai/rest/ExampleConsumer.java b/aai-resources/src/main/java/org/openecomp/aai/rest/ExampleConsumer.java new file mode 100644 index 0000000..de59955 --- /dev/null +++ b/aai-resources/src/main/java/org/openecomp/aai/rest/ExampleConsumer.java @@ -0,0 +1,104 @@ +/*- + * ============LICENSE_START======================================================= + * org.openecomp.aai + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF 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.aai.rest; + +import javax.servlet.http.HttpServletRequest; +import javax.ws.rs.GET; +import javax.ws.rs.Path; +import javax.ws.rs.PathParam; +import javax.ws.rs.Produces; +import javax.ws.rs.core.Context; +import javax.ws.rs.core.HttpHeaders; +import javax.ws.rs.core.MediaType; +import javax.ws.rs.core.Response; +import javax.ws.rs.core.Response.Status; +import javax.ws.rs.core.UriInfo; + +import org.openecomp.aai.exceptions.AAIException; +import org.openecomp.aai.introspection.Introspector; +import org.openecomp.aai.introspection.Loader; +import org.openecomp.aai.introspection.LoaderFactory; +import org.openecomp.aai.introspection.MarshallerProperties; +import org.openecomp.aai.introspection.ModelType; +import org.openecomp.aai.introspection.Version; +import org.openecomp.aai.introspection.generator.CreateExample; +import org.openecomp.aai.restcore.HttpMethod; +import org.openecomp.aai.restcore.RESTAPI; + +/** + * The Class ExampleConsumer. + */ +@Path("/{version: v[2789]|v1[0]}/examples") +public class ExampleConsumer extends RESTAPI { + + + /** + * Gets the example. + * + * @param versionParam the version param + * @param type the type + * @param headers the headers + * @param info the info + * @param req the req + * @return the example + */ + @GET + @Path("/{objectType: [^\\/]+}") + @Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML }) + public Response getExample(@PathParam("version")String versionParam, @PathParam("objectType")String type, @Context HttpHeaders headers, @Context UriInfo info, @Context HttpServletRequest req) { + + Status status = Status.INTERNAL_SERVER_ERROR; + Response response = null; + + try { + String mediaType = getMediaType(headers.getAcceptableMediaTypes()); + org.openecomp.aai.restcore.MediaType outputMediaType = org.openecomp.aai.restcore.MediaType.getEnum(mediaType); + + Version version = Version.valueOf(versionParam); + Loader loader = LoaderFactory.createLoaderForVersion(ModelType.MOXY, version); + + CreateExample example = new CreateExample(loader, type); + + Introspector obj = example.getExampleObject(); + String result = ""; + if (obj != null) { + status = Status.OK; + MarshallerProperties properties = + new MarshallerProperties.Builder(outputMediaType).build(); + result = obj.marshal(properties); + } else { + + } + response = Response + .ok(obj) + .entity(result) + .status(status) + .type(outputMediaType.toString()).build(); + } catch (AAIException e) { + //TODO check that the details here are sensible + response = consumerExceptionResponseGenerator(headers, info, HttpMethod.GET, e); + } catch (Exception e) { + AAIException ex = new AAIException("AAI_4000", e); + response = consumerExceptionResponseGenerator(headers, info, HttpMethod.GET, ex); + } + return response; + } +} diff --git a/aai-resources/src/main/java/org/openecomp/aai/rest/ExceptionHandler.java b/aai-resources/src/main/java/org/openecomp/aai/rest/ExceptionHandler.java new file mode 100644 index 0000000..f1a6f47 --- /dev/null +++ b/aai-resources/src/main/java/org/openecomp/aai/rest/ExceptionHandler.java @@ -0,0 +1,129 @@ +/*- + * ============LICENSE_START======================================================= + * org.openecomp.aai + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF 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.aai.rest; + +import java.util.ArrayList; +import java.util.List; + +import javax.servlet.http.HttpServletRequest; +import javax.ws.rs.WebApplicationException; +import javax.ws.rs.core.Context; +import javax.ws.rs.core.HttpHeaders; +import javax.ws.rs.core.MediaType; +import javax.ws.rs.core.Response; +import javax.ws.rs.ext.ExceptionMapper; +import javax.ws.rs.ext.Provider; + +import org.openecomp.aai.exceptions.AAIException; +import org.openecomp.aai.logging.ErrorLogHelper; +import com.fasterxml.jackson.core.JsonParseException; +import com.fasterxml.jackson.databind.JsonMappingException; +import com.sun.istack.SAXParseException2; + +/** + * The Class ExceptionHandler. + */ +@Provider +public class ExceptionHandler implements ExceptionMapper { + + @Context + private HttpServletRequest request; + + @Context + private HttpHeaders headers; + + /** + * @{inheritDoc} + */ + @Override + public Response toResponse(Exception exception) { + + Response response = null; + ArrayList templateVars = new ArrayList(); + + //the general case is that cxf will give us a WebApplicationException + //with a linked exception + if (exception instanceof WebApplicationException) { + WebApplicationException e = (WebApplicationException) exception; + if (e.getCause() != null) { + if (e.getCause() instanceof SAXParseException2) { + templateVars.add("UnmarshalException"); + AAIException ex = new AAIException("AAI_4007", exception); + response = Response + .status(400) + .entity(ErrorLogHelper.getRESTAPIErrorResponse(headers.getAcceptableMediaTypes(), ex, templateVars)) + .build(); + } + } + } else if (exception instanceof JsonParseException) { + //jackson does it differently so we get the direct JsonParseException + templateVars.add("JsonParseException"); + AAIException ex = new AAIException("AAI_4007", exception); + response = Response + .status(400) + .entity(ErrorLogHelper.getRESTAPIErrorResponse(headers.getAcceptableMediaTypes(), ex, templateVars)) + .build(); + } else if (exception instanceof JsonMappingException) { + //jackson does it differently so we get the direct JsonParseException + templateVars.add("JsonMappingException"); + AAIException ex = new AAIException("AAI_4007", exception); + response = Response + .status(400) + .entity(ErrorLogHelper.getRESTAPIErrorResponse(headers.getAcceptableMediaTypes(), ex, templateVars)) + .build(); + } + + // it didn't get set above, we wrap a general fault here + if (response == null) { + + Exception actual_e = exception; + if (exception instanceof WebApplicationException) { + WebApplicationException e = (WebApplicationException) exception; + response = e.getResponse(); + } else { + templateVars.add(request.getMethod()); + templateVars.add("unknown"); + AAIException ex = new AAIException("AAI_4000", actual_e); + List mediaTypes = headers.getAcceptableMediaTypes(); + int setError = 0; + + for (MediaType mediaType : mediaTypes) { + if (MediaType.APPLICATION_XML_TYPE.isCompatible(mediaType)) { + response = Response + .status(400) + .type(MediaType.APPLICATION_XML_TYPE) + .entity(ErrorLogHelper.getRESTAPIErrorResponse(headers.getAcceptableMediaTypes(), ex, templateVars)) + .build(); + setError = 1; + } + } + if (setError == 0) { + response = Response + .status(400) + .type(MediaType.APPLICATION_JSON_TYPE) + .entity(ErrorLogHelper.getRESTAPIErrorResponse(headers.getAcceptableMediaTypes(), ex, templateVars)) + .build(); + } + } + } + return response; + } +} diff --git a/aai-resources/src/main/java/org/openecomp/aai/rest/LegacyMoxyConsumer.java b/aai-resources/src/main/java/org/openecomp/aai/rest/LegacyMoxyConsumer.java new file mode 100644 index 0000000..7af432d --- /dev/null +++ b/aai-resources/src/main/java/org/openecomp/aai/rest/LegacyMoxyConsumer.java @@ -0,0 +1,583 @@ +/*- + * ============LICENSE_START======================================================= + * org.openecomp.aai + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF 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.aai.rest; + +import java.io.UnsupportedEncodingException; +import java.net.URI; +import java.util.ArrayList; +import java.util.HashSet; +import java.util.List; +import java.util.Set; + +import javax.servlet.http.HttpServletRequest; +import javax.ws.rs.Consumes; +import javax.ws.rs.DELETE; +import javax.ws.rs.DefaultValue; +import javax.ws.rs.Encoded; +import javax.ws.rs.GET; +import javax.ws.rs.PUT; +import javax.ws.rs.Path; +import javax.ws.rs.PathParam; +import javax.ws.rs.Produces; +import javax.ws.rs.QueryParam; +import javax.ws.rs.core.Context; +import javax.ws.rs.core.HttpHeaders; +import javax.ws.rs.core.MediaType; +import javax.ws.rs.core.MultivaluedMap; +import javax.ws.rs.core.Response; +import javax.ws.rs.core.UriBuilder; +import javax.ws.rs.core.UriInfo; + +import org.apache.cxf.jaxrs.ext.PATCH; +import org.javatuples.Pair; + +import org.openecomp.aai.dbmap.DBConnectionType; +import org.openecomp.aai.exceptions.AAIException; +import org.openecomp.aai.introspection.Introspector; +import org.openecomp.aai.introspection.Loader; +import org.openecomp.aai.introspection.ModelType; +import org.openecomp.aai.introspection.Version; +import org.openecomp.aai.parsers.query.QueryParser; +import org.openecomp.aai.rest.db.DBRequest; +import org.openecomp.aai.rest.db.HttpEntry; +import org.openecomp.aai.rest.util.ValidateEncoding; +import org.openecomp.aai.restcore.HttpMethod; +import org.openecomp.aai.restcore.RESTAPI; +import org.openecomp.aai.serialization.engines.QueryStyle; +import org.openecomp.aai.serialization.engines.TransactionalGraphEngine; +import org.openecomp.aai.workarounds.RemoveDME2QueryParams; +import com.att.eelf.configuration.EELFLogger; +import com.att.eelf.configuration.EELFManager; +import com.google.common.base.Joiner; +import com.thinkaurelius.titan.core.TitanTransaction; + + +/** + * The Class LegacyMoxyConsumer. + */ +@Path("{version: v[2789]|v1[0]}") +public class LegacyMoxyConsumer extends RESTAPI { + + private static final EELFLogger LOGGER = EELFManager.getInstance().getLogger(LegacyMoxyConsumer.class.getName()); + protected static String authPolicyFunctionName = "REST"; + private ModelType introspectorFactoryType = ModelType.MOXY; + private QueryStyle queryStyle = QueryStyle.TRAVERSAL; + + /** + * Update. + * + * @param content the content + * @param versionParam the version param + * @param uri the uri + * @param headers the headers + * @param info the info + * @param req the req + * @return the response + */ + @PUT + @Path("/{uri: .+}") + @Consumes({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML }) + @Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML }) + public Response update (String content, @PathParam("version")String versionParam, @PathParam("uri") @Encoded String uri, @Context HttpHeaders headers, @Context UriInfo info, @Context HttpServletRequest req) { + + MediaType mediaType = headers.getMediaType(); + + return this.handleWrites(Action.PUT, mediaType, HttpMethod.PUT, content, versionParam, uri, headers, info, req); + } + + /** + * Update relationship. + * + * @param content the content + * @param versionParam the version param + * @param uri the uri + * @param headers the headers + * @param info the info + * @param req the req + * @return the response + */ + @PUT + @Path("/{uri: .+}/relationship-list/relationship") + @Consumes({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML }) + @Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML }) + public Response updateRelationship (String content, @PathParam("version")String versionParam, @PathParam("uri") @Encoded String uri, @Context HttpHeaders headers, @Context UriInfo info, @Context HttpServletRequest req) { + + String sourceOfTruth = headers.getRequestHeaders().getFirst("X-FromAppId"); + String transId = headers.getRequestHeaders().getFirst("X-TransactionId"); + String realTime = headers.getRequestHeaders().getFirst("Real-Time"); + MediaType inputMediaType = headers.getMediaType(); + Response response = null; + Loader loader = null; + TransactionalGraphEngine dbEngine = null; + TitanTransaction g = null; + boolean success = true; + + try { + validateRequest(info); + Version version = Version.valueOf(versionParam); + version = Version.valueOf(versionParam); + DBConnectionType type = this.determineConnectionType(sourceOfTruth, realTime); + HttpEntry httpEntry = new HttpEntry(version, introspectorFactoryType, queryStyle, type); + loader = httpEntry.getLoader(); + dbEngine = httpEntry.getDbEngine(); + + URI uriObject = UriBuilder.fromPath(uri).build(); + + QueryParser uriQuery = dbEngine.getQueryBuilder().createQueryFromURI(uriObject); + + Introspector wrappedEntity = loader.unmarshal("relationship", content, org.openecomp.aai.restcore.MediaType.getEnum(this.getInputMediaType(inputMediaType))); + + DBRequest request = new DBRequest.Builder(HttpMethod.PUT_EDGE, uriObject, uriQuery, wrappedEntity, headers, info, transId).build(); + List requests = new ArrayList<>(); + requests.add(request); + Pair>> responsesTuple = httpEntry.process(requests, sourceOfTruth); + + response = responsesTuple.getValue1().get(0).getValue1(); + success = responsesTuple.getValue0(); + + } catch (AAIException e) { + response = consumerExceptionResponseGenerator(headers, info, HttpMethod.PUT, e); + success = false; + } catch (Exception e) { + AAIException aaiException = new AAIException("AAI_4000", e); + response = consumerExceptionResponseGenerator(headers, info, HttpMethod.PUT, aaiException); + success = false; + } finally { + if (dbEngine != null) { + if (success) { + dbEngine.commit(); + } else { + LOGGER.warn("Rolling back Titan transaction"); + dbEngine.rollback(); + } + } + + } + + return response; + } + + /** + * Patch. + * + * @param content the content + * @param versionParam the version param + * @param uri the uri + * @param headers the headers + * @param info the info + * @param req the req + * @return the response + */ + @PATCH + @Path("/{uri: .+}") + @Consumes({ "application/merge-patch+json" }) + @Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML }) + public Response patch (String content, @PathParam("version")String versionParam, @PathParam("uri") @Encoded String uri, @Context HttpHeaders headers, @Context UriInfo info, @Context HttpServletRequest req) { + + MediaType mediaType = MediaType.APPLICATION_JSON_TYPE; + + return this.handleWrites(Action.PUT, mediaType, HttpMethod.MERGE_PATCH, content, versionParam, uri, headers, info, req); + + } + + /** + * Gets the legacy. + * + * @param content the content + * @param versionParam the version param + * @param uri the uri + * @param depthParam the depth param + * @param cleanUp the clean up + * @param headers the headers + * @param info the info + * @param req the req + * @return the legacy + */ + @GET + @Path("/{uri: .+}") + @Consumes({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML }) + @Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML }) + public Response getLegacy (String content, @PathParam("version")String versionParam, @PathParam("uri") @Encoded String uri, @DefaultValue("all") @QueryParam("depth") String depthParam, @DefaultValue("false") @QueryParam("cleanup") String cleanUp, @Context HttpHeaders headers, @Context UriInfo info, @Context HttpServletRequest req) { + + return this.getLegacy(content, versionParam, uri, depthParam, cleanUp, headers, info, req, new HashSet()); + } + + /** + * This method exists as a workaround for filtering out undesired query params while routing between REST consumers + * + * @param content + * @param versionParam + * @param uri + * @param depthParam + * @param cleanUp + * @param headers + * @param info + * @param req + * @param removeQueryParams + * @return + */ + public Response getLegacy(String content, String versionParam, String uri, String depthParam, String cleanUp, HttpHeaders headers, UriInfo info, HttpServletRequest req, Set removeQueryParams) { + String sourceOfTruth = headers.getRequestHeaders().getFirst("X-FromAppId"); + String transId = headers.getRequestHeaders().getFirst("X-TransactionId"); + String realTime = headers.getRequestHeaders().getFirst("Real-Time"); + Response response = null; + TransactionalGraphEngine dbEngine = null; + TitanTransaction g = null; + Loader loader = null; + + try { + validateRequest(info); + Version version = Version.valueOf(versionParam); + DBConnectionType type = this.determineConnectionType(sourceOfTruth, realTime); + final HttpEntry httpEntry = new HttpEntry(version, introspectorFactoryType, queryStyle, type); + dbEngine = httpEntry.getDbEngine(); + loader = httpEntry.getLoader(); + MultivaluedMap params = info.getQueryParameters(); + + RemoveDME2QueryParams dme2Workaround = new RemoveDME2QueryParams(); + //clear out all params not used for filtering + params.remove("depth"); + params.remove("cleanup"); + params.remove("nodes-only"); + for (String queryParam : removeQueryParams) { + params.remove(queryParam); + } + if (dme2Workaround.shouldRemoveQueryParams(params)) { + dme2Workaround.removeQueryParams(params); + } + + uri = uri.split("\\?")[0]; + + URI uriObject = UriBuilder.fromPath(uri).build(); + + QueryParser uriQuery = dbEngine.getQueryBuilder().createQueryFromURI(uriObject, params); + + String objType = ""; + if (!uriQuery.getContainerType().equals("")) { + objType = uriQuery.getContainerType(); + } else { + objType = uriQuery.getResultType(); + } + Introspector obj = loader.introspectorFromName(objType); + DBRequest request = + new DBRequest.Builder(HttpMethod.GET, uriObject, uriQuery, obj, headers, info, transId).build(); + List requests = new ArrayList<>(); + requests.add(request); + Pair>> responsesTuple = httpEntry.process(requests, sourceOfTruth); + + response = responsesTuple.getValue1().get(0).getValue1(); + + } catch (AAIException e) { + response = consumerExceptionResponseGenerator(headers, info, HttpMethod.GET, e); + } catch (Exception e ) { + AAIException ex = new AAIException("AAI_4000", e); + + response = consumerExceptionResponseGenerator(headers, info, HttpMethod.GET, ex); + } finally { + if (dbEngine != null) { + if (cleanUp.equals("true")) { + dbEngine.commit(); + } else { + dbEngine.rollback(); + } + } + } + + return response; + } + /** + * Delete. + * + * @param versionParam the version param + * @param uri the uri + * @param headers the headers + * @param info the info + * @param resourceVersion the resource version + * @param req the req + * @return the response + */ + @DELETE + @Path("/{uri: .+}") + @Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML }) + public Response delete (@PathParam("version")String versionParam, @PathParam("uri") @Encoded String uri, @Context HttpHeaders headers, @Context UriInfo info, @QueryParam("resource-version")String resourceVersion, @Context HttpServletRequest req) { + + + String outputMediaType = getMediaType(headers.getAcceptableMediaTypes()); + String sourceOfTruth = headers.getRequestHeaders().getFirst("X-FromAppId"); + String transId = headers.getRequestHeaders().getFirst("X-TransactionId"); + String realTime = headers.getRequestHeaders().getFirst("Real-Time"); + + TransactionalGraphEngine dbEngine = null; + Response response = Response.status(404) + .type(outputMediaType).build(); + + TitanTransaction g = null; + boolean success = true; + + try { + + validateRequest(info); + Version version = Version.valueOf(versionParam); + DBConnectionType type = this.determineConnectionType(sourceOfTruth, realTime); + HttpEntry httpEntry = new HttpEntry(version, introspectorFactoryType, queryStyle, type); + + dbEngine = httpEntry.getDbEngine(); + Loader loader = httpEntry.getLoader(); + + URI uriObject = UriBuilder.fromPath(uri).build(); + + QueryParser uriQuery = dbEngine.getQueryBuilder().createQueryFromURI(uriObject); + String objType = uriQuery.getResultType(); + Introspector obj = loader.introspectorFromName(objType); + + DBRequest request = new DBRequest.Builder(HttpMethod.DELETE, uriObject, uriQuery, obj, headers, info, transId).build(); + List requests = new ArrayList<>(); + requests.add(request); + Pair>> responsesTuple = httpEntry.process(requests, sourceOfTruth); + + response = responsesTuple.getValue1().get(0).getValue1(); + success = responsesTuple.getValue0(); + + } catch (AAIException e) { + response = consumerExceptionResponseGenerator(headers, info, HttpMethod.DELETE, e); + success = false; + } catch (Exception e) { + AAIException ex = new AAIException("AAI_4000", e); + response = consumerExceptionResponseGenerator(headers, info, HttpMethod.DELETE, ex); + success = false; + } finally { + if (dbEngine != null) { + if (success) { + dbEngine.commit(); + } else { + LOGGER.warn("Rolling back Titan transaction"); + dbEngine.rollback(); + } + } + } + + return response; + } + + /** + * This whole method does nothing because the body is being dropped while fielding the request. + * + * @param content the content + * @param versionParam the version param + * @param uri the uri + * @param headers the headers + * @param info the info + * @param req the req + * @return the response + */ + @DELETE + @Path("/{uri: .+}/relationship-list/relationship") + @Consumes({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML }) + @Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML }) + public Response deleteRelationship (String content, @PathParam("version")String versionParam, @PathParam("uri") @Encoded String uri, @Context HttpHeaders headers, @Context UriInfo info, @Context HttpServletRequest req) { + + MediaType inputMediaType = headers.getMediaType(); + + String outputMediaType = getMediaType(headers.getAcceptableMediaTypes()); + String sourceOfTruth = headers.getRequestHeaders().getFirst("X-FromAppId"); + String transId = headers.getRequestHeaders().getFirst("X-TransactionId"); + String realTime = headers.getRequestHeaders().getFirst("Real-Time"); + + Loader loader = null; + TransactionalGraphEngine dbEngine = null; + Response response = Response.status(404) + .type(outputMediaType).build(); + + TitanTransaction g = null; + boolean success = true; + + try { + this.validateRequest(info); + Version version = Version.valueOf(versionParam); + DBConnectionType type = this.determineConnectionType(sourceOfTruth, realTime); + HttpEntry httpEntry = new HttpEntry(version, introspectorFactoryType, queryStyle, type); + loader = httpEntry.getLoader(); + dbEngine = httpEntry.getDbEngine(); + + if (content.equals("")) { + throw new AAIException("AAI_3102", "You must supply a relationship"); + } + URI uriObject = UriBuilder.fromPath(uri).build(); + + QueryParser uriQuery = dbEngine.getQueryBuilder().createQueryFromURI(uriObject); + + Introspector wrappedEntity = loader.unmarshal("relationship", content, org.openecomp.aai.restcore.MediaType.getEnum(this.getInputMediaType(inputMediaType))); + + DBRequest request = new DBRequest.Builder(HttpMethod.DELETE_EDGE, uriObject, uriQuery, wrappedEntity, headers, info, transId).build(); + List requests = new ArrayList<>(); + requests.add(request); + Pair>> responsesTuple = httpEntry.process(requests, sourceOfTruth); + + response = responsesTuple.getValue1().get(0).getValue1(); + success = responsesTuple.getValue0(); + } catch (AAIException e) { + response = consumerExceptionResponseGenerator(headers, info, HttpMethod.DELETE, e); + success = false; + } catch (Exception e) { + AAIException ex = new AAIException("AAI_4000", e); + response = consumerExceptionResponseGenerator(headers, info, HttpMethod.DELETE, ex); + success = false; + } finally { + if (dbEngine != null) { + if (success) { + dbEngine.commit(); + } else { + LOGGER.warn("Rolling back Titan transaction"); + dbEngine.rollback(); + } + } + } + + return response; + } + + /** + * Validate request. + * + * @param uri the uri + * @param headers the headers + * @param req the req + * @param action the action + * @param info the info + * @throws AAIException the AAI exception + * @throws UnsupportedEncodingException the unsupported encoding exception + */ + private void validateRequest(UriInfo info) throws AAIException, UnsupportedEncodingException { + + if (!ValidateEncoding.getInstance().validate(info)) { + throw new AAIException("AAI_3008", "uri=" + getPath(info)); + } + } + + /** + * Gets the path. + * + * @param info the info + * @return the path + */ + private String getPath(UriInfo info) { + String path = info.getPath(false); + MultivaluedMap map = info.getQueryParameters(false); + String params = "?"; + List parmList = new ArrayList<>(); + for (String key : map.keySet()) { + for (String value : map.get(key)) { + parmList.add(key + "=" + value); + } + } + String queryParams = Joiner.on("&").join(parmList); + if (map.keySet().size() > 0) { + path += params + queryParams; + } + + return path; + + } + + /** + * Handle writes. + * + * @param aaiAction the aai action + * @param mediaType the media type + * @param method the method + * @param content the content + * @param versionParam the version param + * @param uri the uri + * @param headers the headers + * @param info the info + * @param req the req + * @return the response + */ + private Response handleWrites(Action aaiAction, MediaType mediaType, HttpMethod method, String content, String versionParam, String uri, HttpHeaders headers, UriInfo info, HttpServletRequest req) { + + Response response = null; + TransactionalGraphEngine dbEngine = null; + Loader loader = null; + Version version = null; + String sourceOfTruth = headers.getRequestHeaders().getFirst("X-FromAppId"); + String transId = headers.getRequestHeaders().getFirst("X-TransactionId"); + String realTime = headers.getRequestHeaders().getFirst("Real-Time"); + TitanTransaction g = null; + Boolean success = true; + + try { + + validateRequest(info); + + version = Version.valueOf(versionParam); + DBConnectionType type = this.determineConnectionType(sourceOfTruth, realTime); + HttpEntry httpEntry = new HttpEntry(version, introspectorFactoryType, queryStyle, type); + loader = httpEntry.getLoader(); + dbEngine = httpEntry.getDbEngine(); + URI uriObject = UriBuilder.fromPath(uri).build(); + + QueryParser uriQuery = dbEngine.getQueryBuilder().createQueryFromURI(uriObject); + String objName = uriQuery.getResultType(); + if (content.length() == 0) { + if (mediaType.toString().contains(MediaType.APPLICATION_JSON)) { + content = "{}"; + } else { + content = ""; + } + } + Introspector obj = loader.unmarshal(objName, content, org.openecomp.aai.restcore.MediaType.getEnum(this.getInputMediaType(mediaType))); + if (obj == null) { + throw new AAIException("AAI_3000", "object could not be unmarshalled:" + content); + } + + this.validateIntrospector(obj, loader, uriObject, method); + + DBRequest request = + new DBRequest.Builder(method, uriObject, uriQuery, obj, headers, info, transId) + .rawRequestContent(content).build(); + List requests = new ArrayList<>(); + requests.add(request); + Pair>> responsesTuple = httpEntry.process(requests, sourceOfTruth); + + response = responsesTuple.getValue1().get(0).getValue1(); + success = responsesTuple.getValue0(); + } catch (AAIException e) { + response = consumerExceptionResponseGenerator(headers, info, method, e); + success = false; + } catch (Exception e ) { + AAIException ex = new AAIException("AAI_4000", e); + response = consumerExceptionResponseGenerator(headers, info, method, ex); + success = false; + } finally { + if (dbEngine != null) { + if (success) { + dbEngine.commit(); + } else { + LOGGER.warn("Rolling back Titan transaction"); + dbEngine.rollback(); + } + } + } + + return response; + } + +} diff --git a/aai-resources/src/main/java/org/openecomp/aai/rest/URLFromVertexIdConsumer.java b/aai-resources/src/main/java/org/openecomp/aai/rest/URLFromVertexIdConsumer.java new file mode 100644 index 0000000..d67a008 --- /dev/null +++ b/aai-resources/src/main/java/org/openecomp/aai/rest/URLFromVertexIdConsumer.java @@ -0,0 +1,120 @@ +/*- + * ============LICENSE_START======================================================= + * org.openecomp.aai + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF 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.aai.rest; + +import java.net.URI; +import java.net.URL; +import java.util.Iterator; + +import javax.servlet.http.HttpServletRequest; +import javax.ws.rs.GET; +import javax.ws.rs.Path; +import javax.ws.rs.PathParam; +import javax.ws.rs.Produces; +import javax.ws.rs.core.Context; +import javax.ws.rs.core.HttpHeaders; +import javax.ws.rs.core.MediaType; +import javax.ws.rs.core.Response; +import javax.ws.rs.core.Response.Status; +import javax.ws.rs.core.UriInfo; + +import org.apache.tinkerpop.gremlin.structure.Vertex; + +import org.openecomp.aai.dbmap.DBConnectionType; +import org.openecomp.aai.exceptions.AAIException; +import org.openecomp.aai.introspection.ModelType; +import org.openecomp.aai.introspection.Version; +import org.openecomp.aai.rest.db.HttpEntry; +import org.openecomp.aai.restcore.HttpMethod; +import org.openecomp.aai.restcore.RESTAPI; +import org.openecomp.aai.serialization.db.DBSerializer; +import org.openecomp.aai.serialization.engines.QueryStyle; +import org.openecomp.aai.serialization.engines.TransactionalGraphEngine; +import org.openecomp.aai.util.AAIConfig; +import org.openecomp.aai.workarounds.LegacyURITransformer; + +/** + * The Class URLFromVertexIdConsumer. + */ +@Path("{version: v[2789]|v1[0]}/generateurl") +public class URLFromVertexIdConsumer extends RESTAPI { + private ModelType introspectorFactoryType = ModelType.MOXY; + private QueryStyle queryStyle = QueryStyle.TRAVERSAL; + + private final String ID_ENDPOINT = "/id/{vertexid: \\d+}"; + + /** + * Generate url from vertex id. + * + * @param content the content + * @param versionParam the version param + * @param vertexid the vertexid + * @param headers the headers + * @param info the info + * @param req the req + * @return the response + */ + @Path(ID_ENDPOINT) + @Produces({ MediaType.TEXT_PLAIN }) + public Response generateUrlFromVertexId(String content, @PathParam("version")String versionParam, @PathParam("vertexid")long vertexid, @Context HttpHeaders headers, @Context UriInfo info, @Context HttpServletRequest req) { + + String sourceOfTruth = headers.getRequestHeaders().getFirst("X-FromAppId"); + String realTime = headers.getRequestHeaders().getFirst("Real-Time"); + + Version version = Version.valueOf(versionParam); + StringBuilder result = new StringBuilder(); + Response response = null; + TransactionalGraphEngine dbEngine = null; + try { + DBConnectionType type = this.determineConnectionType(sourceOfTruth, realTime); + HttpEntry httpEntry = new HttpEntry(version, introspectorFactoryType, queryStyle, type); + dbEngine = httpEntry.getDbEngine(); + + DBSerializer serializer = new DBSerializer(version, dbEngine, introspectorFactoryType, sourceOfTruth); + + Iterator thisVertex = dbEngine.asAdmin().getTraversalSource().V(vertexid); + + if (!thisVertex.hasNext()) { + throw new AAIException("AAI_6114", "no node at that vertex id"); + } + URI uri = serializer.getURIForVertex(thisVertex.next()); + + result.append(uri.getRawPath()); + result.insert(0, version); + result.insert(0, AAIConfig.get("aai.server.url.base")); + LegacyURITransformer urlTransformer = LegacyURITransformer.getInstance(); + URI output = new URI(result.toString()); + + response = Response.ok().entity(result.toString()).status(Status.OK).type(MediaType.TEXT_PLAIN).build(); + } catch (AAIException e) { + //TODO check that the details here are sensible + response = consumerExceptionResponseGenerator(headers, info, HttpMethod.GET, e); + } catch (Exception e) { + AAIException ex = new AAIException("AAI_4000", e); + response = consumerExceptionResponseGenerator(headers, info, HttpMethod.GET, ex); + } finally { //to close the titan transaction (I think) + if (dbEngine != null) { + dbEngine.rollback(); + } + } + return response; + } +} diff --git a/aai-resources/src/main/java/org/openecomp/aai/rest/VertexIdConsumer.java b/aai-resources/src/main/java/org/openecomp/aai/rest/VertexIdConsumer.java new file mode 100644 index 0000000..9e1dcfc --- /dev/null +++ b/aai-resources/src/main/java/org/openecomp/aai/rest/VertexIdConsumer.java @@ -0,0 +1,145 @@ +/*- + * ============LICENSE_START======================================================= + * org.openecomp.aai + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF 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.aai.rest; + +import java.net.URI; +import java.util.ArrayList; +import java.util.Iterator; +import java.util.List; + +import javax.servlet.http.HttpServletRequest; +import javax.ws.rs.DefaultValue; +import javax.ws.rs.GET; +import javax.ws.rs.Path; +import javax.ws.rs.PathParam; +import javax.ws.rs.Produces; +import javax.ws.rs.QueryParam; +import javax.ws.rs.core.Context; +import javax.ws.rs.core.HttpHeaders; +import javax.ws.rs.core.MediaType; +import javax.ws.rs.core.Response; +import javax.ws.rs.core.Response.Status; +import javax.ws.rs.core.UriBuilder; +import javax.ws.rs.core.UriInfo; + +import org.apache.tinkerpop.gremlin.structure.Vertex; +import org.javatuples.Pair; + +import org.openecomp.aai.db.props.AAIProperties; +import org.openecomp.aai.dbmap.DBConnectionType; +import org.openecomp.aai.exceptions.AAIException; +import org.openecomp.aai.introspection.Introspector; +import org.openecomp.aai.introspection.Loader; +import org.openecomp.aai.introspection.MarshallerProperties; +import org.openecomp.aai.introspection.ModelType; +import org.openecomp.aai.introspection.Version; +import org.openecomp.aai.parsers.query.QueryParser; +import org.openecomp.aai.rest.db.DBRequest; +import org.openecomp.aai.rest.db.HttpEntry; +import org.openecomp.aai.restcore.HttpMethod; +import org.openecomp.aai.restcore.RESTAPI; +import org.openecomp.aai.serialization.db.DBSerializer; +import org.openecomp.aai.serialization.engines.QueryStyle; +import org.openecomp.aai.serialization.engines.TransactionalGraphEngine; + +/** + * The Class VertexIdConsumer. + */ +@Path("{version: v[2789]|v1[0]}/resources") +public class VertexIdConsumer extends RESTAPI { + + private ModelType introspectorFactoryType = ModelType.MOXY; + private QueryStyle queryStyle = QueryStyle.TRAVERSAL; + + private final String ID_ENDPOINT = "/id/{vertexid: \\d+}"; + + /** + * Gets the by vertex id. + * + * @param content the content + * @param versionParam the version param + * @param vertexid the vertexid + * @param depthParam the depth param + * @param headers the headers + * @param info the info + * @param req the req + * @return the by vertex id + */ + @GET + @Path(ID_ENDPOINT) + @Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML }) + public Response getByVertexId(String content, @PathParam("version")String versionParam, @PathParam("vertexid")long vertexid, @DefaultValue("all") @QueryParam("depth") String depthParam, @Context HttpHeaders headers, @Context UriInfo info, @Context HttpServletRequest req) { + + String outputMediaType = getMediaType(headers.getAcceptableMediaTypes()); + String sourceOfTruth = headers.getRequestHeaders().getFirst("X-FromAppId"); + String transId = headers.getRequestHeaders().getFirst("X-TransactionId"); + String realTime = headers.getRequestHeaders().getFirst("Real-Time"); + Version version = Version.valueOf(versionParam); + Status status = Status.NOT_FOUND; + String result = ""; + Response response = null; + TransactionalGraphEngine dbEngine = null; + try { + int depth = setDepth(depthParam); + DBConnectionType type = this.determineConnectionType(sourceOfTruth, realTime); + HttpEntry httpEntry = new HttpEntry(version, introspectorFactoryType, queryStyle, type); + dbEngine = httpEntry.getDbEngine(); + Loader loader = httpEntry.getLoader(); + + DBSerializer serializer = new DBSerializer(version, dbEngine, introspectorFactoryType, sourceOfTruth); + + //get type of the object represented by the given id + Vertex thisVertex = null; + Iterator itr = dbEngine.asAdmin().getTraversalSource().V(vertexid); + + if (!itr.hasNext()) { + throw new AAIException("AAI_6114", "no node at that vertex id"); + } + thisVertex = itr.next(); + String objName = thisVertex.property(AAIProperties.NODE_TYPE).orElse(null); + + QueryParser query = dbEngine.getQueryBuilder(thisVertex).createQueryFromObjectName(objName); + + Introspector obj = loader.introspectorFromName(query.getResultType()); + + URI uriObject = UriBuilder.fromPath(info.getPath()).build(); + + DBRequest request = + new DBRequest.Builder(HttpMethod.GET, uriObject, query, obj, headers, info, transId) + .customMarshaller(new MarshallerProperties.Builder(org.openecomp.aai.restcore.MediaType.getEnum(outputMediaType)).includeRoot(true).build()).build(); + + List requests = new ArrayList<>(); + requests.add(request); + Pair>> responsesTuple = httpEntry.process(requests, sourceOfTruth); + response = responsesTuple.getValue1().get(0).getValue1(); + } catch (AAIException e){ + response = consumerExceptionResponseGenerator(headers, info, HttpMethod.GET, e); + } catch (Exception e) { + AAIException ex = new AAIException("AAI_4000", e); + response = consumerExceptionResponseGenerator(headers, info, HttpMethod.GET, ex); + } finally { //to close the titan transaction (I think) + if (dbEngine != null) { + dbEngine.rollback(); + } + } + return response; + } +} diff --git a/aai-resources/src/main/java/org/openecomp/aai/rest/db/DBRequest.java b/aai-resources/src/main/java/org/openecomp/aai/rest/db/DBRequest.java new file mode 100644 index 0000000..e7b6858 --- /dev/null +++ b/aai-resources/src/main/java/org/openecomp/aai/rest/db/DBRequest.java @@ -0,0 +1,251 @@ +/*- + * ============LICENSE_START======================================================= + * org.openecomp.aai + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF 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.aai.rest.db; + +import java.net.URI; +import java.util.Optional; + +import javax.ws.rs.core.HttpHeaders; +import javax.ws.rs.core.UriInfo; + +import org.openecomp.aai.introspection.Introspector; +import org.openecomp.aai.introspection.MarshallerProperties; +import org.openecomp.aai.parsers.query.QueryParser; +import org.openecomp.aai.restcore.HttpMethod; + +/** + * The Class DBRequest. + */ +public class DBRequest { + + private final QueryParser parser; + + private final Introspector introspector; + + private final HttpHeaders headers; + + private final String transactionId; + + private final UriInfo info; + + private final HttpMethod method; + + private final URI uri; + + private final Optional rawRequestContent; + + private final Optional marshallerProperties; + + + /** + * Instantiates a new DB request. + * + * @param method the method + * @param uri the uri + * @param parser the parser + * @param obj the obj + * @param headers the headers + * @param info the info + * @param transactionId the transaction id + */ + private DBRequest(Builder builder) { + this.method = builder.getMethod(); + this.parser = builder.getParser(); + this.introspector = builder.getIntrospector(); + this.headers = builder.getHeaders(); + this.transactionId = builder.getTransactionId(); + this.info = builder.getInfo(); + this.uri = builder.getUri(); + this.marshallerProperties = builder.getMarshallerProperties(); + this.rawRequestContent = builder.getRawRequestContent(); + } + + /** + * Gets the headers. + * + * @return the headers + */ + public HttpHeaders getHeaders() { + return headers; + } + + + /** + * Gets the transaction id. + * + * @return the transaction id + */ + public String getTransactionId() { + return transactionId; + } + + /** + * Gets the info. + * + * @return the info + */ + public UriInfo getInfo() { + return info; + } + + /** + * Gets the parser. + * + * @return the parser + */ + public QueryParser getParser() { + return parser; + } + + /** + * Gets the introspector. + * + * @return the introspector + */ + public Introspector getIntrospector() { + return introspector; + } + + /** + * Gets the method. + * + * @return the method + */ + public HttpMethod getMethod() { + return method; + } + + /** + * Gets the uri. + * + * @return the uri + */ + public URI getUri() { + return uri; + } + + /** + * Gets the raw content. + * + * @return the raw content + */ + public Optional getRawRequestContent() { + return rawRequestContent; + } + + public Optional getMarshallerProperties() { + return marshallerProperties; + } + + + + public static class Builder { + + private QueryParser parser = null; + + private Introspector introspector = null; + + private HttpHeaders headers = null; + + private String transactionId = null; + + private UriInfo info = null; + + private HttpMethod method = null; + + private URI uri = null; + + private Optional marshallerProperties = Optional.empty(); + + private Optional rawRequestContent = Optional.empty(); + /** + * Instantiates a new DB request. + * + * @param method the method + * @param uri the uri + * @param parser the parser + * @param obj the obj + * @param headers the headers + * @param info the info + * @param transactionId the transaction id + */ + public Builder(HttpMethod method, URI uri, QueryParser parser, Introspector obj, HttpHeaders headers, UriInfo info, String transactionId) { + this.method = method; + this.parser = parser; + this.introspector = obj; + this.headers = headers; + this.transactionId = transactionId; + this.info = info; + this.uri = uri; + + } + + public QueryParser getParser() { + return parser; + } + + public Introspector getIntrospector() { + return introspector; + } + + public HttpHeaders getHeaders() { + return headers; + } + + public String getTransactionId() { + return transactionId; + } + + public UriInfo getInfo() { + return info; + } + + public HttpMethod getMethod() { + return method; + } + + public URI getUri() { + return uri; + } + + public Builder customMarshaller(MarshallerProperties properties) { + this.marshallerProperties = Optional.of(properties); + return this; + } + + public Builder rawRequestContent(String content) { + this.rawRequestContent = Optional.of(content); + return this; + } + protected Optional getMarshallerProperties() { + return marshallerProperties; + } + protected Optional getRawRequestContent() { + return rawRequestContent; + } + public DBRequest build() { + + return new DBRequest(this); + } + + + } +} diff --git a/aai-resources/src/main/java/org/openecomp/aai/rest/db/HttpEntry.java b/aai-resources/src/main/java/org/openecomp/aai/rest/db/HttpEntry.java new file mode 100644 index 0000000..ef305b0 --- /dev/null +++ b/aai-resources/src/main/java/org/openecomp/aai/rest/db/HttpEntry.java @@ -0,0 +1,570 @@ +/*- + * ============LICENSE_START======================================================= + * org.openecomp.aai + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF 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.aai.rest.db; + +import java.io.IOException; +import java.io.UnsupportedEncodingException; +import java.lang.reflect.InvocationTargetException; +import java.net.MalformedURLException; +import java.net.URI; +import java.net.URISyntaxException; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Set; + +import javax.ws.rs.core.HttpHeaders; +import javax.ws.rs.core.MediaType; +import javax.ws.rs.core.MultivaluedMap; +import javax.ws.rs.core.Response; +import javax.ws.rs.core.Response.Status; +import javax.ws.rs.core.UriBuilder; + +import org.apache.commons.lang.StringUtils; +import org.apache.tinkerpop.gremlin.structure.Vertex; +import org.javatuples.Pair; + +import org.openecomp.aai.db.props.AAIProperties; +import org.openecomp.aai.dbmap.DBConnectionType; +import org.openecomp.aai.domain.responseMessage.AAIResponseMessage; +import org.openecomp.aai.domain.responseMessage.AAIResponseMessageDatum; +import org.openecomp.aai.exceptions.AAIException; +import org.openecomp.aai.introspection.Introspector; +import org.openecomp.aai.introspection.Loader; +import org.openecomp.aai.introspection.LoaderFactory; +import org.openecomp.aai.introspection.MarshallerProperties; +import org.openecomp.aai.introspection.ModelInjestor; +import org.openecomp.aai.introspection.ModelType; +import org.openecomp.aai.introspection.Version; +import org.openecomp.aai.introspection.exceptions.AAIUnknownObjectException; +import org.openecomp.aai.logging.ErrorLogHelper; +import org.openecomp.aai.parsers.query.QueryParser; +import org.openecomp.aai.parsers.uri.URIToExtensionInformation; +import org.openecomp.aai.rest.ueb.UEBNotification; +import org.openecomp.aai.restcore.HttpMethod; +import org.openecomp.aai.schema.enums.ObjectMetadata; +import org.openecomp.aai.serialization.db.DBSerializer; +import org.openecomp.aai.serialization.engines.QueryStyle; +import org.openecomp.aai.serialization.engines.TitanDBEngine; +import org.openecomp.aai.serialization.engines.TransactionalGraphEngine; +import org.openecomp.aai.serialization.engines.query.QueryEngine; +import com.att.eelf.configuration.EELFLogger; +import com.att.eelf.configuration.EELFManager; +import com.fasterxml.jackson.databind.JsonNode; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.github.fge.jsonpatch.JsonPatchException; +import com.github.fge.jsonpatch.mergepatch.JsonMergePatch; +import com.thinkaurelius.titan.core.TitanException; +import com.thinkaurelius.titan.core.TitanTransaction; + +/** + * The Class HttpEntry. + */ +public class HttpEntry { + + private static final EELFLogger LOGGER = EELFManager.getInstance().getLogger(HttpEntry.class); + + private final ModelType introspectorFactoryType; + + private final QueryStyle queryStyle; + + private final Version version; + + private final Loader loader; + + private final TransactionalGraphEngine dbEngine; + + private boolean processSingle = true; + + /** + * Instantiates a new http entry. + * + * @param version the version + * @param modelType the model type + * @param queryStyle the query style + * @param llBuilder the ll builder + */ + public HttpEntry(Version version, ModelType modelType, QueryStyle queryStyle, DBConnectionType connectionType) { + this.introspectorFactoryType = modelType; + this.queryStyle = queryStyle; + this.version = version; + this.loader = LoaderFactory.createLoaderForVersion(introspectorFactoryType, version); + this.dbEngine = new TitanDBEngine( + queryStyle, + connectionType, + loader); + //start transaction on creation + dbEngine.startTransaction(); + + } + + /** + * Gets the introspector factory type. + * + * @return the introspector factory type + */ + public ModelType getIntrospectorFactoryType() { + return introspectorFactoryType; + } + + /** + * Gets the query style. + * + * @return the query style + */ + public QueryStyle getQueryStyle() { + return queryStyle; + } + + /** + * Gets the version. + * + * @return the version + */ + public Version getVersion() { + return version; + } + + /** + * Gets the loader. + * + * @return the loader + */ + public Loader getLoader() { + return loader; + } + + /** + * Gets the db engine. + * + * @return the db engine + */ + public TransactionalGraphEngine getDbEngine() { + return dbEngine; + } + + public Pair>> process (List requests, String sourceOfTruth) throws AAIException { + return this.process(requests, sourceOfTruth, true); + } + /** + * Process. + * @param requests the requests + * @param sourceOfTruth the source of truth + * + * @return the pair + * @throws AAIException the AAI exception + */ + public Pair>> process (List requests, String sourceOfTruth, boolean enableResourceVersion) throws AAIException { + DBSerializer serializer = new DBSerializer(version, dbEngine, introspectorFactoryType, sourceOfTruth); + Response response = null; + Status status = Status.NOT_FOUND; + Introspector obj = null; + QueryParser query = null; + URI uri = null; + String transactionId = null; + UEBNotification notification = new UEBNotification(loader); + int depth = AAIProperties.MAXIMUM_DEPTH; + List> responses = new ArrayList<>(); + MultivaluedMap params = null; + HttpMethod method = null; + String uriTemp = ""; + Boolean success = true; + QueryEngine queryEngine = dbEngine.getQueryEngine(); + int maxRetries = 10; + int retry = 0; + for (DBRequest request : requests) { + try { + for (retry = 0; retry < maxRetries; ++retry) { + try { + method = request.getMethod(); + obj = request.getIntrospector(); + query = request.getParser(); + transactionId = request.getTransactionId(); + uriTemp = request.getUri().getRawPath().replaceFirst("^v\\d+/", ""); + uri = UriBuilder.fromPath(uriTemp).build(); + List vertices = query.getQueryBuilder().toList(); + boolean isNewVertex = false; + String outputMediaType = getMediaType(request.getHeaders().getAcceptableMediaTypes()); + String result = null; + params = request.getInfo().getQueryParameters(false); + depth = setDepth(obj, params.getFirst("depth")); + String cleanUp = params.getFirst("cleanup"); + String requestContext = ""; + List requestContextList = request.getHeaders().getRequestHeader("aai-request-context"); + if (requestContextList != null) { + requestContext = requestContextList.get(0); + } + + if (cleanUp == null) { + cleanUp = "false"; + } + if (vertices.size() > 1 && processSingle && !method.equals(HttpMethod.GET)) { + if (method.equals(HttpMethod.DELETE)) { + throw new AAIException("AAI_6138"); + } else { + throw new AAIException("AAI_6137"); + } + } + if (method.equals(HttpMethod.PUT)) { + String resourceVersion = (String)obj.getValue("resource-version"); + if (vertices.size() == 1) { + if (enableResourceVersion) { + serializer.verifyResourceVersion("update", query.getResultType(), (String)vertices.get(0).property("resource-version").orElse(null), resourceVersion, obj.getURI()); + } + isNewVertex = false; + } else { + if (enableResourceVersion) { + serializer.verifyResourceVersion("create", query.getResultType(), "", resourceVersion, obj.getURI()); + } + isNewVertex = true; + } + } else { + if (vertices.size() == 0) { + String msg = createNotFoundMessage(query.getResultType(), request.getUri()); + throw new AAIException("AAI_6114", msg); + } else { + isNewVertex = false; + } + } + Vertex v = null; + if (!isNewVertex) { + v = vertices.get(0); + } + HashMap relatedObjects = new HashMap<>(); + switch (method) { + case GET: + String nodeOnly = params.getFirst("nodes-only"); + boolean isNodeOnly = nodeOnly != null; + + obj = this.getObjectFromDb(vertices, serializer, query, obj, request.getUri(), depth, isNodeOnly, cleanUp); + if (obj != null) { + status = Status.OK; + MarshallerProperties properties; + if (!request.getMarshallerProperties().isPresent()) { + properties = + new MarshallerProperties.Builder(org.openecomp.aai.restcore.MediaType.getEnum(outputMediaType)).build(); + } else { + properties = request.getMarshallerProperties().get(); + } + result = obj.marshal(properties); + } + + break; + case PUT: + if (isNewVertex) { + v = serializer.createNewVertex(obj); + } else { + serializer.touchStandardVertexProperties(v, false); + } + serializer.serializeToDb(obj, v, query, uri.getRawPath(), requestContext); + status = Status.OK; + if (isNewVertex) { + status = Status.CREATED; + } + obj = serializer.getLatestVersionView(v); + if (query.isDependent()) { + relatedObjects = this.getRelatedObjects(serializer, queryEngine, v); + } + notification.createNotificationEvent(transactionId, sourceOfTruth, status, uri, obj, relatedObjects); + + break; + case PUT_EDGE: + serializer.touchStandardVertexProperties(v, false); + serializer.createEdge(obj, v); + status = Status.OK; + break; + case MERGE_PATCH: + Introspector existingObj = (Introspector) obj.clone(); + existingObj = this.getObjectFromDb(vertices, serializer, query, existingObj, request.getUri(), 0, false, cleanUp); + String existingJson = existingObj.marshal(false); + String newJson; + + if (request.getRawRequestContent().isPresent()) { + newJson = request.getRawRequestContent().get(); + } else { + newJson = ""; + } + Object relationshipList = request.getIntrospector().getValue("relationship-list"); + ObjectMapper mapper = new ObjectMapper(); + try { + JsonNode existingNode = mapper.readTree(existingJson); + JsonNode newNode = mapper.readTree(newJson); + JsonMergePatch patch = JsonMergePatch.fromJson(newNode); + JsonNode completed = patch.apply(existingNode); + String patched = mapper.writeValueAsString(completed); + Introspector patchedObj = loader.unmarshal(existingObj.getName(), patched); + if (relationshipList == null) { + //if the caller didn't touch the relationship-list, we shouldn't either + patchedObj.setValue("relationship-list", null); + } + serializer.touchStandardVertexProperties(v, false); + serializer.serializeToDb(patchedObj, v, query, uri.getRawPath(), requestContext); + status = Status.OK; + patchedObj = serializer.getLatestVersionView(v); + if (query.isDependent()) { + relatedObjects = this.getRelatedObjects(serializer, queryEngine, v); + } + notification.createNotificationEvent(transactionId, sourceOfTruth, status, uri, patchedObj, relatedObjects); + } catch (IOException | JsonPatchException e) { + throw new AAIException("AAI_3000", "could not perform patch operation"); + } + break; + case DELETE: + String resourceVersion = params.getFirst("resource-version"); + obj = serializer.getLatestVersionView(v); + if (query.isDependent()) { + relatedObjects = this.getRelatedObjects(serializer, queryEngine, v); + } + serializer.delete(v, resourceVersion, enableResourceVersion); + status = Status.NO_CONTENT; + notification.createNotificationEvent(transactionId, sourceOfTruth, status, uri, obj, relatedObjects); + break; + case DELETE_EDGE: + serializer.touchStandardVertexProperties(v, false); + serializer.deleteEdge(obj, v); + status = Status.NO_CONTENT; + break; + default: + break; + } + + + /* temporarily adding vertex id to the headers + * to be able to use for testing the vertex id endpoint functionality + * since we presently have no other way of generating those id urls + */ + if (response == null && v != null && ( + method.equals(HttpMethod.PUT) + || method.equals(HttpMethod.GET) + || method.equals(HttpMethod.MERGE_PATCH)) + ) { + String myvertid = v.id().toString(); + response = Response.status(status) + .header("vertex-id", myvertid) + .entity(result) + .type(outputMediaType).build(); + } else if (response == null) { + response = Response.status(status) + .type(outputMediaType).build(); + } else { + //response already set to something + } + Pair pairedResp = Pair.with(request.getUri(), response); + responses.add(pairedResp); + //break out of retry loop + break; + } catch (TitanException e) { + this.dbEngine.rollback(); + AAIException ex = new AAIException("AAI_6142", e); + ErrorLogHelper.logException(ex); + Thread.sleep((retry + 1) * 20); + this.dbEngine.startTransaction(); + queryEngine = dbEngine.getQueryEngine(); + serializer = new DBSerializer(version, dbEngine, introspectorFactoryType, sourceOfTruth); + } + + if (retry == maxRetries) { + throw new AAIException("AAI_6134"); + } + } + } catch (AAIException e) { + success = false; + ArrayList templateVars = new ArrayList(); + templateVars.add(request.getMethod().toString()); //GET, PUT, etc + templateVars.add(request.getUri().getPath().toString()); + templateVars.addAll(e.getTemplateVars()); + + response = Response + .status(e.getErrorObject().getHTTPResponseCode()) + .entity(ErrorLogHelper.getRESTAPIErrorResponse(request.getHeaders().getAcceptableMediaTypes(), e, templateVars)) + .build(); + Pair pairedResp = Pair.with(request.getUri(), response); + responses.add(pairedResp); + continue; + } catch (Exception e) { + success = false; + e.printStackTrace(); + AAIException ex = new AAIException("AAI_4000", e); + ArrayList templateVars = new ArrayList(); + templateVars.add(request.getMethod().toString()); //GET, PUT, etc + templateVars.add(request.getUri().getPath().toString()); + + response = Response + .status(ex.getErrorObject().getHTTPResponseCode()) + .entity(ErrorLogHelper.getRESTAPIErrorResponse(request.getHeaders().getAcceptableMediaTypes(), ex, templateVars)) + .build(); + Pair pairedResp = Pair.with(request.getUri(), response); + responses.add(pairedResp); + continue; + } + } + + notification.triggerEvents(); + Pair>> tuple = Pair.with(success, responses); + return tuple; + } + + /** + * Gets the media type. + * + * @param mediaTypeList the media type list + * @return the media type + */ + private String getMediaType(List mediaTypeList) { + String mediaType = MediaType.APPLICATION_JSON; // json is the default + for (MediaType mt : mediaTypeList) { + if (MediaType.APPLICATION_XML_TYPE.isCompatible(mt)) { + mediaType = MediaType.APPLICATION_XML; + } + } + return mediaType; + } + + /** + * Gets the object from db. + * + * @param serializer the serializer + * @param g the g + * @param query the query + * @param obj the obj + * @param uri the uri + * @param depth the depth + * @param cleanUp the clean up + * @return the object from db + * @throws AAIException the AAI exception + * @throws IllegalAccessException the illegal access exception + * @throws IllegalArgumentException the illegal argument exception + * @throws InvocationTargetException the invocation target exception + * @throws SecurityException the security exception + * @throws InstantiationException the instantiation exception + * @throws NoSuchMethodException the no such method exception + * @throws UnsupportedEncodingException the unsupported encoding exception + * @throws MalformedURLException the malformed URL exception + * @throws AAIUnknownObjectException + * @throws URISyntaxException + */ + private Introspector getObjectFromDb(List results, DBSerializer serializer, QueryParser query, Introspector obj, URI uri, int depth, boolean nodeOnly, String cleanUp) throws AAIException, IllegalAccessException, IllegalArgumentException, InvocationTargetException, SecurityException, InstantiationException, NoSuchMethodException, UnsupportedEncodingException, AAIUnknownObjectException, URISyntaxException { + + //nothing found + if (results.size() == 0) { + String msg = createNotFoundMessage(query.getResultType(), uri); + throw new AAIException("AAI_6114", msg); + } + + obj = serializer.dbToObject(results, obj, depth, nodeOnly, cleanUp); + + return obj; + } + + + /** + * Creates the not found message. + * + * @param resultType the result type + * @param uri the uri + * @return the string + */ + private String createNotFoundMessage(String resultType, URI uri) { + + String msg = "No Node of type " + resultType + " found at: " + uri.getPath(); + + return msg; + } + + /** + * Sets the depth. + * + * @param depthParam the depth param + * @return the int + * @throws AAIException the AAI exception + */ + protected int setDepth(Introspector obj, String depthParam) throws AAIException { + int depth = AAIProperties.MAXIMUM_DEPTH; + + if(depthParam == null){ + if(this.version.compareTo(Version.v9) >= 0){ + depth = 0; + } else { + depth = AAIProperties.MAXIMUM_DEPTH; + } + } else { + if (depthParam.length() > 0 && !depthParam.equals("all")){ + try { + depth = Integer.valueOf(depthParam); + } catch (Exception e) { + throw new AAIException("AAI_4016"); + } + + } + } + String maxDepth = obj.getMetadata(ObjectMetadata.MAXIMUM_DEPTH); + + int maximumDepth = AAIProperties.MAXIMUM_DEPTH; + + if(maxDepth != null){ + try { + maximumDepth = Integer.parseInt(maxDepth); + } catch(Exception ex){ + throw new AAIException("AAI_4018"); + } + } + + if(depth > maximumDepth){ + throw new AAIException("AAI_3303"); + } + + return depth; + } + + /** + * Checks if is modification method. + * + * @param method the method + * @return true, if is modification method + */ + private boolean isModificationMethod(HttpMethod method) { + boolean result = false; + + if (method.equals(HttpMethod.PUT) || method.equals(HttpMethod.PUT_EDGE) || method.equals(HttpMethod.DELETE_EDGE) || method.equals(HttpMethod.MERGE_PATCH)) { + result = true; + } + + return result; + + } + + private HashMap getRelatedObjects(DBSerializer serializer, QueryEngine queryEngine, Vertex v) throws IllegalAccessException, IllegalArgumentException, InvocationTargetException, SecurityException, InstantiationException, NoSuchMethodException, UnsupportedEncodingException, AAIException, URISyntaxException { + HashMap relatedVertices = new HashMap<>(); + List vertexChain = queryEngine.findParents(v); + for (Vertex vertex : vertexChain) { + try { + final Introspector vertexObj = serializer.getVertexProperties(vertex); + relatedVertices.put(vertexObj.getObjectId(), vertexObj); + } catch (AAIUnknownObjectException e) { + LOGGER.warn("Unable to get vertex properties, partial list of related vertices returned"); + } + + } + + return relatedVertices; + } + +} diff --git a/aai-resources/src/main/java/org/openecomp/aai/rest/retired/RetiredConsumer.java b/aai-resources/src/main/java/org/openecomp/aai/rest/retired/RetiredConsumer.java new file mode 100644 index 0000000..99974ef --- /dev/null +++ b/aai-resources/src/main/java/org/openecomp/aai/rest/retired/RetiredConsumer.java @@ -0,0 +1,143 @@ +/*- + * ============LICENSE_START======================================================= + * org.openecomp.aai + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF 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.aai.rest.retired; + +import java.util.ArrayList; + +import javax.servlet.http.HttpServletRequest; +import javax.ws.rs.DELETE; +import javax.ws.rs.GET; +import javax.ws.rs.POST; +import javax.ws.rs.PUT; +import javax.ws.rs.Path; +import javax.ws.rs.PathParam; +import javax.ws.rs.core.Context; +import javax.ws.rs.core.HttpHeaders; +import javax.ws.rs.core.Response; +import javax.ws.rs.core.UriInfo; + +import org.apache.cxf.jaxrs.ext.PATCH; + +import org.openecomp.aai.exceptions.AAIException; +import org.openecomp.aai.logging.ErrorLogHelper; +import org.openecomp.aai.restcore.RESTAPI; +import org.openecomp.aai.util.AAIConfig; + +/** + * The Class RetiredConsumer. + */ +public abstract class RetiredConsumer extends RESTAPI { + + /** + * Creates the message get. + * + * @param versionParam the version param + * @param headers the headers + * @param info the info + * @param req the req + * @return the response + */ + @GET + @Path("/{uri:.*}") + public Response createMessageGet(@PathParam("version")String versionParam, @Context HttpHeaders headers, @Context UriInfo info, @Context HttpServletRequest req) { + return createMessage(versionParam, headers, info, req); + } + + /** + * Creates the message delete. + * + * @param versionParam the version param + * @param headers the headers + * @param info the info + * @param req the req + * @return the response + */ + @DELETE + @Path("/{uri:.*}") + public Response createMessageDelete(@PathParam("version")String versionParam, @Context HttpHeaders headers, @Context UriInfo info, @Context HttpServletRequest req) { + return createMessage(versionParam, headers, info, req); + } + + /** + * Creates the message post. + * + * @param versionParam the version param + * @param headers the headers + * @param info the info + * @param req the req + * @return the response + */ + @POST + @Path("/{uri:.*}") + public Response createMessagePost(@PathParam("version")String versionParam, @Context HttpHeaders headers, @Context UriInfo info, @Context HttpServletRequest req) { + return createMessage(versionParam, headers, info, req); + } + + @PATCH + @Path("/{uri:.*}") + public Response createMessagePatch(@PathParam("version")String versionParam, @Context HttpHeaders headers, @Context UriInfo info, @Context HttpServletRequest req) { + return createMessage(versionParam, headers, info, req); + } + /** + * Creates the message put. + * + * @param versionParam the version param + * @param headers the headers + * @param info the info + * @param req the req + * @return the response + */ + @PUT + @Path("/{uri:.*}") + public Response createMessagePut(@PathParam("version")String versionParam, @Context HttpHeaders headers, @Context UriInfo info, @Context HttpServletRequest req) { + return createMessage(versionParam, headers, info, req); + } + + + /** + * Creates the message. + * + * @param versionParam the version param + * @param headers the headers + * @param info the info + * @param req the req + * @return the response + */ + private Response createMessage(String versionParam, HttpHeaders headers, UriInfo info, HttpServletRequest req) { + AAIException e = new AAIException("AAI_3007"); + + ArrayList templateVars = new ArrayList(); + + if (templateVars.size() == 0) { + templateVars.add("PUT"); + templateVars.add(info.getPath().toString()); + templateVars.add(versionParam); + templateVars.add(AAIConfig.get("aai.default.api.version", "")); + } + + Response response = Response + .status(e.getErrorObject().getHTTPResponseCode()) + .entity(ErrorLogHelper.getRESTAPIErrorResponse(headers.getAcceptableMediaTypes(), e, + templateVars)).build(); + + return response; + } +} diff --git a/aai-resources/src/main/java/org/openecomp/aai/rest/retired/V3ThroughV7Consumer.java b/aai-resources/src/main/java/org/openecomp/aai/rest/retired/V3ThroughV7Consumer.java new file mode 100644 index 0000000..5572586 --- /dev/null +++ b/aai-resources/src/main/java/org/openecomp/aai/rest/retired/V3ThroughV7Consumer.java @@ -0,0 +1,28 @@ +/*- + * ============LICENSE_START======================================================= + * org.openecomp.aai + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF 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.aai.rest.retired; + +import javax.ws.rs.Path; + +@Path("{version: v[3-6]}") //TODO re-add v7 when we fix our env issues AAI-8567 +public class V3ThroughV7Consumer extends RetiredConsumer { + +} diff --git a/aai-resources/src/main/java/org/openecomp/aai/rest/ueb/NotificationEvent.java b/aai-resources/src/main/java/org/openecomp/aai/rest/ueb/NotificationEvent.java new file mode 100644 index 0000000..389d296 --- /dev/null +++ b/aai-resources/src/main/java/org/openecomp/aai/rest/ueb/NotificationEvent.java @@ -0,0 +1,96 @@ +/*- + * ============LICENSE_START======================================================= + * org.openecomp.aai + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF 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.aai.rest.ueb; + +import org.openecomp.aai.exceptions.AAIException; +import org.openecomp.aai.introspection.Introspector; +import org.openecomp.aai.introspection.Loader; +import org.openecomp.aai.introspection.Version; +import org.openecomp.aai.util.StoreNotificationEvent; + +/** + * The Class NotificationEvent. + */ +public class NotificationEvent { + + private Loader loader = null; + + private Introspector eventHeader = null; + + private Introspector obj = null; + + /** + * Instantiates a new notification event. + * + * @param version the version + * @param eventHeader the event header + * @param obj the obj + */ + public NotificationEvent (Loader loader, Introspector eventHeader, Introspector obj) { + this.loader = loader; + this.eventHeader = eventHeader; + this.obj = obj; + } + + /** + * Trigger. + * + * @throws AAIException the AAI exception + */ + public void trigger() throws AAIException { + + StoreNotificationEvent sne = new StoreNotificationEvent(); + + sne.storeEvent(loader, eventHeader, obj); + + } + + /** + * Gets the notification version. + * + * @return the notification version + */ + public Version getNotificationVersion() { + return loader.getVersion(); + } + + /** + * Gets the event header. + * + * @return the event header + */ + public Introspector getEventHeader() { + return eventHeader; + } + + /** + * Gets the obj. + * + * @return the obj + */ + public Introspector getObj() { + return obj; + } + + + + +} diff --git a/aai-resources/src/main/java/org/openecomp/aai/rest/ueb/UEBNotification.java b/aai-resources/src/main/java/org/openecomp/aai/rest/ueb/UEBNotification.java new file mode 100644 index 0000000..397082f --- /dev/null +++ b/aai-resources/src/main/java/org/openecomp/aai/rest/ueb/UEBNotification.java @@ -0,0 +1,178 @@ +/*- + * ============LICENSE_START======================================================= + * org.openecomp.aai + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF 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.aai.rest.ueb; + +import java.io.UnsupportedEncodingException; +import java.net.URI; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; + +import javax.ws.rs.core.Response.Status; + +import org.openecomp.aai.db.props.AAIProperties; +import org.openecomp.aai.exceptions.AAIException; +import org.openecomp.aai.introspection.Introspector; +import org.openecomp.aai.introspection.Loader; +import org.openecomp.aai.introspection.LoaderFactory; +import org.openecomp.aai.introspection.Version; +import org.openecomp.aai.introspection.exceptions.AAIUnknownObjectException; +import org.openecomp.aai.introspection.exceptions.AAIUnmarshallingException; +import org.openecomp.aai.parsers.uri.URIToObject; +import org.openecomp.aai.util.AAIConfig; +import com.att.eelf.configuration.EELFLogger; +import com.att.eelf.configuration.EELFManager; + +/** + * The Class UEBNotification. + */ +public class UEBNotification { + + private static final EELFLogger LOGGER = EELFManager.getInstance().getLogger(UEBNotification.class); + + private Loader currentVersionLoader = null; + protected List events = null; + private String urlBase = null; + private Version notificationVersion = null; + + /** + * Instantiates a new UEB notification. + * + * @param loader the loader + */ + public UEBNotification(Loader loader) { + events = new ArrayList<>(); + currentVersionLoader = LoaderFactory.createLoaderForVersion(loader.getModelType(), AAIProperties.LATEST); + urlBase = AAIConfig.get("aai.server.url.base",""); + notificationVersion = Version.valueOf(AAIConfig.get("aai.notification.current.version","v10")); + } + + + /** + * Creates the notification event. + * + * @param transactionId the X-TransactionId + * @param sourceOfTruth + * @param status the status + * @param uri the uri + * @param obj the obj + * @throws AAIException the AAI exception + * @throws IllegalArgumentException the illegal argument exception + * @throws UnsupportedEncodingException the unsupported encoding exception + */ + public void createNotificationEvent(String transactionId, String sourceOfTruth, Status status, URI uri, Introspector obj, HashMap relatedObjects) throws AAIException, IllegalArgumentException, UnsupportedEncodingException { + + String action = "UPDATE"; + + if (status.equals(Status.CREATED)) { + action = "CREATE"; + } else if (status.equals(Status.OK)) { + action = "UPDATE"; + } else if (status.equals(Status.NO_CONTENT)) { + action = "DELETE"; + } + + try { + Introspector eventHeader = currentVersionLoader.introspectorFromName("notification-event-header"); + URIToObject parser = new URIToObject(currentVersionLoader, uri, relatedObjects); + + String entityLink = ""; + if (uri.toString().startsWith("/")) { + entityLink = urlBase + notificationVersion + uri; + } else { + entityLink = urlBase + notificationVersion + "/" + uri; + } + + + eventHeader.setValue("entity-link", entityLink); + eventHeader.setValue("action", action); + eventHeader.setValue("entity-type", obj.getDbName()); + eventHeader.setValue("top-entity-type", parser.getTopEntityName()); + eventHeader.setValue("source-name", sourceOfTruth); + eventHeader.setValue("version", notificationVersion.toString()); + eventHeader.setValue("id", transactionId); + + List parentList = parser.getParentList(); + parentList.clear(); + + if (!parser.getTopEntity().equals(parser.getEntity())) { + Introspector child = obj; + if (!parser.getLoader().getVersion().equals(obj.getVersion())) { + String json = obj.marshal(false); + child = parser.getLoader().unmarshal(parser.getEntity().getName(), json); + } + + //wrap the child object in its parents + parentList.add(child.getUnderlyingObject()); + } + + final Introspector eventObject; + + //convert to most resent version + if (!parser.getLoader().getVersion().equals(currentVersionLoader.getVersion())) { + String json = ""; + if (parser.getTopEntity().equals(parser.getEntity())) { + //convert the parent object passed in + json = obj.marshal(false); + eventObject = currentVersionLoader.unmarshal(obj.getName(), json); + } else { + //convert the object created in the parser + json = parser.getTopEntity().marshal(false); + eventObject = currentVersionLoader.unmarshal(parser.getTopEntity().getName(), json); + } + } else { + if (parser.getTopEntity().equals(parser.getEntity())) { + //take the top level parent object passed in + eventObject = obj; + } else { + //take the wrapped child objects (ogres are like onions) + eventObject = parser.getTopEntity(); + } + } + + final NotificationEvent event = new NotificationEvent(currentVersionLoader, eventHeader, eventObject); + events.add(event); + } catch (AAIUnknownObjectException e) { + throw new RuntimeException("Fatal error - notification-event-header object not found!"); + } catch (AAIUnmarshallingException e) { + LOGGER.error("Unmarshalling error occurred while generating UEBNotification", e); + } + } + + /** + * Trigger events. + * + * @throws AAIException the AAI exception + */ + public void triggerEvents() throws AAIException { + for (NotificationEvent event : events) { + event.trigger(); + } + events.clear(); + } + + public List getEvents() { + return this.events; + } + + + +} diff --git a/aai-resources/src/main/java/org/openecomp/aai/rest/util/EchoResponse.java b/aai-resources/src/main/java/org/openecomp/aai/rest/util/EchoResponse.java new file mode 100644 index 0000000..6d01435 --- /dev/null +++ b/aai-resources/src/main/java/org/openecomp/aai/rest/util/EchoResponse.java @@ -0,0 +1,121 @@ +/*- + * ============LICENSE_START======================================================= + * org.openecomp.aai + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF 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.aai.rest.util; + +import java.util.ArrayList; +import java.util.HashMap; + +import javax.servlet.http.HttpServletRequest; +import javax.ws.rs.GET; +import javax.ws.rs.Path; +import javax.ws.rs.Produces; +import javax.ws.rs.QueryParam; +import javax.ws.rs.core.Context; +import javax.ws.rs.core.HttpHeaders; +import javax.ws.rs.core.MediaType; +import javax.ws.rs.core.Response; +import javax.ws.rs.core.Response.Status; + +import org.openecomp.aai.exceptions.AAIException; +import org.openecomp.aai.logging.ErrorLogHelper; +import org.openecomp.aai.restcore.RESTAPI; + +/** + * The Class EchoResponse. + */ +public class EchoResponse extends RESTAPI { + + protected static String authPolicyFunctionName = "util"; + + public static final String echoPath = "/util/echo"; + + /** + * Simple health-check API that echos back the X-FromAppId and X-TransactionId to clients. + * If there is a query string, a transaction gets logged into hbase, proving the application is connected to the data store. + * If there is no query string, no transacction logging is done to hbase. + * + * @param headers the headers + * @param req the req + * @param myAction if exists will cause transaction to be logged to hbase + * @return the response + */ + @GET + @Produces( { MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON }) + @Path(echoPath) + public Response echoResult(@Context HttpHeaders headers, @Context HttpServletRequest req, + @QueryParam("action") String myAction) { + Response response = null; + + AAIException ex = null; + String fromAppId = null; + String transId = null; + + try { + fromAppId = getFromAppId(headers ); + transId = getTransId(headers); + } catch (AAIException e) { + ArrayList templateVars = new ArrayList(); + templateVars.add("PUT uebProvider"); + templateVars.add("addTopic"); + return Response + .status(e.getErrorObject().getHTTPResponseCode()) + .entity(ErrorLogHelper.getRESTAPIErrorResponse(headers.getAcceptableMediaTypes(), e, templateVars)) + .build(); + } + + try { + + HashMap> exceptionList = new HashMap>(); + + ArrayList templateVars = new ArrayList(); + templateVars.add(fromAppId); + templateVars.add(transId); + + exceptionList.put(new AAIException("AAI_0002", "OK"), templateVars); + + response = Response.status(Status.OK) + .entity(ErrorLogHelper.getRESTAPIInfoResponse( + headers.getAcceptableMediaTypes(), exceptionList)) + .build(); + + } catch (Exception e) { + ex = new AAIException("AAI_4000", e); + ArrayList templateVars = new ArrayList(); + templateVars.add(Action.GET.name()); + templateVars.add(fromAppId +" "+transId); + + response = Response + .status(Status.INTERNAL_SERVER_ERROR) + .entity(ErrorLogHelper.getRESTAPIErrorResponse( + headers.getAcceptableMediaTypes(), ex, + templateVars)).build(); + + } finally { + if (ex != null) { + ErrorLogHelper.logException(ex); + } + + } + + return response; + } + +} diff --git a/aai-resources/src/main/java/org/openecomp/aai/rest/util/LogFormatTools.java b/aai-resources/src/main/java/org/openecomp/aai/rest/util/LogFormatTools.java new file mode 100644 index 0000000..d6fcd67 --- /dev/null +++ b/aai-resources/src/main/java/org/openecomp/aai/rest/util/LogFormatTools.java @@ -0,0 +1,36 @@ +/*- + * ============LICENSE_START======================================================= + * org.openecomp.aai + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF 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.aai.rest.util; + +import java.time.ZoneOffset; +import java.time.ZonedDateTime; +import java.time.format.DateTimeFormatter; + +public class LogFormatTools { + + private static final String DATE_FORMAT = "yyyy-MM-dd'T'HH:mm:ss.SSSZ"; + private static final DateTimeFormatter DTF = DateTimeFormatter.ofPattern(DATE_FORMAT) + .withZone(ZoneOffset.UTC); + + public static String getCurrentDateTime() { + return DTF.format(ZonedDateTime.now()); + } +} diff --git a/aai-resources/src/main/java/org/openecomp/aai/rest/util/ValidateEncoding.java b/aai-resources/src/main/java/org/openecomp/aai/rest/util/ValidateEncoding.java new file mode 100644 index 0000000..a09a317 --- /dev/null +++ b/aai-resources/src/main/java/org/openecomp/aai/rest/util/ValidateEncoding.java @@ -0,0 +1,160 @@ +/*- + * ============LICENSE_START======================================================= + * org.openecomp.aai + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF 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.aai.rest.util; + +import java.io.UnsupportedEncodingException; +import java.net.URI; + +import javax.ws.rs.core.MultivaluedMap; +import javax.ws.rs.core.UriInfo; + +import org.springframework.web.util.UriUtils; + +/** + * The Class ValidateEncoding. + */ +public class ValidateEncoding { + + private final String encoding = "UTF-8"; + + /** + * Instantiates a new validate encoding. + */ + private ValidateEncoding() { + + } + + /** + * The Class Helper. + */ + private static class Helper { + + /** The Constant INSTANCE. */ + private static final ValidateEncoding INSTANCE = new ValidateEncoding(); + } + + /** + * Gets the single instance of ValidateEncoding. + * + * @return single instance of ValidateEncoding + */ + public static ValidateEncoding getInstance() { + return Helper.INSTANCE; + } + + /** + * Validate. + * + * @param uri the uri + * @return true, if successful + * @throws UnsupportedEncodingException the unsupported encoding exception + */ + public boolean validate(URI uri) throws UnsupportedEncodingException { + boolean result = true; + if (!validatePath(uri.getRawPath())) { + result = false; + } + /*if (!validateQueryParams(uri.getRawQuery())) { + result = false; + } //TODO + */ + + return result; + } + + /** + * Validate. + * + * @param info the info + * @return true, if successful + * @throws UnsupportedEncodingException the unsupported encoding exception + */ + public boolean validate(UriInfo info) throws UnsupportedEncodingException { + boolean result = true; + if (!validatePath(info.getPath(false))) { + result = false; + } + if (!validateQueryParams(info.getQueryParameters(false))) { + result = false; + } + + return result; + } + + /** + * Validate path. + * + * @param path the path + * @return true, if successful + * @throws UnsupportedEncodingException the unsupported encoding exception + */ + private boolean validatePath(String path) throws UnsupportedEncodingException { + String[] segments = path.split("/"); + boolean valid = true; + for (String segment : segments) { + if (!this.checkEncoding(segment)) { + valid = false; + } + } + + return valid; + + } + + /** + * Validate query params. + * + * @param params the params + * @return true, if successful + * @throws UnsupportedEncodingException the unsupported encoding exception + */ + private boolean validateQueryParams(MultivaluedMap params) throws UnsupportedEncodingException { + boolean valid = true; + + for (String key : params.keySet()) { + if (!this.checkEncoding(key)) { + valid = false; + } + for (String item : params.get(key)) { + if (!this.checkEncoding(item)) { + valid = false; + } + } + } + return valid; + } + + /** + * Check encoding. + * + * @param segment the segment + * @return true, if successful + * @throws UnsupportedEncodingException the unsupported encoding exception + */ + private boolean checkEncoding(String segment) throws UnsupportedEncodingException { + boolean result = false; + String decode = UriUtils.decode(segment, encoding); + String encode = UriUtils.encode(decode, encoding); + result = segment.equals(encode); + + return result; + } +} diff --git a/aai-resources/src/main/java/org/openecomp/aai/transforms/Converter.java b/aai-resources/src/main/java/org/openecomp/aai/transforms/Converter.java new file mode 100644 index 0000000..44a0222 --- /dev/null +++ b/aai-resources/src/main/java/org/openecomp/aai/transforms/Converter.java @@ -0,0 +1,25 @@ +/*- + * ============LICENSE_START======================================================= + * org.openecomp.aai + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF 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.aai.transforms; + +public interface Converter { + String convert(String input); +} diff --git a/aai-resources/src/main/java/org/openecomp/aai/transforms/LowerCamelToLowerHyphenConverter.java b/aai-resources/src/main/java/org/openecomp/aai/transforms/LowerCamelToLowerHyphenConverter.java new file mode 100644 index 0000000..a31da05 --- /dev/null +++ b/aai-resources/src/main/java/org/openecomp/aai/transforms/LowerCamelToLowerHyphenConverter.java @@ -0,0 +1,34 @@ +/*- + * ============LICENSE_START======================================================= + * org.openecomp.aai + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF 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.aai.transforms; + +import com.google.common.base.CaseFormat; + +public class LowerCamelToLowerHyphenConverter implements Converter { + + @Override + public String convert(String input) { + if(input == null){ + return null; + } + return CaseFormat.LOWER_CAMEL.to(CaseFormat.LOWER_HYPHEN, input); + } +} diff --git a/aai-resources/src/main/java/org/openecomp/aai/transforms/LowerHyphenToLowerCamelConverter.java b/aai-resources/src/main/java/org/openecomp/aai/transforms/LowerHyphenToLowerCamelConverter.java new file mode 100644 index 0000000..784adbe --- /dev/null +++ b/aai-resources/src/main/java/org/openecomp/aai/transforms/LowerHyphenToLowerCamelConverter.java @@ -0,0 +1,81 @@ +/*- + * ============LICENSE_START======================================================= + * org.openecomp.aai + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF 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.aai.transforms; + +/** + * LowerHyphenToLowerCamelConverter is the converter to use + * for converting from the lower hyphen to lower camel case + *

+ * Examples: + * lower-test => lowerTest + * lower-Test => lowerTest + * lowerTest => lowerTest + * lower-test-val => lowerTestVal + *

+ * + */ +public class LowerHyphenToLowerCamelConverter implements Converter { + + /** + * Converts the dash formatted string into a camel case string + * Ensure that the capitalization is not lost during this conversion + *

+ * Loops through each character in the string + * checks if the current character is '-' and if it is then sets the + * boolean isPreviousCharDash to true and continues to the next iteration + * If the character is not '-', then checks if the previous character is dash + * If it is, then it will upper case the current character and appends to the builder + * Otherwise, it will just append the current character without any modification + * + * @param input the input string to convert to camel case + * @return a string that is converted to camel case + * if the input is null, then it returns null + */ + @Override + public String convert(String input) { + if(input == null){ + return null; + } + + int size = input.length(); + StringBuilder builder = new StringBuilder(size); + + boolean isPreviousCharDash = false; + + for(int index = 0; index < size; ++index){ + char ch = input.charAt(index); + + if(ch == '-'){ + isPreviousCharDash = true; + continue; + } + if(isPreviousCharDash){ + builder.append(Character.toUpperCase(ch)); + isPreviousCharDash = false; + } else{ + builder.append(ch); + } + } + + return builder.toString(); + } + +} diff --git a/aai-resources/src/main/java/org/openecomp/aai/transforms/MapTraverser.java b/aai-resources/src/main/java/org/openecomp/aai/transforms/MapTraverser.java new file mode 100644 index 0000000..7695240 --- /dev/null +++ b/aai-resources/src/main/java/org/openecomp/aai/transforms/MapTraverser.java @@ -0,0 +1,87 @@ +/*- + * ============LICENSE_START======================================================= + * org.openecomp.aai + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF 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.aai.transforms; + + +import joptsimple.internal.Objects; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +public class MapTraverser { + + private Converter converter; + + public MapTraverser(Converter converter){ + this.converter = converter; + } + + public Map convertKeys(Map map){ + + Objects.ensureNotNull(map); + + Map modifiedMap = new HashMap(); + convertKeys(map, modifiedMap); + + return modifiedMap; + } + + private Map convertKeys(Map original, Map modified){ + + for(Map.Entry entry : original.entrySet()){ + String key = entry.getKey(); + key = converter.convert(key); + Object value = entry.getValue(); + if(value instanceof Map){ + modified.put(key, convertKeys((Map)value, new HashMap())); + } else if(value instanceof List){ + modified.put(key, convertKeys((List) value)); + } else { + modified.put(key, value); + } + } + + return modified; + } + + public List convertKeys(List list){ + + List modifiedList = new ArrayList(); + if(list != null && list.size() > 0){ + + for(Object o : list){ + if(o instanceof Map){ + Map map = (Map) o; + modifiedList.add(convertKeys(map)); + } else if(o instanceof List){ + List l = (List) o; + modifiedList.add(convertKeys(l)); + } else { + modifiedList.add(o); + } + } + } + + return modifiedList; + } +} diff --git a/aai-resources/src/main/java/org/openecomp/aai/util/AAIAppServletContextListener.java b/aai-resources/src/main/java/org/openecomp/aai/util/AAIAppServletContextListener.java new file mode 100644 index 0000000..773b4a6 --- /dev/null +++ b/aai-resources/src/main/java/org/openecomp/aai/util/AAIAppServletContextListener.java @@ -0,0 +1,104 @@ +/*- + * ============LICENSE_START======================================================= + * org.openecomp.aai + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF 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.aai.util; + +import java.io.IOException; + +import javax.servlet.ServletContextEvent; +import javax.servlet.ServletContextListener; + +//import org.apache.activemq.broker.BrokerService; + +import org.openecomp.aai.dbmap.AAIGraph; +import org.openecomp.aai.exceptions.AAIException; +import org.openecomp.aai.introspection.ModelInjestor; +import org.openecomp.aai.logging.ErrorLogHelper; +import com.att.eelf.configuration.EELFLogger; +import com.att.eelf.configuration.EELFManager; + +public class AAIAppServletContextListener implements ServletContextListener { + + private static final EELFLogger LOGGER = EELFManager.getInstance().getLogger(AAIAppServletContextListener.class.getName()); + + //private BrokerService broker = new BrokerService(); + + /** + * Destroys Context + * + * @param arg0 the ServletContextEvent + */ + public void contextDestroyed(ServletContextEvent arg0) { + LOGGER.info("AAIGraph shutting down"); + AAIGraph.getInstance().graphShutdown(); + LOGGER.info("AAIGraph shutdown"); + + try { +// broker.stop(); + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + + /** + * Initializes Context + * + * @param arg0 the ServletContextEvent + */ + public void contextInitialized(ServletContextEvent arg0) { + System.setProperty("org.openecomp.aai.serverStarted", "false"); + LOGGER.info("***AAI Server initialization started..."); + + try { + LOGGER.info("Loading aaiconfig.properties"); + AAIConfig.init(); + + LOGGER.info("Loading error.properties"); + ErrorLogHelper.loadProperties(); + + LOGGER.info("Loading graph database"); + + AAIGraph.getInstance(); + ModelInjestor.getInstance(); + + // Jsm internal broker for aai events + //broker = new BrokerService(); + //broker.addConnector("tcp://localhost:61447"); + //broker.setPersistent(false); + //broker.setUseJmx(false); + //broker.setSchedulerSupport(false); + //broker.start(); + + LOGGER.info("A&AI Server initialization succcessful."); + System.setProperty("org.openecomp.aai.serverStarted", "true"); + + } catch (AAIException e) { + ErrorLogHelper.logException(e); + throw new RuntimeException("AAIException caught while initializing A&AI server", e); + } catch (IOException e) { + ErrorLogHelper.logError("AAI_4000", e.getMessage()); + throw new RuntimeException("IOException caught while initializing A&AI server", e); + } catch (Exception e) { + LOGGER.error("Unknown failure while initializing A&AI Server", e); + throw new RuntimeException("Unknown failure while initializing A&AI server", e); + } + } +} diff --git a/aai-resources/src/main/java/org/openecomp/aai/util/GenerateMethodMapper.java b/aai-resources/src/main/java/org/openecomp/aai/util/GenerateMethodMapper.java new file mode 100644 index 0000000..dd72530 --- /dev/null +++ b/aai-resources/src/main/java/org/openecomp/aai/util/GenerateMethodMapper.java @@ -0,0 +1,142 @@ +/*- + * ============LICENSE_START======================================================= + * org.openecomp.aai + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF 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.aai.util; + +import java.io.FileWriter; +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; +import java.util.Map; + +import org.json.JSONArray; +import org.json.JSONException; +import org.json.JSONObject; + +import org.openecomp.aai.audit.ListEndpoints; +import org.openecomp.aai.introspection.Version; + +public class GenerateMethodMapper { + + private final static String filePath = "bundleconfig-local/etc/appprops/methodMapper.properties"; + + /** + * The main method. + * + * @param args the arguments + * @throws Exception the exception + */ + public static void main(String[] args) throws Exception { + + ListEndpoints le = null; + JSONObject jo = new JSONObject(); + JSONArray ja = new JSONArray(); + + for (Version version : Version.values()) { + + le = new ListEndpoints(version); + Map ln = le.getLogicalNames(); + List keys = new ArrayList(ln.keySet()); + Collections.sort(keys); + for (String key : keys) { + addEndpointToJsonArray(key, ln.get(key), ja, version.toString()); + } + + } + + addUniqueEndpoints(ja); + + jo.put("ActiveAndAvailableInventory-CloudNetwork", ja); + try (FileWriter file = new FileWriter(filePath)) { + file.write(jo.toString(4)); + } + + System.exit(0); + + } + + /** + * Adds the unique endpoints. + * + * @param ja the ja + * @throws JSONException the JSON exception + */ + private static void addUniqueEndpoints(JSONArray ja) throws JSONException { + JSONObject joItem = new JSONObject(); + joItem.put("url", "/aai/{version}/service-design-and-creation/models*"); + joItem.put("method", "get"); + joItem.put("logicalName", "GetModel"); + ja.put(joItem); + joItem = new JSONObject(); + joItem.put("url", "/aai/{version}/service-design-and-creation/models*"); + joItem.put("method", "put"); + joItem.put("logicalName", "PutModel"); + ja.put(joItem); + joItem = new JSONObject(); + joItem.put("url", "/aai/{version}/service-design-and-creation/models*"); + joItem.put("method", "delete"); + joItem.put("logicalName", "DeleteModel"); + ja.put(joItem); + joItem = new JSONObject(); + joItem.put("url", "/aai/{version}/service-design-and-creation/named-queries/*"); + joItem.put("method", "get"); + joItem.put("logicalName", "GetNamedQuery"); + ja.put(joItem); + } + + /** + * Adds the endpoint to json array. + * + * @param url the url + * @param name the name + * @param ja the ja + * @param apiVersion the api version + * @throws JSONException the JSON exception + */ + private static void addEndpointToJsonArray(String url, String name, JSONArray ja, String apiVersion) + throws JSONException { + + JSONObject joGet = new JSONObject(); + JSONObject joPut = new JSONObject(); + JSONObject joDel = new JSONObject(); + + if (!url.endsWith("relationship")) { + joGet.put("url", url); + joGet.put("method", "get"); + joGet.put("logicalName", apiVersion + "Get" + name); + ja.put(joGet); + } + + if (url.endsWith("}") || url.endsWith("relationship")) { + joPut.put("url", url); + joPut.put("method", "put"); + joPut.put("logicalName", apiVersion + "Put" + name); + ja.put(joPut); + + joDel.put("url", url); + joDel.put("method", "delete"); + joDel.put("logicalName", apiVersion + "Delete" + name); + ja.put(joDel); + + } + + } + +} diff --git a/aai-resources/src/main/java/org/openecomp/aai/util/MergeResource.java b/aai-resources/src/main/java/org/openecomp/aai/util/MergeResource.java new file mode 100644 index 0000000..427f65b --- /dev/null +++ b/aai-resources/src/main/java/org/openecomp/aai/util/MergeResource.java @@ -0,0 +1,205 @@ +/*- + * ============LICENSE_START======================================================= + * org.openecomp.aai + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF 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.aai.util; + +import java.lang.reflect.Field; +import java.lang.reflect.Method; +import java.util.Date; + +import com.sun.tools.javac.util.List; + +//SWGK - 01/08/2016 - Helper function to deal with concurrency control +public class MergeResource { + + //Merge Assumptions: + //fromresource and toresource are the same resource type and same resource object + //fromresource is the latest version from the DB + //toresource is the version of the same resource with updates + //merging of child elements are complete overwrite of fromresource corresponding child element + //merging of relationshiplist is complete overwrite of fromresource corresponding releationship element + //In case of supplying the only specific child element update, please specify the child element type (need not be in canonical form) + //For parent only update (not involving child or relationship element update), then all the child elements and relationship list will be set as null in the merged object + //For setting null to primitive type (including String) you have to do it after the merge is called specifically for parent only copy + + + /** + * Merge. + * + * @param the generic type + * @param fromresource the fromresource + * @param toresource the toresource + * @param bupdateChildren the bupdate children + * @param childNamelist the child namelist + * @param bupdateRelatedLink the bupdate related link + * @return the t + */ + public static T merge(T fromresource, T toresource, boolean bupdateChildren, String childNamelist[], boolean bupdateRelatedLink) + { + Field[] fields = fromresource.getClass().getDeclaredFields(); + if (fields != null) + { + for (Field field : fields) + { + try + { + field.setAccessible(true); + if ( field.getName().equalsIgnoreCase("resourceVersion") ) + continue; + if ( isValidMergeType(field.getType()) ) + { + Object obj = field.get(toresource); + // If the updated resource's any property to be set null then one has to set it separately for the merged object + if (obj != null) + field.set(fromresource, obj); + continue; + } + else + // set the child list or relatedTo link to be null so no updates takes place + field.set(fromresource, null); + //override situation + if (bupdateChildren || bupdateRelatedLink) + { + if (bupdateRelatedLink && field.getName().equalsIgnoreCase("relationshipList")) + { + Object obj = field.get(toresource); + field.set(fromresource, obj); + continue; + } + if (field.getName().equalsIgnoreCase("relationshipList")) + if (!bupdateRelatedLink) + continue; + // not an efficient as it blindly updates all children - onus is on callee to nullify + // specific child(ren) that they don't want to update after the merge call. + // can be optimized to send a list of children class names in canonical form + // but deferring for next release so that only those children can be merged + if (bupdateChildren && (childNamelist != null)) + { + for (String classStringName : childNamelist) + { + if ( !classStringName.isEmpty() && field.getType().toString().toLowerCase().endsWith(classStringName.toLowerCase()) ) + { + Object obj = field.get(toresource); + field.set(fromresource, obj); + } + } + continue; + } + + if (bupdateChildren && (childNamelist == null)) + { + Object obj = field.get(toresource); + field.set(fromresource, obj); + + } + } + + } + catch (Exception e) + { + + } + + + } + } + return fromresource; + } + + + /** + * Merge. + * + * @param the generic type + * @param fromresource the fromresource + * @param toresource the toresource + * @return the t + */ + public static T merge(T fromresource, T toresource) + { + return merge(fromresource, toresource, false, false); + } + + /** + * Merge. + * + * @param the generic type + * @param fromresource the fromresource + * @param toresource the toresource + * @param bupdateChildren the bupdate children + * @param bupdateRelatedLink the bupdate related link + * @return the t + */ + public static T merge(T fromresource, T toresource, boolean bupdateChildren, boolean bupdateRelatedLink) + { + return merge(fromresource, toresource, bupdateChildren, null, bupdateRelatedLink); + } + + /** + * Checks if is valid merge type. + * + * @param fieldType the field type + * @return true, if is valid merge type + */ + public static boolean isValidMergeType(Class fieldType) { + if (fieldType.equals(String.class)) { + return true; + } else if (Date.class.isAssignableFrom(fieldType)) { + return true; + } else if (Number.class.isAssignableFrom(fieldType)) { + return true; + } else if (fieldType.equals(Integer.TYPE)) { + return true; + } else if (fieldType.equals(Long.TYPE)) { + return true; + } else if (Enum.class.isAssignableFrom(fieldType)) { + return true; + } else if (Boolean.class.isAssignableFrom(fieldType)) { + return true; + } + else { + return false; + } + } + + /** + * Gets the child return type. + * + * @param classname the classname + * @param methodname the methodname + * @return the class + */ + public static Class GetChildReturnType(String classname, String methodname) + { + try { + Class c = Class.forName(classname); + Method[] allMethods = c.getDeclaredMethods(); + for (Method m : allMethods) { + if (!m.getName().equals(methodname)) { + return m.getReturnType(); + } + } + } catch (ClassNotFoundException x) { + + } + + return null; + } +} diff --git a/aai-resources/src/main/java/org/openecomp/aai/util/PojoUtils.java b/aai-resources/src/main/java/org/openecomp/aai/util/PojoUtils.java new file mode 100644 index 0000000..870ddec --- /dev/null +++ b/aai-resources/src/main/java/org/openecomp/aai/util/PojoUtils.java @@ -0,0 +1,738 @@ +/*- + * ============LICENSE_START======================================================= + * org.openecomp.aai + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF 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.aai.util; + +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.core.JsonGenerationException; +import com.fasterxml.jackson.databind.DeserializationFeature; +import com.fasterxml.jackson.databind.JsonMappingException; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.fasterxml.jackson.databind.SerializationFeature; +import com.fasterxml.jackson.module.jaxb.JaxbAnnotationModule; +import com.google.common.base.CaseFormat; +import com.google.common.collect.Multimap; +import com.thinkaurelius.titan.core.TitanVertex; +import org.apache.commons.io.output.ByteArrayOutputStream; +import org.eclipse.persistence.dynamic.DynamicEntity; +import org.eclipse.persistence.dynamic.DynamicType; +import org.eclipse.persistence.jaxb.MarshallerProperties; +import org.openecomp.aai.domain.model.AAIResource; +import org.openecomp.aai.exceptions.AAIException; + +import javax.xml.bind.JAXBContext; +import javax.xml.bind.JAXBException; +import javax.xml.bind.Marshaller; +import java.io.IOException; +import java.io.StringWriter; +import java.lang.reflect.InvocationTargetException; +import java.lang.reflect.Method; +import java.util.*; +import java.util.Map.Entry; + +public class PojoUtils { + + /** + * Gets the key value list. + * + * @param the generic type + * @param e the e + * @param clazz the clazz + * @return the key value list + * @throws IllegalAccessException the illegal access exception + * @throws IllegalArgumentException the illegal argument exception + * @throws InvocationTargetException the invocation target exception + */ + public List getKeyValueList(Entity e, T clazz) throws IllegalAccessException, IllegalArgumentException, InvocationTargetException { + List kvList = e.getKeyValueList(); + Object value = null; + Method[] methods = clazz.getClass().getDeclaredMethods(); + String propertyName = ""; + + for (Method method : methods) { + if (method.getName().startsWith("get")) { + propertyName = CaseFormat.UPPER_CAMEL.to(CaseFormat.LOWER_HYPHEN,method.getName().substring(3)); + if (!(method.getReturnType().getName().contains("aai")) || method.getReturnType().getName().contains("java.util.List")) { + value = method.invoke(clazz); + KeyValueList kv = new KeyValueList(); + kv.setKey(propertyName); + if (value != null) { + kv.setValue(value.toString()); + } else { + kv.setValue(""); + } + kvList.add(kv); + } + } + } + return kvList; + } + + /** + * Gets the json from object. + * + * @param the generic type + * @param clazz the clazz + * @return the json from object + * @throws JsonGenerationException the json generation exception + * @throws JsonMappingException the json mapping exception + * @throws IOException Signals that an I/O exception has occurred. + */ + public String getJsonFromObject(T clazz) throws JsonGenerationException, JsonMappingException, IOException { + return getJsonFromObject(clazz, false, true); + } + + /** + * Gets the json from object. + * + * @param the generic type + * @param clazz the clazz + * @param wrapRoot the wrap root + * @param indent the indent + * @return the json from object + * @throws JsonGenerationException the json generation exception + * @throws JsonMappingException the json mapping exception + * @throws IOException Signals that an I/O exception has occurred. + */ + public String getJsonFromObject(T clazz, boolean wrapRoot, boolean indent) throws JsonGenerationException, JsonMappingException, IOException { + ObjectMapper mapper = new ObjectMapper(); + + mapper.setSerializationInclusion(JsonInclude.Include.NON_NULL); + + mapper.configure(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS, false); + mapper.configure(SerializationFeature.INDENT_OUTPUT, indent); + mapper.configure(SerializationFeature.WRAP_ROOT_VALUE, wrapRoot); + + mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); + mapper.configure(DeserializationFeature.UNWRAP_ROOT_VALUE, wrapRoot); + + mapper.registerModule(new JaxbAnnotationModule()); + + ByteArrayOutputStream baos = new ByteArrayOutputStream(); + + mapper.writeValue(baos, clazz); + + return baos.toString(); + } + + /** + * Gets the json from dynamic object. + * + * @param ent the ent + * @param jaxbContext the jaxb context + * @param includeRoot the include root + * @return the json from dynamic object + * @throws JsonGenerationException the json generation exception + * @throws JsonMappingException the json mapping exception + * @throws IOException Signals that an I/O exception has occurred. + * @throws JAXBException the JAXB exception + */ + public String getJsonFromDynamicObject(DynamicEntity ent, org.eclipse.persistence.jaxb.JAXBContext jaxbContext, boolean includeRoot) throws JsonGenerationException, JsonMappingException, IOException, JAXBException { + org.eclipse.persistence.jaxb.JAXBMarshaller marshaller = jaxbContext.createMarshaller(); + + marshaller.setProperty(org.eclipse.persistence.jaxb.JAXBMarshaller.JAXB_FORMATTED_OUTPUT, false); + marshaller.setProperty(MarshallerProperties.JSON_MARSHAL_EMPTY_COLLECTIONS, Boolean.FALSE) ; + marshaller.setProperty("eclipselink.json.include-root", includeRoot); + marshaller.setProperty("eclipselink.media-type", "application/json"); + StringWriter writer = new StringWriter(); + marshaller.marshal(ent, writer); + + return writer.toString(); + } + + /** + * Gets the xml from object. + * + * @param the generic type + * @param clazz the clazz + * @return the xml from object + * @throws JAXBException the JAXB exception + */ + public String getXmlFromObject(T clazz) throws JAXBException { + ByteArrayOutputStream baos = new ByteArrayOutputStream(); + JAXBContext jc = JAXBContext.newInstance(clazz.getClass().getPackage().getName()); + + Marshaller marshaller = jc.createMarshaller(); + marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true); + marshaller.marshal(clazz, baos); + + return baos.toString(); + } + + /** + * Gets the lookup key. + * + * @param baseKey the base key + * @param lookupHash the lookup hash + * @param keyProps the key props + * @return the lookup key + */ + public String getLookupKey (String baseKey, HashMap lookupHash, Collection keyProps) { + int baseKeyLen = baseKey.length(); + StringBuffer newKey = new StringBuffer(); + if (baseKeyLen > 0) { + newKey.append(baseKey); + } + + Iterator keyPropI = keyProps.iterator(); + while( keyPropI.hasNext() ){ + String keyProp = keyPropI.next(); + if (baseKeyLen > 0) { + newKey.append("&"); + } + newKey.append(keyProp + "=" + lookupHash.get(keyProp)); + } + return newKey.toString(); + } + + /** + * Gets the lookup keys. + * + * @param lookupHashes the lookup hashes + * @param _dbRulesNodeKeyProps the db rules node key props + * @return the lookup keys + */ + public String getLookupKeys (LinkedHashMap> lookupHashes, Multimap _dbRulesNodeKeyProps) { + Iterator it = lookupHashes.keySet().iterator(); + String lookupKeys = ""; + while (it.hasNext()) { + String objectType = (String)it.next(); + HashMap lookupHash = lookupHashes.get(objectType); + + Collection keyProps = _dbRulesNodeKeyProps.get(objectType); + Iterator keyPropI = keyProps.iterator(); + while( keyPropI.hasNext() ){ + lookupKeys += lookupHash.get(keyPropI.next()); + } + } + return lookupKeys; + } + + /** + * Gets the example object. + * + * @param the generic type + * @param clazz the clazz + * @param singleton the singleton + * @return the example object + * @throws IllegalAccessException the illegal access exception + * @throws IllegalArgumentException the illegal argument exception + * @throws InvocationTargetException the invocation target exception + * @throws NoSuchMethodException the no such method exception + * @throws SecurityException the security exception + * @throws AAIException the AAI exception + */ + public void getExampleObject(T clazz, boolean singleton) throws IllegalAccessException, IllegalArgumentException, InvocationTargetException, NoSuchMethodException, SecurityException, AAIException { + Method[] methods = clazz.getClass().getDeclaredMethods(); + String dnHypPropertyName = ""; + String upCamPropertyName = ""; + Random rand = new Random(); + int randInt = rand.nextInt(10000000); + + for (Method method : methods) { + boolean go = false; + if (method.getName().startsWith("get")) { + dnHypPropertyName = CaseFormat.UPPER_CAMEL.to(CaseFormat.LOWER_HYPHEN,method.getName().substring(3)); + upCamPropertyName = CaseFormat.UPPER_CAMEL.to(CaseFormat.UPPER_CAMEL,method.getName().substring(3)); + go = true; + } else if (method.getName().startsWith("is")) { + dnHypPropertyName = CaseFormat.UPPER_CAMEL.to(CaseFormat.LOWER_HYPHEN,method.getName().substring(2)); + upCamPropertyName = CaseFormat.UPPER_CAMEL.to(CaseFormat.UPPER_CAMEL,method.getName().substring(2)); + go = true; + } + // don't return resource-version on a singleton + if (singleton && dnHypPropertyName.equals("resource-version")) { + go = false; + } + if (go) { + String retType = method.getReturnType().getName(); + if (!retType.contains("aai") && !retType.contains("java.util.List")) { + // get the setter + Method meth = clazz.getClass().getMethod("set" + upCamPropertyName, method.getReturnType()); + + if (retType.contains("String")) { + String val = "example-" + dnHypPropertyName + "-val-" + randInt; + if (val != null) { + meth.invoke(clazz, val); + } + } else if (retType.toLowerCase().contains("long")) { + Integer foo = rand.nextInt(100000); + meth.invoke(clazz, foo.longValue()); + } else if (retType.toLowerCase().contains("int")) { + meth.invoke(clazz, rand.nextInt(100000)); + } else if (retType.toLowerCase().contains("short")) { + Integer randShort = rand.nextInt(10000); + meth.invoke(clazz, randShort.shortValue()); + } else if (retType.toLowerCase().contains("boolean")) { + meth.invoke(clazz, true); + } + } + } + } + } + + + /** + * Gets the aai object from vertex. + * + * @param the generic type + * @param clazz the clazz + * @param vert the vert + * @param _propertyDataTypeMap the property data type map + * @return the aai object from vertex + * @throws IllegalAccessException the illegal access exception + * @throws IllegalArgumentException the illegal argument exception + * @throws InvocationTargetException the invocation target exception + * @throws NoSuchMethodException the no such method exception + * @throws SecurityException the security exception + * @throws AAIException the AAI exception + */ + public void getAaiObjectFromVertex(T clazz, TitanVertex vert, Map _propertyDataTypeMap) throws IllegalAccessException, IllegalArgumentException, InvocationTargetException, NoSuchMethodException, SecurityException, AAIException { + Method[] methods = clazz.getClass().getDeclaredMethods(); + String dnHypPropertyName = ""; + String upCamPropertyName = ""; + for (Method method : methods) { + boolean go = false; + if (method.getName().startsWith("get")) { + dnHypPropertyName = CaseFormat.UPPER_CAMEL.to(CaseFormat.LOWER_HYPHEN,method.getName().substring(3)); + upCamPropertyName = CaseFormat.UPPER_CAMEL.to(CaseFormat.UPPER_CAMEL,method.getName().substring(3)); + go = true; + } else if (method.getName().startsWith("is")) { + dnHypPropertyName = CaseFormat.UPPER_CAMEL.to(CaseFormat.LOWER_HYPHEN,method.getName().substring(2)); + upCamPropertyName = CaseFormat.UPPER_CAMEL.to(CaseFormat.UPPER_CAMEL,method.getName().substring(2)); + go = true; + } + if (go) { + String retType = method.getReturnType().getName(); + if (!retType.contains("aai") && !retType.contains("java.util.List")) { + // get the setter + Method meth = clazz.getClass().getMethod("set" + upCamPropertyName, method.getReturnType()); + + if (retType.contains("String")) { + String val = (String)vert.property(dnHypPropertyName).orElse(null); + if (val != null) { + meth.invoke(clazz, val); + } + } else if (retType.toLowerCase().contains("long")) { + String titanType = _propertyDataTypeMap.get(dnHypPropertyName); + + Long val = null; + // we have a case where the type in titan is "Integer" but in the POJO it's Long or long + if (titanType.toLowerCase().contains("int")) { + Integer intVal = (Integer)vert.property(dnHypPropertyName).orElse(null); + if (intVal != null) { + val = intVal.longValue(); + } + } else { + val = (Long)vert.property(dnHypPropertyName).orElse(null); + } + if (val != null) { + meth.invoke(clazz, val); + } + } else if (retType.toLowerCase().contains("int")) { + Integer val = (Integer)vert.property(dnHypPropertyName).orElse(null); + if (val != null) { + meth.invoke(clazz, val); + } + } else if (retType.toLowerCase().contains("short")) { + Short val = (Short)vert.property(dnHypPropertyName).orElse(null); + if (val != null) { + meth.invoke(clazz, val); + } + } else if (retType.toLowerCase().contains("boolean")) { + Boolean val = (Boolean)vert.property(dnHypPropertyName).orElse(null); + if (val != null) { + meth.invoke(clazz, val); + } + } + } + } + } + } + + /** + * Gets the topology object. + * + * @param the generic type + * @param clazz the clazz + * @param _dbRulesNodeNameProps the db rules node name props + * @param _dbRulesNodeKeyProps the db rules node key props + * @param vert the vert + * @return the topology object + * @throws IllegalAccessException the illegal access exception + * @throws IllegalArgumentException the illegal argument exception + * @throws InvocationTargetException the invocation target exception + * @throws NoSuchMethodException the no such method exception + * @throws SecurityException the security exception + * @throws AAIException the AAI exception + */ + public void getTopologyObject(T clazz, Multimap _dbRulesNodeNameProps, Multimap _dbRulesNodeKeyProps, TitanVertex vert) throws IllegalAccessException, IllegalArgumentException, InvocationTargetException, NoSuchMethodException, SecurityException, AAIException { + Method[] methods = clazz.getClass().getDeclaredMethods(); + String dnHypPropertyName = ""; +// Object value = null; + List includeProps = new ArrayList(); + + if ("false".equals(AAIConfig.get("aai.notification.topology.allAttrs", "false"))) { + for (Method method : methods) { + if (method.getName().startsWith("is")) { + dnHypPropertyName = CaseFormat.UPPER_CAMEL.to(CaseFormat.LOWER_HYPHEN,method.getName().substring(2)); + String upCamPropertyName = CaseFormat.UPPER_CAMEL.to(CaseFormat.UPPER_CAMEL,method.getName().substring(2)); + String retType = method.getReturnType().getName(); + if (retType.equals("java.lang.Boolean")) { + // get the setter + Method setterMeth = clazz.getClass().getMethod("set" + upCamPropertyName, method.getReturnType()); + setterMeth.invoke(clazz, (Boolean)null); + } + } + } + String dnHypClassName = CaseFormat.UPPER_CAMEL.to(CaseFormat.LOWER_HYPHEN,clazz.getClass().getSimpleName()); + Collection keepProps = _dbRulesNodeNameProps.get(dnHypClassName); + Iterator keepPropI = keepProps.iterator(); + while( keepPropI.hasNext() ){ + includeProps.add(keepPropI.next()); + } + Collection keepProps2 = _dbRulesNodeKeyProps.get(dnHypClassName); + Iterator keepPropI2 = keepProps2.iterator(); + while( keepPropI2.hasNext() ){ + includeProps.add(keepPropI2.next()); + } + } + + for (Method method : methods) { + if (method.getName().startsWith("get")) { + dnHypPropertyName = CaseFormat.UPPER_CAMEL.to(CaseFormat.LOWER_HYPHEN,method.getName().substring(3)); + if (includeProps.size() > 0) { + if (!includeProps.contains(dnHypPropertyName)) { + continue; + } + } + String upCamPropertyName = CaseFormat.UPPER_CAMEL.to(CaseFormat.UPPER_CAMEL,method.getName().substring(3)); + String retType = method.getReturnType().getName(); + if (!retType.contains("aai") && !retType.contains("java.util.List")) { + // get the setter + Method meth = clazz.getClass().getMethod("set" + upCamPropertyName, method.getReturnType()); + + if (retType.contains("String")) { + String val = (String)vert.property(dnHypPropertyName).orElse(null); + if (val != null) { + meth.invoke(clazz, val); + } + } else if (retType.toLowerCase().contains("long")) { + Long val = (Long)vert.property(dnHypPropertyName).orElse(null); + if (val != null) { + meth.invoke(clazz, val); + } + } else if (retType.toLowerCase().contains("int")) { + Integer val = (Integer)vert.property(dnHypPropertyName).orElse(null); + if (val != null) { + meth.invoke(clazz, val); + } + } else if (retType.toLowerCase().contains("short")) { + Short val = (Short)vert.property(dnHypPropertyName).orElse(null); + if (val != null) { + meth.invoke(clazz, val); + } + } + } + } + } + } + + /** + * Gets the dynamic topology object. + * + * @param aaiRes the aai res + * @param meObjectType the me object type + * @param _dbRulesNodeNameProps the db rules node name props + * @param _dbRulesNodeKeyProps the db rules node key props + * @param _propertyDataTypeMap the property data type map + * @param vert the vert + * @return the dynamic topology object + * @throws AAIException the AAI exception + */ + public DynamicEntity getDynamicTopologyObject(AAIResource aaiRes, DynamicType meObjectType, Multimap _dbRulesNodeNameProps, + Multimap _dbRulesNodeKeyProps, Map _propertyDataTypeMap, TitanVertex vert) throws AAIException { + + DynamicEntity meObject = meObjectType.newDynamicEntity(); + + List includeProps = new ArrayList(); + + if ("false".equals(AAIConfig.get("aai.notification.topology.allAttrs", "false"))) { + String dnHypClassName = CaseFormat.UPPER_CAMEL.to(CaseFormat.LOWER_HYPHEN,meObjectType.getJavaClass().getSimpleName()); + Collection keepProps = _dbRulesNodeNameProps.get(dnHypClassName); + Iterator keepPropI = keepProps.iterator(); + while( keepPropI.hasNext() ){ + includeProps.add(keepPropI.next()); + } + Collection keepProps2 = _dbRulesNodeKeyProps.get(dnHypClassName); + Iterator keepPropI2 = keepProps2.iterator(); + while( keepPropI2.hasNext() ) { + includeProps.add(keepPropI2.next()); + } + } + + + + for (String attrName : aaiRes.getStringFields()) { + if (includeProps.contains(attrName)) { + meObject.set((CaseFormat.LOWER_HYPHEN.to(CaseFormat.LOWER_CAMEL,attrName)), vert.property(attrName).orElse(null)); + } + } + // the attrName might need to be converted to camel case!!! + for (String attrName : aaiRes.getLongFields()) { + if (includeProps.contains(attrName)) { + String titanType = _propertyDataTypeMap.get(attrName); + + Long val = null; + // we have a case where the type in titan is "Integer" but in the POJO it's Long or long + if (titanType.toLowerCase().contains("int")) { + Integer intVal = (Integer)vert.property(attrName).orElse(null); + if (intVal != null) { + val = intVal.longValue(); + } + } else { + val = (Long)vert.property(attrName).orElse(null); + } + meObject.set((CaseFormat.LOWER_HYPHEN.to(CaseFormat.LOWER_CAMEL,attrName)), val); + } + } + + for (String attrName : aaiRes.getIntFields()) { + if (includeProps.contains(attrName)) { + Integer val = (Integer)vert.property(attrName).orElse(null); + meObject.set((CaseFormat.LOWER_HYPHEN.to(CaseFormat.LOWER_CAMEL,attrName)), val); + } + } + + for (String attrName : aaiRes.getShortFields()) { + if (includeProps.contains(attrName)) { + String titanType = _propertyDataTypeMap.get(attrName); + + Short val = null; + // we have a case where the type in titan is "Integer" but in the POJO it's Long or long + if (titanType.toLowerCase().contains("int")) { + Integer intVal = (Integer)vert.property(attrName).orElse(null); + if (intVal != null) { + val = intVal.shortValue(); + } + } else { + val = (Short)vert.property(attrName).orElse(null); + } + meObject.set((CaseFormat.LOWER_HYPHEN.to(CaseFormat.LOWER_CAMEL,attrName)), val); + } + } + + for (String attrName : aaiRes.getBooleanFields()) { + if (includeProps.contains(attrName)) { + Boolean val = (Boolean)vert.property(attrName).orElse(null); + meObject.set((CaseFormat.LOWER_HYPHEN.to(CaseFormat.LOWER_CAMEL,attrName)), val); + } + } + return meObject; + } + + /** + * Gets the aai dynamic object from vertex. + * + * @param aaiRes the aai res + * @param meObject the me object + * @param vert the vert + * @param _propertyDataTypeMap the property data type map + * @return the aai dynamic object from vertex + */ + public void getAaiDynamicObjectFromVertex(AAIResource aaiRes, DynamicEntity meObject, TitanVertex vert, + Map _propertyDataTypeMap) { + getAaiDynamicObjectFromVertex(aaiRes, meObject, vert, _propertyDataTypeMap, null); + } + + /** + * Gets the aai dynamic object from vertex. + * + * @param aaiRes the aai res + * @param meObject the me object + * @param vert the vert + * @param _propertyDataTypeMap the property data type map + * @param propertyOverRideHash the property over ride hash + * @return the aai dynamic object from vertex + */ + @SuppressWarnings("unchecked") + public void getAaiDynamicObjectFromVertex(AAIResource aaiRes, DynamicEntity meObject, TitanVertex vert, + Map _propertyDataTypeMap, HashMap propertyOverRideHash) { + + for (String attrName : aaiRes.getStringFields()) { + if (propertyOverRideHash == null || (propertyOverRideHash != null && propertyOverRideHash.containsKey(attrName))) { + meObject.set((CaseFormat.LOWER_HYPHEN.to(CaseFormat.LOWER_CAMEL,attrName)), vert.property(dbAliasWorkaround(attrName)).orElse(null)); + } + } + + for (String attrName : aaiRes.getStringListFields()) { + if (propertyOverRideHash == null || (propertyOverRideHash != null && propertyOverRideHash.containsKey(attrName))) { + meObject.set((CaseFormat.LOWER_HYPHEN.to(CaseFormat.LOWER_CAMEL,attrName)), vert.>property(attrName).orElse(null)); + } + } + + // the attrName might need to be converted to camel case!!! + for (String attrName : aaiRes.getLongFields()) { + String titanType = _propertyDataTypeMap.get(attrName); + Long val = null; + // we have a case where the type in titan is "Integer" but in the POJO it's Long or long + if (titanType.toLowerCase().contains("int")) { + Object vertexVal = vert.property(attrName).orElse(null); + if (vertexVal != null) { + if (vertexVal instanceof Integer) { + val = ((Integer)vertexVal).longValue(); + + } else { + val = (Long)vert.property(attrName).orElse(null); + } + } + } else { + val = (Long)vert.property(attrName).orElse(null); + } + if (val != null) { + if (propertyOverRideHash == null || (propertyOverRideHash != null && propertyOverRideHash.containsKey(attrName))) { + meObject.set((CaseFormat.LOWER_HYPHEN.to(CaseFormat.LOWER_CAMEL,attrName)), val); + } + } + } + + for (String attrName : aaiRes.getIntFields()) { + Integer val = (Integer)vert.property(attrName).orElse(null); + if (val != null) { + if (propertyOverRideHash == null || (propertyOverRideHash != null && propertyOverRideHash.containsKey(attrName))) { + meObject.set((CaseFormat.LOWER_HYPHEN.to(CaseFormat.LOWER_CAMEL,attrName)), val); + } + } + } + + for (String attrName : aaiRes.getShortFields()) { + String titanType = _propertyDataTypeMap.get(attrName); + Short val = null; + // we have a case where the type in titan is "Integer" but in the POJO it's Long or long + if (titanType.toLowerCase().contains("int")) { + Integer intVal = (Integer)vert.property(attrName).orElse(null); + if (intVal != null) { + val = intVal.shortValue(); + } + } else { + val = (Short)vert.property(attrName).orElse(null); + } + if (val != null) { + if (propertyOverRideHash == null || (propertyOverRideHash != null && propertyOverRideHash.containsKey(attrName))) { + meObject.set((CaseFormat.LOWER_HYPHEN.to(CaseFormat.LOWER_CAMEL,attrName)), val); + } + } + } + + for (String attrName : aaiRes.getBooleanFields()) { + Boolean val = (Boolean)vert.property(attrName).orElse(null); + // This is not ideal, but moxy isn't marshalling these attributes. + // TODO: Figure out how to see the default-value from the OXM at startup (or at runtime). + String dnHypClassName = CaseFormat.UPPER_CAMEL.to(CaseFormat.LOWER_HYPHEN,aaiRes.getSimpleName()); + if (val == null && AAIConfig.getDefaultBools().containsKey(dnHypClassName)) { + if (AAIConfig.getDefaultBools().get(dnHypClassName).contains(attrName)) { + val = false; + } + } + if (val != null) { + if (propertyOverRideHash == null || (propertyOverRideHash != null && propertyOverRideHash.containsKey(attrName))) { + meObject.set((CaseFormat.LOWER_HYPHEN.to(CaseFormat.LOWER_CAMEL,attrName)), val); + } + } + } + + } + + private String dbAliasWorkaround(String propName) { + final String modelInvariantIdLocal = "model-invariant-id-local"; + final String modelVersionIdLocal = "model-version-id-local"; + final String modelInvariantId = "model-invariant-id"; + final String modelVersionId = "model-version-id"; + + if (propName.equals(modelInvariantId)) { + return modelInvariantIdLocal; + } + if (propName.equals(modelVersionId)) { + return modelVersionIdLocal; + } + + return propName; + + } + + /** + * Gets the dynamic example object. + * + * @param childObject the child object + * @param aaiRes the aai res + * @param singleton the singleton + * @return the dynamic example object + */ + public void getDynamicExampleObject(DynamicEntity childObject, AAIResource aaiRes, boolean singleton) { + // TODO Auto-generated method stub + + Random rand = new Random(); + Integer randInt = rand.nextInt(100000); + long range = 100000000L; + long randLong = (long)(rand.nextDouble()*range); + Integer randShrt = rand.nextInt(20000); + short randShort = randShrt.shortValue(); + + for (String dnHypAttrName : aaiRes.getStringFields()) { + + if (singleton && ("resource-version").equals(dnHypAttrName)) { + continue; + } + + String dnCamAttrName = CaseFormat.LOWER_HYPHEN.to(CaseFormat.LOWER_CAMEL,dnHypAttrName); + childObject.set(dnCamAttrName, "example-" + dnHypAttrName + "-val-" + randInt); + + } + + for (String dnHypAttrName : aaiRes.getStringListFields()) { + ArrayList exampleList = new ArrayList(); + exampleList.add("example-" + dnHypAttrName + "-val-" + randInt + "-" + 1); + exampleList.add("example-" + dnHypAttrName + "-val-" + randInt + "-" + 2); + String dnCamAttrName = CaseFormat.LOWER_HYPHEN.to(CaseFormat.LOWER_CAMEL,dnHypAttrName); + childObject.set(dnCamAttrName, exampleList); + } + + // the attrName might need to be converted to camel case!!! + for (String dnHypAttrName : aaiRes.getLongFields()) { + String dnCamAttrName = CaseFormat.LOWER_HYPHEN.to(CaseFormat.LOWER_CAMEL,dnHypAttrName); + childObject.set(dnCamAttrName, randLong); + } + + for (String dnHypAttrName : aaiRes.getIntFields()) { + String dnCamAttrName = CaseFormat.LOWER_HYPHEN.to(CaseFormat.LOWER_CAMEL,dnHypAttrName); + childObject.set(dnCamAttrName, randInt); + } + + for (String dnHypAttrName : aaiRes.getShortFields()) { + String dnCamAttrName = CaseFormat.LOWER_HYPHEN.to(CaseFormat.LOWER_CAMEL,dnHypAttrName); + childObject.set(dnCamAttrName, randShort); + } + + for (String dnHypAttrName : aaiRes.getBooleanFields()) { + String dnCamAttrName = CaseFormat.LOWER_HYPHEN.to(CaseFormat.LOWER_CAMEL,dnHypAttrName); + childObject.set(dnCamAttrName, Boolean.TRUE); + } + } +} diff --git a/aai-resources/src/main/java/org/openecomp/aai/util/StoreNotificationEvent.java b/aai-resources/src/main/java/org/openecomp/aai/util/StoreNotificationEvent.java new file mode 100644 index 0000000..ea674ed --- /dev/null +++ b/aai-resources/src/main/java/org/openecomp/aai/util/StoreNotificationEvent.java @@ -0,0 +1,283 @@ +/*- + * ============LICENSE_START======================================================= + * org.openecomp.aai + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF 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.aai.util; + +import java.io.StringWriter; +import java.text.DateFormat; +import java.text.SimpleDateFormat; +import java.util.Date; +import java.util.Iterator; +import java.util.List; +import java.util.Map; +import java.util.UUID; + +import javax.xml.bind.Marshaller; + +import org.apache.cxf.helpers.CastUtils; +import org.apache.cxf.message.Message; +import org.apache.cxf.phase.PhaseInterceptorChain; +import org.eclipse.persistence.dynamic.DynamicEntity; +import org.eclipse.persistence.jaxb.dynamic.DynamicJAXBContext; +import org.json.JSONException; +import org.json.JSONObject; +import org.openecomp.aai.dmaap.AAIDmaapEventJMSProducer; +import org.openecomp.aai.exceptions.AAIException; +import org.openecomp.aai.introspection.Introspector; +import org.openecomp.aai.introspection.Loader; +import org.openecomp.aai.introspection.exceptions.AAIUnknownObjectException; + +public class StoreNotificationEvent { + + private AAIDmaapEventJMSProducer messageProducer; + private String fromAppId = ""; + private String transId = ""; + + /** + * Instantiates a new store notification event. + */ + public StoreNotificationEvent() { + this.messageProducer = new AAIDmaapEventJMSProducer(); + Message inMessage = PhaseInterceptorChain.getCurrentMessage().getExchange().getInMessage(); + Map> headersList = CastUtils.cast((Map) inMessage.get(Message.PROTOCOL_HEADERS)); + if (headersList != null) { + List xt = headersList.get("X-TransactionId"); + if (xt != null) { + for (String transIdValue : xt) { + transId = transIdValue; + } + } + List fa = headersList.get("X-FromAppId"); + if (fa != null) { + for (String fromAppIdValue : fa) { + + fromAppId = fromAppIdValue; + } + } + } + } + + + /** + * Store dynamic event. + * + * @param notificationJaxbContext + * the notification jaxb context + * @param notificationVersion + * the notification version + * @param eventHeader + * the event header + * @param obj + * the obj + * @throws AAIException + * the AAI exception + */ + public void storeDynamicEvent(DynamicJAXBContext notificationJaxbContext, String notificationVersion, DynamicEntity eventHeader, DynamicEntity obj) throws AAIException { + + if (obj == null) { + throw new AAIException("AAI_7350"); + } + + DynamicEntity notificationEvent = notificationJaxbContext.getDynamicType("inventory.aai.openecomp.org." + notificationVersion + ".NotificationEvent").newDynamicEntity(); + + if (eventHeader.get("id") == null) { + eventHeader.set("id", genDate2() + "-" + UUID.randomUUID().toString()); + } + + if (eventHeader.get("timestamp") == null) { + eventHeader.set("timestamp", genDate()); + } + + if (eventHeader.get("entityLink") == null) { + eventHeader.set("entityLink", "UNK"); + } + + if (eventHeader.get("action") == null) { + eventHeader.set("action", "UNK"); + } + + if (eventHeader.get("eventType") == null) { + eventHeader.set("eventType", AAIConfig.get("aai.notificationEvent.default.eventType", "UNK")); + } + + if (eventHeader.get("domain") == null) { + eventHeader.set("domain", AAIConfig.get("aai.notificationEvent.default.domain", "UNK")); + } + + if (eventHeader.get("sourceName") == null) { + eventHeader.set("sourceName", AAIConfig.get("aai.notificationEvent.default.sourceName", "UNK")); + } + + if (eventHeader.get("sequenceNumber") == null) { + eventHeader.set("sequenceNumber", AAIConfig.get("aai.notificationEvent.default.sequenceNumber", "UNK")); + } + + if (eventHeader.get("severity") == null) { + eventHeader.set("severity", AAIConfig.get("aai.notificationEvent.default.severity", "UNK")); + } + + if (eventHeader.get("version") == null) { + eventHeader.set("version", AAIConfig.get("aai.notificationEvent.default.version", "UNK")); + } + + if (notificationEvent.get("cambriaPartition") == null) { + notificationEvent.set("cambriaPartition", AAIConstants.UEB_PUB_PARTITION_AAI); + } + + notificationEvent.set("eventHeader", eventHeader); + notificationEvent.set("entity", obj); + + try { + StringWriter result = new StringWriter(); + + Marshaller marshaller = notificationJaxbContext.createMarshaller(); + marshaller.setProperty(org.eclipse.persistence.jaxb.MarshallerProperties.MEDIA_TYPE, "application/json"); + marshaller.setProperty(org.eclipse.persistence.jaxb.MarshallerProperties.JSON_INCLUDE_ROOT, false); + marshaller.setProperty(org.eclipse.persistence.jaxb.MarshallerProperties.JSON_WRAPPER_AS_ARRAY_NAME, false); + marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, false); + marshaller.marshal(notificationEvent, result); + + this.sendToDmaapJmsQueue(result.toString()); + + } catch (Exception e) { + throw new AAIException("AAI_7350", e); + } + } + + public void storeEvent(Loader loader, Introspector eventHeader, Introspector obj) throws AAIException { + if (obj == null) { + throw new AAIException("AAI_7350"); + } + + try { + final Introspector notificationEvent = loader.introspectorFromName("notification-event"); + + if (eventHeader.getValue("id") == null) { + eventHeader.setValue("id", genDate2() + "-" + UUID.randomUUID().toString()); + } + + if (eventHeader.getValue("timestamp") == null) { + eventHeader.setValue("timestamp", genDate()); + } + + if (eventHeader.getValue("entity-link") == null) { + eventHeader.setValue("entity-link", "UNK"); + } + + if (eventHeader.getValue("action") == null) { + eventHeader.setValue("action", "UNK"); + } + + if (eventHeader.getValue("event-type") == null) { + eventHeader.setValue("event-type", AAIConfig.get("aai.notificationEvent.default.eventType", "UNK")); + } + + if (eventHeader.getValue("domain") == null) { + eventHeader.setValue("domain", AAIConfig.get("aai.notificationEvent.default.domain", "UNK")); + } + + if (eventHeader.getValue("source-name") == null) { + eventHeader.setValue("source-name", AAIConfig.get("aai.notificationEvent.default.sourceName", "UNK")); + } + + if (eventHeader.getValue("sequence-number") == null) { + eventHeader.setValue("sequence-number", AAIConfig.get("aai.notificationEvent.default.sequenceNumber", "UNK")); + } + + if (eventHeader.getValue("severity") == null) { + eventHeader.setValue("severity", AAIConfig.get("aai.notificationEvent.default.severity", "UNK")); + } + + if (eventHeader.getValue("version") == null) { + eventHeader.setValue("version", AAIConfig.get("aai.notificationEvent.default.version", "UNK")); + } + + if (notificationEvent.getValue("cambria-partition") == null) { + notificationEvent.setValue("cambria-partition", AAIConstants.UEB_PUB_PARTITION_AAI); + } + + notificationEvent.setValue("event-header", eventHeader.getUnderlyingObject()); + notificationEvent.setValue("entity", obj.getUnderlyingObject()); + + String entityJson = notificationEvent.marshal(false); + sendToDmaapJmsQueue(entityJson); + } catch (JSONException e) { + throw new AAIException("AAI_7350", e); + } catch (AAIUnknownObjectException e) { + throw new AAIException("AAI_7350", e); + } + } + + private void sendToDmaapJmsQueue(String entityString) throws JSONException { + + JSONObject entityJsonObject = new JSONObject(entityString); + + JSONObject entityJsonObjectUpdated = new JSONObject(); + JSONObject finalJson = new JSONObject(); + + JSONObject entityHeader = entityJsonObject.getJSONObject("event-header"); + String cambriaPartition = entityJsonObject.getString("cambria.partition"); + + entityJsonObject.remove("event-header"); + entityJsonObject.remove("cambria.partition"); + + entityJsonObjectUpdated.put("event-header", entityHeader); + entityJsonObjectUpdated.put("cambria.partition", cambriaPartition); + + Iterator iter = entityJsonObject.keys(); + JSONObject entity = new JSONObject(); + if (iter.hasNext()) { + entity = entityJsonObject.getJSONObject(iter.next()); + } + + entityJsonObjectUpdated.put("entity", entity); + + finalJson.put("event-topic", "AAI-EVENT"); + finalJson.put("transId", transId); + finalJson.put("fromAppId", fromAppId); + finalJson.put("fullId", ""); + finalJson.put("aaiEventPayload", entityJsonObjectUpdated); + + messageProducer.sendMessageToDefaultDestination(finalJson); + } + + /** + * Gen date. + * + * @return the string + */ + public static String genDate() { + Date date = new Date(); + DateFormat formatter = new SimpleDateFormat("YYYYMMdd-HH:mm:ss:SSS"); + return formatter.format(date); + } + + /** + * Gen date 2. + * + * @return the string + */ + public static String genDate2() { + Date date = new Date(); + DateFormat formatter = new SimpleDateFormat("YYYYMMddHHmmss"); + return formatter.format(date); + } + +} diff --git a/aai-resources/src/main/java/org/openecomp/aai/util/UniquePropertyCheck.java b/aai-resources/src/main/java/org/openecomp/aai/util/UniquePropertyCheck.java new file mode 100644 index 0000000..b5c5cbc --- /dev/null +++ b/aai-resources/src/main/java/org/openecomp/aai/util/UniquePropertyCheck.java @@ -0,0 +1,264 @@ +/*- + * ============LICENSE_START======================================================= + * org.openecomp.aai + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF 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.aai.util; +import java.util.HashMap; +import java.util.Iterator; +import java.util.Map; +import java.util.Properties; +import java.util.UUID; + +import org.apache.tinkerpop.gremlin.structure.Direction; +import org.apache.tinkerpop.gremlin.structure.Edge; +import org.apache.tinkerpop.gremlin.structure.VertexProperty; +import org.slf4j.MDC; + +import org.openecomp.aai.exceptions.AAIException; +import com.att.eelf.configuration.Configuration; +import com.att.eelf.configuration.EELFLogger; +import com.att.eelf.configuration.EELFManager; +import com.thinkaurelius.titan.core.TitanEdge; +import com.thinkaurelius.titan.core.TitanFactory; +import com.thinkaurelius.titan.core.TitanGraph; +import com.thinkaurelius.titan.core.TitanTransaction; +import com.thinkaurelius.titan.core.TitanVertex; + + + +public class UniquePropertyCheck { + + + private static final String FROMAPPID = "AAI-UTILS"; + private static final String TRANSID = UUID.randomUUID().toString(); + private static final String COMPONENT = "UniquePropertyCheck"; + + /** + * The main method. + * + * @param args the arguments + */ + public static void main(String[] args) { + + + Properties props = System.getProperties(); + props.setProperty(Configuration.PROPERTY_LOGGING_FILE_NAME, "uniquePropertyCheck-logback.xml"); + props.setProperty(Configuration.PROPERTY_LOGGING_FILE_PATH, AAIConstants.AAI_HOME_ETC_APP_PROPERTIES); + EELFLogger logger = EELFManager.getInstance().getLogger(UniquePropertyCheck.class.getSimpleName()); + MDC.put("logFilenameAppender", UniquePropertyCheck.class.getSimpleName()); + + if( args == null || args.length != 1 ){ + String msg = "usage: UniquePropertyCheck propertyName \n"; + System.out.println(msg); + logAndPrint(logger, msg ); + System.exit(1); + } + String propertyName = args[0]; + TitanTransaction graph = null; + + try { + AAIConfig.init(); + System.out.println(" ---- NOTE --- about to open graph (takes a little while)--------\n"); + TitanGraph tGraph = TitanFactory.open(AAIConstants.REALTIME_DB_CONFIG); + + if( tGraph == null ) { + logAndPrint(logger, " Error: Could not get TitanGraph "); + System.exit(1); + } + + graph = tGraph.newTransaction(); + if( graph == null ){ + logAndPrint(logger, "could not get graph object in UniquePropertyCheck() \n"); + System.exit(0); + } + } + catch (AAIException e1) { + String msg = "Threw Exception: [" + e1.toString() + "]"; + logAndPrint(logger, msg); + System.exit(0); + } + catch (Exception e2) { + String msg = "Threw Exception: [" + e2.toString() + "]"; + logAndPrint(logger, msg); + System.exit(0); + } + + runTheCheckForUniqueness( TRANSID, FROMAPPID, graph, propertyName, logger ); + System.exit(0); + + }// End main() + + + /** + * Run the check for uniqueness. + * + * @param transId the trans id + * @param fromAppId the from app id + * @param graph the graph + * @param propertyName the property name + * @param logger the logger + * @return the boolean + */ + public static Boolean runTheCheckForUniqueness( String transId, String fromAppId, TitanTransaction graph, + String propertyName, EELFLogger logger ){ + + // Note - property can be found in more than one nodetype + // our uniqueness constraints are always across the entire db - so this + // tool looks across all nodeTypes that the property is found in. + Boolean foundDupesFlag = false; + + HashMap valuesAndVidHash = new HashMap (); + HashMap dupeHash = new HashMap (); + + int propCount = 0; + int dupeCount = 0; + Iterable vertItr = graph.query().has(propertyName).vertices(); + Iterator vertItor = vertItr.iterator(); + while( vertItor.hasNext() ){ + propCount++; + TitanVertex v = (TitanVertex)vertItor.next(); + String thisVid = v.id().toString(); + Object val = (v.property(propertyName)).orElse(null); + if( valuesAndVidHash.containsKey(val) ){ + // We've seen this one before- track it in our dupe hash + dupeCount++; + if( dupeHash.containsKey(val) ){ + // This is not the first one being added to the dupe hash for this value + String updatedDupeList = dupeHash.get(val) + "|" + thisVid; + dupeHash.put(val.toString(), updatedDupeList); + } + else { + // This is the first time we see this value repeating + String firstTwoVids = valuesAndVidHash.get(val) + "|" + thisVid; + dupeHash.put(val.toString(), firstTwoVids); + } + } + else { + valuesAndVidHash.put(val.toString(), thisVid); + } + } + + + String info = "\n Found this property [" + propertyName + "] " + propCount + " times in our db."; + logAndPrint(logger, info); + info = " Found " + dupeCount + " cases of duplicate values for this property.\n\n"; + logAndPrint(logger, info); + + try { + if( ! dupeHash.isEmpty() ){ + Iterator dupeItr = dupeHash.entrySet().iterator(); + while( dupeItr.hasNext() ){ + Map.Entry pair = (Map.Entry) dupeItr.next(); + String dupeValue = pair.getKey().toString();; + String vidsStr = pair.getValue().toString(); + String[] vidArr = vidsStr.split("\\|"); + logAndPrint(logger, "\n\n -------------- Found " + vidArr.length + + " nodes with " + propertyName + " of this value: [" + dupeValue + "]. Node details: "); + + for( int i = 0; i < vidArr.length; i++ ){ + String vidString = vidArr[i]; + Long idLong = Long.valueOf(vidString); + TitanVertex tvx = (TitanVertex)graph.getVertex(idLong); + showPropertiesAndEdges( TRANSID, FROMAPPID, tvx, logger ); + } + } + } + } + catch( Exception e2 ){ + logAndPrint(logger, "Threw Exception: [" + e2.toString() + "]"); + } + finally { + if( graph != null ){ + graph.rollback(); + } + } + + return foundDupesFlag; + + }// end of runTheCheckForUniqueness() + + + /** + * Show properties and edges. + * + * @param transId the trans id + * @param fromAppId the from app id + * @param tVert the t vert + * @param logger the logger + */ + private static void showPropertiesAndEdges( String transId, String fromAppId, TitanVertex tVert, + EELFLogger logger ){ + + if( tVert == null ){ + logAndPrint(logger, "Null node passed to showPropertiesAndEdges."); + } + else { + String nodeType = ""; + Object ob = tVert.property("aai-node-type").orElse(null); + if( ob == null ){ + nodeType = "null"; + } + else{ + nodeType = ob.toString(); + } + + logAndPrint(logger, " AAINodeType/VtxID for this Node = [" + nodeType + "/" + tVert.id() + "]"); + logAndPrint(logger, " Property Detail: "); + Iterator> pI = tVert.properties(); + while( pI.hasNext() ){ + VertexProperty tp = pI.next(); + Object val = tp.value(); + logAndPrint(logger, "Prop: [" + tp.key() + "], val = [" + val + "] "); + } + + Iterator eI = tVert.edges(Direction.BOTH); + if( ! eI.hasNext() ){ + logAndPrint(logger, "No edges were found for this vertex. "); + } + while( eI.hasNext() ){ + TitanEdge ed = (TitanEdge) eI.next(); + String lab = ed.label(); + TitanVertex vtx = (TitanVertex) ed.otherVertex(tVert); + if( vtx == null ){ + logAndPrint(logger, " >>> COULD NOT FIND VERTEX on the other side of this edge edgeId = " + ed.id() + " <<< "); + } + else { + String nType = vtx.property("aai-node-type").orElse(null); + String vid = vtx.id().toString(); + logAndPrint(logger, "Found an edge (" + lab + ") from this vertex to a [" + nType + "] node with VtxId = " + vid); + } + } + } + } // End of showPropertiesAndEdges() + + + /** + * Log and print. + * + * @param logger the logger + * @param msg the msg + */ + protected static void logAndPrint(EELFLogger logger, String msg) { + System.out.println(msg); + logger.info(msg); + } + +} + + diff --git a/aai-resources/src/main/resources/docker/Dockerfile b/aai-resources/src/main/resources/docker/Dockerfile new file mode 100644 index 0000000..079805d --- /dev/null +++ b/aai-resources/src/main/resources/docker/Dockerfile @@ -0,0 +1,85 @@ +FROM ubuntu:14.04 + +ENV DEBIAN_FRONTEND noninteractive + +ENV HTTP_PROXY ${HTTP_PROXY} +ENV HTTPS_PROXY ${HTTP_PROXY} +ENV https_proxy ${HTTP_PROXY} +ENV http_proxy ${HTTP_PROXY} + +# Setup JAVA_HOME, this is useful for docker commandline +ENV JAVA_HOME /usr/lib/jvm/java-8-openjdk-amd64 + +# Install all the application requirements such as curl ksh and git +# Also install the chef and then remove it in one RUN command +# Because the docker files work like git commits and each command is committed +# So removing the chef in a different command will still have its in its build image +# Its good to be optimizing and removing any files that are not needed for docker images +# for the best possible performance out of your image + +RUN if [ ! -z ${HTTP_PROXY} ]; then echo "Acquire::http::proxy \"${HTTP_PROXY}\";" >> /etc/apt/apt.conf; fi && \ + if [ ! -z ${HTTP_PROXY} ]; then echo "Acquire::https::proxy \"${HTTP_PROXY}\";" >> /etc/apt/apt.conf; fi && \ + apt-get update && \ + apt-get install -y software-properties-common && \ + apt-get install --reinstall ca-certificates && \ + sudo -E add-apt-repository ppa:openjdk-r/ppa && \ + apt-get update && \ + apt-get -qq install -y openjdk-8-jre-headless git curl ksh && \ + curl -k -LO https://packages.chef.io/stable/ubuntu/14.04/chefdk_0.17.17-1_amd64.deb || \ + curl --tlsv1 -LO https://packages.chef.io/stable/ubuntu/14.04/chefdk_0.17.17-1_amd64.deb && \ + dpkg -i chefdk_0.17.17-1_amd64.deb && \ + rm chefdk_0.17.17-1_amd64.deb && \ + rm -rf /var/lib/apt/lists/* + +# Add the proper files into the docker image from your build +ADD ./opt/app /opt/app +ADD ./commonLibs/ /opt/app/commonLibs/ +ADD init-chef.sh /init-chef.sh +ADD docker-entrypoint.sh /docker-entrypoint.sh +ADD aai.sh /etc/profile.d/aai.sh + +# Expose the ports for outside linux to use +# 8447 is the important one to be used + +EXPOSE 8447 + +# Create the /var/chef if it doesn't exist +WORKDIR /var/chef + +# Create the directory structure of aai application resembling the development server +# hard-coding path to match ajsc version + +RUN chmod 755 /init-chef.sh /docker-entrypoint.sh && chmod 644 /etc/profile.d/aai.sh && \ + mkdir /opt/aaihome && \ + useradd -r -ms /bin/bash -d /opt/aaihome/aaiadmin aaiadmin && \ + mkdir -p /opt/app/${project.artifactId} && \ + chown aaiadmin:aaiadmin /opt/app/${project.artifactId} && \ + chown -R aaiadmin:aaiadmin /opt/app/${project.artifactId} && \ + mkdir -p /opt/aai/logroot && \ + chown -R aaiadmin:aaiadmin /opt/aai/logroot && \ + ln -s /opt/app/${project.artifactId}/bin scripts && \ + mkdir -p /opt/app/${project.artifactId}/extApps && chown -R aaiadmin:aaiadmin /opt/app/${project.artifactId}/extApps && \ + find /opt/app/${project.artifactId}/bin -name "*.sh" -exec chmod 755 {} + && \ + chown aaiadmin:aaiadmin /docker-entrypoint.sh && \ + chown -R aaiadmin:aaiadmin /var/chef && \ + mkdir -p /opt/aai/logroot/AAI-RES && \ + chown aaiadmin:aaiadmin /opt/aai/logroot/AAI-RES && \ + ln -s /opt/aai/logroot/AAI-RES /opt/app/${project.artifactId}/logs && \ + chown -R aaiadmin:aaiadmin /opt/app/${project.artifactId}/logs + +VOLUME /opt/aai/logroot/AAI-RES + +WORKDIR / + +USER aaiadmin + +# When the container is started this is the entrypoint script +# that docker will run. Make sure this script doesn't end abruptly +# If you want the container running even if the main application stops +# You can run a ever lasting process like tail -f /dev/null +# Or something like that at the end of the docker-entrypoint script +# So if the main application you are planning on running fails +# the docker container keeps on running forever + +ENTRYPOINT ./docker-entrypoint.sh + diff --git a/aai-resources/src/main/resources/docker/Dockerfile.ext b/aai-resources/src/main/resources/docker/Dockerfile.ext new file mode 100644 index 0000000..6beaf58 --- /dev/null +++ b/aai-resources/src/main/resources/docker/Dockerfile.ext @@ -0,0 +1,76 @@ +FROM ubuntu:14.04 + +ENV DEBIAN_FRONTEND noninteractive + +RUN apt-get update && apt-get install -y software-properties-common + +# sudo -E is required to preserve the environment +# If you remove that line, it will most like freeze at this step + +RUN sudo -E add-apt-repository ppa:openjdk-r/ppa && \ + apt-get update && \ + apt-get -qq install -y openjdk-8-jre-headless git curl ksh + +# Setup JAVA_HOME, this is useful for docker commandline +ENV JAVA_HOME /usr/lib/jvm/java-8-openjdk-amd64 + +# Install Chef +RUN curl -LO https://packages.chef.io/stable/ubuntu/14.04/chefdk_0.17.17-1_amd64.deb +RUN dpkg -i chefdk_0.17.17-1_amd64.deb +RUN rm chefdk_0.17.17-1_amd64.deb + +# Add the application folder and common libs to /opt inside container +# Add the chef script and startup script to docker container +# Change the permissions to enable execute access + +ADD ./opt/app /opt/app +ADD ./commonLibs/ /opt/app/commonLibs/ + +ADD init-chef.sh /init-chef.sh +ADD startup.sh /startup.sh +ADD aai.sh /etc/profile.d/aai.sh + +RUN chmod 755 /init-chef.sh /startup.sh +RUN chmod 644 /etc/profile.d/aai.sh + +# When the container is started this is the entrypoint script +# that docker will run. Make sure this script doesn't end abruptly +# If you want the container running even if the main application stops +# You can run a ever lasting process like tail -f /dev/null +# Or something like that at the end of the startup script +# So if the main application you are planning on running fails +# the docker container keeps on running forever + +ENTRYPOINT ./startup.sh + +# Expose the ports for outside linux to use +# 8443 is the important one to be used + +EXPOSE 8443 +EXPOSE 8080 + +# Create the directory structure of aai application resembling the development server +# hard-coding path to match ajsc version + +RUN mkdir /opt/aaihome && \ + useradd -ms /bin/bash -d /opt/aaihome/aaiadmin aaiadmin && \ + ln -s /opt/app/${project.artifactId}/${project.version} /opt/app/aai && \ + chown aaiadmin:aaiadmin /opt/app/aai && \ + chown -R aaiadmin:aaiadmin /opt/app/${project.artifactId}/${project.version} && \ + mkdir -p /opt/aai/logroot && \ + chown -R aaiadmin:aaiadmin /opt/aai/logroot && \ + ln -s /opt/app/aai/bin scripts && \ + mkdir /opt/app/aai/extApps && chown -R aaiadmin:aaiadmin /opt/app/aai/extApps && \ + find /opt/app/aai/bin -name "*.sh" -exec chmod 755 {} + + +WORKDIR /var/chef + +RUN chown aaiadmin:aaiadmin /startup.sh && \ + chown -R aaiadmin:aaiadmin /var/chef + +RUN mkdir /opt/aai/logroot/AAI && chown aaiadmin:aaiadmin /opt/aai/logroot/AAI +VOLUME /opt/aai/logroot/AAI + +WORKDIR / + +USER aaiadmin diff --git a/aai-resources/src/main/resources/docker/aai.sh b/aai-resources/src/main/resources/docker/aai.sh new file mode 100644 index 0000000..94781ef --- /dev/null +++ b/aai-resources/src/main/resources/docker/aai.sh @@ -0,0 +1,42 @@ +### +# ============LICENSE_START======================================================= +# org.openecomp.aai +# ================================================================================ +# Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. +# ================================================================================ +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# ============LICENSE_END========================================================= +### + +PROJECT_HOME=/opt/app/aai-resources +export PROJECT_HOME + +JAVA_HOME=/usr/lib/jvm/java-8-openjdk-amd64 +export JAVA_HOME + +AAIENV=dev +export AAIENV + +PATH=/usr/lib/jvm/java-8-openjdk-amd64:$PATH + +PROJECT_OWNER=aaiadmin +PROJECT_GROUP=aaiadmin +PROJECT_UNIXHOMEROOT=/opt/aaihome +export PROJECT_OWNER PROJECT_GROUP PROJECT_UNIXHOMEROOT +umask 0022 + +export idns_api_url= +export idnscred= +export idnstenant= + + diff --git a/aai-resources/src/main/resources/docker/commonLibs/README b/aai-resources/src/main/resources/docker/commonLibs/README new file mode 100644 index 0000000..00e36c0 --- /dev/null +++ b/aai-resources/src/main/resources/docker/commonLibs/README @@ -0,0 +1 @@ +// this file's presence ensures commonLibs folder is present when image is created \ No newline at end of file diff --git a/aai-resources/src/main/resources/docker/docker-entrypoint.sh b/aai-resources/src/main/resources/docker/docker-entrypoint.sh new file mode 100644 index 0000000..b22ab39 --- /dev/null +++ b/aai-resources/src/main/resources/docker/docker-entrypoint.sh @@ -0,0 +1,34 @@ +### +# ============LICENSE_START======================================================= +# org.openecomp.aai +# ================================================================================ +# Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. +# ================================================================================ +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# ============LICENSE_END========================================================= +### + +cd /opt/app/aai-resources; + +TITAN_CACHED="/opt/app/aai-resources/bundleconfig/etc/appprops/titan-cached.properties"; +TITAN_REALTIME="/opt/app/aai-resources/bundleconfig/etc/appprops/titan-realtime.properties"; +SERVER_HOST=${SERVER_HOST:-localhost}; +SERVER_TABLE=${SERVER_TABLE:-aaigraph-dev02}; + +sed -i 's/^storage.backend=inmemory/storage.backend=hbase/g' $TITAN_CACHED $TITAN_REALTIME; +sed -i "s/^storage.hostname=.*$/storage.hostname=${SERVER_HOST}/g" $TITAN_CACHED $TITAN_REALTIME; +sed -i "s/^storage.hbase.table=.*$/storage.hbase.table=${SERVER_TABLE}/g" $TITAN_CACHED $TITAN_REALTIME; + +/opt/app/aai-resources/bin/createDBSchema.sh; + +java -cp ${CLASSPATH}:/opt/app/commonLibs/*:/opt/app/aai-resources/etc:/opt/app/aai-resources/lib/*:/opt/app/aai-resources/extJars/logback-access-1.1.7.jar:/opt/app/aai-resources/extJars/logback-core-1.1.7.jar:/opt/app/aai-resources/extJars/aai-core-${AAI_CORE_VERSION}.jar -server -XX:NewSize=512m -XX:MaxNewSize=512m -XX:SurvivorRatio=8 -XX:+DisableExplicitGC -verbose:gc -XX:+UseParNewGC -XX:+CMSParallelRemarkEnabled -XX:+CMSClassUnloadingEnabled -XX:+UseConcMarkSweepGC -XX:-UseBiasedLocking -XX:ParallelGCThreads=4 -XX:LargePageSizeInBytes=128m -XX:+PrintGCDetails -XX:+PrintGCTimeStamps -Dsun.net.inetaddr.ttl=180 -XX:+HeapDumpOnOutOfMemoryError -Dhttps.protocols=TLSv1.1,TLSv1.2 -DSOACLOUD_SERVICE_VERSION=1.0.1 -DAJSC_HOME=/opt/app/aai-resources/ -DAJSC_CONF_HOME=/opt/app/aai-resources/bundleconfig -DAJSC_SHARED_CONFIG=/opt/app/aai-resources/bundleconfig -DAFT_HOME=/opt/app/aai-resources -DAAI_CORE_VERSION=${AAI_CORE_VERSION} -Daai-core.version=${AAI_CORE_VERSION} -Dlogback.configurationFile=/opt/app/aai-resources/bundleconfig/etc/logback.xml -Xloggc:/opt/app/aai-resources/logs/ajsc-jetty/gc/graph-query_gc.log com.att.ajsc.runner.Runner context=/ port=8087 sslport=8447 diff --git a/aai-resources/src/main/resources/docker/init-chef.sh b/aai-resources/src/main/resources/docker/init-chef.sh new file mode 100644 index 0000000..112b0b3 --- /dev/null +++ b/aai-resources/src/main/resources/docker/init-chef.sh @@ -0,0 +1,32 @@ +#!/bin/bash + +### +# ============LICENSE_START======================================================= +# org.openecomp.aai +# ================================================================================ +# Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. +# ================================================================================ +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# ============LICENSE_END========================================================= +### + +############################################################################## +# Script to initialize the chef-repo branch and.chef +# +############################################################################## + +#echo "AAI_CHEF_ENV=${AAI_CHEF_ENV}" >> /etc/environment +#echo "AAI_CHEF_LOC=${AAI_CHEF_LOC}" >> /etc/environment +#touch /root/.bash_profile +chef-solo -c /var/chef/aai-data/chef-config/dev/.knife/solo.rb -j /var/chef/aai-config/cookbooks/runlist-app-server.json -E ${AAI_CHEF_ENV} + diff --git a/aai-resources/src/main/resources/schema/UebEventLogEntry.xsd b/aai-resources/src/main/resources/schema/UebEventLogEntry.xsd new file mode 100644 index 0000000..c679fd2 --- /dev/null +++ b/aai-resources/src/main/resources/schema/UebEventLogEntry.xsd @@ -0,0 +1,20 @@ + + + + + + + + + + + + + + + + + + + + diff --git a/aai-resources/src/main/runtime/context/__module.ajsc.namespace.name__#__module.ajsc.namespace.version__.context b/aai-resources/src/main/runtime/context/__module.ajsc.namespace.name__#__module.ajsc.namespace.version__.context new file mode 100644 index 0000000..8514196 --- /dev/null +++ b/aai-resources/src/main/runtime/context/__module.ajsc.namespace.name__#__module.ajsc.namespace.version__.context @@ -0,0 +1 @@ +{"context":{"contextClass":"ajsc.Context","contextId":"__module_ajsc_namespace_name__:__module_ajsc_namespace_version__","contextName":"__module_ajsc_namespace_name__","contextVersion":"__module_ajsc_namespace_version__","description":"__module_ajsc_namespace_name__ Context"}} \ No newline at end of file diff --git a/aai-resources/src/main/runtime/context/default#0.context b/aai-resources/src/main/runtime/context/default#0.context new file mode 100644 index 0000000..d1b5ab4 --- /dev/null +++ b/aai-resources/src/main/runtime/context/default#0.context @@ -0,0 +1 @@ +{"context":{"contextClass":"ajsc.Context","contextId":"default:0","contextName":"default","contextVersion":"0","description":"Default Context"}} \ No newline at end of file diff --git a/aai-resources/src/main/runtime/deploymentPackage/__module.ajsc.namespace.name__#__module.ajsc.namespace.version__.json b/aai-resources/src/main/runtime/deploymentPackage/__module.ajsc.namespace.name__#__module.ajsc.namespace.version__.json new file mode 100644 index 0000000..d0954cf --- /dev/null +++ b/aai-resources/src/main/runtime/deploymentPackage/__module.ajsc.namespace.name__#__module.ajsc.namespace.version__.json @@ -0,0 +1 @@ +{"deploymentPackage":{"Class":"ajsc.DeploymentPackage","Id":"__module.ajsc.namespace.name__:__module_ajsc_namespace_version__","namespace":"__module_ajsc_namespace_name__","namespaceVersion":"__module_ajsc_namespace_version__","description":"__module_ajsc_namespace_name__ __module_ajsc_namespace_version__ - default description","userId":"ajsc"}} \ No newline at end of file diff --git a/aai-resources/src/main/runtime/shiroRole/ajscadmin.json b/aai-resources/src/main/runtime/shiroRole/ajscadmin.json new file mode 100644 index 0000000..f5e981e --- /dev/null +++ b/aai-resources/src/main/runtime/shiroRole/ajscadmin.json @@ -0,0 +1 @@ +{"shiroRoleClass":"ajsc.auth.ShiroRole","shiroRoleId":"ajscadmin","name":"ajscadmin","permissions":"[ajscadmin:*, ajsc:*]"} \ No newline at end of file diff --git a/aai-resources/src/main/runtime/shiroRole/contextadmin#__module.ajsc.namespace.name__.json b/aai-resources/src/main/runtime/shiroRole/contextadmin#__module.ajsc.namespace.name__.json new file mode 100644 index 0000000..2dae9f5 --- /dev/null +++ b/aai-resources/src/main/runtime/shiroRole/contextadmin#__module.ajsc.namespace.name__.json @@ -0,0 +1 @@ +{"shiroRoleClass":"ajsc.auth.ShiroRole","shiroRoleId":"contextadmin:__module_ajsc_namespace_name__","name":"contextadmin:__module_ajsc_namespace_name__","permissions":"[]"} \ No newline at end of file diff --git a/aai-resources/src/main/runtime/shiroRole/contextadmin#default.json b/aai-resources/src/main/runtime/shiroRole/contextadmin#default.json new file mode 100644 index 0000000..5de814e --- /dev/null +++ b/aai-resources/src/main/runtime/shiroRole/contextadmin#default.json @@ -0,0 +1 @@ +{"shiroRoleClass":"ajsc.auth.ShiroRole","shiroRoleId":"contextadmin:default","name":"contextadmin:default","permissions":"[]"} \ No newline at end of file diff --git a/aai-resources/src/main/runtime/shiroUser/ajsc.json b/aai-resources/src/main/runtime/shiroUser/ajsc.json new file mode 100644 index 0000000..f4c7855 --- /dev/null +++ b/aai-resources/src/main/runtime/shiroUser/ajsc.json @@ -0,0 +1 @@ +{"shiroUserClass":"ajsc.auth.ShiroUser","shiroUserId":"ajsc","passwordHash":"9471697417008c880720ba54c6038791ad7e98f3b88136fe34f4d31a462dd27a","permissions":"[*:*]","username":"ajsc"} \ No newline at end of file diff --git a/aai-resources/src/main/runtime/shiroUserRole/ajsc#ajscadmin.json b/aai-resources/src/main/runtime/shiroUserRole/ajsc#ajscadmin.json new file mode 100644 index 0000000..cb8d483 --- /dev/null +++ b/aai-resources/src/main/runtime/shiroUserRole/ajsc#ajscadmin.json @@ -0,0 +1 @@ +{"shiroUserRoleClass":"ajsc.auth.ShiroUserRole","shiroUserRoleId":"ajsc:ajscadmin","roleId":"ajscadmin","userId":"ajsc"} \ No newline at end of file diff --git a/aai-resources/src/main/runtime/shiroUserRole/ajsc#contextadmin#__module.ajsc.namespace.name__.json b/aai-resources/src/main/runtime/shiroUserRole/ajsc#contextadmin#__module.ajsc.namespace.name__.json new file mode 100644 index 0000000..95d2361 --- /dev/null +++ b/aai-resources/src/main/runtime/shiroUserRole/ajsc#contextadmin#__module.ajsc.namespace.name__.json @@ -0,0 +1 @@ +{"shiroUserRoleClass":"ajsc.auth.ShiroUserRole","shiroUserRoleId":"ajsc:contextadmin:__module_ajsc_namespace_name__","roleId":"contextadmin:__module_ajsc_namespace_name__","userId":"ajsc"} \ No newline at end of file diff --git a/aai-resources/src/main/runtime/shiroUserRole/ajsc#contextadmin#default.json b/aai-resources/src/main/runtime/shiroUserRole/ajsc#contextadmin#default.json new file mode 100644 index 0000000..2bd5063 --- /dev/null +++ b/aai-resources/src/main/runtime/shiroUserRole/ajsc#contextadmin#default.json @@ -0,0 +1 @@ +{"shiroUserRoleClass":"ajsc.auth.ShiroUserRole","shiroUserRoleId":"ajsc:contextadmin:default","roleId":"contextadmin:default","userId":"ajsc"} \ No newline at end of file diff --git a/aai-resources/src/main/scripts/createDBSchema.sh b/aai-resources/src/main/scripts/createDBSchema.sh new file mode 100644 index 0000000..51668de --- /dev/null +++ b/aai-resources/src/main/scripts/createDBSchema.sh @@ -0,0 +1,52 @@ +#!/bin/ksh + +### +# ============LICENSE_START======================================================= +# org.openecomp.aai +# ================================================================================ +# Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. +# ================================================================================ +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# ============LICENSE_END========================================================= +### + +# +# The script invokes GenTester java class to create the DB schema +# +# NOTE: you can pass an option GEN_DB_WITH_NO_SCHEMA if you want it to create an instance of +# the graph - but with no schema (this is useful when using the Hbase copyTable to +# copy our database to different environments). +# Ie. createDbSchema.sh GEN_DB_WITH_NO_SCHEMA +# + +echo +echo `date` " Starting $0" + +. /etc/profile.d/aai.sh + + +for JAR in `ls $PROJECT_HOME/extJars/*.jar` +do + CLASSPATH=$CLASSPATH:$JAR +done + +for JAR in `ls $PROJECT_HOME/lib/*.jar` +do + CLASSPATH=$CLASSPATH:$JAR +done + +$JAVA_HOME/bin/java -classpath $CLASSPATH -Dhttps.protocols=TLSv1.1,TLSv1.2 -DAJSC_HOME=$PROJECT_HOME -Daai.home=$PROJECT_HOME \ + org.openecomp.aai.dbgen.GenTester $1 + +echo `date` " Done $0" +exit 0 diff --git a/aai-resources/src/main/scripts/install/updateQueryData.sh b/aai-resources/src/main/scripts/install/updateQueryData.sh new file mode 100644 index 0000000..e6e5de7 --- /dev/null +++ b/aai-resources/src/main/scripts/install/updateQueryData.sh @@ -0,0 +1,105 @@ +#!/bin/ksh + +### +# ============LICENSE_START======================================================= +# org.openecomp.aai +# ================================================================================ +# Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. +# ================================================================================ +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# ============LICENSE_END========================================================= +### + +PROGNAME=$(basename $0) +OUTFILE=$PROJECT_HOME/logs/misc/${PROGNAME}.log.$(date +\%Y-\%m-\%d) +#OUTFILE=/c/temp/${PROGNAME}.log.$(date +\%Y-\%m-\%d) + +TS=$(date "+%Y-%m-%d %H:%M:%S") + +CHECK_USER="aaiadmin" +userid=$( id | cut -f2 -d"(" | cut -f1 -d")" ) +if [ "${userid}" != $CHECK_USER ]; then + echo "You must be $CHECK_USER to run $0. The id used $userid." + exit 1 +fi + +error_exit () { + echo "${PROGNAME}: failed for ${1:-"Unknown error"} on cmd $2" 1>&2 + echo "${PROGNAME}: failed for ${1:-"Unknown error"} on cmd $2" >> $OUTFILE +# exit ${2:-"1"} +} + +j=0 +for filepath in `ls $PROJECT_HOME/bundleconfig/etc/scriptdata/widget-model-json/*.json|sort -f` +#for filepath in `ls /c/sources/aai/aaigitnew/bundleconfig-local/etc/scriptdata/widget-model-json/*.json|sort -f` +do +j=$(expr "$j" + 1) +filename=$(basename $filepath) +echo "Begin putTool for widget $filename" | tee -a $OUTFILE +vers=`grep model-invariant-id $filepath|cut -d':' -f2|cut -d'"' -f2` +# last parameter will skip put if it exists +resource=service-design-and-creation/models/model/$vers +$PROJECT_HOME/scripts/putTool.sh $resource $filepath 1 0 na 1 >> $OUTFILE 2>&1 || error_exit "$resource $filepath" $j +#/c/sources/aai/aaigitnew/src/main/scripts/putTool.sh $resource $filepath 1 0 na 1 >> $OUTFILE 2>&1 || error_exit "$resource $filepath" $j +echo "End putTool for widget $filename" | tee -a $OUTFILE +done + +j=0 +for filepath in `ls $PROJECT_HOME/bundleconfig/etc/scriptdata/named-query-json/*.json|sort -f` +#for filepath in `ls /c/sources/aai/aaigitnew/bundleconfig-local/etc/scriptdata/named-query-json/*.json|sort -f` +do +j=$(expr "$j" + 1) +filename=$(basename $filepath) +echo "Begin putTool for named-query $filename" | tee -a $OUTFILE +vers=`grep named-query-uuid $filepath|cut -d':' -f2|cut -d'"' -f2` +# last parameter will skip put if it exists +resource=service-design-and-creation/named-queries/named-query/$vers +$PROJECT_HOME/scripts/putTool.sh $resource $filepath 1 0 na 1 >> $OUTFILE 2>&1 || error_exit "$resource $filepath" $j +#/c/sources/aai/aaigitnew/src/main/scripts/putTool.sh $resource $filepath 1 0 na 1 >> $OUTFILE 2>&1 || error_exit "$resource $filepath" $j +echo "End putTool for named-query $filename" | tee -a $OUTFILE +done + +j=0 +for filepath in `ls $PROJECT_HOME/bundleconfig/etc/scriptdata/resource-model-json/*.json|sort -f` +#for filepath in `ls /c/sources/aai/aaigitnew/bundleconfig-local/etc/scriptdata/resource-model-json/*.json|sort -f` +do +j=$(expr "$j" + 1) +filename=$(basename $filepath) +echo "Begin putTool for resource model $filename" | tee -a $OUTFILE +vers=`grep model-invariant-id $filepath|cut -d':' -f2|cut -d'"' -f2` +# last parameter will skip put if it exists +resource=service-design-and-creation/models/model/$vers +$PROJECT_HOME/scripts/putTool.sh $resource $filepath 1 0 na 1 >> $OUTFILE 2>&1 || error_exit "$resource $filepath" $j +#/c/sources/aai/aaigitnew/src/main/scripts/putTool.sh $resource $filepath 1 0 na 1 >> $OUTFILE 2>&1 || error_exit "$resource $filepath" $j +echo "End putTool for resource model $filename" | tee -a $OUTFILE +done + +j=0 +for filepath in `ls $PROJECT_HOME/bundleconfig/etc/scriptdata/service-model-json/*.json|sort -f` +#for filepath in `ls /c/sources/aai/aaigitnew/bundleconfig-local/etc/scriptdata/service-model-json/*.json|sort -f` +do +j=$(expr "$j" + 1) +filename=$(basename $filepath) +echo "Begin putTool for service model $filename" | tee -a $OUTFILE +vers=`grep model-invariant-id $filepath|cut -d':' -f2|cut -d'"' -f2` +# last parameter will skip put if it exists +resource=service-design-and-creation/models/model/$vers +$PROJECT_HOME/scripts/putTool.sh $resource $filepath 1 0 na 1 >> $OUTFILE 2>&1 || error_exit "$resource $filepath" $j +#/c/sources/aai/aaigitnew/src/main/scripts/putTool.sh $resource $filepath 1 0 na 1 >> $OUTFILE 2>&1 || error_exit "$resource $filepath" $j +echo "End putTool for service model $filename" | tee -a $OUTFILE +done + +echo "$PROGNAME completed ${TS}" | tee -a $OUTFILE +echo "See output and error file: $OUTFILE" + +exit 0 diff --git a/aai-resources/src/main/xjb/bindings.xjb b/aai-resources/src/main/xjb/bindings.xjb new file mode 100644 index 0000000..12fbb6d --- /dev/null +++ b/aai-resources/src/main/xjb/bindings.xjb @@ -0,0 +1,46 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/aai-resources/src/test/java/org/openecomp/aai/query/builder/TraversalQueryTest.java b/aai-resources/src/test/java/org/openecomp/aai/query/builder/TraversalQueryTest.java new file mode 100644 index 0000000..694e99e --- /dev/null +++ b/aai-resources/src/test/java/org/openecomp/aai/query/builder/TraversalQueryTest.java @@ -0,0 +1,105 @@ +/*- + * ============LICENSE_START======================================================= + * org.openecomp.aai + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF 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.aai.query.builder; + +import static org.junit.Assert.assertEquals; + +import java.io.UnsupportedEncodingException; +import java.net.URI; +import java.net.URISyntaxException; + +import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversal; +import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource; +import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.__; +import org.apache.tinkerpop.gremlin.structure.Vertex; +import org.junit.BeforeClass; +import org.junit.Ignore; +import org.junit.Test; +import org.mockito.Mock; + +import org.openecomp.aai.db.props.AAIProperties; +import org.openecomp.aai.exceptions.AAIException; +import org.openecomp.aai.introspection.Introspector; +import org.openecomp.aai.introspection.Loader; +import org.openecomp.aai.introspection.LoaderFactory; +import org.openecomp.aai.introspection.ModelType; +//import org.openecomp.aai.serialization.queryformats.QueryFormatTestHelper; +import org.openecomp.aai.util.AAIConstants; + +public class TraversalQueryTest { + + public static Loader loader; + @Mock public GraphTraversalSource g; + @BeforeClass + public static void configure() throws NoSuchFieldException, SecurityException, Exception { + + System.setProperty("AJSC_HOME", "."); + System.setProperty("BUNDLECONFIG_DIR", "bundleconfig-local"); +// QueryFormatTestHelper.setFinalStatic(AAIConstants.class.getField("AAI_HOME_ETC_OXM"), "src/test/resources/org/openecomp/aai/introspection/"); + loader = LoaderFactory.createLoaderForVersion(ModelType.MOXY, AAIProperties.LATEST); + } + + @Test + public void unionQuery() { + TraversalQuery tQ = new TraversalQuery(loader, g); + TraversalQuery tQ2 = new TraversalQuery(loader, g); + TraversalQuery tQ3 = new TraversalQuery(loader, g); + tQ.union( + tQ2.getVerticesByProperty("test1", "value1"), + tQ3.getVerticesByIndexedProperty("test2", "value2")); + + GraphTraversal expected = __.start() + .union(__.has("test1", "value1"),__.has("test2", "value2")); + + assertEquals("they are equal", expected, tQ.getQuery()); + + } + + @Test + @Ignore + public void traversalClones() throws UnsupportedEncodingException, AAIException, URISyntaxException { + TraversalQuery tQ = new TraversalQuery(loader, g); + Introspector test = loader.introspectorFromName("test-object"); + QueryBuilder builder = tQ.createQueryFromURI(new URI("network/test-objects/test-object/key1")).getQueryBuilder(); + GraphTraversal expected = __.start().has("vnf-id", "key1").has("aai-node-type", "test-object"); + GraphTraversal containerExpected = __.start().has("aai-node-type", "test-object"); + + assertEquals("query object", expected.toString(), builder.getQuery().toString()); + assertEquals("container query object", containerExpected.toString(), builder.getContainerQuery().getQuery().toString()); + + } + + @Test + public void nestedTraversalClones() throws UnsupportedEncodingException, AAIException, URISyntaxException { + + TraversalQuery tQ = new TraversalQuery(loader, g); + QueryBuilder builder = tQ.createQueryFromURI(new URI("network/generic-vnfs/generic-vnf/key1/l-interfaces/l-interface/key2")).getQueryBuilder(); + GraphTraversal expected = __.start().has("vnf-id", "key1").has("aai-node-type", "generic-vnf").out("hasLInterface").has(AAIProperties.NODE_TYPE, "l-interface").has("interface-name", "key2"); + GraphTraversal containerExpected = __.start().has("vnf-id", "key1").has("aai-node-type", "generic-vnf").out("hasLInterface").has(AAIProperties.NODE_TYPE, "l-interface"); + + assertEquals("query object", expected.toString(), builder.getQuery().toString()); + assertEquals("container query object", containerExpected.toString(), builder.getContainerQuery().getQuery().toString()); + + } + + + +} diff --git a/aai-resources/src/test/java/org/openecomp/aai/rest/util/ValidateEncodingTest.java b/aai-resources/src/test/java/org/openecomp/aai/rest/util/ValidateEncodingTest.java new file mode 100644 index 0000000..8c6450d --- /dev/null +++ b/aai-resources/src/test/java/org/openecomp/aai/rest/util/ValidateEncodingTest.java @@ -0,0 +1,101 @@ +/*- + * ============LICENSE_START======================================================= + * org.openecomp.aai + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF 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.aai.rest.util; + +import static org.junit.Assert.*; + +import java.io.UnsupportedEncodingException; + +import javax.ws.rs.core.MultivaluedHashMap; +import javax.ws.rs.core.MultivaluedMap; +import javax.ws.rs.core.UriInfo; + +import org.junit.Test; +import org.mockito.Mockito; + +public class ValidateEncodingTest { + + + @Test + public void badPath() throws UnsupportedEncodingException { + String badPath = "/aai/v6/network/vces/vce/blahh::blach/others/other/jklfea{}"; + UriInfo mockUriInfo = getMockUriInfo(badPath, new MultivaluedHashMap()); + ValidateEncoding validator = ValidateEncoding.getInstance(); + + assertEquals(false, validator.validate(mockUriInfo)); + } + + @Test + public void goodPath() throws UnsupportedEncodingException { + String goodPath = "/aai/v6/network/vces/vce/blahh%3A%3Ablach/others/other/jklfea%7B%7D"; + UriInfo mockUriInfo = getMockUriInfo(goodPath, new MultivaluedHashMap()); + ValidateEncoding validator = ValidateEncoding.getInstance(); + + assertEquals(true, validator.validate(mockUriInfo)); + } + + @Test + public void badQueryParamsKey() throws UnsupportedEncodingException { + MultivaluedHashMap map = new MultivaluedHashMap(); + map.putSingle("blahblah", "test"); + map.putSingle("blahblah", "test2"); + map.putSingle("bad::bad", "test3"); + UriInfo mockUriInfo = getMockUriInfo("", map); + + ValidateEncoding validator = ValidateEncoding.getInstance(); + + assertEquals(false, validator.validate(mockUriInfo)); + + } + @Test + public void badQueryParamsValue() throws UnsupportedEncodingException { + MultivaluedHashMap map = new MultivaluedHashMap(); + map.putSingle("blahblah", "test"); + map.putSingle("blahblah", "test//:2"); + map.putSingle("badbad", "test3"); + UriInfo mockUriInfo = getMockUriInfo("", map); + + ValidateEncoding validator = ValidateEncoding.getInstance(); + + assertEquals(false, validator.validate(mockUriInfo)); + } + @Test + public void goodQueryParams() throws UnsupportedEncodingException { + MultivaluedHashMap map = new MultivaluedHashMap(); + map.putSingle("blahblah", "test"); + map.putSingle("blahblah", "test2"); + map.putSingle("badbad", "~test%2F%2F%3A3"); + UriInfo mockUriInfo = getMockUriInfo("", map); + + ValidateEncoding validator = ValidateEncoding.getInstance(); + + assertEquals(true, validator.validate(mockUriInfo)); + } + + private UriInfo getMockUriInfo(String path, MultivaluedMap map) { + UriInfo mockUriInfo = Mockito.mock(UriInfo.class); + Mockito.when(mockUriInfo.getPath(false)).thenReturn(path); + Mockito.when(mockUriInfo.getQueryParameters(false)).thenReturn(map); + + return mockUriInfo; + } + +} diff --git a/aai-resources/src/test/java/org/openecomp/aai/schema/db/AuditOXMTest.java b/aai-resources/src/test/java/org/openecomp/aai/schema/db/AuditOXMTest.java new file mode 100644 index 0000000..8188bdd --- /dev/null +++ b/aai-resources/src/test/java/org/openecomp/aai/schema/db/AuditOXMTest.java @@ -0,0 +1,94 @@ +/*- + * ============LICENSE_START======================================================= + * org.openecomp.aai + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF 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.aai.schema.db; + +import java.io.IOException; + +import org.codehaus.jackson.JsonGenerationException; +import org.codehaus.jackson.map.JsonMappingException; +import org.codehaus.jackson.map.ObjectMapper; +import org.junit.BeforeClass; +import org.junit.Ignore; +import org.junit.Test; + +import org.openecomp.aai.db.schema.AuditDoc; +import org.openecomp.aai.db.schema.AuditOXM; +import org.openecomp.aai.db.schema.Auditor; +import org.openecomp.aai.db.schema.AuditorFactory; +import org.openecomp.aai.introspection.Version; +import com.thinkaurelius.titan.core.TitanFactory; +import com.thinkaurelius.titan.core.TitanGraph; + +@Ignore("not ready for testing") +public class AuditOXMTest { + + /** + * Before. + */ + @BeforeClass + public static void before() { + System.setProperty("AJSC_HOME", "./src/test/resources/");; + System.setProperty("BUNDLECONFIG_DIR", "bundleconfig-local"); + + } + + + /** + * Gets the graph audit. + * + * @return the graph audit + * @throws JsonGenerationException the json generation exception + * @throws JsonMappingException the json mapping exception + * @throws IOException Signals that an I/O exception has occurred. + */ + @Test + public void getGraphAudit() throws JsonGenerationException, JsonMappingException, IOException { + TitanGraph graph = TitanFactory.open("bundleconfig-local/etc/appprops/aaiconfig.properties"); + Auditor a = AuditorFactory.getGraphAuditor(graph); + AuditDoc doc = a.getAuditDoc(); + + ObjectMapper mapper = new ObjectMapper(); + + String json = mapper.writerWithDefaultPrettyPrinter().writeValueAsString(doc); + System.out.println(json); + + } + + /** + * Gets the audit. + * + * @return the audit + * @throws JsonGenerationException the json generation exception + * @throws JsonMappingException the json mapping exception + * @throws IOException Signals that an I/O exception has occurred. + */ + @Test + public void getAudit() throws JsonGenerationException, JsonMappingException, IOException { + AuditOXM oxm = new AuditOXM(Version.v8); + + AuditDoc doc = oxm.getAuditDoc(); + + ObjectMapper mapper = new ObjectMapper(); + + String json = mapper.writerWithDefaultPrettyPrinter().writeValueAsString(doc); + System.out.println(json); + } +} diff --git a/aai-resources/src/test/java/org/openecomp/aai/schema/db/ManageSchemaTest.java b/aai-resources/src/test/java/org/openecomp/aai/schema/db/ManageSchemaTest.java new file mode 100644 index 0000000..9b7dd7c --- /dev/null +++ b/aai-resources/src/test/java/org/openecomp/aai/schema/db/ManageSchemaTest.java @@ -0,0 +1,120 @@ +/*- + * ============LICENSE_START======================================================= + * org.openecomp.aai + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF 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.aai.schema.db; + +import java.io.IOException; +import java.util.Set; + +import org.codehaus.jackson.JsonParseException; +import org.codehaus.jackson.map.JsonMappingException; +import org.codehaus.jackson.map.ObjectMapper; +import org.junit.Before; +import org.junit.BeforeClass; +import org.junit.Ignore; +import org.junit.Test; + +import org.openecomp.aai.db.schema.DBIndex; +import org.openecomp.aai.db.schema.ManageTitanSchema; +import com.thinkaurelius.titan.core.TitanFactory; +import com.thinkaurelius.titan.core.TitanGraph; +import com.thinkaurelius.titan.core.schema.TitanManagement; + +@Ignore("not ready yet") +public class ManageSchemaTest { + + private TitanGraph graph = null; + @BeforeClass + public static void before() { + System.setProperty("AJSC_HOME", "./src/test/resources/");; + System.setProperty("BUNDLECONFIG_DIR", "bundleconfig-local"); + + } + + @Before + public void beforeTest() { + //graph = TitanFactory.open("src/test/resources/inmemory_titan.properties"); + graph = TitanFactory.open("bundleconfig-local/etc/appprops/aaiconfig.properties"); + } + + /* + @Test + public void populateEmptyGraph() { + ManageTitanSchema schema = new ManageTitanSchema(graph); + schema.buildSchema(); + } + + @Test + public void modifyIndex() { + ManageTitanSchema schema = new ManageTitanSchema(graph); + schema.buildSchema(); + Vertex v = graph.addVertex(); + v.setProperty("aai-node-type", "pserver"); + v.setProperty("hostname", "test1"); + v.setProperty("internet-topology", "test2"); + graph.commit(); + DBIndex index = new DBIndex(); + index.setName("internet-topology"); + index.setUnique(false); + schema.updateIndex(index); + + } + */ + @Test + public void closeRunningInstances() { + + TitanManagement mgmt = graph.openManagement(); + Set instances = mgmt.getOpenInstances(); + + for (String instance : instances) { + + if (!instance.contains("(current)")) { + mgmt.forceCloseInstance(instance); + } + } + mgmt.commit(); + + graph.close(); + + } + @Test + public void addNewIndex() throws JsonParseException, JsonMappingException, IOException { + ObjectMapper mapper = new ObjectMapper(); + String content = " {\r\n" + + " \"name\" : \"equipment-name\",\r\n" + + " \"unique\" : false,\r\n" + + " \"properties\" : [ {\r\n" + + " \"name\" : \"equipment-name\",\r\n" + + " \"cardinality\" : \"SINGLE\",\r\n" + + " \"typeClass\" : \"java.lang.String\"\r\n" + + " } ]\r\n" + + " }"; + DBIndex index = mapper.readValue(content, DBIndex.class); + ManageTitanSchema schema = new ManageTitanSchema(graph); + TitanManagement mgmt = graph.openManagement(); + Set instances = mgmt.getOpenInstances(); + System.out.println(instances); + schema.updateIndex(index); + + graph.close(); + + } + +} diff --git a/aai-resources/src/test/java/org/openecomp/aai/util/AAIApiServerURLBaseTest.java b/aai-resources/src/test/java/org/openecomp/aai/util/AAIApiServerURLBaseTest.java new file mode 100644 index 0000000..394f636 --- /dev/null +++ b/aai-resources/src/test/java/org/openecomp/aai/util/AAIApiServerURLBaseTest.java @@ -0,0 +1,85 @@ +/*- + * ============LICENSE_START======================================================= + * org.openecomp.aai + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF 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.aai.util; + +import static org.junit.Assert.*; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import org.apache.cxf.message.Message; +import org.apache.cxf.message.MessageImpl; +import org.apache.cxf.phase.PhaseInterceptorChain; +import org.junit.Rule; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.powermock.core.classloader.annotations.PrepareForTest; +import static org.mockito.Mockito.*; +import org.powermock.api.mockito.PowerMockito; +import org.powermock.modules.agent.PowerMockAgent; +import org.powermock.modules.junit4.PowerMockRunner; +import org.powermock.modules.junit4.rule.PowerMockRule; + +@PrepareForTest({PhaseInterceptorChain.class, AAIConfig.class}) + +public class AAIApiServerURLBaseTest { + @Rule + public PowerMockRule rule = new PowerMockRule(); + + static { + PowerMockAgent.initializeIfNeeded(); + } + + /** + * Test get hostname. + * + * @throws Exception the exception + */ + @Test + public void testGetHostname() throws Exception { + PowerMockito.mockStatic(PhaseInterceptorChain.class); + Map > hm = new HashMap>(); + List host = new ArrayList(); + host.add("my-localhost"); + hm.put("host", host); + + Message outMessage = new MessageImpl(); + outMessage.put(Message.PROTOCOL_HEADERS, hm); + + when(PhaseInterceptorChain.getCurrentMessage()).thenReturn(outMessage); + assertEquals("https://my-localhost/aai/", AAIApiServerURLBase.get()); + } + + /** + * Test get with null hostname. + * + * @throws Exception the exception + */ + @Test + public void testGetWithNullHostname() throws Exception { + PowerMockito.mockStatic(AAIConfig.class); + String defaultHostname = "default-name"; + when(AAIConfig.get(AAIConstants.AAI_SERVER_URL_BASE)).thenReturn(defaultHostname); + assertEquals(defaultHostname, AAIApiServerURLBase.get()); + } +} diff --git a/aai-resources/src/test/java/org/openecomp/aai/util/AAIApiVersionTest.java b/aai-resources/src/test/java/org/openecomp/aai/util/AAIApiVersionTest.java new file mode 100644 index 0000000..f82fc5d --- /dev/null +++ b/aai-resources/src/test/java/org/openecomp/aai/util/AAIApiVersionTest.java @@ -0,0 +1,90 @@ +/*- + * ============LICENSE_START======================================================= + * org.openecomp.aai + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF 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.aai.util; + +import static org.junit.Assert.*; + +import org.apache.cxf.message.Message; +import org.apache.cxf.message.MessageImpl; +import org.apache.cxf.phase.PhaseInterceptorChain; +import org.junit.Rule; +import org.junit.Test; +import org.powermock.core.classloader.annotations.PrepareForTest; +import static org.mockito.Mockito.*; +import org.powermock.api.mockito.PowerMockito; +import org.powermock.modules.agent.PowerMockAgent; +import org.powermock.modules.junit4.rule.PowerMockRule; + +@PrepareForTest({PhaseInterceptorChain.class, AAIConfig.class}) + +public class AAIApiVersionTest { + @Rule + public PowerMockRule rule = new PowerMockRule(); + + static { PowerMockAgent.initializeIfNeeded();} + + /** + * Test get version. + * + * @throws Exception the exception + */ + @Test + public void testGetVersion() throws Exception { + PowerMockito.mockStatic(PhaseInterceptorChain.class); + Message outMessage = new MessageImpl(); + String msg = "/v2/"; + outMessage.put(Message.REQUEST_URI, msg); + when(PhaseInterceptorChain.getCurrentMessage()).thenReturn(outMessage); + assertEquals("v2", AAIApiVersion.get()); + } + + /** + * Test get with null version. + * + * @throws Exception the exception + */ + @Test + public void testGetWithNullVersion() throws Exception { + PowerMockito.mockStatic(AAIConfig.class); + String defaultURI = "default-v2"; + when(AAIConfig.get(AAIConstants.AAI_DEFAULT_API_VERSION_PROP, AAIConstants.AAI_DEFAULT_API_VERSION)).thenReturn(defaultURI); + assertEquals(defaultURI, AAIApiVersion.get()); + } + + /** + * Test incorrect version pattern. + * + * @throws Exception the exception + */ + @Test + public void testIncorrectVersionPattern() throws Exception { + PowerMockito.mockStatic(PhaseInterceptorChain.class); + PowerMockito.mockStatic(AAIConfig.class); + Message outMessage = new MessageImpl(); + String msg = "2.0.1"; + String defaultURI = "default-v2"; + outMessage.put(Message.REQUEST_URI, msg); + when(PhaseInterceptorChain.getCurrentMessage()).thenReturn(outMessage); + when(AAIConfig.get(AAIConstants.AAI_DEFAULT_API_VERSION_PROP, AAIConstants.AAI_DEFAULT_API_VERSION)).thenReturn(defaultURI); + assertEquals(defaultURI, AAIApiVersion.get()); + } + +} diff --git a/aai-resources/src/test/java/org/openecomp/aai/util/AAIAppServletContextListenerTest.java b/aai-resources/src/test/java/org/openecomp/aai/util/AAIAppServletContextListenerTest.java new file mode 100644 index 0000000..deafd5b --- /dev/null +++ b/aai-resources/src/test/java/org/openecomp/aai/util/AAIAppServletContextListenerTest.java @@ -0,0 +1,178 @@ +/*- + * ============LICENSE_START======================================================= + * org.openecomp.aai + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF 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.aai.util; + +import static org.junit.Assert.assertTrue; + +import java.util.ArrayList; +import java.util.List; + +import javax.servlet.ServletContextEvent; + +import org.junit.Before; +import org.junit.Ignore; +import org.junit.Rule; +import org.junit.Test; +import org.powermock.api.mockito.PowerMockito; +import org.powermock.core.classloader.annotations.PrepareForTest; +import org.powermock.modules.agent.PowerMockAgent; +import org.powermock.modules.junit4.rule.PowerMockRule; +import org.slf4j.LoggerFactory; + +import org.openecomp.aai.dbmap.AAIGraph; +import org.openecomp.aai.logging.ErrorLogHelper; + +import ch.qos.logback.classic.Level; +import ch.qos.logback.classic.Logger; +import ch.qos.logback.classic.PatternLayout; +import ch.qos.logback.classic.spi.ILoggingEvent; +import ch.qos.logback.core.AppenderBase; + +@PrepareForTest({AAIGraph.class, AAIConfig.class, ErrorLogHelper.class}) +public class AAIAppServletContextListenerTest { + + @Rule + public PowerMockRule rule = new PowerMockRule(); + + static { + PowerMockAgent.initializeIfNeeded(); + } + + private ServletContextEvent arg; + private AAIAppServletContextListener listener; + + /** + * Initialize. + */ + @Before + @PrepareForTest({AAIGraph.class, AAIConfig.class, ErrorLogHelper.class}) + public void initialize(){ + arg = PowerMockito.mock(ServletContextEvent.class); + PowerMockito.mockStatic(AAIGraph.class); + PowerMockito.mockStatic(AAIConfig.class); + PowerMockito.mockStatic(ErrorLogHelper.class); + + listener = new AAIAppServletContextListener(); + configureLog(); + } + + /** + * Test contextDestroyed. + */ + @Test + @Ignore + public void testContextDestroyed(){ + listener.contextDestroyed(arg); + assertTrue(logContains(Level.DEBUG, "AAI Server shutdown")); + assertTrue(logContains(Level.INFO, "AAI graph shutdown")); + } + + /** + * Test contextInitialized. + */ + @Test + @Ignore + public void testContextInitialized(){ + listener.contextInitialized(arg); + assertTrue(logContains(Level.DEBUG, "Loading aaiconfig.properties")); + assertTrue(logContains(Level.DEBUG, "Loading error.properties")); + assertTrue(logContains(Level.DEBUG, "Loading graph database")); + assertTrue(logContains(Level.INFO, "AAI Server initialization")); + } + + + /** + * Helper method to check if a String appears in the desired log level. + * + * @param level Log level to use + * @param expected String to search for + * @return True if search String is found, false otherwise + */ + private boolean logContains(Level level, String expected) { + String actual[] = RecordingAppender.messages(); + for (String log : actual) { + if (log.contains(level.toString()) && log.contains(expected)) + return true; + } + return false; + } + + /** + * Set logging level, and initialize log-appender. + */ + private void configureLog() { + Logger rootLogger = (Logger)LoggerFactory.getLogger(Logger.ROOT_LOGGER_NAME); + rootLogger.setLevel(Level.DEBUG); + rootLogger.detachAndStopAllAppenders(); + rootLogger.addAppender(RecordingAppender.appender(new PatternLayout())); + } + +} + + +/** + * Appender class that appends log messages to a String List when some logging event occurs + */ +class RecordingAppender extends AppenderBase { + private static List messages = new ArrayList(); + private static RecordingAppender appender = new RecordingAppender(); + private PatternLayout patternLayout; + + private RecordingAppender() { + super(); + } + + /** + * @param patternLayout Pattern to format log message + * @return Current appender + */ + public static RecordingAppender appender(PatternLayout patternLayout) { + appender.patternLayout = patternLayout; + appender.clear(); + return appender; + } + + @Override + protected void append(ILoggingEvent event) { + messages.add(patternLayout.doLayout(event)); + } + + public void close() {} + + public boolean requiresLayout() { + return false; + } + + /** + * @return Return logs as a String array + */ + public static String[] messages() { + return (String[]) messages.toArray(new String[messages.size()]); + } + + /** + * Clear the message container + */ + private void clear() { + messages.clear(); + } + +} diff --git a/aai-resources/src/test/java/org/openecomp/aai/util/AAICSVWriterTest.java b/aai-resources/src/test/java/org/openecomp/aai/util/AAICSVWriterTest.java new file mode 100644 index 0000000..c3e525c --- /dev/null +++ b/aai-resources/src/test/java/org/openecomp/aai/util/AAICSVWriterTest.java @@ -0,0 +1,177 @@ +/*- + * ============LICENSE_START======================================================= + * org.openecomp.aai + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF 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.aai.util; + +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.fail; + +import java.io.File; +import java.io.FileNotFoundException; +import java.io.FileWriter; +import java.io.IOException; +import java.io.PrintWriter; +import java.io.Writer; +import java.nio.file.Files; +import java.nio.file.Paths; + +import org.junit.After; +import org.junit.Before; +import org.junit.Rule; +import org.junit.Test; +import org.powermock.modules.agent.PowerMockAgent; +import org.powermock.modules.junit4.rule.PowerMockRule; + +public class AAICSVWriterTest { + + @Rule + public PowerMockRule rule = new PowerMockRule(); + + static { + PowerMockAgent.initializeIfNeeded(); + } + + + Writer writer; + File f; + AAICSVWriter testObj; + String fileName = "test_csvWriter.csv"; + String lineEnd = "\n"; + char quoteChar = '\"'; + String separator = ","; + String str1[], str2[]; + + /** + * Initialize. + */ + @Before + public void initialize(){ + str1 = new String[]{"s0", "s1"}; + + str2 = new String[]{"t0", "t1"}; + + try { + f = new File(fileName); + f.createNewFile(); + writer = new PrintWriter(f); + testObj = new AAICSVWriter(new FileWriter(fileName), separator, quoteChar, lineEnd); + } catch (FileNotFoundException e) { + fail("Input csv file not found."); + e.printStackTrace(); + } catch (IOException e) { + fail("Can't create csv file."); + e.printStackTrace(); + } + } + + /** + * Test writeNextLine with String arrays. + */ + @Test + public void testWriteNextLine(){ + populateAndGetFileSize(false, str1, str2); + String wholeText = str1[0] + separator + str1[1] + lineEnd + str2[0] + separator + str2[1] + lineEnd; + assertTrue("CSV file missing text", allLinesFound(wholeText)); + } + + /** + * Test writeNextLine with null. + */ + @Test + public void testWriteNextLine_withNull(){ + populateAndGetFileSize(false, null, null); + assertTrue("CSV file should not contain any text", f.length() == 0); + } + + + /** + * Test writeColumn with String arrays. + */ + @Test + public void testWriteColumn(){ + populateAndGetFileSize(true, str1, str2); + String wholeText = str1[0] + str1[1] + lineEnd + str2[0] + str2[1] + lineEnd; + assertTrue("CSV file missing text", allLinesFound(wholeText)); + } + + + /** + * Test writeColumn with null. + */ + @Test + public void testWriteColumn_withNull(){ + populateAndGetFileSize(true, null, null); + assertTrue("CSV file should not contain any text", f.length() == 0); + } + + /** + * Helper method to create file with given data. + * + * @param isColumnWise True if csv file is to be written in column wise, false otherwise + * @param c1 First set of data + * @param c2 Second set of data + */ + private void populateAndGetFileSize(boolean isColumnWise, String c1[], String c2[]){ + if ( isColumnWise ){ + testObj.writeColumn(c1); + testObj.writeColumn(c2); + } else{ + testObj.writeNext(c1, false); + testObj.writeNext(c2, false); + } + try { + testObj.close(); + } catch (IOException e) { + fail("Can't close stream"); + e.printStackTrace(); + } + } + + + /** + * Helper method to check if a file contains required data. + * + * @param all Data to look for + * @return True if data is found, false otherwise + */ + private boolean allLinesFound(String all){ + String fileContents = ""; + try { + fileContents = new String(Files.readAllBytes(Paths.get(fileName))); + } catch (IOException e1) { + fail("csv file not found"); + e1.printStackTrace(); + } + + return all.equals(fileContents); + } + + + /** + * Cleanup. + */ + @After + public void cleanup(){ + if ( f.exists() ){ + f.delete(); + } + } + +} diff --git a/aai-resources/src/test/java/org/openecomp/aai/util/AAIConfigPasswordDecodingTest.java b/aai-resources/src/test/java/org/openecomp/aai/util/AAIConfigPasswordDecodingTest.java new file mode 100644 index 0000000..bdf0fb1 --- /dev/null +++ b/aai-resources/src/test/java/org/openecomp/aai/util/AAIConfigPasswordDecodingTest.java @@ -0,0 +1,53 @@ +/*- + * ============LICENSE_START======================================================= + * org.openecomp.aai + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF 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.aai.util; + +import static org.junit.Assert.assertEquals; + +import org.junit.BeforeClass; +import org.junit.Test; + +import org.openecomp.aai.exceptions.AAIException; + +public class AAIConfigPasswordDecodingTest { + + /** + * Configure. + * + * @throws AAIException the AAI exception + */ + @BeforeClass + public static void configure() throws AAIException { + System.setProperty("AJSC_HOME", "./src/test/resources/"); + System.setProperty("BUNDLECONFIG_DIR", "bundleconfig-local");; //fake prop file for testing + } + + /** + * Password check. + * + * @throws AAIException the AAI exception + */ + @Test + public void passwordCheck() throws AAIException { + assertEquals("password", "aaiuser123", AAIConfig.get("ecm.auth.password")); + } + +} diff --git a/aai-resources/src/test/java/org/openecomp/aai/util/AAIRSyncUtilityTest.java b/aai-resources/src/test/java/org/openecomp/aai/util/AAIRSyncUtilityTest.java new file mode 100644 index 0000000..c15a99f --- /dev/null +++ b/aai-resources/src/test/java/org/openecomp/aai/util/AAIRSyncUtilityTest.java @@ -0,0 +1,221 @@ +/*- + * ============LICENSE_START======================================================= + * org.openecomp.aai + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF 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.aai.util; + + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.fail; + +import java.io.File; +import java.lang.reflect.Field; +import java.lang.reflect.InvocationTargetException; +import java.lang.reflect.Method; +import java.lang.reflect.Modifier; +import java.net.InetAddress; +import java.net.UnknownHostException; +import java.nio.file.Files; +import java.util.ArrayList; +import java.util.List; +import java.util.StringTokenizer; +import java.util.UUID; + +import org.junit.Before; +import org.junit.BeforeClass; +import org.junit.Ignore; +import org.junit.Test; +import org.openecomp.aai.exceptions.AAIException; + +@Ignore +public class AAIRSyncUtilityTest { + + AAIRSyncUtility syncUtil; + AAIRSyncUtility syncUtilOmitDoCommand; + AAIConfig aaiConfig; + String hostName; + String transId = UUID.randomUUID().toString(); + + @BeforeClass + public static void configure() throws AAIException { + System.setProperty("AJSC_HOME", "./src/test/resources/"); + System.setProperty("BUNDLECONFIG_DIR", "bundleconfig-local");; //fake prop file for testing + } + + /** + * Initialize. + */ + @Before + public void initialize(){ + syncUtil = new AAIRSyncUtility(); + + syncUtilOmitDoCommand = new AAIRSyncUtility(){ + /** + * {@inheritDoc} + */ + @Override + public int doCommand(List command) throws Exception + { + return 1; + } + }; + + partialSetupForAAIConfig(); + + InetAddress ip = null; + try { + ip = InetAddress.getLocalHost(); + } catch (UnknownHostException e2) { + e2.printStackTrace(); + } + hostName = ip.getHostName(); + } + + + /** + * Test sendRsync. + */ + @Test + public void testSendRsyncCommand(){ + syncUtilOmitDoCommand.sendRsyncCommand(transId, "RandomFileName"); + //TODO write codes to check what is being logged + } + + /** + * Test getHost. + */ + @Test + public void testGetHost(){ + + String returnedHost = null; + Method getHostMethod = makePublic("getHost"); + try { + returnedHost = (String)getHostMethod.invoke(syncUtil, null); + } catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException e) { + e.printStackTrace(); + } + + assertEquals("Host name didn't match", returnedHost, hostName); + } + + /** + * Test getRemoteHostList. + */ + @Test + public void testGetRemoteHostList(){ + String localHost = "host_local"; + String remoteHost1 = "hostR1"; + String remoteHost2 = "hostR2"; + ArrayList remotes = new ArrayList(); + remotes.add(remoteHost1); + remotes.add(remoteHost2); + + StringTokenizer stTokenizer = new StringTokenizer(remoteHost1+"\r"+remoteHost2+"\r"+localHost); + + Method m = makePublic("getRemoteHostList"); + try { + assertEquals("Remote host missing", remotes, m.invoke(syncUtil, stTokenizer, localHost)); + } catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException e) { + e.printStackTrace(); + } + } + + /** + * Test doCommand. + */ + @Test + public void testDoCommand(){ + + assertTrue("Don't have execute permissions", Files.isExecutable(new File(".").toPath())); + + List commands = new ArrayList(); + commands.add("ping"); + commands.add("google.com"); + try { + assertEquals("Failed to execute commands", 1, syncUtilOmitDoCommand.doCommand(commands)); + } catch (Exception e) { + fail("Failed to execute a command"); + e.printStackTrace(); + } + + } + + /** + * Test doCommand with null. + */ + @Test + public void testDoCommand_withNull(){ + assertTrue("Don't have execute permissions", Files.isExecutable(new File(".").toPath())); + try { + assertEquals("This should be unreachable", 1, syncUtil.doCommand(null)); + } catch (Exception e) { + assertTrue("Expecting an NPE from ProcessBuilder", e instanceof NullPointerException); + } + + } + + + /** + * Helper method to covert access type of a method from private to public . + * + * @param privateMethodName Method which is private originally + * @return method object with 'access type = 'public' + */ + public Method makePublic(String privateMethodName){ + Method targetMethod = null; + try { + if (privateMethodName.equals("getHost")) + targetMethod = AAIRSyncUtility.class.getDeclaredMethod(privateMethodName, null); + else if (privateMethodName.equals("getRemoteHostList")) + targetMethod = AAIRSyncUtility.class.getDeclaredMethod(privateMethodName, StringTokenizer.class, String.class); + } catch (NoSuchMethodException | SecurityException e) { + e.printStackTrace(); + } + targetMethod.setAccessible(true); + return targetMethod; + } + + /** + * Helper method to load aai config from test configuration file + * This requires that the 'test_aaiconfig.properties' file is available + */ + static void setFinalStatic(Field field, Object newValue) throws Exception { + field.setAccessible(true); + Field modifiersField = Field.class.getDeclaredField("modifiers"); + modifiersField.setAccessible(true); + modifiersField.setInt(field, field.getModifiers() & ~Modifier.FINAL); + field.set(null, newValue); + } + + /** + * Helper method to setup AAIConfig for test. + */ + public void partialSetupForAAIConfig(){ + try { + setFinalStatic(AAIConfig.class.getDeclaredField("GlobalPropFileName"), "src/test/resources/bundleconfig-local/etc/appprops/aaiconfig.properties"); + } + catch (SecurityException e) {fail();} + catch (NoSuchFieldException e) {fail();} + catch (Exception e) {fail();} + + AAIConfig.reloadConfig(); + } + +} diff --git a/aai-resources/src/test/java/org/openecomp/aai/util/AAIUtilsTest.java b/aai-resources/src/test/java/org/openecomp/aai/util/AAIUtilsTest.java new file mode 100644 index 0000000..0bba892 --- /dev/null +++ b/aai-resources/src/test/java/org/openecomp/aai/util/AAIUtilsTest.java @@ -0,0 +1,112 @@ +/*- + * ============LICENSE_START======================================================= + * org.openecomp.aai + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF 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.aai.util; + +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.fail; + +import java.text.DateFormat; +import java.text.ParseException; +import java.text.SimpleDateFormat; +import java.util.ArrayList; +import java.util.Date; +import java.util.List; +import java.util.TimeZone; +import java.util.concurrent.TimeUnit; + +import org.junit.Before; +import org.junit.Rule; +import org.junit.Test; +import org.powermock.modules.agent.PowerMockAgent; +import org.powermock.modules.junit4.rule.PowerMockRule; + +public class AAIUtilsTest { + + @Rule + public PowerMockRule rule = new PowerMockRule(); + + static { + PowerMockAgent.initializeIfNeeded(); + } + + + AAIUtils testObj; + + /** + * Initialize. + */ + @Before + public void initialize(){ + testObj = new AAIUtils(); + } + + /** + * Test nullCheck with null. + */ + @Test + public void testNullCheck_withNull(){ + List newList = null; + assertNotNull("method nullCheck should not return null", AAIUtils.nullCheck(newList)); + } + + /** + * Test nullCheck with a List. + */ + @Test + public void testNullCheck_withList(){ + List newList = new ArrayList(); + newList.add("testString"); + assertNotNull("method nullCheck failed for a List", AAIUtils.nullCheck(newList)); + } + + /** + * Test genDate using a past and a future date. + */ + @Test + public void testGenDate(){ + + Date d1 = new Date(0); + + DateFormat formatter = new SimpleDateFormat("YYMMdd-HH:mm:ss:SSS"); + formatter.setTimeZone(TimeZone.getTimeZone("GMT")); + formatter.setLenient(false); + + Date d2 = null; + + try { + d2 = formatter.parse(AAIUtils.genDate()); + } catch (ParseException e) { + fail("Date parsing exception"); + e.printStackTrace(); + } + + try { + TimeUnit.SECONDS.sleep(1); + } catch (InterruptedException e1) {} + + Date d3 = new Date(); + + assertTrue("Generated date is not after a past date", d2.after(d1)); + assertTrue("Generated date is not before a future date", d2.before(d3)); + } + +} diff --git a/aai-resources/src/test/java/org/openecomp/aai/util/CNNameTest.java b/aai-resources/src/test/java/org/openecomp/aai/util/CNNameTest.java new file mode 100644 index 0000000..8f3cfa5 --- /dev/null +++ b/aai-resources/src/test/java/org/openecomp/aai/util/CNNameTest.java @@ -0,0 +1,138 @@ +/*- + * ============LICENSE_START======================================================= + * org.openecomp.aai + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF 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.aai.util; + +import static org.junit.Assert.assertTrue; +import static org.mockito.Mockito.when; + +import java.security.cert.X509Certificate; + +import javax.security.auth.x500.X500Principal; +import javax.servlet.http.HttpServletRequest; + +import org.junit.Before; +import org.junit.Rule; +import org.junit.Test; +import org.mockito.Mockito; +import org.powermock.core.classloader.annotations.PowerMockIgnore; +import org.powermock.core.classloader.annotations.PrepareForTest; +import org.powermock.modules.agent.PowerMockAgent; +import org.powermock.modules.junit4.rule.PowerMockRule; + +import ch.qos.logback.access.spi.IAccessEvent; + +@PowerMockIgnore("javax.security.auth.x500.X500Principal") +@PrepareForTest({IAccessEvent.class, HttpServletRequest.class, X509Certificate.class}) +public class CNNameTest { + + @Rule + public PowerMockRule rule = new PowerMockRule(); + + static { + PowerMockAgent.initializeIfNeeded(); + } + + + IAccessEvent mockAccEvent; + HttpServletRequest mockHttpServletRequest; + org.openecomp.aai.logging.CNName cnname; + X509Certificate cert; + + /** + * Initialize. + */ + @Before + public void initialize(){ + mockAccEvent = Mockito.mock(IAccessEvent.class); + mockHttpServletRequest = Mockito.mock(HttpServletRequest.class); + cert = Mockito.mock(X509Certificate.class); + } + + + /** + * Test 'convert' when there is no AccessConverter. + */ + @Test + public void testConvert_withoutAccessConverter(){ + cnname = getTestObj(false); + assertTrue("Conversion failed with no AccessConverter", "INACTIVE_HEADER_CONV".equals(cnname.convert(mockAccEvent))); + } + + /** + * Test 'convert' with no CipherSuite. + */ + @Test + public void testConvert_withNullCipherSuite(){ + setupForCipherSuite(null); + assertTrue("Conversion failed for a null CipherSuite", "-".equals(cnname.convert(mockAccEvent))); + } + + + /** + * Test 'convert' with a non-null CipherSuite. + */ + @Test + public void testConvert_withNotNullCipherSuite(){ + + setupForCipherSuite("StrRepOfAValidSuite"); + + final X500Principal principal = new X500Principal("CN=AnAI, OU=DOX, O=BWS, C=CA"); + + Mockito.when(cert.getSubjectX500Principal()).thenReturn(principal); + + final X509Certificate[] certChain = {cert}; + + when(mockHttpServletRequest.getAttribute("javax.servlet.request.X509Certificate")).thenReturn(certChain); + + assertTrue("Conversion failed for a valid CipherSuite", principal.toString().equals(cnname.convert(mockAccEvent))); + } + + + /** + * Helper method to mock IAccessEvent and HttpServletRequest. + * + * @param suite CipherSuite to be used in current test + */ + private void setupForCipherSuite(String suite){ + cnname = getTestObj(true); + when(mockAccEvent.getRequest()).thenReturn(mockHttpServletRequest); + when(mockHttpServletRequest.getAttribute("javax.servlet.request.cipher_suite")).thenReturn(suite); + } + + + /** + * Helper method to create a CNName object with overridden 'start status' . + * + * @param instanceStarted Start status to be used + * @return CNName object to test + */ + private org.openecomp.aai.logging.CNName getTestObj(final boolean instanceStarted){ + return new org.openecomp.aai.logging.CNName(){ + @Override + public boolean isStarted(){ + return instanceStarted; + } + }; + } +} + + + diff --git a/aai-resources/src/test/java/org/openecomp/aai/util/CustomLogPatternLayoutTest.java b/aai-resources/src/test/java/org/openecomp/aai/util/CustomLogPatternLayoutTest.java new file mode 100644 index 0000000..e087108 --- /dev/null +++ b/aai-resources/src/test/java/org/openecomp/aai/util/CustomLogPatternLayoutTest.java @@ -0,0 +1,51 @@ +/*- + * ============LICENSE_START======================================================= + * org.openecomp.aai + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF 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.aai.util; + +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; + +import org.openecomp.aai.logging.CNName; +import org.openecomp.aai.logging.CustomLogPatternLayout; +import org.junit.Test; + +public class CustomLogPatternLayoutTest { + + /** + * Test null when defaultConverterMap doesn't have corresponding entry. + */ + @Test + public void testNull(){ + String s = CustomLogPatternLayout.defaultConverterMap.get("z"); + assertFalse("Entry not found for key 'z'", CNName.class.getName().equals(s)); + } + + /** + * Test defaultConverterMap when valid entry exists. + */ + @Test + public void testEntryFor_Z(){ + CustomLogPatternLayout layout = new CustomLogPatternLayout(); + String s = CustomLogPatternLayout.defaultConverterMap.get("z"); + assertTrue("Entry not found for key 'z'", org.openecomp.aai.logging.CNName.class.getName().equals(s)); + } + +} diff --git a/aai-resources/src/test/java/org/openecomp/aai/util/DbTestConfig.java b/aai-resources/src/test/java/org/openecomp/aai/util/DbTestConfig.java new file mode 100644 index 0000000..4f84519 --- /dev/null +++ b/aai-resources/src/test/java/org/openecomp/aai/util/DbTestConfig.java @@ -0,0 +1,303 @@ +/*- + * ============LICENSE_START======================================================= + * org.openecomp.aai + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF 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.aai.util; + +import java.util.Date; +import java.util.Enumeration; +import java.util.Properties; +import java.util.TimerTask; +import java.io.File; +import java.io.FileNotFoundException; +import java.io.InputStream; +import java.io.FileInputStream; +import java.io.IOException; +import java.util.Timer; +import java.net.InetAddress; + +public class DbTestConfig { + + public static final String AUDIT_FILESEP = (System.getProperty("file.separator") == null) ? "/" : System.getProperty("file.separator"); + public static final String AUDIT_HOME = (System.getProperty("audit.home") == null) ? AUDIT_FILESEP + "opt" + AUDIT_FILESEP + "audit" : System.getProperty("audit.home"); + public static final String AuditPropFilename = "c:\\tmp\\auditConfig.prop"; + public static final String AUDIT_CONFIG_CHECKINGTIME = "audit.config.checktime"; + public static final String AUDIT_NODENAME = "localhost"; + public static final String AUDIT_DEBUG = "audit.config.debug"; + + private static Properties serverProps; + private static boolean propsInitialized = false; + private static boolean timerSet = false; + private static Timer timer = null; + + private static String propFile = null; + + /** + * Inits the. + * + * @param propertyFile the property file + */ + public synchronized static void init(String propertyFile) { + propFile = propertyFile; + init(); + } + + /** + * Inits the. + */ + public synchronized static void init() { + System.out.println("Initializing Config"); + + DbTestConfig.getConfigFile(); + DbTestConfig.reloadConfig(); + + if ( propFile == null) + propFile = AuditPropFilename; + TimerTask task = null; + task = new DbTestFileWatcher ( new File(propFile)) { + protected void onChange( File file ) { + // here we implement the onChange + DbTestConfig.reloadConfig(); + } + }; + + if (!timerSet) { + timerSet = true; + // repeat the check every second + timer = new Timer(); + String fwi = DbTestConfig.get(AUDIT_CONFIG_CHECKINGTIME); + timer.schedule( task , new Date(), Integer.parseInt(fwi) ); + System.out.println("Config Watcher Interval=" + fwi); + + System.out.println("File" + propFile+" Loaded!"); + } + + } + + /** + * Cleanup. + */ + public static void cleanup() { + timer.cancel(); + } + + /** + * Gets the config file. + * + * @return the config file + */ + public static String getConfigFile() { + return propFile; + } + + /** + * Reload config. + */ + public synchronized static void reloadConfig() { + + String propFileName = propFile; + + Properties newServerProps = null; + + System.out.println("Reloading config from "+propFileName); + + try { + InputStream is = new FileInputStream(propFileName); + newServerProps = new Properties(); + newServerProps.load(is); + propsInitialized = true; + + serverProps = newServerProps; + if (get(AUDIT_DEBUG).equals("on")) { + serverProps.list(System.out); + } + newServerProps = null; + + } catch (FileNotFoundException fnfe) { + System.out.println("AuditConfig: " + propFileName + ". FileNotFoundException: "+fnfe.getMessage()); + } catch (IOException e) { + System.out.println("AuditConfig: " + propFileName + ". IOException: "+e.getMessage()); + } + } + + /** + * Gets the. + * + * @param key the key + * @param defaultValue the default value + * @return the string + */ + public static String get(String key, String defaultValue) { + String result = defaultValue; + try { + result = get (key); + } + catch ( Exception a ) { + } + return result; + } + + /** + * Gets the. + * + * @param key the key + * @return the string + */ + public static String get(String key) { + String response = null; + + if (key.equals(AUDIT_NODENAME)) { + // Get this from InetAddress rather than the properties file + String nodeName = getNodeName(); + if (nodeName != null) { + return nodeName; + } + // else get from property file + } + + if (!propsInitialized || (serverProps == null)) { + reloadConfig(); + } + if (!serverProps.containsKey(key)) { + System.out.println( "Property key "+key+" cannot be found"); + } else { + response = serverProps.getProperty(key); + if (response == null || response.isEmpty()) { + System.out.println("Property key "+key+" is null or empty"); + } + } + return response; + } + + /** + * Gets the int. + * + * @param key the key + * @return the int + */ + public static int getInt(String key) { + return Integer.valueOf(DbTestConfig.get(key)); + } + + /** + * Gets the server props. + * + * @return the server props + */ + public static Properties getServerProps() { + return serverProps; + } + + /** + * Gets the node name. + * + * @return the node name + */ + public static String getNodeName() { + try { + InetAddress ip = InetAddress.getLocalHost(); + if (ip != null) { + String hostname = ip.getHostName(); + if (hostname != null) { + return hostname; + } + } + } catch (Exception e) { + return null; + } + return null; + } + + /** + * Extracts a specific property key subset from the known properties. + * The prefix may be removed from the keys in the resulting dictionary, + * or it may be kept. In the latter case, exact matches on the prefix + * will also be copied into the resulting dictionary. + * + * @param prefix is the key prefix to filter the properties by. + * @param keepPrefix if true, the key prefix is kept in the resulting + * dictionary. As side-effect, a key that matches the prefix exactly + * will also be copied. If false, the resulting dictionary's keys are + * shortened by the prefix. An exact prefix match will not be copied, + * as it would result in an empty string key. + * @return a property dictionary matching the filter key. May be + * an empty dictionary, if no prefix matches were found. + * + * @see #getProperty( String ) is used to assemble matches + */ + public static Properties matchingSubset(String prefix, boolean keepPrefix) { + Properties result = new Properties(); + + // sanity check + if (prefix == null || prefix.length() == 0) { + return result; + } + + String prefixMatch; // match prefix strings with this + String prefixSelf; // match self with this + if (prefix.charAt(prefix.length() - 1) != '.') { + // prefix does not end in a dot + prefixSelf = prefix; + prefixMatch = prefix + '.'; + } else { + // prefix does end in one dot, remove for exact matches + prefixSelf = prefix.substring(0, prefix.length() - 1); + prefixMatch = prefix; + } + // POSTCONDITION: prefixMatch and prefixSelf are initialized! + + // now add all matches into the resulting properties. + // Remark 1: #propertyNames() will contain the System properties! + // Remark 2: We need to give priority to System properties. This is done + // automatically by calling this class's getProperty method. + String key; + for (Enumeration e = serverProps.keys(); e.hasMoreElements(); ) { + key = (String) e.nextElement(); + + if (keepPrefix) { + // keep full prefix in result, also copy direct matches + if (key.startsWith(prefixMatch) || key.equals(prefixSelf)) { + result.setProperty(key, serverProps.getProperty(key)); + } + } else { + // remove full prefix in result, dont copy direct matches + if (key.startsWith(prefixMatch)) { + result.setProperty(key.substring(prefixMatch.length()), serverProps.getProperty(key)); + } + } + } + + // done + return result; + } + + + + /** + * The main method. + * + * @param args the arguments + */ + public static void main(String[] args) { + // TODO Auto-generated method stub + DbTestConfig.init( ); + + } + +} diff --git a/aai-resources/src/test/java/org/openecomp/aai/util/DbTestFileWatcher.java b/aai-resources/src/test/java/org/openecomp/aai/util/DbTestFileWatcher.java new file mode 100644 index 0000000..05a4cfe --- /dev/null +++ b/aai-resources/src/test/java/org/openecomp/aai/util/DbTestFileWatcher.java @@ -0,0 +1,64 @@ +/*- + * ============LICENSE_START======================================================= + * org.openecomp.aai + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF 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.aai.util; + +import java.util.*; +import java.io.*; + +public abstract class DbTestFileWatcher extends TimerTask { + private long timeStamp; + private File file; + + /** + * Instantiates a new db test file watcher. + * + * @param file the file + */ + public DbTestFileWatcher( File file ) { + this.file = file; + this.timeStamp = file.lastModified(); + } + + /** + * {@inheritDoc} + */ + public final void run() { + long timeStamp = file.lastModified(); + + if( (timeStamp - this.timeStamp) > 500 ) { + this.timeStamp = timeStamp; + onChange(file); + } + try { + Thread.sleep(1000); + } catch (InterruptedException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + + /** + * On change. + * + * @param file the file + */ + protected abstract void onChange( File file ); +} diff --git a/aai-resources/src/test/java/org/openecomp/aai/util/DbTestGetFileTime.java b/aai-resources/src/test/java/org/openecomp/aai/util/DbTestGetFileTime.java new file mode 100644 index 0000000..d56a4d2 --- /dev/null +++ b/aai-resources/src/test/java/org/openecomp/aai/util/DbTestGetFileTime.java @@ -0,0 +1,55 @@ +/*- + * ============LICENSE_START======================================================= + * org.openecomp.aai + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF 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.aai.util; + +import java.io.File; +import java.io.IOException; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; +import java.nio.file.attribute.BasicFileAttributeView; +import java.nio.file.attribute.BasicFileAttributes; +import java.nio.file.attribute.FileTime; + +public class DbTestGetFileTime { + + + /** + * Creates the file return time. + * + * @param path the path + * @return the file time + * @throws IOException Signals that an I/O exception has occurred. + */ + public FileTime createFileReturnTime( String path) throws IOException { + File file = new File(path); + if(!file.exists()) { + file.createNewFile(); + } + Path p = Paths.get(file.getAbsolutePath()); + BasicFileAttributes view + = Files.getFileAttributeView(p, BasicFileAttributeView.class) + .readAttributes(); + FileTime fileTime=view.creationTime(); + // also available view.lastAccessTine and view.lastModifiedTime + return fileTime; + } +} diff --git a/aai-resources/src/test/java/org/openecomp/aai/util/DbTestProcessBuilder.java b/aai-resources/src/test/java/org/openecomp/aai/util/DbTestProcessBuilder.java new file mode 100644 index 0000000..8d8ebe0 --- /dev/null +++ b/aai-resources/src/test/java/org/openecomp/aai/util/DbTestProcessBuilder.java @@ -0,0 +1,218 @@ +/*- + * ============LICENSE_START======================================================= + * org.openecomp.aai + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF 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.aai.util; + +import java.io.BufferedReader; +import java.io.File; +import java.io.IOException; +import java.io.InputStream; +import java.io.InputStreamReader; +import java.nio.file.attribute.FileTime; +import java.text.SimpleDateFormat; +import java.util.Arrays; +import java.util.List; +import java.util.concurrent.Executors; +import java.util.concurrent.ScheduledExecutorService; +import java.util.concurrent.ScheduledFuture; +import java.util.concurrent.TimeUnit; + +public class DbTestProcessBuilder { + ///public static Logger clog = Logger.getLogger("auditConsole"); + //public static Logger alog = Logger.getLogger("auditLog"); + + /** + * Start audit process non blocking. + * + * @param wait the wait + * @param cmds the cmds + * @param dir the dir + */ + public void startAuditProcessNonBlocking(final long wait, final String cmds[], final String dir) { + + final ProcessBuilder pb = new ProcessBuilder(cmds).redirectErrorStream(true).directory(new File(dir)); + + new Thread(new Runnable() { + public void run() { + try { + //System.out.println( "sleeping seconds " + wait + " cmds " + Arrays.toString(cmds)); + Thread.sleep(wait*1000); + //System.out.println( "returned from sleep"); + final Process p = pb.start(); + //System.out.println( "returned from pb.start"); + final InputStream is = p.getInputStream(); + final BufferedReader stdError = new BufferedReader(new InputStreamReader(p.getErrorStream())); + final InputStreamReader isr = new InputStreamReader(is); + final BufferedReader br = new BufferedReader(isr); +//clog.debug("Output of running " + Arrays.toString(cmds) + " is:"); + System.out.println("Output of running is:" ); + String line; + while ((line = br.readLine()) != null ) { + System.out.println(line); + } + System.out.println("stderr of running is:" ); + + while ((line = stdError.readLine()) != null ) { + System.out.println(line); + } + + } catch (IOException ie) { + + } catch (InterruptedException itre) { + Thread.currentThread().interrupt(); + } + } + }).start(); + + } + + + private final ScheduledExecutorService auditProcessScheduler = + Executors.newScheduledThreadPool(10); + + /** + * Run W command every X seconds for Y minutes. + * + * @param w the w + * @param x the x + * @param y the y + * @param runningDir the running dir + */ + public void runWCommandEveryXSecondsForYMinutes(String[] w, int x, int y, final String runningDir) { + final String[] c1 = w; + final Runnable audit = new Runnable() { + public void run() { +//clog.debug("checkpoint "+(new Date()).toString()); + DbTestProcessBuilder a1 = new DbTestProcessBuilder(); + a1.startAuditProcessNonBlocking(1, c1, "/tmp"); + } + }; + + final ScheduledFuture auditHandle = + auditProcessScheduler.scheduleAtFixedRate(audit, 0, x, TimeUnit.SECONDS); + auditProcessScheduler.schedule(new Runnable() { + public void run() { + auditHandle.cancel(true); + } + }, y * 60, TimeUnit.SECONDS); + } + + + /** + * The main method. + * + * @param args the arguments + */ + @SuppressWarnings({ "null", "static-access" }) + public static void main(String args[]) { + String props = "NA"; + if (args.length > 0) { + System.out.println( "DbTestProcessBuilder called with " + args.length + " arguments, " + args[0]); + props = args[0].trim(); + } else { + System.out.print("usage: DbTestProcessBuilder items = Arrays.asList(ail.split("\\s*,\\s*")); + for (String ai: items) { + if (!DbTestConfig.get("audit.task."+ai+".status").startsWith("a")) { + continue; + } +//clog.debug("***audit item = " + ai + " Starting***"); + + String w1 = DbTestConfig.get("audit.task."+ai+".cmd"); + String[] w2 = w1.split("\\s*,\\s*"); + System.out.print( "task items are : " + Arrays.toString(w2)); + // append the audit item name as the prefix of the audit directory name + /*final int N = w2.length; + w2 = Arrays.copyOf(w2, N+1); + w2[N-2] = "\"-Dp=" + DbTestConfig.get("audit.task.odl.output.dir")+ai + "\""; +//clog.debug("***java -D:"+w2[N-2]); + //w2[N] = "\""+DbTestConfig.get("audit.task.odl.output.dir")+ai+"\""; + w2[N] = "\""+DbTestConfig.get("audit.task.odl.output.dir")+ai+"\""; + */ + DbTestProcessBuilder apb = new DbTestProcessBuilder(); + + String ts1 = DbTestConfig.get("audit.task."+ai+".schedule"); + String[] ts2 = ts1.split("\\s*,\\s*"); + // note ts2[0] is the wait-before time, and it is not being used right now. We start with ts2[1] + apb.runWCommandEveryXSecondsForYMinutes(w2,Integer.parseInt(ts2[1]),Integer.parseInt(ts2[2]), runningDir); +//clog.debug("***audit item = " + ai + " started***"); + System.out.println( "started test " + ai); + + /* + int ct = 0; + + while (true) try { + if (DbTestConfig.get("jcl").startsWith("q")) { + System.out.println("***Audit Main Program exiting..."); + System.exit(0); + } + + Thread.currentThread().sleep(1000); + if (ct < 10) { + ct++; + } else { + //clog.debug(AuditConfig.get("jcl").charAt(0)); + ct=0; + } + + } catch (InterruptedException ie) { + + } */ + } + int ct = 0; + + while (true) try { + if (DbTestConfig.get("jcl").startsWith("q")) { + System.out.println("***Audit Main Program exiting..."); + System.exit(0); + } + + Thread.currentThread().sleep(1000); + if (ct < 10) { + ct++; + } else { + //clog.debug(AuditConfig.get("jcl").charAt(0)); + ct=0; + } + + } catch (InterruptedException ie) { + + } + + } + +} diff --git a/aai-resources/src/test/java/org/openecomp/aai/util/HbaseSaltPrefixerTest.java b/aai-resources/src/test/java/org/openecomp/aai/util/HbaseSaltPrefixerTest.java new file mode 100644 index 0000000..4e19c35 --- /dev/null +++ b/aai-resources/src/test/java/org/openecomp/aai/util/HbaseSaltPrefixerTest.java @@ -0,0 +1,39 @@ +/*- + * ============LICENSE_START======================================================= + * org.openecomp.aai + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF 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.aai.util; + +import static org.junit.Assert.*; + +import org.junit.Test; + +public class HbaseSaltPrefixerTest { + + /** + * Test. + */ + @Test + public void test() { + String key = "imakey"; + String saltedKey = HbaseSaltPrefixer.getInstance().prependSalt(key); + assertTrue(saltedKey.equals("0-imakey")); + } + +} diff --git a/aai-resources/src/test/java/org/openecomp/aai/workarounds/LegacyURITransformerTest.java b/aai-resources/src/test/java/org/openecomp/aai/workarounds/LegacyURITransformerTest.java new file mode 100644 index 0000000..25dc648 --- /dev/null +++ b/aai-resources/src/test/java/org/openecomp/aai/workarounds/LegacyURITransformerTest.java @@ -0,0 +1,104 @@ +/*- + * ============LICENSE_START======================================================= + * org.openecomp.aai + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF 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.aai.workarounds; + +import static org.junit.Assert.assertEquals; + +import java.io.File; +import java.net.MalformedURLException; +import java.net.URI; +import java.net.URISyntaxException; +import java.net.URL; + +import org.junit.BeforeClass; +import org.junit.Test; + +import org.openecomp.aai.introspection.Version; + + +public class LegacyURITransformerTest { + + private LegacyURITransformer uriTransformer = LegacyURITransformer.getInstance(); + private String fromSuccess = "http://myhostname.com:8443/aai/{version}/cloud-infrastructure/tenants/tenant/key1/vservers/vserver/key2"; + private String toSuccess = "http://myhostname.com:8443/aai/servers/{version}/key1/vservers/key2"; + + /** + * Configure. + */ + @BeforeClass + public static void configure() { + System.setProperty("AJSC_HOME", "."); + System.setProperty("BUNDLECONFIG_DIR", "bundleconfig-local"); + } + + + /** + * Test spec. + * + * @param version the version + * @param toExpected the to expected + * @param fromExpected the from expected + * @throws URISyntaxException + * @throws MalformedURLException the malformed URL exception + */ + public void testSpec(Version version, String toExpected, String fromExpected) throws URISyntaxException { + + URI toExpectedUri = new URI(toExpected.replace("{version}",version.toString())); + URI fromExpectedUri = new URI(fromExpected.replace("{version}",version.toString())); + + URI result = toLegacyURISpec(version, fromExpectedUri); + + assertEquals("to", toExpectedUri, result); + + result = fromLegacyURISpec(version, toExpectedUri); + + assertEquals("from", fromExpectedUri, result); + } + + + /** + * To legacy URL spec. + * + * @param version the version + * @param url the url + * @return the url + * @throws URISyntaxException + * @throws MalformedURLException the malformed URL exception + */ + public URI toLegacyURISpec(Version version, URI uri) throws URISyntaxException { + return uri; + } + + /** + * From legacy URL spec. + * + * @param version the version + * @param url the url + * @return the url + * @throws URISyntaxException + * @throws MalformedURLException the malformed URL exception + */ + public URI fromLegacyURISpec(Version version, URI uri) throws URISyntaxException { + return uri; + } + + +} diff --git a/aai-resources/src/test/resources/bundleconfig-local/etc/appprops/aaiconfig.properties b/aai-resources/src/test/resources/bundleconfig-local/etc/appprops/aaiconfig.properties new file mode 100644 index 0000000..0558b26 --- /dev/null +++ b/aai-resources/src/test/resources/bundleconfig-local/etc/appprops/aaiconfig.properties @@ -0,0 +1,140 @@ +### +# ============LICENSE_START======================================================= +# org.openecomp.aai +# ================================================================================ +# Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. +# ================================================================================ +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# ============LICENSE_END========================================================= +### + +#################################################################### +# REMEMBER TO THINK ABOUT ENVIRONMENTAL DIFFERENCES AND CHANGE THE +# TEMPLATE AND *ALL* DATAFILES +#################################################################### + +aai.config.checktime=1000 + +# this could come from siteconfig.pl? +aai.config.nodename=AutomaticallyOverwritten + +aai.logging.hbase.interceptor=true +aai.logging.hbase.enabled=true +aai.logging.hbase.logrequest=true +aai.logging.hbase.logresponse=true + +aai.logging.trace.enabled=true +aai.logging.trace.logrequest=false +aai.logging.trace.logresponse=false + +aai.transaction.logging=true +aai.transaction.logging.get=true +aai.transaction.logging.post=true + + +ecm.openstack.tenantid=b0a529aba48440a39e0caf1aea9b27e3 +# This is a fake one just for test so please ignore +ecm.auth.password.x=OBF:1igd1i9a1jnb1yte1vv11vu91yt81jk71i6o1idt + +aai.avpn.interim.laginterface=ae0 + +aai.server.url.base=https://localhost:8443/aai/ +aai.server.url=https://localhost:8443/aai/v9/ +aai.global.callback.url=https://localhost:8443/aai/ + +aai.auth.cspcookies_on=false +aai.dbmodel.filename=ex5.json +aai.truststore.filename=aai_keystore +aai.truststore.passwd.x= +aai.keystore.filename=aai-client-cert.p12 +aai.keystore.passwd.x= + +# for transaction log +hbase.table.name=aailogging-dev1.dev +hbase.notificationTable.name=aainotification-dev1.dev +hbase.table.timestamp.format=YYYYMMdd-HH:mm:ss:SSS +hbase.zookeeper.quorum=ONAPserverTBD +hbase.zookeeper.property.clientPort=2181 +hbase.zookeeper.znode.parent=/hbase-unsecure + +aai.precheck.cloudinfrastructure.complex.defaults.physicalLocationType=AAIDefault +aai.precheck.cloudinfrastructure.complex.defaults.street1=AAIDefault +aai.precheck.cloudinfrastructure.complex.defaults.city=AAIDefault +aai.precheck.cloudinfrastructure.complex.defaults.state=NJ +aai.precheck.cloudinfrastructure.complex.defaults.postalCode=07748 +aai.precheck.cloudinfrastructure.complex.defaults.country=USA +aai.precheck.cloudinfrastructure.complex.defaults.region=US + +# single primary server +aai.primary.filetransfer.serverlist=ONAPserverTBD +aai.primary.filetransfer.primarycheck=echo:8443/aai/util/echo +aai.primary.filetransfer.pingtimeout=5000 +aai.primary.filetransfer.pingcount=5 + +#rsync properties +aai.rsync.command=rsync +aai.rsync.options.list=-v|-t +aai.rsync.remote.user=aaiadmin +aai.rsync.enabled=y + +#Service Specific Data Values +aai.servicedescription.hostedcomm=HOSTED COMMUNICATIONS +aai.servicedescription.mobility=MOBILITY +aai.servicedescription.vusp=VIRTUAL USP +aai.servicedescription.vvig=vVIGaaS +aai.servicedescription.lrsi=LRSI-OSPF + +aai.notification.current.version=v9 +aai.notificationEvent.default.status=UNPROCESSED +aai.notificationEvent.default.eventType=AAI-EVENT +aai.notificationEvent.default.domain=devINT1 +aai.notificationEvent.default.sourceName=aai +aai.notificationEvent.default.sequenceNumber=0 +aai.notificationEvent.default.severity=NORMAL +aai.notificationEvent.default.version=v9 +# This one lets us enable/disable resource-version checking on updates/deletes +aai.resourceversion.enableflag=true +aai.logging.maxStackTraceEntries=10 +aai.default.api.version=v9 + +# Used by Model-processing code +aai.model.delete.sleep.per.vtx.msec=500 +aai.model.query.resultset.maxcount=30 +aai.model.query.timeout.sec=90 + +# Used by Data Grooming +aai.grooming.default.max.fix=150 +aai.grooming.default.sleep.minutes=7 + +# Used by DupeTool +aai.dupeTool.default.max.fix=25 +aai.dupeTool.default.sleep.minutes=7 + +aai.model.proc.max.levels=50 +aai.edgeTag.proc.max.levels=50 + +# Used by the ForceDelete tool +aai.forceDel.protected.nt.list=cloud-region +aai.forceDel.protected.edge.count=10 +aai.forceDel.protected.descendant.count=10 + +# Used for CTAG-Pool generation +aai.ctagPool.rangeString.vplsPe1=2001-2500 +aai.ctagPool.rangeString.vplsPe2=2501-3000 +aai.ctagPool.rangeString.vpe=3001-3500 + +aai.dmaap.workload.enableEventProcessing=true + +aai.realtime.clients=RO,SDNC,MSO + +aai.server.rebind=g diff --git a/aai-resources/src/test/resources/bundleconfig-local/etc/appprops/error.properties b/aai-resources/src/test/resources/bundleconfig-local/etc/appprops/error.properties new file mode 100644 index 0000000..4e98d62 --- /dev/null +++ b/aai-resources/src/test/resources/bundleconfig-local/etc/appprops/error.properties @@ -0,0 +1,163 @@ +# Adding comment trying to trigger a build +#------------------------------------------------------------------------------- ---------- +#Key=Disposition:Category:Severity:Error Code:HTTP ResponseCode:RESTError Code:Error Message +#------------------------------------------------------------------------------- ---------- +# testing code, please don't change unless error utility source code changes +AAI_TESTING=5:2:WARN:0000:400:0001:Error code for testing + +# General success +AAI_0000=0:0:INFO:0000:200:0000:Success + +# health check success +AAI_0001=0:0:INFO:0001:200:0001:Success X-FromAppId=%1 X-TransactionId=%2 +AAI_0002=0:0:INFO:0002:200:0001:Successful health check + +# Success with additional info +AAI_0003=0:3:INFO:0003:202:0003:Success with additional info performing %1 on %2. Added %3 with key %4 +AAI_0004=0:3:INFO:0004:202:0003:Added prerequisite object to db + +#--- aairest: 3000-3299 +# svc errors +AAI_3000=5:2:INFO:3000:400:3000:Invalid input performing %1 on %2 +AAI_3001=5:6:INFO:3001:404:3001:Resource not found for %1 using id %2 +AAI_3002=5:1:WARN:3002:400:3002:Error writing output performing %1 on %2 +AAI_3003=5:1:WARN:3003:400:3003:Failed to make edge to missing target node of type %3 with keys %4 performing %1 on %2 +AAI_3005=5:6:WARN:3005:404:3001:Node cannot be directly accessed for read, must be accessed via ancestor(s) +AAI_3006=5:6:WARN:3006:404:3001:Node cannot be directly accessed for write, must be accessed via ancestor(s) +AAI_3007=5:6:INFO:3007:410:3007:This version (%1) of the API is retired, please migrate to %2 +AAI_3008=5:6:ERROR:3008:400:3008:URI is not encoded in UTF-8 +AAI_3009=5:6:ERROR:3009:400:3002:Malformed URL +# pol errors +AAI_3100=5:1:WARN:3100:400:3100:Unsupported operation %1 +AAI_3101=5:1:WARN:3101:403:3101:Attempt by client %1 to execute API %2 +AAI_3102=5:1:WARN:3102:400:3102:Error parsing input performing %1 on %2 +AAI_3300=5:1:WARN:3300:403:3300:Unauthorized +AAI_3301=5:1:WARN:3301:401:3301:Stale credentials +AAI_3302=5:1:WARN:3302:401:3301:Not authenticated +AAI_3303=5:1:ERROR:3303:403:3300:Too many objects would be returned by this request, please refine your request and retry + +#--- aaigen: 4000-4099 +AAI_4000=5:4:ERROR:4000:500:3002:Internal Error +AAI_4001=5:4:FATAL:4001:500:3002:Configuration file not found +AAI_4002=5:4:FATAL:4002:500:3002:Error reading Configuration file +AAI_4003=5:4:ERROR:4003:500:3002:Error writing to log file +AAI_4004=5:4:FATAL:4004:500:3002:Error reading/parsing the error properties file +AAI_4005=5:4:FATAL:4005:500:3002:Missing or invalid configuration parameter +AAI_4006=5:4:FATAL:4006:500:3002:Unexpected error in service +AAI_4007=5:4:ERROR:4007:500:3102:Input parsing error +AAI_4008=5:4:ERROR:4008:500:3002:Output parsing error +AAI_4009=4:0:ERROR:4009:400:3000:Invalid X-FromAppId in header +AAI_4010=4:0:ERROR:4010:400:3000:Invalid X-TransactionId in header +AAI_4011=5:4:ERROR:4011:500:3002:Missing data for REST error response +AAI_4012=5:4:ERROR:4012:500:3002:Bad rule data in RestRules +AAI_4013=5:4:ERROR:4013:500:3002:Error connecting to AAI REST API +AAI_4014=4:0:ERROR:4014:400:3000:Invalid Accept header +AAI_4015=4:0:ERROR:4015:400:3000:You must provide at least one indexed property +AAI_4016=4:0:ERROR:4016:400:3000:The depth parameter must be a number or the string "all" +AAI_4017=5:2:INFO:4017:400:3000:Could not set property +AAI_4018=5:2:ERROR:4018:400:3000:Unable to convert the string to integer +#--- aaidbmap: 5101-5199 +AAI_5101=5:4:FATAL:5101:500:3002:Could not connect to database +AAI_5102=5:4:FATAL:5102:500:3002:Graph database is null after open +AAI_5103=5:4:ERROR:5103:500:3002:Unexpected error during commit +AAI_5104=5:4:ERROR:5104:500:3002:Unexpected error during rollback +AAI_5105=5:4:ERROR:5105:500:3002:Unexpected error reading/updating database +AAI_5106=5:4:WARN:5106:404:3001:Node not found +AAI_5107=5:2:WARN:5107:400:3000:Required information missing +AAI_5108=5:2:WARN:5108:200:0:Unexpected information in request being ignored + +#--- aaidbgen: 6101-6199 +AAI_6101=5:4:ERROR:6101:500:3002:null TitanGraph object passed +AAI_6102=5:4:WARN:6102:400:3000:Passed-in property is not valid for this nodeType +AAI_6103=5:4:WARN:6103:400:3000:Required Node-property not found in input data +AAI_6104=5:4:WARN:6104:400:3000:Required Node-property was passed with no data +AAI_6105=5:4:WARN:6105:400:3000:Node-Key-Property not defined in DbMaps +AAI_6106=5:4:WARN:6106:400:3000:Passed-in property is not valid for this edgeType +AAI_6107=5:4:WARN:6107:400:3000:Required Edge-property not found in input data +AAI_6108=5:4:WARN:6108:400:3000:Required Edge-property was passed with no data +AAI_6109=5:4:WARN:6109:400:3000:Bad dependent Node value +AAI_6110=5:4:ERROR:6110:400:3100:Node cannot be deleted +AAI_6111=5:4:ERROR:6111:400:3000:JSON processing error +AAI_6112=5:4:ERROR:6112:400:3000:More than one node found by getUniqueNode() +AAI_6114=5:4:INFO:6114:404:3001:Node Not Found +AAI_6115=5:4:ERROR:6115:400:3000:Unrecognized NodeType +AAI_6116=5:4:ERROR:6116:400:3000:Unrecognized Property +AAI_6117=5:4:ERROR:6117:400:3000:Uniqueness constraint violated +AAI_6118=5:4:ERROR:6118:400:3000:Required Field not passed. +AAI_6120=5:4:ERROR:6120:400:3000:Bad Parameter Passed +AAI_6121=5:4:ERROR:6121:400:3000:Problem with internal AAI reference data +AAI_6122=5:4:ERROR:6122:400:3000:Data Set not complete in DB for this request +AAI_6123=5:4:ERROR:6123:500:3000:Bad Data found by DataGrooming Tool - Investigate +AAI_6124=5:4:ERROR:6124:500:3000:File read/write error +AAI_6125=5:4:WARN:6125:500:3000:Problem Pulling Data Set +AAI_6126=5:4:ERROR:6126:400:3000:Edge cannot be deleted +AAI_6127=5:4:INFO:6127:404:3001:Edge Not Found +AAI_6128=5:4:INFO:6128:500:3000:Unexpected error +AAI_6129=5:4:INFO:6129:404:3003:Error making edge to target node +AAI_6130=5:4:WARN:6130:412:3000:Precondition Required +AAI_6131=5:4:WARN:6131:412:3000:Precondition Failed +AAI_6132=5:4:WARN:6132:400:3000:Bad Model Definition +AAI_6133=5:4:WARN:6133:400:3000:Bad Named Query Definition +AAI_6134=5:4:ERROR:6134:500:6134:Could not persist transaction to storage back end. Exhausted retry amount +AAI_6135=5:4:WARN:6135:412:3000:Resource version specified on create +AAI_6136=5:4:ERROR:6136:400:3000:Object cannot hold multiple items +AAI_6137=5:4:ERROR:6137:400:3000:Cannot perform writes on multiple vertices +AAI_6138=5:4:ERROR:6138:400:3000:Cannot delete multiple vertices +AAI_6139=5:4:ERROR:6139:404:3000:Attempted to add edge to vertex that does not exist +AAI_6140=5:4:ERROR:6140:400:3000:Edge multiplicity violated +AAI_6141=5:4:WARN:6141:400:3000:Please Refine Query +AAI_6142=5:4:INFO:6142:400:3000:Retrying transaction +AAI_6143=5:4:INFO:6143:400:3000:Ghost vertex found +AAI_6144=5:4:WARN:6144:400:3000:Cycle found in graph +AAI_6145=5:4:ERROR:6145:400:3000:Cannot create a nested/containment edge via relationship + +#--- aaicsvp: 7101-7199 +AAI_7101=5:4:ERROR:7101:500:3002:Unexpected error in CSV file processing +AAI_7102=5:4:ERROR:7102:500:3002:Error in cleanup temporary directory +#AAI_7103=4:2:ERROR:7103:500:3002:Unsupported user +AAI_7104=5:4:ERROR:7104:500:3002:Failed to create directory +AAI_7105=5:4:ERROR:7105:500:3002:Temporary directory exists +AAI_7106=5:4:ERROR:7106:500:3002:Cannot delete +AAI_7107=5:4:ERROR:7107:500:3002:Input file does not exist +AAI_7108=5:4:ERROR:7108:500:3002:Output file does not exist +AAI_7109=5:4:ERROR:7109:500:3002:Error closing file +AAI_7110=5:4:ERROR:7110:500:3002:Error loading/reading properties file +AAI_7111=5:4:ERROR:7111:500:3002:Error executing shell script +AAI_7112=5:4:ERROR:7112:500:3002:Error creating output file +AAI_7113=5:4:ERROR:7113:500:3002:Trailer record error +AAI_7114=5:4:ERROR:7114:500:3002:Input file error +AAI_7115=5:4:ERROR:7115:500:3002:Unexpected error +AAI_7116=5:4:ERROR:7116:500:3002:Request error +AAI_7117=5:4:ERROR:7117:500:3002:Error in get http client object +AAI_7118=5:4:ERROR:7118:500:3002:Script Error +AAI_7119=5:4:ERROR:7119:500:3002:Unknown host + +#--- aaisdnc: 7201-7299 +AAI_7202=5:4:ERROR:7202:500:3002:Error getting connection to odl +AAI_7203=5:4:ERROR:7203:500:3002:Unexpected error calling DataChangeNotification API +AAI_7204=5:4:ERROR:7204:500:3002:Error returned by DataChangeNotification API +AAI_7205=5:4:ERROR:7205:500:3002:Unexpected error running notifySDNCOnUpdate +AAI_7206=5:4:ERROR:7206:500:3002:Invalid data returned from ODL + +#--- NotificationEvent, using UEB space +AAI_7350=5:4:ERROR:7305:500:3002:Notification event creation failed + +#--- aairestctlr: 7401-7499 +AAI_7401=5:4:ERROR:7401:500:3002:Error connecting to AAI REST API +AAI_7402=5:4:ERROR:7402:500:3002:Unexpected error +AAI_7403=5:4:WARN:7403:400:3001:Request error +AAI_7404=5:4:INFO:7404:404:3001:Node not found + +#--- aaiauth: 9101-9199 +AAI_9101=5:0:WARN:9101:403:3300:User is not authorized to perform function +AAI_9102=5:0:WARN:9102:401:3301:Refresh credentials from source +AAI_9103=5:0:WARN:9103:403:3300:User not found +AAI_9104=5:0:WARN:9104:401:3302:Authentication error +AAI_9105=5:0:WARN:9105:403:3300:Authorization error +AAI_9106=5:0:WARN:9106:403:3300:Invalid AppId +#AAI_9107=5:0:WARN:9107:403:3300:No Username in Request +AAI_9107=5:0:WARN:9107:403:3300:SSL is not provided in request, please contact admin + +#--- aaiinstar: 9201-9299 +AAI_9201=5:4:ERROR:9201:500:3002:Unable to send notification +AAI_9202=5:4:ERROR:9202:500:3002:Unable to start a thread diff --git a/aai-resources/src/test/resources/bundleconfig-local/etc/auth/aai_policy.json b/aai-resources/src/test/resources/bundleconfig-local/etc/auth/aai_policy.json new file mode 100644 index 0000000..9706ce9 --- /dev/null +++ b/aai-resources/src/test/resources/bundleconfig-local/etc/auth/aai_policy.json @@ -0,0 +1,37 @@ +{ + "roles": [{ + "name": "testRole", + "functions": [{ + "name": "testFunction", + "methods": [{ + "name": "GET" + }, { + "name": "DELETE" + }, { + "name": "PUT" + } + ] + } + ], + "users": [{ + "username": "testUser" + } + ] + }, { + "name": "testBasicAuth", + "functions": [{ + "name": "testBasicAuthFuncyion", + "methods": [{ + "name": "GET" + } + ] + } + ], + "users": [{ + "user": "testBasicAuthUser", + "pass": "OBF:1ytc1vu91v2p1rxf1mqh1v8s1z0d1msn1san1mqf1z0h1v9u1msl1rvf1v1p1vv11yta" + } + ] + } + ] +} \ No newline at end of file diff --git a/aai-resources/src/test/resources/bundleconfig-local/etc/oxm/aai_oxm_v10.xml b/aai-resources/src/test/resources/bundleconfig-local/etc/oxm/aai_oxm_v10.xml new file mode 100644 index 0000000..9ba6c05 --- /dev/null +++ b/aai-resources/src/test/resources/bundleconfig-local/etc/oxm/aai_oxm_v10.xml @@ -0,0 +1,5534 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/aai-resources/src/test/resources/bundleconfig-local/etc/oxm/aai_oxm_v8.xml b/aai-resources/src/test/resources/bundleconfig-local/etc/oxm/aai_oxm_v8.xml new file mode 100644 index 0000000..be53291 --- /dev/null +++ b/aai-resources/src/test/resources/bundleconfig-local/etc/oxm/aai_oxm_v8.xml @@ -0,0 +1,4797 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/aai-resources/src/test/resources/bundleconfig-local/etc/oxm/aai_oxm_v9.xml b/aai-resources/src/test/resources/bundleconfig-local/etc/oxm/aai_oxm_v9.xml new file mode 100644 index 0000000..7b8d032 --- /dev/null +++ b/aai-resources/src/test/resources/bundleconfig-local/etc/oxm/aai_oxm_v9.xml @@ -0,0 +1,5469 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/aai-resources/src/test/resources/com/att/aai/introspection/aai_oxm_v10.xml b/aai-resources/src/test/resources/com/att/aai/introspection/aai_oxm_v10.xml new file mode 100644 index 0000000..cf53ad2 --- /dev/null +++ b/aai-resources/src/test/resources/com/att/aai/introspection/aai_oxm_v10.xml @@ -0,0 +1,5933 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/aai-resources/src/test/resources/com/att/aai/introspection/aai_oxm_v8.xml b/aai-resources/src/test/resources/com/att/aai/introspection/aai_oxm_v8.xml new file mode 100644 index 0000000..1eb8f9c --- /dev/null +++ b/aai-resources/src/test/resources/com/att/aai/introspection/aai_oxm_v8.xml @@ -0,0 +1,85 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/aai-resources/src/test/resources/com/att/aai/introspection/aai_oxm_v9.xml b/aai-resources/src/test/resources/com/att/aai/introspection/aai_oxm_v9.xml new file mode 100644 index 0000000..ee02d84 --- /dev/null +++ b/aai-resources/src/test/resources/com/att/aai/introspection/aai_oxm_v9.xml @@ -0,0 +1,596 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/aai-resources/src/test/resources/com/att/aai/introspection/sideeffect/nested-case.json b/aai-resources/src/test/resources/com/att/aai/introspection/sideeffect/nested-case.json new file mode 100644 index 0000000..40a0493 --- /dev/null +++ b/aai-resources/src/test/resources/com/att/aai/introspection/sideeffect/nested-case.json @@ -0,0 +1,18 @@ +{ + "global-customer-id": "key1", + "subscriber-name": "44IPZu0Ri", + "subscriber-type": "gIgOtou5Np5u", + "service-subscriptions": { + "service-subscription" : [ { + "service-type" : "key2", + "temp-ub-sub-account-id" : "JJYRez", + "service-instances" : { + "service-instance" : [ { + "service-instance-id" : "nested-instance-key", + "model-invariant-id" : "key1", + "model-version-id" : "key2" + }] + } + }] + } + } \ No newline at end of file diff --git a/aai-resources/src/test/resources/com/att/aai/serialization/queryformats/graphson/resource.graphson b/aai-resources/src/test/resources/com/att/aai/serialization/queryformats/graphson/resource.graphson new file mode 100644 index 0000000..257916a --- /dev/null +++ b/aai-resources/src/test/resources/com/att/aai/serialization/queryformats/graphson/resource.graphson @@ -0,0 +1,2 @@ +{"id": 386506928,"label": "vertex","properties": {"aai-last-mod-ts": [{"id": "ob632u-6e46nk-5j45","value": 1488308500413}],"aai-uri": [{"id": "ob6712-6e46nk-5lhh","value": "/cloud-infrastructure/cloud-regions/cloud-region/cloud-owner-987654321-9922/cloud-region-id-987654320-9922/tenants/tenant/tenant-987654321-9999/vservers/vserver/vserver-987654321-9999"}],"prov-status": [{"id": "ob651y-6e46nk-1kw5","value": "example-prov-status-val-7367"}],"aai-created-ts": [{"id": "ob62ae-6e46nk-5gqt","value": 1488308500413}],"source-of-truth": [{"id": "ob61w6-6e46nk-5jwl","value": "FitNesse-Test"}],"vserver-selflink": [{"id": "ob65g6-6e46nk-3xfp","value": "example-vserver-selflink-val-7367"}],"aai-node-type": [{"id": "ob61hy-6e46nk-5f5x","value": "vserver"}],"in-maint": [{"id": "ob65ue-6e46nk-20p1","value": false}],"resource-version": [{"id": "ob62om-6e46nk-23ut","value": "1488308500413"}],"vserver-name": [{"id": "ob649i-6e46nk-3u9x","value": "example-vserver-name-val-7367vserver-987654321-9999"}],"vserver-id": [{"id": "ob63va-6e46nk-3sp1","value": "vserver-987654321-9999"}],"last-mod-source-of-truth": [{"id": "ob63h2-6e46nk-5edh","value": "FitNesse-Test"}],"vserver-name2": [{"id": "ob64nq-6e46nk-3vut","value": "example-vserver-name2-val-7367"}],"is-closed-loop-disabled": [{"id": "ob668m-6e46nk-229x","value": false}]}} +{"id": 2461872,"label": "vertex","properties": {"aai-last-mod-ts": [{"id": "21hqu-1grlc-5j45","value": 1467901600}],"in-maint": [{"id": "21i52-1grlc-20p1","value": false}],"resource-version": [{"id": "21ija-1grlc-23ut","value": "1467901600"}],"vserver-name": [{"id": "21ixi-1grlc-3u9x","value": "PerfTest_VServerFix0027TenantPez002701611467901587187Name"}],"aai-created-ts": [{"id": "21jbq-1grlc-5gqt","value": 1467901600}],"vserver-id": [{"id": "21jpy-1grlc-3sp1","value": "PerfTest_VServerFix0027TenantPez002701611467901587187"}],"last-mod-source-of-truth": [{"id": "21k46-1grlc-5edh","value": "MSO"}],"vserver-name2": [{"id": "21kie-1grlc-3vut","value": "PerfTest_VServerFix0027TenantPez002701611467901587187-VM Name2 optional"}],"source-of-truth": [{"id": "21kwm-1grlc-5jwl","value": "MSO"}],"vserver-selflink": [{"id": "21lau-1grlc-3xfp","value": "http://testvserverLink.com/.html?vserv=VserverLink"}],"is-closed-loop-disabled": [{"id": "21lp2-1grlc-229x","value": false}],"aai-node-type": [{"id": "21m3a-1grlc-5f5x","value": "vserver"}],"aai-uri": [{"id": "21m3a-1grlc-5a5x","value": "/vservers/vserver/test1"}]}} diff --git a/aai-resources/src/test/resources/com/att/aai/serialization/queryformats/resource-format.json b/aai-resources/src/test/resources/com/att/aai/serialization/queryformats/resource-format.json new file mode 100644 index 0000000..c7e4255 --- /dev/null +++ b/aai-resources/src/test/resources/com/att/aai/serialization/queryformats/resource-format.json @@ -0,0 +1,13 @@ +{ + "results": [ + { + "vserver": { + + } + }, + { + "vserver": { + } + } + ] +} \ No newline at end of file diff --git a/aai-resources/src/test/resources/com/att/aai/serialization/queryformats/resource_and_url-format.json b/aai-resources/src/test/resources/com/att/aai/serialization/queryformats/resource_and_url-format.json new file mode 100644 index 0000000..80d6560 --- /dev/null +++ b/aai-resources/src/test/resources/com/att/aai/serialization/queryformats/resource_and_url-format.json @@ -0,0 +1,16 @@ +{ + "results": [ + { + "url" : "/cloud-infrastructure/cloud-regions/cloud-region/cloud-owner-987654321-9922/cloud-region-id-987654321-9922/tenants/tenant/tenant-987654321-9999/vservers/vserver/vserver-987654321-9999", + "vserver": { + + } + }, + { + "url" : "/vservers/vserver/test1", + "vserver": { + + } + } + ] +} diff --git a/aai-resources/src/test/resources/com/att/aai/serialization/queryformats/simple-format.json b/aai-resources/src/test/resources/com/att/aai/serialization/queryformats/simple-format.json new file mode 100644 index 0000000..dd34261 --- /dev/null +++ b/aai-resources/src/test/resources/com/att/aai/serialization/queryformats/simple-format.json @@ -0,0 +1,43 @@ +{ + "results" : [{ + "id" : "0", + "node-type" : "generic-vnf", + "url" : "urimissing", + "properties" : { + "vnf-name" : "myVnf" + }, + "related-to" : [{ + "node-type" : "vserver", + "id" : "1", + "url" : "urimissing" + }] + } , { + "id" : "1", + "node-type" : "vserver", + "url" : "urimissing", + "properties" : { + "vserver-name" : "myVserver" + }, + "related-to" : [{ + "node-type" : "generic-vnf", + "id" : "0", + "url" : "urimissing" + },{ + "node-type" : "pserver", + "id" : "2", + "url" : "/pservers/pserver/key1" + }] + },{ + "id" : "2", + "node-type" : "pserver", + "url" : "/pservers/pserver/key1", + "properties" : { + "hostname" : "myPserver" + }, + "related-to" : [{ + "node-type" : "vserver", + "id" : "1", + "url" : "urimissing" + }] + }] +} \ No newline at end of file diff --git a/aai-resources/src/test/resources/inmemory_titan.properties b/aai-resources/src/test/resources/inmemory_titan.properties new file mode 100644 index 0000000..46695d6 --- /dev/null +++ b/aai-resources/src/test/resources/inmemory_titan.properties @@ -0,0 +1,21 @@ +### +# ============LICENSE_START======================================================= +# org.openecomp.aai +# ================================================================================ +# Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. +# ================================================================================ +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# ============LICENSE_END========================================================= +### + +storage.backend=inmemory diff --git a/aai-resources/src/test/resources/log4j.properties b/aai-resources/src/test/resources/log4j.properties new file mode 100644 index 0000000..2e68f61 --- /dev/null +++ b/aai-resources/src/test/resources/log4j.properties @@ -0,0 +1,3 @@ +log4j.logger.org.apache.zookeeper=WARN +log4j.logger.org.apache.hadoop.hbase.zookeeper=WARN +log4j.logger.org.apache.hadoop.hbase.client=WARN \ No newline at end of file diff --git a/aai-resources/src/test/resources/logback.xml b/aai-resources/src/test/resources/logback.xml new file mode 100644 index 0000000..65682b0 --- /dev/null +++ b/aai-resources/src/test/resources/logback.xml @@ -0,0 +1,255 @@ + + + + ${module.ajsc.namespace.name} + + + + + + + + ERROR + ACCEPT + DENY + + + %d{HH:mm:ss.SSS} [%thread] %-5level %logger{1024} - %msg%n + + + + + + + INFO + ACCEPT + DENY + + ${logDirectory}/rest/metric.log + + ${logDirectory}/rest/metric.log.%d{yyyy-MM-dd} + + + + %d{yyyy-MM-dd'T'HH:mm:ss.SSSXXX}|%m%n + + + + + + DEBUG + ACCEPT + DENY + + ${logDirectory}/rest/debug.log + + ${logDirectory}/rest/debug.log.%d{yyyy-MM-dd} + + + + %d{yyyy-MM-dd'T'HH:mm:ss.SSSXXX}|%m%n + + + + + + WARN + ACCEPT + DENY + + ${logDirectory}/rest/error.log + + ${logDirectory}/rest/error.log.%d{yyyy-MM-dd} + + + + + %d{yyyy-MM-dd'T'HH:mm:ss.SSSXXX}|%m%n + + + + + + + + audit + + co\=aairest + + level == INFO && audit.matches(formattedMessage) + + ACCEPT + DENY + + ${logDirectory}/rest/audit.log + + ${logDirectory}/rest/metric.log.%d{yyyy-MM-dd} + + + %d{yyyy-MM-dd'T'HH:mm:ss.SSSXXX}|%m%n + + + + + + + ${logDirectory}/rest/audit.log + + ${logDirectory}/rest/audit.%d{yyyy-MM-dd}.log.zip + + + + 5MB + + + "%d [%thread] %-5level %logger{1024} - %msg%n" + + + + + + + ${logDirectory}/rest/perform.log + + ${logDirectory}/rest/perform.%d{yyyy-MM-dd}.log.zip + + + + + "%d [%thread] %-5level %logger{1024} - %msg%n" + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 1000 + 0 + + + + + 1000 + 0 + + + + + + + + + + + + + + + + + + + + + diff --git a/aai-resources/src/test/resources/maputils/testcases/TestCase1.json b/aai-resources/src/test/resources/maputils/testcases/TestCase1.json new file mode 100644 index 0000000..1f7a794 --- /dev/null +++ b/aai-resources/src/test/resources/maputils/testcases/TestCase1.json @@ -0,0 +1,32 @@ +{ + "input": { + "myImage": { + "imageId": "test-imageId-1", + "imageName": "test-image-name", + "imageList": [ + { + "imageListName": "testListName", + "imageListId": "testListId", + "imageListNumber": 200, + "imageListBoolean": true, + "imageListNull": null + } + ] + } + }, + "output": { + "my-image": { + "image-id": "test-imageId-1", + "image-name": "test-image-name", + "image-list": [ + { + "image-list-name": "testListName", + "image-list-id": "testListId", + "image-list-number": 200, + "image-list-boolean": true, + "image-list-null": null + } + ] + } + } +} \ No newline at end of file diff --git a/aai-resources/src/test/resources/maputils/testcases/TestCase2.json b/aai-resources/src/test/resources/maputils/testcases/TestCase2.json new file mode 100644 index 0000000..9b8a1e3 --- /dev/null +++ b/aai-resources/src/test/resources/maputils/testcases/TestCase2.json @@ -0,0 +1,40 @@ +{ + "input": { + "myImage": { + "imageId": "test-imageId-1", + "imageName": "test-image-name", + "imageList": [ + { + "imageListName": "testListName", + "imageListId": "testListId", + "imageArray": [ + [ + { + "imageNestedArrayElement": "value" + } + ] + ] + } + ] + } + }, + "output": { + "my-image": { + "image-id": "test-imageId-1", + "image-name": "test-image-name", + "image-list": [ + { + "image-list-name": "testListName", + "image-list-id": "testListId", + "image-array": [ + [ + { + "image-nested-array-element": "value" + } + ] + ] + } + ] + } + } +} \ No newline at end of file diff --git a/aai-resources/src/test/resources/test_aaiconfig.properties b/aai-resources/src/test/resources/test_aaiconfig.properties new file mode 100644 index 0000000..d5a7c25 --- /dev/null +++ b/aai-resources/src/test/resources/test_aaiconfig.properties @@ -0,0 +1,118 @@ +### +# ============LICENSE_START======================================================= +# org.openecomp.aai +# ================================================================================ +# Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. +# ================================================================================ +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# ============LICENSE_END========================================================= +### + +#################################################################### +# REMEMBER TO THINK ABOUT ENVIRONMENTAL DIFFERENCES AND CHANGE THE +# TEMPLATE AND *ALL* DATAFILES +#################################################################### + +aai.config.checktime=1000 + +# this could come from siteconfig.pl? +aai.config.nodename=AutomaticallyOverwritten + +aai.logging.hbase.interceptor=true +aai.logging.hbase.enabled=true +aai.logging.hbase.logrequest=true +aai.logging.hbase.logresponse=true + +aai.logging.trace.enabled=true +aai.logging.trace.logrequest=false +aai.logging.trace.logresponse=false + +ecm.openstack.tenantid=b0a529aba48440a39e0caf1aea9b27e3 +ecm.serviceid.trinity=UNUSED +ecm.serviceid.vusp=UNUSED + +aai.auth.cspcookies_on=false +aai.dbmodel.filename=ex5.json +aai.server.url.base=https://localhost.com:8443/aai/ +aai.server.url=https://localhost.com:8443/aai/v7/ +aai.oldserver.url.base=https://localhost.com:8443/aai/servers/ +aai.oldserver.url=https://localhost.com:8443/aai/servers/v3/ +aai.truststore.filename=aai_keystore +aai.truststore.passwd.x= +aai.keystore.filename=aai-client-cert.p12 +aai.keystore.passwd.x= + +# the following parameters are not reloaded automatically and require a manual bounce +storage.backend=hbase +storage.hostname=ONAPserverTBD +#schema.default=none +storage.lock.wait-time=300 +storage.hbase.table=aaigraph-dev1.dev +storage.hbase.ext.zookeeper.znode.parent=/hbase-unsecure +# Setting db-cache to false ensure the fastest propagation of changes across servers +cache.db-cache = false +#cache.db-cache-clean-wait = 20 +#cache.db-cache-time = 180000 +#cache.db-cache-size = 0.5 + +# for transaction log +hbase.table.name=aailogging-dev1.dev +hbase.notificationTable.name=aainotification-dev1.dev +hbase.table.timestamp.format=YYYYMMdd-HH:mm:ss:SSS +hbase.zookeeper.quorum=ONAPserverTBD +hbase.zookeeper.property.clientPort=2181 +hbase.zookeeper.znode.parent=/hbase-unsecure + +aai.precheck.cloudinfrastructure.complex.defaults.physicalLocationType=AAIDefault +aai.precheck.cloudinfrastructure.complex.defaults.street1=AAIDefault +aai.precheck.cloudinfrastructure.complex.defaults.city=AAIDefault +aai.precheck.cloudinfrastructure.complex.defaults.state=NJ +aai.precheck.cloudinfrastructure.complex.defaults.postalCode=07748 +aai.precheck.cloudinfrastructure.complex.defaults.country=USA +aai.precheck.cloudinfrastructure.complex.defaults.region=Americas + +# single primary server +aai.primary.filetransfer.serverlist=ONAPserverTBD +aai.primary.filetransfer.primarycheck=echo:8443/aai/util/echo +aai.primary.filetransfer.pingtimeout=5000 +aai.primary.filetransfer.pingcount=5 + +#rsync properties +aai.rsync.command=rsync +aai.rsync.options.list=-v|-t +aai.rsync.remote.user=aaiadmin +aai.rsync.enabled=y + +#Service Specific Data Values +aai.servicedescription.hostedcomm=HOSTED COMMUNICATIONS +aai.servicedescription.mobility=MOBILITY +aai.servicedescription.vusp=VIRTUAL USP + +<<<<<<< HEAD +aai.notification.current.package=org.openecomp.aai.dbmapGen.v6 +======= +>>>>>>> feature/AAI-8158-cleanup-at-t-specific-reference +aai.notification.current.version=v7 +aai.notificationEvent.default.status=UNPROCESSED +aai.notificationEvent.default.eventType=AAI-EVENT +aai.notificationEvent.default.domain=devINT1 +aai.notificationEvent.default.sourceName=aai +aai.notificationEvent.default.sequenceNumber=0 +aai.notificationEvent.default.severity=NORMAL +aai.notificationEvent.default.version=v7 +# This one lets us enable/disable resource-version checking on updates/deletes +aai.resourceversion.enableflag=true +aai.logging.maxStackTraceEntries=10 +aai.default.api.version=v7 + + diff --git a/deploy.sh b/deploy.sh new file mode 100755 index 0000000..4dc80c8 --- /dev/null +++ b/deploy.sh @@ -0,0 +1,55 @@ +#!/bin/bash + +if [ -f "/opt/docker/docker-compose" ]; +then + DOCKER_COMPOSE_CMD="/opt/docker/docker-compose" +else + DOCKER_COMPOSE_CMD="docker-compose" +fi + +export DOCKER_REGISTRY="${DOCKER_REGISTRY:-localhost:5000}"; +export HBASE_IMAGE="${HBASE_IMAGE:-wc9368/aai-hbase-1.2.3}"; +export GREMLIN_SERVER_IMAGE="${GREMLIN_SERVER_IMAGE:-gremlin-server}"; +export AAI_HAPROXY_IMAGE="${AAI_HAPROXY_IMAGE:-aai-haproxy}"; + +function wait_for_container() { + + CONTAINER_NAME="$1"; + START_TEXT="$2"; + + TIMEOUT=120 + + # wait for the real startup + AMOUNT_STARTUP=$(docker logs ${CONTAINER_NAME} 2>&1 | grep "$START_TEXT" | wc -l) + while [[ ${AMOUNT_STARTUP} -ne 1 ]]; + do + echo "Waiting for '$CONTAINER_NAME' deployment to finish ..." + AMOUNT_STARTUP=$(docker logs ${CONTAINER_NAME} 2>&1 | grep "$START_TEXT" | wc -l) + if [ "$TIMEOUT" = "0" ]; + then + echo "ERROR: $CONTAINER_NAME deployment failed." + exit 1 + fi + let TIMEOUT-=1 + sleep 1 + done +} + +# cleanup +$DOCKER_COMPOSE_CMD stop +$DOCKER_COMPOSE_CMD rm -f -v + +# deploy +$DOCKER_COMPOSE_CMD up -d aai_haproxy + +HBASE_CONTAINER_NAME=$($DOCKER_COMPOSE_CMD up -d hbase 2>&1 | awk '{ print $2; }'); +wait_for_container $HBASE_CONTAINER_NAME '^starting regionserver'; + +GREMLIN_CONTAINER_NAME=$($DOCKER_COMPOSE_CMD up -d gremlin 2>&1 | awk '{ print $2; }'); +wait_for_container $GREMLIN_CONTAINER_NAME 'Channel started at port 8182'; + +RESOURCES_CONTAINER_NAME=$($DOCKER_COMPOSE_CMD up -d aai-resources 2>&1 | awk '{ print $2; }'); +wait_for_container $RESOURCES_CONTAINER_NAME '0.0.0.0:8447'; + +$DOCKER_COMPOSE_CMD up -d aai-graph-query + diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..a6d260f --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,56 @@ +version: '2' +services: + aai-resources: + image: ${DOCKER_REGISTRY}/openecomp/aai-resources + network_mode: host + environment: + - AAI_CHEF_ENV=solo + - AAI_REPO_PATH=r/aai + - AAI_CHEF_LOC=/var/chef/aai-data/environments + - docker_gitbranch=master + - PROTOCOL=http + logging: + driver: "json-file" + options: + max-size: "30m" + max-file: "5" + aai-graph-query: + image: ${DOCKER_REGISTRY}/openecomp/aai-traversal + network_mode: host + environment: + - AAI_CHEF_ENV=solo + - AAI_REPO_PATH=r/aai + - AAI_CHEF_LOC=/var/chef/aai-data/environments + - docker_gitbranch=master + - PROTOCOL=http + logging: + driver: "json-file" + options: + max-size: "30m" + max-file: "5" + hbase: + image: ${HBASE_IMAGE} + network_mode: host + logging: + driver: "json-file" + options: + max-size: "30m" + max-file: "5" + gremlin: + image: ${GREMLIN_SERVER_IMAGE} + network_mode: host + logging: + driver: "json-file" + options: + max-size: "30m" + max-file: "5" + aai_haproxy: + image: ${AAI_HAPROXY_IMAGE} + volumes: + - /dev/log:/dev/log + network_mode: host + logging: + driver: "json-file" + options: + max-size: "30m" + max-file: "5" diff --git a/pom.xml b/pom.xml new file mode 100644 index 0000000..e0f9c69 --- /dev/null +++ b/pom.xml @@ -0,0 +1,343 @@ + + + 4.0.0 + + + ajsc-archetype-parent + com.att.ajsc + 2.1.0 + + org.openecomp.aai + aai-resources-service + 1.1.0-SNAPSHOT + aai-resources-service + pom + + aai-resources + + + https://nexus.onap.org + 1.8 + 1.8 + ActiveAndAvailableInventory-CloudNetwork + ${aaiAppHome}/target/swm/package/nix/dist_files${distFilesRoot} + v1 + 2.1.0 + ${project.version} + + + /opt/app/aai-resources + /opt/app/aai-resources + ${basedir}/aai-resources + + + aaiadmin + aaiadmin + + + 8087 + 8447 + + workstation + DEV + + + 3.0.4 + int1-data.graphson + 1.1.0-SNAPSHOT + + + + central + http://repo1.maven.org/maven2 + + + EvoSuite + EvoSuite Repository + http://www.evosuite.org/m2 + + + + + AJSC + AJSC repository + https://mvnrepository.com/artifact/com.att.ajsc + + + restlet + maven reslet + https://maven.restlet.com/ + + + + central + Maven 2 repository 2 + http://repo2.maven.org/maven2/ + + + ecomp-releases + ECOMP Release Repository + ${nexusproxy}/content/repositories/releases/ + + + ecomp-staging + ECOMP Staging Repository + ${nexusproxy}/content/repositories/staging/ + + + ecomp-snapshots + ECOMP Snapshot Repository + ${nexusproxy}/content/repositories/snapshots/ + + + + + + + + jenkins-properties + + + unix + + + + + + + + runAjsc + + initialize + + + + org.codehaus.mojo + exec-maven-plugin + 1.3.2 + + + run ajsc + initialize + + java + + + + false + true + java + com.att.ajsc.runner.Runner + + com.att.ajsc + ajsc-runner + + + + ${runAjscHome} + + + ${runAjscHome}/extJars/logback-access-1.1.7.jar + ${runAjscHome}/extJars/logback-core-1.1.7.jar + ${runAjscHome}/extJars/aai-core-${aai-core.version}.jar + + + + + + AJSC_HOME + ${runAjscHome} + + + AFT_HOME + ${runAjscHome}/bundleconfig/ + + + AJSC_CONF_HOME + ${aaiAppHome}/bundleconfig-local + + + logback.configurationFile + ${aaiAppHome}/ajsc-shared-config/etc/logback.xml + + + AJSC_SHARED_CONFIG + ${aaiAppHome}/ajsc-shared-config + + + file.separator + / + + + snapshot.location + ${basedir}/aai-resources/snapshots/${snapshot.file} + + + + + AJSC_EXTERNAL_LIB_FOLDERS + ${aaiAppHome}/target/commonLibs + + + + AJSC_EXTERNAL_PROPERTIES_FOLDERS + ${aaiAppHome}/ajsc-shared-config/etc + + + + AJSC_SERVICE_NAMESPACE + ${module.ajsc.namespace.name} + + + AJSC_SERVICE_VERSION + ${module.ajsc.namespace.version} + + + SOACLOUD_SERVICE_VERSION + ${project.version} + + + server.port + ${serverPort} + + + aai-core.version + ${aai-core.version} + + + + + + context=/ + port=${serverPort} + sslport=${sslport} + + + + + + java + + + + com.att.ajsc + ajsc-runner + ${ajscRuntimeVersion} + + + + + + + + + + + + org.apache.maven.plugins + maven-compiler-plugin + 3.1 + + groovy-eclipse-compiler + false + 1.8 + 1.8 + + + + org.codehaus.groovy + groovy-eclipse-compiler + 2.9.0-01 + + + org.codehaus.groovy + groovy-eclipse-batch + 2.3.4-01 + + + + + + + + + org.codehaus.mojo + license-maven-plugin + 1.12 + + false + apache_v2 + 2017 + AT&T Intellectual Property. All rights reserved. + org.openecomp.aai + true + true + true + true + ============LICENSE_START======================================================= + ============LICENSE_END========================================================= + ================================================================================ + + **/*.java + **/*.ksh + **/*.sh + **/*.ftl + **/*.xsd + **/*.xjb + **/*.yml + **/*.yaml + **/aai*.xml + **/*logback*.xml + **/*aaiconfig*.properties + **/*titan*.properties + + + + + first + + update-file-header + + process-sources + + + + + + + diff --git a/set-debug-port.bat b/set-debug-port.bat new file mode 100644 index 0000000..b87e8dc --- /dev/null +++ b/set-debug-port.bat @@ -0,0 +1 @@ +SET MAVEN_OPTS=-Xms2048m -Xmx2048m -Xdebug -Xnoagent -Djava.compile=NONE -Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=9447 \ No newline at end of file diff --git a/start-cassandra-service.bat b/start-cassandra-service.bat new file mode 100644 index 0000000..8b7b9ea --- /dev/null +++ b/start-cassandra-service.bat @@ -0,0 +1,33 @@ +@echo off + +:: BatchGotAdmin +:------------------------------------- +REM --> Check for permissions + IF "%PROCESSOR_ARCHITECTURE%" EQU "amd64" ( +>nul 2>&1 "%SYSTEMROOT%\SysWOW64\cacls.exe" "%SYSTEMROOT%\SysWOW64\config\system" +) ELSE ( +>nul 2>&1 "%SYSTEMROOT%\system32\cacls.exe" "%SYSTEMROOT%\system32\config\system" +) + +REM --> If error flag set, we do not have admin. +if '%errorlevel%' NEQ '0' ( + echo Requesting administrative privileges... + goto UACPrompt +) else ( goto gotAdmin ) + +:UACPrompt + echo Set UAC = CreateObject^("Shell.Application"^) > "%temp%\getadmin.vbs" + set params = %*:"="" + echo UAC.ShellExecute "cmd.exe", "/c ""%~s0"" %params%", "", "runas", 1 >> "%temp%\getadmin.vbs" + + "%temp%\getadmin.vbs" + del "%temp%\getadmin.vbs" + exit /B + +:gotAdmin + pushd "%CD%" + CD /D "%~dp0" +:-------------------------------------- +call net start DataStax_Cassandra_Community_Server +call net start DataStax_OpsCenter_Agent +call net start DataStax_OpsCenter_Community \ No newline at end of file diff --git a/stop-cassandra-service.bat b/stop-cassandra-service.bat new file mode 100644 index 0000000..32335ba --- /dev/null +++ b/stop-cassandra-service.bat @@ -0,0 +1,33 @@ +@echo off + +:: BatchGotAdmin +:------------------------------------- +REM --> Check for permissions + IF "%PROCESSOR_ARCHITECTURE%" EQU "amd64" ( +>nul 2>&1 "%SYSTEMROOT%\SysWOW64\cacls.exe" "%SYSTEMROOT%\SysWOW64\config\system" +) ELSE ( +>nul 2>&1 "%SYSTEMROOT%\system32\cacls.exe" "%SYSTEMROOT%\system32\config\system" +) + +REM --> If error flag set, we do not have admin. +if '%errorlevel%' NEQ '0' ( + echo Requesting administrative privileges... + goto UACPrompt +) else ( goto gotAdmin ) + +:UACPrompt + echo Set UAC = CreateObject^("Shell.Application"^) > "%temp%\getadmin.vbs" + set params = %*:"="" + echo UAC.ShellExecute "cmd.exe", "/c ""%~s0"" %params%", "", "runas", 1 >> "%temp%\getadmin.vbs" + + "%temp%\getadmin.vbs" + del "%temp%\getadmin.vbs" + exit /B + +:gotAdmin + pushd "%CD%" + CD /D "%~dp0" +:-------------------------------------- +call net stop DataStax_Cassandra_Community_Server +call net stop DataStax_OpsCenter_Agent +call net stop DataStax_OpsCenter_Community \ No newline at end of file diff --git a/version.properties b/version.properties new file mode 100644 index 0000000..abe15cf --- /dev/null +++ b/version.properties @@ -0,0 +1,14 @@ +########################################################### +# 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 + +major_version=1 +minor_version=1 +patch_version=0 + +base_version=${major_version}.${minor_version}.${patch_version} + +# Release must be completed with GIT information # in Jenkins +release_version=${base_version} +snapshot_version=${base_version}-SNAPSHOT \ No newline at end of file -- cgit 1.2.3-korg