From ba31685194c77ef140411531299696ae701385d4 Mon Sep 17 00:00:00 2001
From: da490c
Date: Thu, 22 Mar 2018 00:32:52 -0400
Subject: Convert Sparky to Spring-Boot
Issue-ID: AAI-599
Change-Id: If474dd02794f442fdddcd90f62fb75e0d6b907e7
Signed-off-by: da490c
---
.../inventory-ui-service/v1/conf/jaxrsBeans.groovy | 11 -
.../inventory-ui-service/v1/docs/README.txt | 1 -
.../inventory-ui-service/v1/lib/README.txt | 1 -
.../inventory-ui-service/v1/props/module.props | 1 -
.../inventory-ui-service/v1/routes/README.txt | 1 -
src/main/assemble/ajsc_module_assembly.xml | 69 -
src/main/assemble/ajsc_props_assembly.xml | 26 -
src/main/assemble/ajsc_runtime_assembly.xml | 47 -
src/main/config/aaiEntityNodeDescriptors.json | 218 ---
src/main/config/ajsc-chef.jks | Bin 5256 -> 0 bytes
src/main/config/ajsc-jetty.xml | 128 --
src/main/config/ajsc-override-web.xml | 52 -
src/main/config/ajscJetty.jks | Bin 3736 -> 0 bytes
src/main/config/autoSuggestMappings.json | 10 -
src/main/config/autoSuggestSettings.json | 21 -
src/main/config/cadi.properties | 36 -
src/main/config/csp-cookie-filter.properties | 18 -
src/main/config/dynamicMappings.json | 14 -
src/main/config/entityCountHistoryMappings.json | 16 -
src/main/config/es_mappings.json | 32 -
src/main/config/es_settings.json | 36 -
src/main/config/es_sv_mappings.json | 36 -
src/main/config/es_sv_settings.json | 36 -
src/main/config/jul-redirect.properties | 13 -
src/main/config/keyfile | 27 -
src/main/config/runner-web.xml | 95 --
src/main/docker/Dockerfile | 27 -
src/main/java/org/onap/aai/sparky/HelloWorld.java | 44 -
.../java/org/onap/aai/sparky/JaxrsEchoService.java | 78 -
.../java/org/onap/aai/sparky/JaxrsUserService.java | 59 -
src/main/java/org/onap/aai/sparky/Test.java | 25 -
.../search/AggregateSummaryProcessor.java | 209 ---
.../search/AggregateVnfSearchProvider.java | 172 ---
.../aggregatevnf/search/VnfSearchQueryBuilder.java | 168 --
.../sync/AggregationSyncControllerFactory.java | 234 ---
.../aggregation/sync/AggregationSynchronizer.java | 778 ----------
.../sync/HistoricalEntitySummarizer.java | 380 -----
.../sync/HistoricalEntitySyncController.java | 90 --
.../aai/sparky/analytics/AbstractStatistics.java | 174 ---
.../aai/sparky/analytics/AveragingRingBuffer.java | 117 --
.../aai/sparky/analytics/ComponentStatistics.java | 76 -
.../aai/sparky/analytics/HistogramSampler.java | 282 ----
.../aai/sparky/analytics/HistoricalCounter.java | 173 ---
.../sync/AutoSuggestionSyncController.java | 99 --
.../sync/AutosuggestionSynchronizer.java | 772 ----------
.../sync/VnfAliasSuggestionSynchronizer.java | 193 ---
.../sync/VnfAliasSyncController.java | 94 --
.../common/search/CommonSearchSuggestion.java | 86 --
.../sparky/config/oxm/CrossEntityReference.java | 74 -
.../config/oxm/CrossEntityReferenceDescriptor.java | 63 -
.../config/oxm/CrossEntityReferenceLookup.java | 132 --
.../aai/sparky/config/oxm/GeoEntityDescriptor.java | 57 -
.../aai/sparky/config/oxm/GeoEntityLookup.java | 133 --
.../sparky/config/oxm/GeoOxmEntityDescriptor.java | 67 -
.../aai/sparky/config/oxm/OxmEntityDescriptor.java | 64 -
.../aai/sparky/config/oxm/OxmEntityLookup.java | 128 --
.../onap/aai/sparky/config/oxm/OxmModelLoader.java | 191 ---
.../aai/sparky/config/oxm/OxmModelProcessor.java | 29 -
.../sparky/config/oxm/SearchableEntityLookup.java | 115 --
.../config/oxm/SearchableOxmEntityDescriptor.java | 71 -
.../config/oxm/SuggestionEntityDescriptor.java | 50 -
.../sparky/config/oxm/SuggestionEntityLookup.java | 177 ---
.../sync/CrossEntityReferenceSynchronizer.java | 933 -----------
.../aai/sparky/dal/ActiveInventoryAdapter.java | 400 -----
.../onap/aai/sparky/dal/ElasticSearchAdapter.java | 153 --
.../java/org/onap/aai/sparky/dal/GizmoAdapter.java | 332 ----
.../onap/aai/sparky/dal/NetworkTransaction.java | 155 --
.../dal/aai/ActiveInventoryEntityStatistics.java | 281 ----
...tiveInventoryProcessingExceptionStatistics.java | 135 --
.../ElasticSearchEntityStatistics.java | 261 ----
.../sparky/dal/elasticsearch/SearchAdapter.java | 113 --
.../exception/ElasticSearchOperationException.java | 49 -
.../dal/proxy/processor/AaiUiProxyProcessor.java | 203 ---
.../org/onap/aai/sparky/dal/rest/HttpMethod.java | 29 -
.../dal/rest/RestClientConstructionException.java | 34 -
.../aai/sparky/dal/rest/RestClientFactory.java | 92 --
.../sparky/dal/rest/RestOperationalStatistics.java | 251 ---
.../sparky/dal/rest/config/RestEndpointConfig.java | 165 --
.../sparky/dal/sas/config/SearchServiceConfig.java | 219 ---
.../editattributes/AttributeEditProcessor.java | 178 ---
.../sparky/editattributes/AttributeUpdater.java | 358 -----
.../editattributes/UserAuthorizationReader.java | 75 -
.../aai/sparky/editattributes/UserValidator.java | 63 -
.../sparky/editattributes/entity/EditRequest.java | 65 -
.../exception/AttributeUpdateException.java | 58 -
.../inventory/EntityHistoryQueryBuilder.java | 139 --
.../inventory/GeoVisualizationProcessor.java | 176 ---
.../sparky/inventory/entity/GeoIndexDocument.java | 285 ----
.../inventory/entity/TopographicalEntity.java | 215 ---
.../org/onap/aai/sparky/logging/AaiUiMsgs.java | 468 ------
.../onap/aai/sparky/logging/util/LoggingUtils.java | 39 -
.../onap/aai/sparky/logging/util/ServletUtils.java | 158 --
.../sparky/search/EntityCountHistoryProcessor.java | 403 -----
.../onap/aai/sparky/search/EntityTypeSummary.java | 49 -
.../aai/sparky/search/EntityTypeSummaryBucket.java | 42 -
.../aai/sparky/search/SearchEntityProperties.java | 45 -
.../org/onap/aai/sparky/search/SearchResponse.java | 98 --
.../aai/sparky/search/SearchServiceAdapter.java | 147 --
.../aai/sparky/search/UnifiedSearchProcessor.java | 208 ---
.../onap/aai/sparky/search/api/SearchProvider.java | 32 -
.../aai/sparky/search/config/SuggestionConfig.java | 72 -
.../sparky/search/entity/QuerySearchEntity.java | 69 -
.../aai/sparky/search/entity/SearchSuggestion.java | 35 -
.../search/filters/FilterElasticSearchAdapter.java | 115 --
.../aai/sparky/search/filters/FilterProcessor.java | 134 --
.../sparky/search/filters/FilterQueryBuilder.java | 214 ---
.../search/filters/FilteredSearchHelper.java | 154 --
.../search/filters/UiFiltersEntityConverter.java | 176 ---
.../search/filters/config/FiltersConfig.java | 137 --
.../filters/config/FiltersDetailsConfig.java | 54 -
.../filters/config/FiltersForViewsConfig.java | 53 -
.../search/filters/config/UiFilterConfig.java | 184 ---
.../filters/config/UiFilterDataSourceConfig.java | 95 --
.../filters/config/UiFilterListItemConfig.java | 66 -
.../config/UiFilterOptionsValuesConfig.java | 64 -
.../filters/config/UiViewListItemConfig.java | 64 -
.../search/filters/entity/AggregationEntity.java | 76 -
.../search/filters/entity/BoolQueryBuilder.java | 119 --
.../entity/FilteredAggregationQueryBuilder.java | 61 -
.../filters/entity/MatchFilterCriteriaEntity.java | 73 -
.../sparky/search/filters/entity/SearchFilter.java | 84 -
.../search/filters/entity/UiFilterEntity.java | 176 ---
.../search/filters/entity/UiFilterValueEntity.java | 76 -
.../search/filters/entity/UiFiltersEntity.java | 49 -
.../search/registry/SearchProviderRegistry.java | 72 -
.../aai/sparky/security/BaseCookieDecryptor.java | 47 -
.../onap/aai/sparky/security/CookieDecryptor.java | 27 -
.../org/onap/aai/sparky/security/EcompSso.java | 151 --
.../sparky/security/SecurityContextFactory.java | 74 -
.../security/SecurityContextFactoryImpl.java | 201 ---
.../sparky/security/filter/CspCookieFilter.java | 263 ----
.../aai/sparky/security/filter/LoginFilter.java | 232 ---
.../security/portal/PortalRestAPIServiceImpl.java | 209 ---
.../aai/sparky/security/portal/UserManager.java | 166 --
.../portal/config/PortalAuthenticationConfig.java | 120 --
.../sparky/security/portal/config/RolesConfig.java | 86 --
.../subscription/SubscriptionServiceProcessor.java | 102 --
.../subscription/config/SubscriptionConfig.java | 135 --
.../subscription/payload/entity/Message.java | 56 -
.../payload/entity/ObjectInspectorPayload.java | 124 --
.../sparky/subscription/payload/entity/Params.java | 56 -
.../subscription/payload/entity/Payload.java | 56 -
.../subscription/services/SubscriptionService.java | 61 -
.../sparky/sync/AbstractEntitySynchronizer.java | 520 -------
.../aai/sparky/sync/ElasticSearchIndexCleaner.java | 600 --------
.../sparky/sync/ElasticSearchSchemaFactory.java | 106 --
.../org/onap/aai/sparky/sync/IndexCleaner.java | 53 -
.../aai/sparky/sync/IndexIntegrityValidator.java | 174 ---
.../onap/aai/sparky/sync/IndexSynchronizer.java | 63 -
.../org/onap/aai/sparky/sync/IndexValidator.java | 54 -
.../org/onap/aai/sparky/sync/SyncController.java | 92 --
.../onap/aai/sparky/sync/SyncControllerImpl.java | 676 --------
.../aai/sparky/sync/SyncControllerRegistrar.java | 25 -
.../aai/sparky/sync/SyncControllerRegistry.java | 46 -
.../aai/sparky/sync/SyncControllerService.java | 218 ---
.../aai/sparky/sync/SynchronizerConstants.java | 61 -
.../onap/aai/sparky/sync/TaskProcessingStats.java | 131 --
.../aai/sparky/sync/TransactionRateMonitor.java | 71 -
.../sync/config/ElasticSearchEndpointConfig.java | 68 -
.../sync/config/ElasticSearchSchemaConfig.java | 73 -
.../sync/config/NetworkStatisticsConfig.java | 235 ---
.../sparky/sync/config/SyncControllerConfig.java | 301 ----
.../aai/sparky/sync/entity/AggregationEntity.java | 95 --
.../sync/entity/AggregationSuggestionEntity.java | 107 --
.../onap/aai/sparky/sync/entity/IndexDocument.java | 37 -
.../sync/entity/IndexableCrossEntityReference.java | 93 --
.../aai/sparky/sync/entity/IndexableEntity.java | 96 --
.../aai/sparky/sync/entity/MergableEntity.java | 55 -
.../aai/sparky/sync/entity/ObjectIdCollection.java | 74 -
.../aai/sparky/sync/entity/SearchableEntity.java | 138 --
.../aai/sparky/sync/entity/SelfLinkDescriptor.java | 86 --
.../sparky/sync/entity/SuggestionSearchEntity.java | 323 ----
.../sparky/sync/entity/TransactionStorageType.java | 52 -
.../sparky/sync/enumeration/OperationState.java | 28 -
.../sparky/sync/enumeration/SynchronizerState.java | 28 -
.../sync/task/PerformActiveInventoryRetrieval.java | 93 --
.../sparky/sync/task/PerformElasticSearchPut.java | 86 --
.../sync/task/PerformElasticSearchRetrieval.java | 68 -
.../sync/task/PerformElasticSearchUpdate.java | 78 -
.../sparky/sync/task/PerformGizmoRetrieval.java | 91 --
.../aai/sparky/sync/task/StoreDocumentTask.java | 86 --
.../aai/sparky/sync/task/SyncControllerTask.java | 51 -
.../sparky/topology/sync/GeoSyncController.java | 96 --
.../aai/sparky/topology/sync/GeoSynchronizer.java | 483 ------
.../org/onap/aai/sparky/util/ConfigHelper.java | 189 ---
.../org/onap/aai/sparky/util/EncryptConvertor.java | 145 --
.../java/org/onap/aai/sparky/util/Encryptor.java | 151 --
.../java/org/onap/aai/sparky/util/ErrorUtil.java | 57 -
.../org/onap/aai/sparky/util/JsonXmlConverter.java | 75 -
.../java/org/onap/aai/sparky/util/NodeUtils.java | 892 -----------
.../org/onap/aai/sparky/util/RawByteHelper.java | 172 ---
.../org/onap/aai/sparky/util/RestletUtils.java | 115 --
.../aai/sparky/util/SuggestionsPermutation.java | 96 --
.../java/org/onap/aai/sparky/util/TreeWalker.java | 132 --
.../viewandinspect/EntityTypeAggregation.java | 57 -
.../SchemaVisualizationProcessor.java | 121 --
.../viewandinspect/config/SparkyConstants.java | 101 --
.../config/TierSupportUiConstants.java | 98 --
.../config/VisualizationConfigs.java | 158 --
.../viewandinspect/entity/ActiveInventoryNode.java | 827 ----------
.../entity/D3VisualizationOutput.java | 89 --
.../sparky/viewandinspect/entity/EntityEntry.java | 77 -
.../sparky/viewandinspect/entity/GizmoEntity.java | 94 --
.../entity/GizmoRelationshipEntity.java | 99 --
.../entity/GizmoRelationshipHint.java | 73 -
.../sparky/viewandinspect/entity/GraphMeta.java | 143 --
.../sparky/viewandinspect/entity/GraphRequest.java | 54 -
.../viewandinspect/entity/InlineMessage.java | 66 -
.../aai/sparky/viewandinspect/entity/JsonNode.java | 203 ---
.../sparky/viewandinspect/entity/JsonNodeLink.java | 73 -
.../sparky/viewandinspect/entity/NodeDebug.java | 55 -
.../aai/sparky/viewandinspect/entity/NodeMeta.java | 203 ---
.../entity/NodeProcessingTransaction.java | 105 --
.../sparky/viewandinspect/entity/QueryParams.java | 53 -
.../sparky/viewandinspect/entity/QueryRequest.java | 43 -
.../viewandinspect/entity/RelatedToProperty.java | 60 -
.../sparky/viewandinspect/entity/Relationship.java | 92 --
.../viewandinspect/entity/RelationshipData.java | 59 -
.../entity/RelationshipDirectionality.java | 38 -
.../viewandinspect/entity/RelationshipList.java | 53 -
.../entity/SearchableEntityList.java | 112 --
.../entity/SelfLinkDeterminationTransaction.java | 76 -
.../viewandinspect/entity/SparkyGraphLink.java | 71 -
.../viewandinspect/entity/SparkyGraphNode.java | 244 ---
.../enumeration/NodeProcessingAction.java | 32 -
.../enumeration/NodeProcessingState.java | 27 -
.../search/ViewInspectSearchProvider.java | 422 -----
.../services/BaseGizmoVisualizationContext.java | 986 ------------
.../services/BaseVisualizationContext.java | 1627 --------------------
.../services/BaseVisualizationService.java | 378 -----
.../services/VisualizationContext.java | 51 -
.../services/VisualizationService.java | 48 -
.../services/VisualizationTransformer.java | 292 ----
.../PerformGizmoNodeSelfLinkProcessingTask.java | 124 --
.../task/PerformNodeSelfLinkProcessingTask.java | 125 --
.../task/PerformSelfLinkDeterminationTask.java | 91 --
.../sync/ViewInspectEntitySynchronizer.java | 774 ----------
.../sync/ViewInspectSyncController.java | 117 --
src/main/resources/authentication/tomcat_keystore | Bin 7201 -> 0 bytes
src/main/resources/extApps/aai.xml | 8 -
src/main/resources/logging/AAIUIMsgs.properties | 901 -----------
...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 -
src/main/runtime/shiroUser/ajsc.json | 1 -
src/main/runtime/shiroUserRole/ajsc#ajscadmin.json | 1 -
...ontextadmin#__module.ajsc.namespace.name__.json | 1 -
.../shiroUserRole/ajsc#contextadmin#default.json | 1 -
src/main/scripts/encNameValue.sh | 20 -
src/main/scripts/start.sh | 99 --
253 files changed, 36034 deletions(-)
delete mode 100644 src/main/ajsc/inventory-ui-service_v1/inventory-ui-service/v1/conf/jaxrsBeans.groovy
delete mode 100644 src/main/ajsc/inventory-ui-service_v1/inventory-ui-service/v1/docs/README.txt
delete mode 100644 src/main/ajsc/inventory-ui-service_v1/inventory-ui-service/v1/lib/README.txt
delete mode 100644 src/main/ajsc/inventory-ui-service_v1/inventory-ui-service/v1/props/module.props
delete mode 100644 src/main/ajsc/inventory-ui-service_v1/inventory-ui-service/v1/routes/README.txt
delete mode 100644 src/main/assemble/ajsc_module_assembly.xml
delete mode 100644 src/main/assemble/ajsc_props_assembly.xml
delete mode 100644 src/main/assemble/ajsc_runtime_assembly.xml
delete mode 100644 src/main/config/aaiEntityNodeDescriptors.json
delete mode 100644 src/main/config/ajsc-chef.jks
delete mode 100644 src/main/config/ajsc-jetty.xml
delete mode 100644 src/main/config/ajsc-override-web.xml
delete mode 100644 src/main/config/ajscJetty.jks
delete mode 100644 src/main/config/autoSuggestMappings.json
delete mode 100644 src/main/config/autoSuggestSettings.json
delete mode 100644 src/main/config/cadi.properties
delete mode 100644 src/main/config/csp-cookie-filter.properties
delete mode 100644 src/main/config/dynamicMappings.json
delete mode 100644 src/main/config/entityCountHistoryMappings.json
delete mode 100644 src/main/config/es_mappings.json
delete mode 100644 src/main/config/es_settings.json
delete mode 100644 src/main/config/es_sv_mappings.json
delete mode 100644 src/main/config/es_sv_settings.json
delete mode 100644 src/main/config/jul-redirect.properties
delete mode 100644 src/main/config/keyfile
delete mode 100644 src/main/config/runner-web.xml
delete mode 100644 src/main/docker/Dockerfile
delete mode 100644 src/main/java/org/onap/aai/sparky/HelloWorld.java
delete mode 100644 src/main/java/org/onap/aai/sparky/JaxrsEchoService.java
delete mode 100644 src/main/java/org/onap/aai/sparky/JaxrsUserService.java
delete mode 100644 src/main/java/org/onap/aai/sparky/Test.java
delete mode 100644 src/main/java/org/onap/aai/sparky/aggregatevnf/search/AggregateSummaryProcessor.java
delete mode 100644 src/main/java/org/onap/aai/sparky/aggregatevnf/search/AggregateVnfSearchProvider.java
delete mode 100644 src/main/java/org/onap/aai/sparky/aggregatevnf/search/VnfSearchQueryBuilder.java
delete mode 100644 src/main/java/org/onap/aai/sparky/aggregation/sync/AggregationSyncControllerFactory.java
delete mode 100644 src/main/java/org/onap/aai/sparky/aggregation/sync/AggregationSynchronizer.java
delete mode 100644 src/main/java/org/onap/aai/sparky/aggregation/sync/HistoricalEntitySummarizer.java
delete mode 100644 src/main/java/org/onap/aai/sparky/aggregation/sync/HistoricalEntitySyncController.java
delete mode 100644 src/main/java/org/onap/aai/sparky/analytics/AbstractStatistics.java
delete mode 100644 src/main/java/org/onap/aai/sparky/analytics/AveragingRingBuffer.java
delete mode 100644 src/main/java/org/onap/aai/sparky/analytics/ComponentStatistics.java
delete mode 100644 src/main/java/org/onap/aai/sparky/analytics/HistogramSampler.java
delete mode 100644 src/main/java/org/onap/aai/sparky/analytics/HistoricalCounter.java
delete mode 100644 src/main/java/org/onap/aai/sparky/autosuggestion/sync/AutoSuggestionSyncController.java
delete mode 100644 src/main/java/org/onap/aai/sparky/autosuggestion/sync/AutosuggestionSynchronizer.java
delete mode 100644 src/main/java/org/onap/aai/sparky/autosuggestion/sync/VnfAliasSuggestionSynchronizer.java
delete mode 100644 src/main/java/org/onap/aai/sparky/autosuggestion/sync/VnfAliasSyncController.java
delete mode 100644 src/main/java/org/onap/aai/sparky/common/search/CommonSearchSuggestion.java
delete mode 100644 src/main/java/org/onap/aai/sparky/config/oxm/CrossEntityReference.java
delete mode 100644 src/main/java/org/onap/aai/sparky/config/oxm/CrossEntityReferenceDescriptor.java
delete mode 100644 src/main/java/org/onap/aai/sparky/config/oxm/CrossEntityReferenceLookup.java
delete mode 100644 src/main/java/org/onap/aai/sparky/config/oxm/GeoEntityDescriptor.java
delete mode 100644 src/main/java/org/onap/aai/sparky/config/oxm/GeoEntityLookup.java
delete mode 100644 src/main/java/org/onap/aai/sparky/config/oxm/GeoOxmEntityDescriptor.java
delete mode 100644 src/main/java/org/onap/aai/sparky/config/oxm/OxmEntityDescriptor.java
delete mode 100644 src/main/java/org/onap/aai/sparky/config/oxm/OxmEntityLookup.java
delete mode 100644 src/main/java/org/onap/aai/sparky/config/oxm/OxmModelLoader.java
delete mode 100644 src/main/java/org/onap/aai/sparky/config/oxm/OxmModelProcessor.java
delete mode 100644 src/main/java/org/onap/aai/sparky/config/oxm/SearchableEntityLookup.java
delete mode 100644 src/main/java/org/onap/aai/sparky/config/oxm/SearchableOxmEntityDescriptor.java
delete mode 100644 src/main/java/org/onap/aai/sparky/config/oxm/SuggestionEntityDescriptor.java
delete mode 100644 src/main/java/org/onap/aai/sparky/config/oxm/SuggestionEntityLookup.java
delete mode 100644 src/main/java/org/onap/aai/sparky/crossentityreference/sync/CrossEntityReferenceSynchronizer.java
delete mode 100644 src/main/java/org/onap/aai/sparky/dal/ActiveInventoryAdapter.java
delete mode 100644 src/main/java/org/onap/aai/sparky/dal/ElasticSearchAdapter.java
delete mode 100644 src/main/java/org/onap/aai/sparky/dal/GizmoAdapter.java
delete mode 100644 src/main/java/org/onap/aai/sparky/dal/NetworkTransaction.java
delete mode 100644 src/main/java/org/onap/aai/sparky/dal/aai/ActiveInventoryEntityStatistics.java
delete mode 100644 src/main/java/org/onap/aai/sparky/dal/aai/ActiveInventoryProcessingExceptionStatistics.java
delete mode 100644 src/main/java/org/onap/aai/sparky/dal/elasticsearch/ElasticSearchEntityStatistics.java
delete mode 100644 src/main/java/org/onap/aai/sparky/dal/elasticsearch/SearchAdapter.java
delete mode 100644 src/main/java/org/onap/aai/sparky/dal/exception/ElasticSearchOperationException.java
delete mode 100644 src/main/java/org/onap/aai/sparky/dal/proxy/processor/AaiUiProxyProcessor.java
delete mode 100644 src/main/java/org/onap/aai/sparky/dal/rest/HttpMethod.java
delete mode 100644 src/main/java/org/onap/aai/sparky/dal/rest/RestClientConstructionException.java
delete mode 100644 src/main/java/org/onap/aai/sparky/dal/rest/RestClientFactory.java
delete mode 100644 src/main/java/org/onap/aai/sparky/dal/rest/RestOperationalStatistics.java
delete mode 100644 src/main/java/org/onap/aai/sparky/dal/rest/config/RestEndpointConfig.java
delete mode 100644 src/main/java/org/onap/aai/sparky/dal/sas/config/SearchServiceConfig.java
delete mode 100644 src/main/java/org/onap/aai/sparky/editattributes/AttributeEditProcessor.java
delete mode 100644 src/main/java/org/onap/aai/sparky/editattributes/AttributeUpdater.java
delete mode 100644 src/main/java/org/onap/aai/sparky/editattributes/UserAuthorizationReader.java
delete mode 100644 src/main/java/org/onap/aai/sparky/editattributes/UserValidator.java
delete mode 100644 src/main/java/org/onap/aai/sparky/editattributes/entity/EditRequest.java
delete mode 100644 src/main/java/org/onap/aai/sparky/editattributes/exception/AttributeUpdateException.java
delete mode 100644 src/main/java/org/onap/aai/sparky/inventory/EntityHistoryQueryBuilder.java
delete mode 100644 src/main/java/org/onap/aai/sparky/inventory/GeoVisualizationProcessor.java
delete mode 100644 src/main/java/org/onap/aai/sparky/inventory/entity/GeoIndexDocument.java
delete mode 100644 src/main/java/org/onap/aai/sparky/inventory/entity/TopographicalEntity.java
delete mode 100644 src/main/java/org/onap/aai/sparky/logging/AaiUiMsgs.java
delete mode 100644 src/main/java/org/onap/aai/sparky/logging/util/LoggingUtils.java
delete mode 100644 src/main/java/org/onap/aai/sparky/logging/util/ServletUtils.java
delete mode 100644 src/main/java/org/onap/aai/sparky/search/EntityCountHistoryProcessor.java
delete mode 100644 src/main/java/org/onap/aai/sparky/search/EntityTypeSummary.java
delete mode 100644 src/main/java/org/onap/aai/sparky/search/EntityTypeSummaryBucket.java
delete mode 100644 src/main/java/org/onap/aai/sparky/search/SearchEntityProperties.java
delete mode 100644 src/main/java/org/onap/aai/sparky/search/SearchResponse.java
delete mode 100644 src/main/java/org/onap/aai/sparky/search/SearchServiceAdapter.java
delete mode 100644 src/main/java/org/onap/aai/sparky/search/UnifiedSearchProcessor.java
delete mode 100644 src/main/java/org/onap/aai/sparky/search/api/SearchProvider.java
delete mode 100644 src/main/java/org/onap/aai/sparky/search/config/SuggestionConfig.java
delete mode 100644 src/main/java/org/onap/aai/sparky/search/entity/QuerySearchEntity.java
delete mode 100644 src/main/java/org/onap/aai/sparky/search/entity/SearchSuggestion.java
delete mode 100644 src/main/java/org/onap/aai/sparky/search/filters/FilterElasticSearchAdapter.java
delete mode 100644 src/main/java/org/onap/aai/sparky/search/filters/FilterProcessor.java
delete mode 100644 src/main/java/org/onap/aai/sparky/search/filters/FilterQueryBuilder.java
delete mode 100644 src/main/java/org/onap/aai/sparky/search/filters/FilteredSearchHelper.java
delete mode 100644 src/main/java/org/onap/aai/sparky/search/filters/UiFiltersEntityConverter.java
delete mode 100644 src/main/java/org/onap/aai/sparky/search/filters/config/FiltersConfig.java
delete mode 100644 src/main/java/org/onap/aai/sparky/search/filters/config/FiltersDetailsConfig.java
delete mode 100644 src/main/java/org/onap/aai/sparky/search/filters/config/FiltersForViewsConfig.java
delete mode 100644 src/main/java/org/onap/aai/sparky/search/filters/config/UiFilterConfig.java
delete mode 100644 src/main/java/org/onap/aai/sparky/search/filters/config/UiFilterDataSourceConfig.java
delete mode 100644 src/main/java/org/onap/aai/sparky/search/filters/config/UiFilterListItemConfig.java
delete mode 100644 src/main/java/org/onap/aai/sparky/search/filters/config/UiFilterOptionsValuesConfig.java
delete mode 100644 src/main/java/org/onap/aai/sparky/search/filters/config/UiViewListItemConfig.java
delete mode 100644 src/main/java/org/onap/aai/sparky/search/filters/entity/AggregationEntity.java
delete mode 100644 src/main/java/org/onap/aai/sparky/search/filters/entity/BoolQueryBuilder.java
delete mode 100644 src/main/java/org/onap/aai/sparky/search/filters/entity/FilteredAggregationQueryBuilder.java
delete mode 100644 src/main/java/org/onap/aai/sparky/search/filters/entity/MatchFilterCriteriaEntity.java
delete mode 100644 src/main/java/org/onap/aai/sparky/search/filters/entity/SearchFilter.java
delete mode 100644 src/main/java/org/onap/aai/sparky/search/filters/entity/UiFilterEntity.java
delete mode 100644 src/main/java/org/onap/aai/sparky/search/filters/entity/UiFilterValueEntity.java
delete mode 100644 src/main/java/org/onap/aai/sparky/search/filters/entity/UiFiltersEntity.java
delete mode 100644 src/main/java/org/onap/aai/sparky/search/registry/SearchProviderRegistry.java
delete mode 100644 src/main/java/org/onap/aai/sparky/security/BaseCookieDecryptor.java
delete mode 100644 src/main/java/org/onap/aai/sparky/security/CookieDecryptor.java
delete mode 100644 src/main/java/org/onap/aai/sparky/security/EcompSso.java
delete mode 100644 src/main/java/org/onap/aai/sparky/security/SecurityContextFactory.java
delete mode 100644 src/main/java/org/onap/aai/sparky/security/SecurityContextFactoryImpl.java
delete mode 100644 src/main/java/org/onap/aai/sparky/security/filter/CspCookieFilter.java
delete mode 100644 src/main/java/org/onap/aai/sparky/security/filter/LoginFilter.java
delete mode 100644 src/main/java/org/onap/aai/sparky/security/portal/PortalRestAPIServiceImpl.java
delete mode 100644 src/main/java/org/onap/aai/sparky/security/portal/UserManager.java
delete mode 100644 src/main/java/org/onap/aai/sparky/security/portal/config/PortalAuthenticationConfig.java
delete mode 100644 src/main/java/org/onap/aai/sparky/security/portal/config/RolesConfig.java
delete mode 100644 src/main/java/org/onap/aai/sparky/subscription/SubscriptionServiceProcessor.java
delete mode 100644 src/main/java/org/onap/aai/sparky/subscription/config/SubscriptionConfig.java
delete mode 100644 src/main/java/org/onap/aai/sparky/subscription/payload/entity/Message.java
delete mode 100644 src/main/java/org/onap/aai/sparky/subscription/payload/entity/ObjectInspectorPayload.java
delete mode 100644 src/main/java/org/onap/aai/sparky/subscription/payload/entity/Params.java
delete mode 100644 src/main/java/org/onap/aai/sparky/subscription/payload/entity/Payload.java
delete mode 100644 src/main/java/org/onap/aai/sparky/subscription/services/SubscriptionService.java
delete mode 100644 src/main/java/org/onap/aai/sparky/sync/AbstractEntitySynchronizer.java
delete mode 100644 src/main/java/org/onap/aai/sparky/sync/ElasticSearchIndexCleaner.java
delete mode 100644 src/main/java/org/onap/aai/sparky/sync/ElasticSearchSchemaFactory.java
delete mode 100644 src/main/java/org/onap/aai/sparky/sync/IndexCleaner.java
delete mode 100644 src/main/java/org/onap/aai/sparky/sync/IndexIntegrityValidator.java
delete mode 100644 src/main/java/org/onap/aai/sparky/sync/IndexSynchronizer.java
delete mode 100644 src/main/java/org/onap/aai/sparky/sync/IndexValidator.java
delete mode 100644 src/main/java/org/onap/aai/sparky/sync/SyncController.java
delete mode 100644 src/main/java/org/onap/aai/sparky/sync/SyncControllerImpl.java
delete mode 100644 src/main/java/org/onap/aai/sparky/sync/SyncControllerRegistrar.java
delete mode 100644 src/main/java/org/onap/aai/sparky/sync/SyncControllerRegistry.java
delete mode 100644 src/main/java/org/onap/aai/sparky/sync/SyncControllerService.java
delete mode 100644 src/main/java/org/onap/aai/sparky/sync/SynchronizerConstants.java
delete mode 100644 src/main/java/org/onap/aai/sparky/sync/TaskProcessingStats.java
delete mode 100644 src/main/java/org/onap/aai/sparky/sync/TransactionRateMonitor.java
delete mode 100644 src/main/java/org/onap/aai/sparky/sync/config/ElasticSearchEndpointConfig.java
delete mode 100644 src/main/java/org/onap/aai/sparky/sync/config/ElasticSearchSchemaConfig.java
delete mode 100644 src/main/java/org/onap/aai/sparky/sync/config/NetworkStatisticsConfig.java
delete mode 100644 src/main/java/org/onap/aai/sparky/sync/config/SyncControllerConfig.java
delete mode 100644 src/main/java/org/onap/aai/sparky/sync/entity/AggregationEntity.java
delete mode 100644 src/main/java/org/onap/aai/sparky/sync/entity/AggregationSuggestionEntity.java
delete mode 100644 src/main/java/org/onap/aai/sparky/sync/entity/IndexDocument.java
delete mode 100644 src/main/java/org/onap/aai/sparky/sync/entity/IndexableCrossEntityReference.java
delete mode 100644 src/main/java/org/onap/aai/sparky/sync/entity/IndexableEntity.java
delete mode 100644 src/main/java/org/onap/aai/sparky/sync/entity/MergableEntity.java
delete mode 100644 src/main/java/org/onap/aai/sparky/sync/entity/ObjectIdCollection.java
delete mode 100644 src/main/java/org/onap/aai/sparky/sync/entity/SearchableEntity.java
delete mode 100644 src/main/java/org/onap/aai/sparky/sync/entity/SelfLinkDescriptor.java
delete mode 100644 src/main/java/org/onap/aai/sparky/sync/entity/SuggestionSearchEntity.java
delete mode 100644 src/main/java/org/onap/aai/sparky/sync/entity/TransactionStorageType.java
delete mode 100644 src/main/java/org/onap/aai/sparky/sync/enumeration/OperationState.java
delete mode 100644 src/main/java/org/onap/aai/sparky/sync/enumeration/SynchronizerState.java
delete mode 100644 src/main/java/org/onap/aai/sparky/sync/task/PerformActiveInventoryRetrieval.java
delete mode 100644 src/main/java/org/onap/aai/sparky/sync/task/PerformElasticSearchPut.java
delete mode 100644 src/main/java/org/onap/aai/sparky/sync/task/PerformElasticSearchRetrieval.java
delete mode 100644 src/main/java/org/onap/aai/sparky/sync/task/PerformElasticSearchUpdate.java
delete mode 100644 src/main/java/org/onap/aai/sparky/sync/task/PerformGizmoRetrieval.java
delete mode 100644 src/main/java/org/onap/aai/sparky/sync/task/StoreDocumentTask.java
delete mode 100644 src/main/java/org/onap/aai/sparky/sync/task/SyncControllerTask.java
delete mode 100644 src/main/java/org/onap/aai/sparky/topology/sync/GeoSyncController.java
delete mode 100644 src/main/java/org/onap/aai/sparky/topology/sync/GeoSynchronizer.java
delete mode 100644 src/main/java/org/onap/aai/sparky/util/ConfigHelper.java
delete mode 100644 src/main/java/org/onap/aai/sparky/util/EncryptConvertor.java
delete mode 100644 src/main/java/org/onap/aai/sparky/util/Encryptor.java
delete mode 100644 src/main/java/org/onap/aai/sparky/util/ErrorUtil.java
delete mode 100644 src/main/java/org/onap/aai/sparky/util/JsonXmlConverter.java
delete mode 100644 src/main/java/org/onap/aai/sparky/util/NodeUtils.java
delete mode 100644 src/main/java/org/onap/aai/sparky/util/RawByteHelper.java
delete mode 100644 src/main/java/org/onap/aai/sparky/util/RestletUtils.java
delete mode 100644 src/main/java/org/onap/aai/sparky/util/SuggestionsPermutation.java
delete mode 100644 src/main/java/org/onap/aai/sparky/util/TreeWalker.java
delete mode 100644 src/main/java/org/onap/aai/sparky/viewandinspect/EntityTypeAggregation.java
delete mode 100644 src/main/java/org/onap/aai/sparky/viewandinspect/SchemaVisualizationProcessor.java
delete mode 100644 src/main/java/org/onap/aai/sparky/viewandinspect/config/SparkyConstants.java
delete mode 100644 src/main/java/org/onap/aai/sparky/viewandinspect/config/TierSupportUiConstants.java
delete mode 100644 src/main/java/org/onap/aai/sparky/viewandinspect/config/VisualizationConfigs.java
delete mode 100644 src/main/java/org/onap/aai/sparky/viewandinspect/entity/ActiveInventoryNode.java
delete mode 100644 src/main/java/org/onap/aai/sparky/viewandinspect/entity/D3VisualizationOutput.java
delete mode 100644 src/main/java/org/onap/aai/sparky/viewandinspect/entity/EntityEntry.java
delete mode 100644 src/main/java/org/onap/aai/sparky/viewandinspect/entity/GizmoEntity.java
delete mode 100644 src/main/java/org/onap/aai/sparky/viewandinspect/entity/GizmoRelationshipEntity.java
delete mode 100644 src/main/java/org/onap/aai/sparky/viewandinspect/entity/GizmoRelationshipHint.java
delete mode 100644 src/main/java/org/onap/aai/sparky/viewandinspect/entity/GraphMeta.java
delete mode 100644 src/main/java/org/onap/aai/sparky/viewandinspect/entity/GraphRequest.java
delete mode 100644 src/main/java/org/onap/aai/sparky/viewandinspect/entity/InlineMessage.java
delete mode 100644 src/main/java/org/onap/aai/sparky/viewandinspect/entity/JsonNode.java
delete mode 100644 src/main/java/org/onap/aai/sparky/viewandinspect/entity/JsonNodeLink.java
delete mode 100644 src/main/java/org/onap/aai/sparky/viewandinspect/entity/NodeDebug.java
delete mode 100644 src/main/java/org/onap/aai/sparky/viewandinspect/entity/NodeMeta.java
delete mode 100644 src/main/java/org/onap/aai/sparky/viewandinspect/entity/NodeProcessingTransaction.java
delete mode 100644 src/main/java/org/onap/aai/sparky/viewandinspect/entity/QueryParams.java
delete mode 100644 src/main/java/org/onap/aai/sparky/viewandinspect/entity/QueryRequest.java
delete mode 100644 src/main/java/org/onap/aai/sparky/viewandinspect/entity/RelatedToProperty.java
delete mode 100644 src/main/java/org/onap/aai/sparky/viewandinspect/entity/Relationship.java
delete mode 100644 src/main/java/org/onap/aai/sparky/viewandinspect/entity/RelationshipData.java
delete mode 100644 src/main/java/org/onap/aai/sparky/viewandinspect/entity/RelationshipDirectionality.java
delete mode 100644 src/main/java/org/onap/aai/sparky/viewandinspect/entity/RelationshipList.java
delete mode 100644 src/main/java/org/onap/aai/sparky/viewandinspect/entity/SearchableEntityList.java
delete mode 100644 src/main/java/org/onap/aai/sparky/viewandinspect/entity/SelfLinkDeterminationTransaction.java
delete mode 100644 src/main/java/org/onap/aai/sparky/viewandinspect/entity/SparkyGraphLink.java
delete mode 100644 src/main/java/org/onap/aai/sparky/viewandinspect/entity/SparkyGraphNode.java
delete mode 100644 src/main/java/org/onap/aai/sparky/viewandinspect/enumeration/NodeProcessingAction.java
delete mode 100644 src/main/java/org/onap/aai/sparky/viewandinspect/enumeration/NodeProcessingState.java
delete mode 100644 src/main/java/org/onap/aai/sparky/viewandinspect/search/ViewInspectSearchProvider.java
delete mode 100644 src/main/java/org/onap/aai/sparky/viewandinspect/services/BaseGizmoVisualizationContext.java
delete mode 100644 src/main/java/org/onap/aai/sparky/viewandinspect/services/BaseVisualizationContext.java
delete mode 100644 src/main/java/org/onap/aai/sparky/viewandinspect/services/BaseVisualizationService.java
delete mode 100644 src/main/java/org/onap/aai/sparky/viewandinspect/services/VisualizationContext.java
delete mode 100644 src/main/java/org/onap/aai/sparky/viewandinspect/services/VisualizationService.java
delete mode 100644 src/main/java/org/onap/aai/sparky/viewandinspect/services/VisualizationTransformer.java
delete mode 100644 src/main/java/org/onap/aai/sparky/viewandinspect/task/PerformGizmoNodeSelfLinkProcessingTask.java
delete mode 100644 src/main/java/org/onap/aai/sparky/viewandinspect/task/PerformNodeSelfLinkProcessingTask.java
delete mode 100644 src/main/java/org/onap/aai/sparky/viewandinspect/task/PerformSelfLinkDeterminationTask.java
delete mode 100644 src/main/java/org/onap/aai/sparky/viewinspect/sync/ViewInspectEntitySynchronizer.java
delete mode 100644 src/main/java/org/onap/aai/sparky/viewinspect/sync/ViewInspectSyncController.java
delete mode 100644 src/main/resources/authentication/tomcat_keystore
delete mode 100644 src/main/resources/extApps/aai.xml
delete mode 100644 src/main/resources/logging/AAIUIMsgs.properties
delete mode 100644 src/main/runtime/context/__module.ajsc.namespace.name__#__module.ajsc.namespace.version__.context
delete mode 100644 src/main/runtime/context/default#0.context
delete mode 100644 src/main/runtime/deploymentPackage/__module.ajsc.namespace.name__#__module.ajsc.namespace.version__.json
delete mode 100644 src/main/runtime/shiroRole/ajscadmin.json
delete mode 100644 src/main/runtime/shiroRole/contextadmin#__module.ajsc.namespace.name__.json
delete mode 100644 src/main/runtime/shiroRole/contextadmin#default.json
delete mode 100644 src/main/runtime/shiroUser/ajsc.json
delete mode 100644 src/main/runtime/shiroUserRole/ajsc#ajscadmin.json
delete mode 100644 src/main/runtime/shiroUserRole/ajsc#contextadmin#__module.ajsc.namespace.name__.json
delete mode 100644 src/main/runtime/shiroUserRole/ajsc#contextadmin#default.json
delete mode 100644 src/main/scripts/encNameValue.sh
delete mode 100644 src/main/scripts/start.sh
(limited to 'src/main')
diff --git a/src/main/ajsc/inventory-ui-service_v1/inventory-ui-service/v1/conf/jaxrsBeans.groovy b/src/main/ajsc/inventory-ui-service_v1/inventory-ui-service/v1/conf/jaxrsBeans.groovy
deleted file mode 100644
index da9b558..0000000
--- a/src/main/ajsc/inventory-ui-service_v1/inventory-ui-service/v1/conf/jaxrsBeans.groovy
+++ /dev/null
@@ -1,11 +0,0 @@
-beans{
- xmlns cxf: "http://camel.apache.org/schema/cxf"
- xmlns jaxrs: "http://cxf.apache.org/jaxrs"
- xmlns util: "http://www.springframework.org/schema/util"
-
- echoService(org.openecomp.sparky.JaxrsEchoService)
-
- util.list(id: 'jaxrsServices') {
- ref(bean:'echoService')
- }
-}
\ No newline at end of file
diff --git a/src/main/ajsc/inventory-ui-service_v1/inventory-ui-service/v1/docs/README.txt b/src/main/ajsc/inventory-ui-service_v1/inventory-ui-service/v1/docs/README.txt
deleted file mode 100644
index 3707179..0000000
--- a/src/main/ajsc/inventory-ui-service_v1/inventory-ui-service/v1/docs/README.txt
+++ /dev/null
@@ -1 +0,0 @@
-Place any docs here that you want to access within the ajsc upon deployment of your service.
diff --git a/src/main/ajsc/inventory-ui-service_v1/inventory-ui-service/v1/lib/README.txt b/src/main/ajsc/inventory-ui-service_v1/inventory-ui-service/v1/lib/README.txt
deleted file mode 100644
index 639e21b..0000000
--- a/src/main/ajsc/inventory-ui-service_v1/inventory-ui-service/v1/lib/README.txt
+++ /dev/null
@@ -1 +0,0 @@
-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/src/main/ajsc/inventory-ui-service_v1/inventory-ui-service/v1/props/module.props b/src/main/ajsc/inventory-ui-service_v1/inventory-ui-service/v1/props/module.props
deleted file mode 100644
index 17ebc08..0000000
--- a/src/main/ajsc/inventory-ui-service_v1/inventory-ui-service/v1/props/module.props
+++ /dev/null
@@ -1 +0,0 @@
-EXAMPLE.PROPERTY=EXAMLE_VALUE
\ No newline at end of file
diff --git a/src/main/ajsc/inventory-ui-service_v1/inventory-ui-service/v1/routes/README.txt b/src/main/ajsc/inventory-ui-service_v1/inventory-ui-service/v1/routes/README.txt
deleted file mode 100644
index a3997db..0000000
--- a/src/main/ajsc/inventory-ui-service_v1/inventory-ui-service/v1/routes/README.txt
+++ /dev/null
@@ -1 +0,0 @@
-Place any camel routes here that you want to access within the ajsc upon deployment of your service.
diff --git a/src/main/assemble/ajsc_module_assembly.xml b/src/main/assemble/ajsc_module_assembly.xml
deleted file mode 100644
index 359f792..0000000
--- a/src/main/assemble/ajsc_module_assembly.xml
+++ /dev/null
@@ -1,69 +0,0 @@
-
-
- ${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/src/main/assemble/ajsc_props_assembly.xml b/src/main/assemble/ajsc_props_assembly.xml
deleted file mode 100644
index 6ee4093..0000000
--- a/src/main/assemble/ajsc_props_assembly.xml
+++ /dev/null
@@ -1,26 +0,0 @@
-
-
- ${version}_properties
- false
-
- zip
-
-
-
- ${project.basedir}/target/versioned-ajsc/props
- ${module.ajsc.namespace.name}/${module.ajsc.namespace.version}/props/
-
- *.props
-
-
-
-
-
-
-
-
diff --git a/src/main/assemble/ajsc_runtime_assembly.xml b/src/main/assemble/ajsc_runtime_assembly.xml
deleted file mode 100644
index c86d265..0000000
--- a/src/main/assemble/ajsc_runtime_assembly.xml
+++ /dev/null
@@ -1,47 +0,0 @@
-
-
- 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/src/main/config/aaiEntityNodeDescriptors.json b/src/main/config/aaiEntityNodeDescriptors.json
deleted file mode 100644
index e72bab0..0000000
--- a/src/main/config/aaiEntityNodeDescriptors.json
+++ /dev/null
@@ -1,218 +0,0 @@
-{
- "generalNodeClass": {
- "class": "aai-entity-node general-node",
- "visualElements": [{
- "type": "circle",
- "class": "outer",
- "svgAttributes": {
- "r": "16"
- }
- },
- {
- "type": "circle",
- "class": "inner",
- "svgAttributes": {
- "r": "10"
- }
- },
- {
- "type": "text",
- "class": "id-type-label",
- "displayKey": "itemType",
- "shapeAttributes": {
- "offset": {
- "x": "0",
- "y": "33"
- }
- }
- },
- {
- "type": "text",
- "class": "id-value-label",
- "displayKey": "itemNameValue",
- "shapeAttributes": {
- "offset": {
- "x": "0",
- "y": "48"
- }
- }
- }]
- },
- "searchedNodeClass": {
- "class": "aai-entity-node search-node",
- "visualElements": [{
- "type": "circle",
- "class": "outer",
- "svgAttributes": {
- "r": "16"
- }
- },
- {
- "type": "circle",
- "class": "inner",
- "svgAttributes": {
- "r": "10"
- }
- },
- {
- "type": "text",
- "class": "id-type-label",
- "displayKey": "itemType",
- "shapeAttributes": {
- "offset": {
- "x": "0",
- "y": "33"
- }
- }
- },
- {
- "type": "text",
- "class": "id-value-label",
- "displayKey": "itemNameValue",
- "shapeAttributes": {
- "offset": {
- "x": "0",
- "y": "48"
- }
- }
- }]
- },
- "selectedSearchedNodeClass": {
- "class": "aai-entity-node selected-search-node",
- "visualElements": [{
- "type": "circle",
- "class": "outer",
- "svgAttributes": {
- "r": "31"
- }
- },
- {
- "type": "circle",
- "class": "inner",
- "svgAttributes": {
- "r": "20"
- }
- },
- {
- "type": "text",
- "class": "id-type-label",
- "displayKey": "itemType",
- "shapeAttributes": {
- "offset": {
- "x": "0",
- "y": "48"
- }
- }
- },
- {
- "type": "text",
- "class": "id-value-label",
- "displayKey": "itemNameValue",
- "shapeAttributes": {
- "offset": {
- "x": "0",
- "y": "63"
- }
- }
- },
- {
- "type": "button",
- "name": "icon_ellipses",
- "class": "node-button",
- "shapeAttributes": {
- "offset": {
- "x": "33",
- "y": "-35"
- }
- },
- "svgAttributes": {
- "className": "node-button",
- "r": "10"
- }
- },
- {
- "type": "button",
- "name": "icon_triangle_warning",
- "class": "node-button",
- "shapeAttributes": {
- "offset": {
- "x": "46",
- "y": "-12"
- }
- },
- "svgAttributes": {
- "className": "node-button",
- "r": "10"
- }
- }]
- },
- "selectedNodeClass": {
- "class": "aai-entity-node selected-node",
- "visualElements": [{
- "type": "circle",
- "class": "outer",
- "svgAttributes": {
- "r": "31"
- }
- },
- {
- "type": "circle",
- "class": "inner",
- "svgAttributes": {
- "r": "20"
- }
- },
- {
- "type": "text",
- "class": "id-type-label",
- "displayKey": "itemType",
- "shapeAttributes": {
- "offset": {
- "x": "0",
- "y": "48"
- }
- }
- },
- {
- "type": "text",
- "class": "id-value-label",
- "displayKey": "itemNameValue",
- "shapeAttributes": {
- "offset": {
- "x": "0",
- "y": "63"
- }
- }
- },
- {
- "type": "button",
- "name": "icon_ellipses",
- "class": "node-button",
- "shapeAttributes": {
- "offset": {
- "x": "33",
- "y": "-35"
- }
- },
- "svgAttributes": {
- "className": "node-button",
- "r": "10"
- }
- },
- {
- "type": "button",
- "name": "icon_triangle_warning",
- "class": "node-button",
- "shapeAttributes": {
- "offset": {
- "x": "46",
- "y": "-12"
- }
- },
- "svgAttributes": {
- "className": "node-button",
- "r": "10"
- }
- }]
- }
-}
\ No newline at end of file
diff --git a/src/main/config/ajsc-chef.jks b/src/main/config/ajsc-chef.jks
deleted file mode 100644
index aeca770..0000000
Binary files a/src/main/config/ajsc-chef.jks and /dev/null differ
diff --git a/src/main/config/ajsc-jetty.xml b/src/main/config/ajsc-jetty.xml
deleted file mode 100644
index 1e026cd..0000000
--- a/src/main/config/ajsc-jetty.xml
+++ /dev/null
@@ -1,128 +0,0 @@
-
-
-
-
-
-
-
- true
-
-
- /etc/runner-web.xml
- /etc/ajsc-override-web.xml
- true
-
-
- false
-
-
-
-
-
-
-
-
- -
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- /extApps
- 10
- true
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- /auth/inventory-ui-keystore
-
-
-
-
-
-
-
-
-
-
- false
- false
-
-
-
-
-
-
-
-
-
-
- -
-
- http/1.1
-
-
-
-
-
- -
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- 30000
-
-
-
-
-
-
-
-
- false
-
-
-
diff --git a/src/main/config/ajsc-override-web.xml b/src/main/config/ajsc-override-web.xml
deleted file mode 100644
index e267829..0000000
--- a/src/main/config/ajsc-override-web.xml
+++ /dev/null
@@ -1,52 +0,0 @@
-
-
-
-
-
- LoginFilter
- /*
-
-
-
- PortalRestAPIProxy
- /api/v2/*
-
-
-
- springSecurityFilterChain
- /*
-
-
-
- ManagementServlet
- /mgmt
-
-
-
- RestletServlet
- /rest/*
-
-
-
- CamelServlet
- /services/*
-
-
-
- jsp
- *.jsp
- *.jspf
- *.jspx
- *.xsp
- *.JSP
- *.JSPF
- *.JSPX
- *.XSP
-
-
- default
- /*
-
-
\ No newline at end of file
diff --git a/src/main/config/ajscJetty.jks b/src/main/config/ajscJetty.jks
deleted file mode 100644
index 48cdbff..0000000
Binary files a/src/main/config/ajscJetty.jks and /dev/null differ
diff --git a/src/main/config/autoSuggestMappings.json b/src/main/config/autoSuggestMappings.json
deleted file mode 100644
index 7857617..0000000
--- a/src/main/config/autoSuggestMappings.json
+++ /dev/null
@@ -1,10 +0,0 @@
-{
- "properties" : {
- "entity_suggest" : {
- "type" : "completion",
- "payloads" : true,
- "analyzer" : "custom_analyzer",
- "preserve_position_increments": false
- }
- }
-}
\ No newline at end of file
diff --git a/src/main/config/autoSuggestSettings.json b/src/main/config/autoSuggestSettings.json
deleted file mode 100644
index 4525be1..0000000
--- a/src/main/config/autoSuggestSettings.json
+++ /dev/null
@@ -1,21 +0,0 @@
-{
- "analysis": {
- "filter": {
- "eng_stop": {
- "type": "stop",
- "stopwords": "_english_"
- }
- },
- "analyzer": {
- "custom_analyzer": {
- "type": "custom",
- "tokenizer": "standard",
- "filter": [
- "lowercase",
- "asciifolding",
- "eng_stop"
- ]
- }
- }
- }
- }
\ No newline at end of file
diff --git a/src/main/config/cadi.properties b/src/main/config/cadi.properties
deleted file mode 100644
index 83a5ce0..0000000
--- a/src/main/config/cadi.properties
+++ /dev/null
@@ -1,36 +0,0 @@
-#This properties file is used for defining AAF properties related to the CADI framework. This file is used for running AAF framework
-
-#In order to test functionality of cadi-ajsc-plugin locally cross domain cookie. Cadi "should" find your hostname for you.
-#However, we have seen some situations where this fails. A Local testing
-#modification can include modifying your hosts file so that you can use "mywebserver.att.com" for your localhost in order
-#to test/verify GLO functionality locally. If you are on a Windows machine, you will already have a machine name associated with
-#it that will utilize an AT&T domain such as "sbc.com". You may need to add your domain to this as a comma separated list depending
-#upon your particular machine domain. This property is commented out as cadi SHOULD find your machine name. With version 1.2.1 of cadi,
-#it appears to resolve Mac machine names as well, now. But, this can be somewhat inconsistent depending on your specific working envrironment.
-hostname=mywebserver.att.com
-
-#Setting csp_domain to PROD will allow for testing using your attuid and password through GLO.
-csp_domain=PROD
-csp_devl_localhost=true
-
-basic_realm=csp.att.com
-#basic_realm=aaf.att.com
-basic_warn=TRUE
-
-cadi_loglevel=WARN
-cadi_keyfile=target/swm/package/nix/dist_files/appl/inventory-ui-service/etc/keyfile
-
-# Configure AAF
-#These are dummy values add appropriate values required
-aaf_url=url
-
-#AJSC - MECHID
-#These are dummy values add appropriate values required
-aaf_id=dummyid@ajsc.att.com
-aaf_password=enc:277edqJCjT0RlUI3BtbDQa-3Ha-CQGd
-aaf_timeout=5000
-aaf_clean_interval=30000
-aaf_user_expires=5000
-aaf_high_count=1000
-
-
diff --git a/src/main/config/csp-cookie-filter.properties b/src/main/config/csp-cookie-filter.properties
deleted file mode 100644
index e12109a..0000000
--- a/src/main/config/csp-cookie-filter.properties
+++ /dev/null
@@ -1,18 +0,0 @@
-# AT&T Global login page. This is the redirect URL
-# Production login page:
-# https://www.e-access.att.com/empsvcs/hrpinmgt/pagLogin/
-#
-# Test login page:
-# https://webtest.csp.att.com/empsvcs/hrpinmgt/pagLogin/
-global.login.url=https://www.e-access.att.com/empsvcs/hrpinmgt/pagLogin/
-
-# valid domains for open redirect
-redirect-domain=att.com,sbc.com,bls.com,cingular.net
-
-# MOTS ID of the application
-application.id=24153
-
-# Required by esGateKeeper. Valid values are:
-# DEVL - used during development
-# PROD - used in production
-gatekeeper.environment=PROD
\ No newline at end of file
diff --git a/src/main/config/dynamicMappings.json b/src/main/config/dynamicMappings.json
deleted file mode 100644
index 09a00ac..0000000
--- a/src/main/config/dynamicMappings.json
+++ /dev/null
@@ -1,14 +0,0 @@
-{
- "dynamic_templates": [
- {
- "strings": {
- "match_mapping_type": "string",
- "match": "*",
- "mapping": {
- "type": "string",
- "index": "not_analyzed"
- }
- }
- }
- ]
-}
\ No newline at end of file
diff --git a/src/main/config/entityCountHistoryMappings.json b/src/main/config/entityCountHistoryMappings.json
deleted file mode 100644
index 84e3aec..0000000
--- a/src/main/config/entityCountHistoryMappings.json
+++ /dev/null
@@ -1,16 +0,0 @@
-{
- "properties": {
- "count": {
- "type": "long"
- },
- "entityType": {
- "type": "string",
- "index": "not_analyzed"
- },
- "timestamp": {
- "type": "date",
- "format": "MMM d y HH:m:s||dd-MM-yyyy HH:mm:ss||yyyy-MM-dd'T'HH:mm:ss.SSSZZ||MM/dd/yyyy||yyyyMMdd'T'HHmmssZ"
- }
- }
-}
-
diff --git a/src/main/config/es_mappings.json b/src/main/config/es_mappings.json
deleted file mode 100644
index 216e3d9..0000000
--- a/src/main/config/es_mappings.json
+++ /dev/null
@@ -1,32 +0,0 @@
-{
- "properties": {
- "entityType": {
- "type": "string",
- "analyzer": "ngram_analyzer",
- "search_analyzer": "ngram_analyzer"
- },
- "entityPrimaryKeyValue": {
- "type": "string",
- "index": "not_analyzed"
- },
- "searchTagIDs": {
- "type": "string"
- },
- "searchTags": {
- "type": "string",
- "analyzer": "ngram_analyzer"
- },
- "crossEntityReferenceValues": {
- "type": "string",
- "analyzer": "ngram_analyzer"
- },
- "link": {
- "type": "string",
- "index": "not_analyzed"
- },
- "lastmodTimestamp": {
- "type": "date",
- "format": "MMM d y HH:m:s||dd-MM-yyyy HH:mm:ss||yyyy-MM-dd'T'HH:mm:ss.SSSZZ||yyyy-MM-dd HH:mm:ss||MM/dd/yyyy||yyyyMMdd'T'HHmmssZ"
- }
- }
-}
\ No newline at end of file
diff --git a/src/main/config/es_settings.json b/src/main/config/es_settings.json
deleted file mode 100644
index 21a357c..0000000
--- a/src/main/config/es_settings.json
+++ /dev/null
@@ -1,36 +0,0 @@
-{
- "analysis": {
- "filter": {
- "ngram_filter": {
- "type": "nGram",
- "min_gram": 1,
- "max_gram": 50,
- "token_chars": [
- "letter",
- "digit",
- "punctuation",
- "symbol"
- ]
- }
- },
- "analyzer": {
- "ngram_analyzer": {
- "type": "custom",
- "tokenizer": "whitespace",
- "filter": [
- "lowercase",
- "asciifolding",
- "ngram_filter"
- ]
- },
- "whitespace_analyzer": {
- "type": "custom",
- "tokenizer": "whitespace",
- "filter": [
- "lowercase",
- "asciifolding"
- ]
- }
- }
- }
-}
\ No newline at end of file
diff --git a/src/main/config/es_sv_mappings.json b/src/main/config/es_sv_mappings.json
deleted file mode 100644
index c964ca3..0000000
--- a/src/main/config/es_sv_mappings.json
+++ /dev/null
@@ -1,36 +0,0 @@
-{
- "properties": {
- "entityType": {
- "type": "string",
- "analyzer": "ngram_analyzer",
- "search_analyzer": "ngram_analyzer"
- },
- "entityPrimaryKeyValue": {
- "type": "string",
- "index": "not_analyzed"
- },
- "searchTagIDs": {
- "type": "string"
- },
- "searchTags": {
- "type": "string",
- "analyzer": "ngram_analyzer"
- },
- "perspectives" : {
- "type": "string",
- "index": "not_analyzed"
- },
- "crossEntityReferenceValues": {
- "type": "string",
- "analyzer": "ngram_analyzer"
- },
- "link": {
- "type": "string",
- "index": "not_analyzed"
- },
- "lastmodTimestamp": {
- "type": "date",
- "format": "MMM d y HH:m:s||dd-MM-yyyy HH:mm:ss||yyyy-MM-dd'T'HH:mm:ss.SSSZZ||yyyy-MM-dd HH:mm:ss||MM/dd/yyyy||yyyyMMdd'T'HHmmssZ"
- }
- }
-}
\ No newline at end of file
diff --git a/src/main/config/es_sv_settings.json b/src/main/config/es_sv_settings.json
deleted file mode 100644
index 21a357c..0000000
--- a/src/main/config/es_sv_settings.json
+++ /dev/null
@@ -1,36 +0,0 @@
-{
- "analysis": {
- "filter": {
- "ngram_filter": {
- "type": "nGram",
- "min_gram": 1,
- "max_gram": 50,
- "token_chars": [
- "letter",
- "digit",
- "punctuation",
- "symbol"
- ]
- }
- },
- "analyzer": {
- "ngram_analyzer": {
- "type": "custom",
- "tokenizer": "whitespace",
- "filter": [
- "lowercase",
- "asciifolding",
- "ngram_filter"
- ]
- },
- "whitespace_analyzer": {
- "type": "custom",
- "tokenizer": "whitespace",
- "filter": [
- "lowercase",
- "asciifolding"
- ]
- }
- }
- }
-}
\ No newline at end of file
diff --git a/src/main/config/jul-redirect.properties b/src/main/config/jul-redirect.properties
deleted file mode 100644
index 8b6624d..0000000
--- a/src/main/config/jul-redirect.properties
+++ /dev/null
@@ -1,13 +0,0 @@
-
-# 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/src/main/config/keyfile b/src/main/config/keyfile
deleted file mode 100644
index 882e86a..0000000
--- a/src/main/config/keyfile
+++ /dev/null
@@ -1,27 +0,0 @@
-ZuIwp0TkyVPDeX1Up-8JtkMWvjsCpoiu1_VKeWrtrvxunvAke8_tiFyHPPyb2nkhepFYj6tXzpfS
-rGz5XF_TH9NbsKaP8u0HV5clz2WriYQRvHS85vjY7hXxkpFuLb7zkLAPqTyIDpj7FiW61NzsRUAq
-TM8jH16jr7mBNnb56w24mNGOwznMPcIZKcjgZU1ekaPDFpWyhQElU7Y0q_94P_Gkk45r66Hj22sU
-OiOaaftmudZlswLw8-8Zaakqf2yW9HjMVfuYCwSodBHCW5rdB3Ctb5W36rnD_AQco3Ky2PgPmqvk
-QkJYuUHpbuDqVHqLOajlKSIGMTIqAIBg51fRaaONtD-Q5xzY8E5wO1YWTLKcP5tsNvUpzM8Wu3NS
-ynpGpUcvlTqWWsGzTbzOyamyKkdNdx97sSqjM25Zh1-ps48h6cddGYWpab7SUvqRCS11QBUyLTry
-2iwTEHMhHRIbo7PO99ALQfuq9gI1zKGfurJdvLBeBaFs5SCF0AiCZ3WcDO8Rv3HpxVZ2_ShbDxb0
-eMoO6SotXu51fj8Y3-WqsfZziQyEsHyqpg5uQ6yUtz01h5YHLEoVuotF1U4agmQR6kEkYk-wNOiZ
-v-8gaA9gtbLoAdKhuKFxQgQLNMf6GzVzZNujbmDzLoZAP_mXAv29aBPaf64Ugzv-Oa5GZdBgD-Xd
-_pahML-ionw99r0TnkpShYmDqMKhMdjaP3m87WIAZkIB-L-VTyKcEsJ4340VSzCOsv3waiM0S89u
-4cMcG5y-PLY8IoipIlLUPTWD3SjcQ9DV1Dt3T5KjdWLsj48D3W4K4e9PB8yxs0gtUjgVUR2_xEir
-G5eDO9Ac1eHFWGDFFP0SgG-TbHJUKlvy9mwLzmU0fC3xPjhqmIr-v0HxF7HN-tmb1LHDorno8tSN
-u7kUGcKSchIiFfvkd066crUb2mH7PnXTaWmAjyVj9VsBExFUYEdpHMAV4sAP9-RxZGDRt46UhrDK
-QZvvNhBVyOEjHPHWI4vl1r1v8HNH1_2jZu5DVJWyHWR56aCo1lhFH9_X6UAHUHbnXViDONZOVXlT
-9-WD0tk2zJGuwrhdZDAnPnAmjfwbwbpnr5Hmex1i1JiD7WVyP1kbfoej2TmdiYbxr9oBYaGQ29JI
-aHod7MQCLtvL1z5XgnDPLZ4y3_9SbqHKYbNa8UgZkTLF5EacGThYVFDLA9cbafHDtR1kMGE3vv4D
-EJ-0pAYTOGmKlVI7DwNyKsY9JTyudrxTqhOxi9jgcJNWiUaNe9yhL8Pyc2YBqUTTYhh_a2d1rvkZ
-0Gh1crviVxqBrIkRKaMRXZ4f1vDLz-3NvG_vwPOo8WRFo5nGmSdTw7CjBaigJ_cYCfDhoP11pEnw
-cndsZNcHs-v05LlxeIIMDD_f5Bvz-il_DLA4eK2HqgLdxh8ziSDl2azk14MJY4amzz6reEXUuKLV
-RsZGf_jbDGKhE2HuDQ5ovoLOi4OqE1oRuqh-dGxitrYouP2SN1l_1tCEMRth86FMV-6AQtZsvdUo
-y9MtQ7e35atjA8nHtgADlDTmJBKQiUHUsOZ77p1qp17HAFMovUkc739opfEYnKUn6Itpw5Ipm_Is
-ra6chJUfMpOFof5rb5OjqFAN27c_-mPo1lQU3ndYlKGh_n5V8ufX6v2Yri8WzOPf6hjVYotkmoMP
-NPAICDCB8W5ddBjsopzLVVEtaXDu9Qj6-zf77hT4iQ7rBd2Ner8iLqN3Kis0dvkNM3_uH8onau1G
-Y_YYw7PPSZyd2S_7Dd6G-IG4ayO6e5DD6oUwwekyiQI_3rTXNa_wldGxqW9u818010ekE4Qdlfcj
-beIn7fAeaOjReZ87hRgWyMs-EgTVHw8RL3yI_O6VvRTVRONRF1Y4C_-IYa8z-bfrwXx3BBd9TTgb
-EnS9wVOyC2OgUN6BhPLGLhxzkJ05nEjizXEc9t5EPYoSRwesajGGrrG_0-qWbuU5hKLPLkyeJLHb
-5HXOTVsrUR59Vov2M3_EswkxcImblox3k3VS2yihZMGyfqLzZIUXgd8ufkevKKU6DxwacGTb
\ No newline at end of file
diff --git a/src/main/config/runner-web.xml b/src/main/config/runner-web.xml
deleted file mode 100644
index 2e39e24..0000000
--- a/src/main/config/runner-web.xml
+++ /dev/null
@@ -1,95 +0,0 @@
-
-
-
-
-
- contextConfigLocation
- /WEB-INF/spring-servlet.xml,
- classpath:applicationContext.xml
-
-
-
-
- spring.profiles.default
- nooauth
-
-
-
- org.springframework.web.context.ContextLoaderListener
-
-
-
- PortalRestAPIProxy
- org.openecomp.portalsdk.core.onboarding.crossapi.PortalRestAPIProxy
-
-
-
- LoginFilter
- org.onap.aai.sparky.security.filter.LoginFilter
-
-
-
- ManagementServlet
- ajsc.ManagementServlet
-
-
-
- WriteableRequestFilter
- com.att.ajsc.csi.writeablerequestfilter.WriteableRequestFilter
-
-
-
- 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
-
-
-
-
-
-
-
- jsp
- org.apache.jasper.servlet.JspServlet
-
-
-
-
-
-
- default
- org.eclipse.jetty.servlet.DefaultServlet
-
- dirAllowed
- true
-
-
-
-
-
-
-
-
diff --git a/src/main/docker/Dockerfile b/src/main/docker/Dockerfile
deleted file mode 100644
index b97e621..0000000
--- a/src/main/docker/Dockerfile
+++ /dev/null
@@ -1,27 +0,0 @@
-FROM ubuntu:14.04
-
-ARG MICRO_HOME=/opt/app/sparky
-ARG BIN_HOME=$MICRO_HOME/bin
-
-RUN apt-get update
-
-# Install and setup java8
-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 install -y openjdk-8-jdk
-## Setup JAVA_HOME, this is useful for docker commandline
-ENV JAVA_HOME usr/lib/jvm/java-8-openjdk-amd64
-RUN export JAVA_HOME
-
-# Build up the deployment folder structure
-RUN mkdir -p $MICRO_HOME
-copy swm/package/nix/dist_files/appl/sparky-be/${project.version}/ $MICRO_HOME/
-RUN ls -la $BIN_HOME/
-RUN chmod 755 $BIN_HOME/*
-RUN ln -s /logs $MICRO_HOME/logs
-
-EXPOSE 8000 8000
-
-CMD tail -F -n0 /etc/hosts
-CMD /opt/app/sparky/bin/start.sh
-#CMD top
diff --git a/src/main/java/org/onap/aai/sparky/HelloWorld.java b/src/main/java/org/onap/aai/sparky/HelloWorld.java
deleted file mode 100644
index f71fa1d..0000000
--- a/src/main/java/org/onap/aai/sparky/HelloWorld.java
+++ /dev/null
@@ -1,44 +0,0 @@
-/**
- * ============LICENSE_START=======================================================
- * org.onap.aai
- * ================================================================================
- * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved.
- * Copyright © 2017-2018 Amdocs
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-package org.onap.aai.sparky;
-
-import org.apache.camel.Exchange;
-
-/**
- * The Class HelloWorld.
- */
-public class HelloWorld {
-
- /**
- * Instantiates a new hello world.
- */
- public HelloWorld() {}
-
- /**
- * Speak.
- *
- * @param exc the exc
- */
- public final void speak(Exchange exc) {
- exc.setOut(exc.getIn());
- exc.getOut().setBody("Hello World!");
- }
-}
diff --git a/src/main/java/org/onap/aai/sparky/JaxrsEchoService.java b/src/main/java/org/onap/aai/sparky/JaxrsEchoService.java
deleted file mode 100644
index 148ed52..0000000
--- a/src/main/java/org/onap/aai/sparky/JaxrsEchoService.java
+++ /dev/null
@@ -1,78 +0,0 @@
-/**
- * ============LICENSE_START=======================================================
- * org.onap.aai
- * ================================================================================
- * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved.
- * Copyright © 2017-2018 Amdocs
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-package org.onap.aai.sparky;
-
-import javax.ws.rs.GET;
-import javax.ws.rs.Path;
-import javax.ws.rs.PathParam;
-import javax.ws.rs.Produces;
-
-import com.att.ajsc.beans.PropertiesMapBean;
-import com.att.ajsc.filemonitor.AJSCPropertiesMap;
-
-
-/**
- * The Class JaxrsEchoService.
- */
-@Path("/jaxrs-services")
-public class JaxrsEchoService {
-
- /**
- * Ping.
- *
- * @param input the input
- * @return the string
- */
- @GET
- @Path("/echo/{input}")
- @Produces("text/plain")
- public String ping(@PathParam("input") String input) {
- return "Hello";
- }
-
- /**
- * Gets the property.
- *
- * @param fileName the file name
- * @param input the input
- * @return the property
- */
- @GET
- @Path("/property/{fileName}/{input:.*}")
- @Produces("text/plain")
- public String getProperty(@PathParam("fileName") String fileName,
- @PathParam("input") String input) {
- String val = null;
- try {
- val = AJSCPropertiesMap.getProperty(fileName, input);
- if (val == null || val.isEmpty() || val.length() < 1) {
- val = PropertiesMapBean.getProperty(fileName, input);
- }
- } catch (Exception ex) {
- System.out.println("*** Error retrieving property " + input + ": " + ex);
- }
- if (val == null) {
- return "Property is not available";
- }
- return "Property value is, " + val + ".";
- }
-
-}
diff --git a/src/main/java/org/onap/aai/sparky/JaxrsUserService.java b/src/main/java/org/onap/aai/sparky/JaxrsUserService.java
deleted file mode 100644
index a918a5f..0000000
--- a/src/main/java/org/onap/aai/sparky/JaxrsUserService.java
+++ /dev/null
@@ -1,59 +0,0 @@
-/**
- * ============LICENSE_START=======================================================
- * org.onap.aai
- * ================================================================================
- * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved.
- * Copyright © 2017-2018 Amdocs
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-package org.onap.aai.sparky;
-
-import java.util.HashMap;
-import java.util.Map;
-
-import javax.ws.rs.GET;
-import javax.ws.rs.Path;
-import javax.ws.rs.PathParam;
-import javax.ws.rs.Produces;
-
-/**
- * The Class JaxrsUserService.
- */
-@Path("/user")
-public class JaxrsUserService {
-
- private static final Map userIdToNameMap;
-
- static {
- userIdToNameMap = new HashMap();
- userIdToNameMap.put("dw113c", "Doug Wait");
- userIdToNameMap.put("so401q", "Stuart O'Day");
- }
-
- /**
- * 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/src/main/java/org/onap/aai/sparky/Test.java b/src/main/java/org/onap/aai/sparky/Test.java
deleted file mode 100644
index dfba83c..0000000
--- a/src/main/java/org/onap/aai/sparky/Test.java
+++ /dev/null
@@ -1,25 +0,0 @@
-/**
- * ============LICENSE_START=======================================================
- * org.onap.aai
- * ================================================================================
- * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved.
- * Copyright © 2017-2018 Amdocs
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-package org.onap.aai.sparky;
-
-public class Test {
-
-}
diff --git a/src/main/java/org/onap/aai/sparky/aggregatevnf/search/AggregateSummaryProcessor.java b/src/main/java/org/onap/aai/sparky/aggregatevnf/search/AggregateSummaryProcessor.java
deleted file mode 100644
index 941c1e5..0000000
--- a/src/main/java/org/onap/aai/sparky/aggregatevnf/search/AggregateSummaryProcessor.java
+++ /dev/null
@@ -1,209 +0,0 @@
-/**
- * ============LICENSE_START=======================================================
- * org.onap.aai
- * ================================================================================
- * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved.
- * Copyright © 2017-2018 Amdocs
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-package org.onap.aai.sparky.aggregatevnf.search;
-
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.List;
-
-import javax.json.JsonObject;
-
-import org.apache.camel.Exchange;
-import org.apache.camel.component.restlet.RestletConstants;
-import org.json.JSONArray;
-import org.json.JSONObject;
-import org.onap.aai.cl.api.Logger;
-import org.onap.aai.cl.eelf.LoggerFactory;
-import org.onap.aai.restclient.client.OperationResult;
-import org.onap.aai.sparky.dal.ElasticSearchAdapter;
-import org.onap.aai.sparky.logging.AaiUiMsgs;
-import org.onap.aai.sparky.search.filters.FilterQueryBuilder;
-import org.onap.aai.sparky.search.filters.config.FiltersConfig;
-import org.onap.aai.sparky.search.filters.entity.SearchFilter;
-import org.onap.aai.sparky.viewandinspect.config.SparkyConstants;
-import org.restlet.Request;
-import org.restlet.Response;
-import org.restlet.data.MediaType;
-import org.restlet.data.Status;
-
-public class AggregateSummaryProcessor {
-
- private static final Logger LOG =
- LoggerFactory.getInstance().getLogger(AggregateSummaryProcessor.class);
-
- private static final String KEY_FILTERS = "filters";
-
- private ElasticSearchAdapter elasticSearchAdapter = null;
-
- private String vnfAggregationIndexName;
- private FiltersConfig filtersConfig;
-
- public AggregateSummaryProcessor(ElasticSearchAdapter elasticSearchAdapter,
- FiltersConfig filtersConfig) {
- this.elasticSearchAdapter = elasticSearchAdapter;
- this.filtersConfig = filtersConfig;
- }
-
- public void setVnfAggregationIndexName(String vnfAggregationIndexName) {
- this.vnfAggregationIndexName = vnfAggregationIndexName;
- }
-
- public void getFilteredAggregation(Exchange exchange) {
-
- Response response =
- exchange.getIn().getHeader(RestletConstants.RESTLET_RESPONSE, Response.class);
-
- Request request = exchange.getIn().getHeader(RestletConstants.RESTLET_REQUEST, Request.class);
-
- /*
- * Disables automatic Apache Camel Restlet component logging which prints out an undesirable log
- * entry which includes client (e.g. browser) information
- */
- request.setLoggable(false);
-
- try {
- String payload = exchange.getIn().getBody(String.class);
-
- if (payload == null || payload.isEmpty()) {
-
- LOG.error(AaiUiMsgs.SEARCH_SERVLET_ERROR, "Request Payload is empty");
-
- /*
- * Don't throw back an error, just return an empty set
- */
-
- } else {
-
- JSONObject parameters = new JSONObject(payload);
-
- JSONArray requestFilters = null;
- if (parameters.has(KEY_FILTERS)) {
- requestFilters = parameters.getJSONArray(KEY_FILTERS);
- } else {
-
- JSONObject zeroResponsePayload = new JSONObject();
- zeroResponsePayload.put("count", 0);
- response.setStatus(Status.SUCCESS_OK);
- response.setEntity(zeroResponsePayload.toString(), MediaType.APPLICATION_JSON);
- exchange.getOut().setBody(response);
-
- LOG.error(AaiUiMsgs.ERROR_FILTERS_NOT_FOUND);
- return;
- }
-
- if (requestFilters != null && requestFilters.length() > 0) {
- List filtersToQuery = new ArrayList();
- for (int i = 0; i < requestFilters.length(); i++) {
- JSONObject filterEntry = requestFilters.getJSONObject(i);
- filtersToQuery.add(filterEntry);
- }
-
- String jsonResponsePayload = getVnfFilterAggregations(filtersToQuery);
- response.setStatus(Status.SUCCESS_OK);
- response.setEntity(jsonResponsePayload, MediaType.APPLICATION_JSON);
- exchange.getOut().setBody(response);
-
- } else {
- String emptyResponse = getEmptyAggResponse();
- response.setStatus(Status.SUCCESS_OK);
- response.setEntity(emptyResponse, MediaType.APPLICATION_JSON);
- exchange.getOut().setBody(response);
- LOG.error(AaiUiMsgs.ERROR_FILTERS_NOT_FOUND);
- }
- }
- } catch (Exception exc) {
- LOG.error(AaiUiMsgs.ERROR_GENERIC,
- "FilterProcessor failed to get filter list due to error = " + exc.getMessage());
- }
- }
-
- private String getEmptyAggResponse() {
- JSONObject aggPayload = new JSONObject();
- aggPayload.put("totalChartHits", 0);
- aggPayload.put("buckets", new JSONArray());
- JSONObject payload = new JSONObject();
- payload.append("groupby_aggregation", aggPayload);
-
- return payload.toString();
- }
-
- private static final String FILTER_ID_KEY = "filterId";
- private static final String FILTER_VALUE_KEY = "filterValue";
- private static final int DEFAULT_SHOULD_MATCH_SCORE = 1;
- private static final String VNF_FILTER_AGGREGATION = "vnfFilterAggregation";
-
- private String getVnfFilterAggregations(List filtersToQuery) throws IOException {
-
- List searchFilters = new ArrayList();
- for (JSONObject filterEntry : filtersToQuery) {
-
- String filterId = filterEntry.getString(FILTER_ID_KEY);
- if (filterId != null) {
- SearchFilter filter = new SearchFilter();
- filter.setFilterId(filterId);
-
- if (filterEntry.has(FILTER_VALUE_KEY)) {
- String filterValue = filterEntry.getString(FILTER_VALUE_KEY);
- filter.addValue(filterValue);
- }
-
- searchFilters.add(filter);
- }
- }
-
- // Create query for summary by entity type
- JsonObject vnfSearch = FilterQueryBuilder.createCombinedBoolAndAggQuery(filtersConfig,
- searchFilters, DEFAULT_SHOULD_MATCH_SCORE);
-
- // Parse response for summary by entity type query
- OperationResult opResult = elasticSearchAdapter.doPost(
- elasticSearchAdapter.buildElasticSearchUrlForApi(vnfAggregationIndexName,
- SparkyConstants.ES_SEARCH_API),
- vnfSearch.toString(), javax.ws.rs.core.MediaType.APPLICATION_JSON_TYPE);
-
- return buildAggregateVnfResponseJson(opResult.getResult());
-
- }
-
- private String buildAggregateVnfResponseJson(String responseJsonStr) {
-
- JSONObject finalOutputToFe = new JSONObject();
- JSONObject responseJson = new JSONObject(responseJsonStr);
-
- JSONObject hits = responseJson.getJSONObject("hits");
- int totalHits = hits.getInt("total");
- finalOutputToFe.put("total", totalHits);
-
- JSONObject aggregations = responseJson.getJSONObject("aggregations");
- String[] aggKeys = JSONObject.getNames(aggregations);
- JSONObject aggregationsList = new JSONObject();
-
- for (String aggName : aggKeys) {
- JSONObject aggregation = aggregations.getJSONObject(aggName);
- JSONArray buckets = aggregation.getJSONArray("buckets");
- aggregationsList.put(aggName, buckets);
- }
-
- finalOutputToFe.put("aggregations", aggregationsList);
-
- return finalOutputToFe.toString();
- }
-}
diff --git a/src/main/java/org/onap/aai/sparky/aggregatevnf/search/AggregateVnfSearchProvider.java b/src/main/java/org/onap/aai/sparky/aggregatevnf/search/AggregateVnfSearchProvider.java
deleted file mode 100644
index 5fd0dc9..0000000
--- a/src/main/java/org/onap/aai/sparky/aggregatevnf/search/AggregateVnfSearchProvider.java
+++ /dev/null
@@ -1,172 +0,0 @@
-/**
- * ============LICENSE_START=======================================================
- * org.onap.aai
- * ================================================================================
- * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved.
- * Copyright © 2017-2018 Amdocs
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-package org.onap.aai.sparky.aggregatevnf.search;
-
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-
-import org.onap.aai.cl.api.Logger;
-import org.onap.aai.cl.eelf.LoggerFactory;
-import org.onap.aai.restclient.client.OperationResult;
-import org.onap.aai.sparky.common.search.CommonSearchSuggestion;
-import org.onap.aai.sparky.logging.AaiUiMsgs;
-import org.onap.aai.sparky.search.SearchServiceAdapter;
-import org.onap.aai.sparky.search.api.SearchProvider;
-import org.onap.aai.sparky.search.entity.QuerySearchEntity;
-import org.onap.aai.sparky.search.entity.SearchSuggestion;
-import org.onap.aai.sparky.search.filters.entity.UiFilterValueEntity;
-import org.onap.aai.sparky.util.NodeUtils;
-
-import com.fasterxml.jackson.databind.JsonNode;
-import com.fasterxml.jackson.databind.ObjectMapper;
-import com.fasterxml.jackson.databind.node.ArrayNode;
-
-public class AggregateVnfSearchProvider implements SearchProvider {
-
- private static final Logger LOG =
- LoggerFactory.getInstance().getLogger(AggregateVnfSearchProvider.class);
-
- private ObjectMapper mapper;
- private SearchServiceAdapter searchServiceAdapter = null;
- private String autoSuggestIndexName;
- private String vnfSearchSuggestionRoute;
-
- private static final String AUTO_SUGGEST_TEMPLATE = "{ " + "\"results-size\": %d,"
- + "\"suggest-text\": \"%s\"," + "\"suggest-field\": \"%s\"" + "}";
-
- private static final String KEY_SEARCH_RESULT = "searchResult";
- private static final String KEY_HITS = "hits";
- private static final String KEY_DOCUMENT = "document";
- private static final String KEY_CONTENT = "content";
- private static final String KEY_TEXT = "text";
- private static final String KEY_FILTER_LIST = "filterList";
-
- public AggregateVnfSearchProvider(SearchServiceAdapter searchServiceAdapter,
- String autoSuggestIndexName, String vnfSearchSuggestionRoute) {
- mapper = new ObjectMapper();
- this.searchServiceAdapter = searchServiceAdapter;
- this.autoSuggestIndexName = autoSuggestIndexName;
- this.vnfSearchSuggestionRoute = vnfSearchSuggestionRoute;
- }
-
- public void setAutoSuggestIndexName(String autoSuggestIndexName) {
- this.autoSuggestIndexName = autoSuggestIndexName;
- }
-
- @Override
- public List search(QuerySearchEntity queryRequest) {
-
- List returnList = new ArrayList();
- try {
-
- final String fullUrlStr =
- searchServiceAdapter.buildSuggestServiceQueryUrl(autoSuggestIndexName);
- String postBody =
- String.format(AUTO_SUGGEST_TEMPLATE, Integer.parseInt(queryRequest.getMaxResults()),
- queryRequest.getQueryStr(), "entity_suggest");
- OperationResult opResult =
- searchServiceAdapter.doPost(fullUrlStr, postBody, "application/json");
- if (opResult.getResultCode() == 200) {
- returnList = generateSuggestionsForSearchResponse(opResult.getResult());
- } else {
- LOG.error(AaiUiMsgs.ERROR_PARSING_JSON_PAYLOAD_VERBOSE, opResult.getResult());
- return returnList;
- }
- } catch (Exception exc) {
- LOG.error(AaiUiMsgs.ERROR_GENERIC, "Search failed due to error = " + exc.getMessage());
- }
-
- return returnList;
- }
-
- private List generateSuggestionsForSearchResponse(String operationResult) {
-
- if (operationResult == null || operationResult.length() == 0) {
- return null;
- }
-
- ObjectMapper mapper = new ObjectMapper();
- JsonNode rootNode = null;
- List suggestionEntityList = new ArrayList();
-
- try {
- rootNode = mapper.readTree(operationResult);
- JsonNode hitsNode = rootNode.get(KEY_SEARCH_RESULT);
- // Check if there are hits that are coming back
- if (hitsNode.has(KEY_HITS)) {
- ArrayNode hitsArray = (ArrayNode) hitsNode.get(KEY_HITS);
-
- /*
- * next we iterate over the values in the hit array elements
- */
- Iterator nodeIterator = hitsArray.elements();
- JsonNode entityNode = null;
- CommonSearchSuggestion responseSuggestion = null;
- JsonNode sourceNode = null;
-
- while (nodeIterator.hasNext()) {
- entityNode = nodeIterator.next();
- String responseText = getValueFromNode(entityNode, KEY_TEXT);
- // do the point transformation as we build the response?
- responseSuggestion = new CommonSearchSuggestion();
- responseSuggestion.setRoute(vnfSearchSuggestionRoute);
- responseSuggestion.setText(responseText);
- responseSuggestion.setHashId(NodeUtils.generateUniqueShaDigest(responseText));
-
- sourceNode = entityNode.get(KEY_DOCUMENT).get(KEY_CONTENT);
- if (sourceNode.has(KEY_FILTER_LIST)) {
- ArrayNode filtersArray = (ArrayNode) sourceNode.get(KEY_FILTER_LIST);
- for (int i = 0; i < filtersArray.size(); i++) {
- String filterValueString = filtersArray.get(i).toString();
- UiFilterValueEntity filterValue =
- mapper.readValue(filterValueString, UiFilterValueEntity.class);
- responseSuggestion.getFilterValues().add(filterValue);
- }
- }
- suggestionEntityList.add(responseSuggestion);
- }
- }
- } catch (IOException exc) {
- LOG.warn(AaiUiMsgs.SEARCH_RESPONSE_BUILDING_EXCEPTION, exc.getLocalizedMessage());
- }
- return suggestionEntityList;
-
- }
-
- private String getValueFromNode(JsonNode node, String fieldName) {
-
- if (node == null || fieldName == null) {
- return null;
- }
-
- JsonNode valueNode = node.get(fieldName);
-
- if (valueNode != null) {
- return valueNode.asText();
- }
-
- return null;
-
- }
-
-}
diff --git a/src/main/java/org/onap/aai/sparky/aggregatevnf/search/VnfSearchQueryBuilder.java b/src/main/java/org/onap/aai/sparky/aggregatevnf/search/VnfSearchQueryBuilder.java
deleted file mode 100644
index 8542c9a..0000000
--- a/src/main/java/org/onap/aai/sparky/aggregatevnf/search/VnfSearchQueryBuilder.java
+++ /dev/null
@@ -1,168 +0,0 @@
-/**
- * ============LICENSE_START=======================================================
- * org.onap.aai
- * ================================================================================
- * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved.
- * Copyright © 2017-2018 Amdocs
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-package org.onap.aai.sparky.aggregatevnf.search;
-
-import java.util.Map;
-
-import javax.json.Json;
-import javax.json.JsonArray;
-import javax.json.JsonArrayBuilder;
-import javax.json.JsonObject;
-import javax.json.JsonObjectBuilder;
-
-/**
- * Build a JSON payload to send to elastic search to get vnf search data.
- */
-
-public class VnfSearchQueryBuilder {
-
- /**
- * Creates the suggestions query.
- *
- * @param maxResults maximum number of suggestions to fetch
- * @param queryStr query string
- * @return the json object
- */
-
- /*
- * { "vnfs" : { "text" : "VNFs", "completion" : { "field" : "entity_suggest", "size": 1 } } }
- */
- public static JsonObject createSuggestionsQuery(String maxResults, String queryStr) {
- JsonObjectBuilder jsonBuilder = Json.createObjectBuilder();
-
- JsonObjectBuilder completionBlob = Json.createObjectBuilder();
- completionBlob.add("field", "entity_suggest");
- completionBlob.add("size", maxResults);
-
- JsonObjectBuilder jsonAllBuilder = Json.createObjectBuilder();
- jsonAllBuilder.add("text", queryStr);
- jsonAllBuilder.add("completion", completionBlob);
-
- jsonBuilder.add("vnfs", jsonAllBuilder.build());
- return jsonBuilder.build();
- }
-
- public static JsonObject getTermBlob(String key, String value) {
- JsonObjectBuilder termBlobBuilder = Json.createObjectBuilder();
- JsonObjectBuilder jsonBuilder = Json.createObjectBuilder().add(key, value);
- return termBlobBuilder.add("term", jsonBuilder.build()).build();
- }
-
- public static void getSummaryAggsBlob(JsonObjectBuilder aggsBlobBuilder, String aggsKey,
- int resultSize) {
- JsonObjectBuilder fieldBuilder =
- Json.createObjectBuilder().add("field", aggsKey).add("size", resultSize);
- JsonObject aggsFieldBlob = fieldBuilder.build();
- JsonObjectBuilder defaultBlobBuilder = Json.createObjectBuilder().add("terms", aggsFieldBlob);
- JsonObject defaultBlob = defaultBlobBuilder.build();
- aggsBlobBuilder.add("default", defaultBlob);
- }
-
- public static void buildSingleTermCountQuery(JsonObjectBuilder jsonBuilder, String key,
- String value) {
- jsonBuilder.add("query", getTermBlob(key, value));
- }
-
- public static void buildSingleTermSummaryQuery(JsonObjectBuilder jsonBuilder, String key,
- String value, String groupByKey) {
- JsonObjectBuilder queryBlobBuilder = Json.createObjectBuilder();
- JsonObjectBuilder aggsBlobBuilder = Json.createObjectBuilder();
-
- queryBlobBuilder.add("constant_score",
- Json.createObjectBuilder().add("filter", getTermBlob(key, value)));
-
- getSummaryAggsBlob(aggsBlobBuilder, groupByKey, 0);
-
- jsonBuilder.add("query", queryBlobBuilder.build());
- jsonBuilder.add("aggs", aggsBlobBuilder.build());
- }
-
- public static void buildMultiTermSummaryQuery(JsonObjectBuilder jsonBuilder,
- Map attributes, String groupByKey) {
- JsonObjectBuilder queryBlobBuilder = Json.createObjectBuilder();
- JsonObjectBuilder aggsBlobBuilder = Json.createObjectBuilder();
- JsonArrayBuilder mustBlobBuilder = Json.createArrayBuilder();
- for (String key : attributes.keySet()) {
- mustBlobBuilder.add(getTermBlob(key, attributes.get(key)));
- }
- JsonArray mustBlob = mustBlobBuilder.build();
-
- queryBlobBuilder.add("constant_score", Json.createObjectBuilder().add("filter",
- Json.createObjectBuilder().add("bool", Json.createObjectBuilder().add("must", mustBlob))));
-
- getSummaryAggsBlob(aggsBlobBuilder, groupByKey, 0);
-
- jsonBuilder.add("query", queryBlobBuilder.build());
- jsonBuilder.add("aggs", aggsBlobBuilder.build());
- }
-
- public static void buildZeroTermSummaryQuery(JsonObjectBuilder jsonBuilder, String groupByKey) {
- JsonObjectBuilder aggsBlobBuilder = Json.createObjectBuilder();
-
- getSummaryAggsBlob(aggsBlobBuilder, groupByKey, 0);
-
- jsonBuilder.add("aggs", aggsBlobBuilder.build());
- }
-
- public static void buildMultiTermCountQuery(JsonObjectBuilder jsonBuilder,
- Map attributes) {
- JsonArrayBuilder mustBlobBuilder = Json.createArrayBuilder();
- for (String key : attributes.keySet()) {
- mustBlobBuilder.add(getTermBlob(key, attributes.get(key)));
- }
- jsonBuilder.add("query", Json.createObjectBuilder().add("bool",
- Json.createObjectBuilder().add("must", mustBlobBuilder)));
- }
-
- public static JsonObject createSummaryByEntityTypeQuery(Map attributes,
- String groupByKey) {
- JsonObjectBuilder jsonBuilder = Json.createObjectBuilder();
- jsonBuilder.add("size", "0"); // avoid source data
- if (attributes.size() == 0) {
- buildZeroTermSummaryQuery(jsonBuilder, groupByKey);
- } else if (attributes.size() == 1) {
- Map.Entry entry = attributes.entrySet().iterator().next();
- buildSingleTermSummaryQuery(jsonBuilder, entry.getKey(), entry.getValue(), groupByKey);
- } else {
- buildMultiTermSummaryQuery(jsonBuilder, attributes, groupByKey);
- }
- return jsonBuilder.build();
- }
-
- public static JsonObject createEntityCountsQuery(Map attributes) {
- JsonObjectBuilder jsonBuilder = Json.createObjectBuilder();
- if (attributes.size() == 1) {
- Map.Entry entry = attributes.entrySet().iterator().next();
- buildSingleTermCountQuery(jsonBuilder, entry.getKey(), entry.getValue());
- } else {
- buildMultiTermCountQuery(jsonBuilder, attributes);
- }
- return jsonBuilder.build();
- }
-
- public static JsonArray getSortCriteria(String sortFieldName, String sortOrder) {
- JsonArrayBuilder jsonBuilder = Json.createArrayBuilder();
- jsonBuilder.add(Json.createObjectBuilder().add(sortFieldName,
- Json.createObjectBuilder().add("order", sortOrder)));
-
- return jsonBuilder.build();
- }
-}
diff --git a/src/main/java/org/onap/aai/sparky/aggregation/sync/AggregationSyncControllerFactory.java b/src/main/java/org/onap/aai/sparky/aggregation/sync/AggregationSyncControllerFactory.java
deleted file mode 100644
index d33dbed..0000000
--- a/src/main/java/org/onap/aai/sparky/aggregation/sync/AggregationSyncControllerFactory.java
+++ /dev/null
@@ -1,234 +0,0 @@
-/**
- * ============LICENSE_START=======================================================
- * org.onap.aai
- * ================================================================================
- * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved.
- * Copyright © 2017-2018 Amdocs
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-package org.onap.aai.sparky.aggregation.sync;
-
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Map;
-
-import org.onap.aai.cl.api.Logger;
-import org.onap.aai.cl.eelf.LoggerFactory;
-import org.onap.aai.sparky.config.oxm.OxmEntityLookup;
-import org.onap.aai.sparky.config.oxm.SuggestionEntityDescriptor;
-import org.onap.aai.sparky.config.oxm.SuggestionEntityLookup;
-import org.onap.aai.sparky.dal.ActiveInventoryAdapter;
-import org.onap.aai.sparky.dal.ElasticSearchAdapter;
-import org.onap.aai.sparky.logging.AaiUiMsgs;
-import org.onap.aai.sparky.sync.ElasticSearchIndexCleaner;
-import org.onap.aai.sparky.sync.ElasticSearchSchemaFactory;
-import org.onap.aai.sparky.sync.IndexCleaner;
-import org.onap.aai.sparky.sync.IndexIntegrityValidator;
-import org.onap.aai.sparky.sync.SyncController;
-import org.onap.aai.sparky.sync.SyncControllerImpl;
-import org.onap.aai.sparky.sync.SyncControllerRegistrar;
-import org.onap.aai.sparky.sync.SyncControllerRegistry;
-import org.onap.aai.sparky.sync.config.ElasticSearchEndpointConfig;
-import org.onap.aai.sparky.sync.config.ElasticSearchSchemaConfig;
-import org.onap.aai.sparky.sync.config.NetworkStatisticsConfig;
-import org.onap.aai.sparky.sync.config.SyncControllerConfig;
-
-public class AggregationSyncControllerFactory implements SyncControllerRegistrar {
-
- private static final Logger LOG =
- LoggerFactory.getInstance().getLogger(AggregationSyncControllerFactory.class);
-
- private ActiveInventoryAdapter aaiAdapter;
- private ElasticSearchAdapter esAdapter;
- private SuggestionEntityLookup suggestionEntityLookup;
-
- private Map aggregationEntityToIndexMap;
- private Map indexNameToSchemaConfigMap;
-
- private ElasticSearchEndpointConfig elasticSearchEndpointConfig;
- private SyncControllerConfig syncControllerConfig;
- private SyncControllerRegistry syncControllerRegistry;
- private NetworkStatisticsConfig aaiStatConfig;
- private NetworkStatisticsConfig esStatConfig;
- private OxmEntityLookup oxmEntityLookup;
-
- private List syncControllers;
-
- public AggregationSyncControllerFactory(ElasticSearchEndpointConfig esEndpointConfig,
- SyncControllerConfig syncControllerConfig, SyncControllerRegistry syncControllerRegistry,
- SuggestionEntityLookup suggestionEntityLookup,
- OxmEntityLookup oxmEntityLookup) {
- this.syncControllers = new ArrayList();
- this.elasticSearchEndpointConfig = esEndpointConfig;
- this.syncControllerConfig = syncControllerConfig;
- this.syncControllerRegistry = syncControllerRegistry;
- this.suggestionEntityLookup = suggestionEntityLookup;
- this.oxmEntityLookup = oxmEntityLookup;
- }
-
- public NetworkStatisticsConfig getAaiStatConfig() {
- return aaiStatConfig;
- }
-
- public void setAaiStatConfig(NetworkStatisticsConfig aaiStatConfig) {
- this.aaiStatConfig = aaiStatConfig;
- }
-
- public NetworkStatisticsConfig getEsStatConfig() {
- return esStatConfig;
- }
-
- public void setEsStatConfig(NetworkStatisticsConfig esStatConfig) {
- this.esStatConfig = esStatConfig;
- }
-
- public Map getIndexNameToSchemaConfigMap() {
- return indexNameToSchemaConfigMap;
- }
-
- public void setIndexNameToSchemaConfigMap(
- Map indexNameToSchemaConfigMap) {
- this.indexNameToSchemaConfigMap = indexNameToSchemaConfigMap;
- }
-
- public ElasticSearchEndpointConfig getElasticSearchEndpointConfig() {
- return elasticSearchEndpointConfig;
- }
-
- public void setElasticSearchEndpointConfig(
- ElasticSearchEndpointConfig elasticSearchEndpointConfig) {
- this.elasticSearchEndpointConfig = elasticSearchEndpointConfig;
- }
-
- public SyncControllerConfig getSyncControllerConfig() {
- return syncControllerConfig;
- }
-
- public void setSyncControllerConfig(SyncControllerConfig syncControllerConfig) {
- this.syncControllerConfig = syncControllerConfig;
- }
-
- public ActiveInventoryAdapter getAaiAdapter() {
- return aaiAdapter;
- }
-
- public void setAaiAdapter(ActiveInventoryAdapter aaiAdapter) {
- this.aaiAdapter = aaiAdapter;
- }
-
- public ElasticSearchAdapter getEsAdapter() {
- return esAdapter;
- }
-
- public void setEsAdapter(ElasticSearchAdapter esAdapter) {
- this.esAdapter = esAdapter;
- }
-
- public SuggestionEntityLookup getSuggestionEntityLookup() {
- return suggestionEntityLookup;
- }
-
- public void setSuggestionEntityLookup(SuggestionEntityLookup suggestionEntityLookup) {
- this.suggestionEntityLookup = suggestionEntityLookup;
- }
-
- public Map getAggregationEntityToIndexMap() {
- return aggregationEntityToIndexMap;
- }
-
- public void setAggregationEntityToIndexMap(Map aggregationEntityToIndexMap) {
- this.aggregationEntityToIndexMap = aggregationEntityToIndexMap;
- }
-
- public void buildControllers() {
-
- if (syncControllerConfig.isEnabled()) {
-
- Map suggestionEntitites =
- suggestionEntityLookup.getSuggestionSearchEntityDescriptors();
- SyncControllerImpl aggregationSyncController = null;
-
- for (String entityType : suggestionEntitites.keySet()) {
-
- String indexName = aggregationEntityToIndexMap.get(entityType);
-
- if (indexName == null) {
- LOG.error(AaiUiMsgs.ERROR_GENERIC,
- "Could not determine aggregation index name" + " for entity type: " + entityType);
- continue;
- }
-
- try {
-
- aggregationSyncController = new SyncControllerImpl(syncControllerConfig, entityType);
-
- ElasticSearchSchemaConfig schemaConfig = indexNameToSchemaConfigMap.get(indexName);
-
- if (schemaConfig == null) {
- LOG.error(AaiUiMsgs.ERROR_GENERIC,
- "Could not determine elastic search schema config for index name: " + indexName);
- continue;
- }
-
- IndexIntegrityValidator aggregationIndexValidator = new IndexIntegrityValidator(esAdapter,
- schemaConfig, elasticSearchEndpointConfig, ElasticSearchSchemaFactory.getIndexSchema(schemaConfig));
-
- aggregationSyncController.registerIndexValidator(aggregationIndexValidator);
-
- AggregationSynchronizer aggSynchronizer = new AggregationSynchronizer(entityType,
- schemaConfig, syncControllerConfig.getNumInternalSyncWorkers(),
- syncControllerConfig.getNumSyncActiveInventoryWorkers(),
- syncControllerConfig.getNumSyncElasticWorkers(), aaiStatConfig, esStatConfig,
- oxmEntityLookup);
-
- aggSynchronizer.setAaiAdapter(aaiAdapter);
- aggSynchronizer.setElasticSearchAdapter(esAdapter);
-
- aggregationSyncController.registerEntitySynchronizer(aggSynchronizer);
-
- IndexCleaner entityDataIndexCleaner =
- new ElasticSearchIndexCleaner(esAdapter, elasticSearchEndpointConfig, schemaConfig);
-
- aggregationSyncController.registerIndexCleaner(entityDataIndexCleaner);
-
- syncControllers.add(aggregationSyncController);
- } catch (Exception exc) {
-
- exc.printStackTrace();
-
- LOG.error(AaiUiMsgs.ERROR_GENERIC,
- "Failed to build aggregation sync controller. Error : " + exc.getMessage());
- }
-
- }
- } else {
- LOG.info(AaiUiMsgs.INFO_GENERIC, "Sync controller with name = "
- + syncControllerConfig.getControllerName() + " is disabled");
- }
- }
-
- @Override
- public void registerController() {
-
- buildControllers();
-
- if ( syncControllerRegistry != null ) {
- for ( SyncController controller : syncControllers ) {
- syncControllerRegistry.registerSyncController(controller);
- }
- }
-
- }
-}
diff --git a/src/main/java/org/onap/aai/sparky/aggregation/sync/AggregationSynchronizer.java b/src/main/java/org/onap/aai/sparky/aggregation/sync/AggregationSynchronizer.java
deleted file mode 100644
index e0b6955..0000000
--- a/src/main/java/org/onap/aai/sparky/aggregation/sync/AggregationSynchronizer.java
+++ /dev/null
@@ -1,778 +0,0 @@
-/**
- * ============LICENSE_START=======================================================
- * org.onap.aai
- * ================================================================================
- * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved.
- * Copyright © 2017-2018 Amdocs
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-package org.onap.aai.sparky.aggregation.sync;
-
-import static java.util.concurrent.CompletableFuture.supplyAsync;
-
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.Deque;
-import java.util.EnumSet;
-import java.util.Iterator;
-import java.util.Map;
-import java.util.concurrent.ConcurrentHashMap;
-import java.util.concurrent.ConcurrentLinkedDeque;
-import java.util.concurrent.ExecutorService;
-import java.util.concurrent.atomic.AtomicInteger;
-import java.util.function.Supplier;
-
-import org.onap.aai.cl.api.Logger;
-import org.onap.aai.cl.eelf.LoggerFactory;
-import org.onap.aai.cl.mdc.MdcContext;
-import org.onap.aai.restclient.client.OperationResult;
-import org.onap.aai.sparky.config.oxm.OxmEntityDescriptor;
-import org.onap.aai.sparky.config.oxm.OxmEntityLookup;
-import org.onap.aai.sparky.dal.ActiveInventoryAdapter;
-import org.onap.aai.sparky.dal.NetworkTransaction;
-import org.onap.aai.sparky.dal.rest.HttpMethod;
-import org.onap.aai.sparky.logging.AaiUiMsgs;
-import org.onap.aai.sparky.sync.AbstractEntitySynchronizer;
-import org.onap.aai.sparky.sync.IndexSynchronizer;
-import org.onap.aai.sparky.sync.SynchronizerConstants;
-import org.onap.aai.sparky.sync.config.ElasticSearchSchemaConfig;
-import org.onap.aai.sparky.sync.config.NetworkStatisticsConfig;
-import org.onap.aai.sparky.sync.entity.AggregationEntity;
-import org.onap.aai.sparky.sync.entity.MergableEntity;
-import org.onap.aai.sparky.sync.entity.SelfLinkDescriptor;
-import org.onap.aai.sparky.sync.enumeration.OperationState;
-import org.onap.aai.sparky.sync.enumeration.SynchronizerState;
-import org.onap.aai.sparky.sync.task.PerformActiveInventoryRetrieval;
-import org.onap.aai.sparky.sync.task.PerformElasticSearchPut;
-import org.onap.aai.sparky.sync.task.PerformElasticSearchRetrieval;
-import org.onap.aai.sparky.sync.task.PerformElasticSearchUpdate;
-import org.onap.aai.sparky.util.NodeUtils;
-import org.slf4j.MDC;
-
-import com.fasterxml.jackson.core.JsonProcessingException;
-import com.fasterxml.jackson.databind.JsonNode;
-import com.fasterxml.jackson.databind.ObjectReader;
-import com.fasterxml.jackson.databind.node.ArrayNode;
-
-/**
- * The Class AutosuggestionSynchronizer.
- */
-public class AggregationSynchronizer extends AbstractEntitySynchronizer
- implements IndexSynchronizer {
-
- /**
- * The Class RetryAggregationEntitySyncContainer.
- */
- private class RetryAggregationEntitySyncContainer {
- NetworkTransaction txn;
- AggregationEntity ae;
-
- /**
- * Instantiates a new retry aggregation entity sync container.
- *
- * @param txn the txn
- * @param ae the se
- */
- public RetryAggregationEntitySyncContainer(NetworkTransaction txn, AggregationEntity ae) {
- this.txn = txn;
- this.ae = ae;
- }
-
- public NetworkTransaction getNetworkTransaction() {
- return txn;
- }
-
- public AggregationEntity getAggregationEntity() {
- return ae;
- }
- }
-
- private static final Logger LOG =
- LoggerFactory.getInstance().getLogger(AggregationSynchronizer.class);
- private static final String INSERTION_DATE_TIME_FORMAT = "yyyyMMdd'T'HHmmssZ";
-
- private boolean allWorkEnumerated;
- private Deque selflinks;
- private Deque retryQueue;
- private Map retryLimitTracker;
- protected ExecutorService esPutExecutor;
- private ConcurrentHashMap entityCounters;
- private boolean syncInProgress;
- private Map contextMap;
- private String entityType;
- private ElasticSearchSchemaConfig schemaConfig;
- private OxmEntityLookup oxmEntityLookup;
-
- /**
- * Instantiates a new entity aggregation synchronizer.
- *
- * @param indexName the index name
- * @throws Exception the exception
- */
- public AggregationSynchronizer(String entityType, ElasticSearchSchemaConfig schemaConfig,
- int numSyncWorkers, int numActiveInventoryWorkers, int numElasticWorkers,
- NetworkStatisticsConfig aaiStatConfig, NetworkStatisticsConfig esStatConfig,
- OxmEntityLookup oxmEntityLookup) throws Exception {
-
- super(LOG, "AGGES-" + schemaConfig.getIndexName().toUpperCase(), numSyncWorkers,
- numActiveInventoryWorkers, numElasticWorkers, schemaConfig.getIndexName(),aaiStatConfig, esStatConfig);
-
- this.oxmEntityLookup = oxmEntityLookup;
-
- this.schemaConfig = schemaConfig;
- this.entityType = entityType;
- this.allWorkEnumerated = false;
- this.entityCounters = new ConcurrentHashMap();
- this.synchronizerName = "Entity Aggregation Synchronizer";
- this.enabledStatFlags = EnumSet.of(StatFlag.AAI_REST_STATS, StatFlag.ES_REST_STATS);
- this.syncInProgress = false;
- this.allWorkEnumerated = false;
- this.selflinks = new ConcurrentLinkedDeque();
- this.retryQueue = new ConcurrentLinkedDeque();
- this.retryLimitTracker = new ConcurrentHashMap();
-
- this.esPutExecutor = NodeUtils.createNamedExecutor("AGGES-ES-PUT", 1, LOG);
-
- this.aaiEntityStats.intializeEntityCounters(entityType);
- this.esEntityStats.intializeEntityCounters(entityType);
-
- this.contextMap = MDC.getCopyOfContextMap();
- }
-
- /**
- * Collect all the work.
- *
- * @return the operation state
- */
- private OperationState collectAllTheWork() {
- final Map contextMap = MDC.getCopyOfContextMap();
- final String entity = this.getEntityType();
- try {
-
- aaiWorkOnHand.set(1);
-
- supplyAsync(new Supplier() {
-
- @Override
- public Void get() {
- MDC.setContextMap(contextMap);
- OperationResult typeLinksResult = null;
- try {
- typeLinksResult = aaiAdapter.getSelfLinksByEntityType(entity);
- aaiWorkOnHand.decrementAndGet();
- processEntityTypeSelfLinks(typeLinksResult);
- } catch (Exception exc) {
- LOG.error(AaiUiMsgs.ERROR_GENERIC, "Processing execption while building working set. Error:"
- + exc.getMessage());
- }
-
- return null;
- }
-
- }, aaiExecutor).whenComplete((result, error) -> {
-
- if (error != null) {
- LOG.error(AaiUiMsgs.ERROR_GENERIC,
- "An error occurred getting data from AAI. Error = " + error.getMessage());
- }
- });
-
- while (aaiWorkOnHand.get() != 0) {
-
- if (LOG.isDebugEnabled()) {
- LOG.debug(AaiUiMsgs.WAIT_FOR_ALL_SELFLINKS_TO_BE_COLLECTED);
- }
-
- Thread.sleep(1000);
- }
-
- aaiWorkOnHand.set(selflinks.size());
- allWorkEnumerated = true;
- syncEntityTypes();
-
- while (!isSyncDone()) {
- performRetrySync();
- Thread.sleep(1000);
- }
-
- /*
- * Make sure we don't hang on to retries that failed which could cause issues during future
- * syncs
- */
- retryLimitTracker.clear();
-
- } catch (Exception exc) {
- // TODO -> LOG, waht should be logged here?
- }
-
- return OperationState.OK;
- }
-
-
- /**
- * Perform retry sync.
- */
- private void performRetrySync() {
- while (retryQueue.peek() != null) {
-
- RetryAggregationEntitySyncContainer rsc = retryQueue.poll();
- if (rsc != null) {
-
- AggregationEntity ae = rsc.getAggregationEntity();
- NetworkTransaction txn = rsc.getNetworkTransaction();
-
- String link = null;
- try {
- /*
- * In this retry flow the se object has already derived its fields
- */
- link = elasticSearchAdapter.buildElasticSearchGetDocUrl(getIndexName(), ae.getId());
- } catch (Exception exc) {
- LOG.error(AaiUiMsgs.ES_FAILED_TO_CONSTRUCT_URI, exc.getLocalizedMessage());
- }
-
- if (link != null) {
- NetworkTransaction retryTransaction = new NetworkTransaction();
- retryTransaction.setLink(link);
- retryTransaction.setEntityType(txn.getEntityType());
- retryTransaction.setDescriptor(txn.getDescriptor());
- retryTransaction.setOperationType(HttpMethod.GET);
-
- /*
- * IMPORTANT - DO NOT incrementAndGet the esWorkOnHand as this is a retry flow! We already
- * called incrementAndGet when queuing the failed PUT!
- */
-
- supplyAsync(new PerformElasticSearchRetrieval(retryTransaction, elasticSearchAdapter),
- esExecutor).whenComplete((result, error) -> {
-
- esWorkOnHand.decrementAndGet();
-
- if (error != null) {
- LOG.error(AaiUiMsgs.ES_RETRIEVAL_FAILED_RESYNC, error.getLocalizedMessage());
- } else {
- updateElasticSearchCounters(result);
- performDocumentUpsert(result, ae);
- }
- });
- }
-
- }
- }
- }
-
- /**
- * Perform document upsert.
- *
- * @param esGetTxn the es get txn
- * @param ae the ae
- */
- protected void performDocumentUpsert(NetworkTransaction esGetTxn, AggregationEntity ae) {
- /**
- *
- *
- * As part of the response processing we need to do the following:
- * - 1. Extract the version (if present), it will be the ETAG when we use the
- * Search-Abstraction-Service
- *
- 2. Spawn next task which is to do the PUT operation into elastic with or with the version
- * tag
- *
- a) if version is null or RC=404, then standard put, no _update with version tag
- *
- b) if version != null, do PUT with _update?version= versionNumber in the URI to elastic
- *
- *
- */
- String link = null;
- try {
- link = elasticSearchAdapter.buildElasticSearchGetDocUrl(getIndexName(), ae.getId());
- } catch (Exception exc) {
- LOG.error(AaiUiMsgs.ES_LINK_UPSERT, exc.getLocalizedMessage());
- return;
- }
-
- String versionNumber = null;
- boolean wasEntryDiscovered = false;
- if (esGetTxn.getOperationResult().getResultCode() == 404) {
- LOG.info(AaiUiMsgs.ES_SIMPLE_PUT, ae.getEntityPrimaryKeyValue());
- } else if (esGetTxn.getOperationResult().getResultCode() == 200) {
- wasEntryDiscovered = true;
- try {
- versionNumber = NodeUtils.extractFieldValueFromObject(
- NodeUtils.convertJsonStrToJsonNode(esGetTxn.getOperationResult().getResult()),
- "_version");
- } catch (IOException exc) {
- String message =
- "Error extracting version number from response, aborting aggregation entity sync of "
- + ae.getEntityPrimaryKeyValue() + ". Error - " + exc.getLocalizedMessage();
- LOG.error(AaiUiMsgs.ERROR_EXTRACTING_FROM_RESPONSE, message);
- return;
- }
- } else {
- /*
- * Not being a 200 does not mean a failure. eg 201 is returned for created. TODO -> Should we
- * return.
- */
- LOG.error(AaiUiMsgs.ES_OPERATION_RETURN_CODE,
- String.valueOf(esGetTxn.getOperationResult().getResultCode()));
- return;
- }
-
- try {
- String jsonPayload = null;
- if (wasEntryDiscovered) {
- try {
- ArrayList sourceObject = new ArrayList();
- NodeUtils.extractObjectsByKey(
- NodeUtils.convertJsonStrToJsonNode(esGetTxn.getOperationResult().getResult()),
- "_source", sourceObject);
-
- if (!sourceObject.isEmpty()) {
- String responseSource = NodeUtils.convertObjectToJson(sourceObject.get(0), false);
- MergableEntity me = mapper.readValue(responseSource, MergableEntity.class);
- ObjectReader updater = mapper.readerForUpdating(me);
- MergableEntity merged = updater.readValue(ae.getAsJson());
- jsonPayload = mapper.writeValueAsString(merged);
- }
- } catch (IOException exc) {
- String message =
- "Error extracting source value from response, aborting aggregation entity sync of "
- + ae.getEntityPrimaryKeyValue() + ". Error - " + exc.getLocalizedMessage();
- LOG.error(AaiUiMsgs.ERROR_EXTRACTING_FROM_RESPONSE, message);
- return;
- }
- } else {
- jsonPayload = ae.getAsJson();
- }
-
- if (wasEntryDiscovered) {
- if (versionNumber != null && jsonPayload != null) {
-
- String requestPayload =
- elasticSearchAdapter.buildBulkImportOperationRequest(schemaConfig.getIndexName(),
- schemaConfig.getIndexDocType(), ae.getId(), versionNumber, jsonPayload);
-
- NetworkTransaction transactionTracker = new NetworkTransaction();
- transactionTracker.setEntityType(esGetTxn.getEntityType());
- transactionTracker.setDescriptor(esGetTxn.getDescriptor());
- transactionTracker.setOperationType(HttpMethod.PUT);
-
- esWorkOnHand.incrementAndGet();
- supplyAsync(new PerformElasticSearchUpdate(elasticSearchAdapter.getBulkUrl(),
- requestPayload, elasticSearchAdapter, transactionTracker), esPutExecutor)
- .whenComplete((result, error) -> {
-
- esWorkOnHand.decrementAndGet();
-
- if (error != null) {
- String message = "Aggregation entity sync UPDATE PUT error - "
- + error.getLocalizedMessage();
- LOG.error(AaiUiMsgs.ERROR_GENERIC, message);
- } else {
- updateElasticSearchCounters(result);
- processStoreDocumentResult(result, esGetTxn, ae);
- }
- });
- }
-
- } else {
- if (link != null && jsonPayload != null) {
-
- NetworkTransaction updateElasticTxn = new NetworkTransaction();
- updateElasticTxn.setLink(link);
- updateElasticTxn.setEntityType(esGetTxn.getEntityType());
- updateElasticTxn.setDescriptor(esGetTxn.getDescriptor());
- updateElasticTxn.setOperationType(HttpMethod.PUT);
-
- esWorkOnHand.incrementAndGet();
- supplyAsync(new PerformElasticSearchPut(jsonPayload, updateElasticTxn, elasticSearchAdapter),
- esPutExecutor).whenComplete((result, error) -> {
-
- esWorkOnHand.decrementAndGet();
-
- if (error != null) {
- String message =
- "Aggregation entity sync UPDATE PUT error - " + error.getLocalizedMessage();
- LOG.error(AaiUiMsgs.ERROR_GENERIC, message);
- } else {
- updateElasticSearchCounters(result);
- processStoreDocumentResult(result, esGetTxn, ae);
- }
- });
- }
- }
- } catch (Exception exc) {
- String message = "Exception caught during aggregation entity sync PUT operation. Message - "
- + exc.getLocalizedMessage();
- LOG.error(AaiUiMsgs.ERROR_GENERIC, message);
- }
- }
-
- /**
- * Should allow retry.
- *
- * @param id the id
- * @return true, if successful
- */
- private boolean shouldAllowRetry(String id) {
- boolean isRetryAllowed = true;
- if (retryLimitTracker.get(id) != null) {
- Integer currentCount = retryLimitTracker.get(id);
- if (currentCount.intValue() >= RETRY_COUNT_PER_ENTITY_LIMIT.intValue()) {
- isRetryAllowed = false;
- String message = "Aggregation entity re-sync limit reached for " + id
- + ", re-sync will no longer be attempted for this entity";
- LOG.error(AaiUiMsgs.ERROR_GENERIC, message);
- } else {
- Integer newCount = new Integer(currentCount.intValue() + 1);
- retryLimitTracker.put(id, newCount);
- }
- } else {
- Integer firstRetryCount = new Integer(1);
- retryLimitTracker.put(id, firstRetryCount);
- }
-
- return isRetryAllowed;
- }
-
- /**
- * Process store document result.
- *
- * @param esPutResult the es put result
- * @param esGetResult the es get result
- * @param ae the ae
- */
- private void processStoreDocumentResult(NetworkTransaction esPutResult,
- NetworkTransaction esGetResult, AggregationEntity ae) {
-
- OperationResult or = esPutResult.getOperationResult();
-
- if (!or.wasSuccessful()) {
- if (or.getResultCode() == VERSION_CONFLICT_EXCEPTION_CODE) {
-
- if (shouldAllowRetry(ae.getId())) {
- esWorkOnHand.incrementAndGet();
-
- RetryAggregationEntitySyncContainer rsc =
- new RetryAggregationEntitySyncContainer(esGetResult, ae);
- retryQueue.push(rsc);
-
- String message = "Store document failed during aggregation entity synchronization"
- + " due to version conflict. Entity will be re-synced.";
- LOG.warn(AaiUiMsgs.ERROR_GENERIC, message);
- }
- } else {
- String message =
- "Store document failed during aggregation entity synchronization with result code "
- + or.getResultCode() + " and result message " + or.getResult();
- LOG.error(AaiUiMsgs.ERROR_GENERIC, message);
- }
- }
- }
-
- /**
- * Sync entity types.
- */
- private void syncEntityTypes() {
-
- while (selflinks.peek() != null) {
-
- SelfLinkDescriptor linkDescriptor = selflinks.poll();
- aaiWorkOnHand.decrementAndGet();
-
- OxmEntityDescriptor descriptor = null;
-
- if (linkDescriptor.getSelfLink() != null && linkDescriptor.getEntityType() != null) {
-
- descriptor = oxmEntityLookup.getEntityDescriptors().get(linkDescriptor.getEntityType());
-
- if (descriptor == null) {
- LOG.error(AaiUiMsgs.MISSING_ENTITY_DESCRIPTOR, linkDescriptor.getEntityType());
- // go to next element in iterator
- continue;
- }
-
- NetworkTransaction txn = new NetworkTransaction();
- txn.setDescriptor(descriptor);
- txn.setLink(linkDescriptor.getSelfLink());
- txn.setOperationType(HttpMethod.GET);
- txn.setEntityType(linkDescriptor.getEntityType());
-
- aaiWorkOnHand.incrementAndGet();
-
- supplyAsync(new PerformActiveInventoryRetrieval(txn, aaiAdapter), aaiExecutor)
- .whenComplete((result, error) -> {
-
- aaiWorkOnHand.decrementAndGet();
-
- if (error != null) {
- LOG.error(AaiUiMsgs.AAI_RETRIEVAL_FAILED_GENERIC, error.getLocalizedMessage());
- } else {
- if (result == null) {
- LOG.error(AaiUiMsgs.AAI_RETRIEVAL_FAILED_FOR_SELF_LINK,
- linkDescriptor.getSelfLink());
- } else {
- updateActiveInventoryCounters(result);
- fetchDocumentForUpsert(result);
- }
- }
- });
- }
-
- }
-
- }
-
- /**
- * Fetch document for upsert.
- *
- * @param txn the txn
- */
- private void fetchDocumentForUpsert(NetworkTransaction txn) {
- // modified
- if (!txn.getOperationResult().wasSuccessful()) {
- String message = "Self link failure. Result - " + txn.getOperationResult().getResult();
- LOG.error(AaiUiMsgs.ERROR_GENERIC, message);
- return;
- }
-
- try {
- final String jsonResult = txn.getOperationResult().getResult();
- if (jsonResult != null && jsonResult.length() > 0) {
-
- AggregationEntity ae = new AggregationEntity();
- ae.setLink(ActiveInventoryAdapter.extractResourcePath(txn.getLink()));
- populateAggregationEntityDocument(ae, jsonResult, txn.getDescriptor());
- ae.deriveFields();
-
- String link = null;
- try {
- link = elasticSearchAdapter.buildElasticSearchGetDocUrl(getIndexName(), ae.getId());
- } catch (Exception exc) {
- LOG.error(AaiUiMsgs.ES_FAILED_TO_CONSTRUCT_QUERY, exc.getLocalizedMessage());
- }
-
- if (link != null) {
- NetworkTransaction n2 = new NetworkTransaction();
- n2.setLink(link);
- n2.setEntityType(txn.getEntityType());
- n2.setDescriptor(txn.getDescriptor());
- n2.setOperationType(HttpMethod.GET);
-
- esWorkOnHand.incrementAndGet();
-
- supplyAsync(new PerformElasticSearchRetrieval(n2, elasticSearchAdapter), esExecutor)
- .whenComplete((result, error) -> {
-
- esWorkOnHand.decrementAndGet();
-
- if (error != null) {
- LOG.error(AaiUiMsgs.ES_RETRIEVAL_FAILED, error.getLocalizedMessage());
- } else {
- updateElasticSearchCounters(result);
- performDocumentUpsert(result, ae);
- }
- });
- }
- }
-
- } catch (JsonProcessingException exc) {
- LOG.error(AaiUiMsgs.ERROR_GENERIC,
- "There was a JSON processing error fetching the elastic document for upsert. Error: "
- + exc.getMessage());
- } catch (IOException exc) {
- LOG.error(AaiUiMsgs.ERROR_GENERIC,
- "There was an IO error fetching the elastic document for upsert. Error: " + exc.getMessage());
- }
- }
-
-
- /**
- * Populate aggregation entity document.
- *
- * @param doc the doc
- * @param result the result
- * @param resultDescriptor the result descriptor
- * @throws JsonProcessingException the json processing exception
- * @throws IOException Signals that an I/O exception has occurred.
- */
- protected void populateAggregationEntityDocument(AggregationEntity doc, String result,
- OxmEntityDescriptor resultDescriptor) throws JsonProcessingException, IOException {
- doc.setEntityType(resultDescriptor.getEntityName());
- JsonNode entityNode = mapper.readTree(result);
- Map map = mapper.convertValue(entityNode, Map.class);
- doc.copyAttributeKeyValuePair(map);
- }
-
- /**
- * Process entity type self links.
- *
- * @param operationResult the operation result
- */
- private void processEntityTypeSelfLinks(OperationResult operationResult) {
-
- JsonNode rootNode = null;
-
- if ( operationResult == null ) {
- return;
- }
-
- final String jsonResult = operationResult.getResult();
-
- if (jsonResult != null && jsonResult.length() > 0 && operationResult.wasSuccessful()) {
-
- try {
- rootNode = mapper.readTree(jsonResult);
- } catch (IOException exc) {
- String message =
- "Could not deserialize JSON (representing operation result) as node tree. " +
- "Operation result = " + jsonResult + ". " + exc.getLocalizedMessage();
- LOG.error(AaiUiMsgs.JSON_PROCESSING_ERROR, message);
- }
-
- JsonNode resultData = rootNode.get("result-data");
- ArrayNode resultDataArrayNode = null;
-
- if (resultData.isArray()) {
- resultDataArrayNode = (ArrayNode) resultData;
-
- Iterator elementIterator = resultDataArrayNode.elements();
- JsonNode element = null;
-
- while (elementIterator.hasNext()) {
- element = elementIterator.next();
-
- final String resourceType = NodeUtils.getNodeFieldAsText(element, "resource-type");
- final String resourceLink = NodeUtils.getNodeFieldAsText(element, "resource-link");
-
- OxmEntityDescriptor descriptor = null;
-
- if (resourceType != null && resourceLink != null) {
-
- descriptor = oxmEntityLookup.getEntityDescriptors().get(resourceType);
-
- if (descriptor == null) {
- LOG.error(AaiUiMsgs.MISSING_ENTITY_DESCRIPTOR, resourceType);
- // go to next element in iterator
- continue;
- }
-
- selflinks.add(new SelfLinkDescriptor(resourceLink, SynchronizerConstants.NODES_ONLY_MODIFIER, resourceType));
-
-
- }
- }
- }
- }
-
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.openecomp.sparky.synchronizer.IndexSynchronizer#doSync()
- */
- @Override
- public OperationState doSync() {
- this.syncDurationInMs = -1;
- syncStartedTimeStampInMs = System.currentTimeMillis();
- String txnID = NodeUtils.getRandomTxnId();
- MdcContext.initialize(txnID, "AggregationSynchronizer", "", "Sync", "");
-
- return collectAllTheWork();
- }
-
- @Override
- public SynchronizerState getState() {
-
- if (!isSyncDone()) {
- return SynchronizerState.PERFORMING_SYNCHRONIZATION;
- }
-
- return SynchronizerState.IDLE;
-
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.openecomp.sparky.synchronizer.IndexSynchronizer#getStatReport(boolean)
- */
- @Override
- public String getStatReport(boolean showFinalReport) {
- syncDurationInMs = System.currentTimeMillis() - syncStartedTimeStampInMs;
- return getStatReport(syncDurationInMs, showFinalReport);
- }
-
- public String getEntityType() {
- return entityType;
- }
-
- public void setEntityType(String entityType) {
- this.entityType = entityType;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.openecomp.sparky.synchronizer.IndexSynchronizer#shutdown()
- */
- @Override
- public void shutdown() {
- this.shutdownExecutors();
- }
-
- @Override
- protected boolean isSyncDone() {
-
- int totalWorkOnHand = aaiWorkOnHand.get() + esWorkOnHand.get();
-
- if (LOG.isDebugEnabled()) {
- LOG.debug(AaiUiMsgs.DEBUG_GENERIC, indexName + ", isSyncDone(), totalWorkOnHand = "
- + totalWorkOnHand + " all work enumerated = " + allWorkEnumerated);
- }
-
- if (totalWorkOnHand > 0 || !allWorkEnumerated) {
- return false;
- }
-
- this.syncInProgress = false;
-
- return true;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.openecomp.sparky.synchronizer.AbstractEntitySynchronizer#clearCache()
- */
- @Override
- public void clearCache() {
-
- if (syncInProgress) {
- LOG.debug(AaiUiMsgs.DEBUG_GENERIC,
- "Autosuggestion Entity Summarizer in progress, request to clear cache ignored");
- return;
- }
-
- super.clearCache();
- this.resetCounters();
- if (entityCounters != null) {
- entityCounters.clear();
- }
-
- allWorkEnumerated = false;
-
- }
-
-}
diff --git a/src/main/java/org/onap/aai/sparky/aggregation/sync/HistoricalEntitySummarizer.java b/src/main/java/org/onap/aai/sparky/aggregation/sync/HistoricalEntitySummarizer.java
deleted file mode 100644
index a41df4f..0000000
--- a/src/main/java/org/onap/aai/sparky/aggregation/sync/HistoricalEntitySummarizer.java
+++ /dev/null
@@ -1,380 +0,0 @@
-/**
- * ============LICENSE_START=======================================================
- * org.onap.aai
- * ================================================================================
- * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved.
- * Copyright © 2017-2018 Amdocs
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-package org.onap.aai.sparky.aggregation.sync;
-
-import static java.util.concurrent.CompletableFuture.supplyAsync;
-
-import java.io.IOException;
-import java.sql.Timestamp;
-import java.text.SimpleDateFormat;
-import java.util.Collection;
-import java.util.EnumSet;
-import java.util.Map;
-import java.util.Map.Entry;
-import java.util.Set;
-import java.util.concurrent.ConcurrentHashMap;
-import java.util.concurrent.atomic.AtomicInteger;
-import java.util.function.Supplier;
-
-import javax.json.Json;
-import javax.ws.rs.core.MediaType;
-
-import org.onap.aai.cl.api.Logger;
-import org.onap.aai.cl.eelf.LoggerFactory;
-import org.onap.aai.cl.mdc.MdcContext;
-import org.onap.aai.restclient.client.OperationResult;
-import org.onap.aai.sparky.config.oxm.SearchableEntityLookup;
-import org.onap.aai.sparky.config.oxm.SearchableOxmEntityDescriptor;
-import org.onap.aai.sparky.dal.rest.HttpMethod;
-import org.onap.aai.sparky.logging.AaiUiMsgs;
-import org.onap.aai.sparky.sync.AbstractEntitySynchronizer;
-import org.onap.aai.sparky.sync.IndexSynchronizer;
-import org.onap.aai.sparky.sync.config.ElasticSearchSchemaConfig;
-import org.onap.aai.sparky.sync.config.NetworkStatisticsConfig;
-import org.onap.aai.sparky.sync.enumeration.OperationState;
-import org.onap.aai.sparky.sync.enumeration.SynchronizerState;
-import org.onap.aai.sparky.util.NodeUtils;
-import org.slf4j.MDC;
-
-import com.fasterxml.jackson.databind.JsonNode;
-import com.fasterxml.jackson.databind.node.ArrayNode;
-
-/**
- * The Class HistoricalEntitySummarizer.
- */
-public class HistoricalEntitySummarizer extends AbstractEntitySynchronizer
- implements IndexSynchronizer {
-
- private static final Logger LOG = LoggerFactory.getInstance().getLogger(HistoricalEntitySummarizer.class);
- private static final String INSERTION_DATE_TIME_FORMAT = "yyyyMMdd'T'HHmmssZ";
-
- private boolean allWorkEnumerated;
- private ConcurrentHashMap entityCounters;
- private boolean syncInProgress;
- private Map contextMap;
- private ElasticSearchSchemaConfig schemaConfig;
- private SearchableEntityLookup searchableEntityLookup;
-
- /**
- * Instantiates a new historical entity summarizer.
- *
- * @param indexName the index name
- * @throws Exception the exception
- */
- public HistoricalEntitySummarizer(ElasticSearchSchemaConfig schemaConfig, int internalSyncWorkers,
- int aaiWorkers, int esWorkers, NetworkStatisticsConfig aaiStatConfig,
- NetworkStatisticsConfig esStatConfig, SearchableEntityLookup searchableEntityLookup)
- throws Exception {
- super(LOG, "HES", internalSyncWorkers, aaiWorkers, esWorkers, schemaConfig.getIndexName(), aaiStatConfig, esStatConfig);
-
- this.schemaConfig = schemaConfig;
- this.allWorkEnumerated = false;
- this.entityCounters = new ConcurrentHashMap();
- this.synchronizerName = "Historical Entity Summarizer";
- this.enabledStatFlags = EnumSet.of(StatFlag.AAI_REST_STATS, StatFlag.ES_REST_STATS);
- this.syncInProgress = false;
- this.contextMap = MDC.getCopyOfContextMap();
- this.syncDurationInMs = -1;
- this.searchableEntityLookup = searchableEntityLookup;
- }
-
- /**
- * Collect all the work.
- *
- * @return the operation state
- */
- private OperationState collectAllTheWork() {
-
- Map descriptorMap =
- searchableEntityLookup.getSearchableEntityDescriptors();
-
- if (descriptorMap.isEmpty()) {
- LOG.error(AaiUiMsgs.OXM_FAILED_RETRIEVAL, "historical entities");
-
- return OperationState.ERROR;
- }
-
- Collection entityTypes = descriptorMap.keySet();
-
- AtomicInteger asyncWoH = new AtomicInteger(0);
-
- asyncWoH.set(entityTypes.size());
-
- try {
- for (String entityType : entityTypes) {
-
- supplyAsync(new Supplier() {
-
- @Override
- public Void get() {
- MDC.setContextMap(contextMap);
- try {
- OperationResult typeLinksResult =
- aaiAdapter.getSelfLinksByEntityType(entityType);
- updateActiveInventoryCounters(HttpMethod.GET, entityType, typeLinksResult);
- processEntityTypeSelfLinks(entityType, typeLinksResult);
- } catch (Exception exc) {
- LOG.error(AaiUiMsgs.ERROR_GETTING_DATA_FROM_AAI, exc.getMessage());
-
- }
-
- return null;
- }
-
- }, aaiExecutor).whenComplete((result, error) -> {
-
- asyncWoH.decrementAndGet();
-
- if (error != null) {
- LOG.error(AaiUiMsgs.HISTORICAL_COLLECT_ERROR, error.getMessage());
- }
-
- });
-
- }
-
-
- while (asyncWoH.get() > 0) {
-
- if (LOG.isDebugEnabled()) {
- LOG.debug(AaiUiMsgs.DEBUG_GENERIC, indexName + " summarizer waiting for all the links to be processed.");
- }
-
- Thread.sleep(250);
- }
-
- esWorkOnHand.set(entityCounters.size());
-
- // start doing the real work
- allWorkEnumerated = true;
-
- insertEntityTypeCounters();
-
- if (LOG.isDebugEnabled()) {
-
- StringBuilder sb = new StringBuilder(128);
-
- sb.append("\n\nHistorical Entity Counters:");
-
- for (Entry entry : entityCounters.entrySet()) {
- sb.append("\n").append(entry.getKey()).append(" = ").append(entry.getValue().get());
- }
-
- LOG.debug(AaiUiMsgs.DEBUG_GENERIC, sb.toString());
-
- }
-
- } catch (Exception exc) {
- LOG.error(AaiUiMsgs.HISTORICAL_COLLECT_ERROR, exc.getMessage());
-
-
- esWorkOnHand.set(0);
- allWorkEnumerated = true;
-
- return OperationState.ERROR;
- }
-
- return OperationState.OK;
-
- }
-
- /* (non-Javadoc)
- * @see org.openecomp.sparky.synchronizer.IndexSynchronizer#doSync()
- */
- @Override
- public OperationState doSync() {
- this.syncDurationInMs = -1;
- String txnID = NodeUtils.getRandomTxnId();
- MdcContext.initialize(txnID, "HistoricalEntitySynchronizer", "", "Sync", "");
-
- if (syncInProgress) {
- LOG.info(AaiUiMsgs.HISTORICAL_SYNC_PENDING);
- return OperationState.PENDING;
- }
-
- clearCache();
-
- syncInProgress = true;
- this.syncStartedTimeStampInMs = System.currentTimeMillis();
- allWorkEnumerated = false;
-
- return collectAllTheWork();
- }
-
- /**
- * Process entity type self links.
- *
- * @param entityType the entity type
- * @param operationResult the operation result
- */
- private void processEntityTypeSelfLinks(String entityType, OperationResult operationResult) {
-
- JsonNode rootNode = null;
-
- final String jsonResult = operationResult.getResult();
-
- if (jsonResult != null && jsonResult.length() > 0 && operationResult.wasSuccessful()) {
-
- try {
- rootNode = mapper.readTree(jsonResult);
- } catch (IOException exc) {
- LOG.error(AaiUiMsgs.JSON_PROCESSING_ERROR, exc.getMessage());
- return;
- }
-
- JsonNode resultData = rootNode.get("result-data");
- ArrayNode resultDataArrayNode = null;
-
- if (resultData != null && resultData.isArray()) {
- resultDataArrayNode = (ArrayNode) resultData;
- entityCounters.put(entityType, new AtomicInteger(resultDataArrayNode.size()));
- }
- }
-
- }
-
- /**
- * Insert entity type counters.
- */
- private void insertEntityTypeCounters() {
-
- if (esWorkOnHand.get() <= 0) {
- return;
- }
-
- SimpleDateFormat dateFormat = new SimpleDateFormat(INSERTION_DATE_TIME_FORMAT);
- Timestamp timestamp = new Timestamp(System.currentTimeMillis());
- String currentFormattedTimeStamp = dateFormat.format(timestamp);
-
- Set> entityCounterEntries = entityCounters.entrySet();
-
- for (Entry entityCounterEntry : entityCounterEntries) {
-
- supplyAsync(new Supplier() {
-
- @Override
- public Void get() {
- MDC.setContextMap(contextMap);
- String jsonString = Json.createObjectBuilder().add(
- "count", entityCounterEntry.getValue().get())
- .add("entityType", entityCounterEntry.getKey())
- .add("timestamp", currentFormattedTimeStamp).build().toString();
-
- String link = null;
- try {
- link = elasticSearchAdapter.buildElasticSearchPostUrl(indexName);
- OperationResult or = elasticSearchAdapter.doPost(link, jsonString, MediaType.APPLICATION_JSON_TYPE);
- updateElasticSearchCounters(HttpMethod.POST, entityCounterEntry.getKey(), or);
- } catch (Exception exc) {
- LOG.error(AaiUiMsgs.ES_STORE_FAILURE, exc.getMessage() );
- }
-
- return null;
- }
-
- }, esExecutor).whenComplete((result, error) -> {
-
- esWorkOnHand.decrementAndGet();
-
- });
-
- }
-
- while (esWorkOnHand.get() > 0) {
-
- try {
- Thread.sleep(500);
- } catch (InterruptedException exc) {
- LOG.error(AaiUiMsgs.INTERRUPTED, "historical Entities", exc.getMessage());
- }
- }
-
- }
-
- @Override
- public SynchronizerState getState() {
-
- if (!isSyncDone()) {
- return SynchronizerState.PERFORMING_SYNCHRONIZATION;
- }
-
- return SynchronizerState.IDLE;
-
- }
-
- /* (non-Javadoc)
- * @see org.openecomp.sparky.synchronizer.IndexSynchronizer#getStatReport(boolean)
- */
- @Override
- public String getStatReport(boolean showFinalReport) {
- syncDurationInMs = System.currentTimeMillis() - syncStartedTimeStampInMs;
- return this.getStatReport(syncDurationInMs, showFinalReport);
- }
-
- /* (non-Javadoc)
- * @see org.openecomp.sparky.synchronizer.IndexSynchronizer#shutdown()
- */
- @Override
- public void shutdown() {
- this.shutdownExecutors();
- }
-
- @Override
- protected boolean isSyncDone() {
-
- int totalWorkOnHand = aaiWorkOnHand.get() + esWorkOnHand.get();
-
- if (LOG.isDebugEnabled()) {
- LOG.debug(AaiUiMsgs.DEBUG_GENERIC,indexName + ", isSyncDone(), totalWorkOnHand = " + totalWorkOnHand
- + " all work enumerated = " + allWorkEnumerated);
- }
-
- if (totalWorkOnHand > 0 || !allWorkEnumerated) {
- return false;
- }
-
- this.syncInProgress = false;
-
- return true;
- }
-
- /* (non-Javadoc)
- * @see org.openecomp.sparky.synchronizer.AbstractEntitySynchronizer#clearCache()
- */
- @Override
- public void clearCache() {
-
- if (syncInProgress) {
- LOG.debug(AaiUiMsgs.DEBUG_GENERIC, "Historical Entity Summarizer in progress, request to clear cache ignored");
- return;
- }
-
- super.clearCache();
- this.resetCounters();
- if (entityCounters != null) {
- entityCounters.clear();
- }
-
- allWorkEnumerated = false;
-
- }
-
-}
diff --git a/src/main/java/org/onap/aai/sparky/aggregation/sync/HistoricalEntitySyncController.java b/src/main/java/org/onap/aai/sparky/aggregation/sync/HistoricalEntitySyncController.java
deleted file mode 100644
index a9b36a9..0000000
--- a/src/main/java/org/onap/aai/sparky/aggregation/sync/HistoricalEntitySyncController.java
+++ /dev/null
@@ -1,90 +0,0 @@
-/**
- * ============LICENSE_START=======================================================
- * org.onap.aai
- * ================================================================================
- * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved.
- * Copyright © 2017-2018 Amdocs
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-package org.onap.aai.sparky.aggregation.sync;
-
-import org.onap.aai.sparky.config.oxm.SearchableEntityLookup;
-import org.onap.aai.sparky.dal.ActiveInventoryAdapter;
-import org.onap.aai.sparky.dal.ElasticSearchAdapter;
-import org.onap.aai.sparky.sync.ElasticSearchSchemaFactory;
-import org.onap.aai.sparky.sync.IndexIntegrityValidator;
-import org.onap.aai.sparky.sync.SyncControllerImpl;
-import org.onap.aai.sparky.sync.SyncControllerRegistrar;
-import org.onap.aai.sparky.sync.SyncControllerRegistry;
-import org.onap.aai.sparky.sync.config.ElasticSearchEndpointConfig;
-import org.onap.aai.sparky.sync.config.ElasticSearchSchemaConfig;
-import org.onap.aai.sparky.sync.config.NetworkStatisticsConfig;
-import org.onap.aai.sparky.sync.config.SyncControllerConfig;
-
-public class HistoricalEntitySyncController extends SyncControllerImpl
- implements SyncControllerRegistrar {
-
- private SyncControllerRegistry syncControllerRegistry;
-
- public HistoricalEntitySyncController(SyncControllerConfig syncControllerConfig,
- ActiveInventoryAdapter aaiAdapter, ElasticSearchAdapter esAdapter,
- ElasticSearchSchemaConfig schemaConfig, ElasticSearchEndpointConfig endpointConfig,
- int syncFrequencyInMinutes, NetworkStatisticsConfig aaiStatConfig,
- NetworkStatisticsConfig esStatConfig, SearchableEntityLookup searchableEntityLookup)
- throws Exception {
- super(syncControllerConfig);
-
- // final String controllerName = "Historical Entity Count Synchronizer";
-
- long taskFrequencyInMs = syncFrequencyInMinutes * 60 * 1000;
-
- setDelayInMs(taskFrequencyInMs);
- setSyncFrequencyInMs(taskFrequencyInMs);
-
- IndexIntegrityValidator entityCounterHistoryValidator = new IndexIntegrityValidator(esAdapter,
- schemaConfig, endpointConfig, ElasticSearchSchemaFactory.getIndexSchema(schemaConfig));
-
- registerIndexValidator(entityCounterHistoryValidator);
-
- HistoricalEntitySummarizer historicalSummarizer = new HistoricalEntitySummarizer(schemaConfig,
- syncControllerConfig.getNumInternalSyncWorkers(),
- syncControllerConfig.getNumSyncActiveInventoryWorkers(),
- syncControllerConfig.getNumSyncElasticWorkers(),aaiStatConfig, esStatConfig,searchableEntityLookup);
-
- historicalSummarizer.setAaiAdapter(aaiAdapter);
- historicalSummarizer.setElasticSearchAdapter(esAdapter);
-
- registerEntitySynchronizer(historicalSummarizer);
-
- }
-
- public SyncControllerRegistry getSyncControllerRegistry() {
- return syncControllerRegistry;
- }
-
- public void setSyncControllerRegistry(SyncControllerRegistry syncControllerRegistry) {
- this.syncControllerRegistry = syncControllerRegistry;
- }
-
- @Override
- public void registerController() {
- if ( syncControllerRegistry != null ) {
- if ( syncControllerConfig.isEnabled()) {
- syncControllerRegistry.registerSyncController(this);
- }
- }
-
- }
-}
diff --git a/src/main/java/org/onap/aai/sparky/analytics/AbstractStatistics.java b/src/main/java/org/onap/aai/sparky/analytics/AbstractStatistics.java
deleted file mode 100644
index 1ff38c8..0000000
--- a/src/main/java/org/onap/aai/sparky/analytics/AbstractStatistics.java
+++ /dev/null
@@ -1,174 +0,0 @@
-/**
- * ============LICENSE_START=======================================================
- * org.onap.aai
- * ================================================================================
- * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved.
- * Copyright © 2017-2018 Amdocs
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-package org.onap.aai.sparky.analytics;
-
-import java.util.HashMap;
-import java.util.concurrent.atomic.AtomicInteger;
-
-/**
- * The Class AbstractStatistics.
- */
-public class AbstractStatistics implements ComponentStatistics {
-
- private HashMap namedCounters;
- private HashMap namedHistograms;
-
- /**
- * Instantiates a new abstract statistics.
- */
- protected AbstractStatistics() {
- namedCounters = new HashMap();
- namedHistograms = new HashMap();
- }
-
- /* (non-Javadoc)
- * @see org.openecomp.sparky.analytics.ComponentStatistics#addCounter(java.lang.String)
- */
- /*
- * sync-lock the creation of counters during initialization, but run time should not use lock
- * synchronization, only thread safe types
- *
- */
- @Override
- public synchronized void addCounter(String key) {
-
- AtomicInteger counter = namedCounters.get(key);
-
- if (counter == null) {
- counter = new AtomicInteger(0);
- namedCounters.put(key, counter);
- }
-
- }
-
- /* (non-Javadoc)
- * @see org.openecomp.sparky.analytics.ComponentStatistics#pegCounter(java.lang.String)
- */
- @Override
- public void pegCounter(String key) {
-
- AtomicInteger counter = namedCounters.get(key);
-
- if (counter != null) {
- counter.incrementAndGet();
- }
-
- }
-
- /* (non-Javadoc)
- * @see org.openecomp.sparky.analytics.ComponentStatistics#incrementCounter(java.lang.String, int)
- */
- @Override
- public void incrementCounter(String key, int value) {
-
- AtomicInteger counter = namedCounters.get(key);
-
- if (counter != null) {
- counter.addAndGet(value);
- }
-
- }
-
-
- /* (non-Javadoc)
- * @see org.openecomp.sparky.analytics.ComponentStatistics#addHistogram(java.lang.String, java.lang.String, long, int, int)
- */
- @Override
- public synchronized void addHistogram(String key, String histName, long maxYValue, int numBins,
- int numDecimalPoints) {
- HistogramSampler histSampler = namedHistograms.get(key);
-
- if (histSampler == null) {
- histSampler = new HistogramSampler(histName, maxYValue, numBins, numDecimalPoints);
- namedHistograms.put(key, histSampler);
- }
-
- }
-
- /* (non-Javadoc)
- * @see org.openecomp.sparky.analytics.ComponentStatistics#updateHistogram(java.lang.String, long)
- */
- @Override
- public void updateHistogram(String key, long value) {
- HistogramSampler histSampler = namedHistograms.get(key);
-
- if (histSampler != null) {
- histSampler.track(value);
- }
- }
-
- /* (non-Javadoc)
- * @see org.openecomp.sparky.analytics.ComponentStatistics#reset()
- */
- @Override
- public void reset() {
-
- for (HistogramSampler h : namedHistograms.values()) {
- h.clear();
- }
-
- for (AtomicInteger c : namedCounters.values()) {
- c.set(0);
- }
-
- }
-
- /**
- * Gets the counter value.
- *
- * @param key the key
- * @return the counter value
- */
- protected int getCounterValue(String key) {
-
- AtomicInteger counter = namedCounters.get(key);
-
- if (counter == null) {
- return -1;
- }
-
- return counter.get();
-
- }
-
- /**
- * Gets the histogram stats.
- *
- * @param key the key
- * @param verboseEnabled the verbose enabled
- * @param indentPadding the indent padding
- * @return the histogram stats
- */
- protected String getHistogramStats(String key, boolean verboseEnabled, String indentPadding) {
-
- HistogramSampler histSampler = namedHistograms.get(key);
-
- if (histSampler == null) {
- return null;
- }
-
- return histSampler.getStats(verboseEnabled, indentPadding);
-
- }
-
-
-
-}
diff --git a/src/main/java/org/onap/aai/sparky/analytics/AveragingRingBuffer.java b/src/main/java/org/onap/aai/sparky/analytics/AveragingRingBuffer.java
deleted file mode 100644
index 3e868f3..0000000
--- a/src/main/java/org/onap/aai/sparky/analytics/AveragingRingBuffer.java
+++ /dev/null
@@ -1,117 +0,0 @@
-/**
- * ============LICENSE_START=======================================================
- * org.onap.aai
- * ================================================================================
- * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved.
- * Copyright © 2017-2018 Amdocs
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-package org.onap.aai.sparky.analytics;
-
-import java.util.concurrent.atomic.AtomicInteger;
-
-/**
- * TODO: Fill in description.
- *
- * @author davea
- */
-public class AveragingRingBuffer {
-
- private int numElements;
-
- private long[] data;
-
- private AtomicInteger index;
-
- private long average;
-
- private boolean initialAverageCalculated;
-
- /**
- * Instantiates a new averaging ring buffer.
- *
- * @param size the size
- */
- public AveragingRingBuffer(int size) {
-
- if (size == 0) {
- throw new IllegalArgumentException("Size must be greater than zero");
- }
-
- this.initialAverageCalculated = false;
- this.numElements = size;
- this.data = new long[this.numElements];
- this.index = new AtomicInteger(-1);
- }
-
- /**
- * Calculate average.
- *
- * @param maxArrayIndex the max array index
- */
- private void calculateAverage(int maxArrayIndex) {
-
- long sum = 0;
-
- for (int i = 0; i <= maxArrayIndex; i++) {
- sum += data[i];
- }
-
- average = (sum / (maxArrayIndex + 1));
-
- }
-
- public long getAvg() {
-
- if (!initialAverageCalculated) {
- /*
- * until the index rolls once we will calculate the average from the data that has been added
- * to the array, not including the zero elements
- */
- if (index.get() < 0) {
- calculateAverage(0);
- } else {
- calculateAverage(index.get());
- }
-
- }
-
- return average;
- }
-
- /**
- * Adds the sample.
- *
- * @param value the value
- */
- public synchronized void addSample(long value) {
-
- index.incrementAndGet();
-
- data[index.get()] = value;
-
- if (index.get() == (numElements - 1)) {
- calculateAverage(numElements - 1);
-
- if (!initialAverageCalculated) {
- initialAverageCalculated = true;
- }
-
- index.set(-1);
- }
-
- }
-
-}
diff --git a/src/main/java/org/onap/aai/sparky/analytics/ComponentStatistics.java b/src/main/java/org/onap/aai/sparky/analytics/ComponentStatistics.java
deleted file mode 100644
index ab9fbca..0000000
--- a/src/main/java/org/onap/aai/sparky/analytics/ComponentStatistics.java
+++ /dev/null
@@ -1,76 +0,0 @@
-/**
- * ============LICENSE_START=======================================================
- * org.onap.aai
- * ================================================================================
- * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved.
- * Copyright © 2017-2018 Amdocs
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-package org.onap.aai.sparky.analytics;
-
-
-/**
- * The Interface ComponentStatistics.
- */
-public interface ComponentStatistics {
-
- /**
- * Adds the counter.
- *
- * @param key the key
- */
- public void addCounter(String key);
-
- /**
- * Peg counter.
- *
- * @param key the key
- */
- public void pegCounter(String key);
-
- /**
- * Increment counter.
- *
- * @param key the key
- * @param value the value
- */
- public void incrementCounter(String key, int value);
-
- /**
- * Adds the histogram.
- *
- * @param key the key
- * @param name the name
- * @param maxYValue the max Y value
- * @param numBins the num bins
- * @param numDecimalPoints the num decimal points
- */
- public void addHistogram(String key, String name, long maxYValue, int numBins,
- int numDecimalPoints);
-
- /**
- * Update histogram.
- *
- * @param key the key
- * @param value the value
- */
- public void updateHistogram(String key, long value);
-
- /**
- * Reset.
- */
- public void reset();
-
-}
diff --git a/src/main/java/org/onap/aai/sparky/analytics/HistogramSampler.java b/src/main/java/org/onap/aai/sparky/analytics/HistogramSampler.java
deleted file mode 100644
index c1fa9f1..0000000
--- a/src/main/java/org/onap/aai/sparky/analytics/HistogramSampler.java
+++ /dev/null
@@ -1,282 +0,0 @@
-/**
- * ============LICENSE_START=======================================================
- * org.onap.aai
- * ================================================================================
- * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved.
- * Copyright © 2017-2018 Amdocs
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-package org.onap.aai.sparky.analytics;
-
-/**
- * A class that models a histogram for reporting and tracking long values with variable steps, bins,
- * and floating point accuracy.
- *
- * @author davea.
- */
-public final class HistogramSampler {
-
- private String label;
-
- private long binMaxValue;
-
- private int numBins;
-
- private double stepSize;
-
- private long sampleValueTotal;
-
- private long minValue = -1;
-
- private long maxValue = 0;
-
- private long numSamples = 0;
-
- private long decimalPointAccuracy = 0;
-
- private static String FORMAT_FLOAT_TEMPLATE = "%%.%df";
-
- private String floatFormatStr;
-
- private long[] histogramBins;
-
- /**
- * Instantiates a new histogram sampler.
- *
- * @param label the label
- * @param maxValue the max value
- * @param numBins the num bins
- * @param decimalPointAccuracy the decimal point accuracy
- */
- public HistogramSampler(String label, long maxValue, int numBins, int decimalPointAccuracy) {
- this.label = label;
- this.binMaxValue = maxValue;
- this.numBins = numBins;
- this.stepSize = ((double) binMaxValue / (double) numBins);
- this.decimalPointAccuracy = decimalPointAccuracy;
- this.floatFormatStr = String.format(FORMAT_FLOAT_TEMPLATE, this.decimalPointAccuracy);
-
- /*
- * [numBins + 1] => last bin is catch-all for outliers
- */
-
- initializeHistogramBins(numBins + 1);
-
- }
-
- /**
- * Initialize histogram bins.
- *
- * @param numBins the num bins
- */
- private void initializeHistogramBins(int numBins) {
-
- histogramBins = new long[numBins];
- int counter = 0;
- while (counter < numBins) {
- histogramBins[counter] = 0;
- counter++;
- }
-
- }
-
- /*
- * Is it really necessary to synchronize the collection, or should we simply switch the underlying
- * data type to an AtomicLong
- */
-
- /**
- * Track.
- *
- * @param value the value
- */
- public synchronized void track(long value) {
-
- if (value < 0) {
- return;
- }
-
- sampleValueTotal += value;
- numSamples++;
-
- if (minValue == -1) {
- minValue = value;
- }
-
- if (value < minValue) {
- minValue = value;
- }
-
- if (value > maxValue) {
- maxValue = value;
- }
-
- /*
- * One step bin determination
- */
-
- if (value < (numBins * stepSize)) {
-
- int index = (int) (value / stepSize);
- histogramBins[index]++;
-
- } else {
- // peg the metric in the outlier bin
- histogramBins[numBins - 1]++;
- }
-
- }
-
- /**
- * Clear.
- */
- public void clear() {
-
- int counter = 0;
- while (counter < numBins) {
- histogramBins[counter] = 0;
- counter++;
- }
-
- minValue = -1;
- maxValue = 0;
- numSamples = 0;
- sampleValueTotal = 0;
-
- }
-
- /**
- * Re initialize bins.
- *
- * @param label the label
- * @param numBins the num bins
- * @param maxValue the max value
- * @param decimalPointAccuracy the decimal point accuracy
- */
- public void reInitializeBins(String label, int numBins, long maxValue, int decimalPointAccuracy) {
- this.label = label;
- this.decimalPointAccuracy = decimalPointAccuracy;
- this.floatFormatStr = String.format(FORMAT_FLOAT_TEMPLATE, this.decimalPointAccuracy);
- this.numBins = numBins;
- this.minValue = -1;
- this.maxValue = 0;
- initializeHistogramBins(numBins);
- this.stepSize = (maxValue / numBins);
- clear();
- }
-
- public long getNumberOfSamples() {
- return numSamples;
- }
-
- public long getTotalValueSum() {
- return sampleValueTotal;
- }
-
- /**
- * Gets the stats.
- *
- * @param formatted the formatted
- * @param indentPadding the indent padding
- * @return the stats
- */
- public String getStats(boolean formatted, String indentPadding) {
-
- StringBuilder sb = new StringBuilder(128);
-
-
- if (!formatted) {
- // generate CSV in the following format
-
- /*
- * label,minValue,maxValue,avgValue,numSamples,stepSize,numSteps,stepCounters
- */
- sb.append(indentPadding);
- sb.append(label).append(",");
- sb.append(minValue).append(",");
- sb.append(maxValue).append(",");
- if (numSamples == 0) {
- sb.append(0).append(",");
- } else {
- sb.append((sampleValueTotal / numSamples)).append(",");
- }
- sb.append(numSamples).append(",");
- sb.append(numBins).append(",");
- sb.append(String.format(floatFormatStr, stepSize));
-
- int counter = 0;
- while (counter < numBins) {
-
- if (counter != (numBins)) {
- sb.append(",");
- }
-
- sb.append(histogramBins[counter]);
-
- counter++;
-
- }
-
- return sb.toString();
-
- }
-
- sb.append("\n");
- sb.append(indentPadding).append("Label = ").append(label).append("\n");
- sb.append(indentPadding).append("Min = ").append(minValue).append("\n");
- sb.append(indentPadding).append("Max = ").append(maxValue).append("\n");
- sb.append(indentPadding).append("numSamples = ").append(numSamples).append("\n");
-
- if (numSamples == 0) {
- sb.append(indentPadding).append("Avg = ").append(0).append("\n");
- } else {
- sb.append(indentPadding).append("Avg = ").append((sampleValueTotal / numSamples))
- .append("\n");
- }
-
- sb.append(indentPadding).append("StepSize = ").append(String.format(floatFormatStr, stepSize))
- .append("\n");
-
- sb.append(indentPadding).append("Sample Histogram:").append("\n");
-
- int counter = 0;
- while (counter < numBins) {
-
- if (counter == (numBins - 1)) {
- // outlier bin
- double leftBound = (stepSize * counter);
- sb.append(indentPadding).append("\t")
- .append(" x >= " + String.format(floatFormatStr, leftBound) + " : "
- + histogramBins[counter])
- .append("\n");
-
- } else {
- double leftBound = (stepSize * counter);
- double rightBound = ((stepSize) * (counter + 1));
- sb.append(indentPadding).append("\t")
- .append((String.format(floatFormatStr, leftBound) + " < x < "
- + String.format(floatFormatStr, rightBound) + " : " + histogramBins[counter]))
- .append("\n");
- }
-
- counter++;
-
- }
-
- return sb.toString();
-
- }
-
-}
diff --git a/src/main/java/org/onap/aai/sparky/analytics/HistoricalCounter.java b/src/main/java/org/onap/aai/sparky/analytics/HistoricalCounter.java
deleted file mode 100644
index 68305f8..0000000
--- a/src/main/java/org/onap/aai/sparky/analytics/HistoricalCounter.java
+++ /dev/null
@@ -1,173 +0,0 @@
-/**
- * ============LICENSE_START=======================================================
- * org.onap.aai
- * ================================================================================
- * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved.
- * Copyright © 2017-2018 Amdocs
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-package org.onap.aai.sparky.analytics;
-
-/**
- * A simple class to model a historical counter. A set of values will be tracked and basic
- * statistics will be calculated in real time (n, min, max, avg).
- *
- * @author davea
- */
-public class HistoricalCounter {
-
- private double min;
-
- private double max;
-
- private double totalOfSamples;
-
- private long numSamples;
-
- private double value;
-
- private boolean maintainSingleValue;
-
- /**
- * Instantiates a new historical counter.
- *
- * @param trackSingleValue the track single value
- */
- public HistoricalCounter(boolean trackSingleValue) {
- min = -1;
- max = 0;
- totalOfSamples = 0;
- value = 0.0;
- numSamples = 0;
- this.maintainSingleValue = trackSingleValue;
- }
-
- public boolean isSingleValue() {
- return maintainSingleValue;
- }
-
- /**
- * Update.
- *
- * @param value the value
- */
- public synchronized void update(double value) {
-
- if (value < 0) {
- return;
- }
-
- if (maintainSingleValue) {
-
- this.value = value;
-
- } else {
-
- if (min == -1) {
- min = value;
- }
-
- if (value < min) {
- min = value;
- }
-
- if (value > max) {
- max = value;
- }
-
- totalOfSamples += value;
- numSamples++;
- }
- }
-
- public double getValue() {
- return value;
- }
-
- public double getMin() {
- return min;
- }
-
- public double getMax() {
- return max;
- }
-
- public long getNumSamples() {
- return numSamples;
- }
-
- public double getAvg() {
- if (numSamples == 0) {
- return 0;
- }
-
- return (totalOfSamples / numSamples);
- }
- public void setMin(double min) {
- this.min = min;
- }
-
- public void setMax(double max) {
- this.max = max;
- }
-
- public double getTotalOfSamples() {
- return totalOfSamples;
- }
-
- public void setTotalOfSamples(double totalOfSamples) {
- this.totalOfSamples = totalOfSamples;
- }
-
- public void setNumSamples(long numSamples) {
- this.numSamples = numSamples;
- }
-
- public void setMaintainSingleValue(boolean maintainSingleValue) {
- this.maintainSingleValue = maintainSingleValue;
- }
-
-
- /**
- * Reset.
- */
- public synchronized void reset() {
- min = -1;
- max = 0;
- numSamples = 0;
- totalOfSamples = 0;
- value = 0.0;
- }
-
- /* (non-Javadoc)
- * @see java.lang.Object#toString()
- */
- @Override
- public String toString() {
- StringBuilder sb = new StringBuilder(32);
-
- if (maintainSingleValue) {
- sb.append("[ Val=").append(value).append(" ]");
- } else {
- sb.append("[ NumSamples=").append(numSamples).append(",");
- sb.append(" Min=").append(min).append(",");
- sb.append(" Max=").append(max).append(",");
- sb.append(" Avg=").append(getAvg()).append(" ]");
- }
-
- return sb.toString();
- }
-
-}
diff --git a/src/main/java/org/onap/aai/sparky/autosuggestion/sync/AutoSuggestionSyncController.java b/src/main/java/org/onap/aai/sparky/autosuggestion/sync/AutoSuggestionSyncController.java
deleted file mode 100644
index 071a5ef..0000000
--- a/src/main/java/org/onap/aai/sparky/autosuggestion/sync/AutoSuggestionSyncController.java
+++ /dev/null
@@ -1,99 +0,0 @@
-/**
- * ============LICENSE_START=======================================================
- * org.onap.aai
- * ================================================================================
- * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved.
- * Copyright © 2017-2018 Amdocs
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-package org.onap.aai.sparky.autosuggestion.sync;
-
-import org.onap.aai.sparky.config.oxm.OxmEntityLookup;
-import org.onap.aai.sparky.config.oxm.SuggestionEntityLookup;
-import org.onap.aai.sparky.dal.ActiveInventoryAdapter;
-import org.onap.aai.sparky.dal.ElasticSearchAdapter;
-import org.onap.aai.sparky.search.filters.config.FiltersConfig;
-import org.onap.aai.sparky.sync.ElasticSearchIndexCleaner;
-import org.onap.aai.sparky.sync.ElasticSearchSchemaFactory;
-import org.onap.aai.sparky.sync.IndexCleaner;
-import org.onap.aai.sparky.sync.IndexIntegrityValidator;
-import org.onap.aai.sparky.sync.SyncControllerImpl;
-import org.onap.aai.sparky.sync.SyncControllerRegistrar;
-import org.onap.aai.sparky.sync.SyncControllerRegistry;
-import org.onap.aai.sparky.sync.config.ElasticSearchEndpointConfig;
-import org.onap.aai.sparky.sync.config.ElasticSearchSchemaConfig;
-import org.onap.aai.sparky.sync.config.NetworkStatisticsConfig;
-import org.onap.aai.sparky.sync.config.SyncControllerConfig;
-
-public class AutoSuggestionSyncController extends SyncControllerImpl implements SyncControllerRegistrar {
-
- private SyncControllerRegistry syncControllerRegistry;
-
- public AutoSuggestionSyncController(SyncControllerConfig syncControllerConfig,
- ActiveInventoryAdapter aaiAdapter, ElasticSearchAdapter esAdapter,
- ElasticSearchSchemaConfig schemaConfig, ElasticSearchEndpointConfig endpointConfig,
- NetworkStatisticsConfig aaiStatConfig, NetworkStatisticsConfig esStatConfig,
- OxmEntityLookup oxmEntityLookup, SuggestionEntityLookup suggestionEntityLookup,
- FiltersConfig filtersConfig) throws Exception {
- super(syncControllerConfig);
-
- // final String controllerName = "Auto Suggestion Synchronizer";
-
- IndexIntegrityValidator autoSuggestionIndexValidator = new IndexIntegrityValidator(esAdapter,
- schemaConfig, endpointConfig, ElasticSearchSchemaFactory.getIndexSchema(schemaConfig));
-
- registerIndexValidator(autoSuggestionIndexValidator);
-
- AutosuggestionSynchronizer suggestionSynchronizer = new AutosuggestionSynchronizer(schemaConfig,
- syncControllerConfig.getNumInternalSyncWorkers(),
- syncControllerConfig.getNumSyncActiveInventoryWorkers(),
- syncControllerConfig.getNumSyncElasticWorkers(), aaiStatConfig, esStatConfig,
- oxmEntityLookup, suggestionEntityLookup, filtersConfig);
-
- suggestionSynchronizer.setAaiAdapter(aaiAdapter);
- suggestionSynchronizer.setElasticSearchAdapter(esAdapter);
-
- registerEntitySynchronizer(suggestionSynchronizer);
-
- IndexCleaner autosuggestIndexCleaner =
- new ElasticSearchIndexCleaner(esAdapter, endpointConfig, schemaConfig);
-
- registerIndexCleaner(autosuggestIndexCleaner);
-
- }
-
- public SyncControllerRegistry getSyncControllerRegistry() {
- return syncControllerRegistry;
- }
-
-
-
- public void setSyncControllerRegistry(SyncControllerRegistry syncControllerRegistry) {
- this.syncControllerRegistry = syncControllerRegistry;
- }
-
-
-
- @Override
- public void registerController() {
-
- if ( syncControllerRegistry != null ) {
- if ( syncControllerConfig.isEnabled()) {
- syncControllerRegistry.registerSyncController(this);
- }
- }
-
- }
-}
diff --git a/src/main/java/org/onap/aai/sparky/autosuggestion/sync/AutosuggestionSynchronizer.java b/src/main/java/org/onap/aai/sparky/autosuggestion/sync/AutosuggestionSynchronizer.java
deleted file mode 100644
index aad7bcb..0000000
--- a/src/main/java/org/onap/aai/sparky/autosuggestion/sync/AutosuggestionSynchronizer.java
+++ /dev/null
@@ -1,772 +0,0 @@
-/**
- * ============LICENSE_START=======================================================
- * org.onap.aai
- * ================================================================================
- * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved.
- * Copyright © 2017-2018 Amdocs
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-package org.onap.aai.sparky.autosuggestion.sync;
-
-import static java.util.concurrent.CompletableFuture.supplyAsync;
-
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.Deque;
-import java.util.EnumSet;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import java.util.concurrent.ConcurrentHashMap;
-import java.util.concurrent.ConcurrentLinkedDeque;
-import java.util.concurrent.ExecutorService;
-import java.util.concurrent.atomic.AtomicInteger;
-import java.util.function.Supplier;
-
-import org.onap.aai.cl.api.Logger;
-import org.onap.aai.cl.eelf.LoggerFactory;
-import org.onap.aai.cl.mdc.MdcContext;
-import org.onap.aai.restclient.client.OperationResult;
-import org.onap.aai.sparky.config.oxm.OxmEntityDescriptor;
-import org.onap.aai.sparky.config.oxm.OxmEntityLookup;
-import org.onap.aai.sparky.config.oxm.SuggestionEntityDescriptor;
-import org.onap.aai.sparky.config.oxm.SuggestionEntityLookup;
-import org.onap.aai.sparky.dal.ActiveInventoryAdapter;
-import org.onap.aai.sparky.dal.NetworkTransaction;
-import org.onap.aai.sparky.dal.rest.HttpMethod;
-import org.onap.aai.sparky.logging.AaiUiMsgs;
-import org.onap.aai.sparky.search.filters.config.FiltersConfig;
-import org.onap.aai.sparky.sync.AbstractEntitySynchronizer;
-import org.onap.aai.sparky.sync.IndexSynchronizer;
-import org.onap.aai.sparky.sync.SynchronizerConstants;
-import org.onap.aai.sparky.sync.config.ElasticSearchSchemaConfig;
-import org.onap.aai.sparky.sync.config.NetworkStatisticsConfig;
-import org.onap.aai.sparky.sync.entity.SelfLinkDescriptor;
-import org.onap.aai.sparky.sync.entity.SuggestionSearchEntity;
-import org.onap.aai.sparky.sync.enumeration.OperationState;
-import org.onap.aai.sparky.sync.enumeration.SynchronizerState;
-import org.onap.aai.sparky.sync.task.PerformActiveInventoryRetrieval;
-import org.onap.aai.sparky.sync.task.PerformElasticSearchPut;
-import org.onap.aai.sparky.sync.task.PerformElasticSearchRetrieval;
-import org.onap.aai.sparky.util.NodeUtils;
-import org.onap.aai.sparky.util.SuggestionsPermutation;
-import org.slf4j.MDC;
-
-import com.fasterxml.jackson.core.JsonProcessingException;
-import com.fasterxml.jackson.databind.JsonNode;
-import com.fasterxml.jackson.databind.node.ArrayNode;
-
-/**
- * The Class AutosuggestionSynchronizer.
- */
-public class AutosuggestionSynchronizer extends AbstractEntitySynchronizer
- implements IndexSynchronizer {
-
- private class RetrySuggestionEntitySyncContainer {
- NetworkTransaction txn;
- SuggestionSearchEntity ssec;
-
- /**
- * Instantiates a new RetrySuggestionEntitySyncContainer.
- *
- * @param txn the txn
- * @param icer the icer
- */
- public RetrySuggestionEntitySyncContainer(NetworkTransaction txn, SuggestionSearchEntity icer) {
- this.txn = txn;
- this.ssec = icer;
- }
-
- public NetworkTransaction getNetworkTransaction() {
- return txn;
- }
-
- public SuggestionSearchEntity getSuggestionSearchEntity() {
- return ssec;
- }
- }
-
- private static final Logger LOG =
- LoggerFactory.getInstance().getLogger(AutosuggestionSynchronizer.class);
- private static final String INSERTION_DATE_TIME_FORMAT = "yyyyMMdd'T'HHmmssZ";
-
- private boolean allWorkEnumerated;
- private Deque selflinks;
- private ConcurrentHashMap entityCounters;
- private boolean syncInProgress;
- private Map contextMap;
- protected ExecutorService esPutExecutor;
- private Deque retryQueue;
- private Map retryLimitTracker;
- private OxmEntityLookup oxmEntityLookup;
- private SuggestionEntityLookup suggestionEntityLookup;
- private FiltersConfig filtersConfig;
-
- /**
- * Instantiates a new historical entity summarizer.
- *
- * @param indexName the index name
- * @throws Exception the exception
- */
- public AutosuggestionSynchronizer(ElasticSearchSchemaConfig schemaConfig, int internalSyncWorkers,
- int aaiWorkers, int esWorkers, NetworkStatisticsConfig aaiStatConfig,
- NetworkStatisticsConfig esStatConfig, OxmEntityLookup oxmEntityLookup,
- SuggestionEntityLookup suggestionEntityLookup, FiltersConfig filtersConfig) throws Exception {
-
- super(LOG, "ASES-" + schemaConfig.getIndexName().toUpperCase(), internalSyncWorkers, aaiWorkers,
- esWorkers, schemaConfig.getIndexName(), aaiStatConfig, esStatConfig);
-
- this.oxmEntityLookup = oxmEntityLookup;
- this.suggestionEntityLookup = suggestionEntityLookup;
- this.allWorkEnumerated = false;
- this.selflinks = new ConcurrentLinkedDeque();
- this.entityCounters = new ConcurrentHashMap();
- this.synchronizerName = "Autosuggestion Entity Synchronizer";
- this.enabledStatFlags = EnumSet.of(StatFlag.AAI_REST_STATS, StatFlag.ES_REST_STATS);
- this.syncInProgress = false;
- this.contextMap = MDC.getCopyOfContextMap();
- this.esPutExecutor = NodeUtils.createNamedExecutor("SUES-ES-PUT", 5, LOG);
- this.retryQueue = new ConcurrentLinkedDeque();
- this.retryLimitTracker = new ConcurrentHashMap();
- this.syncDurationInMs = -1;
- this.filtersConfig = filtersConfig;
- }
-
- /**
- * Collect all the work.
- *
- * @return the operation state
- */
- private OperationState collectAllTheWork() {
- final Map contextMap = MDC.getCopyOfContextMap();
- Map descriptorMap =
- suggestionEntityLookup.getSuggestionSearchEntityDescriptors();
-
- if (descriptorMap.isEmpty()) {
- LOG.error(AaiUiMsgs.ERROR_LOADING_OXM_SUGGESTIBLE_ENTITIES);
- LOG.info(AaiUiMsgs.ERROR_LOADING_OXM_SUGGESTIBLE_ENTITIES);
- return OperationState.ERROR;
- }
-
- Collection syncTypes = descriptorMap.keySet();
-
- try {
-
- /*
- * launch a parallel async thread to process the documents for each entity-type (to max the of
- * the configured executor anyway)
- */
-
- aaiWorkOnHand.set(syncTypes.size());
-
- for (String key : syncTypes) {
-
- supplyAsync(new Supplier() {
-
- @Override
- public Void get() {
- MDC.setContextMap(contextMap);
- OperationResult typeLinksResult = null;
- try {
- typeLinksResult = aaiAdapter.getSelfLinksByEntityType(key);
- aaiWorkOnHand.decrementAndGet();
- processEntityTypeSelfLinks(typeLinksResult);
- } catch (Exception exc) {
- LOG.error(AaiUiMsgs.ERROR_GENERIC,
- "An error occurred while processing entity self-links. Error: "
- + exc.getMessage());
- }
-
- return null;
- }
-
- }, aaiExecutor).whenComplete((result, error) -> {
-
- if (error != null) {
- LOG.error(AaiUiMsgs.ERROR_GENERIC,
- "An error occurred getting data from AAI. Error = " + error.getMessage());
- }
- });
-
- }
-
- while (aaiWorkOnHand.get() != 0) {
-
- if (LOG.isDebugEnabled()) {
- LOG.debug(AaiUiMsgs.WAIT_FOR_ALL_SELFLINKS_TO_BE_COLLECTED);
- }
-
- Thread.sleep(1000);
- }
-
- aaiWorkOnHand.set(selflinks.size());
- allWorkEnumerated = true;
- syncEntityTypes();
-
- while (!isSyncDone()) {
- performRetrySync();
- Thread.sleep(1000);
- }
-
- /*
- * Make sure we don't hang on to retries that failed which could cause issues during future
- * syncs
- */
- retryLimitTracker.clear();
-
- } catch (Exception exc) {
- LOG.error(AaiUiMsgs.ERROR_GENERIC,
- "An error occurred while performing the sync. Error: " + exc.getMessage());
- }
-
- return OperationState.OK;
-
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.openecomp.sparky.synchronizer.IndexSynchronizer#doSync()
- */
- @Override
- public OperationState doSync() {
- this.syncDurationInMs = -1;
- syncStartedTimeStampInMs = System.currentTimeMillis();
- String txnID = NodeUtils.getRandomTxnId();
- MdcContext.initialize(txnID, "AutosuggestionSynchronizer", "", "Sync", "");
-
- return collectAllTheWork();
- }
-
- /**
- * Process entity type self links.
- *
- * @param operationResult the operation result
- */
- private void processEntityTypeSelfLinks(OperationResult operationResult) {
-
- JsonNode rootNode = null;
-
- if ( operationResult == null ) {
- return;
- }
-
- final String jsonResult = operationResult.getResult();
-
- if (jsonResult != null && jsonResult.length() > 0 && operationResult.wasSuccessful()) {
-
- try {
- rootNode = mapper.readTree(jsonResult);
- } catch (IOException exc) {
- String message = "Could not deserialize JSON (representing operation result) as node tree. "
- + "Operation result = " + jsonResult + ". " + exc.getLocalizedMessage();
- LOG.error(AaiUiMsgs.JSON_PROCESSING_ERROR, message);
- }
-
- JsonNode resultData = rootNode.get("result-data");
- ArrayNode resultDataArrayNode = null;
-
- if (resultData.isArray()) {
- resultDataArrayNode = (ArrayNode) resultData;
-
- Iterator elementIterator = resultDataArrayNode.elements();
- JsonNode element = null;
-
- while (elementIterator.hasNext()) {
- element = elementIterator.next();
-
- final String resourceType = NodeUtils.getNodeFieldAsText(element, "resource-type");
- final String resourceLink = NodeUtils.getNodeFieldAsText(element, "resource-link");
-
- OxmEntityDescriptor descriptor = null;
-
- if (resourceType != null && resourceLink != null) {
-
- descriptor = oxmEntityLookup.getEntityDescriptors().get(resourceType);
-
- if (descriptor == null) {
- LOG.error(AaiUiMsgs.MISSING_ENTITY_DESCRIPTOR, resourceType);
- // go to next element in iterator
- continue;
- }
- selflinks.add(new SelfLinkDescriptor(resourceLink,
- SynchronizerConstants.NODES_ONLY_MODIFIER, resourceType));
-
-
- }
- }
- }
- }
- }
-
- /**
- * Sync entity types.
- */
- private void syncEntityTypes() {
-
- while (selflinks.peek() != null) {
-
- SelfLinkDescriptor linkDescriptor = selflinks.poll();
- aaiWorkOnHand.decrementAndGet();
-
- OxmEntityDescriptor descriptor = null;
-
- if (linkDescriptor.getSelfLink() != null && linkDescriptor.getEntityType() != null) {
-
- descriptor = oxmEntityLookup.getEntityDescriptors().get(linkDescriptor.getEntityType());
-
- if (descriptor == null) {
- LOG.error(AaiUiMsgs.MISSING_ENTITY_DESCRIPTOR, linkDescriptor.getEntityType());
- // go to next element in iterator
- continue;
- }
-
- NetworkTransaction txn = new NetworkTransaction();
- txn.setDescriptor(descriptor);
- txn.setLink(linkDescriptor.getSelfLink());
- txn.setOperationType(HttpMethod.GET);
- txn.setEntityType(linkDescriptor.getEntityType());
-
- aaiWorkOnHand.incrementAndGet();
-
- supplyAsync(new PerformActiveInventoryRetrieval(txn, aaiAdapter), aaiExecutor)
- .whenComplete((result, error) -> {
-
- aaiWorkOnHand.decrementAndGet();
-
- if (error != null) {
- LOG.error(AaiUiMsgs.AAI_RETRIEVAL_FAILED_GENERIC, error.getLocalizedMessage());
- } else {
- if (result == null) {
- LOG.error(AaiUiMsgs.AAI_RETRIEVAL_FAILED_FOR_SELF_LINK,
- linkDescriptor.getSelfLink());
- } else {
- updateActiveInventoryCounters(result);
- fetchDocumentForUpsert(result);
- }
- }
- });
- }
-
- }
-
- }
-
- /*
- * Return a set of valid suggestion attributes for the provided entityName that are present in the
- * JSON
- *
- * @param node JSON node in which the attributes should be found
- *
- * @param entityName Name of the entity
- *
- * @return List of all valid suggestion attributes(key's)
- */
- public List getSuggestableAttrNamesFromReponse(JsonNode node, String entityName) {
- List suggestableAttr = new ArrayList();
-
- HashMap desc =
- suggestionEntityLookup.getSuggestionSearchEntityOxmModel().get(entityName);
-
- if (desc != null) {
-
- String attr = desc.get("suggestibleAttributes");
-
- if (attr != null) {
- suggestableAttr = Arrays.asList(attr.split(","));
- List suggestableValue = new ArrayList();
- for (String attribute : suggestableAttr) {
- if (node.get(attribute) != null && node.get(attribute).asText().length() > 0) {
- suggestableValue.add(attribute);
- }
- }
- return suggestableValue;
- }
- }
-
- return new ArrayList();
- }
-
- /**
- * Fetch all the documents for upsert. Based on the number of permutations that are available the
- * number of documents will be different
- *
- * @param txn the txn
- */
- private void fetchDocumentForUpsert(NetworkTransaction txn) {
- if (!txn.getOperationResult().wasSuccessful()) {
- String message = "Self link failure. Result - " + txn.getOperationResult().getResult();
- LOG.error(AaiUiMsgs.ERROR_GENERIC, message);
- return;
- }
- try {
- final String jsonResult = txn.getOperationResult().getResult();
-
- if (jsonResult != null && jsonResult.length() > 0) {
-
- // Step 1: Calculate the number of possible permutations of attributes
- String entityName = txn.getDescriptor().getEntityName();
- JsonNode entityNode = mapper.readTree(jsonResult);
-
- List availableSuggestableAttrName =
- getSuggestableAttrNamesFromReponse(entityNode, entityName);
-
- ArrayList> uniqueLists =
- SuggestionsPermutation.getNonEmptyUniqueLists(availableSuggestableAttrName);
- // Now we have a list of all possible permutations for the status that are
- // defined for this entity type. Try inserting a document for every combination.
- for (ArrayList uniqueList : uniqueLists) {
-
- SuggestionSearchEntity sse = new SuggestionSearchEntity(filtersConfig, suggestionEntityLookup);
- sse.setSuggestableAttr(uniqueList);
- sse.setFilterBasedPayloadFromResponse(entityNode, entityName, uniqueList);
- sse.setLink(ActiveInventoryAdapter.extractResourcePath(txn.getLink()));
- populateSuggestionSearchEntityDocument(sse, jsonResult, txn);
- // The unique id for the document will be created at derive fields
- sse.deriveFields();
- // Insert the document only if it has valid statuses
- if (sse.isSuggestableDoc()) {
- String link = null;
- try {
- link = elasticSearchAdapter.buildElasticSearchGetDocUrl(getIndexName(), sse.getId());
- } catch (Exception exc) {
- LOG.error(AaiUiMsgs.ES_FAILED_TO_CONSTRUCT_QUERY, exc.getLocalizedMessage());
- }
-
- if (link != null) {
- NetworkTransaction n2 = new NetworkTransaction();
- n2.setLink(link);
- n2.setEntityType(txn.getEntityType());
- n2.setDescriptor(txn.getDescriptor());
- n2.setOperationType(HttpMethod.GET);
-
- esWorkOnHand.incrementAndGet();
-
- supplyAsync(new PerformElasticSearchRetrieval(n2, elasticSearchAdapter), esExecutor)
- .whenComplete((result, error) -> {
-
- esWorkOnHand.decrementAndGet();
-
- if (error != null) {
- LOG.error(AaiUiMsgs.ES_RETRIEVAL_FAILED, error.getLocalizedMessage());
- } else {
- updateElasticSearchCounters(result);
- performDocumentUpsert(result, sse);
- }
- });
- }
- }
- }
- }
- } catch (JsonProcessingException exc) {
- LOG.error(AaiUiMsgs.ERROR_GENERIC, "There was a json processing error while processing the result from elasticsearch. Error: " + exc.getMessage());
- } catch (IOException exc) {
- LOG.error(AaiUiMsgs.ERROR_GENERIC, "There was a io processing error while processing the result from elasticsearch. Error: " + exc.getMessage());
- }
- }
-
- protected void populateSuggestionSearchEntityDocument(SuggestionSearchEntity sse, String result,
- NetworkTransaction txn) throws JsonProcessingException, IOException {
-
- OxmEntityDescriptor resultDescriptor = txn.getDescriptor();
-
- sse.setEntityType(resultDescriptor.getEntityName());
-
- JsonNode entityNode = mapper.readTree(result);
-
- List primaryKeyValues = new ArrayList();
- String pkeyValue = null;
-
- for (String keyName : resultDescriptor.getPrimaryKeyAttributeNames()) {
- pkeyValue = NodeUtils.getNodeFieldAsText(entityNode, keyName);
- if (pkeyValue != null) {
- primaryKeyValues.add(pkeyValue);
- } else {
- String message = "populateSuggestionSearchEntityDocument(),"
- + " pKeyValue is null for entityType = " + resultDescriptor.getEntityName();
- LOG.warn(AaiUiMsgs.WARN_GENERIC, message);
- }
- }
-
- final String primaryCompositeKeyValue = NodeUtils.concatArray(primaryKeyValues, "/");
- sse.setEntityPrimaryKeyValue(primaryCompositeKeyValue);
- sse.generateSuggestionInputPermutations();
- }
-
- protected void performDocumentUpsert(NetworkTransaction esGetTxn, SuggestionSearchEntity sse) {
- /**
- *
- *
- * As part of the response processing we need to do the following:
- * - 1. Extract the version (if present), it will be the ETAG when we use the
- * Search-Abstraction-Service
- *
- 2. Spawn next task which is to do the PUT operation into elastic with or with the version
- * tag
- *
- a) if version is null or RC=404, then standard put, no _update with version tag
- *
- b) if version != null, do PUT with _update?version= versionNumber in the URI to elastic
- *
- *
- */
- String link = null;
- try {
- link = elasticSearchAdapter.buildElasticSearchGetDocUrl(getIndexName(), sse.getId());
- } catch (Exception exc) {
- LOG.error(AaiUiMsgs.ES_LINK_UPSERT, exc.getLocalizedMessage());
- return;
- }
-
- boolean wasEntryDiscovered = false;
- if (esGetTxn.getOperationResult().getResultCode() == 404) {
- LOG.info(AaiUiMsgs.ES_SIMPLE_PUT, sse.getEntityPrimaryKeyValue());
- } else if (esGetTxn.getOperationResult().getResultCode() == 200) {
- wasEntryDiscovered = true;
- } else {
- /*
- * Not being a 200 does not mean a failure. eg 201 is returned for created. and 500 for es not
- * found TODO -> Should we return.
- */
- LOG.error(AaiUiMsgs.ES_OPERATION_RETURN_CODE,
- String.valueOf(esGetTxn.getOperationResult().getResultCode()));
- return;
- }
- // Insert a new document only if the paylod is different.
- // This is determined by hashing the payload and using it as a id for the document
- //
- if (!wasEntryDiscovered) {
- try {
- String jsonPayload = null;
-
- jsonPayload = sse.getAsJson();
- if (link != null && jsonPayload != null) {
-
- NetworkTransaction updateElasticTxn = new NetworkTransaction();
- updateElasticTxn.setLink(link);
- updateElasticTxn.setEntityType(esGetTxn.getEntityType());
- updateElasticTxn.setDescriptor(esGetTxn.getDescriptor());
- updateElasticTxn.setOperationType(HttpMethod.PUT);
-
- esWorkOnHand.incrementAndGet();
- supplyAsync(new PerformElasticSearchPut(jsonPayload, updateElasticTxn, elasticSearchAdapter),
- esPutExecutor).whenComplete((result, error) -> {
-
- esWorkOnHand.decrementAndGet();
-
- if (error != null) {
- String message = "Suggestion search entity sync UPDATE PUT error - "
- + error.getLocalizedMessage();
- LOG.error(AaiUiMsgs.ES_SUGGESTION_SEARCH_ENTITY_SYNC_ERROR, message);
- } else {
- updateElasticSearchCounters(result);
- processStoreDocumentResult(result, esGetTxn, sse);
- }
- });
- }
- } catch (Exception exc) {
- String message =
- "Exception caught during suggestion search entity sync PUT operation. Message - "
- + exc.getLocalizedMessage();
- LOG.error(AaiUiMsgs.ES_SUGGESTION_SEARCH_ENTITY_SYNC_ERROR, message);
- }
- }
- }
-
- private void processStoreDocumentResult(NetworkTransaction esPutResult,
- NetworkTransaction esGetResult, SuggestionSearchEntity sse) {
-
- OperationResult or = esPutResult.getOperationResult();
-
- if (!or.wasSuccessful()) {
- if (or.getResultCode() == VERSION_CONFLICT_EXCEPTION_CODE) {
-
- if (shouldAllowRetry(sse.getId())) {
- esWorkOnHand.incrementAndGet();
-
- RetrySuggestionEntitySyncContainer rssec =
- new RetrySuggestionEntitySyncContainer(esGetResult, sse);
- retryQueue.push(rssec);
-
- String message = "Store document failed during suggestion search entity synchronization"
- + " due to version conflict. Entity will be re-synced.";
- LOG.warn(AaiUiMsgs.ES_SUGGESTION_SEARCH_ENTITY_SYNC_ERROR, message);
- }
- } else {
- String message =
- "Store document failed during suggestion search entity synchronization with result code "
- + or.getResultCode() + " and result message " + or.getResult();
- LOG.error(AaiUiMsgs.ES_SUGGESTION_SEARCH_ENTITY_SYNC_ERROR, message);
- }
- }
- }
-
- /**
- * Perform retry sync.
- */
- private void performRetrySync() {
- while (retryQueue.peek() != null) {
-
- RetrySuggestionEntitySyncContainer susc = retryQueue.poll();
- if (susc != null) {
-
- SuggestionSearchEntity sus = susc.getSuggestionSearchEntity();
- NetworkTransaction txn = susc.getNetworkTransaction();
-
- String link = null;
- try {
- /*
- * In this retry flow the se object has already derived its fields
- */
- link = elasticSearchAdapter.buildElasticSearchGetDocUrl(getIndexName(), sus.getId());
- } catch (Exception exc) {
- LOG.error(AaiUiMsgs.ES_FAILED_TO_CONSTRUCT_URI, exc.getLocalizedMessage());
- }
-
- if (link != null) {
- NetworkTransaction retryTransaction = new NetworkTransaction();
- retryTransaction.setLink(link);
- retryTransaction.setEntityType(txn.getEntityType());
- retryTransaction.setDescriptor(txn.getDescriptor());
- retryTransaction.setOperationType(HttpMethod.GET);
-
- /*
- * IMPORTANT - DO NOT incrementAndGet the esWorkOnHand as this is a retry flow! We already
- * called incrementAndGet when queuing the failed PUT!
- */
-
- supplyAsync(new PerformElasticSearchRetrieval(retryTransaction, elasticSearchAdapter),
- esExecutor).whenComplete((result, error) -> {
-
- esWorkOnHand.decrementAndGet();
-
- if (error != null) {
- LOG.error(AaiUiMsgs.ES_RETRIEVAL_FAILED_RESYNC, error.getLocalizedMessage());
- } else {
- updateElasticSearchCounters(result);
- performDocumentUpsert(result, sus);
- }
- });
- }
-
- }
- }
- }
-
- /**
- * Should allow retry.
- *
- * @param id the id
- * @return true, if successful
- */
- private boolean shouldAllowRetry(String id) {
- boolean isRetryAllowed = true;
- if (retryLimitTracker.get(id) != null) {
- Integer currentCount = retryLimitTracker.get(id);
- if (currentCount.intValue() >= RETRY_COUNT_PER_ENTITY_LIMIT.intValue()) {
- isRetryAllowed = false;
- String message = "Searchable entity re-sync limit reached for " + id
- + ", re-sync will no longer be attempted for this entity";
- LOG.error(AaiUiMsgs.ES_SEARCHABLE_ENTITY_SYNC_ERROR, message);
- } else {
- Integer newCount = new Integer(currentCount.intValue() + 1);
- retryLimitTracker.put(id, newCount);
- }
- } else {
- Integer firstRetryCount = new Integer(1);
- retryLimitTracker.put(id, firstRetryCount);
- }
-
- return isRetryAllowed;
- }
-
-
-
- @Override
- public SynchronizerState getState() {
-
- if (!isSyncDone()) {
- return SynchronizerState.PERFORMING_SYNCHRONIZATION;
- }
-
- return SynchronizerState.IDLE;
-
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.openecomp.sparky.synchronizer.IndexSynchronizer#getStatReport(boolean)
- */
- @Override
- public String getStatReport(boolean showFinalReport) {
- syncDurationInMs = System.currentTimeMillis() - syncStartedTimeStampInMs;
- return getStatReport(syncDurationInMs, showFinalReport);
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.openecomp.sparky.synchronizer.IndexSynchronizer#shutdown()
- */
- @Override
- public void shutdown() {
- this.shutdownExecutors();
- }
-
- @Override
- protected boolean isSyncDone() {
-
- int totalWorkOnHand = aaiWorkOnHand.get() + esWorkOnHand.get();
-
- if (LOG.isDebugEnabled()) {
- LOG.debug(AaiUiMsgs.DEBUG_GENERIC, indexName + ", isSyncDone(), totalWorkOnHand = "
- + totalWorkOnHand + " all work enumerated = " + allWorkEnumerated);
- }
-
- if (totalWorkOnHand > 0 || !allWorkEnumerated) {
- return false;
- }
-
- this.syncInProgress = false;
-
- return true;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.openecomp.sparky.synchronizer.AbstractEntitySynchronizer#clearCache()
- */
- @Override
- public void clearCache() {
-
- if (syncInProgress) {
- LOG.debug(AaiUiMsgs.DEBUG_GENERIC,
- "Autosuggestion Entity Summarizer in progress, request to clear cache ignored");
- return;
- }
-
- super.clearCache();
- this.resetCounters();
- if (entityCounters != null) {
- entityCounters.clear();
- }
-
- allWorkEnumerated = false;
-
- }
-
-}
diff --git a/src/main/java/org/onap/aai/sparky/autosuggestion/sync/VnfAliasSuggestionSynchronizer.java b/src/main/java/org/onap/aai/sparky/autosuggestion/sync/VnfAliasSuggestionSynchronizer.java
deleted file mode 100644
index fe3ecd0..0000000
--- a/src/main/java/org/onap/aai/sparky/autosuggestion/sync/VnfAliasSuggestionSynchronizer.java
+++ /dev/null
@@ -1,193 +0,0 @@
-/**
- * ============LICENSE_START=======================================================
- * org.onap.aai
- * ================================================================================
- * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved.
- * Copyright © 2017-2018 Amdocs
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-package org.onap.aai.sparky.autosuggestion.sync;
-
-import static java.util.concurrent.CompletableFuture.supplyAsync;
-
-import java.util.Map;
-import java.util.concurrent.ExecutorService;
-
-import org.onap.aai.cl.api.Logger;
-import org.onap.aai.cl.eelf.LoggerFactory;
-import org.onap.aai.cl.mdc.MdcContext;
-import org.onap.aai.restclient.client.OperationResult;
-import org.onap.aai.sparky.dal.NetworkTransaction;
-import org.onap.aai.sparky.dal.rest.HttpMethod;
-import org.onap.aai.sparky.logging.AaiUiMsgs;
-import org.onap.aai.sparky.search.filters.config.FiltersConfig;
-import org.onap.aai.sparky.sync.AbstractEntitySynchronizer;
-import org.onap.aai.sparky.sync.IndexSynchronizer;
-import org.onap.aai.sparky.sync.config.ElasticSearchSchemaConfig;
-import org.onap.aai.sparky.sync.config.NetworkStatisticsConfig;
-import org.onap.aai.sparky.sync.entity.AggregationSuggestionEntity;
-import org.onap.aai.sparky.sync.enumeration.OperationState;
-import org.onap.aai.sparky.sync.enumeration.SynchronizerState;
-import org.onap.aai.sparky.sync.task.PerformElasticSearchPut;
-import org.onap.aai.sparky.util.NodeUtils;
-import org.slf4j.MDC;
-
-
-public class VnfAliasSuggestionSynchronizer extends AbstractEntitySynchronizer
- implements IndexSynchronizer {
-
- private static final Logger LOG =
- LoggerFactory.getInstance().getLogger(VnfAliasSuggestionSynchronizer.class);
-
- private boolean isSyncInProgress;
- private boolean shouldPerformRetry;
- private Map contextMap;
- protected ExecutorService esPutExecutor;
- private FiltersConfig filtersConfig;
-
- public VnfAliasSuggestionSynchronizer(ElasticSearchSchemaConfig schemaConfig,
- int internalSyncWorkers, int aaiWorkers, int esWorkers, NetworkStatisticsConfig aaiStatConfig,
- NetworkStatisticsConfig esStatConfig, FiltersConfig filtersConfig) throws Exception {
- super(LOG, "VASS-" + schemaConfig.getIndexName().toUpperCase(), internalSyncWorkers, aaiWorkers,
- esWorkers, schemaConfig.getIndexName(), aaiStatConfig, esStatConfig);
-
- this.isSyncInProgress = false;
- this.shouldPerformRetry = false;
- this.synchronizerName = "VNFs Alias Suggestion Synchronizer";
- this.contextMap = MDC.getCopyOfContextMap();
- this.esPutExecutor = NodeUtils.createNamedExecutor("ASS-ES-PUT", 2, LOG);
- this.filtersConfig = filtersConfig;
- }
-
- @Override
- protected boolean isSyncDone() {
- int totalWorkOnHand = esWorkOnHand.get();
-
- if (LOG.isDebugEnabled()) {
- LOG.debug(AaiUiMsgs.DEBUG_GENERIC,
- indexName + ", isSyncDone(), totalWorkOnHand = " + totalWorkOnHand);
- }
-
- if (totalWorkOnHand > 0 || !isSyncInProgress) {
- return false;
- }
-
- return true;
- }
-
- @Override
- public OperationState doSync() {
- isSyncInProgress = true;
- this.syncDurationInMs = -1;
- syncStartedTimeStampInMs = System.currentTimeMillis();
-
- syncEntity();
-
- while (!isSyncDone()) {
- try {
- if (shouldPerformRetry) {
- syncEntity();
- }
- Thread.sleep(1000);
- } catch (Exception exc) {
- // We don't care about this exception
- }
- }
-
- return OperationState.OK;
- }
-
- private void syncEntity() {
- String txnId = NodeUtils.getRandomTxnId();
- MdcContext.initialize(txnId, synchronizerName, "", "Sync", "");
-
- AggregationSuggestionEntity syncEntity = new AggregationSuggestionEntity(filtersConfig);
- syncEntity.deriveFields();
- syncEntity.initializeFilters();
-
- String link = null;
- try {
- link = elasticSearchAdapter.buildElasticSearchGetDocUrl(getIndexName(), syncEntity.getId());
- } catch (Exception exc) {
- LOG.error(AaiUiMsgs.ES_LINK_UPSERT, exc.getLocalizedMessage());
- }
-
- try {
- String jsonPayload = null;
- jsonPayload = syncEntity.getAsJson();
- if (link != null && jsonPayload != null) {
-
- NetworkTransaction elasticPutTxn = new NetworkTransaction();
- elasticPutTxn.setLink(link);
- elasticPutTxn.setOperationType(HttpMethod.PUT);
-
- esWorkOnHand.incrementAndGet();
- final Map contextMap = MDC.getCopyOfContextMap();
- supplyAsync(new PerformElasticSearchPut(jsonPayload, elasticPutTxn,
- elasticSearchAdapter, contextMap), esPutExecutor).whenComplete((result, error) -> {
-
- esWorkOnHand.decrementAndGet();
-
- if (error != null) {
- String message = "Aggregation suggestion entity sync UPDATE PUT error - "
- + error.getLocalizedMessage();
- LOG.error(AaiUiMsgs.ES_AGGREGATION_SUGGESTION_ENTITY_SYNC_ERROR, message);
- } else {
- updateElasticSearchCounters(result);
- wasEsOperationSuccessful(result);
- }
- });
- }
- } catch (Exception exc) {
- String message =
- "Exception caught during aggregation suggestion entity sync PUT operation. Message - "
- + exc.getLocalizedMessage();
- LOG.error(AaiUiMsgs.ES_AGGREGATION_SUGGESTION_ENTITY_SYNC_ERROR, message);
- }
- }
-
- private void wasEsOperationSuccessful(NetworkTransaction result) {
- if (result != null) {
- OperationResult opResult = result.getOperationResult();
-
- if (!opResult.wasSuccessful()) {
- shouldPerformRetry = true;
- } else {
- isSyncInProgress = false;
- shouldPerformRetry = false;
- }
- }
- }
-
- @Override
- public SynchronizerState getState() {
- if (!isSyncDone()) {
- return SynchronizerState.PERFORMING_SYNCHRONIZATION;
- }
-
- return SynchronizerState.IDLE;
- }
-
- @Override
- public String getStatReport(boolean shouldDisplayFinalReport) {
- syncDurationInMs = System.currentTimeMillis() - syncStartedTimeStampInMs;
- return getStatReport(syncDurationInMs, shouldDisplayFinalReport);
- }
-
- @Override
- public void shutdown() {
- this.shutdownExecutors();
- }
-}
diff --git a/src/main/java/org/onap/aai/sparky/autosuggestion/sync/VnfAliasSyncController.java b/src/main/java/org/onap/aai/sparky/autosuggestion/sync/VnfAliasSyncController.java
deleted file mode 100644
index bfcceb2..0000000
--- a/src/main/java/org/onap/aai/sparky/autosuggestion/sync/VnfAliasSyncController.java
+++ /dev/null
@@ -1,94 +0,0 @@
-/**
- * ============LICENSE_START=======================================================
- * org.onap.aai
- * ================================================================================
- * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved.
- * Copyright © 2017-2018 Amdocs
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-package org.onap.aai.sparky.autosuggestion.sync;
-
-import org.onap.aai.sparky.dal.ActiveInventoryAdapter;
-import org.onap.aai.sparky.dal.ElasticSearchAdapter;
-import org.onap.aai.sparky.search.filters.config.FiltersConfig;
-import org.onap.aai.sparky.sync.ElasticSearchIndexCleaner;
-import org.onap.aai.sparky.sync.ElasticSearchSchemaFactory;
-import org.onap.aai.sparky.sync.IndexCleaner;
-import org.onap.aai.sparky.sync.IndexIntegrityValidator;
-import org.onap.aai.sparky.sync.SyncControllerImpl;
-import org.onap.aai.sparky.sync.SyncControllerRegistrar;
-import org.onap.aai.sparky.sync.SyncControllerRegistry;
-import org.onap.aai.sparky.sync.config.ElasticSearchEndpointConfig;
-import org.onap.aai.sparky.sync.config.ElasticSearchSchemaConfig;
-import org.onap.aai.sparky.sync.config.NetworkStatisticsConfig;
-import org.onap.aai.sparky.sync.config.SyncControllerConfig;
-
-public class VnfAliasSyncController extends SyncControllerImpl implements SyncControllerRegistrar {
-
- private SyncControllerRegistry syncControllerRegistry;
-
- public VnfAliasSyncController(SyncControllerConfig syncControllerConfig,
- ActiveInventoryAdapter aaiAdapter, ElasticSearchAdapter esAdapter,
- ElasticSearchSchemaConfig schemaConfig, ElasticSearchEndpointConfig endpointConfig,
- NetworkStatisticsConfig aaiStatConfig, NetworkStatisticsConfig esStatConfig,
- FiltersConfig filtersConfig) throws Exception {
- super(syncControllerConfig);
-
- // final String controllerName = "VNFs Alias Suggestion Synchronizer";
-
- IndexIntegrityValidator indexValidator = new IndexIntegrityValidator(esAdapter, schemaConfig,
- endpointConfig, ElasticSearchSchemaFactory.getIndexSchema(schemaConfig));
-
- registerIndexValidator(indexValidator);
-
- VnfAliasSuggestionSynchronizer synchronizer = new VnfAliasSuggestionSynchronizer(schemaConfig,
- syncControllerConfig.getNumInternalSyncWorkers(),
- syncControllerConfig.getNumSyncActiveInventoryWorkers(),
- syncControllerConfig.getNumSyncElasticWorkers(), aaiStatConfig, esStatConfig, filtersConfig);
-
- synchronizer.setAaiAdapter(aaiAdapter);
- synchronizer.setElasticSearchAdapter(esAdapter);
-
- registerEntitySynchronizer(synchronizer);
-
-
- IndexCleaner indexCleaner =
- new ElasticSearchIndexCleaner(esAdapter, endpointConfig, schemaConfig);
-
- registerIndexCleaner(indexCleaner);
-
- }
-
- public SyncControllerRegistry getSyncControllerRegistry() {
- return syncControllerRegistry;
- }
-
- public void setSyncControllerRegistry(SyncControllerRegistry syncControllerRegistry) {
- this.syncControllerRegistry = syncControllerRegistry;
- }
-
- @Override
- public void registerController() {
-
- if ( syncControllerRegistry != null ) {
- if ( syncControllerConfig.isEnabled()) {
- syncControllerRegistry.registerSyncController(this);
- }
- }
-
- }
-
-
-}
diff --git a/src/main/java/org/onap/aai/sparky/common/search/CommonSearchSuggestion.java b/src/main/java/org/onap/aai/sparky/common/search/CommonSearchSuggestion.java
deleted file mode 100644
index 0e662d1..0000000
--- a/src/main/java/org/onap/aai/sparky/common/search/CommonSearchSuggestion.java
+++ /dev/null
@@ -1,86 +0,0 @@
-/**
- * ============LICENSE_START=======================================================
- * org.onap.aai
- * ================================================================================
- * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved.
- * Copyright © 2017-2018 Amdocs
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-package org.onap.aai.sparky.common.search;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.onap.aai.sparky.search.entity.SearchSuggestion;
-import org.onap.aai.sparky.search.filters.entity.UiFilterValueEntity;
-
-import com.fasterxml.jackson.annotation.JsonInclude;
-import com.fasterxml.jackson.annotation.JsonInclude.Include;
-
-@JsonInclude(Include.NON_NULL)
-public class CommonSearchSuggestion implements SearchSuggestion {
- protected String hashId;
- protected String route;
- protected String text;
- protected List filterValues = new ArrayList<>();
-
- public CommonSearchSuggestion() {}
-
- public CommonSearchSuggestion(String hashId, String route, String text, String perspective,
- List filterValues) {
- this.hashId = hashId;
- this.route = route;
- this.text = text;
- this.filterValues = filterValues;
- }
-
- public List getFilterValues() {
- return filterValues;
- }
-
- public String getHashId() {
- return hashId;
- }
-
- public String getRoute() {
- return route;
- }
-
- public String getText() {
- return text;
- }
-
- public void setHashId(String hashId) {
- this.hashId = hashId;
- }
-
- public void setRoute(String route) {
- this.route = route;
- }
-
- public void setText(String text) {
- this.text = text;
- }
-
- @Override
- public String toString() {
- return "CommonSearchSuggestion [" + (hashId != null ? "hashId=" + hashId + ", " : "")
- + (route != null ? "route=" + route + ", " : "")
- + (text != null ? "text=" + text + ", " : "")
- + (filterValues != null ? "filterValues=" + filterValues : "") + "]";
- }
-
-
-}
diff --git a/src/main/java/org/onap/aai/sparky/config/oxm/CrossEntityReference.java b/src/main/java/org/onap/aai/sparky/config/oxm/CrossEntityReference.java
deleted file mode 100644
index 28bc91c..0000000
--- a/src/main/java/org/onap/aai/sparky/config/oxm/CrossEntityReference.java
+++ /dev/null
@@ -1,74 +0,0 @@
-/**
- * ============LICENSE_START=======================================================
- * org.onap.aai
- * ================================================================================
- * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved.
- * Copyright © 2017-2018 Amdocs
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-package org.onap.aai.sparky.config.oxm;
-
-import java.util.ArrayList;
-import java.util.List;
-
-/**
- * The Class CrossEntityReference.
- */
-public class CrossEntityReference {
- private String targetEntityType;
- private List referenceAttributes;
-
- /**
- * Instantiates a new cross entity reference.
- */
- public CrossEntityReference() {
- targetEntityType = null;
- referenceAttributes = new ArrayList();
- }
-
- public String getTargetEntityType() {
- return targetEntityType;
- }
-
- public void setTargetEntityType(String targetEntityType) {
- this.targetEntityType = targetEntityType;
- }
-
- public List getReferenceAttributes() {
- return referenceAttributes;
- }
-
- public void setReferenceAttributes(List referenceAttributes) {
- this.referenceAttributes = referenceAttributes;
- }
-
- /**
- * Adds the reference attribute.
- *
- * @param additionalAttribute the additional attribute
- */
- public void addReferenceAttribute(String additionalAttribute) {
- referenceAttributes.add(additionalAttribute);
- }
-
- /* (non-Javadoc)
- * @see java.lang.Object#toString()
- */
- @Override
- public String toString() {
- return "CrossEntityReference [targetEntityType=" + targetEntityType + ", referenceAttributes="
- + referenceAttributes + "]";
- }
-}
diff --git a/src/main/java/org/onap/aai/sparky/config/oxm/CrossEntityReferenceDescriptor.java b/src/main/java/org/onap/aai/sparky/config/oxm/CrossEntityReferenceDescriptor.java
deleted file mode 100644
index 581ddb7..0000000
--- a/src/main/java/org/onap/aai/sparky/config/oxm/CrossEntityReferenceDescriptor.java
+++ /dev/null
@@ -1,63 +0,0 @@
-/**
- * ============LICENSE_START=======================================================
- * org.onap.aai
- * ================================================================================
- * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved.
- * Copyright © 2017-2018 Amdocs
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-package org.onap.aai.sparky.config.oxm;
-
-public class CrossEntityReferenceDescriptor extends OxmEntityDescriptor {
- protected CrossEntityReference crossEntityReference;
-
- public CrossEntityReference getCrossEntityReference() {
- return crossEntityReference;
- }
-
- public void setCrossEntityReference(CrossEntityReference crossEntityReference) {
- this.crossEntityReference = crossEntityReference;
- }
-
- /**
- * Checks for cross entity references.
- *
- * @return true, if successful
- */
- public boolean hasCrossEntityReferences() {
- if (this.crossEntityReference == null) {
- return false;
- }
- if (!this.crossEntityReference.getReferenceAttributes().isEmpty()) {
- return true;
- }
- return false;
- }
-
-
- @Override
- public String toString() {
- return "CrossEntityReferenceDescriptor ["
- + (crossEntityReference != null ? "crossEntityReference=" + crossEntityReference + ", "
- : "")
- + (entityName != null ? "entityName=" + entityName + ", " : "")
- + (primaryKeyAttributeNames != null ? "primaryKeyAttributeNames=" + primaryKeyAttributeNames
- : "")
- + "]";
- }
-
-
-
-}
diff --git a/src/main/java/org/onap/aai/sparky/config/oxm/CrossEntityReferenceLookup.java b/src/main/java/org/onap/aai/sparky/config/oxm/CrossEntityReferenceLookup.java
deleted file mode 100644
index 837503a..0000000
--- a/src/main/java/org/onap/aai/sparky/config/oxm/CrossEntityReferenceLookup.java
+++ /dev/null
@@ -1,132 +0,0 @@
-/**
- * ============LICENSE_START=======================================================
- * org.onap.aai
- * ================================================================================
- * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved.
- * Copyright © 2017-2018 Amdocs
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-package org.onap.aai.sparky.config.oxm;
-
-import java.util.Arrays;
-import java.util.HashMap;
-import java.util.LinkedHashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Map.Entry;
-
-import org.eclipse.persistence.dynamic.DynamicType;
-import org.eclipse.persistence.internal.oxm.mappings.Descriptor;
-import org.eclipse.persistence.jaxb.dynamic.DynamicJAXBContext;
-
-public class CrossEntityReferenceLookup implements OxmModelProcessor {
-
- private Map> crossReferenceEntityOxmModel;
- private Map crossReferenceEntityDescriptors;
-
-
- public CrossEntityReferenceLookup() {
- crossReferenceEntityOxmModel = new LinkedHashMap>();
- crossReferenceEntityDescriptors = new HashMap();
- }
-
- @Override
- public void processOxmModel(DynamicJAXBContext jaxbContext) {
-
- @SuppressWarnings("rawtypes")
- List descriptorsList = jaxbContext.getXMLContext().getDescriptors();
-
- for (@SuppressWarnings("rawtypes")
- Descriptor desc : descriptorsList) {
-
- DynamicType entity = jaxbContext.getDynamicType(desc.getAlias());
-
- LinkedHashMap oxmProperties = new LinkedHashMap();
-
- // Not all fields have key attributes
- if (desc.getPrimaryKeyFields() != null) {
- oxmProperties.put("primaryKeyAttributeNames", desc.getPrimaryKeyFields().toString()
- .replaceAll("/text\\(\\)", "").replaceAll("\\[", "").replaceAll("\\]", ""));
- }
-
- String entityName = desc.getDefaultRootElement();
-
- // add entityName
- oxmProperties.put("entityName", entityName);
-
- Map properties = entity.getDescriptor().getProperties();
- if (properties != null) {
- for (Map.Entry entry : properties.entrySet()) {
-
- if (entry.getKey().equalsIgnoreCase("crossEntityReference")) {
- oxmProperties.put("crossEntityReference", entry.getValue());
- }
- }
- }
-
- if (oxmProperties.containsKey("crossEntityReference")) {
- crossReferenceEntityOxmModel.put(entityName, oxmProperties);
- }
-
- }
-
- for (Entry> crossRefModel : crossReferenceEntityOxmModel
- .entrySet()) {
- HashMap attribute = crossRefModel.getValue();
- CrossEntityReferenceDescriptor entity = new CrossEntityReferenceDescriptor();
- entity.setEntityName(attribute.get("entityName"));
- entity.setPrimaryKeyAttributeNames(
- Arrays.asList(attribute.get("primaryKeyAttributeNames").replace(" ", "").split(",")));
-
- List crossEntityRefTokens =
- Arrays.asList(attribute.get("crossEntityReference").split(","));
-
- if (crossEntityRefTokens.size() >= 2) {
- CrossEntityReference entityRef = new CrossEntityReference();
- entityRef.setTargetEntityType(crossEntityRefTokens.get(0));
-
- for (int i = 1; i < crossEntityRefTokens.size(); i++) {
- entityRef.addReferenceAttribute(crossEntityRefTokens.get(i));
- }
-
- entity.setCrossEntityReference(entityRef);
- }
- crossReferenceEntityDescriptors.put(attribute.get("entityName"), entity);
- }
-
- }
-
- public Map> getCrossReferenceEntityOxmModel() {
- return crossReferenceEntityOxmModel;
- }
-
- public void setCrossReferenceEntityOxmModel(
- Map> crossReferenceEntityOxmModel) {
- this.crossReferenceEntityOxmModel = crossReferenceEntityOxmModel;
- }
-
- public Map getCrossReferenceEntityDescriptors() {
- return crossReferenceEntityDescriptors;
- }
-
- public void setCrossReferenceEntityDescriptors(
- Map crossReferenceEntityDescriptors) {
- this.crossReferenceEntityDescriptors = crossReferenceEntityDescriptors;
- }
-
-
-
-
-}
diff --git a/src/main/java/org/onap/aai/sparky/config/oxm/GeoEntityDescriptor.java b/src/main/java/org/onap/aai/sparky/config/oxm/GeoEntityDescriptor.java
deleted file mode 100644
index f53e589..0000000
--- a/src/main/java/org/onap/aai/sparky/config/oxm/GeoEntityDescriptor.java
+++ /dev/null
@@ -1,57 +0,0 @@
-/**
- * ============LICENSE_START=======================================================
- * org.onap.aai
- * ================================================================================
- * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved.
- * Copyright © 2017-2018 Amdocs
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-package org.onap.aai.sparky.config.oxm;
-
-public class GeoEntityDescriptor extends OxmEntityDescriptor {
-
- protected String geoLatName;
-
- protected String geoLongName;
-
- public String getGeoLatName() {
- return geoLatName;
- }
-
- public void setGeoLatName(String geoLatName) {
- this.geoLatName = geoLatName;
- }
-
- public String getGeoLongName() {
- return geoLongName;
- }
-
- public void setGeoLongName(String geoLongName) {
- this.geoLongName = geoLongName;
- }
-
- @Override
- public String toString() {
- return "GeoEntityDescriptor [" + (geoLatName != null ? "geoLatName=" + geoLatName + ", " : "")
- + (geoLongName != null ? "geoLongName=" + geoLongName + ", " : "")
- + (entityName != null ? "entityName=" + entityName + ", " : "")
- + (primaryKeyAttributeNames != null ? "primaryKeyAttributeNames=" + primaryKeyAttributeNames
- : "")
- + "]";
- }
-
-
-
-}
diff --git a/src/main/java/org/onap/aai/sparky/config/oxm/GeoEntityLookup.java b/src/main/java/org/onap/aai/sparky/config/oxm/GeoEntityLookup.java
deleted file mode 100644
index 29ed570..0000000
--- a/src/main/java/org/onap/aai/sparky/config/oxm/GeoEntityLookup.java
+++ /dev/null
@@ -1,133 +0,0 @@
-/**
- * ============LICENSE_START=======================================================
- * org.onap.aai
- * ================================================================================
- * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved.
- * Copyright © 2017-2018 Amdocs
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-package org.onap.aai.sparky.config.oxm;
-
-import java.util.Arrays;
-import java.util.HashMap;
-import java.util.LinkedHashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Map.Entry;
-
-import org.eclipse.persistence.dynamic.DynamicType;
-import org.eclipse.persistence.internal.oxm.mappings.Descriptor;
-import org.eclipse.persistence.jaxb.dynamic.DynamicJAXBContext;
-
-public class GeoEntityLookup implements OxmModelProcessor {
-
- private Map> geoEntityOxmModel;
-
- private Map geoEntityDescriptors;
-
- public GeoEntityLookup() {
- geoEntityOxmModel = new LinkedHashMap>();
- geoEntityDescriptors = new HashMap();
- }
-
- public Map> getGeoEntityOxmModel() {
- return geoEntityOxmModel;
- }
-
- public void setGeoEntityOxmModel(Map> geoEntityOxmModel) {
- this.geoEntityOxmModel = geoEntityOxmModel;
- }
-
- public Map getGeoEntityDescriptors() {
- return geoEntityDescriptors;
- }
-
- public void setGeoEntityDescriptors(Map geoEntityDescriptors) {
- this.geoEntityDescriptors = geoEntityDescriptors;
- }
-
- @Override
- public void processOxmModel(DynamicJAXBContext jaxbContext) {
-
- @SuppressWarnings("rawtypes")
- List descriptorsList = jaxbContext.getXMLContext().getDescriptors();
-
- for (@SuppressWarnings("rawtypes")
- Descriptor desc : descriptorsList) {
-
- DynamicType entity = jaxbContext.getDynamicType(desc.getAlias());
-
- LinkedHashMap oxmProperties = new LinkedHashMap();
-
- // Not all fields have key attributes
- if (desc.getPrimaryKeyFields() != null) {
- oxmProperties.put("primaryKeyAttributeNames", desc.getPrimaryKeyFields().toString()
- .replaceAll("/text\\(\\)", "").replaceAll("\\[", "").replaceAll("\\]", ""));
- }
-
- String entityName = desc.getDefaultRootElement();
-
- // add entityName
- oxmProperties.put("entityName", entityName);
-
- Map properties = entity.getDescriptor().getProperties();
-
- if (properties != null) {
- for (Map.Entry entry : properties.entrySet()) {
-
- if (entry.getKey().equalsIgnoreCase("geoLat")) {
- if (entry.getValue().length() > 0) {
- oxmProperties.put("geoLat", entry.getValue());
- }
- } else if (entry.getKey().equalsIgnoreCase("geoLong")) {
- if (entry.getValue().length() > 0) {
- oxmProperties.put("geoLong", entry.getValue());
- }
- }
- }
- }
-
- if (oxmProperties.containsKey("geoLat") && oxmProperties.containsKey("geoLong")) {
- geoEntityOxmModel.put(entityName, oxmProperties);
- }
-
- }
-
- for (Entry> entityModel : geoEntityOxmModel.entrySet()) {
-
- HashMap attribute = entityModel.getValue();
-
- GeoOxmEntityDescriptor entity = new GeoOxmEntityDescriptor();
-
- entity.setEntityName(attribute.get("entityName"));
-
- if (attribute.containsKey("primaryKeyAttributeNames")) {
-
- entity.setPrimaryKeyAttributeNames(
- Arrays.asList(attribute.get("primaryKeyAttributeNames").replace(" ", "").split(",")));
-
- if (attribute.containsKey("geoLat") || attribute.containsKey("geoLong")) {
- entity.setGeoLatName(attribute.get("geoLat"));
- entity.setGeoLongName(attribute.get("geoLong"));
- }
-
- geoEntityDescriptors.put(attribute.get("entityName"), entity);
- }
- }
-
- }
-
-
-}
diff --git a/src/main/java/org/onap/aai/sparky/config/oxm/GeoOxmEntityDescriptor.java b/src/main/java/org/onap/aai/sparky/config/oxm/GeoOxmEntityDescriptor.java
deleted file mode 100644
index 9341d7b..0000000
--- a/src/main/java/org/onap/aai/sparky/config/oxm/GeoOxmEntityDescriptor.java
+++ /dev/null
@@ -1,67 +0,0 @@
-/**
- * ============LICENSE_START=======================================================
- * org.onap.aai
- * ================================================================================
- * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved.
- * Copyright © 2017-2018 Amdocs
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-package org.onap.aai.sparky.config.oxm;
-
-public class GeoOxmEntityDescriptor extends OxmEntityDescriptor {
-
- private String geoLatName;
-
- private String geoLongName;
-
- public String getGeoLatName() {
- return geoLatName;
- }
-
- public void setGeoLatName(String geoLatName) {
- this.geoLatName = geoLatName;
- }
-
- public String getGeoLongName() {
- return geoLongName;
- }
-
- public void setGeoLongName(String geoLongName) {
- this.geoLongName = geoLongName;
- }
-
- /**
- * Checks for geo entity.
- *
- * @return true, if successful
- */
- public boolean hasGeoEntity() {
- return (this.geoLongName != null && this.geoLatName != null);
- }
-
- @Override
- public String toString() {
- return "GeoOxmEntityDescriptor ["
- + (geoLatName != null ? "geoLatName=" + geoLatName + ", " : "")
- + (geoLongName != null ? "geoLongName=" + geoLongName + ", " : "")
- + (entityName != null ? "entityName=" + entityName + ", " : "")
- + (primaryKeyAttributeNames != null ? "primaryKeyAttributeNames=" + primaryKeyAttributeNames
- : "")
- + "]";
- }
-
-
-
-}
diff --git a/src/main/java/org/onap/aai/sparky/config/oxm/OxmEntityDescriptor.java b/src/main/java/org/onap/aai/sparky/config/oxm/OxmEntityDescriptor.java
deleted file mode 100644
index de2b893..0000000
--- a/src/main/java/org/onap/aai/sparky/config/oxm/OxmEntityDescriptor.java
+++ /dev/null
@@ -1,64 +0,0 @@
-/**
- * ============LICENSE_START=======================================================
- * org.onap.aai
- * ================================================================================
- * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved.
- * Copyright © 2017-2018 Amdocs
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-package org.onap.aai.sparky.config.oxm;
-
-import java.util.ArrayList;
-import java.util.List;
-
-public class OxmEntityDescriptor {
-
- protected String entityName;
-
- protected List primaryKeyAttributeNames;
-
- public OxmEntityDescriptor() {
- primaryKeyAttributeNames = new ArrayList();
- }
-
- public String getEntityName() {
- return entityName;
- }
-
- public void setEntityName(String entityName) {
- this.entityName = entityName;
- }
-
- public List getPrimaryKeyAttributeNames() {
- return primaryKeyAttributeNames;
- }
-
- public void setPrimaryKeyAttributeNames(List primaryKeyAttributeNames) {
- this.primaryKeyAttributeNames = primaryKeyAttributeNames;
- }
-
- public void addPrimaryKeyName(String name) {
- primaryKeyAttributeNames.add(name);
- }
-
- @Override
- public String toString() {
- return "OxmEntityDescriptor [" + (entityName != null ? "entityName=" + entityName + ", " : "")
- + (primaryKeyAttributeNames != null ? "primaryKeyAttributeNames=" + primaryKeyAttributeNames
- : "")
- + "]";
- }
-
-}
diff --git a/src/main/java/org/onap/aai/sparky/config/oxm/OxmEntityLookup.java b/src/main/java/org/onap/aai/sparky/config/oxm/OxmEntityLookup.java
deleted file mode 100644
index d99de4c..0000000
--- a/src/main/java/org/onap/aai/sparky/config/oxm/OxmEntityLookup.java
+++ /dev/null
@@ -1,128 +0,0 @@
-/**
- * ============LICENSE_START=======================================================
- * org.onap.aai
- * ================================================================================
- * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved.
- * Copyright © 2017-2018 Amdocs
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-package org.onap.aai.sparky.config.oxm;
-
-import java.util.Arrays;
-import java.util.HashMap;
-import java.util.LinkedHashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Map.Entry;
-
-import org.eclipse.persistence.dynamic.DynamicType;
-import org.eclipse.persistence.internal.oxm.mappings.Descriptor;
-import org.eclipse.persistence.jaxb.dynamic.DynamicJAXBContext;
-
-public class OxmEntityLookup implements OxmModelProcessor {
-
- private Map> oxmModel;
-
- private Map entityTypeLookup;
-
- private Map entityDescriptors;
-
-
- public OxmEntityLookup() {
- oxmModel = new LinkedHashMap>();
- entityTypeLookup = new LinkedHashMap();
- entityDescriptors = new HashMap();
- }
-
- @Override
- public void processOxmModel(DynamicJAXBContext jaxbContext) {
-
- @SuppressWarnings("rawtypes")
- List descriptorsList = jaxbContext.getXMLContext().getDescriptors();
-
- for (@SuppressWarnings("rawtypes")
- Descriptor desc : descriptorsList) {
-
- DynamicType entity = jaxbContext.getDynamicType(desc.getAlias());
-
- LinkedHashMap oxmProperties = new LinkedHashMap();
-
- // Not all fields have key attributes
- if (desc.getPrimaryKeyFields() != null) {
- oxmProperties.put("primaryKeyAttributeNames", desc.getPrimaryKeyFields().toString()
- .replaceAll("/text\\(\\)", "").replaceAll("\\[", "").replaceAll("\\]", ""));
- }
-
- String entityName = desc.getDefaultRootElement();
-
- entityTypeLookup.put(entityName, entity);
-
- // add entityName
- oxmProperties.put("entityName", entityName);
-
- Map properties = entity.getDescriptor().getProperties();
-
- oxmModel.put(entityName, oxmProperties);
-
- }
-
- for (Entry> entityModel : oxmModel.entrySet()) {
- HashMap attribute = entityModel.getValue();
- OxmEntityDescriptor entity = new OxmEntityDescriptor();
-
- entity.setEntityName(attribute.get("entityName"));
-
- if (attribute.containsKey("primaryKeyAttributeNames")) {
-
- entity.setPrimaryKeyAttributeNames(
- Arrays.asList(attribute.get("primaryKeyAttributeNames").replace(" ", "").split(",")));
-
- entityDescriptors.put(attribute.get("entityName"), entity);
- }
- }
-
- }
-
- public Map> getOxmModel() {
- return oxmModel;
- }
-
- public void setOxmModel(Map> oxmModel) {
- this.oxmModel = oxmModel;
- }
-
- public Map getEntityTypeLookup() {
- return entityTypeLookup;
- }
-
- public void setEntityTypeLookup(Map entityTypeLookup) {
- this.entityTypeLookup = entityTypeLookup;
- }
-
- public Map getEntityDescriptors() {
- return entityDescriptors;
- }
-
- public void setEntityDescriptors(Map entityDescriptors) {
- this.entityDescriptors = entityDescriptors;
- }
-
- public void addEntityDescriptor(String type, OxmEntityDescriptor descriptor) {
- if ( this.entityDescriptors != null ) {
- this.entityDescriptors.put(type, descriptor);
- }
- }
-
-}
diff --git a/src/main/java/org/onap/aai/sparky/config/oxm/OxmModelLoader.java b/src/main/java/org/onap/aai/sparky/config/oxm/OxmModelLoader.java
deleted file mode 100644
index 02ce01a..0000000
--- a/src/main/java/org/onap/aai/sparky/config/oxm/OxmModelLoader.java
+++ /dev/null
@@ -1,191 +0,0 @@
-/**
- * ============LICENSE_START=======================================================
- * org.onap.aai
- * ================================================================================
- * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved.
- * Copyright © 2017-2018 Amdocs
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-package org.onap.aai.sparky.config.oxm;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Map;
-import java.util.Set;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
-
-import org.eclipse.persistence.jaxb.JAXBContextProperties;
-import org.eclipse.persistence.jaxb.dynamic.DynamicJAXBContext;
-import org.eclipse.persistence.jaxb.dynamic.DynamicJAXBContextFactory;
-import org.onap.aai.cl.api.Logger;
-import org.onap.aai.cl.eelf.LoggerFactory;
-import org.onap.aai.sparky.logging.AaiUiMsgs;
-import org.springframework.core.io.Resource;
-import org.springframework.core.io.support.PathMatchingResourcePatternResolver;
-import org.springframework.core.io.support.ResourcePatternResolver;
-
-public class OxmModelLoader {
-
- private static final Logger LOG = LoggerFactory.getInstance().getLogger(OxmModelLoader.class);
-
- /*
- * The intent of this parameter is to be able to programmatically over-ride the latest AAI schema
- * version discovered from the aai-schema jar file. This property is optional, but if set on the
- * bean or by another class in the system, then it will override the spec version that is loaded.
- *
- * If the latestVersionOverride is greater than 0 then it will set the latest version to the
- * specified version, and that stream will be returned if available.
- */
-
- protected int oxmApiVersionOverride;
- protected Set processors;
- private int latestVersionNum = 0;
-
- private final static Pattern p = Pattern.compile("aai_oxm_(v)(.*).xml");
-
- public OxmModelLoader() {
- this(-1, new HashSet());
- }
-
- public OxmModelLoader(int apiVersionOverride,Set oxmModelProcessors) {
- this.oxmApiVersionOverride = apiVersionOverride;
- this.processors = oxmModelProcessors;
- }
-
- protected synchronized Map getStreamHandlesForOxmFromResource() {
- Map listOfOxmFiles = new HashMap();
- ClassLoader oxmClassLoader = OxmModelLoader.class.getClassLoader();
- ResourcePatternResolver resolver = new PathMatchingResourcePatternResolver(oxmClassLoader);
- Resource[] resources = null;
- try {
- resources = resolver.getResources("classpath*:/oxm/aai_oxm*.xml");
- } catch (IOException ex) {
- LOG.error(AaiUiMsgs.OXM_LOADING_ERROR, ex.getMessage());
- }
-
- if (resources == null) {
- LOG.error(AaiUiMsgs.OXM_LOADING_ERROR, "No OXM schema files found on classpath");
- }
-
- for (Resource resource : resources) {
- Matcher m = p.matcher(resource.getFilename());
-
- if (m.matches()) {
- try {
- listOfOxmFiles.put(new Integer(m.group(2)), resource.getInputStream());
- } catch (Exception e) {
- LOG.error(AaiUiMsgs.OXM_LOADING_ERROR,
- resource.getFilename(), e.getMessage());
- }
- }
- }
- return listOfOxmFiles;
- }
-
- /**
- * Load an oxm model.
- * @param inputStream file handle for oxm
- */
- protected void loadModel(InputStream inputStream) {
- Map properties = new HashMap();
- properties.put(JAXBContextProperties.OXM_METADATA_SOURCE, inputStream);
- try {
- final DynamicJAXBContext oxmContext = DynamicJAXBContextFactory
- .createContextFromOXM(Thread.currentThread().getContextClassLoader(), properties);
-
- parseOxmContext(oxmContext);
- // populateSearchableOxmModel();
- LOG.info(AaiUiMsgs.OXM_LOAD_SUCCESS, String.valueOf(latestVersionNum));
- } catch (Exception exc) {
- LOG.info(AaiUiMsgs.OXM_PARSE_ERROR_NONVERBOSE);
- LOG.error(AaiUiMsgs.OXM_PARSE_ERROR_VERBOSE, "OXM v" + latestVersionNum, exc.getMessage());
- }
- }
-
- /**
- * Load the latest oxm model.
- */
- public synchronized void loadLatestOxmModel() {
-
- LOG.info(AaiUiMsgs.INITIALIZE_OXM_MODEL_LOADER);
-
- // find handles for available oxm models
- final Map listOfOxmStreams = getStreamHandlesForOxmFromResource();
- if (listOfOxmStreams.isEmpty()) {
- LOG.error(AaiUiMsgs.OXM_FILE_NOT_FOUND);
- return;
- }
-
- InputStream stream = null;
-
- if (oxmApiVersionOverride > 0) {
- latestVersionNum = oxmApiVersionOverride;
- LOG.warn(AaiUiMsgs.WARN_GENERIC, "Overriding AAI Schema with version = " + latestVersionNum);
- stream = listOfOxmStreams.get(latestVersionNum);
- } else {
-
- for (Integer key : listOfOxmStreams.keySet()) {
- if (key.intValue() > latestVersionNum) {
- latestVersionNum = key.intValue();
- stream = listOfOxmStreams.get(key);
- }
- }
- }
-
- // load the latest oxm file
- loadModel(stream);
-
- }
-
- public int getLatestVersionNum() {
- return latestVersionNum;
- }
-
- public void setLatestVersionNum(int latestVersionNum) {
- this.latestVersionNum = latestVersionNum;
- }
-
- /**
- * Parses the oxm context.
- *
- * @param oxmContext the oxm context
- */
- private void parseOxmContext(DynamicJAXBContext oxmContext) {
-
- if (processors != null && processors.size() > 0) {
-
- for (OxmModelProcessor processor : processors) {
-
- try {
-
- processor.processOxmModel(oxmContext);
-
- } catch (Exception exc) {
-
- LOG.warn(AaiUiMsgs.WARN_GENERIC,
- "OxmModelProcessor experienced an error. Error: " + exc.getMessage());
-
- }
-
- }
-
- }
-
- }
-
-}
diff --git a/src/main/java/org/onap/aai/sparky/config/oxm/OxmModelProcessor.java b/src/main/java/org/onap/aai/sparky/config/oxm/OxmModelProcessor.java
deleted file mode 100644
index 29eeb6b..0000000
--- a/src/main/java/org/onap/aai/sparky/config/oxm/OxmModelProcessor.java
+++ /dev/null
@@ -1,29 +0,0 @@
-/**
- * ============LICENSE_START=======================================================
- * org.onap.aai
- * ================================================================================
- * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved.
- * Copyright © 2017-2018 Amdocs
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-package org.onap.aai.sparky.config.oxm;
-
-import org.eclipse.persistence.jaxb.dynamic.DynamicJAXBContext;
-
-public interface OxmModelProcessor {
-
- public void processOxmModel(DynamicJAXBContext jaxbContext);
-
-}
diff --git a/src/main/java/org/onap/aai/sparky/config/oxm/SearchableEntityLookup.java b/src/main/java/org/onap/aai/sparky/config/oxm/SearchableEntityLookup.java
deleted file mode 100644
index e1e37f4..0000000
--- a/src/main/java/org/onap/aai/sparky/config/oxm/SearchableEntityLookup.java
+++ /dev/null
@@ -1,115 +0,0 @@
-/**
- * ============LICENSE_START=======================================================
- * org.onap.aai
- * ================================================================================
- * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved.
- * Copyright © 2017-2018 Amdocs
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-package org.onap.aai.sparky.config.oxm;
-
-import java.util.Arrays;
-import java.util.HashMap;
-import java.util.LinkedHashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Map.Entry;
-
-import org.eclipse.persistence.dynamic.DynamicType;
-import org.eclipse.persistence.internal.oxm.mappings.Descriptor;
-import org.eclipse.persistence.jaxb.dynamic.DynamicJAXBContext;
-
-public class SearchableEntityLookup implements OxmModelProcessor {
-
- private Map> searchableOxmModel;
- private Map searchableEntityDescriptors;
-
- public SearchableEntityLookup() {
- searchableOxmModel = new LinkedHashMap>();
- searchableEntityDescriptors = new HashMap();
- }
-
- @Override
- public void processOxmModel(DynamicJAXBContext jaxbContext) {
-
- @SuppressWarnings("rawtypes")
- List descriptorsList = jaxbContext.getXMLContext().getDescriptors();
-
- for (@SuppressWarnings("rawtypes")
- Descriptor desc : descriptorsList) {
-
- DynamicType entity = jaxbContext.getDynamicType(desc.getAlias());
-
- LinkedHashMap oxmProperties = new LinkedHashMap();
-
- // Not all fields have key attributes
- if (desc.getPrimaryKeyFields() != null) {
- oxmProperties.put("primaryKeyAttributeNames", desc.getPrimaryKeyFields().toString()
- .replaceAll("/text\\(\\)", "").replaceAll("\\[", "").replaceAll("\\]", ""));
- }
-
- String entityName = desc.getDefaultRootElement();
-
- // add entityName
- oxmProperties.put("entityName", entityName);
-
- Map properties = entity.getDescriptor().getProperties();
- if (properties != null) {
- for (Map.Entry entry : properties.entrySet()) {
-
- if (entry.getKey().equalsIgnoreCase("searchable")) {
- oxmProperties.put("searchableAttributes", entry.getValue());
- }
- }
- }
-
- // Add all searchable entity types for reserve lookup
- if (oxmProperties.containsKey("searchableAttributes")) {
- searchableOxmModel.put(entityName, oxmProperties);
- }
-
- }
-
- for (Entry> searchableModel : searchableOxmModel.entrySet()) {
- HashMap attribute = searchableModel.getValue();
- SearchableOxmEntityDescriptor entity = new SearchableOxmEntityDescriptor();
- entity.setEntityName(attribute.get("entityName"));
- entity.setPrimaryKeyAttributeNames(
- Arrays.asList(attribute.get("primaryKeyAttributeNames").replace(" ", "").split(",")));
- entity
- .setSearchableAttributes(Arrays.asList(attribute.get("searchableAttributes").split(",")));
- searchableEntityDescriptors.put(attribute.get("entityName"), entity);
- }
-
- }
-
- public Map> getSearchableOxmModel() {
- return searchableOxmModel;
- }
-
- public void setSearchableOxmModel(Map> searchableOxmModel) {
- this.searchableOxmModel = searchableOxmModel;
- }
-
- public Map getSearchableEntityDescriptors() {
- return searchableEntityDescriptors;
- }
-
- public void setSearchableEntityDescriptors(
- Map searchableEntityDescriptors) {
- this.searchableEntityDescriptors = searchableEntityDescriptors;
- }
-
-}
diff --git a/src/main/java/org/onap/aai/sparky/config/oxm/SearchableOxmEntityDescriptor.java b/src/main/java/org/onap/aai/sparky/config/oxm/SearchableOxmEntityDescriptor.java
deleted file mode 100644
index 7c73344..0000000
--- a/src/main/java/org/onap/aai/sparky/config/oxm/SearchableOxmEntityDescriptor.java
+++ /dev/null
@@ -1,71 +0,0 @@
-/**
- * ============LICENSE_START=======================================================
- * org.onap.aai
- * ================================================================================
- * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved.
- * Copyright © 2017-2018 Amdocs
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-package org.onap.aai.sparky.config.oxm;
-
-import java.util.List;
-
-public class SearchableOxmEntityDescriptor extends OxmEntityDescriptor {
-
- protected List searchableAttributes;
-
- public List getSearchableAttributes() {
- return searchableAttributes;
- }
-
- public void setSearchableAttributes(List searchableAttributes) {
- this.searchableAttributes = searchableAttributes;
- }
-
- public void addSearchableAttribute(String attributeName) {
- searchableAttributes.add(attributeName);
- }
-
- /**
- * Checks for searchable attributes.
- *
- * @return true, if successful
- */
- public boolean hasSearchableAttributes() {
-
- if (this.searchableAttributes == null) {
- return false;
- }
-
- if (this.searchableAttributes.size() > 0) {
- return true;
- }
-
- return false;
-
- }
-
- @Override
- public String toString() {
- return "SearchableOxmEntityDescriptor ["
- + (searchableAttributes != null ? "searchableAttributes=" + searchableAttributes + ", "
- : "")
- + (entityName != null ? "entityName=" + entityName + ", " : "")
- + (primaryKeyAttributeNames != null ? "primaryKeyAttributeNames=" + primaryKeyAttributeNames
- : "")
- + "]";
- }
-
-}
diff --git a/src/main/java/org/onap/aai/sparky/config/oxm/SuggestionEntityDescriptor.java b/src/main/java/org/onap/aai/sparky/config/oxm/SuggestionEntityDescriptor.java
deleted file mode 100644
index e4fdac4..0000000
--- a/src/main/java/org/onap/aai/sparky/config/oxm/SuggestionEntityDescriptor.java
+++ /dev/null
@@ -1,50 +0,0 @@
-/**
- * ============LICENSE_START=======================================================
- * org.onap.aai
- * ================================================================================
- * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved.
- * Copyright © 2017-2018 Amdocs
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-package org.onap.aai.sparky.config.oxm;
-
-import org.onap.aai.sparky.sync.entity.SuggestionSearchEntity;
-
-public class SuggestionEntityDescriptor extends OxmEntityDescriptor {
-
- protected SuggestionSearchEntity suggestionSearchEntity;
-
- public SuggestionSearchEntity getSuggestionSearchEntity() {
- return suggestionSearchEntity;
- }
-
- public void setSuggestionSearchEntity(SuggestionSearchEntity suggestionSearchEntity) {
- this.suggestionSearchEntity = suggestionSearchEntity;
- }
-
- @Override
- public String toString() {
- return "SuggestionEntityDescriptor ["
- + (suggestionSearchEntity != null
- ? "suggestionSearchEntity=" + suggestionSearchEntity + ", " : "")
- + (entityName != null ? "entityName=" + entityName + ", " : "")
- + (primaryKeyAttributeNames != null ? "primaryKeyAttributeNames=" + primaryKeyAttributeNames
- : "")
- + "]";
- }
-
-
-
-}
diff --git a/src/main/java/org/onap/aai/sparky/config/oxm/SuggestionEntityLookup.java b/src/main/java/org/onap/aai/sparky/config/oxm/SuggestionEntityLookup.java
deleted file mode 100644
index 2901763..0000000
--- a/src/main/java/org/onap/aai/sparky/config/oxm/SuggestionEntityLookup.java
+++ /dev/null
@@ -1,177 +0,0 @@
-/**
- * ============LICENSE_START=======================================================
- * org.onap.aai
- * ================================================================================
- * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved.
- * Copyright © 2017-2018 Amdocs
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-package org.onap.aai.sparky.config.oxm;
-
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.HashMap;
-import java.util.LinkedHashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Map.Entry;
-import java.util.Vector;
-
-import org.eclipse.persistence.dynamic.DynamicType;
-import org.eclipse.persistence.internal.oxm.mappings.Descriptor;
-import org.eclipse.persistence.jaxb.dynamic.DynamicJAXBContext;
-import org.eclipse.persistence.mappings.DatabaseMapping;
-import org.onap.aai.sparky.search.filters.config.FiltersConfig;
-import org.onap.aai.sparky.sync.entity.SuggestionSearchEntity;
-
-public class SuggestionEntityLookup implements OxmModelProcessor {
-
- private Map> suggestionSearchEntityOxmModel;
- private Map suggestionSearchEntityDescriptors;
- private FiltersConfig filtersConfig;
-
- public SuggestionEntityLookup(FiltersConfig filtersConfig) {
- suggestionSearchEntityOxmModel = new LinkedHashMap>();
- suggestionSearchEntityDescriptors = new HashMap();
- this.filtersConfig = filtersConfig;
- }
-
- @Override
- public void processOxmModel(DynamicJAXBContext jaxbContext) {
-
- @SuppressWarnings("rawtypes")
- List descriptorsList = jaxbContext.getXMLContext().getDescriptors();
-
- for (@SuppressWarnings("rawtypes")
- Descriptor desc : descriptorsList) {
-
- DynamicType entity = jaxbContext.getDynamicType(desc.getAlias());
-
- LinkedHashMap oxmProperties = new LinkedHashMap();
-
- // Not all fields have key attributes
- if (desc.getPrimaryKeyFields() != null) {
- oxmProperties.put("primaryKeyAttributeNames", desc.getPrimaryKeyFields().toString()
- .replaceAll("/text\\(\\)", "").replaceAll("\\[", "").replaceAll("\\]", ""));
- }
-
- String entityName = desc.getDefaultRootElement();
-
- // add entityName
- oxmProperties.put("entityName", entityName);
-
- Map properties = entity.getDescriptor().getProperties();
- if (properties != null) {
- for (Map.Entry entry : properties.entrySet()) {
-
-
- if (entry.getKey().equalsIgnoreCase("containsSuggestibleProps")) {
-
- oxmProperties.put("containsSuggestibleProps", "true");
-
- Vector descriptorMaps = entity.getDescriptor().getMappings();
- List listOfSuggestableAttributes = new ArrayList();
-
- for (DatabaseMapping descMap : descriptorMaps) {
- if (descMap.isAbstractDirectMapping()) {
-
- if (descMap.getProperties().get("suggestibleOnSearch") != null) {
- String suggestableOnSearchString =
- String.valueOf(descMap.getProperties().get("suggestibleOnSearch"));
-
- boolean isSuggestibleOnSearch = Boolean.valueOf(suggestableOnSearchString);
-
- if (isSuggestibleOnSearch) {
- /* Grab attribute types for suggestion */
- String attributeName =
- descMap.getField().getName().replaceAll("/text\\(\\)", "");
- listOfSuggestableAttributes.add(attributeName);
-
- if (descMap.getProperties().get("suggestionVerbs") != null) {
- String suggestionVerbsString =
- String.valueOf(descMap.getProperties().get("suggestionVerbs"));
-
- oxmProperties.put("suggestionVerbs", suggestionVerbsString);
- }
- }
- }
- }
- }
-
- if (!listOfSuggestableAttributes.isEmpty()) {
- oxmProperties.put("suggestibleAttributes",
- String.join(",", listOfSuggestableAttributes));
- }
- } else if (entry.getKey().equalsIgnoreCase("suggestionAliases")) {
- oxmProperties.put("suggestionAliases", entry.getValue());
- }
- }
- }
-
- if (oxmProperties.containsKey("containsSuggestibleProps")) {
- suggestionSearchEntityOxmModel.put(entityName, oxmProperties);
- }
- }
-
- for (Entry> suggestionEntityModel : suggestionSearchEntityOxmModel
- .entrySet()) {
- HashMap attribute = suggestionEntityModel.getValue();
-
- String entityName = attribute.get("entityName");
- SuggestionSearchEntity suggestionSearchEntity = new SuggestionSearchEntity(filtersConfig, this);
- suggestionSearchEntity.setEntityType(entityName);
-
- if (attribute.get("suggestionAliases") != null) {
- suggestionSearchEntity
- .setSuggestionAliases(Arrays.asList(attribute.get("suggestionAliases").split(",")));
- }
-
- if (attribute.get("suggestibleAttributes") != null) {
- suggestionSearchEntity.setSuggestionPropertyTypes(
- Arrays.asList(attribute.get("suggestibleAttributes").split(",")));
- }
-
- SuggestionEntityDescriptor entity = new SuggestionEntityDescriptor();
- entity.setSuggestionSearchEntity(suggestionSearchEntity);
- entity.setEntityName(entityName);
-
- if (attribute.get("primaryKeyAttributeNames") != null) {
- entity.setPrimaryKeyAttributeNames(
- Arrays.asList(attribute.get("primaryKeyAttributeNames").replace(" ", "").split(",")));
- }
-
- suggestionSearchEntityDescriptors.put(entityName, entity);
- }
- }
-
- public Map> getSuggestionSearchEntityOxmModel() {
- return suggestionSearchEntityOxmModel;
- }
-
- public void setSuggestionSearchEntityOxmModel(
- Map> suggestionSearchEntityOxmModel) {
- this.suggestionSearchEntityOxmModel = suggestionSearchEntityOxmModel;
- }
-
- public Map getSuggestionSearchEntityDescriptors() {
- return suggestionSearchEntityDescriptors;
- }
-
- public void setSuggestionSearchEntityDescriptors(
- Map suggestionSearchEntityDescriptors) {
- this.suggestionSearchEntityDescriptors = suggestionSearchEntityDescriptors;
- }
-
-}
diff --git a/src/main/java/org/onap/aai/sparky/crossentityreference/sync/CrossEntityReferenceSynchronizer.java b/src/main/java/org/onap/aai/sparky/crossentityreference/sync/CrossEntityReferenceSynchronizer.java
deleted file mode 100644
index d95e507..0000000
--- a/src/main/java/org/onap/aai/sparky/crossentityreference/sync/CrossEntityReferenceSynchronizer.java
+++ /dev/null
@@ -1,933 +0,0 @@
-/**
- * ============LICENSE_START=======================================================
- * org.onap.aai
- * ================================================================================
- * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved.
- * Copyright © 2017-2018 Amdocs
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-package org.onap.aai.sparky.crossentityreference.sync;
-
-import static java.util.concurrent.CompletableFuture.supplyAsync;
-
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Deque;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import java.util.concurrent.ConcurrentHashMap;
-import java.util.concurrent.ConcurrentLinkedDeque;
-import java.util.concurrent.ExecutorService;
-import java.util.function.Supplier;
-
-import org.onap.aai.cl.api.Logger;
-import org.onap.aai.cl.eelf.LoggerFactory;
-import org.onap.aai.cl.mdc.MdcContext;
-import org.onap.aai.restclient.client.OperationResult;
-import org.onap.aai.sparky.config.oxm.CrossEntityReference;
-import org.onap.aai.sparky.config.oxm.CrossEntityReferenceDescriptor;
-import org.onap.aai.sparky.config.oxm.CrossEntityReferenceLookup;
-import org.onap.aai.sparky.config.oxm.OxmEntityDescriptor;
-import org.onap.aai.sparky.config.oxm.OxmEntityLookup;
-import org.onap.aai.sparky.config.oxm.SearchableEntityLookup;
-import org.onap.aai.sparky.config.oxm.SearchableOxmEntityDescriptor;
-import org.onap.aai.sparky.dal.ActiveInventoryAdapter;
-import org.onap.aai.sparky.dal.NetworkTransaction;
-import org.onap.aai.sparky.dal.rest.HttpMethod;
-import org.onap.aai.sparky.logging.AaiUiMsgs;
-import org.onap.aai.sparky.sync.AbstractEntitySynchronizer;
-import org.onap.aai.sparky.sync.IndexSynchronizer;
-import org.onap.aai.sparky.sync.SynchronizerConstants;
-import org.onap.aai.sparky.sync.config.ElasticSearchSchemaConfig;
-import org.onap.aai.sparky.sync.config.NetworkStatisticsConfig;
-import org.onap.aai.sparky.sync.entity.IndexableCrossEntityReference;
-import org.onap.aai.sparky.sync.entity.MergableEntity;
-import org.onap.aai.sparky.sync.entity.SelfLinkDescriptor;
-import org.onap.aai.sparky.sync.enumeration.OperationState;
-import org.onap.aai.sparky.sync.enumeration.SynchronizerState;
-import org.onap.aai.sparky.sync.task.PerformActiveInventoryRetrieval;
-import org.onap.aai.sparky.sync.task.PerformElasticSearchPut;
-import org.onap.aai.sparky.sync.task.PerformElasticSearchRetrieval;
-import org.onap.aai.sparky.sync.task.PerformElasticSearchUpdate;
-import org.onap.aai.sparky.util.NodeUtils;
-import org.slf4j.MDC;
-
-import com.fasterxml.jackson.core.JsonProcessingException;
-import com.fasterxml.jackson.databind.JsonNode;
-import com.fasterxml.jackson.databind.ObjectReader;
-import com.fasterxml.jackson.databind.node.ArrayNode;
-
-/**
- * The Class CrossEntityReferenceSynchronizer.
- */
-public class CrossEntityReferenceSynchronizer extends AbstractEntitySynchronizer
- implements IndexSynchronizer {
-
- /**
- * The Class RetryCrossEntitySyncContainer.
- */
- private class RetryCrossEntitySyncContainer {
- NetworkTransaction txn;
- IndexableCrossEntityReference icer;
-
- /**
- * Instantiates a new retry cross entity sync container.
- *
- * @param txn the txn
- * @param icer the icer
- */
- public RetryCrossEntitySyncContainer(NetworkTransaction txn,
- IndexableCrossEntityReference icer) {
- this.txn = txn;
- this.icer = icer;
- }
-
- public NetworkTransaction getNetworkTransaction() {
- return txn;
- }
-
- public IndexableCrossEntityReference getIndexableCrossEntityReference() {
- return icer;
- }
- }
-
- private static final Logger LOG =
- LoggerFactory.getInstance().getLogger(CrossEntityReferenceSynchronizer.class);
-
- private static final String SERVICE_INSTANCE = "service-instance";
-
- private Deque selflinks;
- private Deque retryQueue;
- private Map retryLimitTracker;
- private boolean isAllWorkEnumerated;
- protected ExecutorService esPutExecutor;
- private CrossEntityReferenceLookup crossEntityReferenceLookup;
- private OxmEntityLookup oxmEntityLookup;
- private SearchableEntityLookup searchableEntityLookup;
-
-
- /**
- * Instantiates a new cross entity reference synchronizer.
- *
- * @param indexName the index name
- * @throws Exception the exception
- */
- public CrossEntityReferenceSynchronizer(ElasticSearchSchemaConfig schemaConfig,
- int internalSyncWorkers, int aaiWorkers, int esWorkers, NetworkStatisticsConfig aaiStatConfig,
- NetworkStatisticsConfig esStatConfig, CrossEntityReferenceLookup crossEntityReferenceLookup,
- OxmEntityLookup oxmEntityLookup, SearchableEntityLookup searchableEntityLookup) throws Exception {
- super(LOG, "CERS", internalSyncWorkers, aaiWorkers, esWorkers, schemaConfig.getIndexName(),
- aaiStatConfig, esStatConfig);
- this.crossEntityReferenceLookup = crossEntityReferenceLookup;
- this.oxmEntityLookup = oxmEntityLookup;
- this.searchableEntityLookup = searchableEntityLookup;
- this.selflinks = new ConcurrentLinkedDeque();
- this.retryQueue = new ConcurrentLinkedDeque();
- this.retryLimitTracker = new ConcurrentHashMap();
- this.synchronizerName = "Cross Reference Entity Synchronizer";
- this.isAllWorkEnumerated = false;
- this.esPutExecutor = NodeUtils.createNamedExecutor("CERS-ES-PUT", 5, LOG);
- this.aaiEntityStats.intializeEntityCounters(
- crossEntityReferenceLookup.getCrossReferenceEntityDescriptors().keySet());
-
- this.esEntityStats.intializeEntityCounters(
- crossEntityReferenceLookup.getCrossReferenceEntityDescriptors().keySet());
- this.syncDurationInMs = -1;
- }
-
- /* (non-Javadoc)
- * @see org.openecomp.sparky.synchronizer.IndexSynchronizer#doSync()
- */
- @Override
- public OperationState doSync() {
- this.syncDurationInMs = -1;
- String txnID = NodeUtils.getRandomTxnId();
- MdcContext.initialize(txnID, "CrossEntitySynchronizer", "", "Sync", "");
-
- resetCounters();
- syncStartedTimeStampInMs = System.currentTimeMillis();
- launchSyncFlow();
- return OperationState.OK;
- }
-
- @Override
- public SynchronizerState getState() {
- if (!isSyncDone()) {
- return SynchronizerState.PERFORMING_SYNCHRONIZATION;
- }
-
- return SynchronizerState.IDLE;
- }
-
- /* (non-Javadoc)
- * @see org.openecomp.sparky.synchronizer.IndexSynchronizer#getStatReport(boolean)
- */
- @Override
- public String getStatReport(boolean showFinalReport) {
- syncDurationInMs = System.currentTimeMillis() - syncStartedTimeStampInMs;
- return getStatReport(syncDurationInMs, showFinalReport);
- }
-
- /* (non-Javadoc)
- * @see org.openecomp.sparky.synchronizer.IndexSynchronizer#shutdown()
- */
- @Override
- public void shutdown() {
- this.shutdownExecutors();
- }
-
- @Override
- protected boolean isSyncDone() {
- int totalWorkOnHand = aaiWorkOnHand.get() + esWorkOnHand.get();
-
- if (totalWorkOnHand > 0 || !isAllWorkEnumerated) {
- return false;
- }
-
- return true;
- }
-
- /**
- * Launch sync flow.
- *
- * @return the operation state
- */
- private OperationState launchSyncFlow() {
- final Map contextMap = MDC.getCopyOfContextMap();
- Map descriptorMap =
- crossEntityReferenceLookup.getCrossReferenceEntityDescriptors();
-
- if (descriptorMap.isEmpty()) {
- LOG.error(AaiUiMsgs.ERROR_LOADING_OXM);
-
- return OperationState.ERROR;
- }
-
- Collection syncTypes = descriptorMap.keySet();
-
- try {
-
- /*
- * launch a parallel async thread to process the documents for each entity-type (to max the of
- * the configured executor anyway)
- */
-
- aaiWorkOnHand.set(syncTypes.size());
-
- for (String key : syncTypes) {
-
- supplyAsync(new Supplier() {
-
- @Override
- public Void get() {
- MDC.setContextMap(contextMap);
- OperationResult typeLinksResult = null;
- try {
- typeLinksResult = aaiAdapter.getSelfLinksByEntityType(key);
- aaiWorkOnHand.decrementAndGet();
- processEntityTypeSelfLinks(typeLinksResult);
- } catch (Exception exc) {
- LOG.error(AaiUiMsgs.ERROR_GENERIC,
- "An error occurred processing entity selflinks. Error: " + exc.getMessage());
- }
-
- return null;
- }
-
- }, aaiExecutor).whenComplete((result, error) -> {
- if (error != null) {
- LOG.error(AaiUiMsgs.ERROR_GETTING_DATA_FROM_AAI, error.getMessage());
- }
- });
- }
-
- while (aaiWorkOnHand.get() != 0) {
-
- if (LOG.isDebugEnabled()) {
- LOG.debug(AaiUiMsgs.WAIT_FOR_ALL_SELFLINKS_TO_BE_COLLECTED);
- }
-
- Thread.sleep(1000);
- }
-
- aaiWorkOnHand.set(selflinks.size());
- isAllWorkEnumerated = true;
- performSync();
-
- while (!isSyncDone()) {
- performRetrySync();
- Thread.sleep(1000);
- }
-
- /*
- * Make sure we don't hang on to retries that failed which could cause issues during future
- * syncs
- */
- retryLimitTracker.clear();
-
- } catch (Exception exc) {
- LOG.error(AaiUiMsgs.ERROR_GENERIC,
- "An error occurred during entity synchronization. Error: " + exc.getMessage());
-
- }
-
- return OperationState.OK;
- }
-
- /**
- * Perform sync.
- */
- private void performSync() {
- while (selflinks.peek() != null) {
-
- SelfLinkDescriptor linkDescriptor = selflinks.poll();
- aaiWorkOnHand.decrementAndGet();
-
- CrossEntityReferenceDescriptor descriptor = null;
-
- if (linkDescriptor.getSelfLink() != null && linkDescriptor.getEntityType() != null) {
-
- descriptor = crossEntityReferenceLookup.getCrossReferenceEntityDescriptors()
- .get(linkDescriptor.getEntityType());
-
- if (descriptor == null) {
- LOG.error(AaiUiMsgs.MISSING_ENTITY_DESCRIPTOR, linkDescriptor.getEntityType());
- // go to next element in iterator
- continue;
- }
-
- if (descriptor.hasCrossEntityReferences()) {
-
- NetworkTransaction txn = new NetworkTransaction();
- txn.setDescriptor(descriptor);
- txn.setLink(linkDescriptor.getSelfLink());
- txn.setQueryParameters(linkDescriptor.getDepthModifier());
- txn.setOperationType(HttpMethod.GET);
- txn.setEntityType(linkDescriptor.getEntityType());
-
- aaiWorkOnHand.incrementAndGet();
-
- supplyAsync(new PerformActiveInventoryRetrieval(txn, aaiAdapter), aaiExecutor)
- .whenComplete((result, error) -> {
-
- aaiWorkOnHand.decrementAndGet();
-
- if (error != null) {
- LOG.error(AaiUiMsgs.SELF_LINK_GET, error.getLocalizedMessage());
- } else {
- if (result == null) {
- LOG.error(AaiUiMsgs.SELF_LINK_CROSS_REF_SYNC);
- } else {
- updateActiveInventoryCounters(result);
- fetchDocumentForUpsert(result);
- }
- }
- });
- }
- }
- }
- }
-
- /**
- * Process entity type self links.
- *
- * @param operationResult the operation result
- */
- private void processEntityTypeSelfLinks(OperationResult operationResult) {
-
- JsonNode rootNode = null;
-
- final String jsonResult = operationResult.getResult();
-
- if (jsonResult != null && jsonResult.length() > 0) {
-
- try {
- rootNode = mapper.readTree(jsonResult);
- } catch (IOException exc) {
- // TODO // TODO -> LOG, waht should be logged here?
- }
-
- JsonNode resultData = rootNode.get("result-data");
- ArrayNode resultDataArrayNode = null;
-
- if (resultData.isArray()) {
- resultDataArrayNode = (ArrayNode) resultData;
-
- Iterator elementIterator = resultDataArrayNode.elements();
- JsonNode element = null;
-
- while (elementIterator.hasNext()) {
- element = elementIterator.next();
-
- final String resourceType = NodeUtils.getNodeFieldAsText(element, "resource-type");
- final String resourceLink = NodeUtils.getNodeFieldAsText(element, "resource-link");
-
- CrossEntityReferenceDescriptor descriptor = null;
-
- if (resourceType != null && resourceLink != null) {
- descriptor = crossEntityReferenceLookup.getCrossReferenceEntityDescriptors().get(resourceType);
-
- if (descriptor == null) {
- LOG.error(AaiUiMsgs.MISSING_ENTITY_DESCRIPTOR, resourceType);
- // go to next element in iterator
- continue;
- }
- if (descriptor.hasCrossEntityReferences()) {
- selflinks.add(new SelfLinkDescriptor(
- resourceLink,SynchronizerConstants.DEPTH_ALL_MODIFIER, resourceType));
- }
- }
- }
- }
- }
- }
-
-
-
- /**
- * By providing the entity type and a json node for the entity, determine the
- * primary key name(s) + primary key value(s) sufficient to build an entity query string
- * of the following format:
- *
- * .:
- *
- * @return - a composite string in the above format or null
- */
- private String determineEntityQueryString(String entityType, JsonNode entityJsonNode) {
-
- OxmEntityDescriptor entityDescriptor =
- oxmEntityLookup.getEntityDescriptors().get(entityType);
-
- String queryString = null;
-
- if ( entityDescriptor != null ) {
-
- final List primaryKeyNames = entityDescriptor.getPrimaryKeyAttributeNames();
- final List keyValues = new ArrayList();
- NodeUtils.extractFieldValuesFromObject(entityJsonNode, primaryKeyNames, keyValues);
-
- queryString = entityType + "." + NodeUtils.concatArray(primaryKeyNames,"/") + ":" + NodeUtils.concatArray(keyValues);
-
- }
-
- return queryString;
-
-
- }
-
- /**
- * Fetch document for upsert.
- *
- * @param txn the txn
- */
- private void fetchDocumentForUpsert(NetworkTransaction txn) {
-
- if (!txn.getOperationResult().wasSuccessful()) {
- LOG.error(AaiUiMsgs.SELF_LINK_GET, txn.getOperationResult().getResult());
- return;
- }
-
- CrossEntityReferenceDescriptor cerDescriptor = crossEntityReferenceLookup
- .getCrossReferenceEntityDescriptors().get(txn.getDescriptor().getEntityName());
-
- if (cerDescriptor != null && cerDescriptor.hasCrossEntityReferences()) {
-
- final String jsonResult = txn.getOperationResult().getResult();
-
- if (jsonResult != null && jsonResult.length() > 0) {
-
- /**
- * Here's what we are going to do:
- *
- * Extract primary key name and value from the parent type.
- * Extract the primary key and value from the nested child instance.
- * Build a generic query to discover the self-link for the nested-child-instance using
- * parent and child.
- * Set the self-link on the child.
- * Generate the id that will allow the elastic-search upsert to work.
- * Rinse and repeat.
- */
-
- CrossEntityReference cerDefinition = cerDescriptor.getCrossEntityReference();
-
- if (cerDefinition != null) {
- JsonNode convertedNode = null;
- try {
- convertedNode = NodeUtils.convertJsonStrToJsonNode(txn.getOperationResult().getResult());
-
- final String parentEntityQueryString = determineEntityQueryString(txn.getEntityType(), convertedNode);
-
- List extractedParentEntityAttributeValues = new ArrayList();
-
- NodeUtils.extractFieldValuesFromObject(convertedNode,
- cerDefinition.getReferenceAttributes(),
- extractedParentEntityAttributeValues);
-
- List nestedTargetEntityInstances = new ArrayList();
- NodeUtils.extractObjectsByKey(convertedNode, cerDefinition.getTargetEntityType(),
- nestedTargetEntityInstances);
-
- for (JsonNode targetEntityInstance : nestedTargetEntityInstances) {
-
- if (cerDescriptor != null) {
-
- String childEntityType = cerDefinition.getTargetEntityType();
- OxmEntityDescriptor childDesciptor = oxmEntityLookup.getEntityDescriptors().get(childEntityType);
-
- List childPrimaryKeyNames = null;
-
- if (childDesciptor != null) {
- childPrimaryKeyNames = childDesciptor.getPrimaryKeyAttributeNames();
- } else {
- childPrimaryKeyNames = new ArrayList();
- }
-
- List childKeyValues = new ArrayList();
- NodeUtils.extractFieldValuesFromObject(targetEntityInstance, childPrimaryKeyNames, childKeyValues);
-
- String childEntityQueryKeyString = childEntityType + "." + NodeUtils.concatArray(childPrimaryKeyNames,"/") + ":" + NodeUtils.concatArray(childKeyValues);
-
- /**
- * Build generic-query to query child instance self-link from AAI
- */
- List orderedQueryKeyParams = new ArrayList();
-
- /**
- * At present, there is an issue with resolving the self-link using the
- * generic-query with nothing more than the service-instance identifier and the
- * service-subscription. There is another level of detail we don't have access to
- * unless we parse it out of the service-subscription self-link, which is a
- * coupling I would like to avoid. Fortunately, there is a workaround, but only
- * for service-instances, which is presently our only use-case for the
- * cross-entity-reference in R1707. Going forwards hopefully there will be other
- * ways to resolve a child self-link using parental embedded meta data that we
- * don't currently have.
- *
- * The work-around with the service-instance entity-type is that it's possible to
- * request the self-link using only the service-instance-id because of a
- * historical AAI functional query requirement that it be possible to query a
- * service-instance only by it's service-instance-id. This entity type is the only
- * one in the system that can be queried this way which makes it a very limited
- * workaround, but good enough for the current release.
- */
-
- if (SERVICE_INSTANCE.equals(childEntityType)) {
- orderedQueryKeyParams.clear();
- orderedQueryKeyParams.add(childEntityQueryKeyString);
- } else {
- orderedQueryKeyParams.add(parentEntityQueryString);
- orderedQueryKeyParams.add(childEntityQueryKeyString);
- }
-
- String genericQueryStr = null;
- try {
- genericQueryStr = aaiAdapter.getGenericQueryForSelfLink(childEntityType, orderedQueryKeyParams);
-
- if (genericQueryStr != null) {
- aaiWorkOnHand.incrementAndGet();
-
- OperationResult aaiQueryResult = aaiAdapter.queryActiveInventoryWithRetries(
- genericQueryStr, "application/json",
- aaiAdapter.getEndpointConfig().getNumRequestRetries());
-
- aaiWorkOnHand.decrementAndGet();
-
- if (aaiQueryResult!= null && aaiQueryResult.wasSuccessful()) {
-
- Collection entityLinks = new ArrayList();
- JsonNode genericQueryResult = null;
- try {
- genericQueryResult = NodeUtils.convertJsonStrToJsonNode(aaiQueryResult.getResult());
-
- if ( genericQueryResult != null ) {
-
- NodeUtils.extractObjectsByKey(genericQueryResult, "resource-link", entityLinks);
-
- String selfLink = null;
-
- if (entityLinks.size() != 1) {
- /**
- * an ambiguity exists where we can't reliably determine the self
- * link, this should be a permanent error
- */
- LOG.error(AaiUiMsgs.ENTITY_SYNC_FAILED_SELFLINK_AMBIGUITY, String.valueOf(entityLinks.size()));
- } else {
- selfLink = ((JsonNode) entityLinks.toArray()[0]).asText();
-
-
- IndexableCrossEntityReference icer =
- getPopulatedDocument(targetEntityInstance, cerDescriptor);
-
- for (String parentCrossEntityReferenceAttributeValue : extractedParentEntityAttributeValues) {
- icer.addCrossEntityReferenceValue(
- parentCrossEntityReferenceAttributeValue);
- }
-
- icer.setLink(ActiveInventoryAdapter.extractResourcePath(selfLink));
-
- icer.deriveFields();
-
- String link = null;
- try {
- link = elasticSearchAdapter
- .buildElasticSearchGetDocUrl(getIndexName(), icer.getId());
- } catch (Exception exc) {
- LOG.error(AaiUiMsgs.ES_FAILED_TO_CONSTRUCT_QUERY,
- exc.getLocalizedMessage());
- }
-
- if (link != null) {
- NetworkTransaction n2 = new NetworkTransaction();
- n2.setLink(link);
- n2.setEntityType(txn.getEntityType());
- n2.setDescriptor(txn.getDescriptor());
- n2.setOperationType(HttpMethod.GET);
-
- esWorkOnHand.incrementAndGet();
-
- supplyAsync(
- new PerformElasticSearchRetrieval(n2, elasticSearchAdapter),
- esExecutor).whenComplete((result, error) -> {
-
- esWorkOnHand.decrementAndGet();
-
- if (error != null) {
- LOG.error(AaiUiMsgs.ES_RETRIEVAL_FAILED,
- error.getLocalizedMessage());
- } else {
- updateElasticSearchCounters(result);
- performDocumentUpsert(result, icer);
- }
- });
- }
-
- }
- } else {
- LOG.error(AaiUiMsgs.ENTITY_SYNC_FAILED_DURING_AAI_RESPONSE_CONVERSION);
- }
-
- } catch (Exception exc) {
- LOG.error(AaiUiMsgs.JSON_CONVERSION_ERROR, JsonNode.class.toString(), exc.getLocalizedMessage());
- }
-
- } else {
- String message = "Entity sync failed because AAI query failed with error " + aaiQueryResult.getResult();
- LOG.error(AaiUiMsgs.ENTITY_SYNC_FAILED_QUERY_ERROR, message);
- }
-
- } else {
- String message = "Entity Sync failed because generic query str could not be determined.";
- LOG.error(AaiUiMsgs.ENTITY_SYNC_FAILED_QUERY_ERROR, message);
- }
- } catch (Exception exc) {
- String message = "Failed to sync entity because generation of generic query failed with error = " + exc.getMessage();
- LOG.error(AaiUiMsgs.ENTITY_SYNC_FAILED_QUERY_ERROR, message);
- }
-
- }
- }
-
- } catch (IOException ioe) {
- LOG.error(AaiUiMsgs.JSON_PROCESSING_ERROR, ioe.getMessage());
- }
- }
-
- }
-
- } else {
- LOG.error(AaiUiMsgs.ENTITY_SYNC_FAILED_DESCRIPTOR_NOT_FOUND, txn.getEntityType());
- }
- }
-
- /**
- * Perform document upsert.
- *
- * @param esGetResult the es get result
- * @param icer the icer
- */
- protected void performDocumentUpsert(NetworkTransaction esGetResult,
- IndexableCrossEntityReference icer) {
- /**
- *
- *
- * As part of the response processing we need to do the following:
- * - 1. Extract the version (if present), it will be the ETAG when we use the
- * Search-Abstraction-Service
- *
- 2. Spawn next task which is to do the PUT operation into elastic with or with the version
- * tag
- *
- a) if version is null or RC=404, then standard put, no _update with version tag
- *
- b) if version != null, do PUT with _update?version= (versionNumber) in the URI to elastic
- *
- *
- */
- String link = null;
- try {
- link = elasticSearchAdapter.buildElasticSearchGetDocUrl(getIndexName(), icer.getId());
- } catch (Exception exc) {
- LOG.error(AaiUiMsgs.ES_LINK_UPSERT, exc.getLocalizedMessage());
- return;
- }
-
- boolean wasEntryDiscovered = false;
- String versionNumber = null;
- if (esGetResult.getOperationResult().getResultCode() == 404) {
- LOG.info(AaiUiMsgs.ES_SIMPLE_PUT, icer.getEntityPrimaryKeyValue());
- } else if (esGetResult.getOperationResult().getResultCode() == 200) {
- wasEntryDiscovered = true;
- try {
- versionNumber = NodeUtils.extractFieldValueFromObject(
- NodeUtils.convertJsonStrToJsonNode(esGetResult.getOperationResult().getResult()),
- "_version");
- } catch (IOException exc) {
- LOG.error(AaiUiMsgs.ES_ABORT_CROSS_ENTITY_REF_SYNC, "version Number",
- icer.getEntityPrimaryKeyValue(), exc.getLocalizedMessage());
- return;
- }
- } else {
- /*
- * Not being a 200 does not mean a failure. eg 201 is returned for created. TODO -> Should we
- * return.
- */
- LOG.info(AaiUiMsgs.ES_OPERATION_RETURN_CODE,
- String.valueOf(esGetResult.getOperationResult().getResultCode()));
- return;
- }
-
- try {
- String jsonPayload = null;
- if (wasEntryDiscovered) {
- try {
- ArrayList sourceObject = new ArrayList();
- NodeUtils.extractObjectsByKey(
- NodeUtils.convertJsonStrToJsonNode(esGetResult.getOperationResult().getResult()),
- "_source", sourceObject);
-
- if (!sourceObject.isEmpty()) {
- String responseSource = NodeUtils.convertObjectToJson(sourceObject.get(0), false);
- MergableEntity me = mapper.readValue(responseSource, MergableEntity.class);
- ObjectReader updater = mapper.readerForUpdating(me);
- MergableEntity merged = updater.readValue(icer.getAsJson());
- jsonPayload = mapper.writeValueAsString(merged);
- }
- } catch (IOException exc) {
- LOG.error(AaiUiMsgs.ES_ABORT_CROSS_ENTITY_REF_SYNC, "source value",
- icer.getEntityPrimaryKeyValue(), exc.getLocalizedMessage());
- return;
- }
- } else {
- jsonPayload = icer.getAsJson();
- }
-
- if (wasEntryDiscovered) {
- if (versionNumber != null && jsonPayload != null) {
-
- String requestPayload = elasticSearchAdapter.buildBulkImportOperationRequest(getIndexName(),
- "default", icer.getId(), versionNumber, jsonPayload);
-
- NetworkTransaction transactionTracker = new NetworkTransaction();
- transactionTracker.setEntityType(esGetResult.getEntityType());
- transactionTracker.setDescriptor(esGetResult.getDescriptor());
- transactionTracker.setOperationType(HttpMethod.PUT);
-
- esWorkOnHand.incrementAndGet();
- supplyAsync(new PerformElasticSearchUpdate(elasticSearchAdapter.getBulkUrl(),
- requestPayload, elasticSearchAdapter, transactionTracker), esPutExecutor)
- .whenComplete((result, error) -> {
-
- esWorkOnHand.decrementAndGet();
-
- if (error != null) {
- LOG.error(AaiUiMsgs.ES_CROSS_ENTITY_REF_PUT, error.getLocalizedMessage());
- } else {
- updateElasticSearchCounters(result);
- processStoreDocumentResult(result, esGetResult, icer);
- }
- });
- }
-
- } else {
- if (link != null && jsonPayload != null) {
-
- NetworkTransaction updateElasticTxn = new NetworkTransaction();
- updateElasticTxn.setLink(link);
- updateElasticTxn.setEntityType(esGetResult.getEntityType());
- updateElasticTxn.setDescriptor(esGetResult.getDescriptor());
- updateElasticTxn.setOperationType(HttpMethod.PUT);
-
- esWorkOnHand.incrementAndGet();
- supplyAsync(new PerformElasticSearchPut(jsonPayload, updateElasticTxn, elasticSearchAdapter),
- esPutExecutor).whenComplete((result, error) -> {
-
- esWorkOnHand.decrementAndGet();
-
- if (error != null) {
- LOG.error(AaiUiMsgs.ES_CROSS_ENTITY_REF_PUT, error.getLocalizedMessage());
- } else {
- updateElasticSearchCounters(result);
- processStoreDocumentResult(result, esGetResult, icer);
- }
- });
- }
- }
- } catch (Exception exc) {
- LOG.error(AaiUiMsgs.ES_CROSS_ENTITY_REF_PUT, exc.getLocalizedMessage());
- }
- }
-
- /**
- * Process store document result.
- *
- * @param esPutResult the es put result
- * @param esGetResult the es get result
- * @param icer the icer
- */
- private void processStoreDocumentResult(NetworkTransaction esPutResult,
- NetworkTransaction esGetResult, IndexableCrossEntityReference icer) {
-
- OperationResult or = esPutResult.getOperationResult();
-
- if (!or.wasSuccessful()) {
- if (or.getResultCode() == VERSION_CONFLICT_EXCEPTION_CODE) {
-
- if (shouldAllowRetry(icer.getId())) {
-
- esWorkOnHand.incrementAndGet();
-
- RetryCrossEntitySyncContainer rsc = new RetryCrossEntitySyncContainer(esGetResult, icer);
- retryQueue.push(rsc);
-
- LOG.warn(AaiUiMsgs.ES_CROSS_REF_SYNC_VERSION_CONFLICT);
- }
- } else {
- LOG.error(AaiUiMsgs.ES_CROSS_REF_SYNC_FAILURE, String.valueOf(or.getResultCode()),
- or.getResult());
- }
- }
- }
-
- /**
- * Perform retry sync.
- */
- private void performRetrySync() {
- while (retryQueue.peek() != null) {
-
- RetryCrossEntitySyncContainer rsc = retryQueue.poll();
- if (rsc != null) {
-
- IndexableCrossEntityReference icer = rsc.getIndexableCrossEntityReference();
- NetworkTransaction txn = rsc.getNetworkTransaction();
-
- String link = null;
- try {
- // In this retry flow the icer object has already
- // derived its fields
- link = elasticSearchAdapter.buildElasticSearchGetDocUrl(getIndexName(), icer.getId());
- } catch (Exception exc) {
- LOG.error(AaiUiMsgs.ES_FAILED_TO_CONSTRUCT_URI, exc.getLocalizedMessage());
- }
-
- if (link != null) {
- NetworkTransaction retryTransaction = new NetworkTransaction();
- retryTransaction.setLink(link);
- retryTransaction.setEntityType(txn.getEntityType());
- retryTransaction.setDescriptor(txn.getDescriptor());
- retryTransaction.setOperationType(HttpMethod.GET);
-
- /*
- * IMPORTANT - DO NOT incrementAndGet the esWorkOnHand as this is a retry flow and we did
- * that for this request already when queuing the failed PUT!
- */
-
- supplyAsync(new PerformElasticSearchRetrieval(retryTransaction, elasticSearchAdapter),
- esExecutor).whenComplete((result, error) -> {
-
- esWorkOnHand.decrementAndGet();
-
- if (error != null) {
- LOG.error(AaiUiMsgs.ES_RETRIEVAL_FAILED_RESYNC, error.getLocalizedMessage());
- } else {
- updateElasticSearchCounters(result);
- performDocumentUpsert(result, icer);
- }
- });
- }
-
- }
- }
- }
-
- /**
- * Should allow retry.
- *
- * @param id the id
- * @return true, if successful
- */
- private boolean shouldAllowRetry(String id) {
- boolean isRetryAllowed = true;
- if (retryLimitTracker.get(id) != null) {
- Integer currentCount = retryLimitTracker.get(id);
- if (currentCount.intValue() >= RETRY_COUNT_PER_ENTITY_LIMIT.intValue()) {
- isRetryAllowed = false;
- LOG.error(AaiUiMsgs.ES_CROSS_ENTITY_RESYNC_LIMIT, id);
- } else {
- Integer newCount = new Integer(currentCount.intValue() + 1);
- retryLimitTracker.put(id, newCount);
- }
-
- } else {
- Integer firstRetryCount = new Integer(1);
- retryLimitTracker.put(id, firstRetryCount);
- }
-
- return isRetryAllowed;
- }
-
- /**
- * Gets the populated document.
- *
- * @param entityNode the entity node
- * @param resultDescriptor the result descriptor
- * @return the populated document
- * @throws JsonProcessingException the json processing exception
- * @throws IOException Signals that an I/O exception has occurred.
- */
- protected IndexableCrossEntityReference getPopulatedDocument(JsonNode entityNode,
- OxmEntityDescriptor resultDescriptor) throws JsonProcessingException, IOException {
-
- IndexableCrossEntityReference icer = new IndexableCrossEntityReference();
-
- icer.setEntityType(resultDescriptor.getEntityName());
-
- List primaryKeyValues = new ArrayList();
- String pkeyValue = null;
-
- for (String keyName : resultDescriptor.getPrimaryKeyAttributeNames()) {
- pkeyValue = NodeUtils.getNodeFieldAsText(entityNode, keyName);
- if (pkeyValue != null) {
- primaryKeyValues.add(pkeyValue);
- } else {
- LOG.warn(AaiUiMsgs.ES_PKEYVALUE_NULL, resultDescriptor.getEntityName());
- }
- }
-
- final String primaryCompositeKeyValue = NodeUtils.concatArray(primaryKeyValues, "/");
- icer.setEntityPrimaryKeyValue(primaryCompositeKeyValue);
-
- return icer;
-
- }
-}
diff --git a/src/main/java/org/onap/aai/sparky/dal/ActiveInventoryAdapter.java b/src/main/java/org/onap/aai/sparky/dal/ActiveInventoryAdapter.java
deleted file mode 100644
index 9d33a3b..0000000
--- a/src/main/java/org/onap/aai/sparky/dal/ActiveInventoryAdapter.java
+++ /dev/null
@@ -1,400 +0,0 @@
-/**
- * ============LICENSE_START=======================================================
- * org.onap.aai
- * ================================================================================
- * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved.
- * Copyright © 2017-2018 Amdocs
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-package org.onap.aai.sparky.dal;
-
-import java.io.IOException;
-import java.net.URI;
-import java.net.URISyntaxException;
-import java.net.URLEncoder;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.NoSuchElementException;
-
-import javax.ws.rs.core.MediaType;
-import javax.ws.rs.core.UriBuilder;
-
-import org.apache.http.client.utils.URIBuilder;
-import org.onap.aai.cl.api.Logger;
-import org.onap.aai.cl.eelf.LoggerFactory;
-import org.onap.aai.restclient.client.OperationResult;
-import org.onap.aai.restclient.client.RestClient;
-import org.onap.aai.restclient.enums.RestAuthenticationMode;
-import org.onap.aai.sparky.config.oxm.OxmEntityDescriptor;
-import org.onap.aai.sparky.config.oxm.OxmEntityLookup;
-import org.onap.aai.sparky.config.oxm.OxmModelLoader;
-import org.onap.aai.sparky.dal.exception.ElasticSearchOperationException;
-import org.onap.aai.sparky.dal.rest.RestClientConstructionException;
-import org.onap.aai.sparky.dal.rest.RestClientFactory;
-import org.onap.aai.sparky.dal.rest.config.RestEndpointConfig;
-import org.onap.aai.sparky.logging.AaiUiMsgs;
-import org.onap.aai.sparky.util.NodeUtils;
-
-/**
- * The Class ActiveInventoryAdapter.
- */
-
-public class ActiveInventoryAdapter {
-
- private static final Logger LOG =
- LoggerFactory.getInstance().getLogger(ActiveInventoryAdapter.class);
-
- private static final String HEADER_TRANS_ID = "X-TransactionId";
- private static final String HEADER_FROM_APP_ID = "X-FromAppId";
- private static final String HEADER_AUTHORIZATION = "Authorization";
-
- private static final String HTTP_SCHEME = "http";
- private static final String HTTPS_SCHEME = "https";
-
- private static final String TRANSACTION_ID_PREFIX = "txnId-";
- private static final String UI_APP_NAME = "AAI-UI";
-
- private OxmModelLoader oxmModelLoader;
- private OxmEntityLookup oxmEntityLookup;
- private RestEndpointConfig endpointConfig;
-
- private RestClient restClient;
-
- /**
- * Instantiates a new active inventory adapter.
- * @throws RestClientConstructionException
- *
- */
-
- public ActiveInventoryAdapter(OxmModelLoader oxmModelLoader, OxmEntityLookup oxmEntityLookup,
- RestEndpointConfig endpointConfig)
- throws ElasticSearchOperationException, IOException, RestClientConstructionException {
-
- this.oxmModelLoader = oxmModelLoader;
- this.oxmEntityLookup = oxmEntityLookup;
- this.endpointConfig = endpointConfig;
- this.restClient = RestClientFactory.buildClient(endpointConfig);
-
- }
-
- protected Map> getMessageHeaders() {
-
- Map> headers = new HashMap>();
-
- headers.putIfAbsent(HEADER_FROM_APP_ID, new ArrayList());
- headers.get(HEADER_FROM_APP_ID).add(UI_APP_NAME);
-
- headers.putIfAbsent(HEADER_TRANS_ID, new ArrayList());
- headers.get(HEADER_TRANS_ID).add(TRANSACTION_ID_PREFIX + NodeUtils.getRandomTxnId());
-
- if (endpointConfig.getRestAuthenticationMode() == RestAuthenticationMode.SSL_BASIC) {
-
- headers.putIfAbsent(HEADER_AUTHORIZATION, new ArrayList());
- headers.get(HEADER_AUTHORIZATION).add(getBasicAuthenticationCredentials());
-
- }
-
- return headers;
- }
-
- protected String getBasicAuthenticationCredentials() {
- String usernameAndPassword = String.join(":", endpointConfig.getBasicAuthUserName(),
- endpointConfig.getBasicAuthPassword());
- return "Basic " + java.util.Base64.getEncoder().encodeToString(usernameAndPassword.getBytes());
- }
-
- public OxmEntityLookup getOxmEntityLookup() {
- return oxmEntityLookup;
- }
-
- public void setOxmEntityLookup(OxmEntityLookup oxmEntityLookup) {
- this.oxmEntityLookup = oxmEntityLookup;
- }
-
- protected String getResourceBasePath() {
-
- String versionStr = null;
- if (oxmModelLoader != null) {
- versionStr = String.valueOf(oxmModelLoader.getLatestVersionNum());
- }
-
- return "/aai/v" + versionStr;
-
- }
-
- public static String extractResourcePath(String selflink) {
- try {
- return new URI(selflink).getRawPath();
- } catch (URISyntaxException uriSyntaxException) {
- LOG.error(AaiUiMsgs.ERROR_EXTRACTING_RESOURCE_PATH_FROM_LINK,
- uriSyntaxException.getMessage());
- return selflink;
- }
- }
-
-
- /**
- * Gets the full url.
- *
- * @param resourceUrl the resource url
- * @return the full url
- * @throws Exception the exception
- */
- private String getFullUrl(String resourceUrl) throws Exception {
- final String basePath = getResourceBasePath();
- return String.format("https://%s:%s%s%s", endpointConfig.getEndpointIpAddress(),
- endpointConfig.getEndpointServerPort(), basePath, resourceUrl);
- }
-
- public String getGenericQueryForSelfLink(String startNodeType, List queryParams)
- throws Exception {
-
- URIBuilder urlBuilder = new URIBuilder(getFullUrl("/search/generic-query"));
-
- for (String queryParam : queryParams) {
- urlBuilder.addParameter("key", queryParam);
- }
-
- urlBuilder.addParameter("start-node-type", startNodeType);
- urlBuilder.addParameter("include", startNodeType);
-
- final String constructedLink = urlBuilder.toString();
-
- return constructedLink;
-
- }
-
-
- public OperationResult getSelfLinksByEntityType(String entityType) throws Exception {
-
- /*
- * For this one, I want to dynamically construct the nodes-query for self-link discovery as a
- * utility method that will use the OXM model entity data to drive the query as well.
- */
-
- if (entityType == null) {
- throw new NullPointerException(
- "Failed to getSelfLinksByEntityType() because entityType is null");
- }
-
- OxmEntityDescriptor entityDescriptor = oxmEntityLookup.getEntityDescriptors().get(entityType);
-
- if (entityDescriptor == null) {
- throw new NoSuchElementException("Failed to getSelfLinksByEntityType() because could"
- + " not find entity descriptor from OXM with type = " + entityType);
- }
-
- String link = null;
- final String primaryKeyStr =
- NodeUtils.concatArray(entityDescriptor.getPrimaryKeyAttributeNames(), "/");
-
- link = getFullUrl("/search/nodes-query?search-node-type=" + entityType + "&filter="
- + primaryKeyStr + ":EXISTS");
-
-
- return restClient.get(link, getMessageHeaders(), MediaType.APPLICATION_JSON_TYPE);
-
- }
-
- public OperationResult getSelfLinkForEntity(String entityType, String primaryKeyName,
- String primaryKeyValue) throws Exception {
-
- if (entityType == null) {
- throw new NullPointerException("Failed to getSelfLinkForEntity() because entityType is null");
- }
-
- if (primaryKeyName == null) {
- throw new NullPointerException(
- "Failed to getSelfLinkForEntity() because primaryKeyName is null");
- }
-
- if (primaryKeyValue == null) {
- throw new NullPointerException(
- "Failed to getSelfLinkForEntity() because primaryKeyValue is null");
- }
-
- /*
- * Try to protect ourselves from illegal URI formatting exceptions caused by characters that
- * aren't natively supported in a URI, but can be escaped to make them legal.
- */
-
- String encodedEntityType = URLEncoder.encode(entityType, "UTF-8");
- String encodedPrimaryKeyName = URLEncoder.encode(primaryKeyName, "UTF-8");
- String encodedPrimaryKeyValue = URLEncoder.encode(primaryKeyValue, "UTF-8");
-
- String link = null;
-
- if ("service-instance".equals(entityType)) {
-
- link = getFullUrl("/search/generic-query?key=" + encodedEntityType + "."
- + encodedPrimaryKeyName + ":" + encodedPrimaryKeyValue + "&start-node-type="
- + encodedEntityType + "&include=customer&depth=2");
-
- } else {
-
- link =
- getFullUrl("/search/generic-query?key=" + encodedEntityType + "." + encodedPrimaryKeyName
- + ":" + encodedPrimaryKeyValue + "&start-node-type=" + encodedEntityType);
-
- }
-
- return queryActiveInventoryWithRetries(link, "application/json",
- endpointConfig.getNumRequestRetries());
-
- }
-
-
- /**
- * Our retry conditions should be very specific.
- *
- * @param r the r
- * @return true, if successful
- */
- private boolean shouldRetryRequest(OperationResult r) {
-
- if (r == null) {
- return true;
- }
-
- int rc = r.getResultCode();
-
- if (rc == 200) {
- return false;
- }
-
- if (rc == 404) {
- return false;
- }
-
- return true;
-
- }
-
- /**
- * Query active inventory.
- *
- * @param url the url
- * @param acceptContentType the accept content type
- * @return the operation result
- */
- // package protected for test classes instead of private
- OperationResult queryActiveInventory(String url, String acceptContentType) {
-
- return restClient.get(url, getMessageHeaders(), MediaType.APPLICATION_JSON_TYPE);
-
- }
-
- public RestEndpointConfig getEndpointConfig() {
- return endpointConfig;
- }
-
- public void setEndpointConfig(RestEndpointConfig endpointConfig) {
- this.endpointConfig = endpointConfig;
- }
-
- public OperationResult queryActiveInventoryWithRetries(String url, String responseType,
- int numRetries) {
-
- OperationResult result = null;
-
- for (int retryCount = 0; retryCount < numRetries; retryCount++) {
-
- LOG.debug(AaiUiMsgs.QUERY_AAI_RETRY_SEQ, url, String.valueOf(retryCount + 1));
-
- result = queryActiveInventory(url, responseType);
-
- /**
- * Record number of times we have attempted the request to later summarize how many times we
- * are generally retrying over thousands of messages in a sync.
- *
- * If the number of retries is surprisingly high, then we need to understand why that is as
- * the number of retries is also causing a heavier load on AAI beyond the throttling controls
- * we already have in place in term of the transaction rate controller and number of
- * parallelized threads per task processor.
- */
-
- result.setNumRetries(retryCount);
-
- if (!shouldRetryRequest(result)) {
-
- result.setFromCache(false);
- LOG.debug(AaiUiMsgs.QUERY_AAI_RETRY_DONE_SEQ, url, String.valueOf(retryCount + 1));
-
- return result;
- }
-
- try {
- /*
- * Sleep between re-tries to be nice to the target system.
- */
- Thread.sleep(50);
- } catch (InterruptedException exc) {
- LOG.error(AaiUiMsgs.QUERY_AAI_WAIT_INTERRUPTION, exc.getLocalizedMessage());
- break;
- }
- LOG.error(AaiUiMsgs.QUERY_AAI_RETRY_FAILURE_WITH_SEQ, url, String.valueOf(retryCount + 1));
-
- }
-
- LOG.info(AaiUiMsgs.QUERY_AAI_RETRY_MAXED_OUT, url);
-
- return result;
-
- }
-
- public String repairSelfLink(String selfLink) {
- return repairSelfLink(selfLink, null);
- }
-
- /**
- * This method adds a scheme, host and port (if missing) to the passed-in URI.
- * If these parts of the URI are already present, they will not be duplicated.
- *
- * @param selflink The URI to repair
- * @param queryParams The query parameters as a single string
- * @return The corrected URI (i.e. includes a scheme/host/port)
- */
- public String repairSelfLink(String selflink, String queryParams) {
- if (selflink == null) {
- return selflink;
- }
-
- UriBuilder builder = UriBuilder.fromPath(selflink).host(endpointConfig.getEndpointIpAddress())
- .port(Integer.parseInt(endpointConfig.getEndpointServerPort()));
-
- switch (endpointConfig.getRestAuthenticationMode()) {
-
- case SSL_BASIC:
- case SSL_CERT: {
- builder.scheme(HTTPS_SCHEME);
- break;
- }
-
- default: {
- builder.scheme(HTTP_SCHEME);
- }
- }
-
- boolean includeQueryParams = ( (null != queryParams) && (!"".equals(queryParams)) );
-
- /* builder.build().toString() will encode special characters to hexadecimal pairs prefixed with a '%'
- so we're adding the query parameters separately, in their UTF-8 representations, so that
- characters such as '?', '&', etc. remain intact as needed by the synchronizer */
- return (builder.build().toString() + (includeQueryParams ? queryParams : ""));
- }
-
-}
diff --git a/src/main/java/org/onap/aai/sparky/dal/ElasticSearchAdapter.java b/src/main/java/org/onap/aai/sparky/dal/ElasticSearchAdapter.java
deleted file mode 100644
index 3072b91..0000000
--- a/src/main/java/org/onap/aai/sparky/dal/ElasticSearchAdapter.java
+++ /dev/null
@@ -1,153 +0,0 @@
-/**
- * ============LICENSE_START=======================================================
- * org.onap.aai
- * ================================================================================
- * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved.
- * Copyright © 2017-2018 Amdocs
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-package org.onap.aai.sparky.dal;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-import javax.ws.rs.core.MediaType;
-
-import org.onap.aai.restclient.client.OperationResult;
-import org.onap.aai.restclient.client.RestClient;
-import org.onap.aai.sparky.dal.rest.RestClientConstructionException;
-import org.onap.aai.sparky.dal.rest.RestClientFactory;
-import org.onap.aai.sparky.dal.rest.config.RestEndpointConfig;
-
-/**
- * The Class ElasticSearchAdapter.
-
- */
-public class ElasticSearchAdapter {
-
- private static final String BULK_IMPORT_INDEX_TEMPLATE =
- "{\"index\":{\"_index\":\"%s\",\"_type\":\"%s\",\"_id\":\"%s\", \"_version\":\"%s\"}}\n";
-
- private static final String BULK_API = "_bulk";
-
- private static final String DEFAULT_TYPE = "default";
-
- private RestClient restClient;
- private RestEndpointConfig endpointConfig;
-
- /**
- * Instantiates a new elastic search adapter.
- * @throws RestClientConstructionException
- */
- public ElasticSearchAdapter(RestEndpointConfig endpointConfig) throws RestClientConstructionException {
-
- this.restClient = RestClientFactory.buildClient(endpointConfig);
- this.endpointConfig = endpointConfig;
-
- }
-
- protected Map> getMessageHeaders() {
- Map> headers = new HashMap>();
- // insert mandatory headers if there are any
- return headers;
- }
-
- public OperationResult doGet(String url, MediaType acceptContentType) {
- return restClient.get(url, getMessageHeaders(), acceptContentType);
- }
-
- public OperationResult doDelete(String url, MediaType acceptContentType) {
- return restClient.delete(url, getMessageHeaders(), acceptContentType);
- }
-
- public OperationResult doPost(String url, String jsonPayload, MediaType acceptContentType) {
- return restClient.post(url, jsonPayload, getMessageHeaders(), MediaType.APPLICATION_JSON_TYPE,
- acceptContentType);
- }
-
- public OperationResult doPut(String url, String jsonPayload, MediaType acceptContentType) {
- return restClient.put(url, jsonPayload, getMessageHeaders(), MediaType.APPLICATION_JSON_TYPE,
- acceptContentType);
- }
-
- public OperationResult doPatch(String url, String jsonPayload, MediaType acceptContentType) {
-
- Map> headers = getMessageHeaders();
- headers.putIfAbsent("X-HTTP-Method-Override", new ArrayList());
- headers.get("X-HTTP-Method-Override").add("PATCH");
-
- return restClient.post(url, jsonPayload, headers, MediaType.APPLICATION_JSON_TYPE, acceptContentType);
- }
-
- public OperationResult doHead(String url, MediaType acceptContentType) {
- return restClient.head(url, getMessageHeaders(), acceptContentType);
- }
-
- public OperationResult doBulkOperation(String url, String payload) {
- return restClient.put(url, payload, getMessageHeaders(),
- MediaType.APPLICATION_FORM_URLENCODED_TYPE, MediaType.APPLICATION_JSON_TYPE);
- }
-
- public String buildBulkImportOperationRequest(String index, String type, String id,
- String version, String payload) {
-
- StringBuilder requestPayload = new StringBuilder(128);
-
- requestPayload.append(String.format(BULK_IMPORT_INDEX_TEMPLATE, index, type, id, version));
- requestPayload.append(payload).append("\n");
-
- return requestPayload.toString();
-
- }
-
- public OperationResult retrieveEntityById(String host, String port, String indexName,
- String docType, String resourceUrl) {
- String esUrl =
- String.format("http://%s:%s/%s/%s/%s", host, port, indexName, docType, resourceUrl);
- return doGet(esUrl, MediaType.APPLICATION_JSON_TYPE);
- }
-
- public String buildElasticSearchUrlForApi(String indexName, String api) {
- return String.format("http://%s:%s/%s/%s", endpointConfig.getEndpointIpAddress(),
- endpointConfig.getEndpointServerPort(), indexName, api);
- }
-
- public String buildElasticSearchUrl(String indexName, String docType) {
- return String.format("http://%s:%s/%s/%s", endpointConfig.getEndpointIpAddress(),
- endpointConfig.getEndpointServerPort(), indexName, docType);
- }
-
- public String buildElasticSearchGetDocUrl(String indexName, String docType, String docId) {
- return String.format("http://%s:%s/%s/%s/%s", endpointConfig.getEndpointIpAddress(),
- endpointConfig.getEndpointServerPort(), indexName, docType, docId);
- }
-
- public String buildElasticSearchGetDocUrl(String indexName, String docId) {
- return buildElasticSearchGetDocUrl(indexName, DEFAULT_TYPE, docId);
- }
-
- public String buildElasticSearchPostUrl(String indexName) {
- return String.format("http://%s:%s/%s/%s", endpointConfig.getEndpointIpAddress(),
- endpointConfig.getEndpointServerPort(), indexName, DEFAULT_TYPE);
- }
-
- public String getBulkUrl() {
- return String.format("http://%s:%s/%s", endpointConfig.getEndpointIpAddress(),
- endpointConfig.getEndpointServerPort(), BULK_API);
- }
-
-}
diff --git a/src/main/java/org/onap/aai/sparky/dal/GizmoAdapter.java b/src/main/java/org/onap/aai/sparky/dal/GizmoAdapter.java
deleted file mode 100644
index 86573d2..0000000
--- a/src/main/java/org/onap/aai/sparky/dal/GizmoAdapter.java
+++ /dev/null
@@ -1,332 +0,0 @@
-/**
- * ============LICENSE_START=======================================================
- * org.onap.aai
- * ================================================================================
- * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved.
- * Copyright © 2017-2018 Amdocs
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-package org.onap.aai.sparky.dal;
-
-import java.io.IOException;
-import java.net.URI;
-import java.net.URISyntaxException;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-import javax.ws.rs.core.MediaType;
-import javax.ws.rs.core.UriBuilder;
-
-import org.onap.aai.cl.api.Logger;
-import org.onap.aai.cl.eelf.LoggerFactory;
-import org.onap.aai.restclient.client.OperationResult;
-import org.onap.aai.restclient.client.RestClient;
-import org.onap.aai.restclient.enums.RestAuthenticationMode;
-import org.onap.aai.sparky.config.oxm.OxmModelLoader;
-import org.onap.aai.sparky.dal.exception.ElasticSearchOperationException;
-import org.onap.aai.sparky.dal.rest.RestClientConstructionException;
-import org.onap.aai.sparky.dal.rest.RestClientFactory;
-import org.onap.aai.sparky.dal.rest.config.RestEndpointConfig;
-import org.onap.aai.sparky.logging.AaiUiMsgs;
-import org.onap.aai.sparky.util.NodeUtils;
-
-/**
- * The Class GizmoAdapter.
- */
-
-public class GizmoAdapter {
-
- private static final Logger LOG = LoggerFactory.getInstance().getLogger(GizmoAdapter.class);
-
- private static final String HEADER_TRANS_ID = "X-TransactionId";
- private static final String HEADER_FROM_APP_ID = "X-FromAppId";
- private static final String HEADER_AUTHORIZATION = "Authorization";
-
- private static final String HTTP_SCHEME = "http";
- private static final String HTTPS_SCHEME = "https";
-
- private static final String TRANSACTION_ID_PREFIX = "txnId-";
- private static final String UI_APP_NAME = "AAI-UI";
-
- private OxmModelLoader oxmModelLoader;
-
- private RestEndpointConfig endpointConfig;
-
- private RestClient restClient;
-
- private String inventoryBasePath;
- private String relationshipsBasePath;
-
- /**
- * Instantiates a new active inventory adapter.
- *
- * @throws RestClientConstructionException
- *
- */
-
- public GizmoAdapter(OxmModelLoader oxmModelLoader, RestEndpointConfig endpointConfig)
- throws ElasticSearchOperationException, IOException, RestClientConstructionException {
-
- this.oxmModelLoader = oxmModelLoader;
- this.endpointConfig = endpointConfig;
- this.restClient = RestClientFactory.buildClient(endpointConfig);
-
- }
-
- public String getRelationshipsBasePath() {
- return relationshipsBasePath;
- }
-
- public void setRelationshipsBasePath(String relationshipsBasePath) {
- this.relationshipsBasePath = relationshipsBasePath;
- }
-
- public String getInventoryBasePath() {
- return inventoryBasePath;
- }
-
- public void setInventoryBasePath(String inventoryBasePath) {
- this.inventoryBasePath = inventoryBasePath;
- }
-
- public String getFullInventoryUrl(String resourceUrl) throws Exception {
- final String host = endpointConfig.getEndpointIpAddress();
- final String port = endpointConfig.getEndpointServerPort();
- final String basePath = getInventoryBasePath();
- return String.format("https://%s:%s%s%s", host, port, basePath, resourceUrl);
- }
-
- public String addServerDetailsToUrl(String resourceUrl) throws Exception {
- final String host = endpointConfig.getEndpointIpAddress();
- final String port = endpointConfig.getEndpointServerPort();
- return String.format("https://%s:%s/%s", host, port, resourceUrl);
- }
-
- public String getFullRelationshipUrl(String resourceUrl) throws Exception {
- final String host = endpointConfig.getEndpointIpAddress();
- final String port = endpointConfig.getEndpointServerPort();
- final String basePath = getRelationshipsBasePath();
- return String.format("https://%s:%s%s%s", host, port, basePath, resourceUrl);
- }
-
- protected Map> getMessageHeaders() {
-
- Map> headers = new HashMap>();
-
- headers.putIfAbsent(HEADER_FROM_APP_ID, new ArrayList());
- headers.get(HEADER_FROM_APP_ID).add(UI_APP_NAME);
-
- headers.putIfAbsent(HEADER_TRANS_ID, new ArrayList());
- headers.get(HEADER_TRANS_ID).add(TRANSACTION_ID_PREFIX + NodeUtils.getRandomTxnId());
-
- if (endpointConfig.getRestAuthenticationMode() == RestAuthenticationMode.SSL_BASIC) {
-
- headers.putIfAbsent(HEADER_AUTHORIZATION, new ArrayList());
- headers.get(HEADER_AUTHORIZATION).add(getBasicAuthenticationCredentials());
-
- }
-
- return headers;
- }
-
- protected String getBasicAuthenticationCredentials() {
- String usernameAndPassword = String.join(":", endpointConfig.getBasicAuthUserName(),
- endpointConfig.getBasicAuthPassword());
- return "Basic " + java.util.Base64.getEncoder().encodeToString(usernameAndPassword.getBytes());
- }
-
- /**
- * Our retry conditions should be very specific.
- *
- * @param r
- * the r
- * @return true, if successful
- */
- private boolean shouldRetryRequest(OperationResult r) {
-
- if (r == null) {
- return true;
- }
-
- int rc = r.getResultCode();
-
- if (rc == 200) {
- return false;
- }
-
- if (rc == 404) {
- return false;
- }
-
- return true;
-
- }
-
- /**
- * Query active inventory.
- *
- * @param url
- * the url
- * @param acceptContentType
- * the accept content type
- * @return the operation result
- */
- OperationResult queryGizmo(String url, String acceptContentType) {
-
- return restClient.get(url, getMessageHeaders(), MediaType.APPLICATION_JSON_TYPE);
-
- }
-
- public RestEndpointConfig getEndpointConfig() {
- return endpointConfig;
- }
-
- public void setEndpointConfig(RestEndpointConfig endpointConfig) {
- this.endpointConfig = endpointConfig;
- }
-
- public OperationResult queryGizmoWithRetries(String url, String responseType, int numRetries) {
-
- OperationResult result = null;
-
- for (int retryCount = 0; retryCount < numRetries; retryCount++) {
-
- LOG.debug(AaiUiMsgs.QUERY_AAI_RETRY_SEQ, url, String.valueOf(retryCount + 1));
-
- result = queryGizmo(url, responseType);
-
- /**
- * Record number of times we have attempted the request to later
- * summarize how many times we are generally retrying over thousands
- * of messages in a sync.
- *
- * If the number of retries is surprisingly high, then we need to
- * understand why that is as the number of retries is also causing a
- * heavier load on AAI beyond the throttling controls we already
- * have in place in term of the transaction rate controller and
- * number of parallelized threads per task processor.
- */
-
- result.setNumRetries(retryCount);
-
- if (!shouldRetryRequest(result)) {
-
- result.setFromCache(false);
- LOG.debug(AaiUiMsgs.QUERY_AAI_RETRY_DONE_SEQ, url, String.valueOf(retryCount + 1));
-
- return result;
- }
-
- try {
- /*
- * Sleep between re-tries to be nice to the target system.
- */
- Thread.sleep(50);
- } catch (InterruptedException exc) {
- LOG.error(AaiUiMsgs.QUERY_AAI_WAIT_INTERRUPTION, exc.getLocalizedMessage());
- break;
- }
- LOG.error(AaiUiMsgs.QUERY_AAI_RETRY_FAILURE_WITH_SEQ, url, String.valueOf(retryCount + 1));
-
- }
-
- LOG.info(AaiUiMsgs.QUERY_AAI_RETRY_MAXED_OUT, url);
-
- return result;
-
- }
-
- /**
- * This method adds a scheme, host and port (if missing) to the passed-in
- * URI. If these parts of the URI are already present, they will not be
- * duplicated.
- *
- * @param selflink
- * The URI to repair
- * @param queryParams
- * The query parameters as a single string
- * @return The corrected URI (i.e. includes a scheme/host/port)
- */
-
- private String repairGizmoSelfLink(String baseUrlPath, String selfLink, String queryParams) {
-
- if (selfLink == null) {
- return selfLink;
- }
-
- if (selfLink.startsWith("http") || selfLink.startsWith("https")) {
- return selfLink;
- }
-
- UriBuilder builder = UriBuilder.fromPath(baseUrlPath + "/" + selfLink)
- .host(endpointConfig.getEndpointIpAddress())
- .port(Integer.parseInt(endpointConfig.getEndpointServerPort()));
-
- switch (endpointConfig.getRestAuthenticationMode()) {
-
- case SSL_BASIC:
- case SSL_CERT: {
- builder.scheme(HTTPS_SCHEME);
- break;
- }
-
- default: {
- builder.scheme(HTTP_SCHEME);
- }
- }
-
- boolean includeQueryParams = ((null != queryParams) && (!"".equals(queryParams)));
-
- /*
- * builder.build().toString() will encode special characters to hexadecimal pairs prefixed with
- * a '%' so we're adding the query parameters separately, in their UTF-8 representations, so
- * that characters such as '?', '&', etc. remain intact as needed by the synchronizer
- */
- return (builder.build().toString() + (includeQueryParams ? queryParams : ""));
-
- }
-
- public String repairRelationshipSelfLink(String selflink, String queryParams) {
- return repairGizmoSelfLink(relationshipsBasePath, selflink, queryParams);
- }
-
- public String repairInventorySelfLink(String selflink, String queryParams) {
- return repairGizmoSelfLink(inventoryBasePath, selflink, queryParams);
- }
-
- public OperationResult getSelfLinksByEntityType(String entityType) throws Exception {
-
- if (entityType == null) {
- throw new NullPointerException("Failed to getSelfLinksByEntityType() because entityType is null");
- }
-
- String link = getFullInventoryUrl(entityType);
-
- return queryGizmoWithRetries(link, "application/json", endpointConfig.getNumRequestRetries());
-
- }
-
- public static String extractResourcePath(String selflink) {
- try {
- return new URI(selflink).getRawPath();
- } catch (URISyntaxException uriSyntaxException) {
- LOG.error(AaiUiMsgs.ERROR_EXTRACTING_RESOURCE_PATH_FROM_LINK, uriSyntaxException.getMessage());
- return selflink;
- }
- }
-
-}
diff --git a/src/main/java/org/onap/aai/sparky/dal/NetworkTransaction.java b/src/main/java/org/onap/aai/sparky/dal/NetworkTransaction.java
deleted file mode 100644
index 61f2e0a..0000000
--- a/src/main/java/org/onap/aai/sparky/dal/NetworkTransaction.java
+++ /dev/null
@@ -1,155 +0,0 @@
-/**
- * ============LICENSE_START=======================================================
- * org.onap.aai
- * ================================================================================
- * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved.
- * Copyright © 2017-2018 Amdocs
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-package org.onap.aai.sparky.dal;
-
-import org.onap.aai.restclient.client.OperationResult;
-import org.onap.aai.sparky.config.oxm.OxmEntityDescriptor;
-import org.onap.aai.sparky.dal.rest.HttpMethod;
-
-
-/**
- * The Class NetworkTransaction.
- */
-public class NetworkTransaction {
-
- private OperationResult operationResult;
-
- private String entityType;
-
- private String link;
-
- private String queryParameters;
-
- private HttpMethod operationType;
-
- private OxmEntityDescriptor descriptor;
-
- private long createdTimeStampInMs;
-
- private long opTimeInMs;
-
- private long taskAgeInMs;
-
- /**
- * Instantiates a new network transaction.
- */
- public NetworkTransaction() {
- this.createdTimeStampInMs = System.currentTimeMillis();
- this.opTimeInMs = 0L;
- }
-
- /**
- * Instantiates a new network transaction.
- *
- * @param method the method
- * @param entityType the entity type
- * @param or the or
- */
- public NetworkTransaction(HttpMethod method, String entityType, OperationResult or) {
- this();
- this.operationType = method;
- this.entityType = entityType;
- this.operationResult = or;
- this.opTimeInMs = 0L;
- }
-
- public HttpMethod getOperationType() {
- return operationType;
- }
-
- public long getTaskAgeInMs() {
- return taskAgeInMs;
- }
-
- /**
- * Sets the task age in ms.
- */
- public void setTaskAgeInMs() {
- this.taskAgeInMs = (System.currentTimeMillis() - createdTimeStampInMs);
- }
-
- public void setOperationType(HttpMethod operationType) {
- this.operationType = operationType;
- }
-
- public OperationResult getOperationResult() {
- return operationResult;
- }
-
- public void setOperationResult(OperationResult operationResult) {
- this.operationResult = operationResult;
- }
-
- public String getEntityType() {
- return entityType;
- }
-
- public void setEntityType(String entityType) {
- this.entityType = entityType;
- }
-
- public String getLink() {
- return link;
- }
-
- public void setLink(String link) {
- this.link = link;
- }
-
- public String getQueryParameters() {
- return queryParameters;
- }
-
- public void setQueryParameters(String queryParameters) {
- this.queryParameters = queryParameters;
- }
-
- public long getOpTimeInMs() {
- return opTimeInMs;
- }
-
- public void setOpTimeInMs(long opTimeInMs) {
- this.opTimeInMs = opTimeInMs;
- }
-
- public OxmEntityDescriptor getDescriptor() {
- return descriptor;
- }
-
- public void setDescriptor(OxmEntityDescriptor descriptor) {
- this.descriptor = descriptor;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see java.lang.Object#toString()
- */
- @Override
- public String toString() {
- return "NetworkTransaction [operationResult=" + operationResult.toString() + ", entityType="
- + entityType + ", link=" + link + ", operationType=" + operationType + ", descriptor="
- + descriptor.toString() + ", createdTimeStampInMs=" + createdTimeStampInMs
- + ", taskAgeInMs=" + taskAgeInMs + "]";
- }
-
-
-}
diff --git a/src/main/java/org/onap/aai/sparky/dal/aai/ActiveInventoryEntityStatistics.java b/src/main/java/org/onap/aai/sparky/dal/aai/ActiveInventoryEntityStatistics.java
deleted file mode 100644
index 3e79619..0000000
--- a/src/main/java/org/onap/aai/sparky/dal/aai/ActiveInventoryEntityStatistics.java
+++ /dev/null
@@ -1,281 +0,0 @@
-/**
- * ============LICENSE_START=======================================================
- * org.onap.aai
- * ================================================================================
- * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved.
- * Copyright © 2017-2018 Amdocs
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-package org.onap.aai.sparky.dal.aai;
-
-import java.util.Comparator;
-import java.util.HashMap;
-import java.util.Map;
-import java.util.Set;
-import java.util.TreeMap;
-import java.util.concurrent.atomic.AtomicInteger;
-
-import org.onap.aai.restclient.client.OperationResult;
-import org.onap.aai.sparky.dal.NetworkTransaction;
-
-
-/**
- * The Class ActiveInventoryEntityStatistics.
- */
-public class ActiveInventoryEntityStatistics {
-
- private static final String TOTAL = "Total";
-
- private static final String FOUND = "Found";
-
- private static final String NO_PAYLOAD = "NoPayload";
-
- private static final String NOT_FOUND = "NotFound";
-
- private static final String NUM_RETRIES = "NumRetries";
-
- private static final String ERROR = "Error";
-
- private Map> activeInventoryEntityStatistics;
-
- /**
- * Creates the entity op stats.
- *
- * @return the hash map
- */
- private HashMap createEntityOpStats() {
-
- HashMap opStats = new HashMap();
-
- opStats.put(TOTAL, new AtomicInteger());
- opStats.put(FOUND, new AtomicInteger());
- opStats.put(NO_PAYLOAD, new AtomicInteger());
- opStats.put(NOT_FOUND, new AtomicInteger());
- opStats.put(NUM_RETRIES, new AtomicInteger());
- opStats.put(ERROR, new AtomicInteger());
-
- return opStats;
-
- }
-
- /**
- * Initializecreate active inventory entity statistics.
- */
- private void initializecreateActiveInventoryEntityStatistics() {
- Set keys = activeInventoryEntityStatistics.keySet();
-
- Set opStatKeySet = null;
- Map opStats = null;
-
- for (String k : keys) {
-
- opStats = activeInventoryEntityStatistics.get(k);
-
- opStatKeySet = opStats.keySet();
-
- for (String opStatKey : opStatKeySet) {
- opStats.get(opStatKey).set(0);
- }
- }
- }
-
- /**
- * Instantiates a new active inventory entity statistics.
- *
- * @param loader the loader
- */
- public ActiveInventoryEntityStatistics() {
- activeInventoryEntityStatistics = new HashMap>();
- reset();
- }
-
- /**
- * Initialize counters from oxm entity descriptors.
- *
- * @param descriptors the descriptors
- */
- public void intializeEntityCounters(
- String... entityTypes) {
-
- if (entityTypes != null && entityTypes.length > 0) {
- for (String entityType : entityTypes) {
- activeInventoryEntityStatistics.put(entityType, createEntityOpStats());
- }
-
- }
-
- }
-
- public void intializeEntityCounters(
- Set entityTypes) {
-
- if (entityTypes != null && entityTypes.size() > 0) {
- for (String entityType : entityTypes) {
- activeInventoryEntityStatistics.put(entityType, createEntityOpStats());
- }
- }
-
- }
-
-
-
- /**
- * Reset.
- */
- public void reset() {
- initializecreateActiveInventoryEntityStatistics();
- }
-
- /**
- * Gets the result code.
- *
- * @param txn the txn
- * @return the result code
- */
- private int getResultCode(NetworkTransaction txn) {
-
-
- if (txn == null) {
- return -1;
- }
-
- OperationResult or = txn.getOperationResult();
-
- if (or == null) {
- return -1;
- }
-
- return or.getResultCode();
-
- }
-
- /**
- * Update active inventory entity counters.
- *
- * @param txn the txn
- */
- private void updateActiveInventoryEntityCounters(NetworkTransaction txn) {
-
- if (txn == null) {
- return;
- }
-
- Map opStats = activeInventoryEntityStatistics.get(txn.getEntityType());
-
- int rc = getResultCode(txn);
-
- switch (txn.getOperationType()) {
-
- case GET: {
-
- opStats.get(TOTAL).incrementAndGet();
-
- if (200 <= rc && rc <= 299) {
- opStats.get(FOUND).incrementAndGet();
- } else if (rc == 404) {
- opStats.get(NOT_FOUND).incrementAndGet();
- } else {
- opStats.get(ERROR).incrementAndGet();
- }
-
- break;
- }
-
- default: {
- // nothing else for now
- }
-
- }
-
- OperationResult or = txn.getOperationResult();
-
- if (or != null && or.wasSuccessful()) {
-
- if (or.getResult() == null || or.getResult().length() == 0) {
- opStats.get(NO_PAYLOAD).incrementAndGet();
- }
-
- if (or.getNumRetries() > 0) {
- opStats.get(NUM_RETRIES).addAndGet(or.getNumRetries());
- }
-
- }
-
-
- }
-
- /**
- * Update counters.
- *
- * @param txn the txn
- */
- public void updateCounters(NetworkTransaction txn) {
-
- updateActiveInventoryEntityCounters(txn);
-
- }
-
- public String getStatisticsReport() {
-
- StringBuilder sb = new StringBuilder(128);
-
- /*
- * sort entities, then sort nested op codes
- */
-
- TreeMap> activeInventoryEntitySortedTreeMap =
- new TreeMap>(new Comparator() {
-
- @Override
- public int compare(String o1, String o2) {
- return o1.toLowerCase().compareTo(o2.toLowerCase());
- }
- });
-
- activeInventoryEntitySortedTreeMap.putAll(activeInventoryEntityStatistics);
-
- for (String counterEntityKey : activeInventoryEntitySortedTreeMap.keySet()) {
-
- HashMap entityCounters =
- activeInventoryEntitySortedTreeMap.get(counterEntityKey);
-
- AtomicInteger total = entityCounters.get(TOTAL);
- AtomicInteger found = entityCounters.get(FOUND);
- AtomicInteger noPayload = entityCounters.get(NO_PAYLOAD);
- AtomicInteger notFound = entityCounters.get(NOT_FOUND);
- AtomicInteger numRetries = entityCounters.get(NUM_RETRIES);
- AtomicInteger error = entityCounters.get(ERROR);
-
- int totalValue = (total == null) ? 0 : total.get();
- int foundValue = (found == null) ? 0 : found.get();
- int noPayloadValue = (noPayload == null) ? 0 : noPayload.get();
- int notFoundValue = (notFound == null) ? 0 : notFound.get();
- int numRetriesValue = (numRetries == null) ? 0 : numRetries.get();
- int errorValue = (error == null) ? 0 : error.get();
-
- sb.append("\n ")
- .append(String.format(
- "%-30s TOTAL: %-12d FOUND: %-12d NO_PAYLOAD:"
- + " %-12d NOT_FOUND: %-12d NUM_RETRIES: %-12d ERROR: %-12d",
- counterEntityKey, totalValue, foundValue, noPayloadValue, notFoundValue,
- numRetriesValue, errorValue));
- }
-
- return sb.toString();
- }
-
-
-
-}
diff --git a/src/main/java/org/onap/aai/sparky/dal/aai/ActiveInventoryProcessingExceptionStatistics.java b/src/main/java/org/onap/aai/sparky/dal/aai/ActiveInventoryProcessingExceptionStatistics.java
deleted file mode 100644
index f883634..0000000
--- a/src/main/java/org/onap/aai/sparky/dal/aai/ActiveInventoryProcessingExceptionStatistics.java
+++ /dev/null
@@ -1,135 +0,0 @@
-/**
- * ============LICENSE_START=======================================================
- * org.onap.aai
- * ================================================================================
- * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved.
- * Copyright © 2017-2018 Amdocs
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-package org.onap.aai.sparky.dal.aai;
-
-import org.onap.aai.cl.api.Logger;
-import org.onap.aai.cl.eelf.LoggerFactory;
-import org.onap.aai.restclient.client.OperationResult;
-import org.onap.aai.sparky.analytics.AbstractStatistics;
-import org.onap.aai.sparky.dal.ActiveInventoryAdapter;
-import org.onap.aai.sparky.dal.NetworkTransaction;
-import org.onap.aai.sparky.logging.AaiUiMsgs;
-
-/**
- * The Class ActiveInventoryProcessingExceptionStatistics.
- */
-public class ActiveInventoryProcessingExceptionStatistics extends AbstractStatistics {
-
- private static final Logger LOG =
- LoggerFactory.getInstance().getLogger(ActiveInventoryAdapter.class);
-
- private static final String NATIVE_SOCKET_CONNECT_EXCEPTION = "NativeSocketConnectException";
- private static final String NATIVE_SOCKET_CONNECTION_RESET = "NativeSocketConnectionReset";
- private static final String NATIVE_SOCKET_CONNECTION_REFUSED = "NativeSocketConnectionRefused";
- private static final String CLIENT_TIMEOUT_EXCEPTION = "JerseyClientTimoutException";
- private static final String UNKNOWN_EXCEPTION = "UnknownException";
-
- /**
- * Creates the counters.
- */
- private void createCounters() {
- addCounter(NATIVE_SOCKET_CONNECT_EXCEPTION);
- addCounter(NATIVE_SOCKET_CONNECTION_RESET);
- addCounter(NATIVE_SOCKET_CONNECTION_REFUSED);
- addCounter(CLIENT_TIMEOUT_EXCEPTION);
- addCounter(UNKNOWN_EXCEPTION);
- }
-
- /**
- * Instantiates a new active inventory processing exception statistics.
- */
- public ActiveInventoryProcessingExceptionStatistics() {
- createCounters();
- reset();
- }
-
- /**
- * Update counters.
- *
- * @param txn the txn
- */
- public void updateCounters(NetworkTransaction txn) {
-
- if (txn == null) {
- return;
- }
-
- OperationResult or = txn.getOperationResult();
-
- if (or != null && !or.wasSuccessful()) {
-
- if (or.getResultCode() != 404) {
-
- String result = or.getResult();
-
- if (result != null) {
-
- /*
- * Try to classify exceptions and peg counters
- */
-
- if (result.contains("java.net.SocketTimeoutException: connect timed out")) {
- pegCounter(CLIENT_TIMEOUT_EXCEPTION);
- } else if (result.contains("java.net.ConnectException: Connection timed out: connect")) {
- pegCounter(NATIVE_SOCKET_CONNECT_EXCEPTION);
- } else if (result.contains("java.net.ConnectException: Connection refused: connect")) {
- pegCounter(NATIVE_SOCKET_CONNECTION_REFUSED);
- } else if (result.contains("java.net.SocketException: Connection reset")) {
- pegCounter(NATIVE_SOCKET_CONNECTION_RESET);
- } else {
- pegCounter(UNKNOWN_EXCEPTION);
- LOG.error(AaiUiMsgs.PEGGING_ERROR, result.toString());
- }
-
- }
- }
-
- }
-
- }
-
- public String getStatisticsReport() {
-
- StringBuilder sb = new StringBuilder(128);
-
- int nativeConnect = getCounterValue(NATIVE_SOCKET_CONNECT_EXCEPTION);
- int nativeCxnReset = getCounterValue(NATIVE_SOCKET_CONNECTION_RESET);
- int nativeCxnRefused = getCounterValue(NATIVE_SOCKET_CONNECTION_REFUSED);
- int clientTimeout = getCounterValue(CLIENT_TIMEOUT_EXCEPTION);
- int unknown = getCounterValue(UNKNOWN_EXCEPTION);
-
- sb.append("\n ")
- .append(String.format("%-40s: %-12d", NATIVE_SOCKET_CONNECT_EXCEPTION, nativeConnect));
- sb.append("\n ")
- .append(String.format("%-40s: %-12d", NATIVE_SOCKET_CONNECTION_RESET, nativeCxnReset));
- sb.append("\n ")
- .append(String.format("%-40s: %-12d", NATIVE_SOCKET_CONNECTION_REFUSED, nativeCxnRefused));
- sb.append("\n ")
- .append(String.format("%-40s: %-12d", CLIENT_TIMEOUT_EXCEPTION, clientTimeout));
- sb.append("\n ").append(String.format("%-40s: %-12d", UNKNOWN_EXCEPTION, unknown));
-
- return sb.toString();
-
- }
-
-
-
-}
diff --git a/src/main/java/org/onap/aai/sparky/dal/elasticsearch/ElasticSearchEntityStatistics.java b/src/main/java/org/onap/aai/sparky/dal/elasticsearch/ElasticSearchEntityStatistics.java
deleted file mode 100644
index 8226a25..0000000
--- a/src/main/java/org/onap/aai/sparky/dal/elasticsearch/ElasticSearchEntityStatistics.java
+++ /dev/null
@@ -1,261 +0,0 @@
-/**
- * ============LICENSE_START=======================================================
- * org.onap.aai
- * ================================================================================
- * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved.
- * Copyright © 2017-2018 Amdocs
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-package org.onap.aai.sparky.dal.elasticsearch;
-
-import java.util.Comparator;
-import java.util.HashMap;
-import java.util.Map;
-import java.util.Set;
-import java.util.TreeMap;
-import java.util.concurrent.atomic.AtomicInteger;
-
-import org.onap.aai.restclient.client.OperationResult;
-import org.onap.aai.sparky.dal.NetworkTransaction;
-import org.onap.aai.sparky.dal.rest.HttpMethod;
-
-
-/**
- * The Class ElasticSearchEntityStatistics.
- */
-public class ElasticSearchEntityStatistics {
-
- private static final String TOTAL = "Total";
- private static final String CREATED = "Created";
- private static final String MODIFIED = "Modified";
- private static final String OTHERSUCCESS = "OTHERSUCCESS";
- private static final String DELETED = "DELETED";
- private static final String ERROR = "ERROR";
-
- private Map> entityStatistics;
-
- /**
- * Creates the entity op stats.
- *
- * @return the hash map
- */
- private HashMap createEntityOpStats() {
-
- HashMap opStats = new HashMap();
-
- opStats.put(TOTAL, new AtomicInteger());
- opStats.put(CREATED, new AtomicInteger());
- opStats.put(MODIFIED, new AtomicInteger());
- opStats.put(OTHERSUCCESS, new AtomicInteger());
- opStats.put(DELETED, new AtomicInteger());
- opStats.put(ERROR, new AtomicInteger());
-
- return opStats;
-
- }
-
- /**
- * Initializecreate active inventory entity statistics.
- */
- private void initializecreateActiveInventoryEntityStatistics() {
- Set keys = entityStatistics.keySet();
-
- Set opStatKeySet = null;
- Map opStats = null;
-
- for (String k : keys) {
-
- opStats = entityStatistics.get(k);
-
- opStatKeySet = opStats.keySet();
-
- for (String opStatKey : opStatKeySet) {
- opStats.get(opStatKey).set(0);
- }
- }
- }
-
- /**
- * Instantiates a new elastic search entity statistics.
- *
- * @param loader the loader
- */
- public ElasticSearchEntityStatistics() {
- entityStatistics = new HashMap>();
- reset();
- }
-
- /**
- * Initialize counters from oxm entity descriptors.
- *
- * @param descriptors the descriptors
- */
- public void intializeEntityCounters(
- String... entityTypes) {
-
- if (entityTypes != null && entityTypes.length > 0) {
- for (String entityType : entityTypes) {
- entityStatistics.put(entityType, createEntityOpStats());
- }
-
- }
-
- }
-
- public void intializeEntityCounters(
- Set entityTypes) {
-
- if (entityTypes != null && entityTypes.size() > 0) {
- for (String entityType : entityTypes) {
- entityStatistics.put(entityType, createEntityOpStats());
- }
- }
-
- }
-
- /**
- * Reset.
- */
- public void reset() {
- initializecreateActiveInventoryEntityStatistics();
- }
-
- /**
- * Gets the result code.
- *
- * @param txn the txn
- * @return the result code
- */
- private int getResultCode(NetworkTransaction txn) {
-
-
- if (txn == null) {
- return -1;
- }
-
- OperationResult or = txn.getOperationResult();
-
- if (or == null) {
- return -1;
- }
-
- return or.getResultCode();
-
- }
-
- /**
- * Update elastic search entity counters.
- *
- * @param txn the txn
- */
- private void updateElasticSearchEntityCounters(NetworkTransaction txn) {
-
- if (txn == null) {
- return;
- }
-
- Map entityOpStats = entityStatistics.get(txn.getEntityType());
-
- int resultCode = getResultCode(txn);
-
- if (txn.getOperationType() == HttpMethod.PUT) {
-
- entityOpStats.get(TOTAL).incrementAndGet();
-
- if (resultCode == 201) {
- entityOpStats.get(CREATED).incrementAndGet();
- } else if (resultCode == 200) {
- entityOpStats.get(MODIFIED).incrementAndGet();
- } else if (202 <= resultCode && resultCode <= 299) {
- entityOpStats.get(OTHERSUCCESS).incrementAndGet();
- } else {
- entityOpStats.get(ERROR).incrementAndGet();
- }
-
- } else if (txn.getOperationType() == HttpMethod.DELETE) {
-
- entityOpStats.get(TOTAL).incrementAndGet();
-
- if (200 <= resultCode && resultCode <= 299) {
- entityOpStats.get(DELETED).incrementAndGet();
- } else {
- entityOpStats.get(ERROR).incrementAndGet();
- }
- }
-
- }
-
- /**
- * Update counters.
- *
- * @param txn the txn
- */
- public void updateCounters(NetworkTransaction txn) {
-
- updateElasticSearchEntityCounters(txn);
-
- }
-
- public String getStatisticsReport() {
-
- StringBuilder sb = new StringBuilder(128);
-
- /*
- * sort entities, then sort nested op codes
- */
-
- TreeMap> elasticEntitySortedTreeMap =
- new TreeMap>(new Comparator() {
-
- @Override
- public int compare(String o1, String o2) {
- return o1.toLowerCase().compareTo(o2.toLowerCase());
- }
- });
-
- elasticEntitySortedTreeMap.putAll(entityStatistics);
-
- for (String counterEntityKey : elasticEntitySortedTreeMap.keySet()) {
-
- HashMap entityCounters =
- elasticEntitySortedTreeMap.get(counterEntityKey);
-
- AtomicInteger total = entityCounters.get(TOTAL);
- AtomicInteger created = entityCounters.get(CREATED);
- AtomicInteger modified = entityCounters.get(MODIFIED);
- AtomicInteger otherSuccess = entityCounters.get(OTHERSUCCESS);
- AtomicInteger deleted = entityCounters.get(DELETED);
- AtomicInteger error = entityCounters.get(ERROR);
-
- int totalValue = (total == null) ? 0 : total.get();
- int createdValue = (created == null) ? 0 : created.get();
- int modifiedValue = (modified == null) ? 0 : modified.get();
- int otherSuccessValue = (otherSuccess == null) ? 0 : otherSuccess.get();
- int deletedValue = (deleted == null) ? 0 : deleted.get();
- int errorValue = (error == null) ? 0 : error.get();
-
- sb.append("\n ")
- .append(String.format(
- "%-30s TOTAL: %-12d CREATED: %-12d MODIFIED:"
- + " %-12d OTHER_2XX: %-12d DELETED: %-12d ERROR: %-12d",
- counterEntityKey, totalValue, createdValue, modifiedValue, otherSuccessValue,
- deletedValue, errorValue));
- }
- return sb.toString();
- }
-
-
-
-}
diff --git a/src/main/java/org/onap/aai/sparky/dal/elasticsearch/SearchAdapter.java b/src/main/java/org/onap/aai/sparky/dal/elasticsearch/SearchAdapter.java
deleted file mode 100644
index b80a7d7..0000000
--- a/src/main/java/org/onap/aai/sparky/dal/elasticsearch/SearchAdapter.java
+++ /dev/null
@@ -1,113 +0,0 @@
-/**
- * ============LICENSE_START=======================================================
- * org.onap.aai
- * ================================================================================
- * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved.
- * Copyright © 2017-2018 Amdocs
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-package org.onap.aai.sparky.dal.elasticsearch;
-
-import java.util.Arrays;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-import javax.ws.rs.core.MediaType;
-
-import org.onap.aai.cl.api.Logger;
-import org.onap.aai.cl.eelf.LoggerFactory;
-import org.onap.aai.cl.mdc.MdcContext;
-import org.onap.aai.restclient.client.Headers;
-import org.onap.aai.restclient.client.OperationResult;
-import org.onap.aai.restclient.client.RestClient;
-import org.onap.aai.sparky.dal.sas.config.SearchServiceConfig;
-import org.onap.aai.sparky.util.Encryptor;
-import org.onap.aai.sparky.viewandinspect.config.SparkyConstants;
-import org.slf4j.MDC;
-
-
-/**
- * The Class SearchAdapter.
- */
-public class SearchAdapter {
-
- private static final Logger LOG = LoggerFactory.getInstance().getLogger(SearchAdapter.class);
-
- private RestClient client;
-
- private Map> commonHeaders;
- private SearchServiceConfig sasConfig;
-
- /**
- * Instantiates a new search adapter.
- *
- * @throws Exception
- */
- public SearchAdapter() throws Exception {
- sasConfig = SearchServiceConfig.getConfig();
- Encryptor encryptor = new Encryptor();
-
- client = new RestClient().validateServerHostname(false).validateServerCertChain(false)
- .clientCertFile(SparkyConstants.CONFIG_AUTH_LOCATION + sasConfig.getCertName())
- .clientCertPassword(encryptor.decryptValue(sasConfig.getKeystorePassword()))
- .trustStore(SparkyConstants.CONFIG_AUTH_LOCATION + sasConfig.getKeystore());
-
- commonHeaders = new HashMap>();
- commonHeaders.put("Accept", Arrays.asList("application/json"));
- commonHeaders.put(Headers.FROM_APP_ID, Arrays.asList("AAI-UI"));
- }
-
- public SearchServiceConfig getSasConfig() {
- return sasConfig;
- }
-
- public void setSasConfig(SearchServiceConfig sasConfig) {
- this.sasConfig = sasConfig;
- }
-
- public OperationResult doPost(String url, String jsonPayload, String acceptContentType) {
- OperationResult or = client.post(url, jsonPayload, getTxnHeader(),
- MediaType.APPLICATION_JSON_TYPE, MediaType.APPLICATION_JSON_TYPE);
- return new OperationResult(or.getResultCode(), or.getResult());
- }
-
- public OperationResult doGet(String url, String acceptContentType) {
- OperationResult or = client.get(url, getTxnHeader(), MediaType.APPLICATION_JSON_TYPE);
- return new OperationResult(or.getResultCode(), or.getResult());
- }
-
- public OperationResult doPut(String url, String payload, String acceptContentType) {
- OperationResult or = client.put(url, payload, getTxnHeader(), MediaType.APPLICATION_JSON_TYPE,
- MediaType.APPLICATION_JSON_TYPE);
- return new OperationResult(or.getResultCode(), or.getResult());
- }
-
- public OperationResult doDelete(String url, String acceptContentType) {
-
- OperationResult or = client.delete(url, getTxnHeader(), MediaType.APPLICATION_JSON_TYPE);
- return new OperationResult(or.getResultCode(), or.getResult());
- }
-
- public Map> getTxnHeader() {
- Map headers = new HashMap>();
- headers.putAll(this.commonHeaders);
- headers.put("X-TransactionId", Arrays.asList(MDC.get(MdcContext.MDC_REQUEST_ID)));
- headers.put("X-FromAppId", Arrays.asList(MDC.get(MdcContext.MDC_PARTNER_NAME)));
- return headers;
- }
-
-
-}
diff --git a/src/main/java/org/onap/aai/sparky/dal/exception/ElasticSearchOperationException.java b/src/main/java/org/onap/aai/sparky/dal/exception/ElasticSearchOperationException.java
deleted file mode 100644
index 6c2da6e..0000000
--- a/src/main/java/org/onap/aai/sparky/dal/exception/ElasticSearchOperationException.java
+++ /dev/null
@@ -1,49 +0,0 @@
-/**
- * ============LICENSE_START=======================================================
- * org.onap.aai
- * ================================================================================
- * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved.
- * Copyright © 2017-2018 Amdocs
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-package org.onap.aai.sparky.dal.exception;
-
-/**
- * The Class ElasticSearchOperationException.
- */
-public class ElasticSearchOperationException extends Exception {
-
- private static final long serialVersionUID = -7689309913743200670L;
-
- /**
- * Instantiates a new elastic search operation exception.
- *
- * @param message the message
- * @param exc the exc
- */
- public ElasticSearchOperationException(String message, Exception exc) {
- super(message, exc);
- }
-
- /**
- * Instantiates a new elastic search operation exception.
- *
- * @param message the message
- */
- public ElasticSearchOperationException(String message) {
- super(message);
- }
-
-}
diff --git a/src/main/java/org/onap/aai/sparky/dal/proxy/processor/AaiUiProxyProcessor.java b/src/main/java/org/onap/aai/sparky/dal/proxy/processor/AaiUiProxyProcessor.java
deleted file mode 100644
index 23bfe88..0000000
--- a/src/main/java/org/onap/aai/sparky/dal/proxy/processor/AaiUiProxyProcessor.java
+++ /dev/null
@@ -1,203 +0,0 @@
-/**
- * ============LICENSE_START=======================================================
- * org.onap.aai
- * ================================================================================
- * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved.
- * Copyright © 2017-2018 Amdocs
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-package org.onap.aai.sparky.dal.proxy.processor;
-
-import java.util.Arrays;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-import javax.json.Json;
-import javax.json.JsonObjectBuilder;
-import javax.servlet.http.HttpServletRequest;
-
-import org.apache.camel.Exchange;
-import org.onap.aai.cl.api.Logger;
-import org.onap.aai.cl.eelf.LoggerFactory;
-import org.onap.aai.cl.mdc.MdcContext;
-import org.onap.aai.restclient.client.OperationResult;
-import org.onap.aai.restclient.client.RestClient;
-import org.onap.aai.restclient.rest.HttpUtil;
-import org.onap.aai.sparky.dal.rest.RestClientConstructionException;
-import org.onap.aai.sparky.dal.rest.RestClientFactory;
-import org.onap.aai.sparky.dal.rest.config.RestEndpointConfig;
-import org.onap.aai.sparky.logging.AaiUiMsgs;
-import org.onap.aai.sparky.util.NodeUtils;
-import org.onap.aai.sparky.viewandinspect.config.SparkyConstants;
-import org.slf4j.MDC;
-
-/**
- * The Class AaiUiProxyProcessor.
- */
-public class AaiUiProxyProcessor {
- private static final Logger LOG =
- LoggerFactory.getInstance().getLogger(AaiUiProxyProcessor.class);
- private static Logger auditLogger =
- LoggerFactory.getInstance().getAuditLogger(AaiUiProxyProcessor.class.getName());
-
- private RestClient client;
- private String synapseBaseUrl;
-
- private OperationResult operationResult = null;
-
- private String xTransactionId;
- private String xFromAppId;
-
- private static final String ROUTER_SERVICE = "routerService";
-
-
- /**
- * Instantiates a new AaiUiProxyProcessor.
- *
- * @throws RestClientConstructionException
- */
-
- public AaiUiProxyProcessor(RestEndpointConfig endpointConfig, String apiGatewayEndpoint)
- throws RestClientConstructionException {
- client = RestClientFactory.buildClient(endpointConfig);
- synapseBaseUrl = "https://" + endpointConfig.getEndpointIpAddress() + ":"
- + endpointConfig.getEndpointServerPort() + "/" + apiGatewayEndpoint;
- }
-
-
- void setUpMdcContext(final Exchange exchange, final HttpServletRequest request) {
-
- Object xTransactionId = exchange.getIn().getHeader("X-TransactionId");
- if (xTransactionId == null) {
- this.xTransactionId = NodeUtils.getRandomTxnId();
- } else {
- this.xTransactionId = (String) xTransactionId;
- }
-
- Object partnerName = exchange.getIn().getHeader("X-FromAppId");
- if (partnerName == null) {
- xFromAppId = "Browser";
- } else {
- xFromAppId = (String) partnerName;
- }
-
- MdcContext.initialize((String) xTransactionId, "AAI-UI", "", xFromAppId,
- request.getRequestURI() + ":" + request.getLocalPort());
- }
-
- private Map> getHeaders() {
- Map> headers = new HashMap<>();
- headers.put("X-FromAppId", Arrays.asList(SparkyConstants.APP_NAME));
- headers.put("X-TransactionId", Arrays.asList(MDC.get(MdcContext.MDC_REQUEST_ID)));
- headers.put("X-FromAppId", Arrays.asList(MDC.get(MdcContext.MDC_PARTNER_NAME)));
- return headers;
- }
-
- private String getProxyPayloadAsString(final Exchange exchange) {
- JsonObjectBuilder jsonBuilder = Json.createObjectBuilder();
- String srcUri = "";
- try {
- srcUri = (String) exchange.getIn().getHeader(Exchange.HTTP_URI);
- jsonBuilder.add("origin-uri", srcUri);
-
- String body = exchange.getIn().getBody(String.class);
-
- if (body != null && body.length() != 0) {
- jsonBuilder.add("origin-payload", body);
- }
-
- } catch (Exception e) {
- LOG.error(AaiUiMsgs.ERROR_GENERIC,
- "Failed to extract payload for proxying.\n" + "Requestor URL: " + srcUri);
- }
-
- return jsonBuilder.build().toString();
- }
-
- private String getSynapseUrl(String requestUri) {
- String url = "";
- int pos = requestUri.indexOf(ROUTER_SERVICE);
- if (pos != -1) {
- url = synapseBaseUrl + requestUri.substring(pos + ROUTER_SERVICE.length());
- } else {
- LOG.error(AaiUiMsgs.DR_REQUEST_URI_FOR_PROXY_UNKNOWN, requestUri);
- }
- return url;
- }
-
- public void proxyMessage(Exchange exchange) {
- HttpServletRequest request = exchange.getIn().getBody(HttpServletRequest.class);
-
- setUpMdcContext(exchange, request);
-
- try {
- Map> headers = getHeaders();
- String proxyPayload = getProxyPayloadAsString(exchange);
- String fromUrl = (String) exchange.getIn().getHeader(Exchange.HTTP_URI);
- String toUrl = getSynapseUrl(fromUrl);
- auditLogger.info(AaiUiMsgs.DR_PROXY_FROM_TO, fromUrl, toUrl);
- LOG.debug(AaiUiMsgs.DEBUG_GENERIC,
- "Proxying request:\n" + proxyPayload + "\n" + "Target URL:\n" + toUrl);
-
- long startTimeInMs = System.currentTimeMillis();
-
- operationResult = client.post(toUrl, proxyPayload, headers,
- javax.ws.rs.core.MediaType.APPLICATION_JSON_TYPE,
- javax.ws.rs.core.MediaType.APPLICATION_JSON_TYPE);
-
- long drOpTime = (System.currentTimeMillis() - startTimeInMs);
- int rc = operationResult.getResultCode();
- String result = "";
-
- if (HttpUtil.isHttpResponseClassSuccess(rc)) {
- result = operationResult.getResult();
- } else {
- result = operationResult.getFailureCause();
- LOG.info(AaiUiMsgs.DR_PROCESSING_FAILURE, String.valueOf(rc), proxyPayload);
- }
-
- auditLogger.info(AaiUiMsgs.DR_PROCESSING_TIME, String.valueOf(drOpTime));
-
- exchange.getOut().setHeader("X-TransactionId", xTransactionId);
- exchange.getOut().setHeader("X-FromAppId", xFromAppId);
- exchange.getOut().setHeader("RequestUrl", request.getRequestURI());
- exchange.getOut().setHeader("RequestPort", request.getLocalPort());
- exchange.getOut().setBody(result);
- } catch (Exception exc) {
- LOG.error(AaiUiMsgs.ERROR_PROCESSING_REQUEST, exc);
- }
- }
-
- public String getSynapseBaseUrl() {
- return synapseBaseUrl;
- }
-
- public void setSynapseBaseUrl(String synapseBaseUrl) {
- this.synapseBaseUrl = synapseBaseUrl;
- }
-
- public RestClient getClient() {
- return client;
- }
-
- public void setClient(RestClient client) {
- this.client = client;
- }
-
- protected OperationResult getOperationResult() {
- return operationResult;
- }
-}
diff --git a/src/main/java/org/onap/aai/sparky/dal/rest/HttpMethod.java b/src/main/java/org/onap/aai/sparky/dal/rest/HttpMethod.java
deleted file mode 100644
index aecf153..0000000
--- a/src/main/java/org/onap/aai/sparky/dal/rest/HttpMethod.java
+++ /dev/null
@@ -1,29 +0,0 @@
-/**
- * ============LICENSE_START=======================================================
- * org.onap.aai
- * ================================================================================
- * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved.
- * Copyright © 2017-2018 Amdocs
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-package org.onap.aai.sparky.dal.rest;
-
-
-/**
- * The Enum HttpMethod.
- */
-public enum HttpMethod {
- GET, PUT, POST, DELETE, PATCH, HEAD
-}
diff --git a/src/main/java/org/onap/aai/sparky/dal/rest/RestClientConstructionException.java b/src/main/java/org/onap/aai/sparky/dal/rest/RestClientConstructionException.java
deleted file mode 100644
index d8e2600..0000000
--- a/src/main/java/org/onap/aai/sparky/dal/rest/RestClientConstructionException.java
+++ /dev/null
@@ -1,34 +0,0 @@
-/**
- * ============LICENSE_START=======================================================
- * org.onap.aai
- * ================================================================================
- * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved.
- * Copyright © 2017-2018 Amdocs
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-package org.onap.aai.sparky.dal.rest;
-
-public class RestClientConstructionException extends Exception {
-
- /**
- *
- */
- private static final long serialVersionUID = 1L;
-
- public RestClientConstructionException(String message) {
- super(message);
- }
-
-}
diff --git a/src/main/java/org/onap/aai/sparky/dal/rest/RestClientFactory.java b/src/main/java/org/onap/aai/sparky/dal/rest/RestClientFactory.java
deleted file mode 100644
index 8b7e881..0000000
--- a/src/main/java/org/onap/aai/sparky/dal/rest/RestClientFactory.java
+++ /dev/null
@@ -1,92 +0,0 @@
-/**
- * ============LICENSE_START=======================================================
- * org.onap.aai
- * ================================================================================
- * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved.
- * Copyright © 2017-2018 Amdocs
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-package org.onap.aai.sparky.dal.rest;
-
-import org.onap.aai.restclient.client.RestClient;
-import org.onap.aai.sparky.dal.rest.config.RestEndpointConfig;
-import org.onap.aai.sparky.util.Encryptor;
-import org.onap.aai.sparky.viewandinspect.config.SparkyConstants;
-
-public class RestClientFactory {
-
- public static RestClient buildClient(RestEndpointConfig restEndpointConfig)
- throws RestClientConstructionException {
-
- if (restEndpointConfig == null) {
- throw new RestClientConstructionException(
- "Failed to build RestClient because RestEndpointConfig is null.");
- }
-
- if (restEndpointConfig.getRestAuthenticationMode() == null) {
- throw new RestClientConstructionException(
- "Failed to build RestClient because RestAuthenticationMode is null.");
- }
-
- switch (restEndpointConfig.getRestAuthenticationMode()) {
-
- case SSL_CERT: {
-
- Encryptor enc = new Encryptor();
- String certFileNameFullPath =
- SparkyConstants.CONFIG_AUTH_LOCATION + restEndpointConfig.getCertFileName();
- String decryptedCertPassword = enc.decryptValue(restEndpointConfig.getCertPassword());
- String truststoreFileNameFullPath =
- SparkyConstants.CONFIG_AUTH_LOCATION + restEndpointConfig.getTruststoreFileName();
-
- return new RestClient() //
- .authenticationMode(restEndpointConfig.getRestAuthenticationMode()) //
- .validateServerCertChain(restEndpointConfig.isValidateServerCertChain()) //
- .validateServerHostname(restEndpointConfig.isValidateServerHostname()) //
- .clientCertFile(certFileNameFullPath) //
- .clientCertPassword(decryptedCertPassword) //
- .trustStore(truststoreFileNameFullPath) //
- .connectTimeoutMs(restEndpointConfig.getConnectTimeoutInMs()) //
- .readTimeoutMs(restEndpointConfig.getReadTimeoutInMs());
- }
-
- case SSL_BASIC: {
-
- return new RestClient() //
- .authenticationMode(restEndpointConfig.getRestAuthenticationMode()) //
- .basicAuthUsername(restEndpointConfig.getBasicAuthUserName()) //
- .basicAuthPassword(restEndpointConfig.getBasicAuthPassword()) //
- .connectTimeoutMs(restEndpointConfig.getConnectTimeoutInMs()) //
- .readTimeoutMs(restEndpointConfig.getReadTimeoutInMs());
-
- }
-
- case HTTP_NOAUTH:
- case UNKNOWN_MODE:
- default: {
-
- return new RestClient() //
- .authenticationMode(restEndpointConfig.getRestAuthenticationMode()) //
- .connectTimeoutMs(restEndpointConfig.getConnectTimeoutInMs()) //
- .readTimeoutMs(restEndpointConfig.getReadTimeoutInMs());
-
- }
-
-
- }
-
- }
-
-}
diff --git a/src/main/java/org/onap/aai/sparky/dal/rest/RestOperationalStatistics.java b/src/main/java/org/onap/aai/sparky/dal/rest/RestOperationalStatistics.java
deleted file mode 100644
index 606c279..0000000
--- a/src/main/java/org/onap/aai/sparky/dal/rest/RestOperationalStatistics.java
+++ /dev/null
@@ -1,251 +0,0 @@
-/**
- * ============LICENSE_START=======================================================
- * org.onap.aai
- * ================================================================================
- * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved.
- * Copyright © 2017-2018 Amdocs
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-package org.onap.aai.sparky.dal.rest;
-
-import org.onap.aai.sparky.analytics.AbstractStatistics;
-import org.onap.aai.sparky.dal.NetworkTransaction;
-
-/**
- * The Class RestOperationalStatistics.
- */
-public class RestOperationalStatistics extends AbstractStatistics {
-
- private static final String GET_1XX = "GET_1XX";
- private static final String GET_2XX = "GET_2XX";
- private static final String GET_3XX = "GET_3XX";
- private static final String GET_4XX = "GET_4XX";
- private static final String GET_5XX = "GET_5XX";
- private static final String GET_6XX = "GET_6XX";
-
- private static final String PUT_1XX = "PUT_1XX";
- private static final String PUT_2XX = "PUT_2XX";
- private static final String PUT_3XX = "PUT_3XX";
- private static final String PUT_4XX = "PUT_4XX";
- private static final String PUT_5XX = "PUT_5XX";
- private static final String PUT_6XX = "PUT_6XX";
-
- private static final String POST_1XX = "POST_1XX";
- private static final String POST_2XX = "POST_2XX";
- private static final String POST_3XX = "POST_3XX";
- private static final String POST_4XX = "POST_4XX";
- private static final String POST_5XX = "POST_5XX";
- private static final String POST_6XX = "POST_6XX";
-
- private static final String DELETE_1XX = "DELETE_1XX";
- private static final String DELETE_2XX = "DELETE_2XX";
- private static final String DELETE_3XX = "DELETE_3XX";
- private static final String DELETE_4XX = "DELETE_4XX";
- private static final String DELETE_5XX = "DELETE_5XX";
- private static final String DELETE_6XX = "DELETE_6XX";
-
- /**
- * Creates the counters.
- */
- private void createCounters() {
-
- addCounter(GET_1XX);
- addCounter(GET_2XX);
- addCounter(GET_3XX);
- addCounter(GET_4XX);
- addCounter(GET_5XX);
- addCounter(GET_6XX);
-
- addCounter(PUT_1XX);
- addCounter(PUT_2XX);
- addCounter(PUT_3XX);
- addCounter(PUT_4XX);
- addCounter(PUT_5XX);
- addCounter(PUT_6XX);
-
- addCounter(POST_1XX);
- addCounter(POST_2XX);
- addCounter(POST_3XX);
- addCounter(POST_4XX);
- addCounter(POST_5XX);
- addCounter(POST_6XX);
-
- addCounter(DELETE_1XX);
- addCounter(DELETE_2XX);
- addCounter(DELETE_3XX);
- addCounter(DELETE_4XX);
- addCounter(DELETE_5XX);
- addCounter(DELETE_6XX);
-
-
- }
-
- /**
- * Gets the result code.
- *
- * @param txn the txn
- * @return the result code
- */
- private int getResultCode(NetworkTransaction txn) {
-
- if (txn == null) {
- return -1;
- }
-
- if (txn.getOperationResult() == null) {
- return -1;
- }
-
- return txn.getOperationResult().getResultCode();
-
- }
-
- /**
- * Update counters.
- *
- * @param txn the txn
- */
- public void updateCounters(NetworkTransaction txn) {
-
- if (txn == null) {
- return;
- }
-
- int rc = getResultCode(txn);
-
- switch (txn.getOperationType()) {
-
- case GET: {
-
- if (100 <= rc && rc <= 199) {
- pegCounter(GET_1XX);
- } else if (200 <= rc && rc <= 299) {
- pegCounter(GET_2XX);
- } else if (300 <= rc && rc <= 399) {
- pegCounter(GET_3XX);
- } else if (400 <= rc && rc <= 499) {
- pegCounter(GET_4XX);
- } else if (500 <= rc && rc <= 599) {
- pegCounter(GET_5XX);
- } else if (600 <= rc && rc <= 699) {
- pegCounter(GET_6XX);
- }
-
- break;
- }
-
- case PUT: {
-
- if (100 <= rc && rc <= 199) {
- pegCounter(PUT_1XX);
- } else if (200 <= rc && rc <= 299) {
- pegCounter(PUT_2XX);
- } else if (300 <= rc && rc <= 399) {
- pegCounter(PUT_3XX);
- } else if (400 <= rc && rc <= 499) {
- pegCounter(PUT_4XX);
- } else if (500 <= rc && rc <= 599) {
- pegCounter(PUT_5XX);
- } else if (600 <= rc && rc <= 699) {
- pegCounter(PUT_6XX);
- }
-
- break;
- }
-
- case POST: {
-
- if (100 <= rc && rc <= 199) {
- pegCounter(POST_1XX);
- } else if (200 <= rc && rc <= 299) {
- pegCounter(POST_2XX);
- } else if (300 <= rc && rc <= 399) {
- pegCounter(POST_3XX);
- } else if (400 <= rc && rc <= 499) {
- pegCounter(POST_4XX);
- } else if (500 <= rc && rc <= 599) {
- pegCounter(POST_5XX);
- } else if (600 <= rc && rc <= 699) {
- pegCounter(POST_6XX);
- }
-
- break;
- }
-
- case DELETE: {
-
- if (100 <= rc && rc <= 199) {
- pegCounter(DELETE_1XX);
- } else if (200 <= rc && rc <= 299) {
- pegCounter(DELETE_2XX);
- } else if (300 <= rc && rc <= 399) {
- pegCounter(DELETE_3XX);
- } else if (400 <= rc && rc <= 499) {
- pegCounter(DELETE_4XX);
- } else if (500 <= rc && rc <= 599) {
- pegCounter(DELETE_5XX);
- } else if (600 <= rc && rc <= 699) {
- pegCounter(DELETE_6XX);
- }
-
- break;
- }
-
- default: {
- // not expecting anything else yet
- }
-
- }
-
- }
-
- /**
- * Instantiates a new rest operational statistics.
- */
- public RestOperationalStatistics() {
- createCounters();
- }
-
- public String getStatisticsReport() {
-
- StringBuilder sb = new StringBuilder(128);
-
- sb.append("\n ")
- .append(String.format(
- "%-12s 1XX: %-12d 2XX: %-12d 3XX: %-12d 4XX: %-12d 5XX: %-12d 6XX: %-12d ",
- HttpMethod.DELETE, getCounterValue(DELETE_1XX), getCounterValue(DELETE_2XX),
- getCounterValue(DELETE_3XX), getCounterValue(DELETE_4XX), getCounterValue(DELETE_5XX),
- getCounterValue(DELETE_6XX)));
-
- sb.append("\n ").append(String.format(
- "%-12s 1XX: %-12d 2XX: %-12d 3XX: %-12d 4XX: %-12d 5XX: %-12d 6XX: %-12d ", HttpMethod.PUT,
- getCounterValue(PUT_1XX), getCounterValue(PUT_2XX), getCounterValue(PUT_3XX),
- getCounterValue(PUT_4XX), getCounterValue(PUT_5XX), getCounterValue(PUT_6XX)));
-
- sb.append("\n ").append(String.format(
- "%-12s 1XX: %-12d 2XX: %-12d 3XX: %-12d 4XX: %-12d 5XX: %-12d 6XX: %-12d ", HttpMethod.POST,
- getCounterValue(POST_1XX), getCounterValue(POST_2XX), getCounterValue(POST_3XX),
- getCounterValue(POST_4XX), getCounterValue(POST_5XX), getCounterValue(POST_6XX)));
-
- sb.append("\n ").append(String.format(
- "%-12s 1XX: %-12d 2XX: %-12d 3XX: %-12d 4XX: %-12d 5XX: %-12d 6XX: %-12d ", HttpMethod.GET,
- getCounterValue(GET_1XX), getCounterValue(GET_2XX), getCounterValue(GET_3XX),
- getCounterValue(GET_4XX), getCounterValue(GET_5XX), getCounterValue(GET_6XX)));
-
- return sb.toString();
- }
-
-
-}
diff --git a/src/main/java/org/onap/aai/sparky/dal/rest/config/RestEndpointConfig.java b/src/main/java/org/onap/aai/sparky/dal/rest/config/RestEndpointConfig.java
deleted file mode 100644
index d30e5e7..0000000
--- a/src/main/java/org/onap/aai/sparky/dal/rest/config/RestEndpointConfig.java
+++ /dev/null
@@ -1,165 +0,0 @@
-/**
- * ============LICENSE_START=======================================================
- * org.onap.aai
- * ================================================================================
- * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved.
- * Copyright © 2017-2018 Amdocs
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-package org.onap.aai.sparky.dal.rest.config;
-
-import org.onap.aai.restclient.enums.RestAuthenticationMode;
-
-public class RestEndpointConfig {
-
- private String endpointIpAddress;
- private String endpointServerPort;
- private int numRequestRetries;
- private String basicAuthUserName;
- private String basicAuthPassword;
- private RestAuthenticationMode restAuthenticationMode;
- private int connectTimeoutInMs;
- private int readTimeoutInMs;
- private String certFileName;
- private String certPassword;
- private String truststoreFileName;
- private boolean validateServerCertChain;
- private boolean validateServerHostname;
-
- public boolean isValidateServerCertChain() {
- return validateServerCertChain;
- }
-
- public void setValidateServerCertChain(boolean validateServerCertChain) {
- this.validateServerCertChain = validateServerCertChain;
- }
-
- public boolean isValidateServerHostname() {
- return validateServerHostname;
- }
-
- public void setValidateServerHostname(boolean validateServerHostname) {
- this.validateServerHostname = validateServerHostname;
- }
-
- public String getEndpointIpAddress() {
- return endpointIpAddress;
- }
-
- public void setEndpointIpAddress(String endpointIpAddress) {
- this.endpointIpAddress = endpointIpAddress;
- }
-
- public String getEndpointServerPort() {
- return endpointServerPort;
- }
-
- public void setEndpointServerPort(String endpointServerPort) {
- this.endpointServerPort = endpointServerPort;
- }
-
- public int getNumRequestRetries() {
- return numRequestRetries;
- }
-
- public void setNumRequestRetries(int numRequestRetries) {
- this.numRequestRetries = numRequestRetries;
- }
-
- public String getBasicAuthUserName() {
- return basicAuthUserName;
- }
-
- public void setBasicAuthUserName(String basicAuthUserName) {
- this.basicAuthUserName = basicAuthUserName;
- }
-
- public String getBasicAuthPassword() {
- return basicAuthPassword;
- }
-
- public void setBasicAuthPassword(String basicAuthPassword) {
- this.basicAuthPassword = basicAuthPassword;
- }
-
- public RestAuthenticationMode getRestAuthenticationMode() {
- return restAuthenticationMode;
- }
-
- public void setRestAuthenticationMode(RestAuthenticationMode restAuthenticationMode) {
- this.restAuthenticationMode = restAuthenticationMode;
- }
-
- public int getConnectTimeoutInMs() {
- return connectTimeoutInMs;
- }
-
- public void setConnectTimeoutInMs(int connectTimeoutInMs) {
- this.connectTimeoutInMs = connectTimeoutInMs;
- }
-
- public int getReadTimeoutInMs() {
- return readTimeoutInMs;
- }
-
- public void setReadTimeoutInMs(int readTimeoutInMs) {
- this.readTimeoutInMs = readTimeoutInMs;
- }
-
- public String getCertFileName() {
- return certFileName;
- }
-
- public void setCertFileName(String certFileName) {
- this.certFileName = certFileName;
- }
-
- public String getCertPassword() {
- return certPassword;
- }
-
- public void setCertPassword(String certPassword) {
- this.certPassword = certPassword;
- }
-
- public String getTruststoreFileName() {
- return truststoreFileName;
- }
-
- public void setTruststoreFileName(String truststoreFileName) {
- this.truststoreFileName = truststoreFileName;
- }
-
- @Override
- public String toString() {
- return "RestEndpointConfig ["
- + (endpointIpAddress != null ? "endpointIpAddress=" + endpointIpAddress + ", " : "")
- + (endpointServerPort != null ? "endpointServerPort=" + endpointServerPort + ", " : "")
- + "numRequestRetries=" + numRequestRetries + ", "
- + (basicAuthUserName != null ? "basicAuthUserName=" + basicAuthUserName + ", " : "")
- + (basicAuthPassword != null ? "basicAuthPassword=" + basicAuthPassword + ", " : "")
- + (restAuthenticationMode != null
- ? "restAuthenticationMode=" + restAuthenticationMode + ", " : "")
- + "connectTimeoutInMs=" + connectTimeoutInMs + ", readTimeoutInMs=" + readTimeoutInMs + ", "
- + (certFileName != null ? "certFileName=" + certFileName + ", " : "")
- + (certPassword != null ? "certPassword=" + certPassword + ", " : "")
- + (truststoreFileName != null ? "truststoreFileName=" + truststoreFileName + ", " : "")
- + "validateServerCertChain=" + validateServerCertChain + ", validateServerHostname="
- + validateServerHostname + "]";
- }
-
-
-
-}
diff --git a/src/main/java/org/onap/aai/sparky/dal/sas/config/SearchServiceConfig.java b/src/main/java/org/onap/aai/sparky/dal/sas/config/SearchServiceConfig.java
deleted file mode 100644
index 299fc96..0000000
--- a/src/main/java/org/onap/aai/sparky/dal/sas/config/SearchServiceConfig.java
+++ /dev/null
@@ -1,219 +0,0 @@
-/**
- * ============LICENSE_START=======================================================
- * org.onap.aai
- * ================================================================================
- * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved.
- * Copyright © 2017-2018 Amdocs
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-package org.onap.aai.sparky.dal.sas.config;
-
-import java.util.Properties;
-
-import org.onap.aai.sparky.util.ConfigHelper;
-import org.onap.aai.sparky.viewandinspect.config.SparkyConstants;
-
-/**
- * The Class ElasticSearchConfig.
- */
-public class SearchServiceConfig {
-
- public static final String CONFIG_FILE =
- SparkyConstants.DYNAMIC_CONFIG_APP_LOCATION + "search-service.properties";
-
- private static SearchServiceConfig instance;
-
- private String ipAddress;
-
- private String httpPort;
-
- private String indexName;
-
- private String auditIndexName;
-
- private String topographicalSearchIndex;
-
- private String entityCountHistoryIndex;
-
- private String version;
-
- private String type;
-
- private String certName;
-
- private String keystorePassword;
-
- private String keystore;
-
- private static final String IP_ADDRESS_DEFAULT = "localhost";
-
- private static final String HTTP_PORT_DEFAULT = "9509";
-
- private static final String INDEX_NAME_DEFAULT = "entitySearchIndex-localhost";
-
- private static final String AUDIT_INDEX_NAME_DEFAULT = "di-violations";
-
- private static final String TOPOGRAPHICAL_INDEX_NAME_DEFAULT =
- "topographicalsearchindex-localhost";
-
- private static final String ENTITY_COUNT_HISTORY_INDEX_NAME_DEFAULT =
- "entitycounthistoryindex-localhost";
-
- private static final String VERSION_DEFAULT = "v1";
-
- public static SearchServiceConfig getConfig() throws Exception {
-
- if (instance == null) {
- instance = new SearchServiceConfig();
- instance.initializeProperties();
- }
-
- return instance;
- }
-
- public static void setConfig(SearchServiceConfig config) {
- SearchServiceConfig.instance = config;
- }
-
- /**
- * Instantiates a new search service config.
- */
- public SearchServiceConfig() {
- // test method
- }
-
- /**
- * Initialize properties.
- */
- private void initializeProperties() {
- Properties props = ConfigHelper.loadConfigFromExplicitPath(CONFIG_FILE);
-
- Properties sasProps = ConfigHelper.getConfigWithPrefix("search-service", props);
-
- ipAddress = sasProps.getProperty("ipAddress", IP_ADDRESS_DEFAULT);
- httpPort = sasProps.getProperty("httpPort", "" + HTTP_PORT_DEFAULT);
- version = sasProps.getProperty("version", "" + VERSION_DEFAULT);
- indexName = sasProps.getProperty("indexName", INDEX_NAME_DEFAULT);
- auditIndexName = sasProps.getProperty("auditIndexName", AUDIT_INDEX_NAME_DEFAULT);
- topographicalSearchIndex = sasProps.getProperty("topographicalIndexName",
- TOPOGRAPHICAL_INDEX_NAME_DEFAULT);
- entityCountHistoryIndex = sasProps.getProperty("entityCountHistoryIndexName",
- ENTITY_COUNT_HISTORY_INDEX_NAME_DEFAULT);
- certName =
- sasProps.getProperty("ssl.cert-name", "aai-client-cert.p12");
- keystorePassword = sasProps.getProperty("ssl.keystore-password",
- "OBF:1i9a1u2a1unz1lr61wn51wn11lss1unz1u301i6o");
- keystore = sasProps.getProperty("ssl.keystore", "tomcat_keystore");
- }
-
- public String getIpAddress() {
- return ipAddress;
- }
-
- public void setIpAddress(String ipAddress) {
- this.ipAddress = ipAddress;
- }
-
- public String getHttpPort() {
- return httpPort;
- }
-
- public void setHttpPort(String httpPort) {
- this.httpPort = httpPort;
- }
-
- public String getIndexName() {
- return indexName;
- }
-
- public void setIndexName(String indexName) {
- this.indexName = indexName;
- }
-
- public String getVersion() {
- return version;
- }
-
- public void setVersion(String version) {
- this.version = version;
- }
-
- public String getAuditIndexName() {
- return auditIndexName;
- }
-
- public void setAuditIndexName(String auditIndexName) {
- this.auditIndexName = auditIndexName;
- }
-
- public String getTopographicalSearchIndex() {
- return topographicalSearchIndex;
- }
-
- public void setTopographicalSearchIndex(String topographicalSearchIndex) {
- this.topographicalSearchIndex = topographicalSearchIndex;
- }
-
- public String getEntityCountHistoryIndex() {
- return entityCountHistoryIndex;
- }
-
- public void setEntityCountHistoryIndex(String entityCountHistoryIndex) {
- this.entityCountHistoryIndex = entityCountHistoryIndex;
- }
-
- public String getType() {
- return type;
- }
-
- public void setType(String type) {
- this.type = type;
- }
-
-
- public String getCertName() {
- return certName;
- }
-
- public void setCertName(String certName) {
- this.certName = certName;
- }
-
- public String getKeystorePassword() {
- return keystorePassword;
- }
-
- public void setKeystorePassword(String keystorePassword) {
- this.keystorePassword = keystorePassword;
- }
-
- public String getKeystore() {
- return keystore;
- }
-
- public void setKeystore(String keystore) {
- this.keystore = keystore;
- }
-
- @Override
- public String toString() {
- return "SearchServiceConfig [ipAddress=" + ipAddress + ", httpPort=" + httpPort + ", indexName="
- + indexName + ", auditIndexName=" + auditIndexName + ", topographicalSearchIndex="
- + topographicalSearchIndex + ", entityCountHistoryIndex=" + entityCountHistoryIndex
- + ", version=" + version + ", type=" + type + "]";
- }
-
-
-}
diff --git a/src/main/java/org/onap/aai/sparky/editattributes/AttributeEditProcessor.java b/src/main/java/org/onap/aai/sparky/editattributes/AttributeEditProcessor.java
deleted file mode 100644
index fbdbb94..0000000
--- a/src/main/java/org/onap/aai/sparky/editattributes/AttributeEditProcessor.java
+++ /dev/null
@@ -1,178 +0,0 @@
-/**
- * ============LICENSE_START=======================================================
- * org.onap.aai
- * ================================================================================
- * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved.
- * Copyright © 2017-2018 Amdocs
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-package org.onap.aai.sparky.editattributes;
-
-import java.io.UnsupportedEncodingException;
-import java.util.Map;
-
-import org.apache.camel.Exchange;
-import org.apache.camel.component.restlet.RestletConstants;
-import org.onap.aai.cl.api.Logger;
-import org.onap.aai.cl.eelf.LoggerFactory;
-import org.onap.aai.cl.mdc.MdcContext;
-import org.onap.aai.restclient.client.OperationResult;
-import org.onap.aai.sparky.editattributes.entity.EditRequest;
-import org.onap.aai.sparky.logging.AaiUiMsgs;
-import org.onap.aai.sparky.util.NodeUtils;
-import org.restlet.Request;
-import org.restlet.Response;
-import org.restlet.data.ClientInfo;
-import org.restlet.data.Cookie;
-import org.restlet.data.MediaType;
-import org.restlet.data.Status;
-import org.restlet.util.Series;
-
-import com.fasterxml.jackson.annotation.JsonInclude.Include;
-import com.fasterxml.jackson.databind.ObjectMapper;
-
-/**
- * The Class AttributeEditProcessor.
- */
-public class AttributeEditProcessor {
-
- private static final Logger LOG =
- LoggerFactory.getInstance().getLogger(AttributeEditProcessor.class);
-
- private ObjectMapper mapper;
- private AttributeUpdater attrUpdater;
-
- public AttributeEditProcessor(AttributeUpdater attributeUpdater) {
- this.attrUpdater = attributeUpdater;
-
- this.mapper = new ObjectMapper();
- mapper.setSerializationInclusion(Include.NON_EMPTY);
- }
-
- public void editAttribute(Exchange exchange) {
-
- Object xTransactionId = exchange.getIn().getHeader("X-TransactionId");
-
- if (xTransactionId == null) {
- xTransactionId = NodeUtils.getRandomTxnId();
- }
-
- Object partnerName = exchange.getIn().getHeader("X-FromAppId");
- if (partnerName == null) {
- partnerName = "Browser";
- }
-
- Request request = exchange.getIn().getHeader(RestletConstants.RESTLET_REQUEST, Request.class);
-
- /*
- * Disables automatic Apache Camel Restlet component logging which prints out an undesirable log
- * entry which includes client (e.g. browser) information
- */
- request.setLoggable(false);
-
- ClientInfo clientInfo = request.getClientInfo();
- MdcContext.initialize((String) xTransactionId, "AAI-UI", "", (String) partnerName,
- clientInfo.getAddress() + ":" + clientInfo.getPort());
-
- String payload = exchange.getIn().getBody(String.class);
- EditRequest editRequest = null;
- OperationResult operationResult = new OperationResult();
-
- Response response = exchange.getIn().getHeader(RestletConstants.RESTLET_RESPONSE, Response.class);
- response.setStatus(Status.SUCCESS_OK); // 200 is assumed unless an actual exception occurs (a failure is still a valid response)
-
- boolean wasErrorDuringProcessing = false;
- String errorMessage = null;
-
-
- try {
-
- if (payload != null && !payload.isEmpty()) {
- editRequest = mapper.readValue(payload, EditRequest.class);
-
- if (editRequest != null) {
-
- String attUid = getAttUid(request.getCookies());
- String objectUri = editRequest.getEntityUri();
- Map attributeValues = editRequest.getAttributes();
-
- if (attUid != null && !attUid.isEmpty() && objectUri != null && !objectUri.isEmpty()
- && attributeValues != null && !attributeValues.isEmpty()) {
-
- LOG.info(AaiUiMsgs.ATTRIBUTES_HANDLING_EDIT, objectUri, editRequest.toString());
-
- operationResult = attrUpdater.updateObjectAttribute(objectUri, attributeValues, attUid);
-
- boolean wasSuccess = (operationResult.getResultCode() == 200);
- String message = String.format("Edit Attributes completed with Result Code : %s (%s).",
- operationResult.getResultCode(), wasSuccess ? "success" : "failed");
-
- LOG.info(AaiUiMsgs.INFO_GENERIC, message);
- }
- }
- } else {
- wasErrorDuringProcessing = true;
- errorMessage = "Empty payload provided, need details to complete request";
- }
- } catch (Exception exc) {
- LOG.error(AaiUiMsgs.ATTRIBUTES_NOT_UPDATED_EXCEPTION, exc.getLocalizedMessage());
- operationResult.setResult(500, "Error encountered while trying to update attributes.");
- response.setStatus(Status.SERVER_ERROR_INTERNAL);
- }
-
- if(wasErrorDuringProcessing) {
- LOG.error(AaiUiMsgs.ATTRIBUTES_NOT_UPDATED_MESSAGE, errorMessage);
- }
-
- response.setEntity(operationResult.getResult(), MediaType.APPLICATION_JSON);
- exchange.getOut().setBody(response);
- }
-
- /**
- * Gets the att uid.
- *
- * @param request the request
- * @return the att uid
- * @throws UnsupportedEncodingException the unsupported encoding exception
- */
- public String getAttUid(Series cookies) throws UnsupportedEncodingException {
- String attId = "";
- if (cookies == null) {
- LOG.error(AaiUiMsgs.COOKIE_NOT_FOUND);
- return attId;
- }
- for (Cookie cookie : cookies) {
- if (cookie.getName().equals("attESHr")) {
- // This cookie is of the form :
- // "FIRSTNAME|LASTNAME|emailname@domain.com|||ab1234||fl6789,RBFMSKQ,"
- // + "Z9V2298,9762186|YNNNNNNNNNNNNNYNNYYNNNNN|FIRSTNAME|EY6SC9000|"
- // we are to extract fl6789 from this which would be the attuid for the user.
- String value = cookie.getValue();
- value = java.net.URLDecoder.decode(value, "UTF-8");
- LOG.info(AaiUiMsgs.COOKIE_FOUND, value);
- String[] values = value.split("\\|");
- if (values.length > 7) {
- attId = (values[7].split(","))[0];
-
- String initials = (values[0].substring(0, 1) + values[1].substring(0, 1)).toLowerCase();
- if (attId.startsWith(initials)) {
- return attId;
- }
- }
- }
- }
- return attId;
- }
-}
diff --git a/src/main/java/org/onap/aai/sparky/editattributes/AttributeUpdater.java b/src/main/java/org/onap/aai/sparky/editattributes/AttributeUpdater.java
deleted file mode 100644
index 79b5466..0000000
--- a/src/main/java/org/onap/aai/sparky/editattributes/AttributeUpdater.java
+++ /dev/null
@@ -1,358 +0,0 @@
-/**
- * ============LICENSE_START=======================================================
- * org.onap.aai
- * ================================================================================
- * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved.
- * Copyright © 2017-2018 Amdocs
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-package org.onap.aai.sparky.editattributes;
-
-import java.net.URI;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
-
-import javax.ws.rs.core.UriBuilder;
-
-import org.eclipse.persistence.dynamic.DynamicType;
-import org.onap.aai.cl.api.Logger;
-import org.onap.aai.cl.eelf.LoggerFactory;
-import org.onap.aai.restclient.client.OperationResult;
-import org.onap.aai.sparky.config.oxm.OxmEntityLookup;
-import org.onap.aai.sparky.config.oxm.OxmModelLoader;
-import org.onap.aai.sparky.dal.ActiveInventoryAdapter;
-import org.onap.aai.sparky.editattributes.exception.AttributeUpdateException;
-import org.onap.aai.sparky.logging.AaiUiMsgs;
-
-import com.fasterxml.jackson.core.JsonProcessingException;
-import com.fasterxml.jackson.databind.ObjectMapper;
-import com.fasterxml.jackson.databind.ObjectWriter;
-import com.fasterxml.jackson.databind.PropertyNamingStrategy;
-
-/**
- * Class to process attribute updates on AAI objects.
- *
- *
- */
-public class AttributeUpdater {
-
- /**
- * The Class AaiEditObject.
- */
- public class AaiEditObject {
- String objectType;
- String rootElement;
- String keyName;
- String keyValue;
- String schemaVersion;
-
- /**
- * Instantiates a new aai edit object.
- */
- public AaiEditObject() {
-
- }
-
- /**
- * Instantiates a new aai edit object.
- *
- * @param objectType the object type
- * @param idName the id name
- * @param schemaVersion the schema version
- */
- public AaiEditObject(String objectType, String idName, String schemaVersion) {
- super();
- this.objectType = objectType;
- this.keyName = idName;
- this.schemaVersion = schemaVersion;
- }
-
- public String getObjectType() {
- return objectType;
- }
-
- public void setObjectType(String objectType) {
- this.objectType = objectType;
- }
-
- public String getKeyName() {
- return keyName;
- }
-
- public void setKeyName(String idName) {
- this.keyName = idName;
- }
-
- public String getSchemaVersion() {
- return schemaVersion;
- }
-
- public void setSchemaVersion(String schemaVersion) {
- this.schemaVersion = schemaVersion;
- }
-
- public void setKeyValue(String keyValue) {
- this.keyValue = keyValue;
- }
-
- public String getKeyValue() {
- return keyValue;
- }
-
- public String getRootElement() {
- return rootElement;
- }
-
- public void setRootElement(String rootElement) {
- this.rootElement = rootElement;
- }
-
- }
-
- private static final Logger LOG = LoggerFactory.getInstance().getLogger(AttributeUpdater.class);
- private static final String MESSAGE_VERSION_EXTRACTION_REGEX = "\\/(v[0-9]+)";
- private static final String ATTRIBUTES_UPDATED_SUCCESSFULLY = "Attributes updated successfully";
- private static final String ATTRIBUTES_NOT_UPDATED = "Attributes not updated. ";
-
- private ActiveInventoryAdapter aaiAdapter;
- private UserValidator validator;
- private OxmModelLoader oxmModelLoader;
- private OxmEntityLookup oxmEntityLookup;
-
- /**
- * Instantiates a new attribute updater.
- * @throws AttributeUpdateException
- */
- public AttributeUpdater(OxmModelLoader oxmModelLoader, OxmEntityLookup oxmEntityLookup, ActiveInventoryAdapter activeInventoryAdapter) throws AttributeUpdateException {
- super();
- this.oxmModelLoader = oxmModelLoader;
- this.oxmEntityLookup = oxmEntityLookup;
- this.aaiAdapter = activeInventoryAdapter;
-
- try {
- this.validator = new UserValidator();
- } catch (Exception exc) {
- LOG.error(AaiUiMsgs.ATTRIBUTES_ERROR_GETTING_AAI_CONFIG_OR_ADAPTER, exc.getLocalizedMessage());
- throw new AttributeUpdateException(exc);
- }
- }
-
- protected String getResourceBasePath() {
-
- String versionStr = null;
- if (oxmModelLoader != null) {
- versionStr = String.valueOf(oxmModelLoader.getLatestVersionNum());
- }
-
- return "/aai/v" + versionStr;
-
- }
-
- protected URI getBaseUri() {
- return UriBuilder
- .fromUri("https://" + aaiAdapter.getEndpointConfig().getEndpointIpAddress() + ":"
- + aaiAdapter.getEndpointConfig().getEndpointServerPort() + getResourceBasePath())
- .build();
- }
-
- /**
- * Update object attribute.
- *
- * @param objectUri - Valid URI of the object as per OXM model.
- * @param attributeValues - Map of (attribute-name & attribute-value) for
- * any attributes to be updated to the value.
- * @param attUid - ATTUID of the user requesting the update.
- * @return - OperationResult with success or failure reason.
- */
- public OperationResult updateObjectAttribute(String objectUri, Map attributeValues, String attUid) {
- OperationResult result = new OperationResult();
- LOG.info(AaiUiMsgs.ATTRIBUTES_UPDATE_METHOD_CALLED, objectUri, attUid, String.valueOf(attributeValues));
- if (!validator.isAuthorizedUser(attUid)) {
- result.setResultCode(403);
- result.setResult(String.format("User %s is not authorized for Attributes update ", attUid));
- LOG.error(AaiUiMsgs.ATTRIBUTES_USER_NOT_AUTHORIZED_TO_UPDATE, attUid);
- return result;
- }
-
- AaiEditObject object = null;
-
- try {
- object = getEditObjectFromUri(objectUri);
- } catch (AttributeUpdateException exc) {
- result.setResultCode(400);
- result.setResult(ATTRIBUTES_NOT_UPDATED);
- LOG.error(AaiUiMsgs.ATTRIBUTES_NOT_UPDATED_EXCEPTION, exc.getLocalizedMessage());
- return result;
- }
- try {
- String jsonPayload = convertEditRequestToJson(object, attributeValues);
- String patchUri = getBaseUri().toString() + getRelativeUri(objectUri);
-
-
- /*
- * FIX ME: Dave Adams, 8-Nov-2017
- */
-
- //result = aaiAdapter.doPatch(patchUri, jsonPayload, MediaType.APPLICATION_JSON);
-
- result = new OperationResult();
- result.setResultCode(404);
-
- if (result.getResultCode() == 200) {
- result.setResult(ATTRIBUTES_UPDATED_SUCCESSFULLY);
- String message = result.getResult() + " for " + objectUri;
- LOG.info(AaiUiMsgs.INFO_GENERIC, message);
- } else {
- String message = ATTRIBUTES_NOT_UPDATED + " For: " + objectUri + ". AAI PATCH Status Code : "
- + result.getResultCode() + ". Error : " + result.getResult();
- LOG.error(AaiUiMsgs.ATTRIBUTES_NOT_UPDATED_MESSAGE, message);
- }
- } catch (AttributeUpdateException exc) {
- result.setResultCode(500);
- result.setResult(ATTRIBUTES_NOT_UPDATED + exc.getLocalizedMessage());
- LOG.error(AaiUiMsgs.ATTRIBUTES_NOT_UPDATED_EXCEPTION, exc.getLocalizedMessage());
- }
- return result;
-
- }
-
- /**
- * Gets the relative uri.
- *
- * @param objectUri the object uri
- * @return the relative uri
- */
- public String getRelativeUri(String objectUri) {
- String tempUri = objectUri;
- final Pattern pattern = Pattern.compile(MESSAGE_VERSION_EXTRACTION_REGEX, Pattern.DOTALL);
- Matcher matcher = pattern.matcher(objectUri);
- while (matcher.find()) {
- tempUri = objectUri.substring(matcher.end());
- }
- if (!tempUri.startsWith("/")) {
- tempUri = "/" + tempUri;
- }
- return tempUri;
- }
-
- /**
- * Gets the edits the object from uri.
- *
- * @param objectUri the object uri
- * @return the edits the object from uri
- * @throws AttributeUpdateException the attribute update exception
- */
- public AaiEditObject getEditObjectFromUri(String objectUri) throws AttributeUpdateException {
-
- AaiEditObject object = new AaiEditObject();
- String version = getVersionFromUri(objectUri);
-
- if ( null == version ) {
- version = "v" + String.valueOf(oxmModelLoader.getLatestVersionNum());
- }
- object.setSchemaVersion(version);
-
- String[] values = objectUri.split("/");
- if (values.length < 2) {
- throw new AttributeUpdateException("Invalid or malformed object URI : " + objectUri);
- }
- String keyValue = values[values.length - 1];
- String rootElement = values[values.length - 2];
-
- object.setKeyValue(keyValue);
- object.setRootElement(rootElement);
-
- String objectJavaType = null;
- Map entityTypeLookup = oxmEntityLookup.getEntityTypeLookup();
- DynamicType entity = entityTypeLookup.get(rootElement);
- if ( null != entity ) {
- objectJavaType = entity.getName();
- String message = "Descriptor: Alias: " + objectJavaType + " : DefaultRootElement: "
- + rootElement;
- LOG.debug(AaiUiMsgs.DEBUG_GENERIC, message);
- }
-
-
- if (objectJavaType == null) {
- throw new AttributeUpdateException(
- "Object type could not be determined from the URI : " + objectUri);
- }
- object.setObjectType(objectJavaType);
-
- // Set key attribute name
- final List primaryKeys = entity.getDescriptor().getPrimaryKeyFieldNames();
-
- if (primaryKeys.isEmpty()) {
- throw new AttributeUpdateException("Object primary key not found in OXM version " + version);
- }
-
- for (int i = 0; i < primaryKeys.size(); i++) {
- final String primaryKey = primaryKeys.get(i);
- if (primaryKey.indexOf("/text()") != -1) {
- primaryKeys.set(i, primaryKey.replace("/text()", ""));
- }
- }
- object.setKeyName(primaryKeys.iterator().next());
-
- return object;
- }
-
- /**
- * Gets the version from uri.
- *
- * @param objectUri the object uri
- * @return the version from uri
- * @throws AttributeUpdateException the attribute update exception
- */
- private String getVersionFromUri(String objectUri) throws AttributeUpdateException {
- final Pattern pattern = Pattern.compile(MESSAGE_VERSION_EXTRACTION_REGEX, Pattern.DOTALL);
- Matcher matcher = pattern.matcher(objectUri);
- String messageSchemaVersion = null;
- while (matcher.find()) {
- messageSchemaVersion = matcher.group(1);
- break;
- }
- return messageSchemaVersion;
- }
-
- /**
- * Convert edit request to json.
- *
- * @param object the object
- * @param attributeValues the attribute values
- * @return the string
- * @throws AttributeUpdateException the attribute update exception
- */
- private static String convertEditRequestToJson(AaiEditObject object,
- Map attributeValues) throws AttributeUpdateException {
-
- ObjectMapper mapper = new ObjectMapper();
- mapper.setPropertyNamingStrategy(new PropertyNamingStrategy.KebabCaseStrategy());
- ObjectWriter ow = mapper.writer();
-
- Map patchAttributes = new HashMap<>();
- patchAttributes.put(object.getKeyName(), object.getKeyValue());
- patchAttributes.putAll(attributeValues);
-
- try {
- return ow.writeValueAsString(patchAttributes);
- } catch (JsonProcessingException exc) {
- throw new AttributeUpdateException("Caught a JPE while creating PATCH request body = ", exc);
- }
- }
-}
diff --git a/src/main/java/org/onap/aai/sparky/editattributes/UserAuthorizationReader.java b/src/main/java/org/onap/aai/sparky/editattributes/UserAuthorizationReader.java
deleted file mode 100644
index 170ed5f..0000000
--- a/src/main/java/org/onap/aai/sparky/editattributes/UserAuthorizationReader.java
+++ /dev/null
@@ -1,75 +0,0 @@
-/**
- * ============LICENSE_START=======================================================
- * org.onap.aai
- * ================================================================================
- * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved.
- * Copyright © 2017-2018 Amdocs
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-package org.onap.aai.sparky.editattributes;
-
-import java.io.File;
-import java.io.IOException;
-import java.nio.file.Files;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.stream.Collectors;
-import java.util.stream.Stream;
-
-/**
- * Reads user IDs from a file. Each line in the user authorization file should contain a single user
- * ID. For example,
- *
- *
- * user1
- * user2
- *
- */
-public class UserAuthorizationReader {
-
- private File userAuthorizationFile;
-
- /**
- * Set the user authorization file.
- *
- * @param file a user authorization file
- */
- public UserAuthorizationReader(File file) {
- this.userAuthorizationFile = file;
- }
-
- /**
- * Gets user IDs from a file.
- *
- * @return a list of user IDs
- * @throws IOException if there is a problem reading the user configuration file
- */
- public List getUsers() throws IOException {
- List userList = new ArrayList<>();
- try (Stream stream = Files.lines(getUserAuthorizationFile().toPath())) {
- userList.addAll(stream.map(String::trim).collect(Collectors.toList()));
- }
- return userList;
- }
-
- // Getters and setters
- public File getUserAuthorizationFile() {
- return userAuthorizationFile;
- }
-
- public void setUserAuthorizationFile(File file) {
- this.userAuthorizationFile = file;
- }
-}
diff --git a/src/main/java/org/onap/aai/sparky/editattributes/UserValidator.java b/src/main/java/org/onap/aai/sparky/editattributes/UserValidator.java
deleted file mode 100644
index 83b3932..0000000
--- a/src/main/java/org/onap/aai/sparky/editattributes/UserValidator.java
+++ /dev/null
@@ -1,63 +0,0 @@
-/**
- * ============LICENSE_START=======================================================
- * org.onap.aai
- * ================================================================================
- * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved.
- * Copyright © 2017-2018 Amdocs
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-package org.onap.aai.sparky.editattributes;
-
-import java.io.File;
-import java.io.IOException;
-import java.util.List;
-
-import org.onap.aai.cl.api.Logger;
-import org.onap.aai.cl.eelf.LoggerFactory;
-import org.onap.aai.sparky.logging.AaiUiMsgs;
-import org.onap.aai.sparky.viewandinspect.config.SparkyConstants;
-
-/**
- * Validates users against a user authorization file.
- */
-public class UserValidator {
-
- private static final Logger LOG = LoggerFactory.getInstance().getLogger(UserValidator.class);
- private static final String USER_AUTH_FILE =
- SparkyConstants.AUTHORIZED_USERS_FILE_LOCATION;
-
- private UserAuthorizationReader userAuthorizationReader =
- new UserAuthorizationReader(new File(USER_AUTH_FILE));
-
- /**
- * Returns true if the user is authorized.
- *
- * @param userId a user identifier
- * @return true if the user ID is present in the user authorization file
- */
- public boolean isAuthorizedUser(String userId) {
- if (userId != null && !userId.isEmpty()) {
- try {
- List users = userAuthorizationReader.getUsers();
- return users.contains(userId);
- } catch (IOException exc) {
- LOG.error(AaiUiMsgs.USER_AUTHORIZATION_FILE_UNAVAILABLE, userId);
- return false;
- }
- } else {
- return false;
- }
- }
-}
diff --git a/src/main/java/org/onap/aai/sparky/editattributes/entity/EditRequest.java b/src/main/java/org/onap/aai/sparky/editattributes/entity/EditRequest.java
deleted file mode 100644
index eb34eab..0000000
--- a/src/main/java/org/onap/aai/sparky/editattributes/entity/EditRequest.java
+++ /dev/null
@@ -1,65 +0,0 @@
-/**
- * ============LICENSE_START=======================================================
- * org.onap.aai
- * ================================================================================
- * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved.
- * Copyright © 2017-2018 Amdocs
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-package org.onap.aai.sparky.editattributes.entity;
-
-import java.util.HashMap;
-import java.util.Map;
-
-import com.fasterxml.jackson.annotation.JsonProperty;
-
-/**
- * The Class EditRequest.
- */
-public class EditRequest {
-
- @JsonProperty("entity-uri")
- private String entityUri;
-
- @JsonProperty("entity-type")
- private String entityType;
-
- @JsonProperty("attributes")
- private Map attributes = new HashMap<>();
-
- public String getEntityUri() {
- return entityUri;
- }
-
- public void setEntityUri(String entityUri) {
- this.entityUri = entityUri;
- }
-
- public String getEntityType() {
- return entityType;
- }
-
- public void setEntityType(String entityType) {
- this.entityType = entityType;
- }
-
- public Map getAttributes() {
- return attributes;
- }
-
- public void setAttributes(Map attributes) {
- this.attributes = attributes;
- }
-}
diff --git a/src/main/java/org/onap/aai/sparky/editattributes/exception/AttributeUpdateException.java b/src/main/java/org/onap/aai/sparky/editattributes/exception/AttributeUpdateException.java
deleted file mode 100644
index 8ce56bd..0000000
--- a/src/main/java/org/onap/aai/sparky/editattributes/exception/AttributeUpdateException.java
+++ /dev/null
@@ -1,58 +0,0 @@
-/**
- * ============LICENSE_START=======================================================
- * org.onap.aai
- * ================================================================================
- * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved.
- * Copyright © 2017-2018 Amdocs
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-package org.onap.aai.sparky.editattributes.exception;
-
-/**
- * The Class AttributeUpdateException.
- */
-public class AttributeUpdateException extends Exception {
-
- private static final long serialVersionUID = 1L;
-
- /**
- * Attribute Edit specific Exception Class.
- *
- * @param exc the exc
- */
-
- public AttributeUpdateException(Exception exc) {
- super(exc);
- }
-
- /**
- * Instantiates a new attribute update exception.
- *
- * @param message the message
- */
- public AttributeUpdateException(String message) {
- super(message);
- }
-
- /**
- * Instantiates a new attribute update exception.
- *
- * @param message the message
- * @param exc the exc
- */
- public AttributeUpdateException(String message, Exception exc) {
- super(message, exc);
- }
-}
diff --git a/src/main/java/org/onap/aai/sparky/inventory/EntityHistoryQueryBuilder.java b/src/main/java/org/onap/aai/sparky/inventory/EntityHistoryQueryBuilder.java
deleted file mode 100644
index a7f372a..0000000
--- a/src/main/java/org/onap/aai/sparky/inventory/EntityHistoryQueryBuilder.java
+++ /dev/null
@@ -1,139 +0,0 @@
-/**
- * ============LICENSE_START=======================================================
- * org.onap.aai
- * ================================================================================
- * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved.
- * Copyright © 2017-2018 Amdocs
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-package org.onap.aai.sparky.inventory;
-
-import javax.json.Json;
-import javax.json.JsonArray;
-import javax.json.JsonArrayBuilder;
-import javax.json.JsonObject;
-import javax.json.JsonObjectBuilder;
-
-/**
- * The Class EntityHistoryQueryBuilder.
- */
-public class EntityHistoryQueryBuilder {
-
- private static final String TABLE = "table";
- private static final String GRAPH = "graph";
-
- /**
- * Gets the query.
- *
- * @param type the type
- * @return the query
- */
- public static JsonObject getQuery(String type) {
- if (type.equalsIgnoreCase(TABLE)) {
- return createTableQuery();
- } else if (type.equalsIgnoreCase(GRAPH)) {
- return createGraphQuery();
- } else {
- return null;
- }
- }
-
- /**
- * Creates the graph query.
- *
- * @return the json object
- */
- public static JsonObject createGraphQuery() {
- JsonObjectBuilder jsonBuilder = Json.createObjectBuilder();
-
- jsonBuilder.add("aggs",
- Json.createObjectBuilder().add("group_by_entityType",
- Json.createObjectBuilder()
- .add("terms", Json.createObjectBuilder().add("field", "entityType").add("size", 0))
- .add("aggs", Json.createObjectBuilder().add("group_by_date",
- Json.createObjectBuilder().add("date_histogram", createDateHistogram())
- .add("aggs", Json.createObjectBuilder().add("sort_by_date",
- Json.createObjectBuilder().add("top_hits", createTopHitsBlob())))))));
- jsonBuilder.add("size", 0);
-
- return jsonBuilder.build();
- }
-
- /**
- * Creates the table query.
- *
- * @return the json object
- */
- public static JsonObject createTableQuery() {
- JsonObjectBuilder jsonBuilder = Json.createObjectBuilder();
-
- jsonBuilder.add("aggs",
- Json.createObjectBuilder().add("group_by_entityType",
- Json.createObjectBuilder()
- .add("terms", Json.createObjectBuilder().add("field", "entityType").add("size", 0))
- .add("aggs", Json.createObjectBuilder().add("sort_by_date",
- Json.createObjectBuilder().add("top_hits", createTopHitsBlob())))));
- jsonBuilder.add("size", 0);
-
- return jsonBuilder.build();
- }
-
- /**
- * Creates the date histogram.
- *
- * @return the json object
- */
- private static JsonObject createDateHistogram() {
- JsonObjectBuilder jsonBuilder = Json.createObjectBuilder();
-
- jsonBuilder.add("field", "timestamp");
- jsonBuilder.add("min_doc_count", 1);
- jsonBuilder.add("interval", "day");
- jsonBuilder.add("format", "epoch_millis");
-
- return jsonBuilder.build();
- }
-
- /**
- * Creates the top hits blob.
- *
- * @return the json object
- */
- private static JsonObject createTopHitsBlob() {
- JsonObjectBuilder builder = Json.createObjectBuilder();
- builder.add("size", 1);
- builder.add("sort", getSortCriteria());
- return builder.build();
- }
-
- public static JsonArray getSortCriteria() {
- JsonArrayBuilder jsonBuilder = Json.createArrayBuilder();
- jsonBuilder.add(Json.createObjectBuilder().add("timestamp",
- Json.createObjectBuilder().add("order", "desc")));
-
- return jsonBuilder.build();
- }
-
- /**
- * The main method.
- *
- * @param args the arguments
- */
- public static void main(String[] args) {
- System.out.println("TABLE-QUERY: " + createTableQuery().toString());
- System.out.println("GRAPH_QUERY: " + createGraphQuery().toString());
- }
-
-}
diff --git a/src/main/java/org/onap/aai/sparky/inventory/GeoVisualizationProcessor.java b/src/main/java/org/onap/aai/sparky/inventory/GeoVisualizationProcessor.java
deleted file mode 100644
index 9c1f226..0000000
--- a/src/main/java/org/onap/aai/sparky/inventory/GeoVisualizationProcessor.java
+++ /dev/null
@@ -1,176 +0,0 @@
-/**
- * ============LICENSE_START=======================================================
- * org.onap.aai
- * ================================================================================
- * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved.
- * Copyright © 2017-2018 Amdocs
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-package org.onap.aai.sparky.inventory;
-
-import java.io.IOException;
-
-import org.apache.camel.Exchange;
-import org.apache.camel.component.restlet.RestletConstants;
-import org.json.JSONArray;
-import org.json.JSONObject;
-import org.onap.aai.cl.api.Logger;
-import org.onap.aai.cl.eelf.LoggerFactory;
-import org.onap.aai.cl.mdc.MdcContext;
-import org.onap.aai.restclient.client.OperationResult;
-import org.onap.aai.sparky.dal.ElasticSearchAdapter;
-import org.onap.aai.sparky.logging.AaiUiMsgs;
-import org.onap.aai.sparky.util.NodeUtils;
-import org.restlet.Request;
-import org.restlet.Response;
-import org.restlet.data.ClientInfo;
-import org.restlet.data.Form;
-import org.restlet.data.MediaType;
-import org.restlet.data.Parameter;
-import org.restlet.data.Status;
-
-import com.fasterxml.jackson.databind.JsonNode;
-import com.fasterxml.jackson.databind.ObjectMapper;
-
-/**
- * The Class GeoVisualizationServlet.
- */
-public class GeoVisualizationProcessor {
-
- private static final Logger LOG =
- LoggerFactory.getInstance().getLogger(GeoVisualizationProcessor.class);
-
- private ObjectMapper mapper;
- private ElasticSearchAdapter elasticSearchAdapter = null;
- private String topographicalSearchIndexName;
-
- private static final String SEARCH_STRING = "_search";
- private static final String SEARCH_PARAMETER = "?filter_path=hits.hits._source&_source=location&size=5000&q=entityType:";
- private static final String PARAMETER_KEY = "entity";
-
- /**
- * Instantiates a new geo visualization processor
- */
- public GeoVisualizationProcessor(ElasticSearchAdapter elasticSearchAdapter, String topographicalSearchIndexName) {
- this.mapper = new ObjectMapper();
- this.elasticSearchAdapter = elasticSearchAdapter;
- this.topographicalSearchIndexName = topographicalSearchIndexName;
- }
-
- /**
- * Gets the geo visualization results.
- *
- * @param response the response
- * @param entityType the entity type
- * @return the geo visualization results
- * @throws Exception the exception
- */
- protected OperationResult getGeoVisualizationResults(Exchange exchange) throws Exception {
- OperationResult operationResult = new OperationResult();
-
-
- Object xTransactionId = exchange.getIn().getHeader("X-TransactionId");
- if (xTransactionId == null) {
- xTransactionId = NodeUtils.getRandomTxnId();
- }
-
- Object partnerName = exchange.getIn().getHeader("X-FromAppId");
- if (partnerName == null) {
- partnerName = "Browser";
- }
-
- Request request = exchange.getIn().getHeader(RestletConstants.RESTLET_REQUEST, Request.class);
-
- /* Disables automatic Apache Camel Restlet component logging which prints out an undesirable log entry
- which includes client (e.g. browser) information */
- request.setLoggable(false);
-
- ClientInfo clientInfo = request.getClientInfo();
- MdcContext.initialize((String) xTransactionId, "AAI-UI", "", (String) partnerName, clientInfo.getAddress() + ":" + clientInfo.getPort());
-
- String entityType = "";
-
- Form form = request.getResourceRef().getQueryAsForm();
- for (Parameter parameter : form) {
- if(PARAMETER_KEY.equals(parameter.getName())) {
- entityType = parameter.getName();
- }
- }
-
- String api = SEARCH_STRING + SEARCH_PARAMETER + entityType;
-
- final String requestUrl = elasticSearchAdapter.buildElasticSearchUrlForApi(topographicalSearchIndexName, api);
-
- try {
-
- OperationResult opResult =
- elasticSearchAdapter.doGet(requestUrl, javax.ws.rs.core.MediaType.APPLICATION_JSON_TYPE);
-
- JSONObject finalOutputJson = formatOutput(opResult.getResult());
-
- Response response = exchange.getIn().getHeader(RestletConstants.RESTLET_RESPONSE, Response.class);
- response.setStatus(Status.SUCCESS_OK);
- response.setEntity(String.valueOf(finalOutputJson), MediaType.APPLICATION_JSON);
- exchange.getOut().setBody(response);
-
- } catch (Exception exc) {
- LOG.error(AaiUiMsgs.ERROR_GENERIC, "Error processing Geo Visualization request");
- }
-
- return operationResult;
- }
-
- /**
- * Format output.
- *
- * @param results the results
- * @return the JSON object
- */
- private JSONObject formatOutput(String results) {
- JsonNode resultNode = null;
- JSONObject finalResult = new JSONObject();
- JSONArray entitiesArr = new JSONArray();
-
- try {
- resultNode = mapper.readTree(results);
-
- final JsonNode hitsNode = resultNode.get("hits").get("hits");
- if (hitsNode.isArray()) {
-
- for (final JsonNode arrayNode : hitsNode) {
- JsonNode sourceNode = arrayNode.get("_source");
- if (sourceNode.get("location") != null) {
- JsonNode locationNode = sourceNode.get("location");
- if (NodeUtils.isNumeric(locationNode.get("lon").asText())
- && NodeUtils.isNumeric(locationNode.get("lat").asText())) {
- JSONObject location = new JSONObject();
- location.put("longitude", locationNode.get("lon").asText());
- location.put("latitude", locationNode.get("lat").asText());
-
- entitiesArr.put(location);
- }
-
- }
- }
- }
- finalResult.put("plotPoints", entitiesArr);
-
- } catch (IOException exc) {
- LOG.warn(AaiUiMsgs.ERROR_BUILDING_SEARCH_RESPONSE, exc.getLocalizedMessage());
- }
-
- return finalResult;
- }
-}
diff --git a/src/main/java/org/onap/aai/sparky/inventory/entity/GeoIndexDocument.java b/src/main/java/org/onap/aai/sparky/inventory/entity/GeoIndexDocument.java
deleted file mode 100644
index 9f775e5..0000000
--- a/src/main/java/org/onap/aai/sparky/inventory/entity/GeoIndexDocument.java
+++ /dev/null
@@ -1,285 +0,0 @@
-/**
- * ============LICENSE_START=======================================================
- * org.onap.aai
- * ================================================================================
- * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved.
- * Copyright © 2017-2018 Amdocs
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-package org.onap.aai.sparky.inventory.entity;
-
-import java.io.Serializable;
-import java.security.MessageDigest;
-import java.security.NoSuchAlgorithmException;
-import java.util.List;
-
-import org.onap.aai.sparky.config.oxm.OxmEntityDescriptor;
-import org.onap.aai.sparky.config.oxm.OxmEntityLookup;
-import org.onap.aai.sparky.sync.entity.IndexDocument;
-import org.onap.aai.sparky.util.NodeUtils;
-
-import com.fasterxml.jackson.annotation.JsonIgnore;
-import com.fasterxml.jackson.annotation.JsonProperty;
-import com.fasterxml.jackson.core.JsonProcessingException;
-import com.fasterxml.jackson.databind.ObjectMapper;
-
-/**
- * The Class GeoIndexDocument.
- */
-public class GeoIndexDocument implements Serializable, IndexDocument {
-
- @JsonIgnore
- private static final long serialVersionUID = -5188479658230319058L;
-
- protected String entityType;
- protected String entityPrimaryKeyValue;
- protected String entityPrimaryKeyName;
- protected String latitude;
- protected String longitude;
- protected String selfLink;
-
- @JsonIgnore
- protected OxmEntityLookup oxmEntityLookup;
-
- @JsonIgnore
- protected ObjectMapper mapper = new ObjectMapper();
- // generated, SHA-256 digest
- @JsonIgnore
- protected String id;
-
- /**
- * Convert bytes to hex string.
- *
- * @param bytesToConvert the bytes to convert
- * @return the string
- */
- private static String convertBytesToHexString(byte[] bytesToConvert) {
- StringBuffer hexString = new StringBuffer();
- for (int i = 0; i < bytesToConvert.length; i++) {
- hexString.append(Integer.toHexString(0xFF & bytesToConvert[i]));
- }
- return hexString.toString();
- }
-
-
- @JsonIgnore
- public boolean isValidGeoDocument() {
-
- boolean isValid = true;
-
- isValid &= (this.getEntityType() != null);
- isValid &= (this.getLatitude() != null);
- isValid &= (this.getLongitude() != null);
- isValid &= (this.getId() != null);
- isValid &= (this.getSelfLink() != null);
-
- isValid &= NodeUtils.isNumeric(this.getLatitude());
- isValid &= NodeUtils.isNumeric(this.getLongitude());
-
- return isValid;
- }
-
- /**
- * Concat array.
- *
- * @param list the list
- * @param delimiter the delimiter
- * @return the string
- */
- private static String concatArray(List list, char delimiter) {
-
- if (list == null || list.size() == 0) {
- return "";
- }
-
- StringBuilder result = new StringBuilder(64);
-
- int listSize = list.size();
- boolean firstValue = true;
-
- for (String item : list) {
-
- if (firstValue) {
- result.append(item);
- firstValue = false;
- } else {
- result.append(delimiter).append(item);
- }
-
- }
-
- return result.toString();
-
- }
-
- /*
- * We'll try and create a unique identity key that we can use for differencing the previously
- * imported record sets as we won't have granular control of what is created/removed and when. The
- * best we can hope for is identification of resources by generated Id until the Identity-Service
- * UUID is tagged against all resources, then we can use that instead.
- */
-
- /**
- * Generate unique sha digest.
- *
- * @param entityType the entity type
- * @param fieldName the field name
- * @param fieldValue the field value
- * @return the string
- * @throws NoSuchAlgorithmException the no such algorithm exception
- */
- public static String generateUniqueShaDigest(String entityType, String fieldName,
- String fieldValue) throws NoSuchAlgorithmException {
-
- /*
- * Basically SHA-256 will result in an identity with a guaranteed uniqueness compared to just a
- * java hashcode value.
- */
- MessageDigest digest = MessageDigest.getInstance("SHA-256");
- digest.update(String.format("%s.%s.%s", entityType, fieldName, fieldValue).getBytes());
- return convertBytesToHexString(digest.digest());
- }
-
- /**
- * Instantiates a new geo index document.
- */
- public GeoIndexDocument() {}
-
- /*
- * (non-Javadoc)
- *
- */
-
- @Override
- @JsonIgnore
- public String getAsJson() throws JsonProcessingException {
-
- if (latitude != null && longitude != null) {
-
- /**
- * A valid entry from this class is one that has both lat and long. If one or both is missing
- * we shouldn't be indexing anything.
- */
-
- return NodeUtils.convertObjectToJson(this, true);
-
- }
-
- return null;
-
- }
-
- /* (non-Javadoc)
- * @see org.openecomp.sparky.synchronizer.entity.IndexDocument#deriveFields()
- */
- @Override
- public void deriveFields() {
-
- /*
- * We'll try and create a unique identity key that we can use for differencing the previously
- * imported record sets as we won't have granular control of what is created/removed and when.
- * The best we can hope for is identification of resources by generated Id until the
- * Identity-Service UUID is tagged against all resources, then we can use that instead.
- */
-
- OxmEntityDescriptor descriptor = oxmEntityLookup.getEntityDescriptors().get(entityType);
- String entityPrimaryKeyName = NodeUtils.concatArray(
- descriptor.getPrimaryKeyAttributeNames(), "/");
-
- this.id =
- NodeUtils.generateUniqueShaDigest(entityType, entityPrimaryKeyName, entityPrimaryKeyValue);
- }
-
- /* (non-Javadoc)
- * @see java.lang.Object#toString()
- */
- @Override
- public String toString() {
- return "TopographicalEntity [" + ("entityType=" + entityType + ", ")
- + ("entityPrimaryKeyValue=" + entityPrimaryKeyValue + ", ")
- + ("latitude=" + latitude + ", ") + ("longitude=" + longitude + ", ") + ("ID=" + id + ", ")
- + ("selfLink=" + selfLink) + "]";
- }
-
- @Override
- @JsonIgnore
- public String getId() {
- return this.id;
- }
-
- @JsonProperty("entityType")
- public String getEntityType() {
- return entityType;
- }
-
- public void setEntityType(String entityType) {
- this.entityType = entityType;
- }
-
- @JsonProperty("entityPrimaryKeyValue")
- public String getEntityPrimaryKeyValue() {
- return entityPrimaryKeyValue;
- }
-
- public void setEntityPrimaryKeyValue(String entityPrimaryKeyValue) {
- this.entityPrimaryKeyValue = entityPrimaryKeyValue;
- }
-
- @JsonProperty("entityPrimaryKeyName")
- public String getEntityPrimaryKeyName() {
- return entityPrimaryKeyName;
- }
-
- public void setEntityPrimaryKeyName(String entityPrimaryKeyName) {
- this.entityPrimaryKeyName = entityPrimaryKeyName;
- }
-
- @JsonProperty("lat")
- public String getLatitude() {
- return latitude;
- }
-
- public void setLatitude(String latitude) {
- this.latitude = latitude;
- }
-
- @JsonProperty("long")
- public String getLongitude() {
- return longitude;
- }
-
- public void setLongitude(String longitude) {
- this.longitude = longitude;
- }
-
- @JsonProperty("link")
- public String getSelfLink() {
- return selfLink;
- }
-
- public void setSelfLink(String selfLink) {
- this.selfLink = selfLink;
- }
-
- @JsonIgnore
- public static long getSerialversionuid() {
- return serialVersionUID;
- }
-
- public void setId(String id) {
- this.id = id;
- }
-
-}
diff --git a/src/main/java/org/onap/aai/sparky/inventory/entity/TopographicalEntity.java b/src/main/java/org/onap/aai/sparky/inventory/entity/TopographicalEntity.java
deleted file mode 100644
index 88d47ba..0000000
--- a/src/main/java/org/onap/aai/sparky/inventory/entity/TopographicalEntity.java
+++ /dev/null
@@ -1,215 +0,0 @@
-/**
- * ============LICENSE_START=======================================================
- * org.onap.aai
- * ================================================================================
- * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved.
- * Copyright © 2017-2018 Amdocs
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-package org.onap.aai.sparky.inventory.entity;
-
-import java.io.IOException;
-import java.io.Serializable;
-import java.security.MessageDigest;
-import java.security.NoSuchAlgorithmException;
-import java.util.List;
-
-import javax.json.Json;
-import javax.json.JsonObject;
-
-/**
- * The Class TopographicalEntity.
- */
-public class TopographicalEntity implements Serializable {
-
- private static final long serialVersionUID = -5188479658230319058L;
-
- protected String entityType;
- protected String entityPrimaryKeyValue;
- protected String entityPrimaryKeyName;
- protected String latitude;
- protected String longitude;
- protected String selfLink;
-
- // generated, SHA-256 digest
- protected String id;
-
- /**
- * Convert bytes to hex string.
- *
- * @param bytesToConvert the bytes to convert
- * @return the string
- */
- private static String convertBytesToHexString(byte[] bytesToConvert) {
- StringBuffer hexString = new StringBuffer();
- for (int i = 0; i < bytesToConvert.length; i++) {
- hexString.append(Integer.toHexString(0xFF & bytesToConvert[i]));
- }
- return hexString.toString();
- }
-
- /**
- * Concat array.
- *
- * @param list the list
- * @param delimiter the delimiter
- * @return the string
- */
- private static String concatArray(List