aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--.gitignore4
-rw-r--r--aai-traversal/pom.xml409
-rw-r--r--aai-traversal/src/main/docker/Dockerfile6
-rw-r--r--aai-traversal/src/main/docker/docker-entrypoint.sh46
-rw-r--r--aai-traversal/src/main/java/org/onap/aai/TraversalApp.java33
-rw-r--r--aai-traversal/src/main/java/org/onap/aai/config/DslConfiguration.java (renamed from aai-traversal/src/test/java/org/onap/aai/retiredcustomer/V3ThroughV7ConsumerTest.java)26
-rw-r--r--aai-traversal/src/main/java/org/onap/aai/config/ErrorHandler.java87
-rw-r--r--aai-traversal/src/main/java/org/onap/aai/config/SearchConfiguration.java50
-rw-r--r--aai-traversal/src/main/java/org/onap/aai/dbgraphgen/ModelBasedProcessing.java1435
-rw-r--r--aai-traversal/src/main/java/org/onap/aai/dbgraphmap/SearchGraph.java81
-rw-r--r--aai-traversal/src/main/java/org/onap/aai/interceptors/AAIHeaderProperties.java35
-rw-r--r--aai-traversal/src/main/java/org/onap/aai/interceptors/post/AAIResponseFilterPriority.java20
-rw-r--r--aai-traversal/src/main/java/org/onap/aai/interceptors/post/InvalidResponseStatus.java65
-rw-r--r--aai-traversal/src/main/java/org/onap/aai/interceptors/post/ResetLoggingContext.java67
-rw-r--r--aai-traversal/src/main/java/org/onap/aai/interceptors/post/ResponseHeaderManipulation.java23
-rw-r--r--aai-traversal/src/main/java/org/onap/aai/interceptors/post/ResponseTransactionLogging.java24
-rw-r--r--aai-traversal/src/main/java/org/onap/aai/interceptors/pre/AAIRequestFilterPriority.java26
-rw-r--r--aai-traversal/src/main/java/org/onap/aai/interceptors/pre/HeaderValidation.java19
-rw-r--r--aai-traversal/src/main/java/org/onap/aai/interceptors/pre/HttpHeaderInterceptor.java50
-rw-r--r--aai-traversal/src/main/java/org/onap/aai/interceptors/pre/OneWaySslAuthorization.java3
-rw-r--r--aai-traversal/src/main/java/org/onap/aai/interceptors/pre/RequestHeaderManipulation.java24
-rw-r--r--aai-traversal/src/main/java/org/onap/aai/interceptors/pre/RequestModification.java17
-rw-r--r--aai-traversal/src/main/java/org/onap/aai/interceptors/pre/RequestTransactionLogging.java65
-rw-r--r--aai-traversal/src/main/java/org/onap/aai/interceptors/pre/RetiredInterceptor.java148
-rw-r--r--aai-traversal/src/main/java/org/onap/aai/interceptors/pre/SetLoggingContext.java14
-rw-r--r--aai-traversal/src/main/java/org/onap/aai/interceptors/pre/TwoWaySslAuthorization.java185
-rw-r--r--aai-traversal/src/main/java/org/onap/aai/interceptors/pre/VersionInterceptor.java101
-rw-r--r--aai-traversal/src/main/java/org/onap/aai/interceptors/pre/VersionLatestInterceptor.java57
-rw-r--r--aai-traversal/src/main/java/org/onap/aai/rest/DslConsumer.java187
-rw-r--r--aai-traversal/src/main/java/org/onap/aai/rest/QueryConsumer.java95
-rw-r--r--aai-traversal/src/main/java/org/onap/aai/rest/RecentAPIConsumer.java253
-rw-r--r--aai-traversal/src/main/java/org/onap/aai/rest/dsl/DslContext.java130
-rw-r--r--aai-traversal/src/main/java/org/onap/aai/rest/dsl/DslListener.java267
-rw-r--r--aai-traversal/src/main/java/org/onap/aai/rest/dsl/DslQueryBuilder.java190
-rw-r--r--aai-traversal/src/main/java/org/onap/aai/rest/dsl/DslQueryProcessor.java31
-rw-r--r--aai-traversal/src/main/java/org/onap/aai/rest/retired/RetiredConsumer.java140
-rw-r--r--aai-traversal/src/main/java/org/onap/aai/rest/retired/V3ThroughV7Consumer.java27
-rw-r--r--aai-traversal/src/main/java/org/onap/aai/rest/retired/V7V8NamedQueries.java27
-rw-r--r--aai-traversal/src/main/java/org/onap/aai/rest/search/CustomQueryConfig.java62
-rw-r--r--aai-traversal/src/main/java/org/onap/aai/rest/search/GenericQueryProcessor.java124
-rw-r--r--aai-traversal/src/main/java/org/onap/aai/rest/search/GetCustomQueryConfig.java232
-rw-r--r--aai-traversal/src/main/java/org/onap/aai/rest/search/GremlinGroovyShellSingleton.java87
-rw-r--r--aai-traversal/src/main/java/org/onap/aai/rest/search/GremlinServerImpl.java75
-rw-r--r--aai-traversal/src/main/java/org/onap/aai/rest/search/GremlinServerSingleton.java93
-rw-r--r--aai-traversal/src/main/java/org/onap/aai/rest/search/GroovyQueryBuilderSingleton.java95
-rw-r--r--aai-traversal/src/main/java/org/onap/aai/rest/search/ModelAndNamedQueryRestProvider.java53
-rw-r--r--aai-traversal/src/main/java/org/onap/aai/rest/search/NodeQueryProcessor.java116
-rw-r--r--aai-traversal/src/main/java/org/onap/aai/rest/search/SearchProvider.java93
-rw-r--r--aai-traversal/src/main/java/org/onap/aai/rest/util/ConvertQueryPropertiesToJson.java180
-rw-r--r--aai-traversal/src/main/java/org/onap/aai/rest/util/ValidateEncoding.java3
-rw-r--r--aai-traversal/src/main/java/org/onap/aai/service/AuthorizationService.java3
-rw-r--r--aai-traversal/src/main/java/org/onap/aai/service/RetiredService.java67
-rw-r--r--aai-traversal/src/main/java/org/onap/aai/util/AAIAppServletContextListener.java111
-rw-r--r--aai-traversal/src/main/java/org/onap/aai/util/MakeNamedQuery.java177
-rw-r--r--aai-traversal/src/main/java/org/onap/aai/util/TraversalConstants.java (renamed from aai-traversal/src/test/java/org/onap/aai/retiredcustomer/V7V8NamedQueriesTest.java)26
-rw-r--r--aai-traversal/src/main/java/org/onap/aai/web/JerseyConfiguration.java54
-rw-r--r--aai-traversal/src/main/java/org/onap/aai/web/LocalHostAccessLog.java12
-rw-r--r--aai-traversal/src/main/resources/antlr4/org/onap/aai/AAIDsl.g417
-rw-r--r--aai-traversal/src/main/resources/application.properties83
-rw-r--r--aai-traversal/src/main/resources/etc/appprops/Introscope.properties8
-rw-r--r--aai-traversal/src/main/resources/etc/appprops/PostProcessorInterceptors.properties3
-rw-r--r--aai-traversal/src/main/resources/etc/appprops/aaiEventDMaaPPublisher.properties30
-rw-r--r--aai-traversal/src/main/resources/etc/appprops/aaiconfig.properties77
-rw-r--r--aai-traversal/src/main/resources/etc/appprops/default-logback.xml43
-rw-r--r--aai-traversal/src/main/resources/etc/appprops/error.properties12
-rw-r--r--aai-traversal/src/main/resources/etc/appprops/gremlin-server-config.yaml25
-rw-r--r--aai-traversal/src/main/resources/etc/appprops/janusgraph-cached.properties10
-rw-r--r--aai-traversal/src/main/resources/etc/appprops/janusgraph-realtime.properties10
-rw-r--r--aai-traversal/src/main/resources/etc/appprops/methodMapper.properties24
-rw-r--r--aai-traversal/src/main/resources/etc/appprops/preferredRoute.txt1
-rw-r--r--aai-traversal/src/main/resources/etc/scriptdata/named-query-json/getClfiRoadmTailSummary-1.0.json186
-rw-r--r--aai-traversal/src/main/resources/etc/scriptdata/named-query-json/getRouterRoadmTailSummary-1.0.json238
-rw-r--r--aai-traversal/src/main/resources/etc/sysprops/sys-props.properties140
-rw-r--r--aai-traversal/src/main/resources/etc/sysprops/template.sys-props.properties115
-rw-r--r--aai-traversal/src/main/resources/retired.properties5
-rw-r--r--aai-traversal/src/main/resources/schema/UebEventLogEntry.xsd43
-rw-r--r--aai-traversal/src/main/resources/schema/onap/query/stored-queries.json (renamed from aai-traversal/src/main/resources/etc/query/stored-queries.json)198
-rw-r--r--aai-traversal/src/main/scripts/common_functions.sh10
-rw-r--r--aai-traversal/src/main/scripts/install/instutils.sh725
-rw-r--r--aai-traversal/src/main/scripts/putTool.sh24
-rw-r--r--aai-traversal/src/main/swm/package/nix/common/deinstall.env10
-rw-r--r--aai-traversal/src/main/swm/package/nix/common/install_postproc.sh39
-rw-r--r--aai-traversal/src/main/swm/package/nix/deinstall/preproc/pre_proc4
-rw-r--r--aai-traversal/src/main/swm/package/nix/dist_files/opt/app/aai-traversal/docker-compose.template.yaml51
-rw-r--r--aai-traversal/src/main/swm/package/nix/dist_files/opt/app/aai-traversal/execTool.sh58
-rw-r--r--aai-traversal/src/main/swm/package/nix/dist_files/opt/app/aai-traversal/kill_resources.sh7
-rw-r--r--aai-traversal/src/main/swm/package/nix/dist_files/opt/app/aai-traversal/start_resources.sh6
-rw-r--r--aai-traversal/src/main/swm/package/nix/dist_files/opt/app/aai-traversal/stop_resources.sh6
-rw-r--r--aai-traversal/src/main/swm/package/nix/initinst/postproc/post_proc4
-rw-r--r--aai-traversal/src/main/swm/package/nix/install/postproc/post_proc4
-rw-r--r--aai-traversal/src/main/swm/package/nix/install/preproc/pre_proc4
-rw-r--r--aai-traversal/src/test/java/org/onap/aai/AAIGremlinQueryTest.java131
-rw-r--r--aai-traversal/src/test/java/org/onap/aai/AAISetup.java141
-rw-r--r--aai-traversal/src/test/java/org/onap/aai/HttpTestUtil.java59
-rw-r--r--aai-traversal/src/test/java/org/onap/aai/QueryParameterTest.java188
-rw-r--r--aai-traversal/src/test/java/org/onap/aai/SubgraphPruneTest.java129
-rw-r--r--aai-traversal/src/test/java/org/onap/aai/dbgraphgen/ModelBasedProcessingInvalidDataTest.java1824
-rw-r--r--aai-traversal/src/test/java/org/onap/aai/dbgraphgen/ModelBasedProcessingTest.java113
-rw-r--r--aai-traversal/src/test/java/org/onap/aai/dbgraphmap/SearchGraphEdgeRuleTest.java13
-rw-r--r--aai-traversal/src/test/java/org/onap/aai/dbgraphmap/SearchGraphNamedQueryTest.java38
-rw-r--r--aai-traversal/src/test/java/org/onap/aai/dbgraphmap/SearchGraphTest.java35
-rw-r--r--aai-traversal/src/test/java/org/onap/aai/rest/AbstractSpringRestTest.java135
-rw-r--r--aai-traversal/src/test/java/org/onap/aai/rest/BadQueryFormatTest.java109
-rw-r--r--aai-traversal/src/test/java/org/onap/aai/rest/DslConsumerTest.java113
-rw-r--r--aai-traversal/src/test/java/org/onap/aai/rest/GfpVserverDataStoredQueryTest.java44
-rw-r--r--aai-traversal/src/test/java/org/onap/aai/rest/RecentApiTest.java95
-rw-r--r--aai-traversal/src/test/java/org/onap/aai/rest/SearchProviderRestTest.java102
-rw-r--r--aai-traversal/src/test/java/org/onap/aai/rest/dsl/DslQueryProcessorTest.java124
-rw-r--r--aai-traversal/src/test/java/org/onap/aai/rest/retired/RetiredConsumerSpringTest.java65
-rw-r--r--aai-traversal/src/test/java/org/onap/aai/rest/search/CloudRegionAndSourceFromConfigurationQueryTest.java102
-rw-r--r--aai-traversal/src/test/java/org/onap/aai/rest/search/CloudRegionFromVnfTest.java17
-rw-r--r--aai-traversal/src/test/java/org/onap/aai/rest/search/ContainmentPathQueryTest.java4
-rw-r--r--aai-traversal/src/test/java/org/onap/aai/rest/search/DestinationFromConfigurationQueryTest.java100
-rw-r--r--aai-traversal/src/test/java/org/onap/aai/rest/search/GetClfiRoadmTailSummaryTest.java105
-rw-r--r--aai-traversal/src/test/java/org/onap/aai/rest/search/GetComplexByPnfNameQueryTest.java75
-rw-r--r--aai-traversal/src/test/java/org/onap/aai/rest/search/GetComplexFromHostnameQueryTest.java77
-rw-r--r--aai-traversal/src/test/java/org/onap/aai/rest/search/GetDHVLogicalLinkTest.java116
-rw-r--r--aai-traversal/src/test/java/org/onap/aai/rest/search/GetL3networkCloudRegionByNetworkRoleQueryTest.java91
-rw-r--r--aai-traversal/src/test/java/org/onap/aai/rest/search/GetLinterfaceFromNewvceTest.java121
-rw-r--r--aai-traversal/src/test/java/org/onap/aai/rest/search/GetNetworksTest.java92
-rw-r--r--aai-traversal/src/test/java/org/onap/aai/rest/search/GetPinterfacePhysicalLinkBySvcInstIdTest.java106
-rw-r--r--aai-traversal/src/test/java/org/onap/aai/rest/search/GetRouterRoadmTailSummaryTest.java104
-rw-r--r--aai-traversal/src/test/java/org/onap/aai/rest/search/GetServiceTopologyTest.java220
-rw-r--r--aai-traversal/src/test/java/org/onap/aai/rest/search/GfpVserverDataQueryTest.java1
-rw-r--r--aai-traversal/src/test/java/org/onap/aai/rest/search/GfpVserverQueryTest.java69
-rw-r--r--aai-traversal/src/test/java/org/onap/aai/rest/search/GremlinServerImplTest.java161
-rw-r--r--aai-traversal/src/test/java/org/onap/aai/rest/search/GroovyShellImplTest.java61
-rw-r--r--aai-traversal/src/test/java/org/onap/aai/rest/search/InstanceGroupsByCloudRegionQueryTest.java78
-rw-r--r--aai-traversal/src/test/java/org/onap/aai/rest/search/LinkedDevices_NewvceVserverTest.java2
-rw-r--r--aai-traversal/src/test/java/org/onap/aai/rest/search/LogicalLinkByCloudRegionIdTest.java75
-rw-r--r--aai-traversal/src/test/java/org/onap/aai/rest/search/ModelAndNamedQueryRestProviderTest.java22
-rw-r--r--aai-traversal/src/test/java/org/onap/aai/rest/search/NetworkCollectionByServiceInstanceTest.java103
-rw-r--r--aai-traversal/src/test/java/org/onap/aai/rest/search/PathQueryTest.java4
-rw-r--r--aai-traversal/src/test/java/org/onap/aai/rest/search/PendingTopologyDetailTest.java12
-rw-r--r--aai-traversal/src/test/java/org/onap/aai/rest/search/PserverFromFqdnFirstTokenTest.java74
-rw-r--r--aai-traversal/src/test/java/org/onap/aai/rest/search/PserverFromHostnameFirstTokenTest.java75
-rw-r--r--aai-traversal/src/test/java/org/onap/aai/rest/search/PserverfromConfigurationFilterInterfaceIdTest.java5
-rw-r--r--aai-traversal/src/test/java/org/onap/aai/rest/search/PserverfromConfigurationTest.java4
-rw-r--r--aai-traversal/src/test/java/org/onap/aai/rest/search/QueryCountTest.java4
-rw-r--r--aai-traversal/src/test/java/org/onap/aai/rest/search/QueryPnfFromModelTest.java81
-rw-r--r--aai-traversal/src/test/java/org/onap/aai/rest/search/QueryTest.java108
-rw-r--r--aai-traversal/src/test/java/org/onap/aai/rest/search/RelatedToBothCousinAndTreeCustomQueryTest.java88
-rw-r--r--aai-traversal/src/test/java/org/onap/aai/rest/search/RelatedToCustomQueryTest.java78
-rw-r--r--aai-traversal/src/test/java/org/onap/aai/rest/search/RelatedToTreeCustomQueryTest.java77
-rw-r--r--aai-traversal/src/test/java/org/onap/aai/rest/search/SearchProviderTest.java191
-rw-r--r--aai-traversal/src/test/java/org/onap/aai/rest/search/SimpleFormatTest.java47
-rw-r--r--aai-traversal/src/test/java/org/onap/aai/rest/search/SriovTopologyFromVnfQueryTest.java109
-rw-r--r--aai-traversal/src/test/java/org/onap/aai/rest/search/TopologyDetailFromVnfQueryTest.java163
-rw-r--r--aai-traversal/src/test/java/org/onap/aai/rest/search/TopologyDetailFromVserverQueryTest.java39
-rw-r--r--aai-traversal/src/test/java/org/onap/aai/rest/search/TopologySummaryFromCloudRegionQueryTest.java118
-rw-r--r--aai-traversal/src/test/java/org/onap/aai/rest/search/TopologySummaryFromTenantTest.java93
-rw-r--r--aai-traversal/src/test/java/org/onap/aai/rest/search/TreeQueryTest.java4
-rw-r--r--aai-traversal/src/test/java/org/onap/aai/rest/search/UcpeTopologyQueryTest.java4
-rw-r--r--aai-traversal/src/test/java/org/onap/aai/rest/search/VfModuleFromServiceInstanceTest.java84
-rw-r--r--aai-traversal/src/test/java/org/onap/aai/rest/search/VnfToServiceInstanceQueryTest.java75
-rw-r--r--aai-traversal/src/test/java/org/onap/aai/rest/search/VnfTopologyFromServiceInstanceTest.java126
-rw-r--r--aai-traversal/src/test/java/org/onap/aai/rest/search/VnfTopologyFromVnfTest.java4
-rw-r--r--aai-traversal/src/test/java/org/onap/aai/rest/search/VnfsVlansFromServiceInstanceTest.java103
-rw-r--r--aai-traversal/src/test/java/org/onap/aai/rest/search/VserverFromPserverTreeTest.java86
-rw-r--r--aai-traversal/src/test/java/org/onap/aai/rest/search/VserverFromVnfQueryTest.java20
-rw-r--r--aai-traversal/src/test/java/org/onap/aai/rest/search/VserverLinterfacesFromVnfcTest.java98
-rw-r--r--aai-traversal/src/test/java/org/onap/aai/rest/search/getSvcSubscriberModelInfoTest.java76
-rw-r--r--aai-traversal/src/test/java/org/onap/aai/rest/util/ValidateEncodingTest.java15
-rw-r--r--aai-traversal/src/test/java/org/onap/aai/retiredcustomer/RetiredConsumerTest.java127
-rw-r--r--aai-traversal/src/test/resources/application-test.properties65
-rw-r--r--aai-traversal/src/test/resources/bundleconfig-local/etc/appprops/error.properties172
-rw-r--r--aai-traversal/src/test/resources/payloads/templates/cloud-region-with-vserver.json32
-rw-r--r--aai-traversal/src/test/resources/payloads/templates/configuration.json5
-rw-r--r--aai-traversal/src/test/resources/payloads/templates/customer-with-configurations.json46
-rw-r--r--aai-traversal/src/test/resources/payloads/templates/customer-with-serviceinstance.json20
-rw-r--r--aai-traversal/src/test/resources/payloads/templates/customer.json5
-rw-r--r--aai-traversal/src/test/resources/payloads/templates/dsl-query.json4
-rw-r--r--aai-traversal/src/test/resources/payloads/templates/generic-vnf-to-configuration.json72
-rw-r--r--aai-traversal/src/test/resources/payloads/templates/generic-vnf.json7
-rw-r--r--aai-traversal/src/test/resources/payloads/templates/model-ver.json5
-rw-r--r--aai-traversal/src/test/resources/payloads/templates/model.json4
-rw-r--r--pom.xml6
177 files changed, 10204 insertions, 6141 deletions
diff --git a/.gitignore b/.gitignore
index 0aac718..f586926 100644
--- a/.gitignore
+++ b/.gitignore
@@ -10,4 +10,6 @@ bundleconfig-local/etc/logback.xml
/.classpath
**/.idea/
*/.idea
-*.iml \ No newline at end of file
+*.iml
+**/oxm/**
+**/dbedgerules/**
diff --git a/aai-traversal/pom.xml b/aai-traversal/pom.xml
index d583770..8806714 100644
--- a/aai-traversal/pom.xml
+++ b/aai-traversal/pom.xml
@@ -28,25 +28,24 @@
<version>1.3.0-SNAPSHOT</version>
<parent>
- <groupId>org.springframework.boot</groupId>
- <artifactId>spring-boot-starter-parent</artifactId>
- <version>1.5.12.RELEASE</version>
+ <groupId>org.onap.aai.traversal</groupId>
+ <artifactId>traversal</artifactId>
+ <version>1.3.0-SNAPSHOT</version>
</parent>
<properties>
- <swagger.directory>${basedir}/target/classes/META-INF/traversal/swagger</swagger.directory>
- <icd.file>service.json</icd.file>
- <icd.package>com.att.ajsc.ajsc6configdemo.service.rs</icd.package>
<java.version>1.8</java.version>
- <build.number>local</build.number>
- <kube.namespace>org-onap-aai</kube.namespace>
- <service.account>ajsc-svc-account</service.account>
- <namespace>com.att.ajsc</namespace>
<start-class>org.onap.aai.TraversalApp</start-class>
- <aai-schema.version>1.3.0-SNAPSHOT</aai-schema.version>
+ <maven.skip.tests>true</maven.skip.tests>
+ <maven.compiler.source>1.8</maven.compiler.source>
+ <maven.compiler.target>1.8</maven.compiler.target>
+
+ <aai.schema.version>1.3.0-SNAPSHOT</aai.schema.version>
<aai.core.version>1.3.0-SNAPSHOT</aai.core.version>
+ <spring.boot.version>1.5.12.RELEASE</spring.boot.version>
+
<!-- Start of the jacoco plugin properties -->
<sonar.language>java</sonar.language>
<sonar.java.coveragePlugin>jacoco</sonar.java.coveragePlugin>
@@ -115,12 +114,10 @@
<!--
Location where assembly of our scripts, resources and main jar will be held
- Check the aai-traversal/src/main/assembly/descriptor.xml for more info
+ Check the ${project.artifactId}/src/main/assembly/descriptor.xml for more info
-->
- <aai.build.directory>${project.build.directory}/${project.artifactId}-${project.version}-build/
- </aai.build.directory>
+ <aai.build.directory>${project.build.directory}/${project.artifactId}-${project.version}-build/</aai.build.directory>
<aai.docker.namespace>onap</aai.docker.namespace>
- <maven.skip.tests>true</maven.skip.tests>
<spring.web.version>4.3.6.RELEASE</spring.web.version>
<aai.project.version>1.3.0</aai.project.version>
@@ -151,7 +148,24 @@
<plexus.utils.version>3.1.0</plexus.utils.version>
- <jacoco.line.coverage.limit>0.69</jacoco.line.coverage.limit>
+ <snapshot.file>${project.basedir}/snapshots/data.graphson</snapshot.file>
+ <license.goal.type>check</license.goal.type>
+ <jacoco.line.coverage.limit>0.67</jacoco.line.coverage.limit>
+
+ <!-- Start of Default ONAP Schema Properties -->
+ <schema.source.name>onap</schema.source.name>
+ <schema.configuration.location>N/A</schema.configuration.location>
+ <schema.nodes.location>${project.basedir}/src/main/resources/schema/${schema.source.name}/oxm</schema.nodes.location>
+ <schema.edges.location>${project.basedir}/src/main/resources/schema/${schema.source.name}/dbedgerules</schema.edges.location>
+ <schema.version.depth.start>v9</schema.version.depth.start>
+ <schema.version.related.link.start>v10</schema.version.related.link.start>
+ <schema.version.app.root.start>v11</schema.version.app.root.start>
+ <schema.version.namespace.change.start>v12</schema.version.namespace.change.start>
+ <schema.version.edge.label.start>v12</schema.version.edge.label.start>
+ <schema.version.api.default>v14</schema.version.api.default>
+ <schema.version.list>v8,v9,v10,v11,v12,v13,v14</schema.version.list>
+ <schema.uri.base.path>/aai</schema.uri.base.path>
+ <!-- End of Default ONAP Schema Properties -->
</properties>
<profiles>
<!-- Docker profile to be used for building docker image and pushing to nexus -->
@@ -168,24 +182,24 @@
<apiVersion>1.23</apiVersion>
<images>
<image>
- <name>${docker.push.registry}/${aai.docker.namespace}/aai-traversal:%l</name>
+ <name>${docker.push.registry}/${aai.docker.namespace}/${project.artifactId}:%l</name>
<build>
<filter>@</filter>
<tags>
<tag>latest</tag>
- <tag>${aai.docker.version}-STAGING-${maven.build.timestamp}</tag>
- <tag>${aai.docker.version}-STAGING-latest</tag>
+ <tag>${project.docker.latesttag.version}</tag>
+ <tag>${project.major.version}.${project.minor.version}-STAGING-${maven.build.timestamp}</tag>
</tags>
<cleanup>try</cleanup>
<dockerFileDir>${project.basedir}/src/main/docker</dockerFileDir>
<assembly>
<inline>
- <fileSets>
- <fileSet>
- <directory>${aai.build.directory}</directory>
- <outputDirectory>/${project.artifactId}</outputDirectory>
- </fileSet>
- </fileSets>
+ <fileSets>
+ <fileSet>
+ <directory>${aai.build.directory}</directory>
+ <outputDirectory>/${project.artifactId}</outputDirectory>
+ </fileSet>
+ </fileSets>
</inline>
</assembly>
</build>
@@ -222,11 +236,16 @@
</plugins>
</build>
</profile>
- <!--
- Use of this profile is a way to support legacy runAjsc profile seen using AJSC 2
- and also because spring-boot:run doesn't work with large classpaths in windows
- so this accommodates the behavior of running the application from maven
- -->
+ <!-- Start of ONAP Profile -->
+ <profile>
+ <id>onap</id>
+ <properties>
+ <schema.source.name>onap</schema.source.name>
+ <schema.version.namespace.change.start>v12</schema.version.namespace.change.start>
+ <schema.version.list>v8,v9,v10,v11,v12,v13,v14</schema.version.list>
+ </properties>
+ </profile>
+ <!-- End of ONAP Profile -->
<profile>
<id>runAjsc</id>
<properties>
@@ -251,10 +270,58 @@
<configuration>
<mainClass>${start-class}</mainClass>
<systemProperties>
- <systemProperty>
+ <property>
<key>snapshot.location</key>
<value>${snapshot.file}</value>
- </systemProperty>
+ </property>
+ <property>
+ <key>schema.source.name</key>
+ <value>${schema.source.name}</value>
+ </property>
+ <property>
+ <key>schema.configuration.location</key>
+ <value>${schema.configuration.location}</value>
+ </property>
+ <property>
+ <key>schema.nodes.location</key>
+ <value>${schema.nodes.location}</value>
+ </property>
+ <property>
+ <key>schema.edges.location</key>
+ <value>${schema.edges.location}</value>
+ </property>
+ <property>
+ <key>schema.version.depth.start</key>
+ <value>${schema.version.depth.start}</value>
+ </property>
+ <property>
+ <key>schema.version.related.link.start</key>
+ <value>${schema.version.related.link.start}</value>
+ </property>
+ <property>
+ <key>schema.version.app.root.start</key>
+ <value>${schema.version.app.root.start}</value>
+ </property>
+ <property>
+ <key>schema.version.namespace.change.start</key>
+ <value>${schema.version.namespace.change.start}</value>
+ </property>
+ <property>
+ <key>schema.version.edge.label.start</key>
+ <value>${schema.version.edge.label.start}</value>
+ </property>
+ <property>
+ <key>schema.version.api.default</key>
+ <value>${schema.version.api.default}</value>
+ </property>
+ <property>
+ <key>schema.version.list</key>
+ <value>${schema.version.list}</value>
+ </property>
+ <property>
+ <key>schema.uri.base.path</key>
+ <value>${schema.uri.base.path}</value>
+ </property>
</systemProperties>
<executable>java</executable>
</configuration>
@@ -263,22 +330,19 @@
</build>
</profile>
</profiles>
+ <dependencyManagement>
+ <dependencies>
+ <dependency>
+ <groupId>org.springframework.boot</groupId>
+ <artifactId>spring-boot-starter-parent</artifactId>
+ <version>${spring.boot.version}</version>
+ <type>pom</type>
+ <scope>import</scope>
+ </dependency>
+ </dependencies>
+ </dependencyManagement>
<dependencies>
<dependency>
- <groupId>org.springframework.boot</groupId>
- <artifactId>spring-boot-starter-jersey</artifactId>
- <exclusions>
- <exclusion>
- <groupId>com.sun.jersey</groupId>
- <artifactId>jersey-servlet</artifactId>
- </exclusion>
- <exclusion>
- <groupId>org.springframework.boot</groupId>
- <artifactId>spring-boot-starter-tomcat</artifactId>
- </exclusion>
- </exclusions>
- </dependency>
- <dependency>
<groupId>net.sf.jopt-simple</groupId>
<artifactId>jopt-simple</artifactId>
<version>${jopt.simple.version}</version>
@@ -510,21 +574,6 @@
<version>${gson.version}</version>
</dependency>
<dependency>
- <groupId>com.att.nsa</groupId>
- <artifactId>dmaapClient</artifactId>
- <version>${dmaap.client.version}</version>
- <exclusions>
- <exclusion>
- <groupId>org.slf4j</groupId>
- <artifactId>slf4j-log4j12</artifactId>
- </exclusion>
- <exclusion>
- <groupId>com.att.aft</groupId>
- <artifactId>dme2</artifactId>
- </exclusion>
- </exclusions>
- </dependency>
- <dependency>
<groupId>com.bazaarvoice.jolt</groupId>
<artifactId>jolt-complete</artifactId>
<version>${jolt.version}</version>
@@ -563,11 +612,6 @@
</exclusions>
</dependency>
<dependency>
- <groupId>org.onap.aai.aai-common</groupId>
- <artifactId>aai-schema</artifactId>
- <version>${aai-schema.version}</version>
- </dependency>
- <dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-jms</artifactId>
<version>${spring.jms.version}</version>
@@ -587,10 +631,6 @@
<version>${httpclient.version}</version>
</dependency>
<dependency>
- <groupId>org.springframework.boot</groupId>
- <artifactId>spring-boot-devtools</artifactId>
- </dependency>
- <dependency>
<groupId>org.skyscreamer</groupId>
<artifactId>jsonassert</artifactId>
<version>${jsonassert.version}</version>
@@ -639,6 +679,10 @@
<artifactId>spring-boot-starter-jetty</artifactId>
</dependency>
<dependency>
+ <groupId>org.springframework.boot</groupId>
+ <artifactId>spring-boot-starter-jersey</artifactId>
+ </dependency>
+ <dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-web</artifactId>
<version>${spring.web.version}</version>
@@ -723,8 +767,7 @@
<include>logback.xml</include>
<include>localhost-access-logback.xml</include>
</includes>
- <targetPath>${project.build.directory}/swm/package/nix/dist_files/opt/app/aai-traversal/appconfig
- </targetPath>
+ <targetPath>${project.build.directory}/swm/package/nix/dist_files/opt/app/${project.artifactId}/appconfig</targetPath>
<filtering>false</filtering>
</resource>
<resource>
@@ -741,8 +784,7 @@
<include>janusgraph-cached.properties</include>
<include>aaiconfig.properties</include>
</includes>
- <targetPath>${project.build.directory}/swm/package/nix/dist_files/opt/app/aai-traversal/appconfig
- </targetPath>
+ <targetPath>${project.build.directory}/swm/package/nix/dist_files/opt/app/${project.artifactId}/appconfig</targetPath>
<filtering>false</filtering>
</resource>
<resource>
@@ -750,9 +792,9 @@
<includes>
<include>aai-client-cert.p12</include>
<include>tomcat_keystore</include>
+ <include>aai_policy.json</include>
</includes>
- <targetPath>${project.build.directory}/swm/package/nix/dist_files/opt/app/aai-traversal/appconfig
- </targetPath>
+ <targetPath>${project.build.directory}/swm/package/nix/dist_files/opt/app/${project.artifactId}/appconfig</targetPath>
<filtering>true</filtering>
</resource>
<resource>
@@ -761,11 +803,28 @@
<include>logback.xml</include>
<include>localhost-access-logback.xml</include>
</includes>
- <targetPath>${project.build.directory}/swm/package/nix/dist_files/opt/app/aai-traversal/appconfig
- </targetPath>
+ <targetPath>${project.build.directory}/swm/package/nix/dist_files/opt/app/${project.artifactId}/appconfig</targetPath>
<filtering>true</filtering>
</resource>
<resource>
+ <directory>${project.basedir}/src/main/resources/schema/</directory>
+ <includes>
+ <include>**/oxm/**/*.xml</include>
+ <include>**/dbedgerules/**/*.json</include>
+ <include>**/query/**</include>
+ </includes>
+ <targetPath>${project.build.directory}/swm/package/nix/dist_files/opt/app/${project.artifactId}/appconfig/schema</targetPath>
+ <filtering>false</filtering>
+ </resource>
+ <resource>
+ <directory>${project.basedir}/src/main/resources/query/</directory>
+ <includes>
+ <include>**/*.json</include>
+ </includes>
+ <targetPath>${project.build.directory}/swm/package/nix/dist_files/opt/app/${project.artifactId}/appconfig/query</targetPath>
+ <filtering>false</filtering>
+ </resource>
+ <resource>
<directory>${project.basedir}/src/main/docker</directory>
<includes>
<include>**/*</include>
@@ -777,28 +836,26 @@
<pluginManagement>
<plugins>
<plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-dependency-plugin</artifactId>
- <version>2.8</version>
+ <groupId>com.mycila</groupId>
+ <artifactId>license-maven-plugin</artifactId>
+ <version>3.0</version>
+ <configuration>
+ <header>LICENSE.TXT</header>
+ <includes>
+ <include>src/main/java/**</include>
+ <include>src/test/java/**</include>
+ <include>pom.xml</include>
+ </includes>
+ <skipExistingHeaders>true</skipExistingHeaders>
+ <skip>false</skip>
+ </configuration>
<executions>
<execution>
- <id>unpack-schema-dependency</id>
- <phase>initialize</phase>
<goals>
- <goal>unpack</goal>
+ <!-- Set goal to "format" to auto update license headers -->
+ <goal>${license.goal.type}</goal>
</goals>
- <configuration>
- <artifactItems>
- <artifactItem>
- <groupId>org.onap.aai.aai-common</groupId>
- <artifactId>aai-schema</artifactId>
- <version>${aai.core.version}</version>
- <outputDirectory>${project.basedir}/src/main/resources/etc/</outputDirectory>
- <includes>oxm/*.xml</includes>
- </artifactItem>
- </artifactItems>
- <!-- other configurations here -->
- </configuration>
+ <phase>process-sources</phase>
</execution>
</executions>
</plugin>
@@ -820,12 +877,9 @@
versionArray = project.properties['aai.project.version'].split('\\.');
}
- if (project.properties['aai.project.version'].endsWith("-SNAPSHOT")) {
- project.properties['project.docker.latesttag.version'] = versionArray[0] + '.' + versionArray[1] + "-SNAPSHOT-latest";
- } else {
- project.properties['project.docker.latesttag.version'] = versionArray[0] + '.' + versionArray[1] + "-STAGING-latest";
- }
-
+ project.properties["project.major.version"] = versionArray[0];
+ project.properties["project.minor.version"] = versionArray[1];
+ project.properties['project.docker.latesttag.version'] = versionArray[0] + '.' + versionArray[1] + '-STAGING-latest';
println 'New Tag for docker:' + project.properties['project.docker.latesttag.version'];
</source>
</configuration>
@@ -836,19 +890,39 @@
</pluginManagement>
<plugins>
<plugin>
- <groupId>org.springframework.boot</groupId>
- <artifactId>spring-boot-maven-plugin</artifactId>
- </plugin>
- <plugin>
<groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-gpg-plugin</artifactId>
+ <artifactId>maven-clean-plugin</artifactId>
+ <version>2.4.1</version>
<configuration>
- <skip>true</skip>
+ <filesets>
+ <fileset>
+ <directory>${project.basedir}/src/main/resources/etc/oxm</directory>
+ <includes>
+ <include>**/*</include>
+ </includes>
+ <followSymlinks>false</followSymlinks>
+ </fileset>
+ <fileset>
+ <directory>${project.basedir}/src/main/resources/etc/dbedgerules</directory>
+ <includes>
+ <include>**/*</include>
+ </includes>
+ <followSymlinks>false</followSymlinks>
+ </fileset>
+ <fileset>
+ <directory>${project.basedir}/src/main/resources/schema</directory>
+ <includes>
+ <include>**/oxm/**</include>
+ <include>**/dbedgerules/**</include>
+ </includes>
+ <followSymlinks>false</followSymlinks>
+ </fileset>
+ </filesets>
</configuration>
</plugin>
<plugin>
- <groupId>org.codehaus.groovy.maven</groupId>
- <artifactId>gmaven-plugin</artifactId>
+ <groupId>org.springframework.boot</groupId>
+ <artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
<plugin>
<artifactId>exec-maven-plugin</artifactId>
@@ -857,9 +931,10 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
- <configuration>
- <additionalparam>-Xdoclint:none</additionalparam>
- </configuration>
+ </plugin>
+ <plugin>
+ <groupId>com.mycila</groupId>
+ <artifactId>license-maven-plugin</artifactId>
</plugin>
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
@@ -893,6 +968,10 @@
<version>3.3</version>
</plugin>
<plugin>
+ <groupId>org.codehaus.groovy.maven</groupId>
+ <artifactId>gmaven-plugin</artifactId>
+ </plugin>
+ <plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>0.7.9</version>
@@ -951,27 +1030,6 @@
</executions>
</plugin>
<plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-deploy-plugin</artifactId>
- <executions>
- <execution>
- <id>default-deploy</id>
- <phase>none</phase>
- </execution>
- </executions>
- </plugin>
- <plugin>
- <groupId>org.sonatype.plugins</groupId>
- <artifactId>nexus-staging-maven-plugin</artifactId>
- <version>1.6.7</version>
- <extensions>true</extensions>
- <configuration>
- <nexusUrl>${nexusproxy}</nexusUrl>
- <stagingProfileId>176c31dfe190a</stagingProfileId>
- <serverId>ecomp-staging</serverId>
- </configuration>
- </plugin>
- <plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
@@ -1013,20 +1071,39 @@
<goals>
<goal>unpack</goal>
</goals>
+ <configuration>
+ <artifactItems>
+ <artifactItem>
+ <groupId>org.onap.aai.aai-common</groupId>
+ <artifactId>aai-schema</artifactId>
+ <version>${aai.schema.version}</version>
+ <outputDirectory>${project.basedir}/src/main/resources/schema/</outputDirectory>
+ <includes>**/oxm/**/*.xml</includes>
+ </artifactItem>
+ </artifactItems>
+ <!-- other configurations here -->
+ </configuration>
+ </execution>
+ <execution>
+ <id>unpack-edgerules-dependency</id>
+ <phase>initialize</phase>
+ <goals>
+ <goal>unpack</goal>
+ </goals>
+ <configuration>
+ <artifactItems>
+ <artifactItem>
+ <groupId>org.onap.aai.aai-common</groupId>
+ <artifactId>aai-schema</artifactId>
+ <version>${aai.schema.version}</version>
+ <outputDirectory>${project.basedir}/src/main/resources/schema/</outputDirectory>
+ <includes>**/dbedgerules/**/*.json</includes>
+ </artifactItem>
+ </artifactItems>
+ <!-- other configurations here -->
+ </configuration>
</execution>
</executions>
- <configuration>
- <artifactItems>
- <artifactItem>
- <groupId>org.onap.aai.aai-common</groupId>
- <artifactId>aai-schema</artifactId>
- <version>${aai-schema.version}</version>
- <outputDirectory>src/main/resources/etc</outputDirectory>
- <includes>oxm/*.xml</includes>
- </artifactItem>
- </artifactItems>
- <!-- other configurations here -->
- </configuration>
</plugin>
<plugin>
<groupId>com.mycila</groupId>
@@ -1039,14 +1116,14 @@
<include>src/test/java/**</include>
<include>pom.xml</include>
</includes>
- <skipExistingHeaders>true</skipExistingHeaders>
+ <skipExistingHeaders>false</skipExistingHeaders>
<skip>false</skip>
</configuration>
<executions>
<execution>
<goals>
<!-- Set goal to "format" to auto update license headers -->
- <goal>check</goal>
+ <goal>${license.goal.type}</goal>
</goals>
<phase>process-sources</phase>
</execution>
@@ -1054,40 +1131,4 @@
</plugin>
</plugins>
</build>
- <reporting>
- <plugins>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-javadoc-plugin</artifactId>
- <version>2.10.4</version>
- <configuration>
- <failOnError>false</failOnError>
- <doclet>org.umlgraph.doclet.UmlGraphDoc</doclet>
- <docletArtifact>
- <groupId>org.umlgraph</groupId>
- <artifactId>umlgraph</artifactId>
- <version>5.6</version>
- </docletArtifact>
- <additionalparam>-views</additionalparam>
- <useStandardDocletOptions>true</useStandardDocletOptions>
- </configuration>
- </plugin>
- </plugins>
- </reporting>
- <distributionManagement>
- <repository>
- <id>ecomp-releases</id>
- <name>ECOMP Release Repository</name>
- <url>${nexusproxy}${release.path}</url>
- </repository>
- <snapshotRepository>
- <id>ecomp-snapshots</id>
- <name>ECOMP Snapshot Repository</name>
- <url>${nexusproxy}${snapshot.path}</url>
- </snapshotRepository>
- <site>
- <id>ecomp-site</id>
- <url>dav:${nexusproxy}${site.path}</url>
- </site>
- </distributionManagement>
</project>
diff --git a/aai-traversal/src/main/docker/Dockerfile b/aai-traversal/src/main/docker/Dockerfile
index 3d25170..bbe0aa3 100644
--- a/aai-traversal/src/main/docker/Dockerfile
+++ b/aai-traversal/src/main/docker/Dockerfile
@@ -1,4 +1,4 @@
-FROM aaionap/aai-common:1.2.0
+FROM aaionap/aai-common:1.3.0
# Add the proper files into the docker image from your build
@@ -8,6 +8,7 @@ WORKDIR /opt/app/aai-traversal
# 8446 is the important one to be used
EXPOSE 8446
+
HEALTHCHECK --interval=40s --timeout=10s --retries=3 CMD nc -z -v localhost 8446 || exit 1
ENTRYPOINT ["/bin/bash", "/opt/app/aai-traversal/docker-entrypoint.sh"]
@@ -16,6 +17,9 @@ RUN mkdir -p /opt/aaihome/aaiadmin /opt/aai/logroot/AAI-GQ
VOLUME /opt/aai/logroot/AAI-GQ
+VOLUME /tmp
+VOLUME /opt/tools
+
COPY /maven/aai-traversal/ .
ENV AAI_BUILD_VERSION @aai.docker.version@
diff --git a/aai-traversal/src/main/docker/docker-entrypoint.sh b/aai-traversal/src/main/docker/docker-entrypoint.sh
index ea5ac6b..4dc703b 100644
--- a/aai-traversal/src/main/docker/docker-entrypoint.sh
+++ b/aai-traversal/src/main/docker/docker-entrypoint.sh
@@ -28,9 +28,6 @@ export CHEF_DATA_GIT_URL=${CHEF_DATA_GIT_URL:-$CHEF_GIT_URL};
export SERVER_PORT=${SERVER_PORT:-8446};
-export RESOURCES_HOSTNAME=${RESOURCES_HOSTNAME:-aai-resources.api.simpledemo.onap.org};
-export RESOURCES_PORT=${RESOURCES_PORT:-8447};
-
USER_ID=${LOCAL_USER_ID:-9001}
GROUP_ID=${LOCAL_GROUP_ID:-9001}
@@ -52,7 +49,6 @@ if [ -f ${APP_HOME}/aai.sh ]; then
gosu aaiadmin ln -s bin scripts
gosu aaiadmin ln -s /opt/aai/logroot/AAI-GQ logs
-
mv ${APP_HOME}/aai.sh /etc/profile.d/aai.sh
chmod 755 /etc/profile.d/aai.sh
@@ -74,6 +70,7 @@ if [ -f ${APP_HOME}/aai.sh ]; then
exit 0;
fi;
+
fi;
if [ -z ${DISABLE_UPDATE_QUERY} ]; then
@@ -82,23 +79,30 @@ if [ -z ${DISABLE_UPDATE_QUERY} ]; then
gosu aaiadmin touch ${UPDATE_QUERY_RAN_FILE};
fi
+mkdir -p /opt/app/aai-traversal/logs/gc
+chown -R aaiadmin:aaiadmin /opt/app/aai-traversal/logs/gc
+
+if [ -f ${APP_HOME}/resources/aai-traversal-swm-vars.sh ]; then
+ source ${APP_HOME}/resources/aai-traversal-swm-vars.sh;
+fi;
+
+MIN_HEAP_SIZE=${MIN_HEAP_SIZE:-512m};
+MAX_HEAP_SIZE=${MAX_HEAP_SIZE:-1024m};
+MAX_PERM_SIZE=${MAX_PERM_SIZE:-512m};
+PERM_SIZE=${PERM_SIZE:-512m}
+
JAVA_CMD="exec gosu aaiadmin java";
-JVM_OPTS="${PRE_JVM_OPTS} -XX:+UnlockDiagnosticVMOptions";
-JVM_OPTS="${JVM_OPTS} -XX:+UnsyncloadClass";
-JVM_OPTS="${JVM_OPTS} -XX:+UseConcMarkSweepGC";
-JVM_OPTS="${JVM_OPTS} -XX:+CMSParallelRemarkEnabled";
-JVM_OPTS="${JVM_OPTS} -XX:+UseCMSInitiatingOccupancyOnly";
-JVM_OPTS="${JVM_OPTS} -XX:CMSInitiatingOccupancyFraction=70";
-JVM_OPTS="${JVM_OPTS} -XX:+ScavengeBeforeFullGC";
-JVM_OPTS="${JVM_OPTS} -XX:+CMSScavengeBeforeRemark";
-JVM_OPTS="${JVM_OPTS} -XX:-HeapDumpOnOutOfMemoryError";
-JVM_OPTS="${JVM_OPTS} -XX:+UseParNewGC";
-JVM_OPTS="${JVM_OPTS} -verbose:gc";
+JVM_OPTS="${PRE_JVM_ARGS} -Xloggc:/opt/app/aai-traversal/logs/gc/aai_gc.log";
+JVM_OPTS="${JVM_OPTS} -XX:HeapDumpPath=/opt/app/aai-traversal/logs/ajsc-jetty/heap-dump";
+JVM_OPTS="${JVM_OPTS} -Xms${MIN_HEAP_SIZE}";
+JVM_OPTS="${JVM_OPTS} -Xmx${MAX_HEAP_SIZE}";
+
JVM_OPTS="${JVM_OPTS} -XX:+PrintGCDetails";
JVM_OPTS="${JVM_OPTS} -XX:+PrintGCTimeStamps";
-JVM_OPTS="${JVM_OPTS} -XX:MaxPermSize=512M";
-JVM_OPTS="${JVM_OPTS} -XX:PermSize=512M";
+JVM_OPTS="${JVM_OPTS} -XX:MaxPermSize=${MAX_PERM_SIZE}";
+JVM_OPTS="${JVM_OPTS} -XX:PermSize=${PERM_SIZE}";
+
JVM_OPTS="${JVM_OPTS} -server";
JVM_OPTS="${JVM_OPTS} -XX:NewSize=512m";
JVM_OPTS="${JVM_OPTS} -XX:MaxNewSize=512m";
@@ -114,11 +118,9 @@ JVM_OPTS="${JVM_OPTS} -XX:ParallelGCThreads=4";
JVM_OPTS="${JVM_OPTS} -XX:LargePageSizeInBytes=128m";
JVM_OPTS="${JVM_OPTS} -XX:+PrintGCDetails";
JVM_OPTS="${JVM_OPTS} -XX:+PrintGCTimeStamps";
-JVM_OPTS="${JVM_OPTS} -Xloggc:/opt/app/aai-traversal/logs/ajsc-jetty/gc/aai_gc.log";
JVM_OPTS="${JVM_OPTS} -Dsun.net.inetaddr.ttl=180";
JVM_OPTS="${JVM_OPTS} -XX:+HeapDumpOnOutOfMemoryError";
-JVM_OPTS="${JVM_OPTS} -XX:HeapDumpPath=/opt/app/aai-traversal/logs/ajsc-jetty/heap-dump";
-JVM_OPTS="${JVM_OPTS} ${POST_JVM_OPTS}";
+JVM_OPTS="${JVM_OPTS} ${POST_JVM_ARGS}";
JAVA_OPTS="${PRE_JAVA_OPTS} -DAJSC_HOME=$APP_HOME";
JAVA_OPTS="${JAVA_OPTS} -Dserver.port=${SERVER_PORT}";
@@ -127,9 +129,9 @@ JAVA_OPTS="${JAVA_OPTS} -Dserver.local.startpath=${RESOURCES_HOME}";
JAVA_OPTS="${JAVA_OPTS} -DAAI_CHEF_ENV=${AAI_CHEF_ENV}";
JAVA_OPTS="${JAVA_OPTS} -DSCLD_ENV=${SCLD_ENV}";
JAVA_OPTS="${JAVA_OPTS} -DAFT_ENVIRONMENT=${AFT_ENVIRONMENT}";
-JAVA_OPTS="${JAVA_OPTS} -DlrmName=com.att.ajsc.traversal";
-JAVA_OPTS="${JAVA_OPTS} -DAAI_BUILD_NUMBER=${AAI_BUILD_NUMBER}";
+JAVA_OPTS="${JAVA_OPTS} -DAAI_BUILD_VERSION=${AAI_BUILD_VERSION}";
JAVA_OPTS="${JAVA_OPTS} -Djava.security.egd=file:/dev/./urandom";
+JAVA_OPTS="${JAVA_OPTS} -Dlogback.configurationFile=./resources/logback.xml";
JAVA_OPTS="${JAVA_OPTS} -Dloader.path=$APP_HOME/resources";
JAVA_OPTS="${JAVA_OPTS} ${POST_JAVA_OPTS}";
diff --git a/aai-traversal/src/main/java/org/onap/aai/TraversalApp.java b/aai-traversal/src/main/java/org/onap/aai/TraversalApp.java
index 6fdf3b0..2797545 100644
--- a/aai-traversal/src/main/java/org/onap/aai/TraversalApp.java
+++ b/aai-traversal/src/main/java/org/onap/aai/TraversalApp.java
@@ -22,10 +22,12 @@ package org.onap.aai;
import com.att.eelf.configuration.EELFLogger;
import com.att.eelf.configuration.EELFManager;
import org.onap.aai.config.PropertyPasswordConfiguration;
+import org.onap.aai.config.SpringContextAware;
import org.onap.aai.dbmap.AAIGraph;
import org.onap.aai.exceptions.AAIException;
-import org.onap.aai.introspection.ModelInjestor;
import org.onap.aai.logging.LoggingContext;
+import org.onap.aai.logging.LoggingContext.StatusCode;
+import org.onap.aai.nodes.NodeIngestor;
import org.onap.aai.util.AAIConfig;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.SpringApplication;
@@ -36,10 +38,12 @@ import org.springframework.boot.autoconfigure.jdbc.DataSourceTransactionManagerA
import org.springframework.boot.autoconfigure.orm.jpa.HibernateJpaAutoConfiguration;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.core.env.Environment;
+import org.slf4j.MDC;
import javax.annotation.PostConstruct;
import javax.annotation.PreDestroy;
import java.util.UUID;
+import java.util.Map;
@SpringBootApplication
// Component Scan provides a way to look for spring beans
@@ -49,11 +53,12 @@ import java.util.UUID;
@ComponentScan(basePackages = {
"org.onap.aai.config",
"org.onap.aai.web",
+ "org.onap.aai.setup",
"org.onap.aai.tasks",
"org.onap.aai.service",
- "org.onap.aai.rest",
- "com.att.ajsc.common"
+ "org.onap.aai.rest"
})
+
@EnableAutoConfiguration(exclude = {
DataSourceAutoConfiguration.class,
DataSourceTransactionManagerAutoConfiguration.class,
@@ -64,10 +69,21 @@ public class TraversalApp {
private static final EELFLogger logger = EELFManager.getInstance().getLogger(TraversalApp.class.getName());
private static final String APP_NAME = "aai-traversal";
-
+ private static Map<String,String> contextMap;
+
@Autowired
private Environment env;
+ @Autowired
+ private NodeIngestor nodeIngestor;
+
+ @Autowired
+ private SpringContextAware context;
+
+ @Autowired
+ private SpringContextAware loaderFactory;
+
+
@PostConstruct
private void init() throws AAIException {
System.setProperty("org.onap.aai.serverStarted", "false");
@@ -80,6 +96,8 @@ public class TraversalApp {
LoggingContext.requestId(UUID.randomUUID().toString());
LoggingContext.serviceName(APP_NAME);
LoggingContext.targetServiceName("contextInitialized");
+ LoggingContext.statusCode(StatusCode.COMPLETE);
+ contextMap = MDC.getCopyOfContextMap();
logger.info("AAI Server initialization started...");
@@ -87,14 +105,14 @@ public class TraversalApp {
// This is only needed for tomcat keeping this as temporary
System.setProperty("org.apache.tomcat.util.buf.UDecoder.ALLOW_ENCODED_SLASH", "true");
- logger.info("Starting AAIGraph connections and the ModelInjestor");
+ logger.info("Starting AAIGraph connections and the NodeInjestor");
if(env.acceptsProfiles(Profiles.TWO_WAY_SSL) && env.acceptsProfiles(Profiles.ONE_WAY_SSL)){
logger.warn("You have seriously misconfigured your application");
}
AAIConfig.init();
- ModelInjestor.getInstance();
+
AAIGraph.getInstance();
}
@@ -108,10 +126,11 @@ public class TraversalApp {
setDefaultProps();
SpringApplication app = new SpringApplication(TraversalApp.class);
+ app.setLogStartupInfo(false);
app.setRegisterShutdownHook(true);
app.addInitializers(new PropertyPasswordConfiguration());
Environment env = app.run(args).getEnvironment();
-
+ MDC.setContextMap (contextMap);
logger.info(
"Application '{}' is running on {}!" ,
env.getProperty("spring.application.name"),
diff --git a/aai-traversal/src/test/java/org/onap/aai/retiredcustomer/V3ThroughV7ConsumerTest.java b/aai-traversal/src/main/java/org/onap/aai/config/DslConfiguration.java
index 8c3285a..74bc046 100644
--- a/aai-traversal/src/test/java/org/onap/aai/retiredcustomer/V3ThroughV7ConsumerTest.java
+++ b/aai-traversal/src/main/java/org/onap/aai/config/DslConfiguration.java
@@ -17,16 +17,28 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
-package org.onap.aai.retiredcustomer;
+package org.onap.aai.config;
-import org.onap.aai.rest.retired.RetiredConsumer;
-import org.onap.aai.rest.retired.V3ThroughV7Consumer;
+import org.onap.aai.edges.EdgeIngestor;
+import org.onap.aai.rest.dsl.DslListener;
+import org.onap.aai.rest.dsl.DslQueryProcessor;
+import org.springframework.beans.factory.config.ConfigurableBeanFactory;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.context.annotation.Scope;
+@Configuration
+public class DslConfiguration {
-public class V3ThroughV7ConsumerTest extends RetiredConsumerTest {
+ @Bean
+ @Scope(scopeName = ConfigurableBeanFactory.SCOPE_PROTOTYPE)
+ public DslListener dslListener(EdgeIngestor edgeIngestor){
+ return new DslListener(edgeIngestor);
+ }
- @Override
- public RetiredConsumer getRetiredConsumer() {
- return new V3ThroughV7Consumer();
+ @Bean
+ @Scope(scopeName = ConfigurableBeanFactory.SCOPE_PROTOTYPE)
+ public DslQueryProcessor dslQueryProcessor(DslListener dslListener){
+ return new DslQueryProcessor(dslListener);
}
}
diff --git a/aai-traversal/src/main/java/org/onap/aai/config/ErrorHandler.java b/aai-traversal/src/main/java/org/onap/aai/config/ErrorHandler.java
new file mode 100644
index 0000000..22e12a6
--- /dev/null
+++ b/aai-traversal/src/main/java/org/onap/aai/config/ErrorHandler.java
@@ -0,0 +1,87 @@
+/**
+ * ============LICENSE_START=======================================================
+ * org.onap.aai
+ * ================================================================================
+ * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY 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.config;
+
+import org.onap.aai.exceptions.AAIException;
+import org.onap.aai.logging.ErrorLogHelper;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.core.annotation.Order;
+import org.springframework.stereotype.Component;
+import org.springframework.web.filter.OncePerRequestFilter;
+
+import javax.servlet.FilterChain;
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import javax.ws.rs.core.MediaType;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * Responsible for dealing with uri that doesn't start with basePath
+ * All of the other interceptors will handle any uri that starts with basePath
+ * So we need this to ensure that these cases are properly handled
+ */
+@Order(1)
+@Component
+public class ErrorHandler extends OncePerRequestFilter {
+
+ private String basePath;
+
+ public ErrorHandler(@Value("${schema.uri.base.path}") String basePath){
+ this.basePath = basePath;
+ if(!basePath.endsWith("/")){
+ this.basePath = basePath + "/";
+ }
+ }
+
+ @Override
+ protected void doFilterInternal(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse, FilterChain filterChain) throws ServletException, IOException {
+
+ String uri = httpServletRequest.getRequestURI();
+
+ if (uri != null && !(uri.startsWith(basePath))) {
+
+ AAIException e = new AAIException("AAI_3012");
+ ArrayList<String> templateVars = new ArrayList<>();
+
+ List<MediaType> mediaTypeList = new ArrayList<>();
+
+ String acceptHeader = httpServletRequest.getHeader("Accept");
+ if (acceptHeader == null) {
+ mediaTypeList.add(MediaType.APPLICATION_XML_TYPE);
+ } else {
+ mediaTypeList.add(MediaType.valueOf(acceptHeader));
+ }
+
+ String message = ErrorLogHelper.getRESTAPIErrorResponse(mediaTypeList, e, templateVars);
+
+ httpServletResponse.setStatus(400);
+ httpServletResponse.setContentType(mediaTypeList.get(0).toString());
+ httpServletResponse.getWriter().print(message);
+ httpServletResponse.getWriter().close();
+ return;
+ }
+
+ filterChain.doFilter(httpServletRequest, httpServletResponse);
+ }
+
+}
diff --git a/aai-traversal/src/main/java/org/onap/aai/config/SearchConfiguration.java b/aai-traversal/src/main/java/org/onap/aai/config/SearchConfiguration.java
new file mode 100644
index 0000000..bef10d0
--- /dev/null
+++ b/aai-traversal/src/main/java/org/onap/aai/config/SearchConfiguration.java
@@ -0,0 +1,50 @@
+/**
+ * ============LICENSE_START=======================================================
+ * org.onap.aai
+ * ================================================================================
+ * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY 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.config;
+
+import org.onap.aai.dbgraphmap.SearchGraph;
+
+import org.onap.aai.edges.EdgeIngestor;
+import org.onap.aai.introspection.LoaderFactory;
+import org.onap.aai.rest.dsl.DslListener;
+import org.onap.aai.rest.dsl.DslQueryProcessor;
+import org.onap.aai.rest.search.GremlinServerSingleton;
+import org.onap.aai.setup.SchemaVersions;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.beans.factory.config.ConfigurableBeanFactory;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.context.annotation.Scope;
+
+@Configuration
+public class SearchConfiguration {
+
+ @Bean
+ public SearchGraph searchGraph(LoaderFactory loaderFactory, EdgeIngestor edgeIngestor, SchemaVersions schemaVersions) {
+ SearchGraph searchGraph = new SearchGraph(loaderFactory, edgeIngestor, schemaVersions);
+ return searchGraph;
+ }
+
+ @Bean
+ public GremlinServerSingleton gremlinServerSingleton(){
+ return new GremlinServerSingleton();
+ }
+
+}
diff --git a/aai-traversal/src/main/java/org/onap/aai/dbgraphgen/ModelBasedProcessing.java b/aai-traversal/src/main/java/org/onap/aai/dbgraphgen/ModelBasedProcessing.java
index 1f7a75f..dc42120 100644
--- a/aai-traversal/src/main/java/org/onap/aai/dbgraphgen/ModelBasedProcessing.java
+++ b/aai-traversal/src/main/java/org/onap/aai/dbgraphgen/ModelBasedProcessing.java
@@ -32,17 +32,22 @@ import org.apache.tinkerpop.gremlin.structure.VertexProperty;
import org.onap.aai.db.DbMethHelper;
import org.onap.aai.db.props.AAIProperties;
import org.onap.aai.dbgen.PropertyLimitDesc;
+import org.onap.aai.edges.EdgeIngestor;
+import org.onap.aai.edges.EdgeRuleQuery;
+import org.onap.aai.edges.enums.EdgeType;
import org.onap.aai.exceptions.AAIException;
import org.onap.aai.introspection.Introspector;
import org.onap.aai.introspection.Loader;
import org.onap.aai.introspection.exceptions.AAIUnknownObjectException;
+import org.onap.aai.logging.LogFormatTools;
import org.onap.aai.query.builder.QueryBuilder;
import org.onap.aai.schema.enums.PropertyMetadata;
import org.onap.aai.serialization.db.DBSerializer;
-import org.onap.aai.serialization.db.EdgeRules;
-import org.onap.aai.serialization.db.EdgeType;
+
import org.onap.aai.serialization.engines.TransactionalGraphEngine;
import org.onap.aai.util.AAIConfig;
+import org.onap.aai.concurrent.AaiCallable;
+import org.onap.aai.config.SpringContextAware;
import java.util.*;
import java.util.concurrent.Callable;
@@ -60,9 +65,9 @@ public class ModelBasedProcessing {
private Loader loader;
private DBSerializer serializer;
private DbMethHelper dbMethHelper;
-
+
protected ModelBasedProcessing() {
-
+
}
public ModelBasedProcessing(Loader loader, TransactionalGraphEngine engine, DBSerializer serializer) {
this.loader = loader;
@@ -85,25 +90,25 @@ public class ModelBasedProcessing {
* @throws AAIException the AAI exception
*/
public Map<String,String> getStartNodesAndModVersionIds( String transId, String fromAppId,
- String passedModelVersionId,
+ String passedModelVersionId,
String passedModelInvId,
String passedModelName,
String passedTopNodeType,
- List<Map<String,Object>> startNodeFilterArrayOfHashes,
- String apiVer )
+ List<Map<String,Object>> startNodeFilterArrayOfHashes,
+ String apiVer )
throws AAIException {
// ----------------------------------------------------------------------------------------------------
// Get a hash for all start-nodes (key = vtxId, val = modelVersionId that applies)
- // If no start-node-key info is passed, then use either the passed modelVersion or
+ // If no start-node-key info is passed, then use either the passed modelVersion or
// the passed model-invariant-id or model-name to collect them.
- // If start-node-key info is given, use it instead to look for start-nodes.
- // Note: if ONLY start-node-key info is given, then it would have to map to nodes which
+ // If start-node-key info is given, use it instead to look for start-nodes.
+ // Note: if ONLY start-node-key info is given, then it would have to map to nodes which
// have persona data. Otherwise we'd have no way to know what model to collect data with.
// ----------------------------------------------------------------------------------------------------
Iterator<Vertex> startVerts = null;
Map<String, String> startVertInfo = new HashMap<>();
-
+
if( startNodeFilterArrayOfHashes.isEmpty() ){
// Since they did not give any data to find start instances, we will have to find them
// using whatever model-info they provided so we can use it to map to persona-data in the db.
@@ -125,7 +130,7 @@ public class ModelBasedProcessing {
if( calcModId != null ){
startVerts = this.engine.asAdmin().getReadOnlyTraversalSource().V().has(addDBAliasedSuffix("model-invariant-id"),calcModId).has(addDBAliasedSuffix("model-version-id"),passedModelVersionId);
}
- }
+ }
else if( passedModelInvId != null && !passedModelInvId.equals("") ){
// They gave us the model-invariant-id
startVerts = this.engine.asAdmin().getReadOnlyTraversalSource().V().has(addDBAliasedSuffix("model-invariant-id"),passedModelInvId);
@@ -138,11 +143,11 @@ public class ModelBasedProcessing {
for( int i = 0; i < modelVerVtxList.size(); i++ ){
String calcModVerId = (modelVerVtxList.get(i)).<String>property("model-version-id").orElse(null);
Vertex modVtx = getModelGivenModelVer(modelVerVtxList.get(i),"");
- String calcModInvId = modVtx.<String>property("model-invariant-id").orElse(null);
+ String calcModInvId = modVtx.<String>property("model-invariant-id").orElse(null);
// Now we can look up instances that match this model's info
Iterator<Vertex> tmpStartIter = this.engine.asAdmin().getReadOnlyTraversalSource().V().has(addDBAliasedSuffix("model-invariant-id"),calcModInvId).has(addDBAliasedSuffix("model-version-id"),calcModVerId);
while( tmpStartIter.hasNext() ){
- Vertex tmpStartVert = tmpStartIter.next();
+ Vertex tmpStartVert = (Vertex) tmpStartIter.next();
startVtxList.add(tmpStartVert);
}
}
@@ -150,12 +155,12 @@ public class ModelBasedProcessing {
if( !startVtxList.isEmpty() ){
startVerts = startVtxList.iterator();
}
- }
+ }
}
-
- if( startVerts != null ){
+
+ if( startVerts != null ){
while( startVerts.hasNext() ){
- Vertex tmpStartVert = startVerts.next();
+ Vertex tmpStartVert = (Vertex) startVerts.next();
String vid = tmpStartVert.id().toString();
String tmpModId = tmpStartVert.<String>property(addDBAliasedSuffix("model-invariant-id")).orElse(null);
String tmpModVerId = tmpStartVert.<String>property(addDBAliasedSuffix("model-version-id")).orElse(null);
@@ -164,12 +169,12 @@ public class ModelBasedProcessing {
}
if( startVertInfo.isEmpty() ){
throw new AAIException("AAI_6114", "Start Node(s) could not be found for model data passed. " +
- "(modelVersionId = [" + passedModelVersionId +
+ "(modelVersionId = [" + passedModelVersionId +
"], modelInvariantId = [" + passedModelInvId +
"], modelName = [" + passedModelName +
"])");
}
-
+
return startVertInfo;
}
else {
@@ -179,17 +184,17 @@ public class ModelBasedProcessing {
String modInfoStr = "";
if( passedModelVersionId != null && !passedModelVersionId.equals("") ){
modTopNodeType = getModelVerTopWidgetType( transId, fromAppId, passedModelVersionId, "", "" );
- modInfoStr = "modelVersionId = (" + passedModelVersionId + ")";
+ modInfoStr = "modelVersionId = (" + passedModelVersionId + ")";
}
else if( passedModelInvId != null && !passedModelInvId.equals("") ){
modTopNodeType = getModelVerTopWidgetType( transId, fromAppId,"", passedModelInvId, "" );
- modInfoStr = "modelId = (" + passedModelInvId + ")";
+ modInfoStr = "modelId = (" + passedModelInvId + ")";
}
else if( passedModelName != null && !passedModelName.equals("") ){
modTopNodeType = getModelVerTopWidgetType( transId, fromAppId,"", "", passedModelName );
- modInfoStr = "modelName = (" + passedModelName + ")";
+ modInfoStr = "modelName = (" + passedModelName + ")";
}
-
+
if( modTopNodeType.equals("") ){
if( (passedTopNodeType == null) || passedTopNodeType.equals("") ){
String msg = "Could not determine the top-node nodeType for this request. modelInfo: [" + modInfoStr + "]";
@@ -202,16 +207,16 @@ public class ModelBasedProcessing {
}
}
else {
- // we did get a topNode type based on model info - make sure it doesn't contradict
+ // we did get a topNode type based on model info - make sure it doesn't contradict
// the passsed-in one (if there is one)
- if( passedTopNodeType != null && !passedTopNodeType.equals("")
+ if( passedTopNodeType != null && !passedTopNodeType.equals("")
&& !passedTopNodeType.equals(modTopNodeType) ){
throw new AAIException("AAI_6120", "topNodeType passed in [" + passedTopNodeType
+ "] does not match nodeType derived for model info passed in: ["
- + modTopNodeType + "]");
+ + modTopNodeType + "]");
}
}
-
+
List<String> modelVersionIds2Check = new ArrayList<>();
if( (passedModelName != null && !passedModelName.equals("")) ){
// They passed a modelName, so find all the model UUIDs (model-version-id's) that map to this
@@ -231,7 +236,7 @@ public class ModelBasedProcessing {
modelVersionIds2Check.add(passedModelVersionId);
}
}
-
+
// We should now be OK with our topNodeType for this request, so we can look for the actual startNodes
for( int i=0; i < startNodeFilterArrayOfHashes.size(); i++ ){
// Locate the starting node which will be used to look which corresponds to this set of filter data
@@ -244,42 +249,42 @@ public class ModelBasedProcessing {
startVtx = result.get();
}
catch( AAIException e ){
- String msg = "Could not find startNode of type = [" + modTopNodeType + "], given these params: "
+ String msg = "Could not find startNode of type = [" + modTopNodeType + "], given these params: "
+ startNodeFilterArrayOfHashes.get(i) + ". msg # from getUniqueNode() = " + e.getMessage();
throw new AAIException("AAI_6114", msg);
}
-
+
String vid = startVtx.id().toString();
String personaModInvId = startVtx.<String>property(addDBAliasedSuffix("model-invariant-id")).orElse(null);
String personaModVerId = startVtx.<String>property(addDBAliasedSuffix("model-version-id")).orElse(null);
-
+
// Either this start-node has persona info (which should not contradict any passed-in model info)
// or they should have passed in the model to use - so we'd just use that.
if( personaModVerId != null && !personaModVerId.equals("") ){
// There is persona data in this start-node. So make sure it doesn't contradict any "passed" stuff
- if( modelVersionIds2Check.isEmpty()
+ if( modelVersionIds2Check.isEmpty()
&& (passedModelInvId == null || passedModelInvId.equals("")) ){
// They didn't pass any model info, so use the persona one.
startVertInfo.put(vid, personaModVerId);
}
- else if( modelVersionIds2Check.isEmpty()
+ else if( modelVersionIds2Check.isEmpty()
&& (passedModelInvId != null && !passedModelInvId.equals("")) ){
// They passed in just the modelId - so check it
if( passedModelInvId.equals(personaModInvId) ){
startVertInfo.put(vid, personaModVerId);
}
}
- else if( !modelVersionIds2Check.isEmpty()
+ else if( !modelVersionIds2Check.isEmpty()
&& (passedModelInvId == null || passedModelInvId.equals("")) ){
// They passed in just modelVersionId - so check
if( modelVersionIds2Check.contains(personaModVerId) ){
startVertInfo.put(vid, personaModVerId);
}
- }
- else if( !modelVersionIds2Check.isEmpty()
+ }
+ else if( !modelVersionIds2Check.isEmpty()
&& (passedModelInvId != null && !passedModelInvId.equals("")) ){
- // We have BOTH a modelVersionIds and a modelId to check
- if( passedModelInvId.equals(personaModInvId)
+ // We have BOTH a modelVersionIds and a modelId to check
+ if( passedModelInvId.equals(personaModInvId)
&& modelVersionIds2Check.contains(personaModVerId) ){
startVertInfo.put(vid, personaModVerId);
}
@@ -293,14 +298,16 @@ public class ModelBasedProcessing {
}
else {
throw new AAIException("AAI_6118", "Found startNode but since it does not have persona data, the " +
- " model-version-id is required. ");
+ " model-version-id is required. ");
}
}
}
}
+
return startVertInfo;
- }
-
+
+ }//end of getStartNodesAndModVersionIds()
+
/**
* Query by model. (really model-ver)
@@ -324,16 +331,16 @@ public class ModelBasedProcessing {
List<Map<String,Object>> startNodeFilterArrayOfHashes,
String apiVer )
throws AAIException {
-
+
final String transId_f = transId;
final String fromAppId_f = fromAppId;
final String modelVersionId_f = modelVersionId;
final String modelInvId_f = modelInvariantId;
final String modelName_f = modelName;
final String topNodeType_f = topNodeType;
- final List<Map<String,Object>> startNodeFilterArrayOfHashes_f = startNodeFilterArrayOfHashes;
- final String apiVer_f = apiVer;
-
+ final List<Map<String,Object>> startNodeFilterArrayOfHashes_f = startNodeFilterArrayOfHashes;
+ final String apiVer_f = apiVer;
+
// Find out what our time-limit should be
int timeLimitSec = 0;
String timeLimitString = AAIConfig.get("aai.model.query.timeout.sec");
@@ -345,33 +352,34 @@ public class ModelBasedProcessing {
// Don't worry, we will leave the limit as zero - which tells us not to use it.
}
}
-
+
if( timeLimitSec <= 0 ){
// We will NOT be using a timer
return queryByModel_Timed( transId, fromAppId,
- modelVersionId,
+ modelVersionId,
modelInvariantId,
modelName,
topNodeType,
- startNodeFilterArrayOfHashes,
+ startNodeFilterArrayOfHashes,
apiVer );
}
-
+
List<ResultSet> resultList = new ArrayList<>();
TimeLimiter limiter = new SimpleTimeLimiter();
try {
- resultList = limiter.callWithTimeout(new Callable <List<ResultSet>>() {
- public List<ResultSet> call() throws AAIException {
+
+ resultList = limiter.callWithTimeout(new AaiCallable <List<ResultSet>>() {
+ public List<ResultSet> process() throws AAIException {
return queryByModel_Timed( transId_f, fromAppId_f,
- modelVersionId_f,
+ modelVersionId_f,
modelInvId_f,
modelName_f,
topNodeType_f,
- startNodeFilterArrayOfHashes_f,
+ startNodeFilterArrayOfHashes_f,
apiVer_f );
}
}, timeLimitSec, TimeUnit.SECONDS, true);
- }
+ }
catch (AAIException ae) {
// Re-throw AAIException so we get can tell what happened internally
throw ae;
@@ -382,10 +390,11 @@ public class ModelBasedProcessing {
catch (Exception e) {
throw new AAIException("AAI_6128", "Unexpected exception in queryByModel(): " + e.getMessage() );
}
+
return resultList;
}
-
-
+
+
/**
* Query by model (model-ver) timed.
*
@@ -408,28 +417,28 @@ public class ModelBasedProcessing {
List<Map<String,Object>> startNodeFilterArrayOfHashesVal,
String apiVer )
throws AAIException {
-
+
List<ResultSet> resultArray = new ArrayList<>();
-
+
// NOTE: this method can be used for different styles of queries:
// a) They could pass neither a modelVersionId or a modelInvariantId but just pass a set of data defining start-nodes.
// Note - with no model info, we need them to pass the startNodeType for us to be able to use the
- // start-node-filter data. We would look at each start node and ensure that each has persona-model info.
+ // start-node-filter data. We would look at each start node and ensure that each has persona-model info.
// Then use whatever model corresponds to each instance to pull that instance's data.
// b) They could pass a modelInvariantId, but no modelVersionId and no startNode info. In this case, we
- // Would look in the database for all nodes that have a model-invariant-id-local that matches what was
+ // Would look in the database for all nodes that have a model-invariant-id-local that matches what was
// passed, and then for each of those instances, pull the data based on the corresponding model.
- // c) They could pass a model-version-id, but no startNode info. We'd make sure that if a
+ // c) They could pass a model-version-id, but no startNode info. We'd make sure that if a
// model-invariant-id was also passed, that it does not conflict - but it really should be null if they
// are passing a full model-version-id. Like case -b-, we'd do a query for all nodes
- // that have persona info that corresponds to the model-version-id passed and then
+ // that have persona info that corresponds to the model-version-id passed and then
// collect data for each one.
// d) They could pass either modelVersionId or modelInvariantId AND startNodeFilter info. In this case we
- // would look at the model info to figure out what the top-node-type is, then look at the
+ // would look at the model info to figure out what the top-node-type is, then look at the
// top-node instances based on the startNodeFilter. We'd only collect data for each instance if
// it's persona model info matches what was passed in.
-
-
+
+
// Sorry to do this, but code that gets called with an empty hash as the first array element was causing errors
List<Map<String,Object>> startNodeFilterArrayOfHashes = new ArrayList <Map<String,Object>>();
if( !startNodeFilterArrayOfHashesVal.isEmpty() ){
@@ -440,21 +449,21 @@ public class ModelBasedProcessing {
}
}
}
-
+
// ----------------------------------------------------------------------------------------------------------
- // Get a Hash of all the start-nodes (top instance-data node for a model-ver where we will
- // start collecting data) for startNode2ModelVerHash:
- // key = vertex-id for the startNode,
- // value = model-version-id for the corresponding model-ver
+ // Get a Hash of all the start-nodes (top instance-data node for a model-ver where we will
+ // start collecting data) for startNode2ModelVerHash:
+ // key = vertex-id for the startNode,
+ // value = model-version-id for the corresponding model-ver
// ----------------------------------------------------------------------------------------------------------
Map<String, String> startNode2ModelVerHash = getStartNodesAndModVersionIds( transId, fromAppId,
modelVersionId, modelInvariantId, modelName, topNodeType,
- startNodeFilterArrayOfHashes, apiVer );
-
- //System.out.println("\nDEBUG -- Here's a dump of the startnodes/model-vers: " + startNode2ModelVerHash.toString());
-
+ startNodeFilterArrayOfHashes, apiVer );
+
+ //System.out.println("\nDEBUG -- Here's a dump of the startnodes/model-vers: " + startNode2ModelVerHash.toString());
+
// --------------------------------------------------------------------------------------------------------
- // Figure out what-all models (model-ver nodes) we will be dealing with
+ // Figure out what-all models (model-ver nodes) we will be dealing with
// Note - Instances must all use the same type of start-node, but do not have to all use the same model-ver.
// --------------------------------------------------------------------------------------------------------
Map<String, Vertex> distinctModelVersHash = new HashMap<>();
@@ -469,7 +478,7 @@ public class ModelBasedProcessing {
Set <String> snKeySet = startNode2ModelVerHash.keySet();
Iterator<String> startNodeIterator = snKeySet.iterator();
while( startNodeIterator.hasNext() ){
- String modVerIdKey = startNodeIterator.next();
+ String modVerIdKey = (String) startNodeIterator.next();
String modVerId = startNode2ModelVerHash.get(modVerIdKey);
if( !distinctModelVersHash.containsKey(modVerId) ){
// First time seeing this model-version-id
@@ -487,7 +496,7 @@ public class ModelBasedProcessing {
System.out.println(">>> WARNING - will not collect model data for this vertex since " +
"it uses an inconsistant model-ver model. Model-version-id = " + modVerId );
}
-
+
if( tmpNodeType != null && !tmpNodeType.equals("") ){
if( startNodeType.equals("") ){
startNodeType = tmpNodeType;
@@ -501,12 +510,12 @@ public class ModelBasedProcessing {
}
}
}
-
+
//System.out.println("\nDEBUG -- Here's a dump of the DISTINCT model-ver hash: " + distinctModelVersHash.toString() );
-
+
// ------------------------------------------------------------------------------------------------------
// Get the "valid-next-step" hash for each distinct model-ver
- // While we're at it, get a mapping of model-invariant-id|model-version to model-version-id for
+ // While we're at it, get a mapping of model-invariant-id|model-version to model-version-id for
// the model-vers being used
// ------------------------------------------------------------------------------------------------------
Map<String, Multimap<String, String>> validNextStepHash = new HashMap<>();
@@ -514,46 +523,46 @@ public class ModelBasedProcessing {
Set <String> keySet = distinctModelVersHash.keySet();
Iterator<String> modelVerIterator = keySet.iterator();
while( modelVerIterator.hasNext() ){
- String modVerKey = modelVerIterator.next();
+ String modVerKey = (String) modelVerIterator.next();
if( ! skipModelVerIdList.contains(modVerKey) ){
- Vertex modelVerVtx = distinctModelVersHash.get(modVerKey);
+ Vertex modelVerVtx = (Vertex)distinctModelVersHash.get(modVerKey);
Multimap<String, String> tmpTopoMap = genTopoMap4ModelVer( transId, fromAppId,
modelVerVtx, modVerKey);
validNextStepHash.put(modVerKey, tmpTopoMap);
}
- }
-
+ }
+
// -------------------------------------------------------------------------------------------------
- // Figure out what the "start-node" for each instance will be (plus the info we will use to
+ // Figure out what the "start-node" for each instance will be (plus the info we will use to
// represent that in our topology)
// -------------------------------------------------------------------------------------------------
List<String> failedPersonaCheckVids = new ArrayList<>();
- Map<String, String> firstStepInfoHash = new HashMap<>();
+ Map<String, String> firstStepInfoHash = new HashMap<>();
// For firstStepInfoHash: key = startNodeVtxId, val=topNodeType plus personaData if applicable
// ie. the value is what we'd use as the "first-step" for this model.
if( !nodeTypeSupportsPersona( startNodeType) ){
- // This node type doesn't have persona info, so we just use startNodeType for the first-step-info
+ // This node type doesn't have persona info, so we just use startNodeType for the first-step-info
snKeySet = startNode2ModelVerHash.keySet();
startNodeIterator = snKeySet.iterator();
while( startNodeIterator.hasNext() ){
- String vtxKey = startNodeIterator.next();
+ String vtxKey = (String) startNodeIterator.next();
firstStepInfoHash.put(vtxKey,startNodeType);
}
}
- else {
+ else {
// Need to check that this node's persona data is good and if it is - use it for the first step info
snKeySet = startNode2ModelVerHash.keySet();
startNodeIterator = snKeySet.iterator();
while( startNodeIterator.hasNext() ){
- String vtxKey = startNodeIterator.next();
+ String vtxKey = (String) startNodeIterator.next();
Iterator<Vertex> vtxIterator = this.engine.asAdmin().getReadOnlyTraversalSource().V(vtxKey);
- Vertex tmpVtx = vtxIterator.next();
+ Vertex tmpVtx = (Vertex)vtxIterator.next();
String thisVtxModelVerId = startNode2ModelVerHash.get(vtxKey);
if( skipModelVerIdList.contains(thisVtxModelVerId) ){
// Skip this vertex because it uses a model-ver that is bad
continue;
}
- Vertex modelVerVtx = distinctModelVersHash.get(thisVtxModelVerId);
+ Vertex modelVerVtx = (Vertex)distinctModelVersHash.get(thisVtxModelVerId);
Vertex modelVtx = getModelGivenModelVer( modelVerVtx, "" );
String modInvId = modelVtx.<String>property("model-invariant-id").orElse(null);
String personaModInvId = tmpVtx.<String>property(addDBAliasedSuffix("model-invariant-id")).orElse(null);
@@ -562,21 +571,21 @@ public class ModelBasedProcessing {
String tmpPersonaInfoStr = startNodeType + "," + personaModInvId + "," + personaModVerId;
firstStepInfoHash.put(vtxKey, tmpPersonaInfoStr );
}
- else {
+ else {
// we won't use this start node below when we collect data because it should have
// had persona data that matched it's model - but it did not.
failedPersonaCheckVids.add(vtxKey);
}
- }
- }
+ }
+ }
//System.out.println("\nDEBUG -- Here's a dump of the firstStepInfoHash hash: " + firstStepInfoHash.toString() );
-
+
// ------------------------------------------------------------------------------------------------
- // Loop through each start-node, collect it's data using collectInstanceData() and put the
+ // Loop through each start-node, collect it's data using collectInstanceData() and put the
// resultSet onto the resultArray.
// ------------------------------------------------------------------------------------------------
-
+
// Make sure they're not bringing back too much data
String maxString = AAIConfig.get("aai.model.query.resultset.maxcount");
if( maxString != null && !maxString.equals("") ){
@@ -587,17 +596,17 @@ public class ModelBasedProcessing {
catch ( Exception nfe ){
// Don't worry, we will leave the max as zero - which tells us not to use it.
}
-
+
if( maxSets > 0 && (startNode2ModelVerHash.size() > maxSets) ){
String msg = " Query returns " + startNode2ModelVerHash.size() + " resultSets. Max allowed is: " + maxSets;
throw new AAIException("AAI_6141", msg);
}
}
-
+
snKeySet = startNode2ModelVerHash.keySet();
startNodeIterator = snKeySet.iterator();
while( startNodeIterator.hasNext() ){
- String topNodeVtxId = startNodeIterator.next();
+ String topNodeVtxId = (String) startNodeIterator.next();
if( failedPersonaCheckVids.contains(topNodeVtxId) ){
// Skip this vertex because it failed it's persona-data check above
continue;
@@ -606,27 +615,29 @@ public class ModelBasedProcessing {
// Skip this vertex because it uses a model-ver that is bad
continue;
}
-
+
Iterator<Vertex> vtxIterator = this.engine.asAdmin().getReadOnlyTraversalSource().V(topNodeVtxId);
- Vertex tmpStartVtx = vtxIterator.next();
- String elementLocationTrail = firstStepInfoHash.get(topNodeVtxId);
+ Vertex tmpStartVtx = (Vertex)vtxIterator.next();
+ String elementLocationTrail = firstStepInfoHash.get(topNodeVtxId);
String modelVerId = startNode2ModelVerHash.get(topNodeVtxId);
Multimap<String, String> validNextStepMap = validNextStepHash.get(modelVerId);
-
+
List<String> vidsTraversed = new ArrayList<>();
Map<String,String> emptyDelKeyHash = new HashMap<>();
Map<String,String> emptyNQElementHash = new HashMap<>(); // Only applies to Named Queries
ResultSet tmpResSet = collectInstanceData( transId, fromAppId,
- tmpStartVtx, elementLocationTrail,
+ tmpStartVtx, elementLocationTrail,
validNextStepMap, vidsTraversed, 0, emptyDelKeyHash, emptyNQElementHash, apiVer );
-
+
resultArray.add(tmpResSet);
}
+
return resultArray;
- }
-
-
-
+
+ }// queryByModel_Timed()
+
+
+
/**
* Run delete by model-ver.
*
@@ -641,15 +652,15 @@ public class ModelBasedProcessing {
* @throws AAIException the AAI exception
*/
public Map<String,String> runDeleteByModel( String transId, String fromAppId,
- String modelVersionId, String topNodeTypeVal, Map<String,Object> startNodeFilterHash, String apiVer, String resVersion )
+ String modelVersionId, String topNodeTypeVal, Map<String,Object> startNodeFilterHash, String apiVer, String resVersion )
throws AAIException {
-
+
Map<String,String> retHash = new HashMap<>();
-
- // Locate the Model-ver node to be used
+
+ // Locate the Model-ver node to be used
Vertex modelVerVtx = null;
if( modelVersionId != null && !modelVersionId.equals("") ){
- modelVerVtx = getNodeUsingUniqueId(transId, fromAppId, "model-ver",
+ modelVerVtx = getNodeUsingUniqueId(transId, fromAppId, "model-ver",
"model-version-id", modelVersionId);
}
else {
@@ -658,28 +669,28 @@ public class ModelBasedProcessing {
if( topNodeTypeVal == null || topNodeTypeVal.equals("") ){
throw new AAIException("AAI_6118", "If no model info is passed, then topNodeType is required. ");
}
-
+
Optional<Vertex> result = dbMethHelper.searchVertexByIdentityMap(topNodeTypeVal, startNodeFilterHash);
if (!result.isPresent()) {
throw new AAIException("AAI_6114", "No Node of type " + topNodeTypeVal + " found for properties");
}
Vertex startVtx = result.get();
-
+
String startVertModVerId = startVtx.<String>property(addDBAliasedSuffix("model-version-id")).orElse(null);
- modelVerVtx = getNodeUsingUniqueId(transId, fromAppId, "model-ver",
+ modelVerVtx = getNodeUsingUniqueId(transId, fromAppId, "model-ver",
"model-version-id", startVertModVerId);
}
-
+
if( modelVerVtx == null ){
throw new AAIException("AAI_6114", "Could not determine the model-ver for the given input parameters. ");
}
String topNType = "unknown";
String modelType = getModelTypeFromModelVer( modelVerVtx, "" );
-
+
if( modelType.equals("widget") ){
- // If they want to delete using a widget-level model.. That is just a delete of the one
- // instance of one of our nodes.
+ // If they want to delete using a widget-level model.. That is just a delete of the one
+ // instance of one of our nodes.
String widgModNodeType = modelVerVtx.<String>property("model-name").orElse(null);
if( (widgModNodeType == null) || widgModNodeType.equals("") ){
String msg = "Could not find model-name for the widget model [" + modelVersionId + "].";
@@ -695,11 +706,11 @@ public class ModelBasedProcessing {
retHash.put(widgId, widgModNodeType);
return retHash;
}
-
+
// ---------------------------------------------------------------------------------
// If we got to here, this must be either a service or resource model.
// So, we'll need to get a Hash of which parts of the model to delete.
- // NOTE- deleteByModel is deleting data based on one specific version of a model.
+ // NOTE- deleteByModel is deleting data based on one specific version of a model.
// ---------------------------------------------------------------------------------
String chkFirstNodePersonaModInvId = "";
String chkFirstNodePersonaModVerId = "";
@@ -716,18 +727,18 @@ public class ModelBasedProcessing {
chkFirstNodePersonaModVerId = modelVerVtx.<String>property("model-version-id").orElse(null);
personaData = "," + chkFirstNodePersonaModInvId + "," + chkFirstNodePersonaModVerId;
}
-
+
// Get the deleteKeyHash for this model
String incomingTrail = "";
Map<String, String> currentHash = new HashMap<>();
Map<String, Vertex> modConHash = new HashMap<>();
ArrayList <String> vidsTraversed = new ArrayList<>();
Map<String, String> delKeyHash = collectDeleteKeyHash( transId, fromAppId,
- firstModElementVertex, incomingTrail, currentHash, vidsTraversed,
- 0, modConHash,
- chkFirstNodePersonaModInvId, chkFirstNodePersonaModVerId );
-
-
+ firstModElementVertex, incomingTrail, currentHash, vidsTraversed,
+ 0, modConHash,
+ chkFirstNodePersonaModInvId, chkFirstNodePersonaModVerId );
+
+
System.out.println("\n ----DEBUG -----: Delete Hash for model: [" + modelVersionId + "] looks like: ");
for( Map.Entry<String, String> entry : delKeyHash.entrySet() ){
System.out.println("key = [" + entry.getKey() + "], val = [" + entry.getValue() + "]");
@@ -744,7 +755,7 @@ public class ModelBasedProcessing {
// we need to make sure that the start node matches the persona values.
String startVertPersonaModInvId = startVtx.<String>property(addDBAliasedSuffix("model-invariant-id")).orElse(null);
String startVertPersonaModVerId = startVtx.<String>property(addDBAliasedSuffix("model-version-id")).orElse(null);
- if( !chkFirstNodePersonaModInvId.equals(startVertPersonaModInvId)
+ if( !chkFirstNodePersonaModInvId.equals(startVertPersonaModInvId)
|| !chkFirstNodePersonaModVerId.equals(startVertPersonaModVerId) ){
String msg = "Persona-Model data mismatch for start node (" + topNType + "), " +
startNodeFilterHash ;
@@ -752,34 +763,36 @@ public class ModelBasedProcessing {
}
}
String topVid = startVtx.id().toString();
-
+
// Read the model-ver into a Map for processing
Multimap<String, String> validNextStepMap = genTopoMap4ModelVer(transId, fromAppId,
modelVerVtx, modelVersionId);
-
+
// Collect the data
String elementLocationTrail = topNType + personaData;
vidsTraversed = new ArrayList<>();
- Map<String,String> emptyHash = new HashMap<>();
-
+ Map<String,String> emptyHash = new HashMap<>();
+
// Pass emptyHash for the NQElement hash since that parameter only applies to Named Queries
ResultSet retResSet = collectInstanceData( transId, fromAppId,
- startVtx, elementLocationTrail,
+ startVtx, elementLocationTrail,
validNextStepMap, vidsTraversed, 0, delKeyHash, emptyHash, apiVer );
-
+
// Note: the new ResultSet will have each element tagged with the del flag so we'll know if it
- // should be deleted or not - so loop through the results in a try-block since some things
+ // should be deleted or not - so loop through the results in a try-block since some things
// will get auto-deleted by parents before we get to them --- and try to remove each one.
String vidToResCheck = topVid;
-
- retHash = deleteAsNeededFromResultSet( transId, fromAppId, retResSet,
+
+ retHash = deleteAsNeededFromResultSet( transId, fromAppId, retResSet,
vidToResCheck, apiVer, resVersion, emptyHash );
//String msgStr = "processed deletes for these vids: (\n"+ retHash.keySet().toString() + ").";
+
return retHash;
- }
-
-
+
+ }// End of runDeleteByModel()
+
+
/**
* Delete as needed from result set.
*
@@ -800,26 +813,26 @@ public class ModelBasedProcessing {
Map<String,String> retHash = new HashMap<>();
retHash.putAll( hashSoFar );
Boolean deleteIt = false;
-
+
if( resSet.getVert() == null ){
return retHash;
}
-
+
Vertex thisVtx = resSet.getVert();
String thisGuyId = "";
String thisNT = "";
String thisGuyStr = "";
-
+
Boolean gotVtxOK = false;
try {
if( thisVtx != null ){
thisGuyId = thisVtx.id().toString();
thisNT = thisVtx.<String>property(AAIProperties.NODE_TYPE).orElse(null);
thisGuyStr = thisGuyId + "[" + thisNT + " found at:" + resSet.getLocationInModelSubGraph() + "]";
-
- // NOTE -- will try to set the NodeType to itself to see if the node has been deleted already in
- // this transaction. It lets you get properties from nodes being deleted where the
- // delete hasn't been committed yet. This check used to be accomplished with a call to
+
+ // NOTE -- will try to set the NodeType to itself to see if the node has been deleted already in
+ // this transaction. It lets you get properties from nodes being deleted where the
+ // delete hasn't been committed yet. This check used to be accomplished with a call to
// "vtx.isRemoved()" but that was a Titan-only feature and is not available anymore since
// we no longer use Titan vertices.
// If we don't do this check, we get errors later when we try to delete the node.
@@ -829,19 +842,19 @@ public class ModelBasedProcessing {
}
catch (Exception ex) {
// Sometimes things have already been deleted by the time we get to them - just log it.
- LOGGER.warn("Exception when trying to delete: " + thisGuyStr + ". msg = " + ex.getMessage(), ex);
+ LOGGER.warn("Exception when trying to delete: " + thisGuyStr + ". msg = " + ex.getMessage() + LogFormatTools.getStackTop(ex));
}
-
+
if( !gotVtxOK ){
// The vertex must have already been removed. Just return.
- // Note - We need to catch this because the DB sometimes can still have the vtx
+ // Note - We need to catch this because the DB sometimes can still have the vtx
// and be able to get its ID but it is flagged internally as removed already.
return retHash;
}
else {
if( resSet.getNewDataDelFlag() != null && resSet.getNewDataDelFlag().equals("T") ){
LOGGER.info(">> will try to delete this one >> " + thisGuyStr);
-
+
try {
Boolean requireResourceVersion = false;
if( thisGuyId.equals(vidToResCheck) ){
@@ -859,48 +872,50 @@ public class ModelBasedProcessing {
else {
String errText = ae.getErrorObject().getErrorText();
String errDetail = ae.getMessage();
- LOGGER.warn("Exception when deleting " + thisGuyStr + ". ErrorCode = " + errorCode +
+ LOGGER.warn("Exception when deleting " + thisGuyStr + ". ErrorCode = " + errorCode +
", errorText = " + errText + ", details = " + errDetail);
}
}
catch( Exception e ){
- // We'd expect to get a "node not found" here sometimes depending on the order that
+ // We'd expect to get a "node not found" here sometimes depending on the order that
// the model has us finding / deleting nodes.
// Ignore the exception - but log it so we can see what happened.
- LOGGER.warn("Exception when deleting " + thisGuyStr + e.getMessage(), e);
+ LOGGER.warn("Exception when deleting " + thisGuyStr + e.getMessage() + LogFormatTools.getStackTop(e));
}
-
+
// We can't depend on a thrown exception to tell us if a node was deleted since it may
- // have been auto=deleted before this removeAaiNode() call.
+ // have been auto=deleted before this removeAaiNode() call.
// --- Not sure if we would want to check anything here -- because the graph.commit() is done outside of this call.
-
+
deleteIt = true;
}
else {
- // --- DEBUG ----
+ // --- DEBUG ----
System.out.println(">>>>>>> NOT DELETING THIS ONE >>>> " + thisGuyStr );
List<String> retArr = dbMethHelper.getVertexProperties(thisVtx);
for( String info : retArr ){ System.out.println(info); }
// --- DEBUG ----
}
}
-
+
// Now call this routine for the sub-resultSets
List <ResultSet> subResultSetList = resSet.getSubResultSet();
Iterator <ResultSet> subResSetIter = subResultSetList.iterator();
while( subResSetIter.hasNext() ){
ResultSet tmpSubResSet = subResSetIter.next();
- retHash = deleteAsNeededFromResultSet( transId, fromAppId, tmpSubResSet,
+ retHash = deleteAsNeededFromResultSet( transId, fromAppId, tmpSubResSet,
vidToResCheck, apiVer, resVersion, retHash );
}
-
+
if( deleteIt ){
retHash.put(thisGuyId, thisGuyStr);
}
+
return retHash;
- }
-
-
+
+ }// deleteAsNeededFromResultSet()
+
+
/**
* Query by named query (old version).
@@ -918,18 +933,18 @@ public class ModelBasedProcessing {
ArrayList <Map<String,Object>> startNodeFilterArrayOfHashes,
String apiVer )
throws AAIException {
-
+
String dummyCutPoint = null;
Map<String,Object> dummySecondaryFilterHash = null;
-
+
return queryByNamedQuery( transId, fromAppId,
- namedQueryUuid,
- startNodeFilterArrayOfHashes,
+ namedQueryUuid,
+ startNodeFilterArrayOfHashes,
apiVer,
dummyCutPoint,
- dummySecondaryFilterHash );
+ dummySecondaryFilterHash );
}
-
+
/**
* Query by named query.
@@ -951,15 +966,15 @@ public class ModelBasedProcessing {
String secondaryFilterCutPoint,
Map<String,Object> secondaryFilterHash )
throws AAIException {
-
+
final String transId_f = transId;
final String fromAppId_f = fromAppId;
final String namedQueryUuid_f = namedQueryUuid;
- final List<Map<String,Object>> startNodeFilterArrayOfHashes_f = startNodeFilterArrayOfHashes;
- final String apiVer_f = apiVer;
- final String secondaryFilterCutPoint_f = secondaryFilterCutPoint;
- final Map<String,Object> secondaryFilterHash_f = secondaryFilterHash;
-
+ final List<Map<String,Object>> startNodeFilterArrayOfHashes_f = startNodeFilterArrayOfHashes;
+ final String apiVer_f = apiVer;
+ final String secondaryFilterCutPoint_f = secondaryFilterCutPoint;
+ final Map<String,Object> secondaryFilterHash_f = secondaryFilterHash;
+
// Find out what our time-limit should be
int timeLimitSec = 0;
String timeLimitString = AAIConfig.get("aai.model.query.timeout.sec");
@@ -976,27 +991,27 @@ public class ModelBasedProcessing {
// We will NOT be using a timer
return queryByNamedQuery_Timed( transId, fromAppId,
namedQueryUuid,
- startNodeFilterArrayOfHashes,
+ startNodeFilterArrayOfHashes,
apiVer,
secondaryFilterCutPoint_f,
secondaryFilterHash_f );
}
-
+
List<ResultSet> resultList = new ArrayList<>();
TimeLimiter limiter = new SimpleTimeLimiter();
try {
- resultList = limiter.callWithTimeout(new Callable <List<ResultSet>>() {
- public List<ResultSet> call() throws AAIException {
+ resultList = limiter.callWithTimeout(new AaiCallable <List<ResultSet>>() {
+ public List<ResultSet> process() throws AAIException {
return queryByNamedQuery_Timed( transId_f, fromAppId_f,
namedQueryUuid_f,
- startNodeFilterArrayOfHashes_f,
+ startNodeFilterArrayOfHashes_f,
apiVer_f,
secondaryFilterCutPoint_f,
secondaryFilterHash_f );
}
}, timeLimitSec, TimeUnit.SECONDS, true);
-
- }
+
+ }
catch (AAIException ae) {
// Re-throw AAIException so we get can tell what happened internally
throw ae;
@@ -1007,20 +1022,21 @@ public class ModelBasedProcessing {
catch (Exception e) {
throw new AAIException("AAI_6128", "Unexpected exception in queryByNamedQuery(): " + e.getMessage() );
}
+
return resultList;
}
-
-
+
+
/**
* Query by named query timed.
*
* @param transId the trans id
* @param fromAppId the from app id
* @param namedQueryUuid the named query uuid
- * @param startNodeFilterArrayOfHashes the start node filter array of hashes --used to locate the first nodes of instance data
+ * @param startNodeFilterArrayOfHashes the start node filter array of hashes --used to locate the first nodes of instance data
* @param apiVer the api ver
* @param secondaryFilterCutPoint the nodeType where we will parse for the secondary Filter
- * @param secondaryFilterHash the secondary filter hash
+ * @param secondaryFilterHash the secondary filter hash
* @return resultSet
* @throws AAIException the AAI exception
*/
@@ -1030,13 +1046,13 @@ public class ModelBasedProcessing {
String apiVer,
String secondaryFilterCutPoint,
Map<String,Object> secondaryFilterHash
- )
+ )
throws AAIException {
-
+
// Locate the Query to be used
Vertex queryVtx = getNodeUsingUniqueId(transId, fromAppId, "named-query",
"named-query-uuid", namedQueryUuid);
-
+
// Get the first/top named-query-element used by this query
Iterator<Vertex> vertI = this.traverseIncidentEdges(EdgeType.TREE, queryVtx, "named-query-element");
Vertex firstNqElementVert = null;
@@ -1047,7 +1063,7 @@ public class ModelBasedProcessing {
count++;
topNType = getNqElementWidgetType( transId, fromAppId, firstNqElementVert, "" );
}
-
+
if( count < 1 ){
// A named query must start with a single top element
throw new AAIException("AAI_6133", "No top-node defined for named-query-uuid = [" + namedQueryUuid + "]");
@@ -1060,7 +1076,7 @@ public class ModelBasedProcessing {
String msg = "Could not determine the top-node nodeType for Named Query: [" + namedQueryUuid + "]";
throw new AAIException("AAI_6133", msg);
}
-
+
// Read the topology into a hash for processing
Multimap<String, String> validNextStepMap = genTopoMap4NamedQ(transId, fromAppId, queryVtx, namedQueryUuid);
@@ -1077,7 +1093,7 @@ public class ModelBasedProcessing {
boolean foundIndexedField = false;
int propertiesSet = 0;
while( propIter.hasNext() ){
- String oldVtxKey = propIter.next();
+ String oldVtxKey = (String) propIter.next();
String newKey = oldVtxKey;
String [] parts = oldVtxKey.split("\\.");
if( parts.length == 2 ){
@@ -1121,7 +1137,7 @@ public class ModelBasedProcessing {
}
}
}
-
+
if (startVertList.isEmpty()) {
throw new AAIException("AAI_6114", "No Node of type " + topNType + " found for properties");
}
@@ -1134,7 +1150,7 @@ public class ModelBasedProcessing {
throw new AAIException("AAI_6141", msg);
}
}
-
+
// Loop through each start node and get its data
List<ResultSet> resSetList = new ArrayList<>();
for( int i = 0; i < startVertList.size(); i++ ){
@@ -1143,21 +1159,21 @@ public class ModelBasedProcessing {
String elementLocationTrail = topNType;
ArrayList <String> vidsTraversed = new ArrayList<>();
Map<String,String> emptyDelKeyHash = new HashMap<>(); // Does not apply to Named Queries
-
+
// Get the mapping of namedQuery elements to our widget topology for this namedQuery
String incomingTrail = "";
Map<String, String> currentHash = new HashMap<>();
-
+
Map<String,String> namedQueryElementHash = collectNQElementHash( transId, fromAppId,
firstNqElementVert, incomingTrail, currentHash, vidsTraversed, 0 );
-
+
vidsTraversed = new ArrayList<>();
ResultSet tmpResSet = collectInstanceData( transId, fromAppId,
- startVtx, elementLocationTrail,
+ startVtx, elementLocationTrail,
validNextStepMap, vidsTraversed, 0, emptyDelKeyHash, namedQueryElementHash, apiVer );
resSetList.add(tmpResSet);
}
-
+
// If a secondary filter was defined, we will prune the collected instance data result set(s) based on it.
List<ResultSet> prunedResSetList = new ArrayList<>();
if( resSetList != null && !resSetList.isEmpty() ){
@@ -1174,8 +1190,8 @@ public class ModelBasedProcessing {
}
}
}
-
- // Since a NamedQuery can mark some nodes as "do-not-display", we need to collapse our resultSet so
+
+ // Since a NamedQuery can mark some nodes as "do-not-display", we need to collapse our resultSet so
// does not display those nodes.
List<ResultSet> collapsedResSetList = new ArrayList<>();
if( prunedResSetList != null && !prunedResSetList.isEmpty() ){
@@ -1184,7 +1200,7 @@ public class ModelBasedProcessing {
// marked all the "top" node-elements as do-not-output. Ie. the query may
// have had a top-node of "generic-vnf" which joins down to different l-interfaces.
// If they only want to see the l-interfaces, then a single result set
- // would be "collapsed" into many separate resultSets - each of which is
+ // would be "collapsed" into many separate resultSets - each of which is
// just a single l-interface.
List<ResultSet> tmpResSetList = collapseForDoNotOutput(prunedResSetList.get(i));
if( tmpResSetList != null && !tmpResSetList.isEmpty() ){
@@ -1195,11 +1211,12 @@ public class ModelBasedProcessing {
}
}
}
-
+
return collapsedResSetList;
- }
-
+
+ }// End of queryByNamedQuery()
+
/**
* Prune a result set as per a secondary filter.
*
@@ -1211,13 +1228,13 @@ public class ModelBasedProcessing {
*/
public ResultSet pruneResultSet(ResultSet resSetVal, String cutPointType, Map<String,Object> secFilterHash )
throws AAIException {
-
- // Given a ResultSet and some secondary filter info, do pruning as needed
+
+ // Given a ResultSet and some secondary filter info, do pruning as needed
ResultSet pResSet = new ResultSet();
-
- // For this ResultSet, we will see if we are on a node of the type that is our cutPoint;
+
+ // For this ResultSet, we will see if we are on a node of the type that is our cutPoint;
// then only keep it if we peek "below" and see a match for our filter.
-
+
String nt = resSetVal.getVert().<String>property(AAIProperties.NODE_TYPE).orElse(null);
if( nt != null && nt.equals(cutPointType) ){
// We are on the type of node that may need to be "pruned" along with it's sub-results
@@ -1226,8 +1243,8 @@ public class ModelBasedProcessing {
return pResSet;
}
}
-
- // If we made it to here, we will not be pruning at this level, so we will
+
+ // If we made it to here, we will not be pruning at this level, so we will
// be returning a copy of this resultSet that has it's subResults pruned (as needed).
pResSet.setVert(resSetVal.getVert());
pResSet.setDoNotOutputFlag(resSetVal.getDoNotOutputFlag());
@@ -1236,7 +1253,7 @@ public class ModelBasedProcessing {
pResSet.setNewDataDelFlag(resSetVal.getNewDataDelFlag());
pResSet.setPropertyLimitDesc(resSetVal.getPropertyLimitDesc());
pResSet.setPropertyOverRideHash(resSetVal.getPropertyOverRideHash());
-
+
if( !resSetVal.getSubResultSet().isEmpty() ){
ListIterator<ResultSet> listItr = resSetVal.getSubResultSet().listIterator();
List<ResultSet> newSubSetList = new ArrayList<>();
@@ -1248,11 +1265,13 @@ public class ModelBasedProcessing {
}
}
pResSet.setSubResultSet(newSubSetList);
- }
+ }
+
return pResSet;
- }
-
-
+
+ }// End pruneResultSet()
+
+
/**
* Satisfies hash of filters.
*
@@ -1263,18 +1282,18 @@ public class ModelBasedProcessing {
*/
public boolean satisfiesFilters(ResultSet resSet, Map<String,Object> filterHash )
throws AAIException {
-
+
if( filterHash.isEmpty() ){
// Nothing to look for, so no, we didn't find it.
return false;
}
-
+
Iterator <?> it = filterHash.entrySet().iterator();
while( it.hasNext() ){
Map.Entry<?,?> filtEntry = (Map.Entry<?,?>) it.next();
String propNodeTypeDotName = (filtEntry.getKey()).toString();
String fpv = (filtEntry.getValue()).toString();
-
+
int periodLoc = propNodeTypeDotName.indexOf(".");
if( periodLoc <= 0 ){
String emsg = "Bad filter param key passed in: [" + propNodeTypeDotName + "]. Expected format = [nodeName.paramName]\n";
@@ -1292,11 +1311,13 @@ public class ModelBasedProcessing {
}
}
}
+
// Made it through all the filters -- it found what we were looking for.
return true;
- }
-
-
+
+ }// end of satisfiesFilters()
+
+
/**
* Filter met by this set.
*
@@ -1309,7 +1330,7 @@ public class ModelBasedProcessing {
public boolean filterMetByThisSet(ResultSet resSet, String filtNodeType, String filtPropName, String filtPropVal ) {
// Note - we are just looking for a positive match for one filter for this resultSet
// NOTE: we're expecting the filter to have a format like this: "nodeType.parameterName:parameterValue"
-
+
Vertex vert = resSet.getVert();
if( vert == null ){
return false;
@@ -1335,7 +1356,7 @@ public class ModelBasedProcessing {
}
}
}
-
+
// Didn't find a match at the this level, so check the sets below it meet the criteria
if( resSet.getSubResultSet() != null ){
ListIterator<ResultSet> listItr = resSet.getSubResultSet().listIterator();
@@ -1345,11 +1366,13 @@ public class ModelBasedProcessing {
}
}
}
+
return false;
- }
-
-
+
+ }// end of filterMetByThisSet()
+
+
/**
* Collapse for do not output.
*
@@ -1359,14 +1382,14 @@ public class ModelBasedProcessing {
*/
public List<ResultSet> collapseForDoNotOutput(ResultSet resSetVal )
throws AAIException {
-
- // Given a ResultSet -- if it is tagged to NOT be output, then replace it with
- // it's sub-ResultSets if it has any.
+
+ // Given a ResultSet -- if it is tagged to NOT be output, then replace it with
+ // it's sub-ResultSets if it has any.
List<ResultSet> colResultSet = new ArrayList<>();
-
+
if( resSetVal.getDoNotOutputFlag().equals("true") ){
// This ResultSet isn't to be displayed, so replace it with it's sub-ResultSets
- List<ResultSet> subResList = resSetVal.getSubResultSet();
+ List<ResultSet> subResList = (ArrayList<ResultSet>) resSetVal.getSubResultSet();
for( int k = 0; k < subResList.size(); k++ ){
List<ResultSet> newSubResList = collapseForDoNotOutput(subResList.get(k));
colResultSet.addAll(newSubResList);
@@ -1376,11 +1399,11 @@ public class ModelBasedProcessing {
// This set will be displayed
colResultSet.add(resSetVal);
}
-
+
// For each result set now at this level, call this same routine to collapse their sub-resultSets
for( int i = 0; i < colResultSet.size(); i++ ){
List<ResultSet> newSubSet = new ArrayList<>();
- List<ResultSet> subResList = colResultSet.get(i).getSubResultSet();
+ List<ResultSet> subResList = (ArrayList<ResultSet>) colResultSet.get(i).getSubResultSet();
for( int n = 0; n < subResList.size(); n++ ){
List<ResultSet> newSubResList = collapseForDoNotOutput(subResList.get(n));
newSubSet.addAll(newSubResList);
@@ -1388,18 +1411,19 @@ public class ModelBasedProcessing {
// Replace the old subResultSet with the collapsed set
colResultSet.get(i).setSubResultSet(newSubSet);
}
-
+
return colResultSet;
- }
-
-
-
+
+ }// End collapseForDoNotOutput()
+
+
+
/**
* Collect instance data.
*
* @param transId the trans id
* @param fromAppId the from app id
- * @param thisLevelElemVtx the element vtx at this level
+ * @param thisLevelElemVtx the element vtx at this level
* @param thisVertsTrail the this verts trail
* @param elementLocationTrail -- trail of nodeTypes that got us here (this element vertex) from the top
* @param validNextStepMap the valid next step map -- hash of valid next steps (node types) for this model
@@ -1421,33 +1445,33 @@ public class ModelBasedProcessing {
Map<String,String> namedQueryElementHash, // only applies to named-query data collecting
String apiVer
) throws AAIException {
-
+
levelCounter++;
-
+
String thisElemVid = thisLevelElemVtx.id().toString();
-
+
if( levelCounter > MAX_LEVELS ) {
throw new AAIException("AAI_6125", "collectInstanceData() has looped across more levels than allowed: " + MAX_LEVELS + ". ");
}
-
+
ResultSet rs = new ResultSet();
if( namedQueryElementHash.containsKey(thisVertsTrail) ){
// We're collecting data for a named-query, so need to see if we need to do anything special
String nqElUuid = namedQueryElementHash.get(thisVertsTrail);
Vertex nqElementVtx = getNodeUsingUniqueId(transId, fromAppId, "named-query-element",
"named-query-element-uuid", nqElUuid);
-
+
String tmpDoNotShow = nqElementVtx.<String>property("do-not-output").orElse(null);
if( tmpDoNotShow != null && tmpDoNotShow.equals("true") ){
rs.setDoNotOutputFlag("true");
}
-
+
if( namedQueryConstraintSaysStop(transId, fromAppId, nqElementVtx, thisLevelElemVtx, apiVer) ){
- // There was a property constraint which says they do not want to collect this vertex or whatever
+ // There was a property constraint which says they do not want to collect this vertex or whatever
// might be below it. Just return the empty rs here.
return rs;
}
-
+
String propLimDesc = nqElementVtx.<String>property("property-limit-desc").orElse(null);
if( (propLimDesc != null) && !propLimDesc.equals("") ){
if (propLimDesc.equalsIgnoreCase("show-all")) {
@@ -1463,13 +1487,13 @@ public class ModelBasedProcessing {
Map<String,Object> tmpPropertyOverRideHash = getNamedQueryPropOverRide(transId, fromAppId, nqElementVtx, thisLevelElemVtx, apiVer);
//System.out.println(" DEBUG --- USING this propertyOverride data set on ResSet [" + tmpPropertyOverRideHash.toString() + "]");
rs.setPropertyOverRideHash(tmpPropertyOverRideHash);
-
+
// See if we need to look up any "unconnected" data that needs to be associated with this result set
Map<String,Object> tmpExtraPropHash = getNamedQueryExtraDataLookup(transId, fromAppId, nqElementVtx, thisLevelElemVtx, apiVer);
//System.out.println(" DEBUG --- ADDING this EXTRA Lookup data to the ResSet [" + tmpExtraPropHash.toString() + "]");
rs.setExtraPropertyHash(tmpExtraPropHash);
}
-
+
rs.setVert(thisLevelElemVtx);
rs.setLocationInModelSubGraph(thisVertsTrail);
if( delKeyHash.containsKey(thisVertsTrail) && delKeyHash.get(thisVertsTrail).equals("T") ){
@@ -1478,10 +1502,10 @@ public class ModelBasedProcessing {
else {
rs.setNewDataDelFlag("F");
}
-
+
// Use Gremlin-pipeline to just look for edges that go to a valid "next-steps"
Collection <String> validNextStepColl = validNextStepMap.get(thisVertsTrail);
-
+
// Because of how we process linkage-points, we may have duplicate node-types in our next-stepMap (for one step)
// So, to keep from looking (and bringing back) the same data twice, we need to make sure our next-steps are unique
Set<String> validNextStepHashSet = new HashSet<>();
@@ -1490,20 +1514,20 @@ public class ModelBasedProcessing {
String targetStepStr = ntcItr.next();
validNextStepHashSet.add(targetStepStr);
}
-
+
List<String> tmpVidsTraversedList = new ArrayList<>();
tmpVidsTraversedList.addAll(vidsTraversed);
tmpVidsTraversedList.add(thisElemVid);
-
+
Iterator <String> ntItr = validNextStepHashSet.iterator();
while( ntItr.hasNext() ){
String targetStep = ntItr.next();
// NOTE: NextSteps can either be just a nodeType, or can be a nodeType plus
- // model-invariant-id-local and model-version-id-local (the two persona properties)
+ // model-invariant-id-local and model-version-id-local (the two persona properties)
// if those need to be checked also.
// When the persona stuff is part of the step, it is a comma separated string.
// Ie. "nodeType,model-inv-id-local,model-version-id-local" (the two "persona" props)
- //
+ //
String targetNodeType = "";
String pmid = "";
String pmv = "";
@@ -1525,7 +1549,7 @@ public class ModelBasedProcessing {
// It's just the nodeType with no other info
targetNodeType = targetStep;
}
-
+
GraphTraversal<Vertex, Vertex> modPipe = null;
if( stepIsJustNT ){
modPipe = this.engine.asAdmin().getReadOnlyTraversalSource().V(thisLevelElemVtx).both().has(AAIProperties.NODE_TYPE, targetNodeType);
@@ -1533,29 +1557,31 @@ public class ModelBasedProcessing {
else {
modPipe = this.engine.asAdmin().getReadOnlyTraversalSource().V(thisLevelElemVtx).both().has(AAIProperties.NODE_TYPE, targetNodeType).has(addDBAliasedSuffix("model-invariant-id"),pmid).has(addDBAliasedSuffix("model-version-id"),pmv);
}
-
+
if( modPipe == null || !modPipe.hasNext() ){
//System.out.println("DEBUG - didn't find any [" + targetStep + "] connected to this guy (which is ok)");
}
else {
while( modPipe.hasNext() ){
- Vertex tmpVert = modPipe.next();
+ Vertex tmpVert = (Vertex) modPipe.next();
String tmpVid = tmpVert.id().toString();
String tmpTrail = thisVertsTrail + "|" + targetStep;
if( !vidsTraversed.contains(tmpVid) ){
- // This is one we would like to use - so we'll include the result set we get for it
+ // This is one we would like to use - so we'll include the result set we get for it
ResultSet tmpResSet = collectInstanceData( transId, fromAppId,
- tmpVert, tmpTrail,
- validNextStepMap, tmpVidsTraversedList,
+ tmpVert, tmpTrail,
+ validNextStepMap, tmpVidsTraversedList,
levelCounter, delKeyHash, namedQueryElementHash, apiVer );
-
+
rs.getSubResultSet().add(tmpResSet);
}
}
}
}
+
return rs;
- }
+
+ } // End of collectInstanceData()
/**
@@ -1572,17 +1598,17 @@ public class ModelBasedProcessing {
public Multimap<String, String> genTopoMap4ModelVer(String transId, String fromAppId,
Vertex modelVerVertex, String modelVerId)
throws AAIException {
-
+
if( modelVerVertex == null ){
throw new AAIException("AAI_6114", "null modelVerVertex passed to genTopoMap4ModelVer()");
}
-
+
Multimap<String, String> initialEmptyMap = ArrayListMultimap.create();
List<String> vidsTraversed = new ArrayList<>();
String modelType = getModelTypeFromModelVer( modelVerVertex, "" );
if( modelType.equals("widget") ){
// A widget model by itself does not have a topoplogy. That is - it has no "model-elements" which
- // define how it is connected to other things. All it has is a name which ties it to
+ // define how it is connected to other things. All it has is a name which ties it to
// an aai-node-type
Iterator<Vertex> vertI= this.traverseIncidentEdges(EdgeType.TREE, modelVerVertex, "model-element");
if( vertI != null && vertI.hasNext() ){
@@ -1593,39 +1619,42 @@ public class ModelBasedProcessing {
return initialEmptyMap;
}
}
-
+
String firstModelVerId = modelVerVertex.<String>property("model-version-id").orElse(null);
String firstModelVersion = modelVerVertex.<String>property("model-version").orElse(null);
if( firstModelVerId == null || firstModelVerId.equals("") || firstModelVersion == null || firstModelVersion.equals("") ){
throw new AAIException("AAI_6132", "Bad Model Definition: Bad model-version-id or model-version. model-version-id = "
+ modelVerId);
}
-
+
Vertex firstElementVertex = getTopElementForSvcOrResModelVer( modelVerVertex, "" );
Vertex firstEleModVerVtx = getModelVerThatElementRepresents( firstElementVertex, "" );
- String firstElemModelType = getModelTypeFromModelVer( firstEleModVerVtx, "" );
+ String firstElemModelType = getModelTypeFromModelVer( firstEleModVerVtx, "" );
if( ! firstElemModelType.equals("widget") ){
throw new AAIException("AAI_6132", "Bad Model Definition: First element must correspond to a widget type model. Model UUID = "
+ modelVerId);
}
-
+
Vertex firstModVtx = getModelGivenModelVer( modelVerVertex, "" );
String firstModelInvId = firstModVtx.<String>property("model-invariant-id").orElse(null);
if( firstModelInvId == null || firstModelInvId.equals("") ){
throw new AAIException("AAI_6132", "Bad Model Definition: Could not find model.model-invariant-id given model-ver.model-version-id = "
+ modelVerId);
}
-
- return collectTopology4ModelVer( transId, fromAppId,
+
+ Multimap<String, String> collectedMap = collectTopology4ModelVer( transId, fromAppId,
firstElementVertex, "", initialEmptyMap, vidsTraversed, 0, null, firstModelInvId, firstModelVersion );
- }
+
+ return collectedMap;
+
+ } // End of genTopoMap4ModelVer()
public List<String> makeSureItsAnArrayList( String listStringVal ){
// We're sometimes getting a String back on db properties that should be ArrayList<String>
// Seems to be how they're defined in OXM - whether they use a "xml-wrapper" or not
// Need to translate them into ArrayLists sometimes...
-
+
List<String> retArrList = new ArrayList<String>();
String listString = listStringVal;
listString = listString.replace(" ", "");
@@ -1638,6 +1667,7 @@ public class ModelBasedProcessing {
retArrList.add(pieces[i]);
}
}
+
return retArrList;
}
@@ -1652,33 +1682,33 @@ public class ModelBasedProcessing {
*/
public Map<String, Vertex> getModConstraintHash(Vertex modelElementVtx, Map<String, Vertex> currentHash )
throws AAIException {
-
- // For a given model-element vertex, look to see if there are any "model-constraint" elements that is has
+
+ // For a given model-element vertex, look to see if there are any "model-constraint" elements that is has
// an OUT "uses" edge to. If it does, then get any "constrained-element-set" nodes that are pointed to
// by the "model-constraint". That will be the replacement "constrained-element-set". The UUID of the
// "constrained-element-set" that it is supposed to replace is found in the property:
- // model-constraint.constrained-element-set-uuid-to-replace
+ // model-constraint.constrained-element-set-uuid-to-replace
//
- // For now, that is the only type of model-constraint allowed, so that is all we will look for.
- // Pass back any of these "constrained-element-set" nodes along with any that were passed in by
+ // For now, that is the only type of model-constraint allowed, so that is all we will look for.
+ // Pass back any of these "constrained-element-set" nodes along with any that were passed in by
// the "currentHash" parameter.
-
+
if( modelElementVtx == null ){
String msg = " null modelElementVtx passed to getModConstraintHash() ";
throw new AAIException("AAI_6114", msg);
}
-
+
String modelType = modelElementVtx.<String>property(AAIProperties.NODE_TYPE).orElse(null);
if( modelType == null || (!modelType.equals("model-element")) ){
String msg = " getModConstraintHash() called with wrong type model: [" + modelType + "]. ";
throw new AAIException("AAI_6114", msg);
}
-
+
Map<String, Vertex> thisHash = new HashMap<>();
if( currentHash != null ){
thisHash.putAll(currentHash);
}
-
+
int count = 0;
List<Vertex> modelConstraintArray = new ArrayList<>();
Iterator<Vertex> vertI = this.traverseIncidentEdges(EdgeType.TREE, modelElementVtx, "model-constraint");
@@ -1691,7 +1721,7 @@ public class ModelBasedProcessing {
count++;
}
}
-
+
if( count > 0 ) {
for( int i = 0; i < count; i++ ){
Vertex vtxOfModelConstraint = modelConstraintArray.get(i);
@@ -1700,7 +1730,7 @@ public class ModelBasedProcessing {
// constrained-element-set to use in its place
Iterator<Vertex> mvertI = this.traverseIncidentEdges(EdgeType.TREE, vtxOfModelConstraint, "constrained-element-set");
while( mvertI != null && mvertI.hasNext() ){
- // There better only be one...
+ // There better only be one...
Vertex tmpVert = mvertI.next();
String connectToType = tmpVert.<String>property(AAIProperties.NODE_TYPE).orElse(null);
if( (connectToType != null) && connectToType.equals("constrained-element-set") ){
@@ -1715,9 +1745,10 @@ public class ModelBasedProcessing {
// Didn't find anything to add, so just return what they passed in.
return currentHash;
}
- }
-
-
+
+ } // End of getModConstraintHash()
+
+
/**
* Gets the top element vertex for service or resource model.
*
@@ -1727,48 +1758,50 @@ public class ModelBasedProcessing {
*/
public Vertex getTopElementForSvcOrResModelVer(Vertex modelVerVtx, String trail )
throws AAIException {
-
+
// For a "resource" or "service" type model, return the "top" element in that model
if( modelVerVtx == null ){
String msg = " null modelVertex passed to getTopoElementForSvcOrResModelVer() at [" + trail + "]. ";
throw new AAIException("AAI_6114", msg);
}
-
+
String modelVerId = modelVerVtx.<String>property("model-version-id").orElse(null);
if( modelVerId == null ){
String nt = modelVerVtx.<String>property(AAIProperties.NODE_TYPE).orElse(null);
if( nt != null && !nt.equals("model-ver") ){
- String msg = "Illegal model defined: model element pointing to nodeType: ["
+ String msg = "Illegal model defined: model element pointing to nodeType: ["
+ nt + "], should be pointing to: [model-ver] at [" + trail + "]. ";
throw new AAIException("AAI_6132", msg);
}
}
-
+
Vertex firstElementVertex = null;
-
+
Iterator<Vertex> vertI = this.traverseIncidentEdges(EdgeType.TREE, modelVerVtx, "model-element");
int elCount = 0;
while( vertI != null && vertI.hasNext() ){
elCount++;
firstElementVertex = vertI.next();
}
-
+
if( elCount > 1 ){
- String msg = "Illegal model defined: More than one first element defined for model-ver-id = " +
+ String msg = "Illegal model defined: More than one first element defined for model-ver-id = " +
modelVerId + " at [" + trail + "]. ";
throw new AAIException("AAI_6132", msg);
}
-
+
if( firstElementVertex == null ){
- String msg = "Could not find first model element for model-ver-id = "
+ String msg = "Could not find first model element for model-ver-id = "
+ modelVerId + " at [" + trail + "]. ";
throw new AAIException("AAI_6132", msg);
}
+
return firstElementVertex;
- }
-
-
+
+ } // End of getTopElementForSvcOrResModelVer()
+
+
/**
* Gets the named query prop over ride.
*
@@ -1783,32 +1816,34 @@ public class ModelBasedProcessing {
public Map<String,Object> getNamedQueryPropOverRide(String transId, String fromAppId,
Vertex namedQueryElementVertex, Vertex instanceVertex, String apiVer )
throws AAIException {
-
+
// If this model-element says that they want an alternative set of properties returned, then pull that
// data out of the instance vertex.
-
+
Map<String,Object> altPropHash = new HashMap<>();
-
+
if( namedQueryElementVertex == null ){
String msg = " null namedQueryElementVertex passed to getNamedQueryPropOverRide() ";
throw new AAIException("AAI_6114", msg);
}
-
+
List<String> propCollectList = new ArrayList<>();
Iterator <VertexProperty<Object>> vpI = namedQueryElementVertex.properties("property-collect-list");
while( vpI.hasNext() ){
propCollectList.add((String)vpI.next().value());
}
-
+
for( int i = 0; i < propCollectList.size(); i++ ){
String thisPropName = propCollectList.get(i);
Object instanceVal = instanceVertex.<Object>property(thisPropName).orElse(null);
altPropHash.put(thisPropName, instanceVal);
}
+
return altPropHash;
- }
-
+
+ } // End of getNamedQueryPropOverRide()
+
/**
* Named query constraint says stop.
*
@@ -1823,11 +1858,11 @@ public class ModelBasedProcessing {
public Boolean namedQueryConstraintSaysStop(String transId, String fromAppId,
Vertex namedQueryElementVertex, Vertex instanceVertex, String apiVer )
throws AAIException {
-
+
// For each (if any) property-constraint defined for this named-query-element, we will evaluate if
// the constraint is met or not-met. if there are constraints and any are not-met, then
// we return "true".
-
+
if( namedQueryElementVertex == null ){
String msg = " null namedQueryElementVertex passed to namedQueryConstraintSaysStop() ";
throw new AAIException("AAI_6114", msg);
@@ -1836,15 +1871,15 @@ public class ModelBasedProcessing {
String msg = " null instanceVertex passed to namedQueryConstraintSaysStop() ";
throw new AAIException("AAI_6114", msg);
}
-
+
Iterator<Vertex> constrPipe = this.traverseIncidentEdges(EdgeType.TREE, namedQueryElementVertex, "property-constraint");
if( constrPipe == null || !constrPipe.hasNext() ){
// There's no "property-constraint" defined for this named-query-element. No problem.
return false;
}
-
+
while( constrPipe.hasNext() ){
- Vertex constrVtx = constrPipe.next();
+ Vertex constrVtx = (Vertex) constrPipe.next();
// We found a property constraint that we will need to check
String conType = constrVtx.<String>property("constraint-type").orElse(null);
if( (conType == null) || conType.equals("")){
@@ -1861,13 +1896,13 @@ public class ModelBasedProcessing {
String msg = " Bad property-constraint (propVal) found in Named Query definition. ";
throw new AAIException("AAI_6133", msg);
}
-
+
// See if that constraint is met or not
String val = instanceVertex.<String>property(propName).orElse(null);
if( val == null ){
val = "";
}
-
+
if( conType.equals("EQUALS") ){
if( !val.equals(propVal) ){
// This constraint was not met
@@ -1885,10 +1920,12 @@ public class ModelBasedProcessing {
throw new AAIException("AAI_6133", msg);
}
}
- return false;
- }
-
+
+ return false;
+
+ } // End of namedQueryConstraintSaysStop()
+
/**
* Gets the named query extra data lookup.
*
@@ -1903,10 +1940,10 @@ public class ModelBasedProcessing {
public Map<String,Object> getNamedQueryExtraDataLookup(String transId, String fromAppId,
Vertex namedQueryElementVertex, Vertex instanceVertex, String apiVer )
throws AAIException {
-
+
// For each (if any) related-lookup defined for this named-query-element, we will go and
// and try to find it. All the related-lookup data will get put in a hash and returned.
-
+
if( namedQueryElementVertex == null ){
String msg = " null namedQueryElementVertex passed to getNamedQueryExtraDataLookup() ";
throw new AAIException("AAI_6114", msg);
@@ -1915,22 +1952,22 @@ public class ModelBasedProcessing {
String msg = " null instanceVertex passed to getNamedQueryExtraDataLookup() ";
throw new AAIException("AAI_6114", msg);
}
-
+
Map<String,Object> retHash = new HashMap<>();
-
+
Iterator<Vertex> lookPipe = this.traverseIncidentEdges(EdgeType.TREE, namedQueryElementVertex, "related-lookup");
if( lookPipe == null || !lookPipe.hasNext() ){
// There's no "related-lookup" defined for this named-query-element. No problem.
return retHash;
}
-
+
while( lookPipe.hasNext() ){
- Vertex relLookupVtx = lookPipe.next();
+ Vertex relLookupVtx = (Vertex) lookPipe.next();
// We found a related-lookup record to try and use
String srcProp = relLookupVtx.<String>property("source-node-property").orElse(null);
String srcNodeType = relLookupVtx.<String>property("source-node-type").orElse(null);
srcProp = getPropNameWithAliasIfNeeded(srcNodeType, srcProp);
-
+
if( (srcProp == null) || srcProp.equals("")){
String msg = " Bad related-lookup (source-node-property) found in Named Query definition. ";
throw new AAIException("AAI_6133", msg);
@@ -1942,38 +1979,38 @@ public class ModelBasedProcessing {
}
String targetProp = relLookupVtx.<String>property("target-node-property").orElse(null);
targetProp = getPropNameWithAliasIfNeeded(targetNodeType, targetProp);
-
+
if( (targetProp == null) || targetProp.equals("")){
String msg = " Bad related-lookup (target-node-property) found in Named Query definition. ";
throw new AAIException("AAI_6133", msg);
}
-
+
List<String> propCollectList = new ArrayList<>();
Iterator <VertexProperty<Object>> vpI = relLookupVtx.properties("property-collect-list");
while( vpI.hasNext() ){
propCollectList.add((String)vpI.next().value());
}
- // Use the value from the source to see if we can find ONE target record using the
+ // Use the value from the source to see if we can find ONE target record using the
// value from the source
String valFromInstance = instanceVertex.<String>property(srcProp).orElse(null);
if( valFromInstance == null ){
// if there is no key to use to go look up something, we should end it here and just
- // note what happened - no need to try to look something up by an empty key
- LOGGER.debug("WARNING - the instance data node of type [" + srcNodeType
- + "] did not have a value for property [" + srcProp
+ // note what happened - no need to try to look something up by an empty key
+ LOGGER.debug("WARNING - the instance data node of type [" + srcNodeType
+ + "] did not have a value for property [" + srcProp
+ "], so related-lookup is being abandoned.");
return retHash;
}
-
+
Map<String,Object> propHash = new HashMap<String,Object>();
propHash.put(targetProp, valFromInstance);
-
+
Optional<Vertex> result = dbMethHelper.locateUniqueVertex(targetNodeType, propHash);
if (!result.isPresent()) {
// If it can't find the lookup node, don't fail, just log that it couldn't be found ---
- LOGGER.debug("WARNING - Could not find lookup node that corresponds to nodeType ["
- + targetNodeType + "] propertyName = [" + srcProp
+ LOGGER.debug("WARNING - Could not find lookup node that corresponds to nodeType ["
+ + targetNodeType + "] propertyName = [" + srcProp
+ "], propVal = [" + valFromInstance
+ "] so related-lookup is being abandoned.");
return retHash;
@@ -1987,20 +2024,21 @@ public class ModelBasedProcessing {
Object valObj = tmpVtx.<Object>property(tmpPropName).orElse(null);
String lookupKey = targetNodeType + "." + tmpPropName;
retHash.put(lookupKey, valObj);
-
+
}
}
}
-
+
return retHash;
- }
+
+ } // End of getNamedQueryExtraDataLookup()
/**
* Collect NQ element hash.
*
* @param transId the trans id
* @param fromAppId the from app id
- * @param thisLevelElemVtx the element verrtx for this level
+ * @param thisLevelElemVtx the element verrtx for this level
* @param incomingTrail the incoming trail -- trail of nodeTypes that got us here (this nq-element vertex) from the top
* @param currentHash the current hash
* @param Map that got us to this point (that we will use as the base of the map we will return)
@@ -2013,21 +2051,21 @@ public class ModelBasedProcessing {
Vertex thisLevelElemVtx, String incomingTrail,
Map<String,String> currentHash, ArrayList <String> vidsTraversed,
int levelCounter ) throws AAIException {
-
+
levelCounter++;
Map<String, String> thisHash = new HashMap<>();
thisHash.putAll(currentHash);
-
+
if( levelCounter > MAX_LEVELS ) {
throw new AAIException("AAI_6125", "collectNQElementHash() has looped across more levels than allowed: " + MAX_LEVELS + ". ");
}
String thisGuysTrail = "";
String thisElemVid = thisLevelElemVtx.id().toString();
-
+
// Find out what widget (and thereby what aai-node-type) this element represents.
String thisElementNodeType = getNqElementWidgetType( transId, fromAppId, thisLevelElemVtx, incomingTrail );
-
+
if( incomingTrail == null || incomingTrail.equals("") ){
// This is the first one
thisGuysTrail = thisElementNodeType;
@@ -2036,28 +2074,28 @@ public class ModelBasedProcessing {
thisGuysTrail = incomingTrail + "|" + thisElementNodeType;
}
vidsTraversed.add(thisElemVid);
-
+
String nqElementUuid = thisLevelElemVtx.<String>property("named-query-element-uuid").orElse(null);
if( nqElementUuid == null || nqElementUuid.equals("") ){
String msg = " named-query element UUID not found at trail = [" + incomingTrail + "].";
throw new AAIException("AAI_6133", msg);
}
- thisHash.put(thisGuysTrail, nqElementUuid );
-
+ thisHash.put(thisGuysTrail, nqElementUuid );
+
// Now go "down" and look at the sub-elements pointed to so we can get their data.
Iterator<Vertex> vertI = this.traverseIncidentEdges(EdgeType.TREE, thisLevelElemVtx, "named-query-element");
while( vertI != null && vertI.hasNext() ){
Vertex tmpVert = vertI.next();
String vid = tmpVert.id().toString();
Map<String,Object> elementHash = new HashMap<String, Object>();
-
+
String connectToType = tmpVert.<String>property(AAIProperties.NODE_TYPE).orElse(null);
if( connectToType != null && connectToType.equals("named-query-element") ){
// This is what we would expect
elementHash.put(vid, tmpVert);
}
else {
- String msg = " named query element has [connectedTo] edge to improper nodeType= ["
+ String msg = " named query element has [connectedTo] edge to improper nodeType= ["
+ connectToType + "] trail = [" + incomingTrail + "].";
throw new AAIException("AAI_6133", msg);
}
@@ -2066,15 +2104,16 @@ public class ModelBasedProcessing {
String tmpElVid = elVert.id().toString();
if( !vidsTraversed.contains(tmpElVid) ){
// This is one we would like to use - so we'll recursively get it's result set to add to ours
- Map<String, String> tmpHash = collectNQElementHash( transId, fromAppId,
+ Map<String, String> tmpHash = collectNQElementHash( transId, fromAppId,
elVert, thisGuysTrail, currentHash, vidsTraversed, levelCounter);
thisHash.putAll(tmpHash);
}
- }
+ }
}
return thisHash;
- }
-
+
+ } // End of collectNQElementHash()
+
/**
* Collect delete key hash.
@@ -2100,47 +2139,47 @@ public class ModelBasedProcessing {
int levelCounter, Map<String, Vertex> modConstraintHash,
String overRideModelId, String overRideModelVersionId )
throws AAIException {
-
+
levelCounter++;
Map<String, String> thisHash = new HashMap<>();
thisHash.putAll(currentHash);
-
+
if( levelCounter > MAX_LEVELS ) {
throw new AAIException("AAI_6125", "collectDeleteKeyHash() has looped across more levels than allowed: " + MAX_LEVELS + ". ");
}
String thisGuysTrail = "";
String thisElemVid = thisLevelElemVtx.id().toString();
Map<String, Vertex> modConstraintHash2Use = null;
-
- // If this element represents a resource or service model, then we will replace this element with
+
+ // If this element represents a resource or service model, then we will replace this element with
// the "top" element of that resource or service model. That model-element already points to its
- // topology, so it will graft in that model's topology.
+ // topology, so it will graft in that model's topology.
// EXCEPT - if this element has "linkage-points" defined, then we need to do some extra
// processing for how we join to that model and will not try to go any "deeper".
List<String> linkagePtList = new ArrayList<>();
Iterator <VertexProperty<Object>> vpI = thisLevelElemVtx.properties("linkage-points");
- // I am not sure why, but since "linkage-points" is an xml-element-wrapper in the OXM definition,
+ // I am not sure why, but since "linkage-points" is an xml-element-wrapper in the OXM definition,
// we get back the whole array of Strings in one String - but still use the "vtx.properties()" to
// get it - but only look at the first thing returned by the iterator.
if( vpI.hasNext() ){
String tmpLinkageThing = (String)vpI.next().value();
linkagePtList = makeSureItsAnArrayList( tmpLinkageThing );
- }
-
+ }
+
if( linkagePtList != null && !linkagePtList.isEmpty() ){
// Whatever this element is - we are connecting to it via a linkage-point
// We will figure out what to do and then return without going any deeper
String elemFlag = thisLevelElemVtx.<String>property("new-data-del-flag").orElse(null);
-
+
Set<String> linkageConnectNodeTypes = getLinkageConnectNodeTypes( linkagePtList );
Iterator <?> linkNtIter = linkageConnectNodeTypes.iterator();
String incTrail = "";
if( incomingTrail != null && !incomingTrail.equals("") ){
incTrail = incomingTrail + "|";
}
-
+
while( linkNtIter.hasNext() ){
// The 'trail' (or trails) for this element should just be the to the first-contact on the linkage point
String linkTrail = incTrail + linkNtIter.next();
@@ -2161,14 +2200,14 @@ public class ModelBasedProcessing {
}
return thisHash;
}
-
+
// ----------------------------------------------------------------------------
- // If we got to here, then this was not an element that used a linkage-point
+ // If we got to here, then this was not an element that used a linkage-point
// ----------------------------------------------------------------------------
-
+
// Find out what widget-model (and thereby what aai-node-type) this element represents.
// Even if this element is pointing to a service or resource model, it must have a
- // first element which is a single widget-type model.
+ // first element which is a single widget-type model.
String thisElementNodeType = getModElementWidgetType( thisLevelElemVtx, incomingTrail );
String firstElementModelInfo = "";
@@ -2186,11 +2225,11 @@ public class ModelBasedProcessing {
// could be a resource or service model.
firstElementModelInfo = "," + overRideModelId + "," + overRideModelVersionId;
}
- }
+ }
else if( nodeTypeSupportsPersona(thisElementNodeType) ){
firstElementModelInfo = "," + subModelFirstModInvId + "," + subModelFirstVerId;
}
-
+
if( incomingTrail.equals("") ){
// This is the first one
thisGuysTrail = thisElementNodeType + firstElementModelInfo;
@@ -2198,27 +2237,27 @@ public class ModelBasedProcessing {
else {
thisGuysTrail = incomingTrail + "|" + thisElementNodeType + firstElementModelInfo;
}
-
+
String tmpFlag = "F";
Boolean stoppedByASvcOrResourceModelElement = false;
if( modType.equals("widget") ){
elementVtxForThisLevel = thisLevelElemVtx;
- // For the element-model for the widget at this level, record it's delete flag
+ // For the element-model for the widget at this level, record it's delete flag
tmpFlag = elementVtxForThisLevel.<String>property("new-data-del-flag").orElse(null);
}
else {
- // For an element that is referring to a resource or service model, we replace
+ // For an element that is referring to a resource or service model, we replace
// this element with the "top" element for that resource/service model so that the
// topology of that resource/service model will be included in this topology.
String modelVerId = thisElementsModelVerVtx.<String>property("model-version-id").orElse(null);
- if( subModelFirstModInvId == null || subModelFirstModInvId.equals("")
+ if( subModelFirstModInvId == null || subModelFirstModInvId.equals("")
|| subModelFirstVerId == null || subModelFirstVerId.equals("") ){
throw new AAIException("AAI_6132", "Bad Model Definition: Bad model-invariant-id or model-version-id. Model-version-id = " +
modelVerId + ", at [" + incomingTrail + "]");
}
-
- // BUT -- if the model-element HERE at the resource/service level does NOT have
- // it's new-data-del-flag set to "T", then we do not need to go down into the
+
+ // BUT -- if the model-element HERE at the resource/service level does NOT have
+ // it's new-data-del-flag set to "T", then we do not need to go down into the
// sub-model looking for delete-able things.
tmpFlag = thisLevelElemVtx.<String>property("new-data-del-flag").orElse(null);
@@ -2229,10 +2268,10 @@ public class ModelBasedProcessing {
else {
stoppedByASvcOrResourceModelElement = true;
}
- // For the element-model for the widget at this level, record it's delete flag
+ // For the element-model for the widget at this level, record it's delete flag
tmpFlag = elementVtxForThisLevel.<String>property("new-data-del-flag").orElse(null);
}
-
+
String flag2Use = "F"; // by default we'll use "F" for the delete flag
if( ! stoppedByASvcOrResourceModelElement ){
// Since we haven't been stopped by a resource/service level "F", we can look at the lower level flag
@@ -2254,8 +2293,8 @@ public class ModelBasedProcessing {
flag2Use = "T";
}
}
-
- thisHash.put(thisGuysTrail, flag2Use);
+
+ thisHash.put(thisGuysTrail, flag2Use);
if( ! stoppedByASvcOrResourceModelElement ){
// Since we haven't been stopped by a resource/service level "F", we will continue to
// go "down" and look at the elements pointed to so we can get their data.
@@ -2264,7 +2303,7 @@ public class ModelBasedProcessing {
Vertex tmpVert = vertI.next();
String vid = tmpVert.id().toString();
Map<String,Object> elementHash = new HashMap<String, Object>();
-
+
String connectToType = tmpVert.<String>property(AAIProperties.NODE_TYPE).orElse(null);
if( connectToType != null && connectToType.equals("model-element") ){
// A nice, regular old model-element
@@ -2281,15 +2320,15 @@ public class ModelBasedProcessing {
modConstraintHash.remove(constrainedElementSetUuid);
}
else {
- elementHash = getNextStepElementsFromSet( tmpVert );
+ elementHash = getNextStepElementsFromSet( tmpVert );
}
}
else {
- String msg = " model-element has [connectedTo] edge to improper nodeType= ["
+ String msg = " model-element has [connectedTo] edge to improper nodeType= ["
+ connectToType + "] trail = [" + incomingTrail + "].";
throw new AAIException("AAI_6132", msg);
}
-
+
for( Map.Entry<String, Object> entry : elementHash.entrySet() ){
Vertex elVert = (Vertex)(entry.getValue());
String tmpElVid = elVert.id().toString();
@@ -2297,19 +2336,20 @@ public class ModelBasedProcessing {
check4EdgeRule(tmpElNT, thisElementNodeType);
if( !vidsTraversed.contains(tmpElVid) ){
// This is one we would like to use - so we'll recursively get it's result set to add to ours
- Map<String, String> tmpHash = collectDeleteKeyHash( transId, fromAppId,
- elVert, thisGuysTrail,
+ Map<String, String> tmpHash = collectDeleteKeyHash( transId, fromAppId,
+ elVert, thisGuysTrail,
currentHash, vidsTraversed, levelCounter, modConstraintHash2Use,
"", "" );
thisHash.putAll(tmpHash);
}
- }
+ }
}
}
return thisHash;
- }
-
-
+
+ } // End of collectDeleteKeyHash()
+
+
/**
* Gets the linkage connect node types.
*
@@ -2319,18 +2359,18 @@ public class ModelBasedProcessing {
*/
public Set<String> getLinkageConnectNodeTypes(List<String> linkagePtList )
throws AAIException {
- // linkage points are a path from the top of a model to where we link in.
- // This method wants to just bring back a list of distinct last items.
+ // linkage points are a path from the top of a model to where we link in.
+ // This method wants to just bring back a list of distinct last items.
// Ie: for the input with these two: "pserver|lag-link|l-interface" and "pserver|p-interface|l-interface"
// it would just return a single item, "l-interface" since both linkage points end in that same node-type.
-
+
Set<String> linkPtSet = new HashSet<>();
-
+
if( linkagePtList == null ){
String detail = " Bad (null) linkagePtList passed to getLinkageConnectNodeTypes() ";
throw new AAIException("AAI_6125", detail);
}
-
+
for( int i = 0; i < linkagePtList.size(); i++ ){
String [] trailSteps = linkagePtList.get(i).split("\\|");
if( trailSteps == null || trailSteps.length == 0 ){
@@ -2340,11 +2380,12 @@ public class ModelBasedProcessing {
String lastStepNT = trailSteps[trailSteps.length - 1];
linkPtSet.add(lastStepNT);
}
-
+
return linkPtSet;
- }
-
-
+
+ }// End getLinkageConnectNodeTypes()
+
+
/**
* Collect topology for model-ver.
*
@@ -2368,34 +2409,34 @@ public class ModelBasedProcessing {
int levelCounter, Map<String, Vertex> modConstraintHash,
String overRideModelInvId, String overRideModelVersionId )
throws AAIException {
-
+
levelCounter++;
Multimap<String, String> thisMap = ArrayListMultimap.create();
thisMap.putAll(currentMap);
-
+
if( levelCounter > MAX_LEVELS ) {
throw new AAIException("AAI_6125", "collectTopology4ModelVer() has looped across more levels than allowed: " + MAX_LEVELS + ". ");
}
String thisGuysTrail = "";
String thisElemVid = thisLevelElemVtx.id().toString();
Map<String, Vertex> modConstraintHash2Use = null;
-
- // If this element represents a resource or service model, then we will replace this element with
+
+ // If this element represents a resource or service model, then we will replace this element with
// the "top" element of that resource or service model. That model-element already points to its
- // topology, so it will graft in that model's topology.
+ // topology, so it will graft in that model's topology.
// EXCEPT - if this element defines "linkage-points" defined, then we need to do some extra
// processing for how we join to that model.
-
+
// Find out what widget-model (and thereby what aai-node-type) this element represents.
// Even if this element is pointing to a service or resource model, it must have a
- // first element which is a single widget-type model.
+ // first element which is a single widget-type model.
String firstElementModelInfo = "";
String thisElementNodeType = getModElementWidgetType( thisLevelElemVtx, incomingTrail );
if( nodeTypeSupportsPersona(thisElementNodeType) && overRideModelInvId != null && !overRideModelInvId.equals("") ){
firstElementModelInfo = "," + overRideModelInvId + "," + overRideModelVersionId;
}
-
+
Vertex elementVtxForThisLevel = null;
Vertex thisElementsModelVerVtx = getModelVerThatElementRepresents( thisLevelElemVtx, incomingTrail );
String subModelFirstModInvId = "";
@@ -2406,12 +2447,12 @@ public class ModelBasedProcessing {
// For an element that is referring to a resource or service model, we replace this
// this element with the "top" element for that resource/service model so that the
// topology of that resource/service model gets included in this topology.
- // -- Note - since that top element of a service or resource model will point to a widget model,
+ // -- Note - since that top element of a service or resource model will point to a widget model,
// we have to track what modelId/version it really maps so we can make our recursive call
Vertex thisElementsModelVtx = getModelGivenModelVer(thisElementsModelVerVtx, incomingTrail);
subModelFirstModInvId = thisElementsModelVtx.<String>property("model-invariant-id").orElse(null);
subModelFirstModVerId = thisElementsModelVerVtx.<String>property("model-version-id").orElse(null);
-
+
if( nodeTypeSupportsPersona(thisElementNodeType) ){
modInfo4Trail = "," + subModelFirstModInvId + "," + subModelFirstModVerId;
}
@@ -2420,13 +2461,13 @@ public class ModelBasedProcessing {
throw new AAIException("AAI_6132", "Bad Model Definition: Bad model-invariant-id or model-version-id. Model-ver-id = " + modelVerId);
}
- elementVtxForThisLevel = getTopElementForSvcOrResModelVer(thisElementsModelVerVtx, incomingTrail);
+ elementVtxForThisLevel = getTopElementForSvcOrResModelVer(thisElementsModelVerVtx, incomingTrail);
modConstraintHash2Use = getModConstraintHash( thisLevelElemVtx, modConstraintHash );
}
else {
elementVtxForThisLevel = thisLevelElemVtx;
}
-
+
if( incomingTrail.equals("") ){
// This is the first one
thisGuysTrail = thisElementNodeType + firstElementModelInfo;
@@ -2434,7 +2475,7 @@ public class ModelBasedProcessing {
else {
thisGuysTrail = incomingTrail + "|" + thisElementNodeType + modInfo4Trail;
}
-
+
// We only want to ensure that a particular element does not repeat on a single "branch".
// It could show up on other branches in the case where it is a sub-model which is being
// used in more than one place.
@@ -2442,7 +2483,7 @@ public class ModelBasedProcessing {
List<String> thisTrailsVidsTraversed = new ArrayList <String>();
thisTrailsVidsTraversed.addAll(vidsTraversed);
thisTrailsVidsTraversed.add(thisElemVid);
-
+
// Look at the elements pointed to at this level and add on their data
Iterator<Vertex> vertI = this.traverseIncidentEdges(EdgeType.TREE, elementVtxForThisLevel, "model-element", "constrained-element-set");
@@ -2466,35 +2507,35 @@ public class ModelBasedProcessing {
modConstraintHash.remove(constrainedElementSetUuid);
}
else {
- elementHash = getNextStepElementsFromSet( tmpVert );
+ elementHash = getNextStepElementsFromSet( tmpVert );
}
}
else {
- String msg = " model element has [connectedTo] edge to improper nodeType= ["
+ String msg = " model element has [connectedTo] edge to improper nodeType= ["
+ connectToType + "] trail = [" + incomingTrail + "].";
throw new AAIException("AAI_6132", msg);
}
-
+
for( Map.Entry<String, Object> entry : elementHash.entrySet() ){
Vertex elVert = (Vertex)(entry.getValue());
String tmpElVid = elVert.id().toString();
String tmpElNT = getModElementWidgetType( elVert, thisGuysTrail );
String tmpElStepName = getModelElementStepName( elVert, thisGuysTrail);
-
+
List<String> linkagePtList = new ArrayList <String>();
Iterator <VertexProperty<Object>> vpI = elVert.properties("linkage-points");
-
- // I am not sure why, but since "linkage-points" is an xml-element-wrapper in the OXM definition,
+
+ // I am not sure why, but since "linkage-points" is an xml-element-wrapper in the OXM definition,
// we get back the whole array of Strings in one String - but still use the "vtx.properties()" to
// get it - but only look at the first thing returned by the iterator.
if( vpI.hasNext() ){
String tmpLinkageThing = (String)vpI.next().value();
linkagePtList = makeSureItsAnArrayList( tmpLinkageThing );
- }
-
+ }
+
if( linkagePtList != null && !linkagePtList.isEmpty() ){
- // This is as far as we can go, we will use the linkage point info to define the
- // rest of this "trail"
+ // This is as far as we can go, we will use the linkage point info to define the
+ // rest of this "trail"
for( int i = 0; i < linkagePtList.size(); i++ ){
Multimap<String, String> tmpMap = collectTopology4LinkagePoint( transId, fromAppId,
linkagePtList.get(i), thisGuysTrail, currentMap);
@@ -2507,8 +2548,8 @@ public class ModelBasedProcessing {
if( !thisTrailsVidsTraversed.contains(tmpElVid) ){
// This is one we would like to use - so we'll recursively get it's result set to add to ours
Multimap<String, String> tmpMap = collectTopology4ModelVer( transId, fromAppId,
- elVert, thisGuysTrail,
- currentMap, thisTrailsVidsTraversed, levelCounter,
+ elVert, thisGuysTrail,
+ currentMap, thisTrailsVidsTraversed, levelCounter,
modConstraintHash2Use, subModelFirstModInvId, subModelFirstModVerId );
thisMap.putAll(tmpMap);
}
@@ -2519,14 +2560,16 @@ public class ModelBasedProcessing {
" on trail = [" + thisGuysTrail + "]. ";
System.out.println( msg );
throw new AAIException("AAI_6132", msg);
- }
- }
- }
+ }
+ }
+ }
}
+
return thisMap;
- }
-
-
+
+ } // End of collectTopology4ModelVer()
+
+
/**
* Check 4 edge rule.
*
@@ -2537,11 +2580,16 @@ public class ModelBasedProcessing {
*/
public void check4EdgeRule( String nodeTypeA, String nodeTypeB) throws AAIException {
// Throw an exception if there is no defined edge rule for this combination of nodeTypes in DbEdgeRules.
-
- final EdgeRules edgeRules = EdgeRules.getInstance();
-
- if( !edgeRules.hasEdgeRule(nodeTypeA, nodeTypeB)
- && !edgeRules.hasEdgeRule(nodeTypeB, nodeTypeA) ){
+
+ final EdgeIngestor edgeRules = SpringContextAware.getApplicationContext().getBean(EdgeIngestor.class);
+ //final EdgeRules edgeRules = EdgeRules.getInstance();
+
+ EdgeRuleQuery.Builder baseQ = new EdgeRuleQuery.Builder(nodeTypeA, nodeTypeB);
+ if (!edgeRules.hasRule(baseQ.build())) {
+
+
+ /* if( !edgeRules.hasEdgeRule(nodeTypeA, nodeTypeB)
+ && !edgeRules.hasEdgeRule(nodeTypeB, nodeTypeA) ){*/
// There's no EdgeRule for this -- find out if one of the nodeTypes is invalid or if
// they are valid, but there's just no edgeRule for them.
try {
@@ -2556,14 +2604,16 @@ public class ModelBasedProcessing {
String emsg = " Unrecognized nodeType bb [" + nodeTypeB + "]\n";
throw new AAIException("AAI_6115", emsg);
}
-
- String msg = " No Edge Rule found for this pair of nodeTypes (order does not matter) ["
+
+ String msg = " No Edge Rule found for this pair of nodeTypes (order does not matter) ["
+ nodeTypeA + "], [" + nodeTypeB + "].";
throw new AAIException("AAI_6120", msg);
}
+
+
}
-
-
+
+
/**
* Collect topology 4 linkage point.
*
@@ -2583,11 +2633,11 @@ public class ModelBasedProcessing {
Multimap<String, String> thisMap = ArrayListMultimap.create();
thisMap.putAll(currentMap);
String thisGuysTrail = incomingTrail;
-
+
// NOTE - "trails" can have multiple parts now since we track persona info for some.
// We just want to look at the node type info - which would be the piece
// before any commas (if there are any).
-
+
String [] trailSteps = thisGuysTrail.split("\\|");
if( trailSteps == null || trailSteps.length == 0 ){
throw new AAIException("AAI_6125", "Bad incomingTrail passed to collectTopology4LinkagePoint(): [" + incomingTrail + "] ");
@@ -2595,23 +2645,23 @@ public class ModelBasedProcessing {
String lastStepString = trailSteps[trailSteps.length - 1];
String [] stepPieces = lastStepString.split(",");
String lastStepNT = stepPieces[0];
-
+
// It is assumed that the linkagePoint string will be a pipe-delimited string where each
// piece is an AAIProperties.NODE_TYPE. For now, the first thing to connect to is what is on the farthest right.
// Example: linkagePoint = "pserver|p-interface|l-interface" would mean that we're connecting to the l-interface
// but that after that, we connect to a p-interface followed by a pserver.
// It might have been more clear to define it in the other direction, but for now, that is it. (16-07)
String linkagePointStr = linkagePointStrVal;
-
- // We are getting these with more than linkage thing in one string.
+
+ // We are getting these with more than linkage thing in one string.
// Ie. "pserver|lag-interface|l-interface, pserver|p-interface|l-interface, vlan|l-interface"
linkagePointStr = linkagePointStr.replace("[", "");
linkagePointStr = linkagePointStr.replace("]", "");
linkagePointStr = linkagePointStr.replace(" ", "");
-
+
String [] linkage = linkagePointStr.split("\\,");
for( int x = 0; x < linkage.length; x++ ){
- lastStepNT = stepPieces[0];
+ lastStepNT = stepPieces[0];
String thisStepNT = "";
String [] linkageSteps = linkage[x].split("\\|");
if( linkageSteps == null || linkageSteps.length == 0 ){
@@ -2626,10 +2676,10 @@ public class ModelBasedProcessing {
}
}
return thisMap;
-
- }
-
-
+
+ } // End of collectTopology4LinkagePoint()
+
+
/**
* Gets the next step elements from set.
*
@@ -2641,21 +2691,21 @@ public class ModelBasedProcessing {
throws AAIException {
// Take a constrained-element-set and figure out the total set of all the possible elements that it
// represents and return them as a Hash.
-
+
Map<String,Object> retElementHash = new HashMap<String, Object>();
-
+
if( constrElemSetVtx == null ){
String msg = " getNextStepElementsFromSet() called with null constrElemSetVtx ";
throw new AAIException("AAI_6125", msg);
}
-
+
String constrNodeType = constrElemSetVtx.<String>property(AAIProperties.NODE_TYPE).orElse(null);
String constrElemSetUuid = constrElemSetVtx.<String>property("constrained-element-set-uuid").orElse(null);
if( constrNodeType == null || !constrNodeType.equals("constrained-element-set") ){
String msg = " getNextStepElementsFromSet() called with wrong type model: [" + constrNodeType + "]. ";
throw new AAIException("AAI_6125", msg);
}
-
+
ArrayList <Vertex> choiceSetVertArray = new ArrayList<Vertex>();
Iterator<Vertex> vertI = this.traverseIncidentEdges(EdgeType.TREE, constrElemSetVtx, "element-choice-set");
int setCount = 0;
@@ -2667,12 +2717,12 @@ public class ModelBasedProcessing {
setCount++;
}
}
-
+
if( setCount == 0 ){
String msg = "No element-choice-set found under constrained-element-set-uuid = " + constrElemSetUuid;
throw new AAIException("AAI_6132", msg);
}
-
+
// Loop through each choice-set and grab the model-elements
for( int i = 0; i < setCount; i++ ){
Vertex choiceSetVert = choiceSetVertArray.get(i);
@@ -2688,24 +2738,24 @@ public class ModelBasedProcessing {
}
else {
// unsupported node type found for this choice-set
- String msg = "Unsupported nodeType (" + elNodeType
+ String msg = "Unsupported nodeType (" + elNodeType
+ ") found under choice-set under constrained-element-set-uuid = " + constrElemSetUuid;
throw new AAIException("AAI_6132", msg);
}
}
-
+
if( elCount == 0 ){
String msg = "No model-elements found in choice-set under constrained-element-set-uuid = " + constrElemSetUuid;
throw new AAIException("AAI_6132", msg);
}
-
+
}
return retElementHash;
-
- }
-
-
-
+
+ } // End of getNextStepElementsFromSet()
+
+
+
/**
* Gen topo map 4 named Q.
*
@@ -2719,14 +2769,14 @@ public class ModelBasedProcessing {
public Multimap<String, String> genTopoMap4NamedQ(String transId, String fromAppId,
Vertex queryVertex, String namedQueryUuid )
throws AAIException {
-
+
if( queryVertex == null ){
throw new AAIException("AAI_6125", "null queryVertex passed to genTopoMap4NamedQ()");
}
-
+
Multimap<String, String> initialEmptyMap = ArrayListMultimap.create();
List<String> vidsTraversed = new ArrayList<>();
-
+
Vertex firstElementVertex = null;
Iterator<Vertex> vertI = this.traverseIncidentEdges(EdgeType.TREE, queryVertex, "named-query-element");
int elCount = 0;
@@ -2734,29 +2784,32 @@ public class ModelBasedProcessing {
elCount++;
firstElementVertex = vertI.next();
}
-
+
if( elCount > 1 ){
throw new AAIException("AAI_6133", "Illegal query defined: More than one first element defined for = " + namedQueryUuid);
}
-
+
if( firstElementVertex == null ){
throw new AAIException("AAI_6114", "Could not find first query element = " + namedQueryUuid);
}
-
+
Vertex modVtx = getModelThatNqElementRepresents( firstElementVertex, "" );
- String modelType = getModelTypeFromModel( modVtx, "" );
+ String modelType = getModelTypeFromModel( modVtx, "" );
if( ! modelType.equals("widget") ){
throw new AAIException("AAI_6133", "Bad Named Query Definition: First element must correspond to a widget type model. Named Query UUID = "
+ namedQueryUuid);
}
-
- return collectTopology4NamedQ( transId, fromAppId,
- firstElementVertex, "",
+
+ Multimap<String, String> collectedMap = collectTopology4NamedQ( transId, fromAppId,
+ firstElementVertex, "",
initialEmptyMap, vidsTraversed, 0);
- }
-
-
+
+ return collectedMap;
+
+ } // End of genTopoMap4NamedQ()
+
+
/**
* Collect topology 4 named Q.
*
@@ -2771,21 +2824,21 @@ public class ModelBasedProcessing {
Vertex thisLevelElemVtx, String incomingTrail,
Multimap<String,String> currentMap, List<String> vidsTraversed, int levelCounter )
throws AAIException {
-
+
levelCounter++;
Multimap<String, String> thisMap = ArrayListMultimap.create();
thisMap.putAll(currentMap);
-
+
String thisElemVid = thisLevelElemVtx.id().toString();
if( levelCounter > MAX_LEVELS ) {
throw new AAIException("AAI_6125", "collectModelStructure() has looped across more levels than allowed: " + MAX_LEVELS + ". ");
}
String thisGuysTrail = "";
-
+
// find out what widget (and thereby what aai-node-type) this element represents
String thisElementNodeType = getNqElementWidgetType( transId, fromAppId, thisLevelElemVtx, incomingTrail );
-
+
if( incomingTrail.equals("") ){
// This is the first one
thisGuysTrail = thisElementNodeType;
@@ -2793,9 +2846,9 @@ public class ModelBasedProcessing {
else {
thisGuysTrail = incomingTrail + "|" + thisElementNodeType;
}
-
+
vidsTraversed.add(thisElemVid);
-
+
// Look at the elements pointed to at this level and add on their data
Iterator<Vertex> vertI = this.traverseIncidentEdges(EdgeType.TREE, thisLevelElemVtx, "named-query-element");
while( vertI != null && vertI.hasNext() ){
@@ -2806,15 +2859,15 @@ public class ModelBasedProcessing {
if( !vidsTraversed.contains(tmpVid) ){
// This is one we would like to use - so we'll recursively get it's result set to add to ours
Multimap<String, String> tmpMap = collectTopology4NamedQ( transId, fromAppId,
- tmpVert, thisGuysTrail,
+ tmpVert, thisGuysTrail,
currentMap, vidsTraversed, levelCounter);
thisMap.putAll(tmpMap);
}
}
-
+
return thisMap;
-
- }
+
+ } // End of collectTopology4NamedQ()
/**
@@ -2827,7 +2880,7 @@ public class ModelBasedProcessing {
*/
public Vertex getModelThatNqElementRepresents(Vertex elementVtx, String elementTrail )
throws AAIException {
-
+
// Get the model that a named-query element represents
Vertex modVtx = null;
Iterator<Vertex> mvertI = this.traverseIncidentEdges(EdgeType.COUSIN, elementVtx, "model");
@@ -2836,13 +2889,13 @@ public class ModelBasedProcessing {
modCount++;
modVtx = mvertI.next();
}
-
+
if( modCount > 1 ){
String msg = "Illegal element defined: More than one model pointed to by a single named-query-element at [" +
elementTrail + "].";
throw new AAIException("AAI_6125", msg);
}
-
+
if( modVtx == null ){
String msg = "Bad named-query definition: Could not find model for element. ";
if( !elementTrail.equals("") ){
@@ -2850,20 +2903,20 @@ public class ModelBasedProcessing {
}
throw new AAIException("AAI_6132", msg);
}
-
+
String nodeType = modVtx.<String>property(AAIProperties.NODE_TYPE).orElse(null);
if( (nodeType != null) && nodeType.equals("model") ){
return modVtx;
}
else {
- String msg = "Illegal Named Query element defined: expecting a 'model', but found 'isA' edge pointing to nodeType = " +
+ String msg = "Illegal Named Query element defined: expecting a 'model', but found 'isA' edge pointing to nodeType = " +
nodeType + "] at [" + elementTrail + "].";
throw new AAIException("AAI_6125", msg);
- }
-
- }
-
-
+ }
+
+ }// getModelThatNqElementRepresents()
+
+
/**
* Gets the model-ver that element represents.
*
@@ -2874,7 +2927,7 @@ public class ModelBasedProcessing {
*/
public Vertex getModelVerThatElementRepresents(Vertex elementVtx, String elementTrail )
throws AAIException {
-
+
// Get the model-ver that an element represents
Vertex modVerVtx = null;
Iterator<Vertex> mvertI = this.traverseIncidentEdges(EdgeType.COUSIN, elementVtx, "model-ver");
@@ -2883,13 +2936,13 @@ public class ModelBasedProcessing {
modCount++;
modVerVtx = mvertI.next();
}
-
+
if( modCount > 1 ){
String msg = "Illegal element defined: More than one model pointed to by a single element at [" +
elementTrail + "].";
throw new AAIException("AAI_6125", msg);
}
-
+
if( modVerVtx == null ){
String msg = "Bad model definition: Could not find model-ver for model-element. ";
if( !elementTrail.equals("") ){
@@ -2897,21 +2950,21 @@ public class ModelBasedProcessing {
}
throw new AAIException("AAI_6132", msg);
}
-
+
String nodeType = modVerVtx.<String>property(AAIProperties.NODE_TYPE).orElse(null);
if( (nodeType != null) && nodeType.equals("model-ver") ){
return modVerVtx;
}
else {
- String msg = "Illegal model-element defined: expecting a 'model-ver', but found 'isA' edge pointing to nodeType = " +
+ String msg = "Illegal model-element defined: expecting a 'model-ver', but found 'isA' edge pointing to nodeType = " +
nodeType + "] at [" + elementTrail + "].";
throw new AAIException("AAI_6125", msg);
}
-
- }
-
-
-
+
+ }// getModelVerThatElementRepresents()
+
+
+
/**
* Gets the model that is parent to model-ver node.
*
@@ -2922,7 +2975,7 @@ public class ModelBasedProcessing {
*/
public Vertex getModelGivenModelVer(Vertex modVerVtx, String elementTrail )
throws AAIException {
-
+
// Get the parent model for this "model-ver" node
Vertex modVtx = null;
Iterator<Vertex> mvertI = this.traverseIncidentEdges(EdgeType.TREE, modVerVtx, "model");
@@ -2931,13 +2984,13 @@ public class ModelBasedProcessing {
modCount++;
modVtx = mvertI.next();
}
-
+
if( modCount > 1 ){
String msg = "Illegal model-ver node defined: More than one model points to it with a 'has' edge [" +
elementTrail + "].";
throw new AAIException("AAI_6125", msg);
}
-
+
if( modVtx == null ){
String msg = "Bad model-ver node: Could not find parent model. ";
if( !elementTrail.equals("") ){
@@ -2945,7 +2998,7 @@ public class ModelBasedProcessing {
}
throw new AAIException("AAI_6132", msg);
}
-
+
String nodeType = modVtx.<String>property(AAIProperties.NODE_TYPE).orElse(null);;
if( (nodeType != null) && nodeType.equals("model") ){
// Found what we were looking for.
@@ -2957,12 +3010,12 @@ public class ModelBasedProcessing {
elementTrail + "].";
throw new AAIException("AAI_6125", msg);
}
-
-
- }
-
-
-
+
+
+ }// getModelGivenModelVer()
+
+
+
/**
* Gets the model type.
*
@@ -2973,30 +3026,30 @@ public class ModelBasedProcessing {
*/
public String getModelTypeFromModel(Vertex modelVtx, String elementTrail )
throws AAIException {
-
+
// Get the model-type from a model vertex
if( modelVtx == null ){
String msg = " null modelVtx passed to getModelTypeFromModel() ";
throw new AAIException("AAI_6114", msg);
- }
-
+ }
+
String modelType = modelVtx.<String>property("model-type").orElse(null);
if( (modelType == null) || modelType.equals("") ){
String msg = "Could not find model-type for model encountered at [" + elementTrail + "].";
throw new AAIException("AAI_6132", msg);
}
-
+
if( !modelType.equals("widget") && !modelType.equals("resource") && !modelType.equals("service") ){
String msg = "Unrecognized model-type, [" + modelType + "] for model pointed to by element at [" + elementTrail + "].";
throw new AAIException("AAI_6132", msg);
}
-
- return modelType;
-
- }
-
-
-
+
+ return modelType;
+
+ }// getModelTypeFromModel()
+
+
+
/**
* Gets the model type given model-ver
*
@@ -3007,29 +3060,30 @@ public class ModelBasedProcessing {
*/
public String getModelTypeFromModelVer(Vertex modelVerVtx, String elementTrail )
throws AAIException {
-
+
// Get the model-type given a model-ver vertex
if( modelVerVtx == null ){
String msg = " null modelVerVtx passed to getModelTypeFromModelVer() ";
throw new AAIException("AAI_6114", msg);
- }
-
+ }
+
Vertex modVtx = getModelGivenModelVer( modelVerVtx, elementTrail );
String modelType = modVtx.<String>property("model-type").orElse(null);
if( (modelType == null) || modelType.equals("") ){
String msg = "Could not find model-type for model encountered at [" + elementTrail + "].";
throw new AAIException("AAI_6132", msg);
}
-
+
if( !modelType.equals("widget") && !modelType.equals("resource") && !modelType.equals("service") ){
String msg = "Unrecognized model-type, [" + modelType + "] for model pointed to by element at [" + elementTrail + "].";
throw new AAIException("AAI_6132", msg);
}
-
- return modelType;
- }
-
-
+
+ return modelType;
+
+ }// getModelTypeFromModelVer()
+
+
/**
* Gets the model-element step name.
@@ -3042,8 +3096,8 @@ public class ModelBasedProcessing {
*/
public String getModelElementStepName(Vertex elementVtx, String elementTrail)
throws AAIException {
-
- // Get the "step name" for a model-element
+
+ // Get the "step name" for a model-element
// Step names look like this for widget-models: AAIProperties.NODE_TYPE
// Step names look like this for resource/service models: "aai-node-type,model-invariant-id,model-version-id"
// NOTE -- if the element points to a resource or service model, then we'll return the
@@ -3051,14 +3105,14 @@ public class ModelBasedProcessing {
String thisElementNodeType = "?";
Vertex modVerVtx = getModelVerThatElementRepresents( elementVtx, elementTrail );
String modelType = getModelTypeFromModelVer( modVerVtx, elementTrail );
-
+
if( modelType == null ){
String msg = " could not determine modelType in getModelElementStepName(). elementTrail = [" + elementTrail + "].";
throw new AAIException("AAI_6132", msg);
}
-
+
if( modelType.equals("widget") ){
- // NOTE: for models that have model-type = "widget", their "model-name" maps directly to aai-node-type
+ // NOTE: for models that have model-type = "widget", their "model-name" maps directly to aai-node-type
thisElementNodeType = modVerVtx.<String>property("model-name").orElse(null);
if( (thisElementNodeType == null) || thisElementNodeType.equals("") ){
String msg = "Could not find model-name for the widget model pointed to by element at [" + elementTrail + "].";
@@ -3068,17 +3122,17 @@ public class ModelBasedProcessing {
}
else if( modelType.equals("resource") || modelType.equals("service") ){
Vertex modVtx = getModelGivenModelVer( modVerVtx, elementTrail );
- String modInvId = modVtx.<String>property("model-invariant-id").orElse(null);
+ String modInvId = modVtx.<String>property("model-invariant-id").orElse(null);
String modVerId = modVerVtx.<String>property("model-version-id").orElse(null);
Vertex relatedTopElementModelVtx = getTopElementForSvcOrResModelVer( modVerVtx, elementTrail );
Vertex relatedModelVtx = getModelVerThatElementRepresents( relatedTopElementModelVtx, elementTrail );
thisElementNodeType = relatedModelVtx.<String>property("model-name").orElse(null);
-
+
if( (thisElementNodeType == null) || thisElementNodeType.equals("") ){
String msg = "Could not find model-name for the widget model pointed to by element at [" + elementTrail + "].";
throw new AAIException("AAI_6132", msg);
}
-
+
String stepName = "";
if( nodeTypeSupportsPersona(thisElementNodeType) ){
// This nodeType that this resource or service model refers to does support persona-related fields, so
@@ -3094,10 +3148,11 @@ public class ModelBasedProcessing {
String msg = " Unrecognized model-type = [" + modelType + "] pointed to by element at [" + elementTrail + "].";
throw new AAIException("AAI_6132", msg);
}
- }
-
-
-
+
+ }// getModelElementStepName()
+
+
+
/**
* Node type supports persona.
*
@@ -3108,7 +3163,7 @@ public class ModelBasedProcessing {
*/
public Boolean nodeTypeSupportsPersona(String nodeType)
throws AAIException {
-
+
if( nodeType == null || nodeType.equals("") ){
return false;
}
@@ -3119,13 +3174,18 @@ public class ModelBasedProcessing {
String emsg = " Unrecognized nodeType [" + nodeType + "]\n";
throw new AAIException("AAI_6115", emsg);
}
-
+
Collection <String> props4ThisNT = loader.introspectorFromName(nodeType).getProperties();
- return props4ThisNT.contains(addDBAliasedSuffix("model-invariant-id")) &&
- props4ThisNT.contains(addDBAliasedSuffix("model-version-id"));
- }
-
-
+ if( !props4ThisNT.contains(addDBAliasedSuffix("model-invariant-id")) || !props4ThisNT.contains(addDBAliasedSuffix("model-version-id")) ){
+ return false;
+ }
+ else {
+ return true;
+ }
+
+ }// nodeTypeSupportsPersona()
+
+
/**
* Gets a Named Query element's widget type.
*
@@ -3137,16 +3197,16 @@ public class ModelBasedProcessing {
public String getNqElementWidgetType(String transId, String fromAppId,
Vertex elementVtx, String elementTrail )
throws AAIException {
-
+
String thisNqElementWidgetType = "";
// Get the associated node-type for the model pointed to by a named-query-element.
// NOTE -- if the element points to a resource or service model, then we'll return the
// widget-type of the first element (crown widget) for that model.
Vertex modVtx = getModelThatNqElementRepresents( elementVtx, elementTrail );
String modelType = getModelTypeFromModel( modVtx, elementTrail );
-
+
if( modelType == null || !modelType.equals("widget") ){
- String emsg = " Model Type must be 'widget' for NamedQuery elements. Found [" + modelType + "] at [" +
+ String emsg = " Model Type must be 'widget' for NamedQuery elements. Found [" + modelType + "] at [" +
elementTrail + "]\n";
throw new AAIException("AAI_6132", emsg);
}
@@ -3164,9 +3224,11 @@ public class ModelBasedProcessing {
return thisNqElementWidgetType;
}
}
- }
-
-
+
+
+ }// End getNqElementWidgetType()
+
+
/**
* Gets a model-element's top widget type.
*
@@ -3177,21 +3239,23 @@ public class ModelBasedProcessing {
*/
public String getModElementWidgetType(Vertex elementVtx, String elementTrail )
throws AAIException {
-
+
// Get the associated node-type for the model-ver pointed to by a model-element.
// NOTE -- if the element points to a resource or service model, then we'll return the
// widget-type of the first element (crown widget) for that model.
Vertex modVerVtx = getModelVerThatElementRepresents( elementVtx, elementTrail );
- return getModelVerTopWidgetType( modVerVtx, elementTrail );
- }
-
-
+ String thisElementNodeType = getModelVerTopWidgetType( modVerVtx, elementTrail );
+ return thisElementNodeType;
+
+ }// End getModElementWidgetType()
+
+
/**
* Gets the node using unique identifier
*
* @param transId the trans id
* @param fromAppId the from app id
- * @param nodeType the nodeType
+ * @param nodeType the nodeType
* @param idPropertyName the property name of the unique identifier
* @param uniqueIdVal the UUID value
* @return unique vertex found using UUID
@@ -3200,41 +3264,41 @@ public class ModelBasedProcessing {
public Vertex getNodeUsingUniqueId(String transId, String fromAppId,
String nodeType, String idPropertyName, String uniqueIdVal )
throws AAIException {
-
- // Given a unique identifier, get the Vertex
+
+ // Given a unique identifier, get the Vertex
if( uniqueIdVal == null || uniqueIdVal.equals("") ){
- String emsg = " Bad uniqueIdVal passed to getNodeUsingUniqueId(): ["
+ String emsg = " Bad uniqueIdVal passed to getNodeUsingUniqueId(): ["
+ uniqueIdVal + "]\n";
throw new AAIException("AAI_6118", emsg);
}
-
+
if( idPropertyName == null || idPropertyName.equals("") ){
- String emsg = " Bad idPropertyName passed to getNodeUsingUniqueId(): ["
+ String emsg = " Bad idPropertyName passed to getNodeUsingUniqueId(): ["
+ idPropertyName + "]\n";
throw new AAIException("AAI_6118", emsg);
- }
-
+ }
+
if( nodeType == null || nodeType.equals("") ){
- String emsg = " Bad nodeType passed to getNodeUsingUniqueId(): ["
+ String emsg = " Bad nodeType passed to getNodeUsingUniqueId(): ["
+ nodeType + "]\n";
throw new AAIException("AAI_6118", emsg);
- }
-
+ }
+
Vertex uniqVtx = null;
Iterable <?> uniqVerts = null;
uniqVerts = engine.asAdmin().getReadOnlyTraversalSource().V().has(AAIProperties.NODE_TYPE,nodeType).has(idPropertyName,uniqueIdVal).toList();
if( uniqVerts == null ){
- String emsg = "Node could not be found for nodeType = [" + nodeType
- + "], propertyName = [" + idPropertyName
+ String emsg = "Node could not be found for nodeType = [" + nodeType
+ + "], propertyName = [" + idPropertyName
+ "], propertyValue = [" + uniqueIdVal + "]\n";
throw new AAIException("AAI_6114", emsg);
}
- else {
+ else {
int count = 0;
Iterator <?> uniqVertsIter = uniqVerts.iterator();
if( !uniqVertsIter.hasNext() ){
- String emsg = "Node could not be found for nodeType = [" + nodeType
- + "], propertyName = [" + idPropertyName
+ String emsg = "Node could not be found for nodeType = [" + nodeType
+ + "], propertyName = [" + idPropertyName
+ "], propertyValue = [" + uniqueIdVal + "]\n";
throw new AAIException("AAI_6114", emsg);
}
@@ -3243,18 +3307,19 @@ public class ModelBasedProcessing {
count++;
uniqVtx = (Vertex) uniqVertsIter.next();
if( count > 1 ){
- String emsg = "More than one node found for nodeType = [" + nodeType
- + "], propertyName = [" + idPropertyName
+ String emsg = "More than one node found for nodeType = [" + nodeType
+ + "], propertyName = [" + idPropertyName
+ "], propertyValue = [" + uniqueIdVal + "]\n";
throw new AAIException("AAI_6132", emsg);
}
}
}
}
+
return uniqVtx;
- }
-
-
+ }// End getNodeUsingUniqueId()
+
+
/**
* Gets the model-ver nodes using name.
*
@@ -3267,97 +3332,102 @@ public class ModelBasedProcessing {
public List<Vertex> getModelVersUsingName(String transId, String fromAppId,
String modelName )
throws AAIException {
-
+
// Given a "model-name", find the model-ver vertices that this maps to
if( modelName == null || modelName.equals("") ){
- String emsg = " Bad modelName passed to getModelVersUsingName(): ["
+ String emsg = " Bad modelName passed to getModelVersUsingName(): ["
+ modelName + "]\n";
throw new AAIException("AAI_6118", emsg);
}
-
+
List<Vertex> retVtxArr = new ArrayList<>();
Iterator<Vertex> modVertsIter = this.engine.asAdmin().getReadOnlyTraversalSource().V().has(AAIProperties.NODE_TYPE,"model-ver").has("model-name",modelName);
if( !modVertsIter.hasNext() ){
- String emsg = "Model-ver record(s) could not be found for model-ver data passed. model-name = [" +
+ String emsg = "Model-ver record(s) could not be found for model-ver data passed. model-name = [" +
modelName + "]\n";
throw new AAIException("AAI_6132", emsg);
}
- else {
+ else {
while( modVertsIter.hasNext() ){
- Vertex tmpModelVerVtx = modVertsIter.next();
+ Vertex tmpModelVerVtx = (Vertex) modVertsIter.next();
retVtxArr.add(tmpModelVerVtx);
}
}
+
return retVtxArr;
- }
-
-
+
+ }// End getModelVersUsingName()
+
+
/**
* Gets the model-ver nodes using model-invariant-id.
*
* @param transId the trans id
* @param fromAppId the from app id
* @param model-invariant-id (uniquely identifies a model)
- * @return the model-ver's defined for the corresponding model
+ * @return the model-ver's defined for the corresponding model
* @throws AAIException the AAI exception
*/
public Iterator<Vertex> getModVersUsingModelInvId(String transId, String fromAppId,
String modelInvId )
throws AAIException {
-
+
// Given a "model-invariant-id", find the model-ver nodes that this maps to
if( modelInvId == null || modelInvId.equals("") ){
- String emsg = " Bad model-invariant-id passed to getModVersUsingModelInvId(): ["
+ String emsg = " Bad model-invariant-id passed to getModVersUsingModelInvId(): ["
+ modelInvId + "]\n";
throw new AAIException("AAI_6118", emsg);
}
-
+
Vertex modVtx = getNodeUsingUniqueId(transId, fromAppId, "model", "model-invariant-id", modelInvId);
List<Vertex> retVtxArr = getModVersUsingModel(transId, fromAppId, modVtx);
if( retVtxArr == null || retVtxArr.isEmpty() ){
- String emsg = " Model-ver record(s) could not be found attached to model with model-invariant-id = [" +
+ String emsg = " Model-ver record(s) could not be found attached to model with model-invariant-id = [" +
modelInvId + "]\n";
throw new AAIException("AAI_6132", emsg);
}
+
return retVtxArr.iterator();
- }
-
-
+ }// End getModVersUsingModelInvId()
+
+
/**
* Gets the model-ver nodes using a model node.
*
* @param transId the trans id
* @param fromAppId the from app id
* @param model vertex
- * @return the model-ver's defined for the corresponding model
+ * @return the model-ver's defined for the corresponding model
* @throws AAIException the AAI exception
*/
public List<Vertex> getModVersUsingModel(String transId, String fromAppId,
Vertex modVtx )
throws AAIException {
-
+
if( modVtx == null ){
String emsg = " Null model vertex passed to getModVersUsingModel(): ";
throw new AAIException("AAI_6118", emsg);
}
-
+
List<Vertex> retVtxArr = new ArrayList<>();
Iterator<Vertex> modVerVertsIter = this.traverseIncidentEdges(EdgeType.TREE, modVtx, "model-ver");
if(!modVerVertsIter.hasNext()){
String modelInvId = modVtx.<String>property("model-invariant-id").orElse(null);
- String emsg = "Model-ver record(s) could not be found attached to model with model-invariant-id = [" +
+ String emsg = "Model-ver record(s) could not be found attached to model with model-invariant-id = [" +
modelInvId + "]\n";
throw new AAIException("AAI_6132", emsg);
}
- else {
+ else {
while( modVerVertsIter.hasNext() ){
- Vertex tmpModelVtx = modVerVertsIter.next();
+ Vertex tmpModelVtx = (Vertex) modVerVertsIter.next();
retVtxArr.add(tmpModelVtx);
}
}
+
return retVtxArr;
- }
-
+
+ }// End getModVersUsingModel()
+
/**
* Gets the model-version-ids using model-name.
*
@@ -3370,40 +3440,41 @@ public class ModelBasedProcessing {
public List<String> getModelVerIdsUsingName( String transId, String fromAppId,
String modelName )
throws AAIException {
-
+
// Given a model-name find the model-ver nodes that it maps to
if( modelName == null || modelName.equals("") ){
- String emsg = " Bad modelName passed to getModelVerIdsUsingName(): ["
+ String emsg = " Bad modelName passed to getModelVerIdsUsingName(): ["
+ modelName + "]\n";
throw new AAIException("AAI_6118", emsg);
}
-
+
List<String> retArr = new ArrayList<>();
Iterator<Vertex> modVerVertsIter = this.engine.asAdmin().getReadOnlyTraversalSource().V().has(AAIProperties.NODE_TYPE,"model-ver").has("model-name",modelName);
if( !modVerVertsIter.hasNext() ){
- String emsg = " model-ver record(s) could not be found for model data passed. model-name = [" +
+ String emsg = " model-ver record(s) could not be found for model data passed. model-name = [" +
modelName + "]\n";
throw new AAIException("AAI_6114", emsg);
}
- else {
+ else {
while( modVerVertsIter.hasNext() ){
- Vertex modelVerVtx = modVerVertsIter.next();
+ Vertex modelVerVtx = (Vertex) modVerVertsIter.next();
String tmpUuid = modelVerVtx.<String>property("model-version-id").orElse(null);
if( (tmpUuid != null) && !tmpUuid.equals("") && !retArr.contains(tmpUuid) ){
retArr.add(tmpUuid);
}
}
}
-
+
if( retArr.isEmpty() ){
- String emsg = "No model-ver record found for model-name = ["
+ String emsg = "No model-ver record found for model-name = ["
+ modelName + "]\n";
throw new AAIException("AAI_6132", emsg);
}
+
return retArr;
- }
-
-
+ }// End getModelVerIdsUsingName()
+
+
/**
* Gets the model top widget type.
*
@@ -3418,14 +3489,14 @@ public class ModelBasedProcessing {
public String getModelVerTopWidgetType( String transId, String fromAppId,
String modelVersionId, String modelInvId, String modelName )
throws AAIException {
-
+
// Could be given a model-ver's key info (model-version-id), OR, just a (non-unique) model-name,
// Or just a model-invariant-id (which could have multiple model-ver records under it).
- // In any case, they should only map to one single "top" node-type for the first element.
-
+ // In any case, they should only map to one single "top" node-type for the first element.
+
String nodeType = "?";
Iterator<Vertex> modVerVertsIter;
-
+
if( modelVersionId != null && !modelVersionId.equals("") ){
// this would be the best - we can just look up the model-ver records directly
modVerVertsIter = this.engine.asAdmin().getReadOnlyTraversalSource().V().has(AAIProperties.NODE_TYPE,"model-ver").has("model-version-id",modelVersionId);
@@ -3440,13 +3511,13 @@ public class ModelBasedProcessing {
String msg = "Neither modelVersionId, modelInvariantId, nor modelName passed to: getModelVerTopWidgetType() ";
throw new AAIException("AAI_6120", msg);
}
-
+
if( !modVerVertsIter.hasNext() ){
String emsg = "model-ver record(s) could not be found for model data passed: modelInvariantId = [" + modelInvId +
"], modeVersionId = [" + modelVersionId + "], modelName = [" + modelName + "]\n";
throw new AAIException("AAI_6114", emsg);
}
- else {
+ else {
String lastNT = "";
if( !modVerVertsIter.hasNext() ){
String emsg = "model-ver record(s) could not be found for model data passed: modelInvariantId = [" + modelInvId +
@@ -3454,13 +3525,13 @@ public class ModelBasedProcessing {
throw new AAIException("AAI_6114", emsg);
}
while( modVerVertsIter.hasNext() ){
- Vertex tmpModVerVtx = modVerVertsIter.next();
+ Vertex tmpModVerVtx = (Vertex) modVerVertsIter.next();
String tmpNT = getModelVerTopWidgetType( tmpModVerVtx, "" );
if( lastNT != null && !lastNT.equals("") ){
if( !lastNT.equals(tmpNT) ){
- String emsg = "Different top-node-types (" + tmpNT + ", " + lastNT
+ String emsg = "Different top-node-types (" + tmpNT + ", " + lastNT
+ ") found for model data passed. (" +
- " modelVersionId = [" + modelVersionId +
+ " modelVersionId = [" + modelVersionId +
"], modelId = [" + modelInvId +
"], modelName = [" + modelName +
"])\n";
@@ -3471,10 +3542,12 @@ public class ModelBasedProcessing {
nodeType = tmpNT;
}
}
+
return nodeType;
- }
-
-
+
+ }// End getModelVerTopWidgetType()
+
+
/**
* Gets the widget type that this model-ver starts with.
*
@@ -3493,7 +3566,7 @@ public class ModelBasedProcessing {
String msg = " Could not determine modelType in getModelVerTopWidgetType(). elementTrail = [" + elementTrail + "].";
throw new AAIException("AAI_6132", msg);
}
-
+
String thisElementNodeType = "?";
if( modelType.equals("widget") ){
// NOTE: for models that have model-type = "widget", their child model-ver nodes will
@@ -3518,11 +3591,12 @@ public class ModelBasedProcessing {
String msg = " Unrecognized model-type = [" + modelType + "] pointed to by element at [" + elementTrail + "].";
throw new AAIException("AAI_6132", msg);
}
-
+
return thisElementNodeType;
- }
-
-
+
+ }// getModelVerTopWidgetType()
+
+
/**
* Validate model.
*
@@ -3532,10 +3606,10 @@ public class ModelBasedProcessing {
* @param apiVersion the api version
* @throws AAIException the AAI exception
*/
- public void validateModel(String transId, String fromAppId, String modelVersionIdVal, String apiVersion )
+ public void validateModel(String transId, String fromAppId, String modelVersionIdVal, String apiVersion )
throws AAIException {
-
- // Note - this will throw an exception if the model either can't be found, or if
+
+ // Note - this will throw an exception if the model either can't be found, or if
// we can't figure out its topology map.
Vertex modelVerVtx = getNodeUsingUniqueId(transId, fromAppId, "model-ver",
"model-version-id", modelVersionIdVal);
@@ -3550,9 +3624,10 @@ public class ModelBasedProcessing {
System.out.println("INFO -- " + msg );
}
return;
- }
-
-
+
+ }// End validateModel()
+
+
/**
* Validate named query.
*
@@ -3562,28 +3637,29 @@ public class ModelBasedProcessing {
* @param apiVersion the api version
* @throws AAIException the AAI exception
*/
- public void validateNamedQuery(String transId, String fromAppId, String namedQueryUuid, String apiVersion )
+ public void validateNamedQuery(String transId, String fromAppId, String namedQueryUuid, String apiVersion )
throws AAIException {
-
- // Note - this will throw an exception if the named query either can't be found, or if
+
+ // Note - this will throw an exception if the named query either can't be found, or if
// we can't figure out its topology map.
Vertex nqVtx = getNodeUsingUniqueId(transId, fromAppId, "named-query",
"named-query-uuid", namedQueryUuid);
-
+
if( nqVtx == null ){
String msg = " Could not find named-query with namedQueryUuid = [" + namedQueryUuid + "].";
throw new AAIException("AAI_6114", msg);
}
else {
- //Multimap<String, String> topoMap = genTopoMap4NamedQ( "junkTransId", "junkFromAppId",
+ //Multimap<String, String> topoMap = genTopoMap4NamedQ( "junkTransId", "junkFromAppId",
// graph, nqVtx, namedQueryUuid );
//System.out.println("DEBUG -- for test only : --- ");
//System.out.println("DEBUG -- topomap = [" + topoMap + "]");
}
return;
- }
-
-
+
+ }// End validateNamedQuery()
+
+
/**
* Show result set.
*
@@ -3591,7 +3667,7 @@ public class ModelBasedProcessing {
* @param levelCount the level count
*/
public void showResultSet(ResultSet resSet, int levelCount ) {
-
+
levelCount++;
String propsStr = "";
for( int i= 1; i <= levelCount; i++ ){
@@ -3602,11 +3678,11 @@ public class ModelBasedProcessing {
}
String nt = resSet.getVert().<String>property(AAIProperties.NODE_TYPE).orElse(null);
propsStr = propsStr + "[" + nt + "] ";
-
+
//propsStr = propsStr + " newDataDelFlag = " + resSet.getNewDataDelFlag() + ", trail = " + resSet.getLocationInModelSubGraph();
//propsStr = propsStr + "limitDesc = [" + resSet.getPropertyLimitDesc() + "]";
propsStr = propsStr + " trail = " + resSet.getLocationInModelSubGraph();
-
+
Map<String,Object> overrideHash = resSet.getPropertyOverRideHash();
if( overrideHash != null && !overrideHash.isEmpty() ){
for( Map.Entry<String, Object> entry : overrideHash.entrySet() ){
@@ -3619,7 +3695,7 @@ public class ModelBasedProcessing {
Iterator<VertexProperty<Object>> pI = resSet.getVert().properties();
while( pI.hasNext() ){
VertexProperty<Object> tp = pI.next();
- if( ! tp.key().startsWith("aai")
+ if( ! tp.key().startsWith("aai")
&& ! tp.key().equals("source-of-truth")
//&& ! tp.key().equals("resource-version")
&& ! tp.key().startsWith("last-mod")
@@ -3638,42 +3714,45 @@ public class ModelBasedProcessing {
propsStr = propsStr + " [" + propName + " = " + propVal.toString() + "]";
}
}
-
+
System.out.println( propsStr );
LOGGER.info(propsStr);
-
+
if( !resSet.getSubResultSet().isEmpty() ){
ListIterator<ResultSet> listItr = resSet.getSubResultSet().listIterator();
while( listItr.hasNext() ){
showResultSet( listItr.next(), levelCount );
}
}
- }
-
- private Iterator<Vertex> traverseIncidentEdges(EdgeType treeType, Vertex startV, String connectedNodeType) throws AAIException {
- return this.engine.getQueryBuilder(startV).createEdgeTraversal(treeType, startV, loader.introspectorFromName(connectedNodeType));
+
+ }// end of showResultSet()
+
+ private Iterator<Vertex> traverseIncidentEdges(EdgeType treeType, Vertex startV, String connectedNodeType) throws AAIUnknownObjectException, AAIException {
+ QueryBuilder builder = this.engine.getQueryBuilder(startV).createEdgeTraversal(treeType, startV, loader.introspectorFromName(connectedNodeType));
+ return builder;
}
-
- private Iterator<Vertex> traverseIncidentEdges(EdgeType treeType, Vertex startV, String... connectedNodeType) throws AAIException {
+
+ private Iterator<Vertex> traverseIncidentEdges(EdgeType treeType, Vertex startV, String... connectedNodeType) throws AAIUnknownObjectException, AAIException {
QueryBuilder[] builders = new QueryBuilder[connectedNodeType.length];
for (int i = 0; i < connectedNodeType.length; i++) {
builders[i] = this.engine.getQueryBuilder(startV).createEdgeTraversal(EdgeType.TREE, startV, loader.introspectorFromName(connectedNodeType[i]));
}
- return this.engine.getQueryBuilder(startV).union(builders);
+ QueryBuilder builder = this.engine.getQueryBuilder(startV).union(builders);
+ return builder;
}
private String addDBAliasedSuffix(String propName) {
return propName + AAIProperties.DB_ALIAS_SUFFIX;
}
-
+
protected String getPropNameWithAliasIfNeeded(String nodeType, String propName) throws AAIUnknownObjectException {
-
+
String retPropName = propName;
if( loader.introspectorFromName(nodeType).getPropertyMetadata(propName, PropertyMetadata.DB_ALIAS).isPresent() ){
return propName + AAIProperties.DB_ALIAS_SUFFIX;
}
return retPropName;
}
-
+
}
diff --git a/aai-traversal/src/main/java/org/onap/aai/dbgraphmap/SearchGraph.java b/aai-traversal/src/main/java/org/onap/aai/dbgraphmap/SearchGraph.java
index 40d3027..0725802 100644
--- a/aai-traversal/src/main/java/org/onap/aai/dbgraphmap/SearchGraph.java
+++ b/aai-traversal/src/main/java/org/onap/aai/dbgraphmap/SearchGraph.java
@@ -51,6 +51,10 @@ import org.onap.aai.dbgen.PropertyLimitDesc;
import org.onap.aai.dbgraphgen.ModelBasedProcessing;
import org.onap.aai.dbgraphgen.ResultSet;
import org.onap.aai.dbmap.DBConnectionType;
+import org.onap.aai.edges.EdgeIngestor;
+import org.onap.aai.edges.EdgeRule;
+import org.onap.aai.edges.EdgeRuleQuery;
+import org.onap.aai.edges.exceptions.EdgeRuleNotFoundException;
import org.onap.aai.exceptions.AAIException;
import org.onap.aai.extensions.AAIExtensionMap;
import org.onap.aai.introspection.Introspector;
@@ -64,14 +68,14 @@ import org.onap.aai.query.builder.QueryBuilder;
import org.onap.aai.schema.enums.ObjectMetadata;
import org.onap.aai.schema.enums.PropertyMetadata;
import org.onap.aai.serialization.db.DBSerializer;
-import org.onap.aai.serialization.db.EdgeRule;
-import org.onap.aai.serialization.db.EdgeRules;
import org.onap.aai.serialization.engines.QueryStyle;
import org.onap.aai.serialization.engines.JanusGraphDBEngine;
import org.onap.aai.serialization.engines.TransactionalGraphEngine;
import org.onap.aai.serialization.queryformats.exceptions.AAIFormatVertexException;
import org.onap.aai.serialization.queryformats.utils.UrlBuilder;
+import org.onap.aai.setup.SchemaVersions;
import org.onap.aai.util.StoreNotificationEvent;
+import org.springframework.beans.factory.annotation.Autowired;
import com.att.eelf.configuration.EELFLogger;
import com.att.eelf.configuration.EELFManager;
@@ -79,6 +83,10 @@ import com.google.common.base.CaseFormat;
import edu.emory.mathcs.backport.java.util.Collections;
+import com.google.common.collect.ArrayListMultimap;
+import com.google.common.collect.Multimap;
+import com.jcabi.log.Logger;
+
/**
* Database Mapping class which acts as the middle man between the REST interface objects
* for the Search namespace
@@ -86,9 +94,20 @@ import edu.emory.mathcs.backport.java.util.Collections;
*/
public class SearchGraph {
- private final String COMPONENT = "aaidbmap";
- private AAIExtensionMap aaiExtMap;
private static final EELFLogger LOGGER = EELFManager.getInstance().getLogger(SearchGraph.class);
+
+ private LoaderFactory loaderFactory;
+
+ private EdgeIngestor edgeIngestor;
+
+ private SchemaVersions schemaVersions;
+
+ @Autowired
+ public SearchGraph(LoaderFactory loaderFactory, EdgeIngestor edgeIngestor, SchemaVersions schemaVersions){
+ this.loaderFactory = loaderFactory;
+ this.edgeIngestor = edgeIngestor;
+ this.schemaVersions = schemaVersions;
+ }
/**
* Get the search result based on the includeNodeType and depth provided.
*
@@ -227,7 +246,7 @@ public class SearchGraph {
return response;
}
- private URI craftUriFromQueryParams(Loader loader, String startNodeType, List<String> startNodeKeyParams) throws UnsupportedEncodingException, AAIException {
+ private URI craftUriFromQueryParams(Loader loader, String startNodeType, List<String> startNodeKeyParams) throws UnsupportedEncodingException, IllegalArgumentException, UriBuilderException, AAIException {
Introspector relationship = loader.introspectorFromName("relationship");
relationship.setValue("related-to", startNodeType);
@@ -491,10 +510,18 @@ public class SearchGraph {
* @param nodeType the node type
* @return the edge label
* @throws AAIException the AAI exception
+ * @throws EdgeRuleNotFoundException
*/
- public static String[] getEdgeLabel(String targetNodeType, String nodeType) {
- Map<String, EdgeRule> rules = EdgeRules.getInstance().getEdgeRules(targetNodeType, nodeType);
- return rules.keySet().toArray(new String[0]);
+ public String[] getEdgeLabel(String targetNodeType, String nodeType) throws AAIException, EdgeRuleNotFoundException{
+
+
+ EdgeRuleQuery query = new EdgeRuleQuery.Builder(targetNodeType, nodeType).build();
+ Multimap<String, EdgeRule> edgeRules = ArrayListMultimap.create();
+ edgeRules = edgeIngestor.getRules(query);
+
+ //Map<String, EdgeRule> rules = EdgeRules.getInstance().getEdgeRules(targetNodeType, nodeType);
+ String[] results = edgeRules.keySet().toArray(new String[0]);
+ return results;
}
@@ -511,20 +538,20 @@ public class SearchGraph {
*/
public Response runNamedQuery(String fromAppId, String transId, String queryParameters,
DBConnectionType connectionType,
- AAIExtensionMap aaiExtMap) throws AAIException {
+ AAIExtensionMap aaiExtMap) throws JAXBException, AAIException {
Introspector inventoryItems;
boolean success = true;
TransactionalGraphEngine dbEngine = null;
try {
- MoxyLoader loader = (MoxyLoader)LoaderFactory.createLoaderForVersion(ModelType.MOXY, AAIProperties.LATEST);
+ MoxyLoader loader = (MoxyLoader)loaderFactory.createLoaderForVersion(ModelType.MOXY, schemaVersions.getDefaultVersion());
DynamicJAXBContext jaxbContext = loader.getJAXBContext();
dbEngine = new JanusGraphDBEngine(
QueryStyle.TRAVERSAL,
connectionType,
loader);
- DBSerializer serializer = new DBSerializer(AAIProperties.LATEST, dbEngine, ModelType.MOXY, fromAppId);
+ DBSerializer serializer = new DBSerializer(schemaVersions.getDefaultVersion(), dbEngine, ModelType.MOXY, fromAppId);
ModelBasedProcessing processor = new ModelBasedProcessing(loader, dbEngine, serializer);
dbEngine.startTransaction();
@@ -547,7 +574,7 @@ public class SearchGraph {
DynamicEntity qp = modelAndNamedQuerySearch.get("queryParameters");
String namedQueryUuid = null;
if ((qp != null) && qp.isSet("namedQuery")) {
- DynamicEntity namedQuery = qp.get("namedQuery");
+ DynamicEntity namedQuery = (DynamicEntity) qp.get("namedQuery");
if (namedQuery.isSet("namedQueryUuid")) {
namedQueryUuid = namedQuery.get("namedQueryUuid");
@@ -632,19 +659,19 @@ public class SearchGraph {
public Response executeModelOperation(String fromAppId, String transId, String queryParameters,
DBConnectionType connectionType,
boolean isDelete,
- AAIExtensionMap aaiExtMap) throws AAIException, UnsupportedEncodingException {
+ AAIExtensionMap aaiExtMap) throws JAXBException, AAIException, DynamicException, UnsupportedEncodingException {
Response response;
boolean success = true;
TransactionalGraphEngine dbEngine = null;
try {
- MoxyLoader loader = (MoxyLoader) LoaderFactory.createLoaderForVersion(ModelType.MOXY, AAIProperties.LATEST);
+ MoxyLoader loader = (MoxyLoader) loaderFactory.createLoaderForVersion(ModelType.MOXY, schemaVersions.getDefaultVersion());
DynamicJAXBContext jaxbContext = loader.getJAXBContext();
dbEngine = new JanusGraphDBEngine(
QueryStyle.TRAVERSAL,
connectionType,
loader);
- DBSerializer serializer = new DBSerializer(AAIProperties.LATEST, dbEngine, ModelType.MOXY, fromAppId);
+ DBSerializer serializer = new DBSerializer(schemaVersions.getDefaultVersion(), dbEngine, ModelType.MOXY, fromAppId);
ModelBasedProcessing processor = new ModelBasedProcessing(loader, dbEngine, serializer);
dbEngine.startTransaction();
@@ -688,7 +715,7 @@ public class SearchGraph {
DynamicEntity qp = modelAndNamedQuerySearch.get("queryParameters");
if (qp.isSet("model")) {
- DynamicEntity model = qp.get("model");
+ DynamicEntity model = (DynamicEntity) qp.get("model");
// on an old-style model object, the following 4 attrs were all present
if (model.isSet("modelNameVersionId")) {
@@ -713,7 +740,7 @@ public class SearchGraph {
if (model.isSet("modelVers")) {
// we know that this is new style, because modelVers was not an option
// before v9
- DynamicEntity modelVers = model.get("modelVers");
+ DynamicEntity modelVers = (DynamicEntity) model.get("modelVers");
if (modelVers.isSet("modelVer")) {
List<DynamicEntity> modelVerList = modelVers.get("modelVer");
// if they send more than one, too bad, they get the first one
@@ -734,7 +761,7 @@ public class SearchGraph {
List<Map<String,Object>> startNodeFilterHash = new ArrayList<>();
- String resourceVersion = mapInstanceFilters(modelAndNamedQuerySearch.get("instanceFilters"),
+ String resourceVersion = mapInstanceFilters((DynamicEntity)modelAndNamedQuerySearch.get("instanceFilters"),
startNodeFilterHash, jaxbContext);
if (isDelete) {
@@ -749,13 +776,7 @@ public class SearchGraph {
Vertex firstVert = rs.getVert();
String restURI = serializer.getURIForVertex(firstVert).toString();
- String notificationVersion = AAIProperties.LATEST.toString();
- if (restURI.startsWith("/")) {
- restURI = "/aai/" + notificationVersion + restURI;
- } else {
- restURI = "/aai/" + notificationVersion + "/" + restURI;
- }
-
+ String notificationVersion = schemaVersions.getDefaultVersion().toString();
Map<String,String> delResult = processor.runDeleteByModel( transId, fromAppId,
modelVersionId, topNodeType, startNodeFilterHash.get(0), aaiExtMap.getApiVersion(), resourceVersion );
@@ -836,7 +857,7 @@ public class SearchGraph {
return null;
}
@SuppressWarnings("unchecked")
- List<DynamicEntity> instanceFilter = instanceFilters.get("instanceFilter");
+ List<DynamicEntity> instanceFilter = (ArrayList<DynamicEntity>)instanceFilters.get("instanceFilter");
String resourceVersion = null;
for (DynamicEntity instFilt : instanceFilter) {
@@ -855,7 +876,7 @@ public class SearchGraph {
if (anyEnt.isSet(propName)) {
thisNodeFilterHash.put(nodeType + "." + CaseFormat.LOWER_CAMEL.to(CaseFormat.LOWER_HYPHEN, propName), anyEnt.get(propName));
if (propName.equals("resourceVersion") && resourceVersion == null) {
- resourceVersion = anyEnt.get(propName);
+ resourceVersion = (String)anyEnt.get(propName);
}
}
}
@@ -879,7 +900,7 @@ public class SearchGraph {
return;
}
@SuppressWarnings("unchecked")
- List<DynamicEntity> secondaryFilter = secondaryFilts.get("secondaryFilt");
+ List<DynamicEntity> secondaryFilter = (ArrayList<DynamicEntity>)secondaryFilts.get("secondaryFilt");
for (DynamicEntity secondaryFilt : secondaryFilter) {
List<DynamicEntity> any = secondaryFilt.get("any");
@@ -1061,8 +1082,8 @@ public class SearchGraph {
String modelName = null;
try {
// Try to get the modelName if we can. Otherwise, do not fail, just return what we have already.
- String modelInvariantIdLocal = vert.<String>property("model-invariant-id-local").orElse(null); // this one points at a model
- String modelVersionIdLocal = vert.<String>property("model-version-id-local").orElse(null); // this one points at a model-ver
+ String modelInvariantIdLocal = (String)vert.<String>property("model-invariant-id-local").orElse(null); // this one points at a model
+ String modelVersionIdLocal = (String)vert.<String>property("model-version-id-local").orElse(null); // this one points at a model-ver
if ( (modelInvariantIdLocal != null && modelVersionIdLocal != null)
&& (modelInvariantIdLocal.length() > 0 && modelVersionIdLocal.length() > 0) ) {
diff --git a/aai-traversal/src/main/java/org/onap/aai/interceptors/AAIHeaderProperties.java b/aai-traversal/src/main/java/org/onap/aai/interceptors/AAIHeaderProperties.java
index 9029366..6801aee 100644
--- a/aai-traversal/src/main/java/org/onap/aai/interceptors/AAIHeaderProperties.java
+++ b/aai-traversal/src/main/java/org/onap/aai/interceptors/AAIHeaderProperties.java
@@ -8,7 +8,7 @@
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
- * http://www.apache.org/licenses/LICENSE-2.0
+ * http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
@@ -20,21 +20,20 @@
package org.onap.aai.interceptors;
public final class AAIHeaderProperties {
-
- public static final String REQUEST_CONTEXT = "aai-request-context";
-
- public static final String HTTP_METHOD_OVERRIDE = "X-HTTP-Method-Override";
-
- public static final String TRANSACTION_ID = "X-TransactionId";
-
- public static final String FROM_APP_ID = "X-FromAppId";
-
- public static final String AAI_TX_ID = "X-AAI-TXID";
-
- public static final String AAI_REQUEST = "X-REQUEST";
-
- public static final String AAI_REQUEST_TS = "X-REQUEST-TS";
-
- private AAIHeaderProperties() {
- }
+
+ private AAIHeaderProperties(){}
+
+ public static final String REQUEST_CONTEXT = "aai-request-context";
+
+ public static final String HTTP_METHOD_OVERRIDE = "X-HTTP-Method-Override";
+
+ public static final String TRANSACTION_ID = "X-TransactionId";
+
+ public static final String FROM_APP_ID = "X-FromAppId";
+
+ public static final String AAI_TX_ID = "X-AAI-TXID";
+
+ public static final String AAI_REQUEST = "X-REQUEST";
+
+ public static final String AAI_REQUEST_TS = "X-REQUEST-TS";
}
diff --git a/aai-traversal/src/main/java/org/onap/aai/interceptors/post/AAIResponseFilterPriority.java b/aai-traversal/src/main/java/org/onap/aai/interceptors/post/AAIResponseFilterPriority.java
index 90ab047..146f847 100644
--- a/aai-traversal/src/main/java/org/onap/aai/interceptors/post/AAIResponseFilterPriority.java
+++ b/aai-traversal/src/main/java/org/onap/aai/interceptors/post/AAIResponseFilterPriority.java
@@ -8,7 +8,7 @@
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
- * http://www.apache.org/licenses/LICENSE-2.0
+ * http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
@@ -19,14 +19,22 @@
*/
package org.onap.aai.interceptors.post;
+/**
+ * Response Filter order is done reverse sorted
+ * so in the following case the first response filter would be
+ * HEADER_MANIPULATION, RESPONSE_TRANS_LOGGING, RESET_LOGGING_CONTEXT,
+ * and INVALID_RESPONSE_STATUS
+ */
public final class AAIResponseFilterPriority {
+
+ private AAIResponseFilterPriority() {}
+
+ public static final int INVALID_RESPONSE_STATUS = 1000;
- public static final int HEADER_MANIPULATION = 1000;
+ public static final int RESET_LOGGING_CONTEXT = 2000;
- public static final int RESPONSE_TRANS_LOGGING = 2000;
+ public static final int RESPONSE_TRANS_LOGGING = 3000;
- public static final int RESET_LOGGING_CONTEXT = 3000;
+ public static final int HEADER_MANIPULATION = 4000;
- private AAIResponseFilterPriority() {
- }
}
diff --git a/aai-traversal/src/main/java/org/onap/aai/interceptors/post/InvalidResponseStatus.java b/aai-traversal/src/main/java/org/onap/aai/interceptors/post/InvalidResponseStatus.java
new file mode 100644
index 0000000..7fd0b9c
--- /dev/null
+++ b/aai-traversal/src/main/java/org/onap/aai/interceptors/post/InvalidResponseStatus.java
@@ -0,0 +1,65 @@
+/**
+ * ============LICENSE_START=======================================================
+ * org.onap.aai
+ * ================================================================================
+ * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY 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.interceptors.post;
+
+import org.onap.aai.exceptions.AAIException;
+import org.onap.aai.interceptors.AAIContainerFilter;
+import org.onap.aai.logging.ErrorLogHelper;
+
+import javax.annotation.Priority;
+import javax.ws.rs.container.ContainerRequestContext;
+import javax.ws.rs.container.ContainerResponseContext;
+import javax.ws.rs.container.ContainerResponseFilter;
+import javax.ws.rs.core.MediaType;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.List;
+
+@Priority(AAIResponseFilterPriority.INVALID_RESPONSE_STATUS)
+public class InvalidResponseStatus extends AAIContainerFilter implements ContainerResponseFilter {
+
+ @Override
+ public void filter(ContainerRequestContext requestContext, ContainerResponseContext responseContext)
+ throws IOException {
+
+ if(responseContext.getStatus() == 405){
+
+ responseContext.setStatus(400);
+ AAIException e = new AAIException("AAI_3012");
+ ArrayList<String> templateVars = new ArrayList<>();
+
+ List<MediaType> mediaTypeList = new ArrayList<>();
+
+ String contentType = responseContext.getHeaderString("Content-Type");
+
+ if (contentType == null) {
+ mediaTypeList.add(MediaType.APPLICATION_XML_TYPE);
+ } else {
+ mediaTypeList.add(MediaType.valueOf(contentType));
+ }
+
+ String message = ErrorLogHelper.getRESTAPIErrorResponse(mediaTypeList, e, templateVars);
+
+ responseContext.setEntity(message);
+ }
+
+ }
+
+}
diff --git a/aai-traversal/src/main/java/org/onap/aai/interceptors/post/ResetLoggingContext.java b/aai-traversal/src/main/java/org/onap/aai/interceptors/post/ResetLoggingContext.java
index f8c5644..baf28ad 100644
--- a/aai-traversal/src/main/java/org/onap/aai/interceptors/post/ResetLoggingContext.java
+++ b/aai-traversal/src/main/java/org/onap/aai/interceptors/post/ResetLoggingContext.java
@@ -19,21 +19,21 @@
*/
package org.onap.aai.interceptors.post;
-import java.io.IOException;
+import com.att.eelf.configuration.EELFLogger;
+import com.att.eelf.configuration.EELFManager;
+import org.onap.aai.interceptors.AAIContainerFilter;
+import org.onap.aai.logging.LoggingContext;
+import org.onap.aai.logging.LoggingContext.StatusCode;
+import org.springframework.beans.factory.annotation.Autowired;
import javax.annotation.Priority;
import javax.servlet.http.HttpServletRequest;
import javax.ws.rs.container.ContainerRequestContext;
import javax.ws.rs.container.ContainerResponseContext;
import javax.ws.rs.container.ContainerResponseFilter;
-
-import org.onap.aai.interceptors.AAIContainerFilter;
-import org.onap.aai.logging.LoggingContext;
-import org.onap.aai.logging.LoggingContext.StatusCode;
-import org.springframework.beans.factory.annotation.Autowired;
-
-import com.att.eelf.configuration.EELFLogger;
-import com.att.eelf.configuration.EELFManager;
+import javax.ws.rs.core.Response.Status;
+import javax.ws.rs.core.Response.StatusType;
+import java.io.IOException;
@Priority(AAIResponseFilterPriority.RESET_LOGGING_CONTEXT)
public class ResetLoggingContext extends AAIContainerFilter implements ContainerResponseFilter {
@@ -47,23 +47,52 @@ public class ResetLoggingContext extends AAIContainerFilter implements Container
public void filter(ContainerRequestContext requestContext, ContainerResponseContext responseContext)
throws IOException {
- this.cleanLoggingContext();
+ this.cleanLoggingContext(responseContext);
}
- private void cleanLoggingContext() {
- final String responseCode = LoggingContext.responseCode();
- String url = httpServletRequest.getRequestURL().toString();
+ private void cleanLoggingContext(ContainerResponseContext responseContext) {
+ //String url = httpServletRequest.getRequestURL().toString();
+ boolean success = true;
+ String uri = httpServletRequest.getRequestURI();
+ String queryString = httpServletRequest.getQueryString();
- if (responseCode != null && responseCode.startsWith("ERR.")) {
- LoggingContext.statusCode(StatusCode.ERROR);
- LOGGER.error(url + " call failed with responseCode=" + responseCode);
- } else {
- LoggingContext.statusCode(StatusCode.COMPLETE);
- LOGGER.info(url + " call succeeded");
+ if(queryString != null && !queryString.isEmpty()){
+ uri = uri + "?" + queryString;
}
+ // For now, we use the the HTTP status code,
+ // This may change, once the requirements for response codes are defined
+ int httpStatusCode = responseContext.getStatus();
+ if ( httpStatusCode < 100 || httpStatusCode > 599 ) {
+ httpStatusCode = Status.INTERNAL_SERVER_ERROR.getStatusCode();
+ }
+ LoggingContext.responseCode(Integer.toString(httpStatusCode));
+
+ StatusType sType = responseContext.getStatusInfo();
+ if ( sType != null ) {
+ Status.Family sFamily = sType.getFamily();
+ if ( ! ( Status.Family.SUCCESSFUL.equals(sFamily) ||
+ ( Status.NOT_FOUND.equals(Status.fromStatusCode(httpStatusCode)) ) ) ) {
+ success = false;
+ }
+ }
+ else {
+ if ( (httpStatusCode < 200 || httpStatusCode > 299) && ( ! ( Status.NOT_FOUND.equals(Status.fromStatusCode(httpStatusCode) ) ) ) ) {
+ success = false;
+ }
+ }
+ if (success) {
+ LoggingContext.statusCode(StatusCode.COMPLETE);
+ LOGGER.info(uri + " call succeeded");
+ }
+ else {
+ LoggingContext.statusCode(StatusCode.ERROR);
+ LOGGER.error(uri + " call failed with responseCode=" + httpStatusCode);
+ }
LoggingContext.clear();
+
+
}
}
diff --git a/aai-traversal/src/main/java/org/onap/aai/interceptors/post/ResponseHeaderManipulation.java b/aai-traversal/src/main/java/org/onap/aai/interceptors/post/ResponseHeaderManipulation.java
index 6d6dbd8..9d4efe7 100644
--- a/aai-traversal/src/main/java/org/onap/aai/interceptors/post/ResponseHeaderManipulation.java
+++ b/aai-traversal/src/main/java/org/onap/aai/interceptors/post/ResponseHeaderManipulation.java
@@ -19,19 +19,20 @@
*/
package org.onap.aai.interceptors.post;
-import java.io.IOException;
+import org.onap.aai.interceptors.AAIContainerFilter;
+import org.onap.aai.interceptors.AAIHeaderProperties;
import javax.annotation.Priority;
import javax.ws.rs.container.ContainerRequestContext;
import javax.ws.rs.container.ContainerResponseContext;
import javax.ws.rs.container.ContainerResponseFilter;
-
-import org.onap.aai.interceptors.AAIContainerFilter;
-import org.onap.aai.interceptors.AAIHeaderProperties;
+import javax.ws.rs.core.MediaType;
+import java.io.IOException;
@Priority(AAIResponseFilterPriority.HEADER_MANIPULATION)
public class ResponseHeaderManipulation extends AAIContainerFilter implements ContainerResponseFilter {
+ private static final String DEFAULT_XML_TYPE = MediaType.APPLICATION_XML;
@Override
public void filter(ContainerRequestContext requestContext, ContainerResponseContext responseContext)
@@ -43,7 +44,21 @@ public class ResponseHeaderManipulation extends AAIContainerFilter implements Co
private void updateResponseHeaders(ContainerRequestContext requestContext,
ContainerResponseContext responseContext) {
+
responseContext.getHeaders().add(AAIHeaderProperties.AAI_TX_ID, requestContext.getProperty(AAIHeaderProperties.AAI_TX_ID));
+
+ String responseContentType = responseContext.getHeaderString("Content-Type");
+
+ if(responseContentType == null){
+ String acceptType = requestContext.getHeaderString("Accept");
+
+ if(acceptType == null || "*/*".equals(acceptType)){
+ responseContext.getHeaders().putSingle("Content-Type", DEFAULT_XML_TYPE);
+ } else {
+ responseContext.getHeaders().putSingle("Content-Type", acceptType);
+ }
+ }
+
}
}
diff --git a/aai-traversal/src/main/java/org/onap/aai/interceptors/post/ResponseTransactionLogging.java b/aai-traversal/src/main/java/org/onap/aai/interceptors/post/ResponseTransactionLogging.java
index a9592c4..547a7c8 100644
--- a/aai-traversal/src/main/java/org/onap/aai/interceptors/post/ResponseTransactionLogging.java
+++ b/aai-traversal/src/main/java/org/onap/aai/interceptors/post/ResponseTransactionLogging.java
@@ -19,16 +19,9 @@
*/
package org.onap.aai.interceptors.post;
-import java.io.IOException;
-import java.util.Objects;
-import java.util.Optional;
-
-import javax.annotation.Priority;
-import javax.servlet.http.HttpServletResponse;
-import javax.ws.rs.container.ContainerRequestContext;
-import javax.ws.rs.container.ContainerResponseContext;
-import javax.ws.rs.container.ContainerResponseFilter;
-
+import com.att.eelf.configuration.EELFLogger;
+import com.att.eelf.configuration.EELFManager;
+import com.google.gson.JsonObject;
import org.onap.aai.exceptions.AAIException;
import org.onap.aai.interceptors.AAIContainerFilter;
import org.onap.aai.interceptors.AAIHeaderProperties;
@@ -36,9 +29,14 @@ import org.onap.aai.logging.ErrorLogHelper;
import org.onap.aai.util.AAIConfig;
import org.springframework.beans.factory.annotation.Autowired;
-import com.att.eelf.configuration.EELFLogger;
-import com.att.eelf.configuration.EELFManager;
-import com.google.gson.JsonObject;
+import javax.annotation.Priority;
+import javax.servlet.http.HttpServletResponse;
+import javax.ws.rs.container.ContainerRequestContext;
+import javax.ws.rs.container.ContainerResponseContext;
+import javax.ws.rs.container.ContainerResponseFilter;
+import java.io.IOException;
+import java.util.Objects;
+import java.util.Optional;
@Priority(AAIResponseFilterPriority.RESPONSE_TRANS_LOGGING)
public class ResponseTransactionLogging extends AAIContainerFilter implements ContainerResponseFilter {
diff --git a/aai-traversal/src/main/java/org/onap/aai/interceptors/pre/AAIRequestFilterPriority.java b/aai-traversal/src/main/java/org/onap/aai/interceptors/pre/AAIRequestFilterPriority.java
index ae75776..c3d9d3b 100644
--- a/aai-traversal/src/main/java/org/onap/aai/interceptors/pre/AAIRequestFilterPriority.java
+++ b/aai-traversal/src/main/java/org/onap/aai/interceptors/pre/AAIRequestFilterPriority.java
@@ -8,7 +8,7 @@
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
- * http://www.apache.org/licenses/LICENSE-2.0
+ * http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
@@ -20,19 +20,27 @@
package org.onap.aai.interceptors.pre;
public final class AAIRequestFilterPriority {
+
+ private AAIRequestFilterPriority() {}
+
+ public static final int REQUEST_TRANS_LOGGING = 1000;
+
+ public static final int HEADER_VALIDATION = 2000;
- public static final int REQUEST_TRANS_LOGGING = 1000;
+ public static final int SET_LOGGING_CONTEXT = 3000;
- public static final int HEADER_VALIDATION = 2000;
+ public static final int HTTP_HEADER = 4000;
- public static final int SET_LOGGING_CONTEXT = 3000;
+ public static final int LATEST = 4250;
- public static final int AUTHORIZATION = 4000;
+ public static final int AUTHORIZATION = 4500;
- public static final int HEADER_MANIPULATION = 5000;
+ public static final int RETIRED_SERVICE = 5000;
- public static final int REQUEST_MODIFICATION = 6000;
+ public static final int VERSION = 5500;
+
+ public static final int HEADER_MANIPULATION = 6000;
+
+ public static final int REQUEST_MODIFICATION = 7000;
- private AAIRequestFilterPriority() {
- }
}
diff --git a/aai-traversal/src/main/java/org/onap/aai/interceptors/pre/HeaderValidation.java b/aai-traversal/src/main/java/org/onap/aai/interceptors/pre/HeaderValidation.java
index dfc4376..d6b6080 100644
--- a/aai-traversal/src/main/java/org/onap/aai/interceptors/pre/HeaderValidation.java
+++ b/aai-traversal/src/main/java/org/onap/aai/interceptors/pre/HeaderValidation.java
@@ -19,11 +19,10 @@
*/
package org.onap.aai.interceptors.pre;
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Optional;
-import java.util.UUID;
+import org.onap.aai.exceptions.AAIException;
+import org.onap.aai.interceptors.AAIContainerFilter;
+import org.onap.aai.interceptors.AAIHeaderProperties;
+import org.onap.aai.logging.ErrorLogHelper;
import javax.annotation.Priority;
import javax.ws.rs.container.ContainerRequestContext;
@@ -31,11 +30,11 @@ import javax.ws.rs.container.ContainerRequestFilter;
import javax.ws.rs.container.PreMatching;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
-
-import org.onap.aai.exceptions.AAIException;
-import org.onap.aai.interceptors.AAIContainerFilter;
-import org.onap.aai.interceptors.AAIHeaderProperties;
-import org.onap.aai.logging.ErrorLogHelper;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Optional;
+import java.util.UUID;
@PreMatching
@Priority(AAIRequestFilterPriority.HEADER_VALIDATION)
diff --git a/aai-traversal/src/main/java/org/onap/aai/interceptors/pre/HttpHeaderInterceptor.java b/aai-traversal/src/main/java/org/onap/aai/interceptors/pre/HttpHeaderInterceptor.java
new file mode 100644
index 0000000..ee04453
--- /dev/null
+++ b/aai-traversal/src/main/java/org/onap/aai/interceptors/pre/HttpHeaderInterceptor.java
@@ -0,0 +1,50 @@
+/**
+ * ============LICENSE_START=======================================================
+ * org.onap.aai
+ * ================================================================================
+ * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY 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.interceptors.pre;
+
+import org.onap.aai.interceptors.AAIContainerFilter;
+import org.onap.aai.interceptors.AAIHeaderProperties;
+
+import javax.annotation.Priority;
+import javax.ws.rs.HttpMethod;
+import javax.ws.rs.container.ContainerRequestContext;
+import javax.ws.rs.container.ContainerRequestFilter;
+import javax.ws.rs.container.PreMatching;
+import java.io.IOException;
+
+/**
+ * The Class HttpHeaderInterceptor
+ */
+@PreMatching
+@Priority(AAIRequestFilterPriority.HTTP_HEADER)
+public class HttpHeaderInterceptor extends AAIContainerFilter implements ContainerRequestFilter {
+ public static final String patchMethod = "PATCH";
+
+ @Override
+ public void filter(ContainerRequestContext containerRequestContext) throws IOException {
+ String overrideMethod = containerRequestContext.getHeaderString(AAIHeaderProperties.HTTP_METHOD_OVERRIDE);
+ String httpMethod = containerRequestContext.getMethod();
+
+ if (HttpMethod.POST.equalsIgnoreCase(httpMethod) && patchMethod.equalsIgnoreCase(overrideMethod)) {
+ containerRequestContext.setMethod(patchMethod);
+ }
+ }
+
+}
diff --git a/aai-traversal/src/main/java/org/onap/aai/interceptors/pre/OneWaySslAuthorization.java b/aai-traversal/src/main/java/org/onap/aai/interceptors/pre/OneWaySslAuthorization.java
index 8fe2d6e..1f8a6ec 100644
--- a/aai-traversal/src/main/java/org/onap/aai/interceptors/pre/OneWaySslAuthorization.java
+++ b/aai-traversal/src/main/java/org/onap/aai/interceptors/pre/OneWaySslAuthorization.java
@@ -19,11 +19,13 @@
*/
package org.onap.aai.interceptors.pre;
+import org.onap.aai.Profiles;
import org.onap.aai.exceptions.AAIException;
import org.onap.aai.interceptors.AAIContainerFilter;
import org.onap.aai.logging.ErrorLogHelper;
import org.onap.aai.service.AuthorizationService;
import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.context.annotation.Profile;
import javax.annotation.Priority;
import javax.ws.rs.container.ContainerRequestContext;
@@ -36,6 +38,7 @@ import java.util.ArrayList;
import java.util.List;
import java.util.Optional;
+@Profile(Profiles.ONE_WAY_SSL)
@PreMatching
@Priority(AAIRequestFilterPriority.AUTHORIZATION)
public class OneWaySslAuthorization extends AAIContainerFilter implements ContainerRequestFilter {
diff --git a/aai-traversal/src/main/java/org/onap/aai/interceptors/pre/RequestHeaderManipulation.java b/aai-traversal/src/main/java/org/onap/aai/interceptors/pre/RequestHeaderManipulation.java
index 7f74f1e..d2dcc0b 100644
--- a/aai-traversal/src/main/java/org/onap/aai/interceptors/pre/RequestHeaderManipulation.java
+++ b/aai-traversal/src/main/java/org/onap/aai/interceptors/pre/RequestHeaderManipulation.java
@@ -19,35 +19,25 @@
*/
package org.onap.aai.interceptors.pre;
-import java.io.IOException;
-import java.util.Collections;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
+import org.onap.aai.interceptors.AAIContainerFilter;
+import org.onap.aai.interceptors.AAIHeaderProperties;
import javax.annotation.Priority;
-import javax.servlet.http.HttpServletRequest;
import javax.ws.rs.container.ContainerRequestContext;
import javax.ws.rs.container.ContainerRequestFilter;
import javax.ws.rs.container.PreMatching;
import javax.ws.rs.core.MultivaluedMap;
-
-import org.onap.aai.interceptors.AAIContainerFilter;
-import org.onap.aai.interceptors.AAIHeaderProperties;
-import org.springframework.beans.factory.annotation.Autowired;
+import java.util.Collections;
+import java.util.regex.Matcher;
@PreMatching
@Priority(AAIRequestFilterPriority.HEADER_MANIPULATION)
public class RequestHeaderManipulation extends AAIContainerFilter implements ContainerRequestFilter {
- @Autowired
- private HttpServletRequest httpServletRequest;
-
- private static final Pattern versionedEndpoint = Pattern.compile("^/aai/(v\\d+)");
-
@Override
- public void filter(ContainerRequestContext requestContext) throws IOException {
+ public void filter(ContainerRequestContext requestContext) {
- String uri = httpServletRequest.getRequestURI();
+ String uri = requestContext.getUriInfo().getPath();
this.addRequestContext(uri, requestContext.getHeaders());
}
@@ -56,7 +46,7 @@ public class RequestHeaderManipulation extends AAIContainerFilter implements Con
String rc = "";
- Matcher match = versionedEndpoint.matcher(uri);
+ Matcher match = VersionInterceptor.EXTRACT_VERSION_PATTERN.matcher(uri);
if (match.find()) {
rc = match.group(1);
}
diff --git a/aai-traversal/src/main/java/org/onap/aai/interceptors/pre/RequestModification.java b/aai-traversal/src/main/java/org/onap/aai/interceptors/pre/RequestModification.java
index 50e87b0..acd1305 100644
--- a/aai-traversal/src/main/java/org/onap/aai/interceptors/pre/RequestModification.java
+++ b/aai-traversal/src/main/java/org/onap/aai/interceptors/pre/RequestModification.java
@@ -19,12 +19,7 @@
*/
package org.onap.aai.interceptors.pre;
-import java.io.IOException;
-import java.util.Arrays;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-import java.util.stream.Collectors;
+import org.onap.aai.interceptors.AAIContainerFilter;
import javax.annotation.Priority;
import javax.ws.rs.container.ContainerRequestContext;
@@ -32,11 +27,15 @@ import javax.ws.rs.container.ContainerRequestFilter;
import javax.ws.rs.container.PreMatching;
import javax.ws.rs.core.MultivaluedMap;
import javax.ws.rs.core.UriBuilder;
-
-import org.onap.aai.interceptors.AAIContainerFilter;
+import java.io.IOException;
+import java.util.Arrays;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.stream.Collectors;
@PreMatching
-@Priority(AAIRequestFilterPriority.HEADER_VALIDATION)
+@Priority(AAIRequestFilterPriority.REQUEST_MODIFICATION)
public class RequestModification extends AAIContainerFilter implements ContainerRequestFilter {
@Override
diff --git a/aai-traversal/src/main/java/org/onap/aai/interceptors/pre/RequestTransactionLogging.java b/aai-traversal/src/main/java/org/onap/aai/interceptors/pre/RequestTransactionLogging.java
index 011a041..6c86f19 100644
--- a/aai-traversal/src/main/java/org/onap/aai/interceptors/pre/RequestTransactionLogging.java
+++ b/aai-traversal/src/main/java/org/onap/aai/interceptors/pre/RequestTransactionLogging.java
@@ -19,20 +19,7 @@
*/
package org.onap.aai.interceptors.pre;
-import java.io.ByteArrayInputStream;
-import java.io.ByteArrayOutputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.util.Random;
-import java.util.UUID;
-
-import javax.annotation.Priority;
-import javax.servlet.http.HttpServletRequest;
-import javax.ws.rs.container.ContainerRequestContext;
-import javax.ws.rs.container.ContainerRequestFilter;
-import javax.ws.rs.container.PreMatching;
-import javax.ws.rs.core.MediaType;
-
+import com.google.gson.JsonObject;
import org.glassfish.jersey.message.internal.ReaderWriter;
import org.glassfish.jersey.server.ContainerException;
import org.onap.aai.exceptions.AAIException;
@@ -42,8 +29,21 @@ import org.onap.aai.util.AAIConfig;
import org.onap.aai.util.AAIConstants;
import org.onap.aai.util.HbaseSaltPrefixer;
import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.util.StringUtils;
-import com.google.gson.JsonObject;
+import javax.annotation.Priority;
+import javax.servlet.http.HttpServletRequest;
+import javax.ws.rs.container.ContainerRequestContext;
+import javax.ws.rs.container.ContainerRequestFilter;
+import javax.ws.rs.container.PreMatching;
+import javax.ws.rs.core.MediaType;
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.security.SecureRandom;
+import java.util.Random;
+import java.util.UUID;
@PreMatching
@Priority(AAIRequestFilterPriority.REQUEST_TRANS_LOGGING)
@@ -52,6 +52,13 @@ public class RequestTransactionLogging extends AAIContainerFilter implements Con
@Autowired
private HttpServletRequest httpServletRequest;
+ private static final String DEFAULT_CONTENT_TYPE = MediaType.APPLICATION_JSON;
+ private static final String DEFAULT_RESPONSE_TYPE = MediaType.APPLICATION_XML;
+
+ private static final String CONTENT_TYPE = "Content-Type";
+ private static final String ACCEPT = "Accept";
+ private static final String TEXT_PLAIN = "text/plain";
+
@Override
public void filter(ContainerRequestContext requestContext) throws IOException {
@@ -60,17 +67,34 @@ public class RequestTransactionLogging extends AAIContainerFilter implements Con
this.addToRequestContext(requestContext, AAIHeaderProperties.AAI_TX_ID, fullId);
this.addToRequestContext(requestContext, AAIHeaderProperties.AAI_REQUEST, this.getRequest(requestContext, fullId));
this.addToRequestContext(requestContext, AAIHeaderProperties.AAI_REQUEST_TS, currentTimeStamp);
+ this.addDefaultContentType(requestContext);
}
private void addToRequestContext(ContainerRequestContext requestContext, String name, String aaiTxIdToHeader) {
requestContext.setProperty(name, aaiTxIdToHeader);
}
+ private void addDefaultContentType(ContainerRequestContext requestContext) {
+
+ String contentType = requestContext.getHeaderString(CONTENT_TYPE);
+ String acceptType = requestContext.getHeaderString(ACCEPT);
+
+ if(contentType == null || contentType.contains(TEXT_PLAIN)){
+ requestContext.getHeaders().putSingle(CONTENT_TYPE, DEFAULT_CONTENT_TYPE);
+ }
+
+ if(StringUtils.isEmpty(acceptType) || acceptType.contains(TEXT_PLAIN)){
+ requestContext.getHeaders().putSingle(ACCEPT, DEFAULT_RESPONSE_TYPE);
+ }
+ }
+
private String getAAITxIdToHeader(String currentTimeStamp) {
String txId = UUID.randomUUID().toString();
try {
+ Random rand = new SecureRandom();
+ int number = rand.nextInt(99999);
txId = HbaseSaltPrefixer.getInstance().prependSalt(AAIConfig.get(AAIConstants.AAI_NODENAME) + "-"
- + currentTimeStamp + "-" + new Random(System.currentTimeMillis()).nextInt(99999));
+ + currentTimeStamp + "-" + number ); //new Random(System.currentTimeMillis()).nextInt(99999)
} catch (AAIException e) {
}
@@ -82,14 +106,7 @@ public class RequestTransactionLogging extends AAIContainerFilter implements Con
JsonObject request = new JsonObject();
request.addProperty("ID", fullId);
request.addProperty("Http-Method", requestContext.getMethod());
- String contentType = httpServletRequest.getContentType();
-
- if(contentType == null){
- contentType = MediaType.APPLICATION_JSON;
- requestContext.getHeaders().add("Content-Type", contentType);
- }
-
- request.addProperty("Content-Type", contentType);
+ request.addProperty(CONTENT_TYPE, httpServletRequest.getContentType());
request.addProperty("Headers", requestContext.getHeaders().toString());
ByteArrayOutputStream out = new ByteArrayOutputStream();
diff --git a/aai-traversal/src/main/java/org/onap/aai/interceptors/pre/RetiredInterceptor.java b/aai-traversal/src/main/java/org/onap/aai/interceptors/pre/RetiredInterceptor.java
new file mode 100644
index 0000000..643793d
--- /dev/null
+++ b/aai-traversal/src/main/java/org/onap/aai/interceptors/pre/RetiredInterceptor.java
@@ -0,0 +1,148 @@
+/**
+ * ============LICENSE_START=======================================================
+ * org.onap.aai
+ * ================================================================================
+ * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY 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.interceptors.pre;
+
+import org.onap.aai.exceptions.AAIException;
+import org.onap.aai.interceptors.AAIContainerFilter;
+import org.onap.aai.logging.ErrorLogHelper;
+import org.onap.aai.service.RetiredService;
+import org.onap.aai.util.AAIConfig;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Value;
+
+import javax.annotation.Priority;
+import javax.ws.rs.container.ContainerRequestContext;
+import javax.ws.rs.container.ContainerRequestFilter;
+import javax.ws.rs.container.PreMatching;
+import javax.ws.rs.core.Response;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+// Can cache this so if the uri was already cached then it won't run the string
+// matching each time but only does it for the first time
+
+@PreMatching
+@Priority(AAIRequestFilterPriority.RETIRED_SERVICE)
+public class RetiredInterceptor extends AAIContainerFilter implements ContainerRequestFilter {
+
+ private static final Pattern VERSION_PATTERN = Pattern.compile("v\\d+|latest");
+
+ private RetiredService retiredService;
+
+ private String basePath;
+
+ @Autowired
+ public RetiredInterceptor(RetiredService retiredService, @Value("${schema.uri.base.path}") String basePath){
+ this.retiredService = retiredService;
+ this.basePath = basePath;
+ if(!basePath.endsWith("/")){
+ this.basePath = basePath + "/";
+ }
+ }
+ @Override
+ public void filter(ContainerRequestContext containerRequestContext) throws IOException {
+
+ String requestURI = containerRequestContext.getUriInfo().getAbsolutePath().getPath();
+
+ String version = extractVersionFromPath(requestURI);
+
+ List<Pattern> retiredAllVersionList = retiredService.getRetiredAllVersionList();
+
+
+ if(checkIfUriRetired(containerRequestContext, retiredAllVersionList, version, requestURI, "")){
+ return;
+ }
+
+ List<Pattern> retiredVersionList = retiredService.getRetiredPatterns();
+
+ checkIfUriRetired(containerRequestContext, retiredVersionList, version, requestURI);
+ }
+
+ public boolean checkIfUriRetired(ContainerRequestContext containerRequestContext,
+ List<Pattern> retiredPatterns,
+ String version,
+ String requestURI,
+ String message){
+
+
+ for(Pattern retiredPattern : retiredPatterns){
+ if(retiredPattern.matcher(requestURI).matches()){
+ AAIException e;
+
+ if(message == null){
+ e = new AAIException("AAI_3007");
+ } else {
+ e = new AAIException("AAI_3015");
+ }
+
+ ArrayList<String> templateVars = new ArrayList<>();
+
+ if (templateVars.isEmpty()) {
+ templateVars.add("PUT");
+ if(requestURI != null){
+ requestURI = requestURI.replaceAll(basePath, "");
+ }
+ templateVars.add(requestURI);
+ if(message == null){
+ templateVars.add(version);
+ templateVars.add(AAIConfig.get("aai.default.api.version", ""));
+ }
+ }
+
+ Response response = Response
+ .status(e.getErrorObject().getHTTPResponseCode())
+ .entity(
+ ErrorLogHelper
+ .getRESTAPIErrorResponse(
+ containerRequestContext.getAcceptableMediaTypes(), e, templateVars
+ )
+ )
+ .build();
+
+ containerRequestContext.abortWith(response);
+
+ return true;
+ }
+ }
+
+ return false;
+ }
+
+ public boolean checkIfUriRetired(ContainerRequestContext containerRequestContext,
+ List<Pattern> retiredPatterns,
+ String version,
+ String requestURI){
+ return checkIfUriRetired(containerRequestContext, retiredPatterns, version, requestURI, null);
+ }
+
+ protected String extractVersionFromPath(String requestURI) {
+ Matcher versionMatcher = VERSION_PATTERN.matcher(requestURI);
+ String version = null;
+
+ if(versionMatcher.find()){
+ version = versionMatcher.group(0);
+ }
+ return version;
+ }
+
+}
diff --git a/aai-traversal/src/main/java/org/onap/aai/interceptors/pre/SetLoggingContext.java b/aai-traversal/src/main/java/org/onap/aai/interceptors/pre/SetLoggingContext.java
index c991017..4b0f18a 100644
--- a/aai-traversal/src/main/java/org/onap/aai/interceptors/pre/SetLoggingContext.java
+++ b/aai-traversal/src/main/java/org/onap/aai/interceptors/pre/SetLoggingContext.java
@@ -19,19 +19,18 @@
*/
package org.onap.aai.interceptors.pre;
-import java.io.IOException;
+import org.onap.aai.interceptors.AAIContainerFilter;
+import org.onap.aai.interceptors.AAIHeaderProperties;
+import org.onap.aai.logging.LoggingContext;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.core.env.Environment;
import javax.annotation.Priority;
import javax.servlet.http.HttpServletRequest;
import javax.ws.rs.container.ContainerRequestContext;
import javax.ws.rs.container.ContainerRequestFilter;
import javax.ws.rs.container.PreMatching;
-
-import org.onap.aai.interceptors.AAIContainerFilter;
-import org.onap.aai.interceptors.AAIHeaderProperties;
-import org.onap.aai.logging.LoggingContext;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.core.env.Environment;
+import java.io.IOException;
@PreMatching
@Priority(AAIRequestFilterPriority.SET_LOGGING_CONTEXT)
@@ -64,6 +63,7 @@ public class SetLoggingContext extends AAIContainerFilter implements ContainerRe
LoggingContext.component(fromAppId);
LoggingContext.serviceName(httpMethod + " " + uri);
LoggingContext.targetServiceName(httpMethod + " " + uri);
+ LoggingContext.statusCode(LoggingContext.StatusCode.COMPLETE);
}
}
diff --git a/aai-traversal/src/main/java/org/onap/aai/interceptors/pre/TwoWaySslAuthorization.java b/aai-traversal/src/main/java/org/onap/aai/interceptors/pre/TwoWaySslAuthorization.java
new file mode 100644
index 0000000..bc03082
--- /dev/null
+++ b/aai-traversal/src/main/java/org/onap/aai/interceptors/pre/TwoWaySslAuthorization.java
@@ -0,0 +1,185 @@
+/**
+ * ============LICENSE_START=======================================================
+ * org.onap.aai
+ * ================================================================================
+ * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY 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.interceptors.pre;
+
+import org.onap.aai.auth.AAIAuthCore;
+import org.onap.aai.exceptions.AAIException;
+import org.onap.aai.interceptors.AAIContainerFilter;
+import org.onap.aai.interceptors.AAIHeaderProperties;
+import org.onap.aai.logging.ErrorLogHelper;
+import org.onap.aai.restcore.HttpMethod;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.context.annotation.Profile;
+
+import javax.annotation.Priority;
+import javax.security.auth.x500.X500Principal;
+import javax.servlet.http.HttpServletRequest;
+import javax.ws.rs.container.ContainerRequestContext;
+import javax.ws.rs.container.ContainerRequestFilter;
+import javax.ws.rs.container.PreMatching;
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.Response;
+import java.security.cert.X509Certificate;
+import java.util.*;
+import java.util.stream.Collectors;
+
+@PreMatching
+@Priority(AAIRequestFilterPriority.AUTHORIZATION)
+@Profile("two-way-ssl")
+public class TwoWaySslAuthorization extends AAIContainerFilter implements ContainerRequestFilter {
+
+ @Autowired
+ private HttpServletRequest httpServletRequest;
+
+ @Autowired
+ private AAIAuthCore aaiAuthCore;
+
+ @Override
+ public void filter(ContainerRequestContext requestContext) {
+
+ Optional<Response> oResp;
+
+ String uri = requestContext.getUriInfo().getAbsolutePath().getPath();
+ String httpMethod = getHttpMethod(requestContext);
+
+ List<MediaType> acceptHeaderValues = requestContext.getAcceptableMediaTypes();
+
+ Optional<String> authUser = getUser(this.httpServletRequest);
+
+ if (authUser.isPresent()) {
+ oResp = this.authorize(uri, httpMethod, acceptHeaderValues, authUser.get(),
+ this.getHaProxyUser(this.httpServletRequest), getCertIssuer(this.httpServletRequest));
+ if (oResp.isPresent()) {
+ requestContext.abortWith(oResp.get());
+ return;
+ }
+ } else {
+ AAIException aaie = new AAIException("AAI_9107");
+ requestContext
+ .abortWith(Response
+ .status(aaie.getErrorObject().getHTTPResponseCode()).entity(ErrorLogHelper
+ .getRESTAPIErrorResponseWithLogging(acceptHeaderValues, aaie, new ArrayList<>()))
+ .build());
+ }
+
+ }
+
+ private String getCertIssuer(HttpServletRequest hsr) {
+ String issuer = hsr.getHeader("X-AAI-SSL-Issuer");
+ if (issuer != null && !issuer.isEmpty()) {
+ // the haproxy header replaces the ', ' with '/' and reverses on the '/' need to undo that.
+ List<String> broken = Arrays.asList(issuer.split("/"));
+ broken = broken.stream().filter(s -> !s.isEmpty()).collect(Collectors.toList());
+ Collections.reverse(broken);
+ issuer = String.join(", ", broken);
+ } else {
+ if (hsr.getAttribute("javax.servlet.request.cipher_suite") != null) {
+ X509Certificate[] certChain = (X509Certificate[]) hsr.getAttribute("javax.servlet.request.X509Certificate");
+ if (certChain != null && certChain.length > 0) {
+ X509Certificate clientCert = certChain[0];
+ issuer = clientCert.getIssuerX500Principal().getName();
+ }
+ }
+ }
+ return issuer;
+ }
+
+ private String getHttpMethod(ContainerRequestContext requestContext) {
+ String httpMethod = requestContext.getMethod();
+ if ("POST".equalsIgnoreCase(httpMethod)
+ && "PATCH".equals(requestContext.getHeaderString(AAIHeaderProperties.HTTP_METHOD_OVERRIDE))) {
+ httpMethod = HttpMethod.MERGE_PATCH.toString();
+ }
+ if (httpMethod.equalsIgnoreCase(HttpMethod.MERGE_PATCH.toString()) || "patch".equalsIgnoreCase(httpMethod)) {
+ httpMethod = HttpMethod.PUT.toString();
+ }
+ return httpMethod;
+ }
+
+ private Optional<String> getUser(HttpServletRequest hsr) {
+ String authUser = null;
+ if (hsr.getAttribute("javax.servlet.request.cipher_suite") != null) {
+ X509Certificate[] certChain = (X509Certificate[]) hsr.getAttribute("javax.servlet.request.X509Certificate");
+
+ /*
+ * If the certificate is null or the certificate chain length is zero Then
+ * retrieve the authorization in the request header Authorization Check that it
+ * is not null and that it starts with Basic and then strip the basic portion to
+ * get the base64 credentials Check if this is contained in the AAIBasicAuth
+ * Singleton class If it is, retrieve the username associated with that
+ * credentials and set to authUser Otherwise, get the principal from certificate
+ * and use that authUser
+ */
+
+ if (certChain == null || certChain.length == 0) {
+
+ String authorization = hsr.getHeader("Authorization");
+
+ if (authorization != null && authorization.startsWith("Basic ")) {
+ authUser = authorization.replace("Basic ", "");
+ }
+
+ } else {
+ X509Certificate clientCert = certChain[0];
+ X500Principal subjectDN = clientCert.getSubjectX500Principal();
+ authUser = subjectDN.toString().toLowerCase();
+ }
+ }
+
+ return Optional.ofNullable(authUser);
+ }
+
+ private String getHaProxyUser(HttpServletRequest hsr) {
+ String haProxyUser;
+ if (Objects.isNull(hsr.getHeader("X-AAI-SSL-Client-CN"))
+ || Objects.isNull(hsr.getHeader("X-AAI-SSL-Client-OU"))
+ || Objects.isNull(hsr.getHeader("X-AAI-SSL-Client-O"))
+ || Objects.isNull(hsr.getHeader("X-AAI-SSL-Client-L"))
+ || Objects.isNull(hsr.getHeader("X-AAI-SSL-Client-ST"))
+ || Objects.isNull(hsr.getHeader("X-AAI-SSL-Client-C"))) {
+ haProxyUser = "";
+ } else {
+ haProxyUser = String.format("CN=%s, OU=%s, O=\"%s\", L=%s, ST=%s, C=%s",
+ Objects.toString(hsr.getHeader("X-AAI-SSL-Client-CN"), ""),
+ Objects.toString(hsr.getHeader("X-AAI-SSL-Client-OU"), ""),
+ Objects.toString(hsr.getHeader("X-AAI-SSL-Client-O"), ""),
+ Objects.toString(hsr.getHeader("X-AAI-SSL-Client-L"), ""),
+ Objects.toString(hsr.getHeader("X-AAI-SSL-Client-ST"), ""),
+ Objects.toString(hsr.getHeader("X-AAI-SSL-Client-C"), "")).toLowerCase();
+ }
+ return haProxyUser;
+ }
+
+ private Optional<Response> authorize(String uri, String httpMethod, List<MediaType> acceptHeaderValues,
+ String authUser, String haProxyUser, String issuer) {
+ Response response = null;
+ try {
+ if (!aaiAuthCore.authorize(authUser, uri, httpMethod, haProxyUser, issuer)) {
+ throw new AAIException("AAI_9101", "Request on " + httpMethod + " " + uri + " status is not OK");
+ }
+ } catch (AAIException e) {
+ response = Response.status(e.getErrorObject().getHTTPResponseCode())
+ .entity(ErrorLogHelper.getRESTAPIErrorResponseWithLogging(acceptHeaderValues, e, new ArrayList<>()))
+ .build();
+ }
+ return Optional.ofNullable(response);
+ }
+
+}
diff --git a/aai-traversal/src/main/java/org/onap/aai/interceptors/pre/VersionInterceptor.java b/aai-traversal/src/main/java/org/onap/aai/interceptors/pre/VersionInterceptor.java
new file mode 100644
index 0000000..df9807c
--- /dev/null
+++ b/aai-traversal/src/main/java/org/onap/aai/interceptors/pre/VersionInterceptor.java
@@ -0,0 +1,101 @@
+/**
+ * ============LICENSE_START=======================================================
+ * org.onap.aai
+ * ================================================================================
+ * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY 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.interceptors.pre;
+
+import org.onap.aai.exceptions.AAIException;
+import org.onap.aai.interceptors.AAIContainerFilter;
+import org.onap.aai.logging.ErrorLogHelper;
+import org.onap.aai.setup.SchemaVersion;
+import org.onap.aai.setup.SchemaVersions;
+import org.springframework.beans.factory.annotation.Autowired;
+
+import javax.annotation.Priority;
+import javax.ws.rs.container.ContainerRequestContext;
+import javax.ws.rs.container.ContainerRequestFilter;
+import javax.ws.rs.container.PreMatching;
+import javax.ws.rs.core.Response;
+import java.util.ArrayList;
+import java.util.Set;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+import java.util.stream.Collectors;
+
+@PreMatching
+@Priority(AAIRequestFilterPriority.VERSION)
+public class VersionInterceptor extends AAIContainerFilter implements ContainerRequestFilter {
+
+ public static final Pattern EXTRACT_VERSION_PATTERN = Pattern.compile("^(v[1-9][0-9]*).*$");
+
+ private final Set<String> allowedVersions;
+
+ private final SchemaVersions schemaVersions;
+
+ @Autowired
+ public VersionInterceptor(SchemaVersions schemaVersions){
+ this.schemaVersions = schemaVersions;
+ allowedVersions = schemaVersions.getVersions()
+ .stream()
+ .map(SchemaVersion::toString)
+ .collect(Collectors.toSet());
+
+ }
+
+ @Override
+ public void filter(ContainerRequestContext requestContext) {
+
+ String uri = requestContext.getUriInfo().getPath();
+
+ if (uri.startsWith("search") || uri.startsWith("util/echo") || uri.startsWith("tools") || uri.startsWith("recents")) {
+ return;
+ }
+
+ Matcher matcher = EXTRACT_VERSION_PATTERN.matcher(uri);
+
+ String version = null;
+ if(matcher.matches()){
+ version = matcher.group(1);
+ } else {
+ requestContext.abortWith(createInvalidVersionResponse("AAI_3017", requestContext, version));
+ return;
+ }
+
+ if(!allowedVersions.contains(version)){
+ requestContext.abortWith(createInvalidVersionResponse("AAI_3016", requestContext, version));
+ }
+ }
+
+ private Response createInvalidVersionResponse(String errorCode, ContainerRequestContext context, String version) {
+ AAIException e = new AAIException(errorCode);
+ ArrayList<String> templateVars = new ArrayList<>();
+
+ if (templateVars.isEmpty()) {
+ templateVars.add(context.getMethod());
+ templateVars.add(context.getUriInfo().getPath());
+ templateVars.add(version);
+ }
+
+ String entity = ErrorLogHelper.getRESTAPIErrorResponse(context.getAcceptableMediaTypes(), e, templateVars);
+
+ return Response
+ .status(e.getErrorObject().getHTTPResponseCode())
+ .entity(entity)
+ .build();
+ }
+}
diff --git a/aai-traversal/src/main/java/org/onap/aai/interceptors/pre/VersionLatestInterceptor.java b/aai-traversal/src/main/java/org/onap/aai/interceptors/pre/VersionLatestInterceptor.java
new file mode 100644
index 0000000..124bc1a
--- /dev/null
+++ b/aai-traversal/src/main/java/org/onap/aai/interceptors/pre/VersionLatestInterceptor.java
@@ -0,0 +1,57 @@
+/**
+ * ============LICENSE_START=======================================================
+ * org.onap.aai
+ * ================================================================================
+ * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY 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.interceptors.pre;
+
+import org.onap.aai.interceptors.AAIContainerFilter;
+import org.onap.aai.setup.SchemaVersions;
+import org.springframework.beans.factory.annotation.Autowired;
+
+import javax.annotation.Priority;
+import javax.ws.rs.container.ContainerRequestContext;
+import javax.ws.rs.container.ContainerRequestFilter;
+import javax.ws.rs.container.PreMatching;
+import java.net.URI;
+
+@PreMatching
+@Priority(AAIRequestFilterPriority.LATEST)
+public class VersionLatestInterceptor extends AAIContainerFilter implements ContainerRequestFilter {
+
+ private final SchemaVersions schemaVersions;
+
+ @Autowired
+ public VersionLatestInterceptor(SchemaVersions schemaVersions){
+ this.schemaVersions = schemaVersions;
+ }
+
+ @Override
+ public void filter(ContainerRequestContext requestContext) {
+
+ String uri = requestContext.getUriInfo().getPath();
+
+ if(uri.startsWith("latest")){
+ String rawPath = requestContext.getUriInfo().getRequestUri().getRawPath();
+ String updatedPath = rawPath.replaceFirst("latest",schemaVersions.getDefaultVersion().toString());
+ URI latest = requestContext.getUriInfo().getRequestUriBuilder().replacePath(updatedPath).build();
+ requestContext.setRequestUri(latest);
+ return;
+ }
+
+ }
+}
diff --git a/aai-traversal/src/main/java/org/onap/aai/rest/DslConsumer.java b/aai-traversal/src/main/java/org/onap/aai/rest/DslConsumer.java
new file mode 100644
index 0000000..bdca63b
--- /dev/null
+++ b/aai-traversal/src/main/java/org/onap/aai/rest/DslConsumer.java
@@ -0,0 +1,187 @@
+/**
+ * ============LICENSE_START=======================================================
+ * org.onap.aai
+ * ================================================================================
+ * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY 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.rest;
+
+import java.util.List;
+import java.util.concurrent.TimeUnit;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.ws.rs.Consumes;
+import javax.ws.rs.DefaultValue;
+import javax.ws.rs.Encoded;
+import javax.ws.rs.PUT;
+import javax.ws.rs.Path;
+import javax.ws.rs.PathParam;
+import javax.ws.rs.Produces;
+import javax.ws.rs.QueryParam;
+import javax.ws.rs.core.Context;
+import javax.ws.rs.core.HttpHeaders;
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.Response;
+import javax.ws.rs.core.UriInfo;
+import javax.ws.rs.core.Response.Status;
+
+import org.onap.aai.concurrent.AaiCallable;
+import org.onap.aai.dbmap.DBConnectionType;
+import org.onap.aai.exceptions.AAIException;
+import org.onap.aai.introspection.ModelType;
+import org.onap.aai.logging.LoggingContext;
+import org.onap.aai.logging.StopWatch;
+import org.onap.aai.rest.db.HttpEntry;
+import org.onap.aai.rest.dsl.DslQueryProcessor;
+import org.onap.aai.rest.search.GenericQueryProcessor;
+import org.onap.aai.rest.search.GremlinServerSingleton;
+import org.onap.aai.rest.search.QueryProcessorType;
+import org.onap.aai.restcore.HttpMethod;
+import org.onap.aai.restcore.RESTAPI;
+import org.onap.aai.serialization.db.DBSerializer;
+import org.onap.aai.serialization.engines.TransactionalGraphEngine;
+import org.onap.aai.serialization.queryformats.Format;
+import org.onap.aai.serialization.queryformats.FormatFactory;
+import org.onap.aai.serialization.queryformats.Formatter;
+import org.onap.aai.serialization.queryformats.SubGraphStyle;
+import org.onap.aai.setup.SchemaVersion;
+import org.onap.aai.setup.SchemaVersions;
+import org.onap.aai.util.TraversalConstants;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Value;
+
+import com.att.eelf.configuration.EELFLogger;
+import com.att.eelf.configuration.EELFManager;
+import com.google.gson.JsonElement;
+import com.google.gson.JsonObject;
+import com.google.gson.JsonParser;
+
+@Path("{version: v[1-9][0-9]*|latest}/dsl")
+public class DslConsumer extends RESTAPI {
+
+ private HttpEntry traversalUriHttpEntry;
+
+ private QueryProcessorType processorType = QueryProcessorType.LOCAL_GROOVY;
+
+ private static final String TARGET_ENTITY = "DB";
+ private static final EELFLogger LOGGER = EELFManager.getInstance().getLogger(DslConsumer.class);
+
+ private DslQueryProcessor dslQueryProcessor;
+
+ private SchemaVersions schemaVersions;
+
+ private String basePath;
+
+ private GremlinServerSingleton gremlinServerSingleton;
+
+ @Autowired
+ public DslConsumer(HttpEntry traversalUriHttpEntry, DslQueryProcessor dslQueryProcessor,
+ SchemaVersions schemaVersions, GremlinServerSingleton gremlinServerSingleton,
+ @Value("${schema.uri.base.path}") String basePath) {
+ this.traversalUriHttpEntry = traversalUriHttpEntry;
+ this.dslQueryProcessor = dslQueryProcessor;
+ this.schemaVersions = schemaVersions;
+ this.gremlinServerSingleton = gremlinServerSingleton;
+ this.basePath = basePath;
+ }
+
+ @PUT
+ @Consumes({ MediaType.APPLICATION_JSON })
+ @Produces({ MediaType.APPLICATION_JSON })
+ public Response executeQuery(String content, @PathParam("version") String versionParam,
+ @PathParam("uri") @Encoded String uri, @DefaultValue("graphson") @QueryParam("format") String queryFormat,
+ @DefaultValue("no_op") @QueryParam("subgraph") String subgraph, @Context HttpHeaders headers,
+ @Context UriInfo info, @Context HttpServletRequest req) {
+ return runner(TraversalConstants.AAI_TRAVERSAL_DSL_TIMEOUT_ENABLED,
+ TraversalConstants.AAI_TRAVERSAL_DSL_TIMEOUT_APP, TraversalConstants.AAI_TRAVERSAL_DSL_TIMEOUT_LIMIT,
+ headers, info, HttpMethod.PUT, new AaiCallable<Response>() {
+ @Override
+ public Response process() {
+ return processExecuteQuery(content, versionParam, uri, queryFormat, subgraph, headers, info,
+ req);
+ }
+ });
+ }
+
+ public Response processExecuteQuery(String content, @PathParam("version") String versionParam,
+ @PathParam("uri") @Encoded String uri, @DefaultValue("graphson") @QueryParam("format") String queryFormat,
+ @DefaultValue("no_op") @QueryParam("subgraph") String subgraph, @Context HttpHeaders headers,
+ @Context UriInfo info, @Context HttpServletRequest req) {
+
+ String methodName = "executeDslQuery";
+ String sourceOfTruth = headers.getRequestHeaders().getFirst("X-FromAppId");
+ String realTime = headers.getRequestHeaders().getFirst("Real-Time");
+ Response response;
+ SchemaVersion version = new SchemaVersion(versionParam);
+
+ TransactionalGraphEngine dbEngine = null;
+ try {
+ LoggingContext.save();
+ DBConnectionType type = this.determineConnectionType(sourceOfTruth, realTime);
+ traversalUriHttpEntry.setHttpEntryProperties(version, type);
+ dbEngine = traversalUriHttpEntry.getDbEngine();
+ JsonObject input = new JsonParser().parse(content).getAsJsonObject();
+ JsonElement dslElement = input.get("dsl");
+ String dsl = "";
+ if (dslElement != null) {
+ dsl = dslElement.getAsString();
+ }
+
+ LoggingContext.targetEntity(TARGET_ENTITY);
+ LoggingContext.targetServiceName(methodName);
+ LoggingContext.startTime();
+ StopWatch.conditionalStart();
+
+ GenericQueryProcessor processor = new GenericQueryProcessor.Builder(dbEngine, gremlinServerSingleton)
+ .queryFrom(dsl, "dsl").queryProcessor(dslQueryProcessor).processWith(processorType).create();
+
+ String result = "";
+ SubGraphStyle subGraphStyle = SubGraphStyle.valueOf(subgraph);
+ List<Object> vertices = processor.execute(subGraphStyle);
+
+ DBSerializer serializer = new DBSerializer(version, dbEngine, ModelType.MOXY, sourceOfTruth);
+ Format format = Format.getFormat(queryFormat);
+ FormatFactory ff = new FormatFactory(traversalUriHttpEntry.getLoader(), serializer, schemaVersions,
+ this.basePath);
+
+ Formatter formater = ff.get(format, info.getQueryParameters());
+
+ result = formater.output(vertices).toString();
+
+ double msecs = StopWatch.stopIfStarted();
+ LoggingContext.elapsedTime((long) msecs, TimeUnit.MILLISECONDS);
+ LoggingContext.successStatusFields();
+ LOGGER.info("Completed");
+
+ response = Response.status(Status.OK).type(MediaType.APPLICATION_JSON).entity(result).build();
+
+ } catch (AAIException e) {
+ response = consumerExceptionResponseGenerator(headers, info, HttpMethod.PUT, e);
+ } catch (Exception e) {
+ AAIException ex = new AAIException("AAI_4000", e);
+ response = consumerExceptionResponseGenerator(headers, info, HttpMethod.PUT, ex);
+ } finally {
+ LoggingContext.restoreIfPossible();
+ LoggingContext.successStatusFields();
+ if (dbEngine != null) {
+ dbEngine.rollback();
+ }
+
+ }
+
+ return response;
+ }
+}
diff --git a/aai-traversal/src/main/java/org/onap/aai/rest/QueryConsumer.java b/aai-traversal/src/main/java/org/onap/aai/rest/QueryConsumer.java
index 6f6abd1..7ce61e3 100644
--- a/aai-traversal/src/main/java/org/onap/aai/rest/QueryConsumer.java
+++ b/aai-traversal/src/main/java/org/onap/aai/rest/QueryConsumer.java
@@ -25,7 +25,6 @@ import java.util.LinkedHashSet;
import java.util.List;
import java.util.Set;
import java.util.concurrent.TimeUnit;
-import java.util.concurrent.Callable;
import javax.servlet.http.HttpServletRequest;
import javax.ws.rs.Consumes;
@@ -45,10 +44,10 @@ import javax.ws.rs.core.Response.Status;
import javax.ws.rs.core.UriInfo;
import org.apache.tinkerpop.gremlin.structure.Vertex;
+import org.onap.aai.concurrent.AaiCallable;
import org.onap.aai.dbmap.DBConnectionType;
import org.onap.aai.exceptions.AAIException;
import org.onap.aai.introspection.ModelType;
-import org.onap.aai.introspection.Version;
import org.onap.aai.logging.ErrorLogHelper;
import org.onap.aai.parsers.query.QueryParser;
import org.onap.aai.rest.db.HttpEntry;
@@ -69,18 +68,20 @@ import org.onap.aai.serialization.queryformats.SubGraphStyle;
import com.att.eelf.configuration.EELFLogger;
import com.att.eelf.configuration.EELFManager;
import org.onap.aai.logging.LoggingContext;
-import org.onap.aai.logging.LoggingContext.StatusCode;
import org.onap.aai.logging.StopWatch;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import com.google.gson.JsonParser;
+import org.onap.aai.setup.SchemaVersion;
+import org.onap.aai.setup.SchemaVersions;
import org.onap.aai.util.AAIConstants;
+import org.onap.aai.util.TraversalConstants;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Value;
-@Path("{version: v9|v1[01234]}/query")
+@Path("{version: v[1-9][0-9]*|latest}/query")
public class QueryConsumer extends RESTAPI {
-
- private static final String DEPTH = "depth";
/** The introspector factory type. */
private ModelType introspectorFactoryType = ModelType.MOXY;
@@ -91,20 +92,42 @@ public class QueryConsumer extends RESTAPI {
private static final String TARGET_ENTITY = "DB";
private static final EELFLogger LOGGER = EELFManager.getInstance().getLogger(QueryConsumer.class);
+
+ private HttpEntry traversalUriHttpEntry;
+
+ private SchemaVersions schemaVersions;
+
+ private String basePath;
+
+ private GremlinServerSingleton gremlinServerSingleton;
+
+ @Autowired
+ public QueryConsumer(
+ HttpEntry traversalUriHttpEntry,
+ SchemaVersions schemaVersions,
+ GremlinServerSingleton gremlinServerSingleton,
+ @Value("${schema.uri.base.path}") String basePath
+ ){
+ this.traversalUriHttpEntry = traversalUriHttpEntry;
+ this.schemaVersions = schemaVersions;
+ this.gremlinServerSingleton = gremlinServerSingleton;
+ this.basePath = basePath;
+ }
+
@PUT
@Consumes({ MediaType.APPLICATION_JSON})
@Produces({ MediaType.APPLICATION_JSON})
public Response executeQuery(String content, @PathParam("version")String versionParam, @PathParam("uri") @Encoded String uri, @DefaultValue("graphson") @QueryParam("format") String queryFormat,@DefaultValue("no_op") @QueryParam("subgraph") String subgraph, @Context HttpHeaders headers, @Context UriInfo info, @Context HttpServletRequest req){
- return runner(AAIConstants.AAI_TRAVERSAL_TIMEOUT_ENABLED,
- AAIConstants.AAI_TRAVERSAL_TIMEOUT_APP,
- AAIConstants.AAI_TRAVERSAL_TIMEOUT_LIMIT,
+ return runner(TraversalConstants.AAI_TRAVERSAL_TIMEOUT_ENABLED,
+ TraversalConstants.AAI_TRAVERSAL_TIMEOUT_APP,
+ TraversalConstants.AAI_TRAVERSAL_TIMEOUT_LIMIT,
headers,
info,
HttpMethod.GET,
- new Callable<Response>() {
+ new AaiCallable<Response>() {
@Override
- public Response call() {
+ public Response process() {
return processExecuteQuery(content, versionParam, uri, queryFormat, subgraph, headers, info, req);
}
}
@@ -123,7 +146,7 @@ public class QueryConsumer extends RESTAPI {
try {
LoggingContext.save();
this.checkQueryParams(info.getQueryParameters());
- Format format = Format.valueOf(queryFormat);
+ Format format = Format.getFormat(queryFormat);
if (queryProcessor != null) {
processorType = QueryProcessorType.valueOf(queryProcessor);
}
@@ -135,19 +158,17 @@ public class QueryConsumer extends RESTAPI {
JsonElement startElement = input.get("start");
JsonElement queryElement = input.get("query");
JsonElement gremlinElement = input.get("gremlin");
- JsonElement dslElement = input.get("dsl");
List<URI> startURIs = new ArrayList<>();
String queryURI = "";
String gremlin = "";
- String dsl = "";
- Version version = Version.valueOf(versionParam);
+ SchemaVersion version = new SchemaVersion(versionParam);
DBConnectionType type = this.determineConnectionType(sourceOfTruth, realTime);
- HttpEntry httpEntry = new HttpEntry(version, introspectorFactoryType, queryStyle, type);
- dbEngine = httpEntry.getDbEngine();
+ traversalUriHttpEntry.setHttpEntryProperties(version, type);
+ dbEngine = traversalUriHttpEntry.getDbEngine();
if (startElement != null) {
-
+
if (startElement.isJsonArray()) {
for (JsonElement element : startElement.getAsJsonArray()) {
startURIs.add(new URI(element.getAsString()));
@@ -162,9 +183,6 @@ public class QueryConsumer extends RESTAPI {
if (gremlinElement != null) {
gremlin = gremlinElement.getAsString();
}
- if (dslElement != null) {
- dsl = dslElement.getAsString();
- }
URI queryURIObj = new URI(queryURI);
CustomQueryConfig customQueryConfig = getCustomQueryConfig(queryURIObj);
@@ -184,7 +202,7 @@ public class QueryConsumer extends RESTAPI {
LoggingContext.targetServiceName(methodName);
LoggingContext.startTime();
StopWatch.conditionalStart();
-
+
if (!startURIs.isEmpty()) {
Set<Vertex> vertexSet = new LinkedHashSet<>();
QueryParser uriQuery;
@@ -195,19 +213,16 @@ public class QueryConsumer extends RESTAPI {
vertexSet.addAll(vertices);
}
- processor = new GenericQueryProcessor.Builder(dbEngine)
+
+ processor = new GenericQueryProcessor.Builder(dbEngine, gremlinServerSingleton)
.startFrom(vertexSet).queryFrom(queryURIObj)
.processWith(processorType).create();
} else if (!queryURI.equals("")){
- processor = new GenericQueryProcessor.Builder(dbEngine)
+ processor = new GenericQueryProcessor.Builder(dbEngine, gremlinServerSingleton)
.queryFrom(queryURIObj)
.processWith(processorType).create();
- } else if(!dsl.equals("")){
- processor = new GenericQueryProcessor.Builder(dbEngine)
- .queryFrom(dsl, "dsl")
- .processWith(processorType).create();
- }else {
- processor = new GenericQueryProcessor.Builder(dbEngine)
+ } else {
+ processor = new GenericQueryProcessor.Builder(dbEngine, gremlinServerSingleton)
.queryFrom(gremlin, "gremlin")
.processWith(processorType).create();
}
@@ -215,7 +230,7 @@ public class QueryConsumer extends RESTAPI {
List<Object> vertices = processor.execute(subGraphStyle);
DBSerializer serializer = new DBSerializer(version, dbEngine, introspectorFactoryType, sourceOfTruth);
- FormatFactory ff = new FormatFactory(httpEntry.getLoader(), serializer);
+ FormatFactory ff = new FormatFactory(traversalUriHttpEntry.getLoader(), serializer, schemaVersions, this.basePath);
Formatter formater = ff.get(format, info.getQueryParameters());
@@ -250,8 +265,8 @@ public class QueryConsumer extends RESTAPI {
public void checkQueryParams(MultivaluedMap<String, String> params) throws AAIException {
- if (params.containsKey(DEPTH) && params.getFirst(DEPTH).matches("\\d+")) {
- String depth = params.getFirst(DEPTH);
+ if (params.containsKey("depth") && params.getFirst("depth").matches("\\d+")) {
+ String depth = params.getFirst("depth");
Integer i = Integer.parseInt(depth);
if (i > 1) {
throw new AAIException("AAI_3303");
@@ -274,7 +289,6 @@ public class QueryConsumer extends RESTAPI {
private CustomQueryConfig getCustomQueryConfig(URI uriObj ) {
- GremlinServerSingleton gremlinServerSingleton;
CustomQueryConfig customQueryConfig;
String path = uriObj.getPath();
@@ -282,7 +296,6 @@ public class QueryConsumer extends RESTAPI {
boolean hasQuery = false;
for ( String part:parts ) {
if ( hasQuery) {
- gremlinServerSingleton = GremlinServerSingleton.getInstance();
return gremlinServerSingleton.getCustomQueryConfig(part);
}
if ( "query".equals(part)) {
@@ -303,11 +316,13 @@ public class QueryConsumer extends RESTAPI {
templateVars.add(missingRequiredQueryParams.toString());
}
- return Response
+ Response response = Response
.status(e.getErrorObject().getHTTPResponseCode())
.entity(ErrorLogHelper.getRESTAPIErrorResponse(headers.getAcceptableMediaTypes(), e,
templateVars)).build();
- }
+
+ return response;
+ }
private Response createMessageInvalidQuerySection(String invalidQuery, HttpHeaders headers, UriInfo info, HttpServletRequest req) {
AAIException e = new AAIException("AAI_3014");
@@ -318,11 +333,13 @@ public class QueryConsumer extends RESTAPI {
templateVars.add(invalidQuery);
}
- return Response
+ Response response = Response
.status(e.getErrorObject().getHTTPResponseCode())
.entity(ErrorLogHelper.getRESTAPIErrorResponse(headers.getAcceptableMediaTypes(), e,
templateVars)).build();
- }
+
+ return response;
+ }
}
diff --git a/aai-traversal/src/main/java/org/onap/aai/rest/RecentAPIConsumer.java b/aai-traversal/src/main/java/org/onap/aai/rest/RecentAPIConsumer.java
new file mode 100644
index 0000000..46bccdf
--- /dev/null
+++ b/aai-traversal/src/main/java/org/onap/aai/rest/RecentAPIConsumer.java
@@ -0,0 +1,253 @@
+/**
+ * ============LICENSE_START=======================================================
+ * org.onap.aai
+ * ================================================================================
+ * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY 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.rest;
+
+import java.util.List;
+import java.util.concurrent.TimeUnit;
+
+import javax.ws.rs.Consumes;
+import javax.ws.rs.GET;
+import javax.ws.rs.Path;
+import javax.ws.rs.PathParam;
+import javax.ws.rs.Produces;
+import javax.ws.rs.QueryParam;
+import javax.ws.rs.core.Context;
+import javax.ws.rs.core.HttpHeaders;
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.MultivaluedMap;
+import javax.ws.rs.core.Response;
+import javax.ws.rs.core.Response.Status;
+import javax.ws.rs.core.UriInfo;
+
+import org.onap.aai.concurrent.AaiCallable;
+import org.onap.aai.dbmap.DBConnectionType;
+
+import org.onap.aai.exceptions.AAIException;
+import org.onap.aai.introspection.Introspector;
+import org.onap.aai.introspection.ModelType;
+import org.onap.aai.introspection.exceptions.AAIUnknownObjectException;
+import org.onap.aai.setup.SchemaVersion;
+import org.onap.aai.setup.SchemaVersions;
+import org.onap.aai.rest.db.HttpEntry;
+import org.onap.aai.rest.dsl.DslQueryProcessor;
+import org.onap.aai.rest.search.GenericQueryProcessor;
+import org.onap.aai.rest.search.GremlinServerSingleton;
+import org.onap.aai.rest.search.QueryProcessorType;
+import org.onap.aai.restcore.HttpMethod;
+import org.onap.aai.restcore.RESTAPI;
+import org.onap.aai.serialization.db.DBSerializer;
+import org.onap.aai.serialization.engines.TransactionalGraphEngine;
+import org.onap.aai.serialization.queryformats.Format;
+import org.onap.aai.serialization.queryformats.FormatFactory;
+import org.onap.aai.serialization.queryformats.Formatter;
+import org.onap.aai.serialization.queryformats.SubGraphStyle;
+import com.att.eelf.configuration.EELFLogger;
+import com.att.eelf.configuration.EELFManager;
+import org.onap.aai.logging.LoggingContext;
+import org.onap.aai.logging.StopWatch;
+
+import org.onap.aai.util.AAIConstants;
+import org.onap.aai.util.TraversalConstants;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Value;
+
+@Path("/recents/{version: v[1-9][0-9]*|latest}")
+public class RecentAPIConsumer extends RESTAPI {
+
+ /** The introspector factory type. */
+ private ModelType introspectorFactoryType = ModelType.MOXY;
+
+ private QueryProcessorType processorType = QueryProcessorType.LOCAL_GROOVY;
+ /** The query style. */
+
+ private static final String TARGET_ENTITY = "DB";
+ private static final EELFLogger LOGGER = EELFManager.getInstance().getLogger(RecentAPIConsumer.class);
+
+ private HttpEntry traversalUriHttpEntry;
+
+ private DslQueryProcessor dslQueryProcessor;
+
+ private SchemaVersions schemaVersions;
+
+ private String basePath;
+
+ private GremlinServerSingleton gremlinServerSingleton;
+
+
+ @Autowired
+ public RecentAPIConsumer(
+ HttpEntry traversalUriHttpEntry,
+ DslQueryProcessor dslQueryProcessor,
+ SchemaVersions schemaVersions,
+ GremlinServerSingleton gremlinServerSingleton,
+ @Value("${schema.uri.base.path}") String basePath
+ ){
+ this.traversalUriHttpEntry = traversalUriHttpEntry;
+ this.dslQueryProcessor = dslQueryProcessor;
+ this.schemaVersions = schemaVersions;
+ this.gremlinServerSingleton = gremlinServerSingleton;
+ this.basePath = basePath;
+ }
+
+ @GET
+ @Path("/{nodeType: .+}")
+ @Consumes({ MediaType.APPLICATION_JSON })
+ @Produces({ MediaType.APPLICATION_JSON })
+ public Response getRecentData(String content, @PathParam("version") String versionParam,
+ @PathParam("nodeType") String nodeType, @Context HttpHeaders headers, @Context UriInfo info) {
+
+ return runner(TraversalConstants.AAI_TRAVERSAL_TIMEOUT_ENABLED, TraversalConstants.AAI_TRAVERSAL_TIMEOUT_APP,
+ TraversalConstants.AAI_TRAVERSAL_TIMEOUT_LIMIT, headers, info, HttpMethod.GET, new AaiCallable<Response>() {
+ @Override
+ public Response process() {
+ return processRecentData(content, versionParam, nodeType, info, headers);
+ }
+ });
+
+ }
+
+ public Response processRecentData(String content, @PathParam("version") String versionParam,
+ @PathParam("nodeType") String nodeType, @Context UriInfo info, @Context HttpHeaders headers) {
+
+ String methodName = "processRecentData";
+ String sourceOfTruth = headers.getRequestHeaders().getFirst("X-FromAppId");
+ String realTime = headers.getRequestHeaders().getFirst("Real-Time");
+ String queryProcessor = headers.getRequestHeaders().getFirst("QueryProcessor");
+ QueryProcessorType processorType = this.processorType;
+ Response response = null;
+ TransactionalGraphEngine dbEngine = null;
+ try {
+ LoggingContext.save();
+
+ if (queryProcessor != null) {
+ processorType = QueryProcessorType.valueOf(queryProcessor);
+ }
+
+ SchemaVersion version = new SchemaVersion(versionParam);
+ this.checkVersion(version);
+
+ DBConnectionType type = this.determineConnectionType(sourceOfTruth, realTime);
+ traversalUriHttpEntry.setHttpEntryProperties(version, type);
+ dbEngine = traversalUriHttpEntry.getDbEngine();
+
+ /*
+ * Check for mandatory parameters here
+ */
+
+ this.checkNodeType(nodeType);
+ this.checkQueryParams(info.getQueryParameters());
+
+ GenericQueryProcessor processor = null;
+
+ LoggingContext.targetEntity(TARGET_ENTITY);
+ LoggingContext.targetServiceName(methodName);
+ LoggingContext.startTime();
+ StopWatch.conditionalStart();
+
+ processor = new GenericQueryProcessor.Builder(dbEngine, gremlinServerSingleton).queryFrom(nodeType, "nodeQuery")
+ .uriParams(info.getQueryParameters())
+ .processWith(processorType).create();
+
+
+
+ String result = "";
+ SubGraphStyle subGraphStyle = null;
+ List<Object> vertices = processor.execute(subGraphStyle);
+
+ DBSerializer serializer = new DBSerializer(version, dbEngine, introspectorFactoryType, sourceOfTruth);
+ FormatFactory ff = new FormatFactory(traversalUriHttpEntry.getLoader(), serializer, schemaVersions, this.basePath);
+ Format format = Format.pathed_resourceversion;
+
+ Formatter formater = ff.get(format, info.getQueryParameters());
+
+ result = formater.output(vertices).toString();
+
+ double msecs = StopWatch.stopIfStarted();
+ LoggingContext.elapsedTime((long) msecs, TimeUnit.MILLISECONDS);
+ LoggingContext.successStatusFields();
+ LOGGER.info("Completed");
+
+ response = Response.status(Status.OK).type(MediaType.APPLICATION_JSON).entity(result).build();
+
+ } catch (AAIException e) {
+ response = consumerExceptionResponseGenerator(headers, info, HttpMethod.GET, e);
+ } catch (Exception e) {
+ AAIException ex = new AAIException("AAI_4000", e);
+ response = consumerExceptionResponseGenerator(headers, info, HttpMethod.GET, ex);
+ } finally {
+
+ LoggingContext.restoreIfPossible();
+ LoggingContext.successStatusFields();
+ if (dbEngine != null) {
+ dbEngine.rollback();
+ }
+
+ }
+
+ return response;
+ }
+
+ private void checkVersion(SchemaVersion version) throws AAIException {
+ if(!schemaVersions.getVersions().contains(version)){
+ throw new AAIException("AAI_3021", "Schema Version is not valid");
+ }
+ }
+
+ public void checkNodeType(String nodeType) throws AAIException {
+ try {
+ Introspector target = traversalUriHttpEntry.getLoader().introspectorFromName(nodeType);
+ } catch (AAIUnknownObjectException e) {
+ throw new AAIException("AAI_6115", "Unrecognized nodeType [" + nodeType + "] passed to recents query.");
+ }
+ }
+ public void checkQueryParams(MultivaluedMap<String, String> params) throws AAIException {
+
+ boolean isHoursParameter = false;
+ boolean isDateTimeParameter = false;
+
+ if (params != null && params.containsKey("hours") && params.getFirst("hours").matches("-?\\d+")) {
+ isHoursParameter = true;
+
+ Long hours = Long.parseLong(params.getFirst("hours"));
+ if (hours < 1 || hours > AAIConstants.HISTORY_MAX_HOURS) {
+ throw new AAIException("AAI_3021", " Valid values for hours are 1 to " + AAIConstants.HISTORY_MAX_HOURS);
+ }
+ }
+ if (params != null && params.containsKey("date-time") && params.getFirst("date-time").matches("-?\\d+")) {
+ isDateTimeParameter = true;
+ Long minStartTime = System.currentTimeMillis() - TimeUnit.HOURS.toMillis(AAIConstants.HISTORY_MAX_HOURS);
+ Long startTime = Long.parseLong(params.getFirst("date-time"));
+ if (startTime < minStartTime) {
+ throw new AAIException("AAI_3021", " Valid values for date-time are "+minStartTime+" to " + System.currentTimeMillis() );
+ }
+ }
+
+ if(!isHoursParameter && !isDateTimeParameter){
+ throw new AAIException("AAI_3021", "Send valid hours or date-time to specify the timebounds");
+ }
+
+ if(isHoursParameter && isDateTimeParameter){
+ throw new AAIException("AAI_3021", "Send either hours or date-time and not both to specify the timebounds");
+ }
+
+
+ }
+
+}
diff --git a/aai-traversal/src/main/java/org/onap/aai/rest/dsl/DslContext.java b/aai-traversal/src/main/java/org/onap/aai/rest/dsl/DslContext.java
new file mode 100644
index 0000000..3a3cc96
--- /dev/null
+++ b/aai-traversal/src/main/java/org/onap/aai/rest/dsl/DslContext.java
@@ -0,0 +1,130 @@
+/**
+ * ============LICENSE_START=======================================================
+ * org.onap.aai
+ * ================================================================================
+ * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY 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.rest.dsl;
+
+import java.util.Deque;
+import java.util.LinkedList;
+
+import org.antlr.v4.runtime.ParserRuleContext;
+
+public class DslContext {
+
+ private ParserRuleContext ctx;
+
+ private String currentNode;
+
+ private String previousNode;
+
+ private boolean isTraversal = false;
+ private boolean isWhereQuery = false;
+ private boolean isUnionQuery = false;
+ private boolean isUnionStart = false;
+
+ private String whereStartNode = "";
+
+ private Deque<String> unionStartNodes = new LinkedList<String>();
+
+ /*
+ * Limit Queries have to be applied in the end - so i have to set this in
+ * context
+ */
+ StringBuilder limitQuery = new StringBuilder();
+
+ public ParserRuleContext getCtx() {
+ return ctx;
+ }
+
+ public void setCtx(ParserRuleContext ctx) {
+ this.ctx = ctx;
+ }
+
+ public String getCurrentNode() {
+ return currentNode;
+ }
+
+ public void setCurrentNode(String currentNode) {
+ this.currentNode = currentNode;
+ }
+
+ public String getPreviousNode() {
+ return previousNode;
+ }
+
+ public void setPreviousNode(String previousNode) {
+ this.previousNode = previousNode;
+ }
+
+ public boolean isTraversal() {
+ return isTraversal;
+ }
+
+ public void setTraversal(boolean isTraversal) {
+ this.isTraversal = isTraversal;
+ }
+
+ public boolean isWhereQuery() {
+ return isWhereQuery;
+ }
+
+ public void setWhereQuery(boolean isWhereQuery) {
+ this.isWhereQuery = isWhereQuery;
+ }
+
+ public boolean isUnionQuery() {
+ return isUnionQuery;
+ }
+
+ public void setUnionQuery(boolean isUnionQuery) {
+ this.isUnionQuery = isUnionQuery;
+ }
+
+ public String getWhereStartNode() {
+ return whereStartNode;
+ }
+
+ public void setWhereStartNode(String whereStartNode) {
+ this.whereStartNode = whereStartNode;
+ }
+
+ public Deque<String> getUnionStartNodes() {
+ return unionStartNodes;
+ }
+
+ public void setUnionStartNodes(Deque<String> unionStartNodes) {
+ this.unionStartNodes = unionStartNodes;
+ }
+
+ public boolean isUnionStart() {
+ return isUnionStart;
+ }
+
+ public void setUnionStart(boolean isUnionStart) {
+ this.isUnionStart = isUnionStart;
+ }
+
+ public StringBuilder getLimitQuery() {
+ return limitQuery;
+ }
+
+ public void setLimitQuery(StringBuilder limitQuery) {
+ this.limitQuery = limitQuery;
+ }
+
+}
diff --git a/aai-traversal/src/main/java/org/onap/aai/rest/dsl/DslListener.java b/aai-traversal/src/main/java/org/onap/aai/rest/dsl/DslListener.java
index 1b8341d..ecd04ac 100644
--- a/aai-traversal/src/main/java/org/onap/aai/rest/dsl/DslListener.java
+++ b/aai-traversal/src/main/java/org/onap/aai/rest/dsl/DslListener.java
@@ -20,16 +20,21 @@
package org.onap.aai.rest.dsl;
import java.util.ArrayList;
+import java.util.Deque;
import java.util.HashMap;
+import java.util.LinkedList;
import java.util.Map;
import java.util.List;
import org.antlr.v4.runtime.tree.TerminalNode;
import org.onap.aai.AAIDslParser;
-import org.onap.aai.serialization.db.EdgeRules;
+import org.onap.aai.edges.EdgeRuleQuery;
+import org.onap.aai.edges.enums.EdgeType;
+import org.onap.aai.exceptions.AAIException;
+import org.springframework.beans.factory.annotation.Autowired;
import org.onap.aai.AAIDslBaseListener;
-
+import org.onap.aai.edges.EdgeIngestor;
import com.att.eelf.configuration.EELFLogger;
import com.att.eelf.configuration.EELFManager;
@@ -39,246 +44,150 @@ import com.att.eelf.configuration.EELFManager;
public class DslListener extends AAIDslBaseListener {
private static final EELFLogger LOGGER = EELFManager.getInstance().getLogger(DslQueryProcessor.class);
- private final EdgeRules edgeRules = EdgeRules.getInstance();
-
- protected List<String> list = null;
- //TODO Use StringBuilder to build the query than concat
- String query = "";
-
- Map<Integer, String> unionMap = new HashMap<>();
- Map<String, String> flags = new HashMap<>();
-
- String currentNode = "";
- String prevsNode = "";
- int commas = 0;
- int unionKey = 0;
- int unionMembers = 0;
- boolean isUnionBeg = false;
- boolean isUnionTraversal = false;
+ private final EdgeIngestor edgeRules;
- boolean isTraversal = false;
- boolean isWhereTraversal = false;
- String whereTraversalNode = "";
-
- String limitQuery = "";
- boolean isNot = false;
+ DslContext context = null;
+ DslQueryBuilder dslBuilder = null;
/**
* Instantiates a new DslListener.
*/
+ @Autowired
+ public DslListener(EdgeIngestor edgeIngestor) {
+ this.edgeRules = edgeIngestor;
+ context = new DslContext();
+ dslBuilder = new DslQueryBuilder(edgeIngestor);
+ }
- public DslListener() {
- list = new ArrayList<>();
+ public String getQuery() {
+ return dslBuilder.getQuery().toString();
}
@Override
public void enterAaiquery(AAIDslParser.AaiqueryContext ctx) {
- query += "builder";
+ dslBuilder.start();
}
@Override
- public void enterDslStatement(AAIDslParser.DslStatementContext ctx) {
- // LOGGER.info("Statement Enter"+ctx.getText());
- /*
- * This block of code is entered for every query statement
- */
- if (isUnionBeg) {
- isUnionBeg = false;
- isUnionTraversal = true;
-
- } else if (unionMembers > 0) {
- unionMembers--;
- query += ",builder.newInstance()";
- isUnionTraversal = true;
- }
-
+ public void exitAaiquery(AAIDslParser.AaiqueryContext ctx) {
+ dslBuilder.end(context);
}
@Override
- public void exitDslStatement(AAIDslParser.DslStatementContext ctx) {
- /*
- * Nothing to be done here for now
- * LOGGER.info("Statement Exit"+ctx.getText());
- */
+ public void enterDslStatement(AAIDslParser.DslStatementContext ctx) {
+ if (context.isUnionStart()) {
+ dslBuilder.startUnion();
+ }
}
@Override
- public void exitAaiquery(AAIDslParser.AaiqueryContext ctx) {
- /*
- * dedup is by default for all queries If the query has limit in it
- * include this as well LOGGER.info("Statement Exit"+ctx.getText());
- */
-
- query += ".cap('x').unfold().dedup()" + limitQuery;
+ public void exitDslStatement(AAIDslParser.DslStatementContext ctx) {
+ if (context.isUnionQuery()) {
+ dslBuilder.comma(context);
+ context.setUnionStart(true);
+ }
}
- /*
- * TODO: The contexts are not inherited from a single parent in AAIDslParser
- * Need to find a way to do that
- */
@Override
public void enterSingleNodeStep(AAIDslParser.SingleNodeStepContext ctx) {
-
- prevsNode = currentNode;
- currentNode = ctx.NODE().getText();
+ try {
+ /*
+ * Set the previous Node to current node and get the new current
+ * node
+ */
+ context.setPreviousNode(context.getCurrentNode());
+ context.setCurrentNode(ctx.NODE().getText());
- this.generateQuery();
- if (ctx.STORE() != null && ctx.STORE().getText().equals("*")) {
- flags.put(currentNode, "store");
- }
+ if (context.isUnionQuery() || context.isTraversal() || context.isWhereQuery()) {
+ String oldPreviousNode = context.getPreviousNode();
- }
+ if (context.isUnionStart()) {
+ String previousNode = context.getUnionStartNodes().peek();
+ context.setPreviousNode(previousNode);
- @Override
- public void enterSingleQueryStep(AAIDslParser.SingleQueryStepContext ctx) {
-
- prevsNode = currentNode;
- currentNode = ctx.NODE().getText();
- this.generateQuery();
-
- if (ctx.STORE() != null && ctx.STORE().getText().equals("*")) {
- flags.put(currentNode, "store");
- }
- }
+ context.setUnionStart(false);
+ }
- @Override
- public void enterMultiQueryStep(AAIDslParser.MultiQueryStepContext ctx) {
-
- prevsNode = currentNode;
- currentNode = ctx.NODE().getText();
- this.generateQuery();
-
- if (ctx.STORE() != null && ctx.STORE().getText().equals("*")) {
- flags.put(currentNode, "store");
- }
+ dslBuilder.edgeQuery(context);
- }
+ /*
+ * Reset is required bcos for union queries im changing the
+ * context
+ */
+ context.setPreviousNode(oldPreviousNode);
- /*
- * Generates the QueryBuilder syntax for the dsl query
- */
- private void generateQuery() {
- String edgeType = "";
-
- if (isUnionTraversal || isTraversal || isWhereTraversal) {
- String previousNode = prevsNode;
- if (isUnionTraversal) {
- previousNode = unionMap.get(unionKey);
- isUnionTraversal = false;
}
- if (edgeRules.hasTreeEdgeRule(previousNode, currentNode)) {
- edgeType = "EdgeType.TREE";
- }else if (edgeRules.hasCousinEdgeRule(previousNode, currentNode, "")) {
- edgeType = "EdgeType.COUSIN";
- } else
- edgeType = "EdgeType.COUSIN";
-
- query += ".createEdgeTraversal(" + edgeType + ", '" + previousNode + "','" + currentNode + "')";
+ else {
+ dslBuilder.nodeQuery(context);
+ }
+ } catch (AAIException e) {
+ LOGGER.info("AAIException in DslListener" + e.getMessage());
}
- else
- query += ".getVerticesByProperty('aai-node-type', '" + currentNode + "')";
}
@Override
public void exitSingleNodeStep(AAIDslParser.SingleNodeStepContext ctx) {
-
- generateExitStep();
- }
-
- @Override
- public void exitSingleQueryStep(AAIDslParser.SingleQueryStepContext ctx) {
- generateExitStep();
- }
-
- @Override
- public void exitMultiQueryStep(AAIDslParser.MultiQueryStepContext ctx) {
- generateExitStep();
-
+ context.setCtx(ctx);
+ dslBuilder.store(context);
}
private void generateExitStep() {
- if (flags.containsKey(currentNode)) {
- String storeFlag = flags.get(currentNode);
- if (storeFlag != null && storeFlag.equals("store"))
- query += ".store('x')";
- flags.remove(currentNode);
- }
+
}
@Override
public void enterUnionQueryStep(AAIDslParser.UnionQueryStepContext ctx) {
- isUnionBeg = true;
- unionKey++;
- unionMap.put(unionKey, currentNode);
- query += ".union(builder.newInstance()";
+ Deque<String> unionStartNodes = context.getUnionStartNodes();
+ unionStartNodes.add(context.getCurrentNode());
- List<TerminalNode> commaNodes = ctx.COMMA();
+ context.setUnionStart(true);
+ /*
+ * I may not need this
+ */
+ context.setUnionQuery(true);
+ dslBuilder.union(context);
- for (TerminalNode node : commaNodes) {
- unionMembers++;
- }
}
@Override
public void exitUnionQueryStep(AAIDslParser.UnionQueryStepContext ctx) {
- isUnionBeg = false;
- unionMap.remove(unionKey);
+ context.setUnionStart(false);
+ context.setUnionQuery(false);
+ Deque<String> unionStartNodes = context.getUnionStartNodes();
+ if (unionStartNodes.peek() != null) {
+ unionStartNodes.pop();
+ }
- query += ")";
- unionKey--;
+ dslBuilder.endUnion(context);
}
@Override
public void enterFilterTraverseStep(AAIDslParser.FilterTraverseStepContext ctx) {
- isWhereTraversal = true;
- whereTraversalNode = currentNode;
- query += ".where(builder.newInstance()";
+ context.setWhereQuery(true);
+ context.setWhereStartNode(context.getCurrentNode());
+ dslBuilder.where(context);
+
}
@Override
public void exitFilterTraverseStep(AAIDslParser.FilterTraverseStepContext ctx) {
- query += ")";
- isWhereTraversal = false;
- currentNode = whereTraversalNode;
+ context.setWhereQuery(false);
+ context.setCurrentNode(context.getWhereStartNode());
+
+ dslBuilder.endWhere(context);
+
}
@Override
public void enterFilterStep(AAIDslParser.FilterStepContext ctx) {
- if (ctx.NOT() != null && ctx.NOT().getText().equals("!"))
- isNot = true;
-
- List<TerminalNode> nodes = ctx.KEY();
- String key = ctx.KEY(0).getText();
-
- if (isNot) {
- query += ".getVerticesExcludeByProperty(";
- isNot = false;
- } else
- query += ".getVerticesByProperty(";
-
- if (nodes.size() == 2) {
- query += key + "," + ctx.KEY(1).getText();
- query += ")";
- }
-
- if (nodes.size() > 2) {
-
- for (TerminalNode node : nodes) {
- if (node.getText().equals(key))
- continue;
-
- query += key + "," + node.getText();
- query += ")";
- }
-
- }
-
+ context.setCtx(ctx);
+ dslBuilder.filter(context);
}
@Override
@@ -288,17 +197,17 @@ public class DslListener extends AAIDslBaseListener {
@Override
public void enterTraverseStep(AAIDslParser.TraverseStepContext ctx) {
- isTraversal = true;
+ context.setTraversal(true);
}
@Override
public void exitTraverseStep(AAIDslParser.TraverseStepContext ctx) {
- isTraversal = false;
+ context.setTraversal(false);
}
@Override
public void enterLimitStep(AAIDslParser.LimitStepContext ctx) {
- String value = ctx.NODE().getText();
- limitQuery += ".limit(" + value + ")";
+ context.setCtx(ctx);
+ dslBuilder.limit(context);
}
}
diff --git a/aai-traversal/src/main/java/org/onap/aai/rest/dsl/DslQueryBuilder.java b/aai-traversal/src/main/java/org/onap/aai/rest/dsl/DslQueryBuilder.java
new file mode 100644
index 0000000..59f4443
--- /dev/null
+++ b/aai-traversal/src/main/java/org/onap/aai/rest/dsl/DslQueryBuilder.java
@@ -0,0 +1,190 @@
+/**
+ * ============LICENSE_START=======================================================
+ * org.onap.aai
+ * ================================================================================
+ * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY 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.rest.dsl;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.stream.Collectors;
+
+import org.antlr.v4.runtime.tree.TerminalNode;
+import org.apache.tinkerpop.gremlin.structure.Direction;
+import org.apache.tinkerpop.gremlin.structure.Edge;
+import org.onap.aai.AAIDslBaseListener;
+import org.onap.aai.AAIDslParser;
+import org.onap.aai.edges.EdgeIngestor;
+import org.onap.aai.edges.EdgeRuleQuery;
+import org.onap.aai.edges.enums.EdgeType;
+import org.onap.aai.exceptions.AAIException;
+
+public class DslQueryBuilder {
+
+ private StringBuilder query;
+ private final EdgeIngestor edgeRules;
+
+ public DslQueryBuilder(EdgeIngestor edgeIngestor) {
+ this.edgeRules = edgeIngestor;
+ query = new StringBuilder();
+ }
+
+ public StringBuilder getQuery() {
+ return query;
+ }
+
+ public void setQuery(StringBuilder query) {
+ this.query = query;
+ }
+
+ public DslQueryBuilder start() {
+ query.append("builder");
+ return this;
+ }
+
+ public DslQueryBuilder startUnion() {
+ query.append("builder.newInstance()");
+ return this;
+ }
+
+ public DslQueryBuilder end(DslContext context) {
+ query.append(".cap('x').unfold().dedup()").append(context.getLimitQuery());
+ return this;
+ }
+
+ public DslQueryBuilder nodeQuery(DslContext context) {
+ query.append(".getVerticesByProperty('aai-node-type', '").append(context.getCurrentNode()).append("')");
+ return this;
+ }
+
+ public DslQueryBuilder edgeQuery(DslContext context) throws AAIException {
+ EdgeRuleQuery.Builder baseQ = new EdgeRuleQuery.Builder(context.getPreviousNode(), context.getCurrentNode());
+ String edgeType = "";
+ if (!edgeRules.hasRule(baseQ.build())) {
+ throw new AAIException("AAI_6120", "No EdgeRule found for passed nodeTypes: " + context.getPreviousNode()
+ + ", " + context.getCurrentNode());
+ } else if (edgeRules.hasRule(baseQ.edgeType(EdgeType.TREE).build())) {
+ edgeType = "EdgeType.TREE";
+ } else if (edgeRules.hasRule(baseQ.edgeType(EdgeType.COUSIN).build())) {
+ edgeType = "EdgeType.COUSIN";
+ } else
+ edgeType = "EdgeType.COUSIN";
+
+ query.append(".createEdgeTraversal(").append(edgeType).append(", '").append(context.getPreviousNode())
+ .append("','").append(context.getCurrentNode()).append("')");
+
+ return this;
+ }
+
+ public DslQueryBuilder where(DslContext context) {
+ query.append(".where(builder.newInstance()");
+ return this;
+ }
+
+ public DslQueryBuilder endWhere(DslContext context) {
+ query.append(")");
+ return this;
+ }
+
+ public DslQueryBuilder endUnion(DslContext context) {
+ /*
+ * Need to delete the last comma
+ */
+ if (query.toString().endsWith(",")) {
+ query.deleteCharAt(query.length() - 1);
+ }
+ query.append(")");
+ return this;
+ }
+
+ public DslQueryBuilder limit(DslContext context) {
+ /*
+ * limit queries are strange - You have to append in the end
+ */
+ AAIDslParser.LimitStepContext ctx = (AAIDslParser.LimitStepContext) context.getCtx();
+ context.setLimitQuery(new StringBuilder(".limit(").append(ctx.NODE().getText()).append(")"));
+ return this;
+ }
+
+ public DslQueryBuilder filter(DslContext context) {
+ return this.filterPropertyStart(context).filterPropertyKeys(context).filterPropertyEnd();
+
+ }
+
+ public DslQueryBuilder filterPropertyStart(DslContext context) {
+ AAIDslParser.FilterStepContext ctx = (AAIDslParser.FilterStepContext) context.getCtx();
+ if (ctx.NOT() != null && ctx.NOT().getText().equals("!"))
+ query.append(".getVerticesExcludeByProperty(");
+ else
+ query.append(".getVerticesByProperty(");
+
+ return this;
+
+ }
+
+ public DslQueryBuilder filterPropertyEnd() {
+ query.append(")");
+ return this;
+
+ }
+
+ public DslQueryBuilder filterPropertyKeys(DslContext context) {
+ AAIDslParser.FilterStepContext ctx = (AAIDslParser.FilterStepContext) context.getCtx();
+ final String key = ctx.KEY(0).getText();
+
+ query.append(key);
+
+ List<TerminalNode> nodes = ctx.KEY();
+ List<String> valuesArray = nodes.stream().filter((node) -> !key.equals(node.getText()))
+ .map((node) -> "'" + node.getText().replace("'", "").trim() + "'")
+ .collect(Collectors.toList());
+
+ /*
+ * The whole point of doing this to separate P.within from key-value search
+ * For a list of values QB uses P.within
+ * For just a single value QB uses key,value check
+ */
+ if (nodes.size() > 2) {
+ String values = String.join(",", valuesArray);
+ query.append(",").append(" new ArrayList<>(Arrays.asList(" + values.toString() + "))");
+ } else {
+ if (!valuesArray.isEmpty())
+ query.append(",").append(valuesArray.get(0).toString());
+ }
+ return this;
+ }
+
+ public DslQueryBuilder union(DslContext context) {
+ query.append(".union(");
+ return this;
+ }
+
+ public DslQueryBuilder store(DslContext context) {
+ AAIDslParser.SingleNodeStepContext ctx = (AAIDslParser.SingleNodeStepContext) context.getCtx();
+ if (ctx.STORE() != null && ctx.STORE().getText().equals("*")) {
+ query.append(".store('x')");
+ }
+ return this;
+
+ }
+
+ public DslQueryBuilder comma(DslContext context) {
+ query.append(",");
+ return this;
+
+ }
+}
diff --git a/aai-traversal/src/main/java/org/onap/aai/rest/dsl/DslQueryProcessor.java b/aai-traversal/src/main/java/org/onap/aai/rest/dsl/DslQueryProcessor.java
index 61f16d4..b2be402 100644
--- a/aai-traversal/src/main/java/org/onap/aai/rest/dsl/DslQueryProcessor.java
+++ b/aai-traversal/src/main/java/org/onap/aai/rest/dsl/DslQueryProcessor.java
@@ -36,6 +36,8 @@ import org.antlr.v4.runtime.Token;
import com.att.eelf.configuration.EELFLogger;
import com.att.eelf.configuration.EELFManager;
+import org.springframework.beans.factory.annotation.Autowired;
+
/**
* The Class DslQueryProcessor.
*/
@@ -43,6 +45,13 @@ public class DslQueryProcessor {
private static final EELFLogger LOGGER = EELFManager.getInstance().getLogger(DslQueryProcessor.class);
+ private DslListener dslListener;
+
+ @Autowired
+ public DslQueryProcessor(DslListener dslListener){
+ this.dslListener = dslListener;
+ }
+
public String parseAaiQuery(String aaiQuery) {
try {
// Create a input stream that reads our string
@@ -64,34 +73,18 @@ public class DslQueryProcessor {
// Walk it and attach our listener
ParseTreeWalker walker = new ParseTreeWalker();
- DslListener listener = new DslListener();
- walker.walk(listener, ptree);
- LOGGER.info("Final QUERY" + listener.query);
+ walker.walk(dslListener, ptree);
+ LOGGER.info("Final QUERY" + dslListener.getQuery());
/*
* TODO - Visitor patternQueryDslVisitor visitor = new
* QueryDslVisitor(); String query = visitor.visit(ptree);
*
*/
- return listener.query;
+ return dslListener.getQuery();
} catch (Exception e) {
LOGGER.error("Error while processing the query"+e.getMessage());
}
return "";
}
-
- public static class Builder {
-
- /*
- * Builder constructor doesnt do anything
- */
- public Builder() {
- // Do nothing
- }
-
- public String build(String aaiQuery) {
-
- return new DslQueryProcessor().parseAaiQuery(aaiQuery);
- }
- }
}
diff --git a/aai-traversal/src/main/java/org/onap/aai/rest/retired/RetiredConsumer.java b/aai-traversal/src/main/java/org/onap/aai/rest/retired/RetiredConsumer.java
deleted file mode 100644
index aea9083..0000000
--- a/aai-traversal/src/main/java/org/onap/aai/rest/retired/RetiredConsumer.java
+++ /dev/null
@@ -1,140 +0,0 @@
-/**
- * ============LICENSE_START=======================================================
- * org.onap.aai
- * ================================================================================
- * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY 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.rest.retired;
-
-import java.util.ArrayList;
-
-import javax.servlet.http.HttpServletRequest;
-import javax.ws.rs.DELETE;
-import javax.ws.rs.GET;
-import javax.ws.rs.POST;
-import javax.ws.rs.PUT;
-import javax.ws.rs.Path;
-import javax.ws.rs.PathParam;
-import javax.ws.rs.core.Context;
-import javax.ws.rs.core.HttpHeaders;
-import javax.ws.rs.core.Response;
-import javax.ws.rs.core.UriInfo;
-
-import io.swagger.jaxrs.PATCH;
-
-import org.onap.aai.exceptions.AAIException;
-import org.onap.aai.logging.ErrorLogHelper;
-import org.onap.aai.restcore.RESTAPI;
-import org.onap.aai.util.AAIConfig;
-
-/**
- * The Class RetiredConsumer.
- */
-public abstract class RetiredConsumer extends RESTAPI {
-
- /**
- * Creates the message get.
- *
- * @param versionParam the version param
- * @param headers the headers
- * @param info the info
- * @param req the req
- * @return the response
- */
- @GET
- @Path("/{uri:.*}")
- public Response createMessageGet(@PathParam("version")String versionParam, @Context HttpHeaders headers, @Context UriInfo info, @Context HttpServletRequest req) {
- return createMessage(versionParam, headers, info, req);
- }
-
- /**
- * Creates the message delete.
- *
- * @param versionParam the version param
- * @param headers the headers
- * @param info the info
- * @param req the req
- * @return the response
- */
- @DELETE
- @Path("/{uri:.*}")
- public Response createMessageDelete(@PathParam("version")String versionParam, @Context HttpHeaders headers, @Context UriInfo info, @Context HttpServletRequest req) {
- return createMessage(versionParam, headers, info, req);
- }
-
- /**
- * Creates the message post.
- *
- * @param versionParam the version param
- * @param headers the headers
- * @param info the info
- * @param req the req
- * @return the response
- */
- @POST
- @Path("/{uri:.*}")
- public Response createMessagePost(@PathParam("version")String versionParam, @Context HttpHeaders headers, @Context UriInfo info, @Context HttpServletRequest req) {
- return createMessage(versionParam, headers, info, req);
- }
-
- @PATCH
- @Path("/{uri:.*}")
- public Response createMessagePatch(@PathParam("version")String versionParam, @Context HttpHeaders headers, @Context UriInfo info, @Context HttpServletRequest req) {
- return createMessage(versionParam, headers, info, req);
- }
- /**
- * Creates the message put.
- *
- * @param versionParam the version param
- * @param headers the headers
- * @param info the info
- * @param req the req
- * @return the response
- */
- @PUT
- @Path("/{uri:.*}")
- public Response createMessagePut(@PathParam("version")String versionParam, @Context HttpHeaders headers, @Context UriInfo info, @Context HttpServletRequest req) {
- return createMessage(versionParam, headers, info, req);
- }
-
-
- /**
- * Creates the message.
- *
- * @param versionParam the version param
- * @param headers the headers
- * @param info the info
- * @param req the req
- * @return the response
- */
- private Response createMessage(String versionParam, HttpHeaders headers, UriInfo info, HttpServletRequest req) {
- AAIException e = new AAIException("AAI_3007");
-
- ArrayList<String> templateVars = new ArrayList<String>();
-
- if (templateVars.size() == 0) {
- templateVars.add("PUT");
- templateVars.add(info.getPath().toString());
- templateVars.add(versionParam);
- templateVars.add(AAIConfig.get("aai.default.api.version", ""));
- }
-
- return Response
- .status(e.getErrorObject().getHTTPResponseCode())
- .entity(ErrorLogHelper.getRESTAPIErrorResponse(headers.getAcceptableMediaTypes(), e,
- templateVars)).build();
- }
-}
diff --git a/aai-traversal/src/main/java/org/onap/aai/rest/retired/V3ThroughV7Consumer.java b/aai-traversal/src/main/java/org/onap/aai/rest/retired/V3ThroughV7Consumer.java
deleted file mode 100644
index 2339764..0000000
--- a/aai-traversal/src/main/java/org/onap/aai/rest/retired/V3ThroughV7Consumer.java
+++ /dev/null
@@ -1,27 +0,0 @@
-/**
- * ============LICENSE_START=======================================================
- * org.onap.aai
- * ================================================================================
- * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY 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.rest.retired;
-
-import javax.ws.rs.Path;
-
-@Path("{version: v[3-7]}")
-public class V3ThroughV7Consumer extends RetiredConsumer {
-
-}
diff --git a/aai-traversal/src/main/java/org/onap/aai/rest/retired/V7V8NamedQueries.java b/aai-traversal/src/main/java/org/onap/aai/rest/retired/V7V8NamedQueries.java
deleted file mode 100644
index 9a9c183..0000000
--- a/aai-traversal/src/main/java/org/onap/aai/rest/retired/V7V8NamedQueries.java
+++ /dev/null
@@ -1,27 +0,0 @@
-/**
- * ============LICENSE_START=======================================================
- * org.onap.aai
- * ================================================================================
- * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY 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.rest.retired;
-
-import javax.ws.rs.Path;
-
-@Path("{version: v[78]}/service-design-and-creation/named-queries")
-public class V7V8NamedQueries extends RetiredConsumer {
-
-}
diff --git a/aai-traversal/src/main/java/org/onap/aai/rest/search/CustomQueryConfig.java b/aai-traversal/src/main/java/org/onap/aai/rest/search/CustomQueryConfig.java
index 44420d5..2fa7ec1 100644
--- a/aai-traversal/src/main/java/org/onap/aai/rest/search/CustomQueryConfig.java
+++ b/aai-traversal/src/main/java/org/onap/aai/rest/search/CustomQueryConfig.java
@@ -8,7 +8,7 @@
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
- * http://www.apache.org/licenses/LICENSE-2.0
+ * http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
@@ -22,36 +22,32 @@ package org.onap.aai.rest.search;
import java.util.List;
public class CustomQueryConfig {
-
- private String query;
- private List<String> queryOptionalProperties;
- private List<String> queryRequiredProperties;
-
- public CustomQueryConfig() {
- // used by GetCustomQueryConfig
- }
-
- public void setQuery(String query) {
- this.query = query;
- }
-
- public String getQuery() {
- return this.query;
- }
-
- public void setQueryOptionalProperties(List<String> queryOptionalProperties) {
- this.queryOptionalProperties = queryOptionalProperties;
- }
-
- public List<String> getQueryOptionalProperties() {
- return queryOptionalProperties;
- }
-
- public void setQueryRequiredProperties(List<String> queryRequiredProperties) {
- this.queryRequiredProperties = queryRequiredProperties;
- }
-
- public List<String> getQueryRequiredProperties() {
- return queryRequiredProperties;
- }
+ public CustomQueryConfig() {
+ // used by GetCustomQueryConfig
+ }
+
+
+ private String query;
+ private List<String> queryOptionalProperties;
+ private List<String> queryRequiredProperties;
+
+ public void setQuery(String query) {
+ this.query = query;
+ }
+ public String getQuery() {
+ return this.query;
+ }
+
+ public void setQueryOptionalProperties( List<String> queryOptionalProperties) {
+ this.queryOptionalProperties = queryOptionalProperties;
+ }
+ public List<String> getQueryOptionalProperties( ) {
+ return queryOptionalProperties;
+ }
+ public void setQueryRequiredProperties( List<String> queryRequiredProperties) {
+ this.queryRequiredProperties = queryRequiredProperties;
+ }
+ public List<String> getQueryRequiredProperties( ) {
+ return queryRequiredProperties;
+ }
}
diff --git a/aai-traversal/src/main/java/org/onap/aai/rest/search/GenericQueryProcessor.java b/aai-traversal/src/main/java/org/onap/aai/rest/search/GenericQueryProcessor.java
index 6831fb8..fd9d53b 100644
--- a/aai-traversal/src/main/java/org/onap/aai/rest/search/GenericQueryProcessor.java
+++ b/aai-traversal/src/main/java/org/onap/aai/rest/search/GenericQueryProcessor.java
@@ -19,46 +19,51 @@
*/
package org.onap.aai.rest.search;
-import java.io.FileNotFoundException;
-import java.net.URI;
-import java.util.*;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
-
-import javax.ws.rs.core.MultivaluedHashMap;
-import javax.ws.rs.core.MultivaluedMap;
-
+import com.att.eelf.configuration.EELFLogger;
+import com.att.eelf.configuration.EELFManager;
import org.apache.tinkerpop.gremlin.process.traversal.P;
import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversal;
import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.__;
import org.apache.tinkerpop.gremlin.structure.Graph;
import org.apache.tinkerpop.gremlin.structure.Vertex;
import org.javatuples.Pair;
+import org.onap.aai.config.SpringContextAware;
+import org.onap.aai.exceptions.AAIException;
import org.onap.aai.query.builder.MissingOptionalParameter;
import org.onap.aai.rest.dsl.DslQueryProcessor;
+import org.onap.aai.restcore.search.GroovyQueryBuilderSingleton;
import org.onap.aai.restcore.util.URITools;
import org.onap.aai.serialization.engines.TransactionalGraphEngine;
import org.onap.aai.serialization.queryformats.SubGraphStyle;
-import jersey.repackaged.com.google.common.base.Joiner;
+import javax.ws.rs.core.MultivaluedHashMap;
+import javax.ws.rs.core.MultivaluedMap;
+import java.io.FileNotFoundException;
+import java.net.URI;
+import java.util.*;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
public abstract class GenericQueryProcessor {
+ private static EELFLogger LOGGER = EELFManager.getInstance().getLogger(GenericQueryProcessor.class);
+
protected final Optional<URI> uri;
protected final MultivaluedMap<String, String> queryParams;
protected final Optional<Collection<Vertex>> vertices;
protected static Pattern p = Pattern.compile("query/(.*+)");
protected Optional<String> gremlin;
protected final TransactionalGraphEngine dbEngine;
- protected static GremlinServerSingleton gremlinServerSingleton = GremlinServerSingleton.getInstance();
+ protected GremlinServerSingleton gremlinServerSingleton;
protected static GroovyQueryBuilderSingleton queryBuilderSingleton = GroovyQueryBuilderSingleton.getInstance();
protected final boolean isGremlin;
- /* dsl parameters to store dsl query and to check
+ protected Optional<DslQueryProcessor> dslQueryProcessorOptional;
+ /* dsl parameters to store dsl query and to check
* if this is a DSL request
*/
protected Optional<String> dsl;
protected final boolean isDsl ;
-
+
protected GenericQueryProcessor(Builder builder) {
this.uri = builder.getUri();
this.dbEngine = builder.getDbEngine();
@@ -67,6 +72,8 @@ public abstract class GenericQueryProcessor {
this.isGremlin = builder.isGremlin();
this.dsl = builder.getDsl();
this.isDsl = builder.isDsl();
+ this.gremlinServerSingleton = builder.getGremlinServerSingleton();
+ this.dslQueryProcessorOptional = builder.getDslQueryProcessor();
if (uri.isPresent()) {
queryParams = URITools.getQueryMap(uri.get());
@@ -79,12 +86,12 @@ public abstract class GenericQueryProcessor {
protected List<Object> processSubGraph(SubGraphStyle style, GraphTraversal<?,?> g) {
final List<Object> resultVertices = new Vector<>();
- g.store("x");
+ g.store("y");
if (SubGraphStyle.prune.equals(style) || SubGraphStyle.star.equals(style)) {
g.barrier().bothE();
if (SubGraphStyle.prune.equals(style)) {
- g.where(__.otherV().where(P.within("x")));
+ g.where(__.otherV().where(P.within("y")));
}
g.dedup().subgraph("subGraph").cap("subGraph").map(x -> (Graph)x.get()).next().traversal().V().forEachRemaining(x -> {
resultVertices.add(x);
@@ -95,7 +102,7 @@ public abstract class GenericQueryProcessor {
return resultVertices;
}
- public List<Object> execute(SubGraphStyle style) {
+ public List<Object> execute(SubGraphStyle style) throws FileNotFoundException, AAIException {
final List<Object> resultVertices;
Pair<String, Map<String, Object>> tuple = this.createQuery();
@@ -113,7 +120,7 @@ public abstract class GenericQueryProcessor {
return resultVertices;
}
- protected Pair<String, Map<String, Object>> createQuery() {
+ protected Pair<String, Map<String, Object>> createQuery() throws AAIException {
Map<String, Object> params = new HashMap<>();
String query = "";
if (this.isGremlin) {
@@ -121,12 +128,13 @@ public abstract class GenericQueryProcessor {
}else if (this.isDsl) {
String dslUserQuery = dsl.get();
- String dslQuery = new DslQueryProcessor.Builder().build(dslUserQuery);
-
- query = queryBuilderSingleton.executeTraversal(dbEngine, dslQuery, params);
- String startPrefix = "g.V()";
- query = startPrefix + query;
-
+ if(dslQueryProcessorOptional.isPresent()){
+ String dslQuery = dslQueryProcessorOptional.get().parseAaiQuery(dslUserQuery);
+ query = queryBuilderSingleton.executeTraversal(dbEngine, dslQuery, params);
+ String startPrefix = "g.V()";
+ query = startPrefix + query;
+ }
+ LOGGER.debug("Converted to gremlin query\n {}", query);
}else {
Matcher m = p.matcher(uri.get().getPath());
String queryName = "";
@@ -163,7 +171,10 @@ public abstract class GenericQueryProcessor {
// We are binding the array dynamically to the groovy processor correctly
// This will fix the memory issue of the method size too big
// as statically creating a list string and passing is not appropriate
- params.put("startVertexes", vertices.get().toArray());
+
+ Object [] startVertices = vertices.get().toArray();
+
+ params.put("startVertexes", startVertices);
if (query == null) {
query = "";
@@ -178,6 +189,23 @@ public abstract class GenericQueryProcessor {
} else {
query = startPrefix;
}
+
+ // Getting all the vertices and logging them is not reasonable
+ // As it could have performance impacts so doing a check here
+ // to see if the logger is trace so only print the start vertexes
+ // otherwise we would like to see what the gremlin query that was converted
+ // So to check if the output matches the desired behavior
+ // This way if to enable deeper logging, just changing logback would work
+ if(LOGGER.isTraceEnabled()){
+ String readQuery = query.replaceAll("startVertexes",
+ Arrays.toString(startVertices).replaceAll("[^0-9,]", ""));
+ LOGGER.trace("Converted to gremlin query including the start vertices \n {}", readQuery);
+ }
+ else if(LOGGER.isDebugEnabled()){
+ LOGGER.debug("Converted to gremlin query without the start vertices \n {}", query);
+ }
+ } else {
+ throw new AAIException("AAI_6148");
}
}
@@ -196,9 +224,15 @@ public abstract class GenericQueryProcessor {
private Optional<String> dsl = Optional.empty();
private boolean isDsl = false;
+ private DslQueryProcessor dslQueryProcessor;
+ private GremlinServerSingleton gremlinServerSingleton;
+ private Optional<String> nodeType = Optional.empty();
+ private boolean isNodeTypeQuery = false;
+ protected MultivaluedMap<String, String> uriParams;
- public Builder(TransactionalGraphEngine dbEngine) {
+ public Builder(TransactionalGraphEngine dbEngine, GremlinServerSingleton gremlinServerSingleton) {
this.dbEngine = dbEngine;
+ this.gremlinServerSingleton = gremlinServerSingleton;
}
public Builder queryFrom(URI uri) {
@@ -222,6 +256,15 @@ public abstract class GenericQueryProcessor {
this.dsl = Optional.of(query);
this.isDsl = true;
}
+ if(queryType.equals("nodeQuery")){
+ this.nodeType = Optional.of(query);
+ this.isNodeTypeQuery = true;
+ }
+ return this;
+ }
+
+ public Builder uriParams(MultivaluedMap<String, String> uriParams) {
+ this.uriParams = uriParams;
return this;
}
@@ -229,6 +272,15 @@ public abstract class GenericQueryProcessor {
this.processorType = type;
return this;
}
+
+ public Builder queryProcessor(DslQueryProcessor dslQueryProcessor){
+ this.dslQueryProcessor = dslQueryProcessor;
+ return this;
+ }
+
+ public Optional<DslQueryProcessor> getDslQueryProcessor(){
+ return Optional.ofNullable(this.dslQueryProcessor);
+ }
public TransactionalGraphEngine getDbEngine() {
return dbEngine;
}
@@ -260,16 +312,24 @@ public abstract class GenericQueryProcessor {
public QueryProcessorType getProcessorType() {
return processorType;
}
+
+ public GremlinServerSingleton getGremlinServerSingleton(){
+ return gremlinServerSingleton;
+ }
+
+ public Optional<String> getNodeType() {
+ return nodeType;
+ }
+
+ public boolean isNodeTypeQuery() {
+ return isNodeTypeQuery;
+ }
public GenericQueryProcessor create() {
-
- if (this.getProcessorType().equals(QueryProcessorType.GREMLIN_SERVER)) {
- return new GremlinServerImpl(this);
- } else if (this.getProcessorType().equals(QueryProcessorType.LOCAL_GROOVY)) {
- return new GroovyShellImpl(this);
- } else {
- return new GremlinServerImpl(this);
+ if (isNodeTypeQuery()) {
+ return new NodeQueryProcessor(this);
}
+ return new GroovyShellImpl(this);
}
}
diff --git a/aai-traversal/src/main/java/org/onap/aai/rest/search/GetCustomQueryConfig.java b/aai-traversal/src/main/java/org/onap/aai/rest/search/GetCustomQueryConfig.java
index 2017f10..7227815 100644
--- a/aai-traversal/src/main/java/org/onap/aai/rest/search/GetCustomQueryConfig.java
+++ b/aai-traversal/src/main/java/org/onap/aai/rest/search/GetCustomQueryConfig.java
@@ -8,7 +8,7 @@
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
- * http://www.apache.org/licenses/LICENSE-2.0
+ * http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
@@ -57,122 +57,122 @@ import com.google.gson.reflect.TypeToken;
public class GetCustomQueryConfig {
- private JsonArray storedQueries = null;
- private CustomQueryConfig customQueryConfig;
+ private JsonArray storedQueries = null;
+ private CustomQueryConfig customQueryConfig;
+
+
+ private final static String QUERY_CONFIG = "query";
+ private final static String REQUIRED_CONFIG = "required-properties";
+ private final static String OPTIONAL_CONFIG = "optional-properties";
+ private final static String STORED_QUERIES_CONFIG = "stored-queries";
+ private final static String STORED_QUERY_CONFIG = "stored-query";
+
+// public static final String AAI_HOME_ETC_QUERY_JSON = AAIConstants.AAI_HOME_ETC + "query" + AAIConstants.AAI_FILESEP + "stored-queries.json";
+
+ public GetCustomQueryConfig(String customQueryJson ) {
+ init(customQueryJson);
+ }
+
+ private void init( String customQueryJson) {
+ JsonParser parser = new JsonParser();
+ JsonObject queriesObject = parser.parse(customQueryJson).getAsJsonObject();
+ if (queriesObject.has(STORED_QUERIES_CONFIG)) {
+
+ storedQueries = queriesObject.getAsJsonArray(STORED_QUERIES_CONFIG);
+ }
+ }
+
+ private List<String> toStringList(JsonArray array) {
+ Gson converter = new Gson();
+ Type listType = new TypeToken<List<String>>() {}.getType();
+ return converter.fromJson(array, listType);
+ }
+
+ private List<String> getPropertyList(JsonObject configObject, String config ) {
+ JsonElement subqueryConfig;
+ JsonArray props;
+
+ if ( configObject.has(config)) {
+ subqueryConfig = configObject.get(config);
+ if ( subqueryConfig != null && !subqueryConfig.isJsonNull() ) {
+ props = subqueryConfig.getAsJsonArray();
+ if ( props != null ) {
+ return toStringList(props);
+ }
+ }
+ }
+ return toStringList(null);
+ }
+
+ private String getPropertyString(JsonObject configObject, String config) {
+ JsonElement subqueryConfig;
+
+ if ( configObject.has(config)) {
+ subqueryConfig = configObject.get(config);
+ if ( subqueryConfig != null && !subqueryConfig.isJsonNull() ) {
+ return subqueryConfig.getAsString();
+ }
+ }
+ return null;
+ }
+
+ private void getStoredQueryBlock( JsonObject configObject, String config ) {
+ if ( !configObject.has(config)) {
+ customQueryConfig.setQueryRequiredProperties( new ArrayList<String>() );
+ customQueryConfig.setQueryOptionalProperties( new ArrayList<String>() );
+ return;
+ }
+
+ JsonElement queryConfig;
+ JsonObject subObject;
+ String multipleStartNodes;
+ List<String> propertyList;
+
+ queryConfig = configObject.get(config);
+ subObject = queryConfig.getAsJsonObject();
+ propertyList = getPropertyList(subObject, REQUIRED_CONFIG);
+ if ( propertyList == null ) {
+ propertyList = new ArrayList<String>();
+ }
+ customQueryConfig.setQueryRequiredProperties( propertyList );
+ propertyList = getPropertyList(subObject, OPTIONAL_CONFIG);
+ if ( propertyList == null ) {
+ propertyList = new ArrayList<String>();
+ }
+ customQueryConfig.setQueryOptionalProperties( propertyList );
+
+ }
+
+
+ public CustomQueryConfig getStoredQuery(String queryName ) {
+
+ customQueryConfig = null;
+ JsonObject configObject;
+ JsonElement query;
+ JsonElement queryConfig;
+ String queryString;
+
+ for (JsonElement storedQuery : storedQueries) {
+ if (storedQuery.isJsonObject()) {
+ JsonObject queryObject = storedQuery.getAsJsonObject();
+ query = queryObject.get(queryName);
+ if ( query != null ) {
+ customQueryConfig = new CustomQueryConfig();
+ configObject = query.getAsJsonObject();
+ getStoredQueryBlock(configObject, QUERY_CONFIG);
+ if ( configObject.has(STORED_QUERY_CONFIG)) {
+ queryConfig = configObject.get(STORED_QUERY_CONFIG);
+ customQueryConfig.setQuery(queryConfig.getAsString());
+ }
+ break;
+ }
+ }
+ }
+
+ return customQueryConfig;
+
+ }
- private static final String QUERY_CONFIG = "query";
- private static final String REQUIRED_CONFIG = "required-properties";
- private static final String OPTIONAL_CONFIG = "optional-properties";
- private static final String STORED_QUERIES_CONFIG = "stored-queries";
- private static final String STORED_QUERY_CONFIG = "stored-query";
-
- public static final String AAI_HOME_ETC_QUERY_JSON =
- AAIConstants.AAI_HOME_ETC + "query" + AAIConstants.AAI_FILESEP + "stored-queries.json";
-
- public GetCustomQueryConfig(String customQueryJson) {
- init(customQueryJson);
- }
-
- private void init(String customQueryJson) {
- JsonParser parser = new JsonParser();
- JsonObject queriesObject = parser.parse(customQueryJson).getAsJsonObject();
- if (queriesObject.has(STORED_QUERIES_CONFIG)) {
-
- storedQueries = queriesObject.getAsJsonArray(STORED_QUERIES_CONFIG);
- }
- }
-
- private List<String> toStringList(JsonArray array) {
- Gson converter = new Gson();
- Type listType = new TypeToken<List<String>>() {
- }.getType();
- return converter.fromJson(array, listType);
- }
-
- private List<String> getPropertyList(JsonObject configObject, String config) {
- JsonElement subqueryConfig;
- JsonArray props;
-
- if (configObject.has(config)) {
- subqueryConfig = configObject.get(config);
- if (subqueryConfig != null && !subqueryConfig.isJsonNull()) {
- props = subqueryConfig.getAsJsonArray();
- if (props != null) {
- return toStringList(props);
- }
- }
- }
- return toStringList(null);
- }
-
- private String getPropertyString(JsonObject configObject, String config) {
- JsonElement subqueryConfig;
-
- if (configObject.has(config)) {
- subqueryConfig = configObject.get(config);
- if (subqueryConfig != null && !subqueryConfig.isJsonNull()) {
- return subqueryConfig.getAsString();
- }
- }
- return null;
- }
-
- private void getStoredQueryBlock(JsonObject configObject, String config) {
- if (!configObject.has(config)) {
- customQueryConfig.setQueryRequiredProperties(new ArrayList<String>());
- customQueryConfig.setQueryOptionalProperties(new ArrayList<String>());
- return;
- }
-
- JsonElement queryConfig;
- JsonObject subObject;
- String multipleStartNodes;
- List<String> propertyList;
-
- queryConfig = configObject.get(config);
- subObject = queryConfig.getAsJsonObject();
- propertyList = getPropertyList(subObject, REQUIRED_CONFIG);
- if (propertyList == null) {
- propertyList = new ArrayList<String>();
- }
- customQueryConfig.setQueryRequiredProperties(propertyList);
- propertyList = getPropertyList(subObject, OPTIONAL_CONFIG);
- if (propertyList == null) {
- propertyList = new ArrayList<String>();
- }
- customQueryConfig.setQueryOptionalProperties(propertyList);
-
- }
-
-
- public CustomQueryConfig getStoredQuery(String queryName) {
-
- customQueryConfig = null;
- JsonObject configObject;
- JsonElement query;
- JsonElement queryConfig;
- String queryString;
-
- for (JsonElement storedQuery : storedQueries) {
- if (storedQuery.isJsonObject()) {
- JsonObject queryObject = storedQuery.getAsJsonObject();
- query = queryObject.get(queryName);
- if (query != null) {
- customQueryConfig = new CustomQueryConfig();
- configObject = query.getAsJsonObject();
- getStoredQueryBlock(configObject, QUERY_CONFIG);
- if (configObject.has(STORED_QUERY_CONFIG)) {
- queryConfig = configObject.get(STORED_QUERY_CONFIG);
- customQueryConfig.setQuery(queryConfig.getAsString());
- }
- break;
- }
- }
- }
-
- return customQueryConfig;
-
- }
}
diff --git a/aai-traversal/src/main/java/org/onap/aai/rest/search/GremlinGroovyShellSingleton.java b/aai-traversal/src/main/java/org/onap/aai/rest/search/GremlinGroovyShellSingleton.java
deleted file mode 100644
index 30e876a..0000000
--- a/aai-traversal/src/main/java/org/onap/aai/rest/search/GremlinGroovyShellSingleton.java
+++ /dev/null
@@ -1,87 +0,0 @@
-/**
- * ============LICENSE_START=======================================================
- * org.onap.aai
- * ================================================================================
- * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY 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.rest.search;
-
-import java.util.HashMap;
-import java.util.Map;
-import java.util.concurrent.TimeUnit;
-
-import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversal;
-import org.codehaus.groovy.ast.ClassHelper;
-import org.codehaus.groovy.ast.expr.ClassExpression;
-import org.codehaus.groovy.ast.expr.PropertyExpression;
-import org.codehaus.groovy.control.CompilerConfiguration;
-import org.codehaus.groovy.control.customizers.ASTTransformationCustomizer;
-import org.codehaus.groovy.control.customizers.ImportCustomizer;
-
-import groovy.lang.Binding;
-import groovy.lang.GroovyShell;
-import groovy.lang.Script;
-import groovy.transform.TimedInterrupt;
-
-/**
- * Creates and returns a groovy shell with the
- * configuration to statically import graph classes
- *
- */
-public class GremlinGroovyShellSingleton {
-
- private final GroovyShell shell;
- private GremlinGroovyShellSingleton() {
- Map<String, Object> parameters = new HashMap<>();
- parameters.put("value", 30000);
- parameters.put("unit", new PropertyExpression(new ClassExpression(ClassHelper.make(TimeUnit.class)),"MILLISECONDS"));
-
- ASTTransformationCustomizer custom = new ASTTransformationCustomizer(parameters, TimedInterrupt.class);
- ImportCustomizer imports = new ImportCustomizer();
- imports.addStaticStars(
- "org.apache.tinkerpop.gremlin.process.traversal.P"
- );
- imports.addImports(
- "org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.__",
- "org.apache.tinkerpop.gremlin.structure.T",
- "org.apache.tinkerpop.gremlin.process.traversal.P");
- CompilerConfiguration config = new CompilerConfiguration();
- config.addCompilationCustomizers(custom, imports);
-
- this.shell = new GroovyShell(config);
- }
-
- private static class Helper {
- private static final GremlinGroovyShellSingleton INSTANCE = new GremlinGroovyShellSingleton();
- }
-
- public static GremlinGroovyShellSingleton getInstance() {
-
- return Helper.INSTANCE;
- }
-
- /**
- * @param traversal
- * @param params
- * @return result of graph traversal
- */
- public GraphTraversal<?, ?> executeTraversal (String traversal, Map<String, Object> params) {
- Binding binding = new Binding(params);
- Script script = shell.parse(traversal);
- script.setBinding(binding);
- return (GraphTraversal<?, ?>) script.run();
- }
-}
diff --git a/aai-traversal/src/main/java/org/onap/aai/rest/search/GremlinServerImpl.java b/aai-traversal/src/main/java/org/onap/aai/rest/search/GremlinServerImpl.java
deleted file mode 100644
index a059b04..0000000
--- a/aai-traversal/src/main/java/org/onap/aai/rest/search/GremlinServerImpl.java
+++ /dev/null
@@ -1,75 +0,0 @@
-/**
- * ============LICENSE_START=======================================================
- * org.onap.aai
- * ================================================================================
- * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY 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.rest.search;
-
-import java.util.List;
-import java.util.Map;
-import java.util.Vector;
-
-import org.apache.tinkerpop.gremlin.driver.Client;
-import org.apache.tinkerpop.gremlin.driver.Cluster;
-import org.apache.tinkerpop.gremlin.driver.ResultSet;
-import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversal;
-import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.__;
-
-import org.onap.aai.util.AAIConfig;
-
-public class GremlinServerImpl extends GenericQueryProcessor {
-
-
- protected GremlinServerImpl(Builder builder) {
- super(builder);
- }
-
-
- @Override
- protected GraphTraversal<?,?> runQuery(String query, Map<String, Object> params) {
-
- //must force them into ids because of serialization issue with
- //tinkerpop-3.0.1-incubating
- query += ".id()";
- String rebindGraph = AAIConfig.get("aai.server.rebind", "g");
-
- if(!"g".equals(rebindGraph)){
- query = query.replaceFirst("g\\.V\\(", rebindGraph + ".V(");
- }
-
- Cluster cluster = gremlinServerSingleton.getCluster();
- Client client = cluster.connect();
-
- ResultSet results = client.submit(query, params);
-
-
- List<Object> vIds = new Vector<>();
- results.stream().forEach(x -> {
- Object obj = x.getObject();
- vIds.add(obj);
- });
-
- client.close();
-
- if (vIds.isEmpty()) {
- return __.start();
- } else {
- return this.dbEngine.asAdmin().getTraversalSource().V(vIds.toArray());
- }
- }
-
-}
diff --git a/aai-traversal/src/main/java/org/onap/aai/rest/search/GremlinServerSingleton.java b/aai-traversal/src/main/java/org/onap/aai/rest/search/GremlinServerSingleton.java
index a39bc03..20a18d9 100644
--- a/aai-traversal/src/main/java/org/onap/aai/rest/search/GremlinServerSingleton.java
+++ b/aai-traversal/src/main/java/org/onap/aai/rest/search/GremlinServerSingleton.java
@@ -8,7 +8,7 @@
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
- * http://www.apache.org/licenses/LICENSE-2.0
+ * http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
@@ -25,7 +25,9 @@ import org.onap.aai.util.FileWatcher;
import com.att.eelf.configuration.EELFLogger;
import com.att.eelf.configuration.EELFManager;
import org.apache.tinkerpop.gremlin.driver.Cluster;
+import org.springframework.beans.factory.annotation.Value;
+import javax.annotation.PostConstruct;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
@@ -42,23 +44,13 @@ public class GremlinServerSingleton {
private static EELFLogger logger = EELFManager.getInstance().getLogger(GremlinServerSingleton.class);
- private Cluster cluster;
private boolean timerSet;
private Timer timer;
- private GetCustomQueryConfig queryConfig;
-
- private static class Helper {
-
- private static final GremlinServerSingleton INSTANCE = new GremlinServerSingleton();
- }
- private GremlinServerSingleton() {
- init();
- }
+ private GetCustomQueryConfig queryConfig;
- public static GremlinServerSingleton getInstance() {
- return Helper.INSTANCE;
- }
+ @Value("${schema.queries.location}")
+ private String storedQueriesLocation;
/**
* Initializes the gremlin server singleton
@@ -67,67 +59,60 @@ public class GremlinServerSingleton {
* Then creates a file watcher to watch the file every ten seconds
* and if there is a change in the file, then reloads the file into
* the properties object
+ *
*/
- private void init() {
-
- try {
- cluster = Cluster.build(new File(AAIConstants.AAI_HOME_ETC_APP_PROPERTIES + "gremlin-server-config.yaml"))
- .maxContentLength(6537920)
- .create();
- } catch (FileNotFoundException e) {
- logger.error("Unable to find the file: " + LogFormatTools.getStackTop(e));
- }
+ @PostConstruct
+ public void init() {
- try {
- String filepath = GetCustomQueryConfig.AAI_HOME_ETC_QUERY_JSON;
- Path path = Paths.get(filepath);
- String customQueryConfigJson = new String(Files.readAllBytes(path));
+ try {
+ String filepath = storedQueriesLocation + AAIConstants.AAI_FILESEP + "stored-queries.json";
+ Path path = Paths.get(filepath);
+ String customQueryConfigJson = new String(Files.readAllBytes(path));
+
- queryConfig = new GetCustomQueryConfig(customQueryConfigJson);
- } catch (IOException e) {
- logger.error("Error occurred during the processing of query json file: " + LogFormatTools.getStackTop(e));
- }
+ queryConfig = new GetCustomQueryConfig(customQueryConfigJson);
+ } catch (IOException e) {
+ logger.error("Error occurred during the processing of query json file: " + LogFormatTools.getStackTop(e));
+ }
- TimerTask task = new FileWatcher(new File(GetCustomQueryConfig.AAI_HOME_ETC_QUERY_JSON)) {
+
+ TimerTask task = new FileWatcher(new File(storedQueriesLocation)) {
@Override
protected void onChange(File file) {
- try {
- String filepath = GetCustomQueryConfig.AAI_HOME_ETC_QUERY_JSON;
- Path path = Paths.get(filepath);
- String customQueryConfigJson = new String(Files.readAllBytes(path));
- queryConfig = new GetCustomQueryConfig(customQueryConfigJson);
- } catch (IOException e) {
- logger.error(
- "Error occurred during the processing of query json file: " + LogFormatTools.getStackTop(e));
- }
+ try {
+ String filepath = storedQueriesLocation;
+ Path path = Paths.get(filepath);
+ String customQueryConfigJson = new String(Files.readAllBytes(path));
+ queryConfig = new GetCustomQueryConfig(customQueryConfigJson);
+ } catch (IOException e) {
+ logger.error("Error occurred during the processing of query json file: " + LogFormatTools.getStackTop(e));
+ }
}
};
if (!timerSet) {
timerSet = true;
timer = new Timer();
- timer.schedule(task, new Date(), 10000);
+ timer.schedule( task , new Date(), 10000 );
}
}
- public Cluster getCluster() {
- return cluster;
- }
-
/**
* Gets the query using CustomQueryConfig
+ * @param key
+ * @return
*/
- public String getStoredQueryFromConfig(String key) {
- CustomQueryConfig customQueryConfig = queryConfig.getStoredQuery(key);
- if (customQueryConfig == null) {
- return null;
- }
- return customQueryConfig.getQuery();
+ public String getStoredQueryFromConfig(String key){
+ CustomQueryConfig customQueryConfig = queryConfig.getStoredQuery(key);
+ if ( customQueryConfig == null ) {
+ return null;
+ }
+ return customQueryConfig.getQuery();
}
-
+
public CustomQueryConfig getCustomQueryConfig(String key) {
- return queryConfig.getStoredQuery(key);
+ return queryConfig.getStoredQuery(key);
}
diff --git a/aai-traversal/src/main/java/org/onap/aai/rest/search/GroovyQueryBuilderSingleton.java b/aai-traversal/src/main/java/org/onap/aai/rest/search/GroovyQueryBuilderSingleton.java
deleted file mode 100644
index b1a2b5f..0000000
--- a/aai-traversal/src/main/java/org/onap/aai/rest/search/GroovyQueryBuilderSingleton.java
+++ /dev/null
@@ -1,95 +0,0 @@
-/**
- * ============LICENSE_START=======================================================
- * org.onap.aai
- * ================================================================================
- * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY 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.rest.search;
-
-import java.util.HashMap;
-import java.util.Map;
-import java.util.concurrent.TimeUnit;
-
-import org.apache.tinkerpop.gremlin.structure.Vertex;
-import org.codehaus.groovy.ast.ClassHelper;
-import org.codehaus.groovy.ast.expr.ClassExpression;
-import org.codehaus.groovy.ast.expr.PropertyExpression;
-import org.codehaus.groovy.control.CompilerConfiguration;
-import org.codehaus.groovy.control.customizers.ASTTransformationCustomizer;
-import org.codehaus.groovy.control.customizers.ImportCustomizer;
-import org.onap.aai.query.builder.QueryBuilder;
-import org.onap.aai.serialization.engines.QueryStyle;
-import org.onap.aai.serialization.engines.TransactionalGraphEngine;
-
-import groovy.lang.Binding;
-import groovy.lang.GroovyShell;
-import groovy.lang.Script;
-import groovy.transform.TimedInterrupt;
-
-/**
- * Creates and returns a groovy shell with the
- * configuration to statically import graph classes
- *
- */
-public class GroovyQueryBuilderSingleton {
-
- private final GroovyShell shell;
- private GroovyQueryBuilderSingleton() {
- Map<String, Object> parameters = new HashMap<>();
- parameters.put("value", 30000);
- parameters.put("unit", new PropertyExpression(new ClassExpression(ClassHelper.make(TimeUnit.class)),"MILLISECONDS"));
-
- ASTTransformationCustomizer custom = new ASTTransformationCustomizer(parameters, TimedInterrupt.class);
- ImportCustomizer imports = new ImportCustomizer();
- imports.addStaticStars(
- "org.apache.tinkerpop.gremlin.process.traversal.P"
- );
- imports.addImports(
- "org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.__",
- "org.apache.tinkerpop.gremlin.structure.T",
- "org.apache.tinkerpop.gremlin.process.traversal.P",
- "org.onap.aai.serialization.db.EdgeType");
- CompilerConfiguration config = new CompilerConfiguration();
- config.addCompilationCustomizers(custom, imports);
-
- this.shell = new GroovyShell(config);
- }
-
- private static class Helper {
- private static final GroovyQueryBuilderSingleton INSTANCE = new GroovyQueryBuilderSingleton();
- }
-
- public static GroovyQueryBuilderSingleton getInstance() {
-
- return Helper.INSTANCE;
- }
-
- /**
- * @param traversal
- * @param params
- * @return result of graph traversal
- */
- public String executeTraversal (TransactionalGraphEngine engine, String traversal, Map<String, Object> params) {
- QueryBuilder<Vertex> builder = engine.getQueryBuilder(QueryStyle.GREMLIN_TRAVERSAL);
- Binding binding = new Binding(params);
- binding.setVariable("builder", builder);
- Script script = shell.parse(traversal);
- script.setBinding(binding);
- script.run();
-
- return builder.getQuery();
- }
-}
diff --git a/aai-traversal/src/main/java/org/onap/aai/rest/search/ModelAndNamedQueryRestProvider.java b/aai-traversal/src/main/java/org/onap/aai/rest/search/ModelAndNamedQueryRestProvider.java
index 0a6c1a4..4102c52 100644
--- a/aai-traversal/src/main/java/org/onap/aai/rest/search/ModelAndNamedQueryRestProvider.java
+++ b/aai-traversal/src/main/java/org/onap/aai/rest/search/ModelAndNamedQueryRestProvider.java
@@ -30,8 +30,11 @@ import org.onap.aai.logging.LoggingContext;
import org.onap.aai.logging.StopWatch;
import org.onap.aai.restcore.HttpMethod;
import org.onap.aai.restcore.RESTAPI;
-import org.onap.aai.util.AAIApiVersion;
+import org.onap.aai.setup.SchemaVersions;
import org.onap.aai.util.AAIConstants;
+import org.onap.aai.util.TraversalConstants;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.onap.aai.concurrent.AaiCallable;
import javax.servlet.http.HttpServletRequest;
import javax.ws.rs.POST;
@@ -41,29 +44,35 @@ import javax.ws.rs.QueryParam;
import javax.ws.rs.core.*;
import javax.ws.rs.core.Response.Status;
import java.util.ArrayList;
-import java.util.concurrent.Callable;
import java.util.concurrent.TimeUnit;
/**
* Implements the search subdomain in the REST API. All API calls must include
* X-FromAppId and X-TransactionId in the header.
- *
-
*
*/
-
@Path("/search")
public class ModelAndNamedQueryRestProvider extends RESTAPI {
-
- protected static String authPolicyFunctionName = "search";
-
+
+ private static final EELFLogger LOGGER = EELFManager.getInstance().getLogger(ModelAndNamedQueryRestProvider.class);
+
public static final String NAMED_QUERY = "/named-query";
public static final String MODEL_QUERY = "/model";
public static final String TARGET_ENTITY = "DB";
- private static final EELFLogger LOGGER = EELFManager.getInstance().getLogger(ModelAndNamedQueryRestProvider.class);
+
+ private SearchGraph searchGraph;
+
+ private SchemaVersions schemaVersions;
+
+ @Autowired
+ public ModelAndNamedQueryRestProvider(SearchGraph searchGraph, SchemaVersions schemaVersions){
+ this.searchGraph = searchGraph;
+ this.schemaVersions = schemaVersions;
+ }
+
/**
* Gets the named query response.
*
@@ -80,15 +89,15 @@ public class ModelAndNamedQueryRestProvider extends RESTAPI {
@Context HttpServletRequest req,
String queryParameters,
@Context UriInfo info) {
- return runner(AAIConstants.AAI_TRAVERSAL_TIMEOUT_ENABLED,
- AAIConstants.AAI_TRAVERSAL_TIMEOUT_APP,
- AAIConstants.AAI_TRAVERSAL_TIMEOUT_LIMIT,
+ return runner(TraversalConstants.AAI_TRAVERSAL_TIMEOUT_ENABLED,
+ TraversalConstants.AAI_TRAVERSAL_TIMEOUT_APP,
+ TraversalConstants.AAI_TRAVERSAL_TIMEOUT_LIMIT,
headers,
info,
HttpMethod.GET,
- new Callable<Response>() {
+ new AaiCallable<Response>() {
@Override
- public Response call() {
+ public Response process() {
return processNamedQueryResponse(headers, req, queryParameters);
}
}
@@ -117,12 +126,11 @@ public class ModelAndNamedQueryRestProvider extends RESTAPI {
AAIExtensionMap aaiExtMap = new AAIExtensionMap();
aaiExtMap.setHttpHeaders(headers);
aaiExtMap.setServletRequest(req);
- aaiExtMap.setApiVersion(AAIApiVersion.get());
+ aaiExtMap.setApiVersion(schemaVersions.getDefaultVersion().toString());
String realTime = headers.getRequestHeaders().getFirst("Real-Time");
//only consider header value for search
DBConnectionType type = this.determineConnectionType("force-cache", realTime);
- SearchGraph searchGraph = new SearchGraph();
LoggingContext.startTime();
StopWatch.conditionalStart();
@@ -187,15 +195,15 @@ public class ModelAndNamedQueryRestProvider extends RESTAPI {
String inboundPayload,
@QueryParam("action") String action,
@Context UriInfo info) {
- return runner(AAIConstants.AAI_TRAVERSAL_TIMEOUT_ENABLED,
- AAIConstants.AAI_TRAVERSAL_TIMEOUT_APP,
- AAIConstants.AAI_TRAVERSAL_TIMEOUT_LIMIT,
+ return runner(TraversalConstants.AAI_TRAVERSAL_TIMEOUT_ENABLED,
+ TraversalConstants.AAI_TRAVERSAL_TIMEOUT_APP,
+ TraversalConstants.AAI_TRAVERSAL_TIMEOUT_LIMIT,
headers,
info,
HttpMethod.GET,
- new Callable<Response>() {
+ new AaiCallable<Response>() {
@Override
- public Response call() {
+ public Response process() {
return processModelQueryResponse(headers, req, inboundPayload, action);
}
}
@@ -226,7 +234,7 @@ public class ModelAndNamedQueryRestProvider extends RESTAPI {
AAIExtensionMap aaiExtMap = new AAIExtensionMap();
aaiExtMap.setHttpHeaders(headers);
aaiExtMap.setServletRequest(req);
- aaiExtMap.setApiVersion(AAIApiVersion.get());
+ aaiExtMap.setApiVersion(schemaVersions.getDefaultVersion().toString());
aaiExtMap.setFromAppId(fromAppId);
aaiExtMap.setTransId(transId);
@@ -234,7 +242,6 @@ public class ModelAndNamedQueryRestProvider extends RESTAPI {
//only consider header value for search
DBConnectionType type = this.determineConnectionType("force-cache", realTime);
- SearchGraph searchGraph = new SearchGraph();
LoggingContext.startTime();
StopWatch.conditionalStart();
diff --git a/aai-traversal/src/main/java/org/onap/aai/rest/search/NodeQueryProcessor.java b/aai-traversal/src/main/java/org/onap/aai/rest/search/NodeQueryProcessor.java
new file mode 100644
index 0000000..0126162
--- /dev/null
+++ b/aai-traversal/src/main/java/org/onap/aai/rest/search/NodeQueryProcessor.java
@@ -0,0 +1,116 @@
+/**
+ * ============LICENSE_START=======================================================
+ * org.onap.aai
+ * ================================================================================
+ * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY 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.rest.search;
+
+import com.att.eelf.configuration.EELFLogger;
+import com.att.eelf.configuration.EELFManager;
+
+import edu.emory.mathcs.backport.java.util.concurrent.TimeUnit;
+
+import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversal;
+import org.apache.tinkerpop.gremlin.structure.Vertex;
+import org.javatuples.Pair;
+import org.onap.aai.exceptions.AAIException;
+import org.onap.aai.restcore.search.GroovyQueryBuilderSingleton;
+import org.onap.aai.serialization.engines.TransactionalGraphEngine;
+import org.onap.aai.serialization.queryformats.SubGraphStyle;
+
+import java.io.FileNotFoundException;
+import java.util.*;
+import java.util.regex.Pattern;
+
+import javax.ws.rs.core.MultivaluedHashMap;
+import javax.ws.rs.core.MultivaluedMap;
+
+public class NodeQueryProcessor extends GroovyShellImpl {
+
+ private static EELFLogger LOGGER = EELFManager.getInstance().getLogger(NodeQueryProcessor.class);
+
+ protected String nodeType;
+ private MultivaluedMap<String, String> nodeQueryParams = new MultivaluedHashMap<String, String>();
+ protected final Optional<Collection<Vertex>> vertices;
+ protected static Pattern p = Pattern.compile("query/(.*+)");
+ protected Optional<String> gremlin;
+ protected final TransactionalGraphEngine dbEngine;
+ protected static GroovyQueryBuilderSingleton queryBuilderSingleton = GroovyQueryBuilderSingleton.getInstance();;
+
+ protected NodeQueryProcessor(Builder builder) {
+ super(builder);
+ this.nodeQueryParams = builder.uriParams;
+ if(builder.getNodeType().isPresent())
+ this.nodeType = builder.getNodeType().get();
+ this.dbEngine = builder.getDbEngine();
+ this.vertices = builder.getVertices();
+
+ }
+
+ public Pair<String, Map<String, Object>> createQuery() throws AAIException {
+ Map<String, Object> params = new HashMap<>();
+
+ Long timeNowInMilliSecs = System.currentTimeMillis();
+ Long startTime = 0L;
+ if(nodeQueryParams.containsKey("hours")){
+ Long hoursInMilliSec = TimeUnit.HOURS.toMillis(Long.parseLong(nodeQueryParams.getFirst("hours")));
+ startTime = timeNowInMilliSecs - hoursInMilliSec;
+ }
+ else if(nodeQueryParams.containsKey("date-time")){
+ Long dateTime = Long.parseLong(nodeQueryParams.getFirst("date-time"));
+ startTime = dateTime;
+ }
+
+ String query = "builder.getVerticesByProperty('aai-node-type', nodeType)"
+ + ".or(builder.newInstance().getVerticesGreaterThanProperty('aai-created-ts',startTime),"
+ + " builder.newInstance().getVerticesGreaterThanProperty('aai-last-mod-ts',startTime)" + ")";
+
+ params.put("startTime", startTime);
+ params.put("nodeType", nodeType);
+
+ query = queryBuilderSingleton.executeTraversal(dbEngine, query, params);
+
+ String startPrefix = "g.V()";
+
+ query = startPrefix + query;
+
+ if (LOGGER.isDebugEnabled()) {
+ LOGGER.debug("Converted to gremlin query without the start vertices \n {}", query);
+ }
+
+ return new Pair<>(query, params);
+ }
+
+ public List<Object> execute(SubGraphStyle style) throws FileNotFoundException, AAIException {
+ final List<Object> resultVertices = new Vector<>();
+
+ Pair<String, Map<String, Object>> tuple = this.createQuery();
+ String query = tuple.getValue0();
+ Map<String, Object> params = tuple.getValue1();
+
+ if (query.equals("")) {
+ // nothing to do, just exit
+ return new ArrayList<>();
+ }
+ GraphTraversal<?, ?> g = this.runQuery(query, params);
+
+ resultVertices.addAll(g.toList());
+
+ return resultVertices;
+ }
+
+}
diff --git a/aai-traversal/src/main/java/org/onap/aai/rest/search/SearchProvider.java b/aai-traversal/src/main/java/org/onap/aai/rest/search/SearchProvider.java
index 4973060..f61e342 100644
--- a/aai-traversal/src/main/java/org/onap/aai/rest/search/SearchProvider.java
+++ b/aai-traversal/src/main/java/org/onap/aai/rest/search/SearchProvider.java
@@ -22,7 +22,6 @@ package org.onap.aai.rest.search;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.TimeUnit;
-import java.util.concurrent.Callable;
import javax.servlet.http.HttpServletRequest;
import javax.ws.rs.GET;
@@ -37,18 +36,15 @@ import javax.ws.rs.core.Response;
import javax.ws.rs.core.Response.Status;
import javax.ws.rs.core.UriInfo;
-import org.onap.aai.db.props.AAIProperties;
import org.onap.aai.dbgraphmap.SearchGraph;
import org.onap.aai.dbmap.DBConnectionType;
import org.onap.aai.exceptions.AAIException;
import org.onap.aai.introspection.Loader;
import org.onap.aai.introspection.LoaderFactory;
import org.onap.aai.introspection.ModelType;
-import org.onap.aai.introspection.Version;
import org.onap.aai.logging.ErrorLogHelper;
import org.onap.aai.logging.LoggingContext;
import org.onap.aai.logging.StopWatch;
-import org.onap.aai.logging.LoggingContext.StatusCode;
import org.onap.aai.restcore.HttpMethod;
import org.onap.aai.restcore.RESTAPI;
import org.onap.aai.serialization.db.DBSerializer;
@@ -56,29 +52,53 @@ import org.onap.aai.serialization.engines.QueryStyle;
import org.onap.aai.serialization.engines.JanusGraphDBEngine;
import org.onap.aai.serialization.engines.TransactionalGraphEngine;
import org.onap.aai.serialization.queryformats.utils.UrlBuilder;
+import org.onap.aai.setup.SchemaVersion;
+import org.onap.aai.setup.SchemaVersions;
import org.onap.aai.util.AAIConstants;
+import org.onap.aai.util.TraversalConstants;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.onap.aai.concurrent.AaiCallable;
import com.att.eelf.configuration.EELFLogger;
import com.att.eelf.configuration.EELFManager;
+import org.springframework.beans.factory.annotation.Value;
+
/**
* Implements the search subdomain in the REST API. All API calls must include
* X-FromAppId and X-TransactionId in the header.
- *
-
- *
*/
-
-@Path("/{version: v[789]|v1[01234]|latest}/search")
+@Path("/{version: v[1-9][0-9]*|latest}/search")
public class SearchProvider extends RESTAPI {
-
- protected static String authPolicyFunctionName = "search";
+
+ private static final EELFLogger LOGGER = EELFManager.getInstance().getLogger(SearchProvider.class);
public static final String GENERIC_QUERY = "/generic-query";
public static final String NODES_QUERY = "/nodes-query";
public static final String TARGET_ENTITY = "DB";
- private static final EELFLogger LOGGER = EELFManager.getInstance().getLogger(SearchProvider.class);
+
+ private SearchGraph searchGraph;
+
+ private LoaderFactory loaderFactory;
+
+ private SchemaVersions schemaVersions;
+
+ private String basePath;
+
+ @Autowired
+ public SearchProvider(
+ LoaderFactory loaderFactory,
+ SearchGraph searchGraph,
+ SchemaVersions schemaVersions,
+ @Value("${schema.uri.base.path}") String basePath
+ ){
+ this.loaderFactory = loaderFactory;
+ this.searchGraph = searchGraph;
+ this.schemaVersions = schemaVersions;
+ this.basePath = basePath;
+ }
+
/**
* Gets the generic query response.
*
@@ -103,15 +123,15 @@ public class SearchProvider extends RESTAPI {
@PathParam("version")String versionParam,
@Context UriInfo info
) {
- return runner(AAIConstants.AAI_TRAVERSAL_TIMEOUT_ENABLED,
- AAIConstants.AAI_TRAVERSAL_TIMEOUT_APP,
- AAIConstants.AAI_TRAVERSAL_TIMEOUT_LIMIT,
+ return runner(TraversalConstants.AAI_TRAVERSAL_TIMEOUT_ENABLED,
+ TraversalConstants.AAI_TRAVERSAL_TIMEOUT_APP,
+ TraversalConstants.AAI_TRAVERSAL_TIMEOUT_LIMIT,
headers,
info,
HttpMethod.GET,
- new Callable<Response>() {
+ new AaiCallable<Response>() {
@Override
- public Response call() {
+ public Response process() {
return processGenericQueryResponse(headers, req, startNodeType, startNodeKeyParams, includeNodeTypes, depth, versionParam);
}
}
@@ -145,22 +165,17 @@ public class SearchProvider extends RESTAPI {
String realTime = headers.getRequestHeaders().getFirst("Real-Time");
//only consider header value for search
DBConnectionType type = this.determineConnectionType("force-cache", realTime);
- final Version version;
- if ("latest".equals(versionParam)) {
- version = AAIProperties.LATEST;
- } else {
- version = Version.valueOf(versionParam);
- }
+
+ final SchemaVersion version = new SchemaVersion(versionParam);
+
final ModelType factoryType = ModelType.MOXY;
- Loader loader = LoaderFactory.createLoaderForVersion(factoryType, version);
+ Loader loader = loaderFactory.createLoaderForVersion(factoryType, version);
TransactionalGraphEngine dbEngine = new JanusGraphDBEngine(
QueryStyle.TRAVERSAL,
type,
loader);
DBSerializer dbSerializer = new DBSerializer(version, dbEngine, factoryType, fromAppId);
- UrlBuilder urlBuilder = new UrlBuilder(version, dbSerializer);
- SearchGraph searchGraph = new SearchGraph();
-
+ UrlBuilder urlBuilder = new UrlBuilder(version, dbSerializer, schemaVersions, this.basePath);
LoggingContext.startTime();
StopWatch.conditionalStart();
searchResult = searchGraph.runGenericQuery(
@@ -240,15 +255,15 @@ public class SearchProvider extends RESTAPI {
@Context UriInfo info)
{
- return runner(AAIConstants.AAI_TRAVERSAL_TIMEOUT_ENABLED,
- AAIConstants.AAI_TRAVERSAL_TIMEOUT_APP,
- AAIConstants.AAI_TRAVERSAL_TIMEOUT_LIMIT,
+ return runner(TraversalConstants.AAI_TRAVERSAL_TIMEOUT_ENABLED,
+ TraversalConstants.AAI_TRAVERSAL_TIMEOUT_APP,
+ TraversalConstants.AAI_TRAVERSAL_TIMEOUT_LIMIT,
headers,
info,
HttpMethod.GET,
- new Callable<Response>() {
+ new AaiCallable<Response>() {
@Override
- public Response call() {
+ public Response process() {
return processNodesQueryResponse(headers, req, searchNodeType, edgeFilterList, filterList, versionParam);
}
}
@@ -279,25 +294,19 @@ public class SearchProvider extends RESTAPI {
//only consider header value for search
DBConnectionType type = this.determineConnectionType("force-cache", realTime);
- final Version version;
- if ("latest".equals(versionParam)) {
- version = AAIProperties.LATEST;
- } else {
- version = Version.valueOf(versionParam);
- }
+ final SchemaVersion version = new SchemaVersion(versionParam);
+
final ModelType factoryType = ModelType.MOXY;
- Loader loader = LoaderFactory.createLoaderForVersion(factoryType, version);
+ Loader loader = loaderFactory.createLoaderForVersion(factoryType, version);
TransactionalGraphEngine dbEngine = new JanusGraphDBEngine(
QueryStyle.TRAVERSAL,
type,
loader);
DBSerializer dbSerializer = new DBSerializer(version, dbEngine, factoryType, fromAppId);
- UrlBuilder urlBuilder = new UrlBuilder(version, dbSerializer);
- SearchGraph searchGraph = new SearchGraph();
+ UrlBuilder urlBuilder = new UrlBuilder(version, dbSerializer, schemaVersions, this.basePath);
LoggingContext.startTime();
StopWatch.conditionalStart();
-
searchResult = searchGraph.runNodesQuery(headers,
searchNodeType,
edgeFilterList,
diff --git a/aai-traversal/src/main/java/org/onap/aai/rest/util/ConvertQueryPropertiesToJson.java b/aai-traversal/src/main/java/org/onap/aai/rest/util/ConvertQueryPropertiesToJson.java
index e8d1547..3bf9087 100644
--- a/aai-traversal/src/main/java/org/onap/aai/rest/util/ConvertQueryPropertiesToJson.java
+++ b/aai-traversal/src/main/java/org/onap/aai/rest/util/ConvertQueryPropertiesToJson.java
@@ -8,7 +8,7 @@
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
- * http://www.apache.org/licenses/LICENSE-2.0
+ * http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
@@ -32,102 +32,86 @@ import java.util.Properties;
import org.onap.aai.util.AAIConstants;
public class ConvertQueryPropertiesToJson {
-
- private static final int maxfilesize = 256000;
-
- private void addStart(StringBuilder sb) {
- sb.append("{\n \"stored-queries\":[{\n");
- }
-
- private void addRequiredQueryProperties(StringBuilder sb, List<String> rqd) {
- Iterator it = rqd.iterator();
- sb.append(" \"query\":{\n \"required-properties\":[");
- while (it.hasNext()) {
- sb.append("\"" + it.next() + "\"");
- if (it.hasNext()) {
- sb.append(",");
- }
- }
- sb.append("]\n },\n");
- }
-
- private void addAnotherQuery(StringBuilder sb, String queryName, String query, List<String> rqd) {
- sb.append(" \"" + queryName + "\":{\n");
- if (!rqd.isEmpty()) {
- addRequiredQueryProperties(sb, rqd);
- }
- sb.append(" \"stored-query\":\"" + query + "\"\n }\n },{\n");
- }
-
- private void addLastQuery(StringBuilder sb, String queryName, String query, List<String> rqd) {
- sb.append(" \"" + queryName + "\":{\n");
- if (!rqd.isEmpty()) {
- addRequiredQueryProperties(sb, rqd);
- }
- sb.append(" \"stored-query\":\"" + query + "\"\n }\n }]\n}\n");
- }
-
- private String get2ndParameter(String paramString) {
- String endParams = paramString.substring(0, paramString.indexOf(')'));
- String result = endParams.substring(endParams.indexOf(',') + 1);
- String lastParam = result.trim();
- if (lastParam.startsWith("\\") || lastParam.startsWith("'") || lastParam.startsWith("new ")) {
- return null;
- }
-
- return lastParam;
- }
-
- private List<String> findRqdProperties(String query) {
- String[] parts = query.split("getVerticesByProperty");
- List<String> result = new ArrayList<String>();
- if (parts.length == 1) {
- return result;
- }
- int count = 0;
- String foundRqdProperty;
- while (count++ < parts.length - 1) {
- foundRqdProperty = get2ndParameter(parts[count]);
- if (foundRqdProperty != null && !result.contains(foundRqdProperty)) {
- result.add(foundRqdProperty);
- }
- }
- return result;
- }
-
- public String convertProperties(Properties props) {
- Enumeration<?> e = props.propertyNames();
- StringBuilder sb = new StringBuilder(maxfilesize);
- String queryName;
- String query;
- addStart(sb);
- List<String> rqd;
- while (e.hasMoreElements()) {
- queryName = (String) e.nextElement();
- query = props.getProperty(queryName).trim().replace("\"", "\\\"");
- rqd = findRqdProperties(query);
- if (e.hasMoreElements()) {
- addAnotherQuery(sb, queryName, query, rqd);
- } else {
- addLastQuery(sb, queryName, query, rqd);
- }
- }
-
+
+ private final static int maxfilesize = 256000;
+
+ private void addStart( StringBuilder sb ) {
+ sb.append("{\n \"stored-queries\":[{\n");
+ }
+
+ private void addRequiredQueryProperties( StringBuilder sb, List<String> rqd ) {
+ Iterator it = rqd.iterator();
+ sb.append(" \"query\":{\n \"required-properties\":[");
+ while( it.hasNext()) {
+ sb.append("\"" + it.next() + "\"");
+ if ( it.hasNext()) {
+ sb.append(",");
+ }
+ }
+ sb.append("]\n },\n");
+ }
+
+ private void addAnotherQuery( StringBuilder sb, String queryName, String query, List<String> rqd ) {
+ sb.append(" \"" + queryName + "\":{\n");
+ if ( !rqd.isEmpty()) {
+ addRequiredQueryProperties( sb, rqd);
+ }
+ sb.append(" \"stored-query\":\"" + query + "\"\n }\n },{\n");
+ }
+
+ private void addLastQuery( StringBuilder sb, String queryName, String query, List<String> rqd ) {
+ sb.append(" \"" + queryName + "\":{\n");
+ if ( !rqd.isEmpty() ) {
+ addRequiredQueryProperties( sb, rqd);
+ }
+ sb.append(" \"stored-query\":\"" + query + "\"\n }\n }]\n}\n");
+ }
+
+ private String get2ndParameter( String paramString) {
+ String endParams = paramString.substring(0, paramString.indexOf(')'));
+ String result = endParams.substring(endParams.indexOf(',') + 1 );
+ String lastParam = result.trim();
+ if ( lastParam.startsWith("\\") || lastParam.startsWith("'") || lastParam.startsWith("new ") ){
+ return null;
+ }
+
+ return lastParam;
+ }
+
+ private List<String> findRqdProperties( String query) {
+ String[] parts = query.split("getVerticesByProperty");
+ List<String> result = new ArrayList<String>();
+ if ( parts.length == 1 )
+ return result;
+ int count = 0;
+ String foundRqdProperty;
+ while ( count++ < parts.length - 1 ) {
+ foundRqdProperty = get2ndParameter(parts[count]);
+ if ( foundRqdProperty != null && !result.contains(foundRqdProperty)) {
+ result.add(foundRqdProperty);
+ }
+ }
+ return result;
+ }
+
+ public String convertProperties( Properties props ) {
+ Enumeration<?> e = props.propertyNames();
+ StringBuilder sb = new StringBuilder(maxfilesize);
+ String queryName;
+ String query;
+ addStart( sb );
+ List<String> rqd;
+ while ( e.hasMoreElements()) {
+ queryName = (String)e.nextElement();
+ query = props.getProperty(queryName).trim().replace("\"", "\\\"");
+ rqd = findRqdProperties( query);
+ if ( e.hasMoreElements()) {
+ addAnotherQuery( sb, queryName, query, rqd);
+ } else {
+ addLastQuery( sb, queryName, query, rqd);
+ }
+ }
+
return sb.toString();
- }
-
- public static void main(String[] args) {
- File queryFile = new File(AAIConstants.AAI_HOME_ETC_QUERY);
- Properties properties = new Properties();
- try (FileInputStream fis = new FileInputStream(queryFile)) {
- properties.load(fis);
- } catch (IOException e) {
- e.printStackTrace();
- System.out.println("Error occurred during the processing of query file: " + e);
- }
- ConvertQueryPropertiesToJson c = new ConvertQueryPropertiesToJson();
- String json = c.convertProperties(properties);
- System.out.println("returned json:\n" + json);
- }
-
+ }
}
diff --git a/aai-traversal/src/main/java/org/onap/aai/rest/util/ValidateEncoding.java b/aai-traversal/src/main/java/org/onap/aai/rest/util/ValidateEncoding.java
index 3b4ea73..7d04bf7 100644
--- a/aai-traversal/src/main/java/org/onap/aai/rest/util/ValidateEncoding.java
+++ b/aai-traversal/src/main/java/org/onap/aai/rest/util/ValidateEncoding.java
@@ -133,6 +133,9 @@ public class ValidateEncoding {
valid = false;
}
for (String item : params.get(key)) {
+ if(item.contains("+")){
+ item = item.replaceAll("\\+", "%20");
+ }
if (!this.checkEncoding(item)) {
valid = false;
}
diff --git a/aai-traversal/src/main/java/org/onap/aai/service/AuthorizationService.java b/aai-traversal/src/main/java/org/onap/aai/service/AuthorizationService.java
index 616bb9c..2bb2794 100644
--- a/aai-traversal/src/main/java/org/onap/aai/service/AuthorizationService.java
+++ b/aai-traversal/src/main/java/org/onap/aai/service/AuthorizationService.java
@@ -22,7 +22,9 @@ package org.onap.aai.service;
import com.att.eelf.configuration.EELFLogger;
import com.att.eelf.configuration.EELFManager;
import org.eclipse.jetty.util.security.Password;
+import org.onap.aai.Profiles;
import org.onap.aai.util.AAIConstants;
+import org.springframework.context.annotation.Profile;
import org.springframework.stereotype.Service;
import javax.annotation.PostConstruct;
@@ -36,6 +38,7 @@ import java.util.Map;
import java.util.stream.Stream;
@Service
+@Profile(Profiles.ONE_WAY_SSL)
public class AuthorizationService {
private static final EELFLogger logger = EELFManager.getInstance().getLogger(AuthorizationService.class);
diff --git a/aai-traversal/src/main/java/org/onap/aai/service/RetiredService.java b/aai-traversal/src/main/java/org/onap/aai/service/RetiredService.java
new file mode 100644
index 0000000..5989e31
--- /dev/null
+++ b/aai-traversal/src/main/java/org/onap/aai/service/RetiredService.java
@@ -0,0 +1,67 @@
+/**
+ * ============LICENSE_START=======================================================
+ * org.onap.aai
+ * ================================================================================
+ * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY 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.service;
+
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.context.annotation.PropertySource;
+import org.springframework.stereotype.Service;
+
+import javax.annotation.PostConstruct;
+import java.util.Arrays;
+import java.util.List;
+import java.util.regex.Pattern;
+import java.util.stream.Collectors;
+
+@Service
+@PropertySource("classpath:retired.properties")
+@PropertySource(value = "file:${server.local.startpath}/retired.properties")
+public class RetiredService {
+
+ private String retiredPatterns;
+
+ private String retiredAllVersions;
+
+ private List<Pattern> retiredPatternsList;
+ private List<Pattern> retiredAllVersionList;
+
+ @PostConstruct
+ public void initialize(){
+ this.retiredPatternsList = Arrays.stream(retiredPatterns.split(",")).map(Pattern::compile).collect(Collectors.toList());
+ this.retiredAllVersionList = Arrays.stream(retiredAllVersions.split(",")).map(Pattern::compile).collect(Collectors.toList());
+ }
+
+ @Value("${retired.api.pattern.list}")
+ public void setRetiredPatterns(String retiredPatterns){
+ this.retiredPatterns = retiredPatterns;
+ }
+
+ public List<Pattern> getRetiredPatterns(){
+ return retiredPatternsList;
+ }
+
+ @Value("${retired.api.all.versions}")
+ public void setRetiredAllVersions(String retiredPatterns){
+ this.retiredAllVersions = retiredPatterns;
+ }
+
+ public List<Pattern> getRetiredAllVersionList(){
+ return retiredAllVersionList;
+ }
+}
diff --git a/aai-traversal/src/main/java/org/onap/aai/util/AAIAppServletContextListener.java b/aai-traversal/src/main/java/org/onap/aai/util/AAIAppServletContextListener.java
deleted file mode 100644
index d743adb..0000000
--- a/aai-traversal/src/main/java/org/onap/aai/util/AAIAppServletContextListener.java
+++ /dev/null
@@ -1,111 +0,0 @@
-/**
- * ============LICENSE_START=======================================================
- * org.onap.aai
- * ================================================================================
- * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY 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.util;
-
-import java.io.IOException;
-import java.util.UUID;
-import javax.servlet.ServletContextEvent;
-import javax.servlet.ServletContextListener;
-
-import org.onap.aai.dbmap.AAIGraph;
-import org.onap.aai.exceptions.AAIException;
-import org.onap.aai.introspection.ModelInjestor;
-import org.onap.aai.logging.ErrorLogHelper;
-import org.onap.aai.logging.LogFormatTools;
-import org.onap.aai.logging.LoggingContext;
-import org.onap.aai.logging.LoggingContext.StatusCode;
-
-import com.att.eelf.configuration.EELFLogger;
-import com.att.eelf.configuration.EELFManager;
-
-public class AAIAppServletContextListener implements ServletContextListener {
-
- private static final String MICRO_SVC="aai-traversal";
- private static final String ACTIVEMQ_TCP_URL = "tcp://localhost:61446";
- private static final EELFLogger LOGGER = EELFManager.getInstance().getLogger(AAIAppServletContextListener.class.getName());
-
- /**
- * Destroys Context
- *
- * @param arg0 the ServletContextEvent
- */
- public void contextDestroyed(ServletContextEvent arg0) {
- }
-
- /**
- * Initializes Context
- *
- * @param arg0 the ServletContextEvent
- */
- public void contextInitialized(ServletContextEvent arg0) {
- System.setProperty("org.onap.aai.serverStarted", "false");
- System.setProperty("aai.service.name", "traversal");
-
- LoggingContext.save();
- LoggingContext.component("init");
- LoggingContext.partnerName("NA");
- LoggingContext.targetEntity(MICRO_SVC);
- LoggingContext.requestId(UUID.randomUUID().toString());
- LoggingContext.serviceName(MICRO_SVC);
- LoggingContext.targetServiceName("contextInitialized");
- LoggingContext.statusCode(StatusCode.COMPLETE);
- LOGGER.info("AAI Server initialization started...");
- try {
- LOGGER.info("Loading aaiconfig.properties");
- AAIConfig.init();
-
- LOGGER.info("Loading error.properties");
- ErrorLogHelper.loadProperties();
-
- LOGGER.info("Loading graph database");
-
- AAIGraph.getInstance();
- ModelInjestor.getInstance();
-
- LOGGER.info("A&AI Server initialization succcessful.");
- System.setProperty("activemq.tcp.url", ACTIVEMQ_TCP_URL);
- System.setProperty("org.onap.aai.serverStarted", "true");
-
- Runtime.getRuntime().addShutdownHook(new Thread() {
- public void run() {
- LOGGER.info("AAIGraph shutting down");
- AAIGraph.getInstance().graphShutdown();
- LOGGER.info("AAIGraph shutdown");
- System.out.println("Shutdown hook triggered.");
- }
- });
-
- } catch (AAIException e) {
- ErrorLogHelper.logException(e);
- throw new RuntimeException("AAIException caught while initializing A&AI server", e);
- } catch (IOException e) {
- ErrorLogHelper.logError("AAI_4000", e.getMessage());
- throw new RuntimeException("IOException caught while initializing A&AI server", e);
- } catch (Exception e) {
- LOGGER.error("Unknown failure while initializing A&AI Server" + LogFormatTools.getStackTop(e));
- throw new RuntimeException("Unknown failure while initializing A&AI server", e);
- }
-
- LOGGER.info("Graph-Query MicroService Started");
- LOGGER.debug("Graph-Query MicroService Started");
- LoggingContext.restore();
-
- }
-}
diff --git a/aai-traversal/src/main/java/org/onap/aai/util/MakeNamedQuery.java b/aai-traversal/src/main/java/org/onap/aai/util/MakeNamedQuery.java
index 68d204f..a805e19 100644
--- a/aai-traversal/src/main/java/org/onap/aai/util/MakeNamedQuery.java
+++ b/aai-traversal/src/main/java/org/onap/aai/util/MakeNamedQuery.java
@@ -24,17 +24,18 @@ import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map.Entry;
-import java.util.Optional;
import java.util.UUID;
import org.apache.commons.io.FileUtils;
-
+import org.onap.aai.config.SpringContextAware;
import org.onap.aai.introspection.Introspector;
import org.onap.aai.introspection.Loader;
import org.onap.aai.introspection.LoaderFactory;
import org.onap.aai.introspection.ModelType;
-import org.onap.aai.introspection.Version;
import org.onap.aai.introspection.exceptions.AAIUnknownObjectException;
+import org.onap.aai.setup.SchemaVersion;
+import org.onap.aai.setup.SchemaVersions;
+import org.springframework.context.annotation.AnnotationConfigApplicationContext;
public class MakeNamedQuery {
@@ -67,104 +68,98 @@ public class MakeNamedQuery {
System.exit(0);
}
+ AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext(
+ "org.onap.aai.config",
+ "org.onap.aai.setup"
+ );
- Loader loader = LoaderFactory.createLoaderForVersion(ModelType.MOXY, Version.valueOf(_apiVersion));
+ LoaderFactory loaderFactory = ctx.getBean(LoaderFactory.class);
+ SchemaVersions schemaVersions = ctx.getBean(SchemaVersions.class);
- // iterate the collection of resources
+ if(schemaVersions.getVersions().contains(_apiVersion)){
- ArrayList<String> processedWidgets = new ArrayList<>();
+ Loader loader = loaderFactory.createLoaderForVersion(ModelType.MOXY, new SchemaVersion(_apiVersion));
+ // iterate the collection of resources
- HashMap<String, List<Introspector>> widgetToRelationship = new HashMap<String, List<Introspector>>();
- for (Entry<String, Introspector> aaiResEnt : loader.getAllObjects().entrySet()) {
- Introspector meObject = loader.introspectorFromName("model");
- // no need for a ModelVers DynamicEntity
+ ArrayList<String> processedWidgets = new ArrayList<>();
- Introspector aaiRes = aaiResEnt.getValue();
- if (!(aaiRes.isContainer() || aaiRes.getName().equals("aai-internal"))) {
- String resource = aaiRes.getName();
+ HashMap<String, List<Introspector>> widgetToRelationship = new HashMap<>();
+ for (Entry<String, Introspector> aaiResEnt : loader.getAllObjects().entrySet()) {
+ Introspector meObject = loader.introspectorFromName("model");
+ // no need for a ModelVers DynamicEntity
- if (processedWidgets.contains(resource)) {
- continue;
- }
- processedWidgets.add(resource);
-
- String widgetName = resource;
- String filePathString = widgetJsonDir + "/" + widgetName + "-" + modelVersion + ".json";
- File f = new File(filePathString);
- if (f.exists()) {
- System.out.println(f.toString());
- String json = FileUtils.readFileToString(f);
-
- meObject = loader.unmarshal("Model", json);
- String modelInvariantId = meObject.getValue("model-invariant-id");
- if (meObject.hasProperty("model-vers")) {
- Introspector modelVers = meObject.getWrappedValue("model-vers");
- List<Introspector> modelVerList = modelVers.getWrappedListValue("model-ver");
- for (Introspector modelVer : modelVerList) {
-
- List<Introspector> relList = new ArrayList<Introspector>();
- Introspector widgetRelationship = makeWidgetRelationship(loader, modelInvariantId,
- modelVer.getValue("model-version-id").toString());
- relList.add(widgetRelationship);
-
- widgetToRelationship.put(widgetName, relList);
+ Introspector aaiRes = aaiResEnt.getValue();
+
+ if (!(aaiRes.isContainer() || aaiRes.getName().equals("aai-internal"))) {
+ String resource = aaiRes.getName();
+
+ if (processedWidgets.contains(resource)) {
+ continue;
+ }
+ processedWidgets.add(resource);
+
+ String widgetName = resource;
+ String filePathString = widgetJsonDir + "/" + widgetName + "-" + modelVersion + ".json";
+ File f = new File(filePathString);
+ if (f.exists()) {
+ System.out.println(f.toString());
+ String json = FileUtils.readFileToString(f);
+
+ meObject = loader.unmarshal("Model", json);
+ String modelInvariantId = meObject.getValue("model-invariant-id");
+ if (meObject.hasProperty("model-vers")) {
+ Introspector modelVers = meObject.getWrappedValue("model-vers");
+ List<Introspector> modelVerList = (List<Introspector>) modelVers.getWrappedListValue("model-ver");
+ for (Introspector modelVer : modelVerList) {
+
+ List<Introspector> relList = new ArrayList<Introspector>();
+ Introspector widgetRelationship = makeWidgetRelationship(loader, modelInvariantId,
+ modelVer.getValue("model-version-id").toString());
+ relList.add(widgetRelationship);
+
+ widgetToRelationship.put(widgetName, relList);
+ }
}
}
}
}
- }
-
-// esr-system-info-from-vnf=builder.store('x').union(\
-// builder.newInstance().createEdgeTraversal(EdgeType.COUSIN, 'generic-vnf', 'vserver').store('x').union(\
-// builder.newInstance().createEdgeTraversal(EdgeType.TREE, 'vserver', 'tenant').store('x')\
-// .createEdgeTraversal(EdgeType.TREE, 'tenant', 'cloud-region').store('x')\
-// .createEdgeTraversal(EdgeType.TREE, 'cloud-region', 'esr-system-info').store('x')\
-// )).cap('x').unfold.dedup()
-
- //source vnf-id, related service-instance-id, all related vnfs in this service-instance-id
-
- //this should be abstracted and moved to a file
-
- HashMap<String, List<Introspector>> relationshipMap = new HashMap<String, List<Introspector>>();
-
- List<Introspector> genericVnfRelationship = widgetToRelationship.get("generic-vnf");
- List<Introspector> vserverRelationship = widgetToRelationship.get("vserver");
- List<Introspector> tenantRelationship = widgetToRelationship.get("tenant");
- List<Introspector> cloudRegionRelationship = widgetToRelationship.get("cloud-region");
- List<Introspector> esrSystemInfoRelationship = widgetToRelationship.get("esr-system-info");
-
- Introspector namedQueryObj = loader.introspectorFromName("named-query");
- namedQueryObj.setValue("named-query-uuid", namedQueryUuid);
- namedQueryObj.setValue("named-query-name", "vnf-to-esr-system-info");
- namedQueryObj.setValue("named-query-version", "1.0");
- namedQueryObj.setValue("description", "Named Query - VNF to ESR System Info");
-
- Optional<Introspector> genericVnfNQE = tryToSetUpNQElements(Optional.of(namedQueryObj), genericVnfRelationship);
-
- Optional<Introspector> vserverNQE = tryToSetUpNQElements(genericVnfNQE, vserverRelationship);
-
- Optional<Introspector> tenantNQE = tryToSetUpNQElements(vserverNQE, tenantRelationship);
-
- Optional<Introspector> cloudRegionNQE = tryToSetUpNQElements(tenantNQE, cloudRegionRelationship);
- Optional<Introspector> esrSystemInfoNQE = tryToSetUpNQElements(cloudRegionNQE, esrSystemInfoRelationship);
-
- System.out.println(namedQueryObj.marshal(true));
-
- System.exit(0);
+ //source vnf-id, related service-instance-id, all related vnfs in this service-instance-id
+ //this should be abstracted and moved to a file
- }
+ HashMap<String, List<Introspector>> relationshipMap = new HashMap<String, List<Introspector>>();
+
+ List<Introspector> genericVnfRelationship = widgetToRelationship.get("generic-vnf");
+ List<Introspector> vserverRelationship = widgetToRelationship.get("vserver");
+ List<Introspector> tenantRelationship = widgetToRelationship.get("tenant");
+ List<Introspector> cloudRegionRelationship = widgetToRelationship.get("cloud-region");
+ List<Introspector> esrSystemInfoRelationship = widgetToRelationship.get("esr-system-info");
+
+ Introspector namedQueryObj = loader.introspectorFromName("named-query");
+ namedQueryObj.setValue("named-query-uuid", namedQueryUuid);
+ namedQueryObj.setValue("named-query-name", "vnf-to-esr-system-info");
+ namedQueryObj.setValue("named-query-version", "1.0");
+ namedQueryObj.setValue("description", "Named Query - VNF to ESR System Info");
+
+ Introspector genericVnfNQE = setupNQElements(namedQueryObj, genericVnfRelationship);
+
+ Introspector vserverNQE = setupNQElements(genericVnfNQE, vserverRelationship);
+
+ Introspector tenantNQE = setupNQElements(vserverNQE, tenantRelationship);
+
+ Introspector cloudRegionNQE = setupNQElements(tenantNQE, cloudRegionRelationship);
+
+ Introspector esrSystemInfoNQE = setupNQElements(cloudRegionNQE, esrSystemInfoRelationship);
+
+ System.out.println(namedQueryObj.marshal(true));
- private static Optional<Introspector> tryToSetUpNQElements(Optional<Introspector> genericVnfNQE, List<Introspector> vserverRelationship) {
- if(genericVnfNQE.isPresent()) {
- return Optional.ofNullable(setupNQElements(genericVnfNQE.get(), vserverRelationship));
- } else {
- return Optional.empty();
}
- }
+ System.exit(0);
+
+ }
private static List<Introspector> getRels(String widgetName, HashMap<String, Introspector> widgetToRelationship) {
List<Introspector> relList = new ArrayList<Introspector>();
Introspector genericVnfRelationship = widgetToRelationship.get(widgetName);
@@ -180,16 +175,14 @@ public class MakeNamedQuery {
if (nqeObj.getWrappedValue("named-query-elements") != null) {
newNQElements = nqeObj.getWrappedValue("named-query-elements");
nqElementList = newNQElements.getValue("named-query-element");
- } else {
+ } else {
newNQElements = nqeObj.newIntrospectorInstanceOfProperty("named-query-elements");
nqeObj.setValue("named-query-elements", newNQElements.getUnderlyingObject());
- nqElementList = newNQElements.getValue("named-query-element");
+ nqElementList = (List<Object>)newNQElements.getValue("named-query-element");
}
newNQElement = loadNQElement(newNQElements, listOfRelationships);
- if (newNQElement != null) {
- nqElementList.add(newNQElement.getUnderlyingObject());
- }
-
+ nqElementList.add(newNQElement.getUnderlyingObject());
+
} catch (AAIUnknownObjectException e) {
// TODO Auto-generated catch block
e.printStackTrace();
@@ -210,7 +203,7 @@ public class MakeNamedQuery {
Introspector newRelationshipList = newNqElement.getLoader().introspectorFromName("relationship-list");
newNqElement.setValue("relationship-list", newRelationshipList.getUnderlyingObject());
- List<Object> newRelationshipListList = newRelationshipList.getValue("relationship");
+ List<Object> newRelationshipListList = (List<Object>)newRelationshipList.getValue("relationship");
for (Introspector rel : listOfRelationships) {
newRelationshipListList.add(rel.getUnderlyingObject());
@@ -232,7 +225,7 @@ public class MakeNamedQuery {
try {
newRelationship = loader.introspectorFromName("relationship");
- List<Object> newRelationshipData = newRelationship.getValue("relationship-data");
+ List<Object> newRelationshipData = (List<Object>)newRelationship.getValue("relationship-data");
newRelationship.setValue("related-to", "model");
diff --git a/aai-traversal/src/test/java/org/onap/aai/retiredcustomer/V7V8NamedQueriesTest.java b/aai-traversal/src/main/java/org/onap/aai/util/TraversalConstants.java
index 7ab10d2..69e1e9f 100644
--- a/aai-traversal/src/test/java/org/onap/aai/retiredcustomer/V7V8NamedQueriesTest.java
+++ b/aai-traversal/src/main/java/org/onap/aai/util/TraversalConstants.java
@@ -17,15 +17,23 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
-package org.onap.aai.retiredcustomer;
+package org.onap.aai.util;
-import org.onap.aai.rest.retired.RetiredConsumer;
-import org.onap.aai.rest.retired.V7V8NamedQueries;
+public final class TraversalConstants {
+ public static final int AAI_QUERY_PORT = 8446;
+
+ public static final String AAI_TRAVERSAL_TIMEOUT_LIMIT = "aai.traversal.timeoutlimit";
+ public static final String AAI_TRAVERSAL_TIMEOUT_ENABLED = "aai.traversal.timeoutenabled";
+ public static final String AAI_TRAVERSAL_TIMEOUT_APP = "aai.traversal.timeout.appspecific";
+
+ public static final String AAI_TRAVERSAL_DSL_TIMEOUT_LIMIT = "aai.traversal.dsl.timeoutlimit";
+ public static final String AAI_TRAVERSAL_DSL_TIMEOUT_ENABLED = "aai.traversal.dsl.timeoutenabled";
+ public static final String AAI_TRAVERSAL_DSL_TIMEOUT_APP = "aai.traversal.dsl.timeout.appspecific";
+
+ public static final long HISTORY_MAX_HOURS = 192;
+
+ private TraversalConstants() {
+ // prevent instantiation
+ }
-public class V7V8NamedQueriesTest extends RetiredConsumerTest {
-
- @Override
- public RetiredConsumer getRetiredConsumer() {
- return new V7V8NamedQueries();
- }
}
diff --git a/aai-traversal/src/main/java/org/onap/aai/web/JerseyConfiguration.java b/aai-traversal/src/main/java/org/onap/aai/web/JerseyConfiguration.java
index b979fb8..231c82b 100644
--- a/aai-traversal/src/main/java/org/onap/aai/web/JerseyConfiguration.java
+++ b/aai-traversal/src/main/java/org/onap/aai/web/JerseyConfiguration.java
@@ -8,7 +8,7 @@
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
- * http://www.apache.org/licenses/LICENSE-2.0
+ * http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
@@ -22,8 +22,9 @@ package org.onap.aai.web;
import org.glassfish.jersey.filter.LoggingFilter;
import org.glassfish.jersey.server.ResourceConfig;
import org.glassfish.jersey.servlet.ServletProperties;
+import org.onap.aai.rest.DslConsumer;
import org.onap.aai.rest.QueryConsumer;
-import org.onap.aai.rest.retired.V3ThroughV7Consumer;
+import org.onap.aai.rest.RecentAPIConsumer;
import org.onap.aai.rest.search.ModelAndNamedQueryRestProvider;
import org.onap.aai.rest.search.SearchProvider;
import org.onap.aai.rest.util.EchoResponse;
@@ -34,7 +35,6 @@ import org.springframework.core.env.Environment;
import org.springframework.stereotype.Component;
import javax.annotation.Priority;
-import javax.ws.rs.ApplicationPath;
import javax.ws.rs.container.ContainerRequestFilter;
import javax.ws.rs.container.ContainerResponseFilter;
import java.util.List;
@@ -43,7 +43,6 @@ import java.util.logging.Logger;
import java.util.stream.Collectors;
@Component
-@ApplicationPath("/aai")
public class JerseyConfiguration extends ResourceConfig {
private static final Logger log = Logger.getLogger(JerseyConfiguration.class.getName());
@@ -58,8 +57,8 @@ public class JerseyConfiguration extends ResourceConfig {
register(SearchProvider.class);
register(ModelAndNamedQueryRestProvider.class);
register(QueryConsumer.class);
-
- register(V3ThroughV7Consumer.class);
+ register(RecentAPIConsumer.class);
+ register(DslConsumer.class);
register(EchoResponse.class);
//Request Filters
@@ -83,25 +82,28 @@ public class JerseyConfiguration extends ResourceConfig {
// Filter them based on the clazz that was passed in
Set<Class<? extends ContainerRequestFilter>> filters = reflections.getSubTypesOf(ContainerRequestFilter.class);
+
// Check to ensure that each of the filter has the @Priority annotation and if not throw exception
for (Class filterClass : filters) {
if (filterClass.getAnnotation(Priority.class) == null) {
- throw new RuntimeException(
- "Container filter " + filterClass.getName() + " does not have @Priority annotation");
+ throw new RuntimeException("Container filter " + filterClass.getName() + " does not have @Priority annotation");
}
}
// Turn the set back into a list
List<Class<? extends ContainerRequestFilter>> filtersList = filters
- .stream()
- .filter(f -> !(f.isAnnotationPresent(Profile.class)
- && !env.acceptsProfiles(f.getAnnotation(Profile.class).value()))
- )
- .collect(Collectors.toList());
+ .stream()
+ .filter(f -> {
+ if (f.isAnnotationPresent(Profile.class)
+ && !env.acceptsProfiles(f.getAnnotation(Profile.class).value())) {
+ return false;
+ }
+ return true;
+ })
+ .collect(Collectors.toList());
// Sort them by their priority levels value
- filtersList.sort((c1, c2) -> Integer.valueOf(c1.getAnnotation(Priority.class).value())
- .compareTo(c2.getAnnotation(Priority.class).value()));
+ filtersList.sort((c1, c2) -> Integer.valueOf(c1.getAnnotation(Priority.class).value()).compareTo(c2.getAnnotation(Priority.class).value()));
// Then register this to the jersey application
filtersList.forEach(this::register);
@@ -112,29 +114,31 @@ public class JerseyConfiguration extends ResourceConfig {
// Find all the classes within the interceptors package
Reflections reflections = new Reflections("org.onap.aai.interceptors");
// Filter them based on the clazz that was passed in
- Set<Class<? extends ContainerResponseFilter>> filters = reflections
- .getSubTypesOf(ContainerResponseFilter.class);
+ Set<Class<? extends ContainerResponseFilter>> filters = reflections.getSubTypesOf(ContainerResponseFilter.class);
+
// Check to ensure that each of the filter has the @Priority annotation and if not throw exception
for (Class filterClass : filters) {
if (filterClass.getAnnotation(Priority.class) == null) {
- throw new RuntimeException(
- "Container filter " + filterClass.getName() + " does not have @Priority annotation");
+ throw new RuntimeException("Container filter " + filterClass.getName() + " does not have @Priority annotation");
}
}
// Turn the set back into a list
List<Class<? extends ContainerResponseFilter>> filtersList = filters.stream()
- .filter(f -> !(f.isAnnotationPresent(Profile.class)
- && !env.acceptsProfiles(f.getAnnotation(Profile.class).value())))
- .collect(Collectors.toList());
+ .filter(f -> {
+ if (f.isAnnotationPresent(Profile.class)
+ && !env.acceptsProfiles(f.getAnnotation(Profile.class).value())) {
+ return false;
+ }
+ return true;
+ })
+ .collect(Collectors.toList());
// Sort them by their priority levels value
- filtersList.sort((c1, c2) -> Integer.valueOf(c1.getAnnotation(Priority.class).value())
- .compareTo(c2.getAnnotation(Priority.class).value()));
+ filtersList.sort((c1, c2) -> Integer.valueOf(c1.getAnnotation(Priority.class).value()).compareTo(c2.getAnnotation(Priority.class).value()));
// Then register this to the jersey application
filtersList.forEach(this::register);
}
-
}
diff --git a/aai-traversal/src/main/java/org/onap/aai/web/LocalHostAccessLog.java b/aai-traversal/src/main/java/org/onap/aai/web/LocalHostAccessLog.java
index 9d0aa9a..4bc3300 100644
--- a/aai-traversal/src/main/java/org/onap/aai/web/LocalHostAccessLog.java
+++ b/aai-traversal/src/main/java/org/onap/aai/web/LocalHostAccessLog.java
@@ -22,6 +22,8 @@ package org.onap.aai.web;
import ch.qos.logback.access.jetty.RequestLogImpl;
import org.eclipse.jetty.server.handler.HandlerCollection;
import org.eclipse.jetty.server.handler.RequestLogHandler;
+import org.eclipse.jetty.util.thread.QueuedThreadPool;
+import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.context.embedded.EmbeddedServletContainerFactory;
import org.springframework.boot.context.embedded.jetty.JettyEmbeddedServletContainerFactory;
import org.springframework.boot.context.embedded.jetty.JettyServerCustomizer;
@@ -34,7 +36,11 @@ import java.util.Arrays;
public class LocalHostAccessLog {
@Bean
- public EmbeddedServletContainerFactory jettyConfigBean(){
+ public EmbeddedServletContainerFactory jettyConfigBean(
+ @Value("${jetty.threadPool.maxThreads:200}") final String maxThreads,
+ @Value("${jetty.threadPool.minThreads:8}") final String minThreads
+ ){
+
JettyEmbeddedServletContainerFactory jef = new JettyEmbeddedServletContainerFactory();
jef.addServerCustomizers((JettyServerCustomizer) server -> {
@@ -52,6 +58,10 @@ public class LocalHostAccessLog {
requestLogHandler.setRequestLog(requestLogImpl);
handlers.addHandler(requestLogHandler);
server.setHandler(handlers);
+
+ final QueuedThreadPool threadPool = server.getBean(QueuedThreadPool.class);
+ threadPool.setMaxThreads(Integer.valueOf(maxThreads));
+ threadPool.setMinThreads(Integer.valueOf(minThreads));
});
return jef;
}
diff --git a/aai-traversal/src/main/resources/antlr4/org/onap/aai/AAIDsl.g4 b/aai-traversal/src/main/resources/antlr4/org/onap/aai/AAIDsl.g4
index 2713677..f0c866a 100644
--- a/aai-traversal/src/main/resources/antlr4/org/onap/aai/AAIDsl.g4
+++ b/aai-traversal/src/main/resources/antlr4/org/onap/aai/AAIDsl.g4
@@ -6,21 +6,15 @@ grammar AAIDsl;
aaiquery: dslStatement;
-dslStatement: (queryStep) (traverseStep | unionTraverseStep)* limitStep*;
-
-queryStep : (singleNodeStep |singleQueryStep | multiQueryStep);
+dslStatement: (singleNodeStep ) (traverseStep )* limitStep*;
unionQueryStep: LBRACKET dslStatement ( COMMA (dslStatement))* RBRACKET;
-traverseStep: (TRAVERSE ( queryStep | unionQueryStep));
-
-unionTraverseStep: TRAVERSE unionQueryStep;
+traverseStep: (TRAVERSE ( singleNodeStep | unionQueryStep));
-singleNodeStep: NODE STORE? ;
-singleQueryStep: NODE STORE? (filterStep | filterTraverseStep);
-multiQueryStep: NODE STORE? (filterStep | filterTraverseStep) (filterStep)+;
+singleNodeStep: NODE STORE? (filterStep | filterTraverseStep)*;
-filterStep: NOT? (LPAREN KEY COMMA KEY (COMMA KEY)*RPAREN);
+filterStep: NOT? (LPAREN KEY (COMMA KEY)* RPAREN);
filterTraverseStep: (LPAREN traverseStep* RPAREN);
limitStep: LIMIT NODE;
@@ -28,7 +22,8 @@ limitStep: LIMIT NODE;
LIMIT: 'LIMIT';
NODE: ID;
-KEY: ['] ID ['] ;
+KEY: ['] (ID | ' ')* ['] ;
+
AND: [&];
diff --git a/aai-traversal/src/main/resources/application.properties b/aai-traversal/src/main/resources/application.properties
index bdb7535..a1a14af 100644
--- a/aai-traversal/src/main/resources/application.properties
+++ b/aai-traversal/src/main/resources/application.properties
@@ -10,23 +10,15 @@ spring.jersey.type=filter
server.contextPath=/
spring.autoconfigure.exclude=org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration,org.springframework.boot.autoconfigure.orm.jpa.HibernateJpaAutoConfiguration
-spring.profiles.active=production
+spring.jersey.application-path=${schema.uri.base.path}
+
#The max number of active threads in this pool
-server.tomcat.max-threads=200
+jetty.threadPool.maxThreads=200
#The minimum number of threads always kept alive
-server.tomcat.min-Spare-Threads=25
+jetty.threadPool.minThreads=8
#The number of milliseconds before an idle thread shutsdown, unless the number of active threads are less or equal to minSpareThreads
server.tomcat.max-idle-time=60000
-
-#Add this properties only if you want to change the URL, AJSC Framework interceptors will intercept
-#com.att.ajsc.common.interceptors.PreInterceptor.url=/**
-#com.att.ajsc.common.interceptors.PostInterceptor.url=/**
-
-#Servlet context parameters
-server.context_parameters.p-name=value #context parameter with p-name as key and value as value.
-kubernetes.namespace=org-onap-aai
-
# If you get an application startup failure that the port is already taken
# If thats not it, please check if the key-store file path makes sense
server.local.startpath=aai-traversal/src/main/resources/
@@ -34,39 +26,52 @@ server.basic.auth.location=${server.local.startpath}etc/auth/realm.properties
server.port=8446
server.ssl.enabled-protocols=TLSv1.1,TLSv1.2
+server.ssl.client-auth=want
+server.ssl.key-store-type=JKS
+
+# Start of Internal Specific Properties
+spring.profiles.active=production,two-way-ssl
server.ssl.key-store=${server.local.startpath}etc/auth/aai_keystore
server.ssl.key-store-password=password(OBF:1vn21ugu1saj1v9i1v941sar1ugw1vo0)
server.ssl.trust-store=${server.local.startpath}etc/auth/aai_keystore
server.ssl.trust-store-password=password(OBF:1vn21ugu1saj1v9i1v941sar1ugw1vo0)
-server.ssl.client-auth=want
-server.ssl.key-store-type=JKS
+
+schema.version.list=v8,v9,v10,v11,v12,v13,v14
+# Specifies which component should the oxm be looking at
+schema.source.name=onap
+# End of Internal Specific Properties
# JMS bind address host port
-jms.bind.address=tcp://localhost:61647
-dmaap.ribbon.eureka.enabled=false
+jms.bind.address=tcp://localhost:61646
+
dmaap.ribbon.listOfServers=localhost:3904
-# Number of milliseconds to wait before making ping requests again
-dmaap.ribbon.ServerListRefreshInterval=75000
-dmaap.ribbon.NFLoadBalancerPingInterval=75000
-dmaap.ribbon.NFLoadBalancerRuleClassName=com.netflix.loadbalancer.AvailabilityFilteringRule
-dmaap.ribbon.NFLoadBalancerPingClassName=org.onap.aai.config.HttpPingImpl
-dmaap.ribbon.EnableMarkingServerDownOnReachingFailureLimit=true
-dmaap.ribbon.ServerDownFailureLimit=1
-# This needs to be verified but it seems that adding this property should automatically
-# Make the dmaap client change the url from http to https depending on the server
-dmaap.ribbon.securePorts=3905
-# Custom Dmaap Specific Configuration
-dmaap.ribbon.username=
-dmaap.ribbon.password=
-dmaap.ribbon.health.endpoint=/topics/AAI-EVENT
-# Number of seconds to wait for the ping to work and might need to increase this if the pings are all failing
-dmaap.ribbon.pingport.timeout=3
+# Lists all of the versions in the schema
+# Schema related attributes for the oxm and edges
+# Any additional schema related attributes should start with prefix schema
+
+schema.configuration.location=N/A
+# Location of where the oxm files are
+schema.nodes.location=${server.local.startpath}/schema/${schema.source.name}/oxm/
+# Location of where the dbedgerules files are
+schema.edges.location=${server.local.startpath}/schema/${schema.source.name}/dbedgerules/
+# Location of where the stored queries are
+schema.queries.location=${server.local.startpath}/schema/${schema.source.name}/query/
+
+schema.ingest.file=${server.local.startpath}/application.properties
-niws.loadbalancer.dmaap.filterCircuitTripped=true
-niws.loadbalancer.dmaap.connectionFailureCountThreshold=3
-niws.loadbalancer.dmaap.circuitTripMaxTimeoutSeconds=180
-#dmaap.ribbon.retryableStatusCodes=404,503
-#dmaap.ribbon.retryableStatusCodes.MaxAutoRetriesNextServer=2
-#dmaap.ribbon.retryableStatusCodes.MaxAutoRetries=2
-#dmaap.ribbon.retryableStatusCodes.OkToRetryOnAllOperations=true
+# Schema Version Related Attributes
+schema.uri.base.path=/aai
+# Specifies from which version should the depth parameter to default to zero
+schema.version.depth.start=v9
+# Specifies from which version should the related link be displayed in response payload
+schema.version.related.link.start=v10
+# Specifies from which version should the client see only the uri excluding host info
+# Before this version server base will also be included
+schema.version.app.root.start=v11
+# Specifies from which version should the namespace be changed
+schema.version.namespace.change.start=v12
+# Specifies from which version should the client start seeing the edge label in payload
+schema.version.edge.label.start=v12
+# Specifies the version that the application should default to
+schema.version.api.default=v14
diff --git a/aai-traversal/src/main/resources/etc/appprops/Introscope.properties b/aai-traversal/src/main/resources/etc/appprops/Introscope.properties
deleted file mode 100644
index 319381e..0000000
--- a/aai-traversal/src/main/resources/etc/appprops/Introscope.properties
+++ /dev/null
@@ -1,8 +0,0 @@
-#CSI environment uses the Introscope java agent for monitoring services. The AJSC has provided an implementation class that
-#provides basic information to the Introscope Enterprise Manager for each http request/response.
-
-introscopeEventClass=com.att.ajsc.introscope.IntroscopeEventNotifierImpl
-serviceName=N/A
-conversationId=N/A
-uniqueID=N/A
-userID=N/A
diff --git a/aai-traversal/src/main/resources/etc/appprops/PostProcessorInterceptors.properties b/aai-traversal/src/main/resources/etc/appprops/PostProcessorInterceptors.properties
deleted file mode 100644
index ca31a26..0000000
--- a/aai-traversal/src/main/resources/etc/appprops/PostProcessorInterceptors.properties
+++ /dev/null
@@ -1,3 +0,0 @@
-#This properties file is for defining any PostProcessorInterceptors that have been created for your AJSC service.
-
-/**=org.onap.aai.interceptors.PostAaiAjscInterceptor
diff --git a/aai-traversal/src/main/resources/etc/appprops/aaiEventDMaaPPublisher.properties b/aai-traversal/src/main/resources/etc/appprops/aaiEventDMaaPPublisher.properties
index 4aa7445..3258623 100644
--- a/aai-traversal/src/main/resources/etc/appprops/aaiEventDMaaPPublisher.properties
+++ b/aai-traversal/src/main/resources/etc/appprops/aaiEventDMaaPPublisher.properties
@@ -1,4 +1,32 @@
+# Start of Internal Specific Properties
+TransportType=DME2
+Latitude=39.099727
+Longitude=-94.578567
+Version=1.0
+ServiceName=dmaap-v1.dev.dmaap.dt.saat.acsi.att.com/events
+Environment=TEST
+routeOffer=MR1SBKCD
+Partner=KC_R
+SubContextPath=/
Protocol=http
+MethodType=POST
+username=m08479@aai.ecomp.att.com
+password=OBF:1wfm1z0h18xp1z0f1r411y7z1r3x1z0f18xt1z0d1wgc
contenttype=application/json
-host=localhost:3904
+host=klsd056.ipcoe.att.com:3904
+AFT_DME2_EXCHANGE_REQUEST_HANDLERS=com.att.nsa.test.PreferredRouteRequestHandler
+AFT_DME2_EXCHANGE_REPLY_HANDLERS=com.att.nsa.test.PreferredRouteReplyHandler
+AFT_DME2_REQ_TRACE_ON=true
+AFT_ENVIRONMENT=AFTUAT
+AFT_DME2_EP_CONN_TIMEOUT=10000
+AFT_DME2_ROUNDTRIP_TIMEOUT_MS=180000
+AFT_DME2_EP_READ_TIMEOUT_MS=50000
+DME2_REPLY_HANDLER_TIMEOUT_MS=180000
+DME2_PER_HANDLER_TIMEOUT_MS=180000
+sessionstickinessrequired=NO
+MessageSentThreadOccurance=50
+# End of Internal Specific Properties
topic=AAI-EVENT
+partition=AAI
+maxBatchSize=100
+maxAgeMs=250
diff --git a/aai-traversal/src/main/resources/etc/appprops/aaiconfig.properties b/aai-traversal/src/main/resources/etc/appprops/aaiconfig.properties
index 776ee4b..1a0c337 100644
--- a/aai-traversal/src/main/resources/etc/appprops/aaiconfig.properties
+++ b/aai-traversal/src/main/resources/etc/appprops/aaiconfig.properties
@@ -2,7 +2,7 @@
# ============LICENSE_START=======================================================
# org.onap.aai
# ================================================================================
-# Copyright © 2017 AT&T Intellectual Property. All rights reserved.
+# Copyright © 2017-18 AT&T Intellectual Property. All rights reserved.
# ================================================================================
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
@@ -17,67 +17,23 @@
# limitations under the License.
# ============LICENSE_END=========================================================
#
-# ECOMP is a trademark and service mark of AT&T Intellectual Property.
-#
####################################################################
# REMEMBER TO THINK ABOUT ENVIRONMENTAL DIFFERENCES AND CHANGE THE
# TEMPLATE AND *ALL* DATAFILES
####################################################################
-aai.config.checktime=1000
-
# this could come from siteconfig.pl?
aai.config.nodename=AutomaticallyOverwritten
-aai.logging.hbase.interceptor=true
-aai.logging.hbase.enabled=true
-aai.logging.hbase.logrequest=true
-aai.logging.hbase.logresponse=true
-
-aai.logging.trace.enabled=true
-aai.logging.trace.logrequest=false
-aai.logging.trace.logresponse=false
-
aai.transaction.logging=true
aai.transaction.logging.get=true
aai.transaction.logging.post=true
-aai.tools.enableBasicAuth=true
-aai.tools.username=AAI
-aai.tools.password=AAI
-
aai.server.url.base=https://localhost:8443/aai/
aai.server.url=https://localhost:8443/aai/v14/
aai.global.callback.url=https://localhost:8443/aai/
-aai.auth.cspcookies_on=false
-aai.dbmodel.filename=ex5.json
-aai.truststore.filename=aai_keystore
-aai.truststore.passwd.x=OBF:1vn21ugu1saj1v9i1v941sar1ugw1vo0
-aai.keystore.filename=aai-client-cert.p12
-aai.keystore.passwd.x=
-
-# for transaction log
-hbase.table.name=aailogging-dev1.dev
-hbase.notificationTable.name=aainotification-dev1.dev
-hbase.table.timestamp.format=YYYYMMdd-HH:mm:ss:SSS
-hbase.zookeeper.quorum=ONAPserverTBD
-hbase.zookeeper.property.clientPort=2181
-hbase.zookeeper.znode.parent=/hbase
-
-
-# single primary server
-aai.primary.filetransfer.serverlist=ONAPserverTBD
-aai.primary.filetransfer.primarycheck=echo:8443/aai/util/echo
-aai.primary.filetransfer.pingtimeout=5000
-aai.primary.filetransfer.pingcount=5
-
-#rsync properties
-aai.rsync.command=rsync
-aai.rsync.options.list=-v|-t
-aai.rsync.remote.user=aaiadmin
-aai.rsync.enabled=y
aai.notification.current.version=v14
aai.notificationEvent.default.status=UNPROCESSED
@@ -89,32 +45,37 @@ aai.notificationEvent.default.severity=NORMAL
aai.notificationEvent.default.version=v14
# This one lets us enable/disable resource-version checking on updates/deletes
aai.resourceversion.enableflag=true
+# This will specify how deep the stack trace should be logged
aai.logging.maxStackTraceEntries=10
aai.default.api.version=v14
# Used by Model-processing code
-aai.model.delete.sleep.per.vtx.msec=500
aai.model.query.resultset.maxcount=50
aai.model.query.timeout.sec=90
-aai.model.proc.max.levels=50
-aai.edgeTag.proc.max.levels=50
-
-aai.dmaap.workload.enableEventProcessing=true
-
-aai.realtime.clients=RO,SDNC,MSO,SO
-
-aai.server.rebind=g
-
aai.jms.enable=false
#timeout for traversal enabled flag
aai.traversal.timeoutenabled=true
-
-#timeout app specific
-aai.traversal.timeout.appspecific=JUNITTESTAPP1,1|JUNITTESTAPP2,-1|DCAE-CCS,-1|DCAES,-1|AAI-FILEGEN-GFPIP,-1
+aai.traversal.dsl.timeoutenabled=true
+#timeout app specific -1 to bypass for that app id, a whole number to override the timeout with that value (in ms)
+aai.traversal.timeout.appspecific=JUNITTESTAPP1,1|JUNITTESTAPP2,-1|DCAE-CCS,-1|DCAES,-1|AAI-FILEGEN-GFPIP,-1|FitNesse-Test-PS2418,-1|FitNesse-Test-jenkins,-1|FitNesse-Test-ps2418,-1|FitNesse-Relationship-Test-PS2418,-1|FitNesse-Relationship-Test-ps2418,-1|FitNesse-Relationship-Test-jenkins,-1|VPESAT,-1|AAIRctFeed,-1|NewvceCreator,-1|IANewvceCreator,-1|AAI-CSIOVALS,-1
+aai.traversal.dsl.timeout.appspecific=JUNITTESTAPP1,1|JUNITTESTAPP2,-1|DCAE-CCS,-1|DCAES,-1|AAI-FILEGEN-GFPIP,-1|FitNesse-Test-PS2418,-1|FitNesse-Test-jenkins,-1|FitNesse-Test-ps2418,-1|FitNesse-Relationship-Test-PS2418,-1|FitNesse-Relationship-Test-ps2418,-1|FitNesse-Relationship-Test-jenkins,-1|VPESAT,-1|AAIRctFeed,-1|NewvceCreator,-1|IANewvceCreator,-1|AAI-CSIOVALS,-1
#default timeout limit added for traversal if not overridden (in ms)
aai.traversal.timeoutlimit=180000
+aai.traversal.dsl.timeoutlimit=180000
+
+# Start of INTERNAL Specific Properties
+
+aai.truststore.filename=tomcat_keystore
+aai.truststore.passwd.x=OBF:1i9a1u2a1unz1lr61wn51wn11lss1unz1u301i6o
+aai.keystore.filename=aai-client-cert.p12
+aai.keystore.passwd.x=OBF:1i9a1u2a1unz1lr61wn51wn11lss1unz1u301i6o
+
+aai.realtime.clients=RO,SDNC,MSO
+aai.aic25.cloudregion.owner=attaic
+aai.aic25.cloudregion.id=AAIAIC25
+# End of INTERNAL Specific Properties
diff --git a/aai-traversal/src/main/resources/etc/appprops/default-logback.xml b/aai-traversal/src/main/resources/etc/appprops/default-logback.xml
deleted file mode 100644
index 655157b..0000000
--- a/aai-traversal/src/main/resources/etc/appprops/default-logback.xml
+++ /dev/null
@@ -1,43 +0,0 @@
-<!--
-
- ============LICENSE_START=======================================================
- org.onap.aai
- ================================================================================
- Copyright © 2017 AT&T Intellectual Property. All rights reserved.
- ================================================================================
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
- ============LICENSE_END=========================================================
-
- ECOMP is a trademark and service mark of AT&T Intellectual Property.
-
--->
-<configuration debug="false">
- <property name="defaultPattern" value="%d{MM/dd-HH:mm:ss.SSS}|%logger|%X{RequestId}|%X{ServiceInstanceId}|%thread|%X{ServiceName}|%X{InstanceUUID}|%.-5level|%X{AlertSeverity}|%X{ServerIPAddress}|%X{ServerFQDN}|%X{RemoteHost}|%X{Timer}|%msg%n" />
-
- <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
- <encoder>
- <pattern>${defaultPattern}</pattern>
- </encoder>
- </appender>
-
- <logger name="org.reflections" level="WARN"/>
- <logger name="org.apache.zookeeper" level="WARN"/>
- <logger name="org.apache.hadoop" level="WARN"/>
- <logger name="com.thinkaurelius" level="WARN"/>
- <logger name="ch.qos.logback.classic" level="WARN" />
- <logger name="ch.qos.logback.core" level="WARN" />
-
- <root level="INFO">
- <appender-ref ref="STDOUT"/>
- </root>
-</configuration>
diff --git a/aai-traversal/src/main/resources/etc/appprops/error.properties b/aai-traversal/src/main/resources/etc/appprops/error.properties
index d25a2bf..d1e39cc 100644
--- a/aai-traversal/src/main/resources/etc/appprops/error.properties
+++ b/aai-traversal/src/main/resources/etc/appprops/error.properties
@@ -32,6 +32,11 @@ AAI_3011=5:6:WARN:3011:400:3000:Unknown XML namespace used in payload
AAI_3012=5:6:WARN:3012:400:3012:Unrecognized AAI function
AAI_3013=5:6:WARN:3013:400:3013:Query payload missing required parameters %1
AAI_3014=5:6:WARN:3014:400:3014:Query payload is invalid %1
+AAI_3018=5:6:WARN:3018:400:3018:Query URI missing required parameters
+AAI_3019=5:6:WARN:3019:400:3019:Query URI sending conflicting parameters
+AAI_3020=5:6:WARN:3020:400:3020:Query URI parameters outside bounds
+AAI_3021=5:6:WARN:3021:400:3021:Invalid parameters to Recents API
+
# pol errors
AAI_3100=5:1:WARN:3100:400:3100:Unsupported operation %1
AAI_3101=5:1:WARN:3101:403:3101:Attempt by client %1 to execute API %2
@@ -112,6 +117,7 @@ AAI_6144=5:4:WARN:6144:400:3000:Cycle found in graph
AAI_6145=5:4:ERROR:6145:400:3000:Cannot create a nested/containment edge via relationship
AAI_6146=5:4:ERROR:6146:400:3000:Ambiguous identity map found, use a URI instead
AAI_6147=5:4:ERROR:6147:400:3000:Payload Limit Reached, reduce payload
+AAI_6148=5:4:INFO:6148:404:3001:Node Not Found. Start URI returned no vertexes, please check the start URI
#--- aaicsvp: 7101-7199
AAI_7101=5:4:ERROR:7101:500:3002:Unexpected error in CSV file processing
@@ -138,7 +144,6 @@ AAI_7119=5:4:ERROR:7119:500:3002:Unknown host
AAI_7202=5:4:ERROR:7202:500:3002:Error getting connection to odl
AAI_7203=5:4:ERROR:7203:500:3002:Unexpected error calling DataChangeNotification API
AAI_7204=5:4:ERROR:7204:500:3002:Error returned by DataChangeNotification API
-AAI_7205=5:4:ERROR:7205:500:3002:Unexpected error running notifySDNCOnUpdate
#AAI_7206=5:4:ERROR:7206:500:3002:Invalid data returned from ODL
#--- NotificationEvent, using UEB space
@@ -170,3 +175,8 @@ AAI_9107=5:0:WARN:9107:403:3300:SSL is not provided in request, please contact a
#--- aaiinstar: 9201-9299
#AAI_9201=5:4:ERROR:9201:500:3002:Unable to send notification
AAI_9202=5:4:ERROR:9202:500:3002:Unable to start a thread
+#--- GRM DME2: 9501-9599
+AAI_9501=5:4:WARN:9501:500:3002:Unable to register with GRM retrying
+AAI_9502=5:4:ERROR:9502:500:3002:Unable to register with GRM after exhausting all retries
+AAI_9503=5:4:WARN:9503:500:3002:Unable to successfully unpublish with GRM, recommend manual cleanup but not necessary
+
diff --git a/aai-traversal/src/main/resources/etc/appprops/gremlin-server-config.yaml b/aai-traversal/src/main/resources/etc/appprops/gremlin-server-config.yaml
deleted file mode 100644
index a9de31f..0000000
--- a/aai-traversal/src/main/resources/etc/appprops/gremlin-server-config.yaml
+++ /dev/null
@@ -1,25 +0,0 @@
-#
-# ============LICENSE_START=======================================================
-# org.onap.aai
-# ================================================================================
-# Copyright © 2017 AT&T Intellectual Property. All rights reserved.
-# ================================================================================
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-# ============LICENSE_END=========================================================
-#
-# ECOMP is a trademark and service mark of AT&T Intellectual Property.
-#
-
-hosts: [localhost]
-port: 8182
-serializer: { className: org.apache.tinkerpop.gremlin.driver.ser.GraphSONMessageSerializerV1d0 } \ No newline at end of file
diff --git a/aai-traversal/src/main/resources/etc/appprops/janusgraph-cached.properties b/aai-traversal/src/main/resources/etc/appprops/janusgraph-cached.properties
index aecea7c..9f85c8e 100644
--- a/aai-traversal/src/main/resources/etc/appprops/janusgraph-cached.properties
+++ b/aai-traversal/src/main/resources/etc/appprops/janusgraph-cached.properties
@@ -2,7 +2,7 @@
# ============LICENSE_START=======================================================
# org.onap.aai
# ================================================================================
-# Copyright © 2017 AT&T Intellectual Property. All rights reserved.
+# Copyright © 2017-18 AT&T Intellectual Property. All rights reserved.
# ================================================================================
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
@@ -16,20 +16,12 @@
# See the License for the specific language governing permissions and
# limitations under the License.
# ============LICENSE_END=========================================================
-#
-# ECOMP is a trademark and service mark of AT&T Intellectual Property.
-#
query.fast-property=true
-query.smart-limit=false
# the following parameters are not reloaded automatically and require a manual bounce
-#storage.backend=inmemory
storage.backend=inmemory
storage.hostname=localhost
-#explicit Titan version in use - added for JanusGraph migration
-#graph.titan-version=1.0.0
-
#schema.default=none
storage.lock.wait-time=300
storage.hbase.table=aaigraph-dev02
diff --git a/aai-traversal/src/main/resources/etc/appprops/janusgraph-realtime.properties b/aai-traversal/src/main/resources/etc/appprops/janusgraph-realtime.properties
index 9e64ac2..f938182 100644
--- a/aai-traversal/src/main/resources/etc/appprops/janusgraph-realtime.properties
+++ b/aai-traversal/src/main/resources/etc/appprops/janusgraph-realtime.properties
@@ -2,7 +2,7 @@
# ============LICENSE_START=======================================================
# org.onap.aai
# ================================================================================
-# Copyright © 2017 AT&T Intellectual Property. All rights reserved.
+# Copyright © 2017-18 AT&T Intellectual Property. All rights reserved.
# ================================================================================
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
@@ -16,20 +16,12 @@
# See the License for the specific language governing permissions and
# limitations under the License.
# ============LICENSE_END=========================================================
-#
-# ECOMP is a trademark and service mark of AT&T Intellectual Property.
-#
query.fast-property=true
-query.smart-limit=false
# the following parameters are not reloaded automatically and require a manual bounce
-#storage.backend=inmemory
storage.backend=inmemory
storage.hostname=localhost
-#explicit Titan version in use - added for JanusGraph migration
-#graph.titan-version=1.0.0
-
#schema.default=none
storage.lock.wait-time=300
storage.hbase.table=aaigraph-dev02
diff --git a/aai-traversal/src/main/resources/etc/appprops/methodMapper.properties b/aai-traversal/src/main/resources/etc/appprops/methodMapper.properties
deleted file mode 100644
index d6c1158..0000000
--- a/aai-traversal/src/main/resources/etc/appprops/methodMapper.properties
+++ /dev/null
@@ -1,24 +0,0 @@
-{
- "ActiveAndAvailableInventory-Traversal" : [{
- "logicalName" : "getAAIResource",
- "method" : "get",
- "url" : "/aai/*"
- }, {
- "logicalName" : "putAAIResource",
- "method" : "put",
- "url" : "/aai/*"
- }, {
- "logicalName" : "deleteAAIResource",
- "method" : "delete",
- "url" : "/aai/*"
- }, {
- "logicalName" : "postAAIResource",
- "method" : "post",
- "url" : "/aai/*"
- }, {
- "logicalName" : "patchAAIResource",
- "method" : "patch",
- "url" : "/aai/*"
- }
- ]
-} \ No newline at end of file
diff --git a/aai-traversal/src/main/resources/etc/appprops/preferredRoute.txt b/aai-traversal/src/main/resources/etc/appprops/preferredRoute.txt
deleted file mode 100644
index 662b0aa..0000000
--- a/aai-traversal/src/main/resources/etc/appprops/preferredRoute.txt
+++ /dev/null
@@ -1 +0,0 @@
-preferredRouteKey=MR1 \ No newline at end of file
diff --git a/aai-traversal/src/main/resources/etc/scriptdata/named-query-json/getClfiRoadmTailSummary-1.0.json b/aai-traversal/src/main/resources/etc/scriptdata/named-query-json/getClfiRoadmTailSummary-1.0.json
index a30e797..771197f 100644
--- a/aai-traversal/src/main/resources/etc/scriptdata/named-query-json/getClfiRoadmTailSummary-1.0.json
+++ b/aai-traversal/src/main/resources/etc/scriptdata/named-query-json/getClfiRoadmTailSummary-1.0.json
@@ -1,94 +1,94 @@
-{
- "named-query-uuid" : "4f448e43-339f-4c1c-85f6-896c444e25ca",
- "named-query-name" : "GetClfiRoadmTailSummary",
- "named-query-version" : "1.0",
- "description" : "Named query - Get CLFI ROADM Tail Summary",
- "named-query-elements" : {
- "named-query-element" : [ {
- "named-query-elements" : {
- "named-query-element" : [ {
- "named-query-elements" : {
- "named-query-element" : [ {
- "relationship-list" : {
- "relationship" : [ {
- "related-to" : "model",
- "relationship-data" : [ {
- "relationship-key" : "model.model-invariant-id",
- "relationship-value" : "862b25a1-262a-4961-bdaa-cdc55d69785a"
- } ]
- } ]
- }
- } ]
- },
- "relationship-list" : {
- "relationship" : [ {
- "related-to" : "model",
- "relationship-data" : [ {
- "relationship-key" : "model.model-invariant-id",
- "relationship-value" : "94043c37-4e73-439c-a790-0fdd697924cd"
- } ]
- } ]
- }
- }, {
- "named-query-elements" : {
- "named-query-element" : [ {
- "named-query-elements" : {
- "named-query-element" : [ {
- "named-query-elements" : {
- "named-query-element" : [ {
- "relationship-list" : {
- "relationship" : [ {
- "related-to" : "model",
- "relationship-data" : [ {
- "relationship-key" : "model.model-invariant-id",
- "relationship-value" : "c1d4305f-cdbd-4bbe-9069-a2f4978fd89e"
- } ]
- } ]
- }
- } ]
- },
- "relationship-list" : {
- "relationship" : [ {
- "related-to" : "model",
- "relationship-data" : [ {
- "relationship-key" : "model.model-invariant-id",
- "relationship-value" : "2e1a602a-acd8-4f78-94ff-618b802a303b"
- } ]
- } ]
- }
- } ]
- },
- "relationship-list" : {
- "relationship" : [ {
- "related-to" : "model",
- "relationship-data" : [ {
- "relationship-key" : "model.model-invariant-id",
- "relationship-value" : "82194af1-3c2c-485a-8f44-420e22a9eaa4"
- } ]
- } ]
- }
- } ]
- },
- "relationship-list" : {
- "relationship" : [ {
- "related-to" : "model",
- "relationship-data" : [ {
- "relationship-key" : "model.model-invariant-id",
- "relationship-value" : "fe012535-2c31-4a39-a739-612374c638a0"
- } ]
- } ]
- }
- } ]
- },
- "relationship-list" : {
- "relationship" : [ {
- "related-to" : "model",
- "relationship-data" : [ {
- "relationship-key" : "model.model-invariant-id",
- "relationship-value" : "fe012535-2c31-4a39-a739-612374c638a0"
- } ]
- } ]
- }
- } ]
- }
+{
+ "named-query-uuid" : "4f448e43-339f-4c1c-85f6-896c444e25ca",
+ "named-query-name" : "GetClfiRoadmTailSummary",
+ "named-query-version" : "1.0",
+ "description" : "Named query - Get CLFI ROADM Tail Summary",
+ "named-query-elements" : {
+ "named-query-element" : [ {
+ "named-query-elements" : {
+ "named-query-element" : [ {
+ "named-query-elements" : {
+ "named-query-element" : [ {
+ "relationship-list" : {
+ "relationship" : [ {
+ "related-to" : "model",
+ "relationship-data" : [ {
+ "relationship-key" : "model.model-invariant-id",
+ "relationship-value" : "862b25a1-262a-4961-bdaa-cdc55d69785a"
+ } ]
+ } ]
+ }
+ } ]
+ },
+ "relationship-list" : {
+ "relationship" : [ {
+ "related-to" : "model",
+ "relationship-data" : [ {
+ "relationship-key" : "model.model-invariant-id",
+ "relationship-value" : "94043c37-4e73-439c-a790-0fdd697924cd"
+ } ]
+ } ]
+ }
+ }, {
+ "named-query-elements" : {
+ "named-query-element" : [ {
+ "named-query-elements" : {
+ "named-query-element" : [ {
+ "named-query-elements" : {
+ "named-query-element" : [ {
+ "relationship-list" : {
+ "relationship" : [ {
+ "related-to" : "model",
+ "relationship-data" : [ {
+ "relationship-key" : "model.model-invariant-id",
+ "relationship-value" : "c1d4305f-cdbd-4bbe-9069-a2f4978fd89e"
+ } ]
+ } ]
+ }
+ } ]
+ },
+ "relationship-list" : {
+ "relationship" : [ {
+ "related-to" : "model",
+ "relationship-data" : [ {
+ "relationship-key" : "model.model-invariant-id",
+ "relationship-value" : "2e1a602a-acd8-4f78-94ff-618b802a303b"
+ } ]
+ } ]
+ }
+ } ]
+ },
+ "relationship-list" : {
+ "relationship" : [ {
+ "related-to" : "model",
+ "relationship-data" : [ {
+ "relationship-key" : "model.model-invariant-id",
+ "relationship-value" : "82194af1-3c2c-485a-8f44-420e22a9eaa4"
+ } ]
+ } ]
+ }
+ } ]
+ },
+ "relationship-list" : {
+ "relationship" : [ {
+ "related-to" : "model",
+ "relationship-data" : [ {
+ "relationship-key" : "model.model-invariant-id",
+ "relationship-value" : "fe012535-2c31-4a39-a739-612374c638a0"
+ } ]
+ } ]
+ }
+ } ]
+ },
+ "relationship-list" : {
+ "relationship" : [ {
+ "related-to" : "model",
+ "relationship-data" : [ {
+ "relationship-key" : "model.model-invariant-id",
+ "relationship-value" : "fe012535-2c31-4a39-a739-612374c638a0"
+ } ]
+ } ]
+ }
+ } ]
+ }
} \ No newline at end of file
diff --git a/aai-traversal/src/main/resources/etc/scriptdata/named-query-json/getRouterRoadmTailSummary-1.0.json b/aai-traversal/src/main/resources/etc/scriptdata/named-query-json/getRouterRoadmTailSummary-1.0.json
index 6f775e8..27e198d 100644
--- a/aai-traversal/src/main/resources/etc/scriptdata/named-query-json/getRouterRoadmTailSummary-1.0.json
+++ b/aai-traversal/src/main/resources/etc/scriptdata/named-query-json/getRouterRoadmTailSummary-1.0.json
@@ -1,120 +1,120 @@
-{
- "named-query-uuid" : "cbf22b8a-f29a-4b9b-a466-a878095b258a",
- "named-query-name" : "GetRouterRoadmTailSummary",
- "named-query-version" : "1.0",
- "description" : "Named query - Get Router ROADM Tail Summary",
- "named-query-elements" : {
- "named-query-element" : [ {
- "named-query-elements" : {
- "named-query-element" : [ {
- "named-query-elements" : {
- "named-query-element" : [ {
- "named-query-elements" : {
- "named-query-element" : [ {
- "named-query-elements" : {
- "named-query-element" : [ {
- "relationship-list" : {
- "relationship" : [ {
- "related-to" : "model",
- "relationship-data" : [ {
- "relationship-key" : "model.model-invariant-id",
- "relationship-value" : "862b25a1-262a-4961-bdaa-cdc55d69785a"
- } ]
- } ]
- }
- } ]
- },
- "relationship-list" : {
- "relationship" : [ {
- "related-to" : "model",
- "relationship-data" : [ {
- "relationship-key" : "model.model-invariant-id",
- "relationship-value" : "94043c37-4e73-439c-a790-0fdd697924cd"
- } ]
- } ]
- }
- }, {
- "named-query-elements" : {
- "named-query-element" : [ {
- "named-query-elements" : {
- "named-query-element" : [ {
- "named-query-elements" : {
- "named-query-element" : [ {
- "relationship-list" : {
- "relationship" : [ {
- "related-to" : "model",
- "relationship-data" : [ {
- "relationship-key" : "model.model-invariant-id",
- "relationship-value" : "c1d4305f-cdbd-4bbe-9069-a2f4978fd89e"
- } ]
- } ]
- }
- } ]
- },
- "relationship-list" : {
- "relationship" : [ {
- "related-to" : "model",
- "relationship-data" : [ {
- "relationship-key" : "model.model-invariant-id",
- "relationship-value" : "2e1a602a-acd8-4f78-94ff-618b802a303b"
- } ]
- } ]
- }
- } ]
- },
- "relationship-list" : {
- "relationship" : [ {
- "related-to" : "model",
- "relationship-data" : [ {
- "relationship-key" : "model.model-invariant-id",
- "relationship-value" : "82194af1-3c2c-485a-8f44-420e22a9eaa4"
- } ]
- } ]
- }
- } ]
- },
- "relationship-list" : {
- "relationship" : [ {
- "related-to" : "model",
- "relationship-data" : [ {
- "relationship-key" : "model.model-invariant-id",
- "relationship-value" : "fe012535-2c31-4a39-a739-612374c638a0"
- } ]
- } ]
- }
- } ]
- },
- "relationship-list" : {
- "relationship" : [ {
- "related-to" : "model",
- "relationship-data" : [ {
- "relationship-key" : "model.model-invariant-id",
- "relationship-value" : "fe012535-2c31-4a39-a739-612374c638a0"
- } ]
- } ]
- }
- } ]
- },
- "relationship-list" : {
- "relationship" : [ {
- "related-to" : "model",
- "relationship-data" : [ {
- "relationship-key" : "model.model-invariant-id",
- "relationship-value" : "94043c37-4e73-439c-a790-0fdd697924cd"
- } ]
- } ]
- }
- } ]
- },
- "relationship-list" : {
- "relationship" : [ {
- "related-to" : "model",
- "relationship-data" : [ {
- "relationship-key" : "model.model-invariant-id",
- "relationship-value" : "862b25a1-262a-4961-bdaa-cdc55d69785a"
- } ]
- } ]
- }
- } ]
- }
+{
+ "named-query-uuid" : "cbf22b8a-f29a-4b9b-a466-a878095b258a",
+ "named-query-name" : "GetRouterRoadmTailSummary",
+ "named-query-version" : "1.0",
+ "description" : "Named query - Get Router ROADM Tail Summary",
+ "named-query-elements" : {
+ "named-query-element" : [ {
+ "named-query-elements" : {
+ "named-query-element" : [ {
+ "named-query-elements" : {
+ "named-query-element" : [ {
+ "named-query-elements" : {
+ "named-query-element" : [ {
+ "named-query-elements" : {
+ "named-query-element" : [ {
+ "relationship-list" : {
+ "relationship" : [ {
+ "related-to" : "model",
+ "relationship-data" : [ {
+ "relationship-key" : "model.model-invariant-id",
+ "relationship-value" : "862b25a1-262a-4961-bdaa-cdc55d69785a"
+ } ]
+ } ]
+ }
+ } ]
+ },
+ "relationship-list" : {
+ "relationship" : [ {
+ "related-to" : "model",
+ "relationship-data" : [ {
+ "relationship-key" : "model.model-invariant-id",
+ "relationship-value" : "94043c37-4e73-439c-a790-0fdd697924cd"
+ } ]
+ } ]
+ }
+ }, {
+ "named-query-elements" : {
+ "named-query-element" : [ {
+ "named-query-elements" : {
+ "named-query-element" : [ {
+ "named-query-elements" : {
+ "named-query-element" : [ {
+ "relationship-list" : {
+ "relationship" : [ {
+ "related-to" : "model",
+ "relationship-data" : [ {
+ "relationship-key" : "model.model-invariant-id",
+ "relationship-value" : "c1d4305f-cdbd-4bbe-9069-a2f4978fd89e"
+ } ]
+ } ]
+ }
+ } ]
+ },
+ "relationship-list" : {
+ "relationship" : [ {
+ "related-to" : "model",
+ "relationship-data" : [ {
+ "relationship-key" : "model.model-invariant-id",
+ "relationship-value" : "2e1a602a-acd8-4f78-94ff-618b802a303b"
+ } ]
+ } ]
+ }
+ } ]
+ },
+ "relationship-list" : {
+ "relationship" : [ {
+ "related-to" : "model",
+ "relationship-data" : [ {
+ "relationship-key" : "model.model-invariant-id",
+ "relationship-value" : "82194af1-3c2c-485a-8f44-420e22a9eaa4"
+ } ]
+ } ]
+ }
+ } ]
+ },
+ "relationship-list" : {
+ "relationship" : [ {
+ "related-to" : "model",
+ "relationship-data" : [ {
+ "relationship-key" : "model.model-invariant-id",
+ "relationship-value" : "fe012535-2c31-4a39-a739-612374c638a0"
+ } ]
+ } ]
+ }
+ } ]
+ },
+ "relationship-list" : {
+ "relationship" : [ {
+ "related-to" : "model",
+ "relationship-data" : [ {
+ "relationship-key" : "model.model-invariant-id",
+ "relationship-value" : "fe012535-2c31-4a39-a739-612374c638a0"
+ } ]
+ } ]
+ }
+ } ]
+ },
+ "relationship-list" : {
+ "relationship" : [ {
+ "related-to" : "model",
+ "relationship-data" : [ {
+ "relationship-key" : "model.model-invariant-id",
+ "relationship-value" : "94043c37-4e73-439c-a790-0fdd697924cd"
+ } ]
+ } ]
+ }
+ } ]
+ },
+ "relationship-list" : {
+ "relationship" : [ {
+ "related-to" : "model",
+ "relationship-data" : [ {
+ "relationship-key" : "model.model-invariant-id",
+ "relationship-value" : "862b25a1-262a-4961-bdaa-cdc55d69785a"
+ } ]
+ } ]
+ }
+ } ]
+ }
} \ No newline at end of file
diff --git a/aai-traversal/src/main/resources/etc/sysprops/sys-props.properties b/aai-traversal/src/main/resources/etc/sysprops/sys-props.properties
deleted file mode 100644
index 44d58d5..0000000
--- a/aai-traversal/src/main/resources/etc/sysprops/sys-props.properties
+++ /dev/null
@@ -1,140 +0,0 @@
-#This file is used for defining AJSC system properties for different configuration schemes and is necessary for the AJSC to run properly.
-#The sys-props.properties file is used for running locally. The template.sys-props.properties file will be used when deployed
-#to a SOA/CSI Cloud node.
-
-#AJSC System Properties. The following properties are required for ALL AJSC services. If you are adding System Properties for your
-#particular service, please add them AFTER all AJSC related System Properties.
-
-#For Cadi Authorization, use value="authentication-scheme-1
-CadiAuthN=authentication-scheme-1
-
-#For Basic Authorization, use value="authentication-scheme-1
-authN=authentication-scheme-2
-
-#Persistence used for AJSC meta-data storage. For most environments, "file" should be used.
-ajscPersistence=file
-
-# If using hawtio for local development, these properties will allow for faster server startup and usage for local development
-hawtio.authenticationEnabled=false
-hawtio.config.pullOnStartup=false
-
-#Removes the extraneous restlet console output
-org.restlet.engine.loggerFacadeClass=org.restlet.ext.slf4j.Slf4jLoggerFacade
-
-#server.host property to be enabled for local DME2 related testing
-#server.host=<Your network IP address>
-
-#Enable/disable SSL (values=true/false). This property also determines which protocol to use (https if true, http otherwise), to register services into GRM through DME2.
-enableSSL=false
-
-#Enable/disable csi logging (values=true/false). This can be disabled during local development
-csiEnable=false
-
-#Enable/disable EJB Container
-ENABLE_EJB=false
-
-#Enable/disable OSGI
-isOSGIEnable=false
-
-#Configure JMS Queue (WMQ/TIBCO)
-JMS_BROKER=WMQ
-
-#JMS properties needed for CSI Logging
-JMS_TIBCO_PROVIDER_URL=ONAPserverTBD
-JMS_LOGGER_USER_NAME=spm2
-JMS_LOGGER_PASSWORD=its4test
-JMS_LOGGER_AUDIT_QUEUE_BINDING=pub.m2e.audit.logger.queue
-JMS_LOGGER_PERF_QUEUE_BINDING=log.csi.performance02
-
-#WMQ connectivity
-JMS_WMQ_PROVIDER_URL=aftdsc://AFTUAT/34.07/-84.28
-JMS_WMQ_CONNECTION_FACTORY_NAME=aftdsc://AFTUAT/?service=CSILOG,version=1.0,bindingType=fusionBus,envContext=Q,Q25A=YES
-JMS_WMQ_INITIAL_CONNECTION_FACTORY_NAME=com.att.aft.jms.FusionCtxFactory
-JMS_WMQ_AUDIT_DESTINATION_NAME=queue:///CSILOGQL.M2E.DASHBOARD01.NOT.Q25A
-JMS_WMQ_PERF_DESTINATION_NAME=queue:///CSILOGQL.M2E.PERFORMANCE01.NOT.Q25A
-
-
-#CSI related variables for CSM framework
-csm.hostname=d1a-m2e-q112m2e1.edc.cingular.net
-
-#Enable/disable endpoint level logging (values=true/false). This can be disabled during local development
-endpointLogging=false
-
-#SOA_CLOUD_ENV is used to register your service with dme2 and can be turned off for local development (values=true/false).
-SOA_CLOUD_ENV=false
-
-#CONTINUE_ON_LISTENER_EXCEPTION will exit the application if there is a DME2 exception at the time of registration.
-CONTINUE_ON_LISTENER_EXCEPTION=false
-
-#Jetty Container ThreadCount Configuration Variables
-AJSC_JETTY_ThreadCount_MIN=10
-AJSC_JETTY_ThreadCount_MAX=500
-AJSC_JETTY_IDLETIME_MAX=60000
-AJSC_JETTY_BLOCKING_QUEUE_SIZE=100
-
-#Camel Context level default threadPool Profile configuration
-CAMEL_POOL_SIZE=10
-CAMEL_MAX_POOL_SIZE=20
-CAMEL_KEEP_ALIVE_TIME=60
-CAMEL_MAX_QUEUE_SIZE=1000
-
-#File Monitor configurations
-ssf_filemonitor_polling_interval=5
-ssf_filemonitor_threadpool_size=10
-
-#GRM/DME2 System Properties
-AFT_DME2_CONN_IDLE_TIMEOUTMS=5000
-AJSC_ENV=SOACLOUD
-
-SOACLOUD_NAMESPACE=com.att.ajsc
-SOACLOUD_ENV_CONTEXT=DEV
-SOACLOUD_PROTOCOL=http
-SOACLOUD_ROUTE_OFFER=DEFAULT
-
-sslport=8446
-server.port=8083
-
-AFT_LATITUDE=23.4
-AFT_LONGITUDE=33.6
-AFT_ENVIRONMENT=AFTUAT
-
-#Restlet Component Default Properties
-RESTLET_COMPONENT_CONTROLLER_DAEMON=true
-RESTLET_COMPONENT_CONTROLLER_SLEEP_TIME_MS=100
-RESTLET_COMPONENT_INBOUND_BUFFER_SIZE=8192
-RESTLET_COMPONENT_MIN_THREADS=1
-RESTLET_COMPONENT_MAX_THREADS=10
-RESTLET_COMPONENT_LOW_THREADS=8
-RESTLET_COMPONENT_MAX_QUEUED=0
-RESTLET_COMPONENT_MAX_CONNECTIONS_PER_HOST=-1
-RESTLET_COMPONENT_MAX_TOTAL_CONNECTIONS=-1
-RESTLET_COMPONENT_OUTBOUND_BUFFER_SIZE=8192
-RESTLET_COMPONENT_PERSISTING_CONNECTIONS=true
-RESTLET_COMPONENT_PIPELINING_CONNECTIONS=false
-RESTLET_COMPONENT_THREAD_MAX_IDLE_TIME_MS=60000
-RESTLET_COMPONENT_USE_FORWARDED_HEADER=false
-RESTLET_COMPONENT_REUSE_ADDRESS=true
-
-#Externalized jar and properties file location. In CSI environments, there are a few libs that have been externalized to aid
-#in CSTEM maintenance of the versions of these libs. The most important to the AJSC is the DME2 lib. Not only is this lib necessary
-#for proper registration of your AJSC service on a node, but it is also necessary for running locally as well. Another framework
-#used in CSI envs is the CSM framework. These 2 framework libs are shown as "provided" dependencies within the pom.xml. These
-#dependencies will be copied into the target/commonLibs folder with the normal "mvn clean package" goal of the AJSC. They will
-#then be added to the classpath via AJSC_EXTERNAL_LIB_FOLDERS system property. Any files (mainly property files) that need
-#to be on the classpath should be added to the AJSC_EXTERNAL_PROPERTIES_FOLDERS system property. The default scenario when
-#testing your AJSC service locally will utilize the target/commonLibs directory for DME2 and CSM related artifacts and 2
-#default csm properties files will be used for local testing with anything CSM knorelated.
-#NOTE: we are using maven-replacer-plugin to replace "(doubleUnderscore)basedir(doubleUnderscore)" with ${basedir} within the
-#target directory for running locally. Multiple folder locations can be separated by the pipe ("|") character.
-#Please, NOTE: for running locally, we are setting this system property in the antBuild/build.xml "runLocal" target and in the
-#"runAjsc" profile within the pom.xml. This is to most effectively use maven variables (${basedir}, most specifically. Therefore,
-#when running locally, the following 2 properties should be set within the profile(s) themselves.
-#Example: target/commonLibs|target/otherLibs
-#AJSC_EXTERNAL_LIB_FOLDERS=__basedir__/target/commonLibs
-#AJSC_EXTERNAL_PROPERTIES_FOLDERS=__basedir__/ajsc-shared-config/etc
-#End of AJSC System Properties
-
-#Service System Properties. Please, place any Service related System Properties below.
-KEY_STORE_PASSWORD=OBF:1vn21ugu1saj1v9i1v941sar1ugw1vo0
-KEY_MANAGER_PASSWORD=OBF:1vn21ugu1saj1v9i1v941sar1ugw1vo0
-AAI_CORE_VERSION=1.2.0-SNAPSHOT
diff --git a/aai-traversal/src/main/resources/etc/sysprops/template.sys-props.properties b/aai-traversal/src/main/resources/etc/sysprops/template.sys-props.properties
deleted file mode 100644
index c9060f9..0000000
--- a/aai-traversal/src/main/resources/etc/sysprops/template.sys-props.properties
+++ /dev/null
@@ -1,115 +0,0 @@
-#This file is used for defining AJSC system properties for different configuration schemes and is necessary for the AJSC to run properly.
-#The sys-props.properties file is used for running locally.
-
-#For Cadi Authorization, use value="authentication-scheme-1"
-CadiAuthN=__AJSC_CADI_AUTHN__
-
-#For Basic Authorization, use value="authentication-scheme-1"
-authN=__AJSC_AUTH_SCHEME__
-
-#Persistence used for AJSC meta-data storage. For most environments, "file" should be used.
-ajscPersistence=__AJSC_PERSISTENCE__
-
-#Configure externalized logback location
-logback.configurationFile=__LOGBACK_CONFIG_FILE__
-
-# If using hawtio for local development, these properties will allow for faster server startup and usage for local development.
-# You may wish to deploy hawtio.war to dev/test environments to help debugging as well, but should not be used in PROD env.
-hawtio.authenticationEnabled=__HAWTIO_AUTHENTICATION_ENABLED__
-hawtio.config.pullOnStartup=__HAWTIO_CONFIG_PULLONSTARTUP__
-
-#Removes the extraneous restlet console output
-org.restlet.engine.loggerFacadeClass=org.restlet.ext.slf4j.Slf4jLoggerFacade
-
-#Enable/disable SSL (values=true/false).
-enableSSL=__AJSC_ENABLE_SSL__
-
-#Enable/disable csi logging (values=true/false).
-csiEnable=__CSI_ENABLE__
-
-#Enable/disable EJB Container
-ENABLE_EJB=__ENABLE_EJB__
-
-#Enable/disable OSGI
-isOSGIEnable=__OSGI_ENABLE__
-
-#Configure JMS Queue (WMQ/TIBCO)
-JMS_BROKER=WMQ
-
-#JMS properties needed for CSI Logging
-JMS_TIBCO_PROVIDER_URL=ONAPserverTBD
-JMS_LOGGER_USER_NAME=spm2
-JMS_LOGGER_PASSWORD=
-JMS_LOGGER_AUDIT_QUEUE_BINDING=pub.m2e.audit.logger.queue
-JMS_LOGGER_PERF_QUEUE_BINDING=log.csi.performance02
-
-#WMQ connectivity
-JMS_WMQ_PROVIDER_URL=__JMS_WMQ_PROVIDER_URL__
-JMS_WMQ_CONNECTION_FACTORY_NAME=__JMS_WMQ_CONNECTION_FACTORY_NAME__
-JMS_WMQ_INITIAL_CONNECTION_FACTORY_NAME=__JMS_WMQ_INITIAL_CONNECTION_FACTORY_NAME__
-JMS_WMQ_AUDIT_DESTINATION_NAME=__JMS_WMQ_AUDIT_DESTINATION_NAME__
-JMS_WMQ_PERF_DESTINATION_NAME=__JMS_WMQ_PERF_DESTINATION_NAME__
-
-#CSI related variables for CSM framework
-csm.hostname=d1a-m2e-q112m2e1.edc.cingular.net
-
-#Enable/disable endpoint level logging (values=true/false).
-endpointLogging=__END_POINT_LEVEL_LOGGING__
-
-#SOA_CLOUD_ENV is used to register your service with dme2 (values=true/false).
-SOA_CLOUD_ENV=__SOA_CLOUD_ENV__
-
-#Jetty Container ThreadCount Configuration Variables
-AJSC_JETTY_ThreadCount_MAX=__AJSC_JETTY_ThreadCount_MAX__
-AJSC_JETTY_ThreadCount_MIN=__AJSC_JETTY_ThreadCount_MIN__
-AJSC_JETTY_IDLETIME_MAX=__AJSC_JETTY_IDLETIME_MAX__
-AJSC_SERVICE_NAMESPACE=ActiveAndAvailableInventory-Traversal
-AJSC_SERVICE_VERSION=__AJSC_SERVICE_VERSION__
-AJSC_JETTY_BLOCKING_QUEUE_SIZE=100
-
-#Camel Context level default threadPool Profile configuration
-CAMEL_POOL_SIZE=__CAMEL_POOL_SIZE__
-CAMEL_MAX_POOL_SIZE=__CAMEL_MAX_POOL_SIZE__
-CAMEL_KEEP_ALIVE_TIME=__CAMEL_KEEP_ALIVE_TIME__
-CAMEL_MAX_QUEUE_SIZE=__CAMEL_MAX_QUEUE_SIZE__
-
-#File Monitor configurations
-ssf_filemonitor_polling_interval=__AJSC_SSF_FILE_MONITOR_POLLING_INTERVAL__
-ssf_filemonitor_threadpool_size=__AJSC_SSF_FILE_MONITOR_THREAD_POOL_SIZE__
-
-#GRM/DME2 System Properties below
-AFT_DME2_CONN_IDLE_TIMEOUTMS=__AFT_DME2_CONN_IDLE_TIMEOUTMS__
-AJSC_ENV=__AJSC_ENV__
-SOACLOUD_NAMESPACE=__SOA_CLOUD_NAMESPACE__
-SOACLOUD_ENV_CONTEXT=__SCLD_ENV__
-SOACLOUD_PROTOCOL=__SOACLOUD_PROTOCOL__
-SOACLOUD_ROUTE_OFFER=__AAIENV__
-sslport=8446
-server.port=8083
-AFT_LATITUDE=__LATITUDE__
-AFT_LONGITUDE=__LONGITUDE__
-AFT_ENVIRONMENT=__AFT_ENVIRONMENT__
-
-#Restlet Component Properties
-RESTLET_COMPONENT_CONTROLLER_DAEMON=__RESTLET_COMPONENT_CONTROLLER_DAEMON__
-RESTLET_COMPONENT_CONTROLLER_SLEEP_TIME_MS=__RESTLET_COMPONENT_CONTROLLER_SLEEP_TIME_MS__
-RESTLET_COMPONENT_INBOUND_BUFFER_SIZE=__RESTLET_COMPONENT_INBOUND_BUFFER_SIZE__
-RESTLET_COMPONENT_MIN_THREADS=__RESTLET_COMPONENT_MIN_THREADS__
-RESTLET_COMPONENT_MAX_THREADS=__RESTLET_COMPONENT_MAX_THREADS__
-RESTLET_COMPONENT_LOW_THREADS=__RESTLET_COMPONENT_LOW_THREADS__
-RESTLET_COMPONENT_MAX_QUEUED=__RESTLET_COMPONENT_MAX_QUEUED__
-RESTLET_COMPONENT_MAX_CONNECTIONS_PER_HOST=__RESTLET_COMPONENT_MAX_CONNECTIONS_PER_HOST__
-RESTLET_COMPONENT_MAX_TOTAL_CONNECTIONS=__RESTLET_COMPONENT_MAX_TOTAL_CONNECTIONS__
-RESTLET_COMPONENT_OUTBOUND_BUFFER_SIZE=__RESTLET_COMPONENT_OUTBOUND_BUFFER_SIZE__
-RESTLET_COMPONENT_PERSISTING_CONNECTIONS=__RESTLET_COMPONENT_PERSISTING_CONNECTIONS__
-RESTLET_COMPONENT_PIPELINING_CONNECTIONS=__RESTLET_COMPONENT_PIPELINING_CONNECTIONS__
-RESTLET_COMPONENT_THREAD_MAX_IDLE_TIME_MS=__RESTLET_COMPONENT_THREAD_MAX_IDLE_TIME_MS__
-RESTLET_COMPONENT_USE_FORWARDED_HEADER=__RESTLET_COMPONENT_USE_FORWARDED_HEADER__
-RESTLET_COMPONENT_REUSE_ADDRESS=__RESTLET_COMPONENT_REUSE_ADDRESS__
-
-AJSC_EXTERNAL_LIB_FOLDERS=__CSM_LIB__|__DME2_LIB__|__AJSC_EXTERNAL_LIB_FOLDERS__
-AJSC_EXTERNAL_PROPERTIES_FOLDERS=__AJSC_SHARED_CONFIG__|__AJSC_EXTERNAL_PROPERTIES_FOLDERS__
-
-KEY_STORE_PASSWORD=__KEY_STORE_PASSWORD__
-KEY_MANAGER_PASSWORD=__KEY_MANAGER_PASSWORD__
-AAI_CORE_VERSION=1.2.0-SNAPSHOT
diff --git a/aai-traversal/src/main/resources/retired.properties b/aai-traversal/src/main/resources/retired.properties
new file mode 100644
index 0000000..2261713
--- /dev/null
+++ b/aai-traversal/src/main/resources/retired.properties
@@ -0,0 +1,5 @@
+# Retired properties
+retired.api.pattern.list=\
+ ^/aai/v[2-7]+/.*$\
+
+retired.api.all.versions= \ No newline at end of file
diff --git a/aai-traversal/src/main/resources/schema/UebEventLogEntry.xsd b/aai-traversal/src/main/resources/schema/UebEventLogEntry.xsd
deleted file mode 100644
index edc8924..0000000
--- a/aai-traversal/src/main/resources/schema/UebEventLogEntry.xsd
+++ /dev/null
@@ -1,43 +0,0 @@
-<!--
-
- ============LICENSE_START=======================================================
- org.onap.aai
- ================================================================================
- Copyright © 2017 AT&T Intellectual Property. All rights reserved.
- ================================================================================
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
- ============LICENSE_END=========================================================
-
- ECOMP is a trademark and service mark of AT&T Intellectual Property.
-
--->
-<xs:schema attributeFormDefault="unqualified" elementFormDefault="qualified" xmlns:xs="http://www.w3.org/2001/XMLSchema">
- <xs:complexType name="UebEventLogEntry">
- <xs:sequence>
- <xs:element type="xs:string" name="transactionLogEntryId"/>
- <xs:element type="xs:string" name="notificationId"/>
- <xs:element type="xs:string" name="topic"/>
- <xs:element type="xs:string" name="action"/>
- <xs:element minOccurs="0" type="xs:string" name="entityLink"/>
- <xs:element type="xs:string" name="payload"/>
- <xs:element type="xs:string" name="status"/>
- <xs:element minOccurs="0" type="xs:string" name="owner"/>
- <xs:element type="xs:long" name="lastUpdateTimestamp"/>
- </xs:sequence>
- </xs:complexType>
- <xs:complexType name="UebEventLogEntries">
- <xs:sequence>
- <xs:element minOccurs="0" maxOccurs="unbounded" name="UebEventLogEntries" type="UebEventLogEntry"/>
- </xs:sequence>
- </xs:complexType>
-</xs:schema>
diff --git a/aai-traversal/src/main/resources/etc/query/stored-queries.json b/aai-traversal/src/main/resources/schema/onap/query/stored-queries.json
index d511e5a..a3f6a62 100644
--- a/aai-traversal/src/main/resources/etc/query/stored-queries.json
+++ b/aai-traversal/src/main/resources/schema/onap/query/stored-queries.json
@@ -1,7 +1,7 @@
{
"stored-queries":[{
"cloud-region-fromVnf":{
- "stored-query":"builder.createEdgeTraversal(EdgeType.COUSIN, 'generic-vnf', 'vnfc').store('x').createEdgeTraversal(EdgeType.COUSIN, 'vnfc', 'vserver').store('x').createEdgeTraversal(EdgeType.TREE, 'vserver', 'tenant').store('x').createEdgeTraversal(EdgeType.TREE, 'tenant', 'cloud-region').store('x').cap('x').unfold().dedup()"
+ "stored-query":"builder.store('x').union(builder.newInstance().createEdgeTraversal(EdgeType.COUSIN, 'generic-vnf', 'vnfc').store('x').createEdgeTraversal(EdgeType.COUSIN, 'vnfc', 'vserver').store('x').union(builder.newInstance().createEdgeTraversal(EdgeType.COUSIN, 'vserver', 'pserver').store('x'),builder.newInstance().createEdgeTraversal(EdgeType.TREE, 'vserver', 'tenant').store('x').createEdgeTraversal(EdgeType.TREE, 'tenant', 'cloud-region').store('x')), builder.newInstance().createEdgeTraversal(EdgeType.COUSIN, 'generic-vnf', 'vserver').store('x').union(builder.newInstance().createEdgeTraversal(EdgeType.COUSIN, 'vserver', 'pserver').store('x'),builder.newInstance().createEdgeTraversal(EdgeType.TREE, 'vserver', 'tenant').store('x').createEdgeTraversal(EdgeType.TREE, 'tenant', 'cloud-region').store('x'))).cap('x').unfold().dedup()"
}
},{
"linked-devices":{
@@ -16,7 +16,7 @@
}
},{
"pserver-fromConfiguration":{
- "stored-query":"builder.store('x').createEdgeTraversal(EdgeType.COUSIN, 'configuration', 'logical-link').union(builder.newInstance().createEdgeTraversal(EdgeType.COUSIN, 'logical-link', 'l-interface').store('x'),builder.newInstance().createEdgeTraversal(EdgeType.COUSIN, 'logical-link', 'pserver').store('x'),builder.newInstance().createEdgeTraversal(EdgeType.COUSIN, 'logical-link', 'generic-vnf').store('x').createEdgeTraversal(EdgeType.COUSIN, 'generic-vnf', 'pnf').store('x')).cap('x').unfold().dedup()"
+ "stored-query":"builder.store('x').createEdgeTraversal(EdgeType.COUSIN, 'configuration', 'logical-link').union(builder.newInstance().createEdgeTraversal(EdgeType.COUSIN, 'logical-link', 'l-interface').store('x').createEdgeTraversal(EdgeType.TREE, 'l-interface', 'vserver').createEdgeTraversal(EdgeType.COUSIN, 'vserver', 'pserver').store('x'),builder.newInstance().createEdgeTraversal(EdgeType.COUSIN, 'logical-link', 'generic-vnf').store('x').createEdgeTraversal(EdgeType.COUSIN, 'generic-vnf', 'pnf').store('x')).cap('x').unfold().dedup()"
}
},{
"spaas-topology-fromServiceInstance":{
@@ -53,6 +53,13 @@
"stored-query":"builder.store('x').createEdgeTraversal(EdgeType.COUSIN, 'complex', 'l3-network').store('x').createEdgeTraversal(EdgeType.COUSIN, 'l3-network', 'cloud-region').store('x').cap('x').unfold()"
}
},{
+ "pnf-from-model":{
+ "query":{
+ "required-properties":["equipVendor","equipModel"]
+ },
+ "stored-query":"builder.createEdgeTraversal(EdgeType.COUSIN, 'service-instance', 'pnf').getVerticesByProperty('equip-vendor', equipVendor).getVerticesByProperty('equip-model', equipModel).store('x').cap('x').unfold().dedup()"
+ }
+ },{
"pnf-fromModel-byRegion":{
"query":{
"required-properties":["equipVendor","equipModel","cloudRegionId"]
@@ -85,7 +92,7 @@
"query":{
"required-properties":["interfaceId"]
},
- "stored-query":"builder.store('x').createEdgeTraversal(EdgeType.COUSIN, 'configuration', 'logical-link').where(builder.newInstance().createEdgeTraversal(EdgeType.COUSIN, 'logical-link', 'l-interface').getVerticesByProperty('interface-id', interfaceId).store('x')).union(builder.newInstance().createEdgeTraversal(EdgeType.COUSIN, 'logical-link', 'pserver').store('x'),builder.newInstance().createEdgeTraversal(EdgeType.COUSIN, 'logical-link', 'generic-vnf').store('x').createEdgeTraversal(EdgeType.COUSIN, 'generic-vnf', 'pnf').store('x')).cap('x').unfold().dedup()"
+ "stored-query":"builder.store('x').createEdgeTraversal(EdgeType.COUSIN, 'configuration', 'logical-link').where(builder.newInstance().createEdgeTraversal(EdgeType.COUSIN, 'logical-link', 'l-interface').getVerticesByProperty('interface-id', interfaceId).store('x')).union(builder.newInstance().createEdgeTraversal(EdgeType.COUSIN, 'logical-link', 'l-interface').createEdgeTraversal(EdgeType.TREE, 'l-interface', 'vserver').createEdgeTraversal(EdgeType.COUSIN, 'vserver', 'pserver').store('x'),builder.newInstance().createEdgeTraversal(EdgeType.COUSIN, 'logical-link', 'generic-vnf').store('x').createEdgeTraversal(EdgeType.COUSIN, 'generic-vnf', 'pnf').store('x')).cap('x').unfold().dedup()"
}
},{
"cloudRegion-fromCountry":{
@@ -112,9 +119,9 @@
},{
"vserver-fromVnf":{
"query":{
- "required-properties":["nfcFunction"]
+ "required-properties":["nfcNamingCode"]
},
- "stored-query":"builder.createEdgeTraversal(EdgeType.COUSIN, 'generic-vnf', 'vnfc').getVerticesByProperty('nfc-function', nfcFunction).store('x').createEdgeTraversal(EdgeType.COUSIN, 'vnfc', 'vserver').store('x').createEdgeTraversal(EdgeType.TREE, 'vserver', 'l-interface').store('x').union(builder.newInstance().createEdgeTraversal(EdgeType.TREE, 'l-interface', 'l3-interface-ipv4-address-list').store('x'),builder.newInstance().createEdgeTraversal(EdgeType.TREE, 'l-interface', 'l3-interface-ipv6-address-list').store('x')).cap('x').unfold().dedup()"
+ "stored-query":"builder.createEdgeTraversal(EdgeType.COUSIN, 'generic-vnf', 'vnfc').getVerticesByProperty('nfc-naming-code', nfcNamingCode).store('x').createEdgeTraversal(EdgeType.COUSIN, 'vnfc', 'vserver').store('x').createEdgeTraversal(EdgeType.TREE, 'vserver', 'l-interface').store('x').union(builder.newInstance().createEdgeTraversal(EdgeType.TREE, 'l-interface', 'l3-interface-ipv4-address-list').store('x'),builder.newInstance().createEdgeTraversal(EdgeType.TREE, 'l-interface', 'l3-interface-ipv6-address-list').store('x')).cap('x').unfold().dedup()"
}
},{
"sites-byCloudRegionId":{
@@ -181,7 +188,7 @@
}
},{
"vnf-topology-fromServiceInstance":{
- "stored-query":"builder.store('x').union(builder.newInstance().createEdgeTraversal(EdgeType.TREE, 'service-instance', 'service-subscription').createEdgeTraversal(EdgeType.TREE, 'service-subscription', 'customer').store('x'),builder.newInstance().createEdgeTraversal(EdgeType.TREE, 'service-instance', 'allotted-resource').store('x'),builder.newInstance().createEdgeTraversal(EdgeType.COUSIN, 'service-instance', 'generic-vnf').store('x').union(builder.newInstance().createEdgeTraversal(EdgeType.TREE, 'generic-vnf', 'vf-module').store('x'),builder.newInstance().createEdgeTraversal(EdgeType.COUSIN, 'generic-vnf', 'volume-group').store('x'),builder.newInstance().createEdgeTraversal(EdgeType.TREE, 'generic-vnf', 'l-interface').union(builder.newInstance().createEdgeTraversal(EdgeType.TREE, 'l-interface', 'l3-interface-ipv4-address-list').store('x').createEdgeTraversal(EdgeType.COUSIN, 'l3-interface-ipv4-address-list', 'l3-network').store('x'),builder.newInstance().createEdgeTraversal(EdgeType.TREE, 'l-interface', 'l3-interface-ipv6-address-list').store('x').createEdgeTraversal(EdgeType.COUSIN, 'l3-interface-ipv6-address-list', 'l3-network').store('x')),builder.newInstance().createEdgeTraversal(EdgeType.COUSIN, 'generic-vnf', 'vserver').store('x').union(builder.newInstance().createEdgeTraversal(EdgeType.TREE, 'vserver', 'tenant').store('x').createEdgeTraversal(EdgeType.TREE, 'tenant', 'cloud-region').store('x'),builder.newInstance().createEdgeTraversal(EdgeType.COUSIN, 'vserver', 'pserver').store('x'),builder.newInstance().createEdgeTraversal(EdgeType.TREE, 'vserver', 'l-interface').createEdgeTraversal(EdgeType.TREE, 'l-interface', 'l3-interface-ipv4-address-list').store('x').createEdgeTraversal(EdgeType.COUSIN, 'l3-interface-ipv4-address-list', 'l3-network').store('x'),builder.newInstance().createEdgeTraversal(EdgeType.TREE, 'vserver', 'l-interface').createEdgeTraversal(EdgeType.TREE, 'l-interface', 'l3-interface-ipv6-address-list').store('x').createEdgeTraversal(EdgeType.COUSIN, 'l3-interface-ipv6-address-list', 'l3-network').store('x')))).cap('x').unfold().dedup()"
+ "stored-query":"builder.store('x').union(builder.newInstance().createEdgeTraversal(EdgeType.TREE, 'service-instance', 'service-subscription').createEdgeTraversal(EdgeType.TREE, 'service-subscription', 'customer').store('x'),builder.newInstance().createEdgeTraversal(EdgeType.COUSIN, 'service-instance', 'configuration').store('x'),builder.newInstance().createEdgeTraversal(EdgeType.TREE, 'service-instance', 'allotted-resource').store('x'),builder.newInstance().createEdgeTraversal(EdgeType.COUSIN, 'service-instance', 'generic-vnf').store('x').union(builder.newInstance().createEdgeTraversal(EdgeType.COUSIN, 'generic-vnf', 'l3-network').store('x').union(builder.newInstance().createEdgeTraversal(EdgeType.COUSIN, 'l3-network', 'vlan-tag').store('x'), builder.newInstance().createEdgeTraversal(EdgeType.COUSIN, 'l3-network', 'l3-network').store('x').createEdgeTraversal(EdgeType.COUSIN, 'l3-network', 'vlan-tag').store('x')),builder.newInstance().createEdgeTraversal(EdgeType.TREE, 'generic-vnf', 'vf-module').store('x'),builder.newInstance().createEdgeTraversal(EdgeType.COUSIN, 'generic-vnf', 'volume-group').store('x'),builder.newInstance().createEdgeTraversal(EdgeType.TREE, 'generic-vnf', 'l-interface').union(builder.newInstance().createEdgeTraversal(EdgeType.TREE, 'l-interface', 'l3-interface-ipv4-address-list').store('x').createEdgeTraversal(EdgeType.COUSIN, 'l3-interface-ipv4-address-list', 'l3-network').store('x'),builder.newInstance().createEdgeTraversal(EdgeType.TREE, 'l-interface', 'l3-interface-ipv6-address-list').store('x').createEdgeTraversal(EdgeType.COUSIN, 'l3-interface-ipv6-address-list', 'l3-network').store('x')),builder.newInstance().createEdgeTraversal(EdgeType.COUSIN, 'generic-vnf', 'vserver').store('x').union(builder.newInstance().createEdgeTraversal(EdgeType.TREE, 'vserver', 'tenant').store('x').createEdgeTraversal(EdgeType.TREE, 'tenant', 'cloud-region').store('x'),builder.newInstance().createEdgeTraversal(EdgeType.COUSIN, 'vserver', 'pserver').store('x'),builder.newInstance().createEdgeTraversal(EdgeType.TREE, 'vserver', 'l-interface').createEdgeTraversal(EdgeType.TREE, 'l-interface', 'l3-interface-ipv4-address-list').store('x').createEdgeTraversal(EdgeType.COUSIN, 'l3-interface-ipv4-address-list', 'l3-network').store('x'),builder.newInstance().createEdgeTraversal(EdgeType.TREE, 'vserver', 'l-interface').createEdgeTraversal(EdgeType.TREE, 'l-interface', 'l3-interface-ipv6-address-list').store('x').createEdgeTraversal(EdgeType.COUSIN, 'l3-interface-ipv6-address-list', 'l3-network').store('x')))).cap('x').unfold().dedup()"
}
},{
"ucpe-topology":{
@@ -204,7 +211,7 @@
}
},{
"pending-topology-detail":{
- "stored-query":"builder.store('x').union(builder.newInstance().createEdgeTraversal(EdgeType.COUSIN, 'generic-vnf', 'platform').store('x'),builder.newInstance().createEdgeTraversal(EdgeType.COUSIN, 'generic-vnf', 'line-of-business').store('x'),builder.newInstance().createEdgeTraversal(EdgeType.COUSIN, 'generic-vnf', 'service-instance').union(builder.newInstance().createEdgeTraversal(EdgeType.COUSIN, 'service-instance', 'owning-entity').store('x'),builder.newInstance().createEdgeTraversal(EdgeType.COUSIN, 'service-instance', 'project').store('x')),builder.newInstance().createEdgeTraversal(EdgeType.COUSIN, 'generic-vnf', 'vnfc').store('x').union(builder.newInstance().createEdgeTraversal(EdgeType.TREE, 'vnfc', 'l3-interface-ipv4-address-list').store('x').createEdgeTraversal(EdgeType.COUSIN, 'l3-interface-ipv4-address-list', 'subnet').store('x').createEdgeTraversal(EdgeType.TREE, 'subnet', 'l3-network').store('x'),builder.newInstance().createEdgeTraversal(EdgeType.TREE, 'vnfc', 'l3-interface-ipv6-address-list').store('x').createEdgeTraversal(EdgeType.COUSIN, 'l3-interface-ipv6-address-list', 'subnet').store('x').createEdgeTraversal(EdgeType.TREE, 'subnet', 'l3-network').store('x'),builder.newInstance().createEdgeTraversal(EdgeType.COUSIN, 'vnfc', 'vip-ipv4-address-list').store('x').createEdgeTraversal(EdgeType.COUSIN, 'vip-ipv4-address-list', 'subnet').store('x').createEdgeTraversal(EdgeType.TREE, 'subnet', 'l3-network').store('x'),builder.newInstance().createEdgeTraversal(EdgeType.COUSIN, 'vnfc', 'vip-ipv6-address-list').store('x').createEdgeTraversal(EdgeType.COUSIN, 'vip-ipv6-address-list', 'subnet').store('x').createEdgeTraversal(EdgeType.TREE, 'subnet', 'l3-network').store('x')).dedup()).cap('x').unfold().dedup()"
+ "stored-query":"builder.store('x').union(builder.newInstance().createEdgeTraversal(EdgeType.COUSIN, 'generic-vnf', 'platform').store('x'),builder.newInstance().createEdgeTraversal(EdgeType.COUSIN, 'generic-vnf', 'line-of-business').store('x'),builder.newInstance().createEdgeTraversal(EdgeType.COUSIN, 'generic-vnf', 'service-instance').union(builder.newInstance().createEdgeTraversal(EdgeType.COUSIN, 'service-instance', 'owning-entity').store('x'),builder.newInstance().createEdgeTraversal(EdgeType.COUSIN, 'service-instance', 'project').store('x')),builder.newInstance().createEdgeTraversal(EdgeType.TREE, 'generic-vnf', 'vf-module').store('x').createEdgeTraversal(EdgeType.COUSIN, 'vf-module', 'vnfc').store('x').union(builder.newInstance().createEdgeTraversal(EdgeType.TREE, 'vnfc', 'l3-interface-ipv4-address-list').store('x').createEdgeTraversal(EdgeType.COUSIN, 'l3-interface-ipv4-address-list', 'subnet').store('x').createEdgeTraversal(EdgeType.TREE, 'subnet', 'l3-network').store('x'),builder.newInstance().createEdgeTraversal(EdgeType.TREE, 'vnfc', 'l3-interface-ipv6-address-list').store('x').createEdgeTraversal(EdgeType.COUSIN, 'l3-interface-ipv6-address-list', 'subnet').store('x').createEdgeTraversal(EdgeType.TREE, 'subnet', 'l3-network').store('x'),builder.newInstance().createEdgeTraversal(EdgeType.COUSIN, 'vnfc', 'vip-ipv4-address-list').store('x').createEdgeTraversal(EdgeType.COUSIN, 'vip-ipv4-address-list', 'subnet').store('x').createEdgeTraversal(EdgeType.TREE, 'subnet', 'l3-network').store('x'),builder.newInstance().createEdgeTraversal(EdgeType.COUSIN, 'vnfc', 'vip-ipv6-address-list').store('x').createEdgeTraversal(EdgeType.COUSIN, 'vip-ipv6-address-list', 'subnet').store('x').createEdgeTraversal(EdgeType.TREE, 'subnet', 'l3-network').store('x')).dedup()).cap('x').unfold().dedup()"
}
},{
"vnfs-fromServiceInstance":{
@@ -228,7 +235,7 @@
}
},{
"topology-detail-fromVserver":{
- "stored-query":"builder.store('x').union(builder.newInstance().createEdgeTraversal(EdgeType.TREE, 'vserver', 'l-interface').store('x').union(builder.newInstance().createEdgeTraversal(EdgeType.TREE, 'l-interface', 'l3-interface-ipv4-address-list').store('x').createEdgeTraversal(EdgeType.COUSIN, 'l3-interface-ipv4-address-list', 'subnet').store('x').createEdgeTraversal(EdgeType.TREE, 'subnet', 'l3-network').store('x'),builder.newInstance().createEdgeTraversal(EdgeType.TREE, 'l-interface', 'l3-interface-ipv6-address-list').store('x').createEdgeTraversal(EdgeType.COUSIN, 'l3-interface-ipv6-address-list', 'subnet').store('x').createEdgeTraversal(EdgeType.TREE, 'subnet', 'l3-network').store('x')),builder.newInstance().createEdgeTraversal(EdgeType.TREE, 'vserver', 'tenant').createEdgeTraversal(EdgeType.TREE, 'tenant', 'cloud-region').store('x'),builder.newInstance().createEdgeTraversal(EdgeType.COUSIN, 'vserver', 'pserver').createEdgeTraversal(EdgeType.COUSIN, 'pserver', 'complex').store('x'),builder.newInstance().createEdgeTraversal(EdgeType.COUSIN, 'vserver', 'generic-vnf').store('x').union(builder.newInstance().createEdgeTraversal(EdgeType.COUSIN, 'generic-vnf', 'platform').store('x'),builder.newInstance().createEdgeTraversal(EdgeType.COUSIN, 'generic-vnf', 'line-of-business').store('x'),builder.newInstance().createEdgeTraversal(EdgeType.COUSIN, 'generic-vnf', 'service-instance').union(builder.newInstance().createEdgeTraversal(EdgeType.COUSIN, 'service-instance', 'owning-entity').store('x'),builder.newInstance().createEdgeTraversal(EdgeType.COUSIN, 'service-instance', 'project').store('x')),builder.newInstance().createEdgeTraversal(EdgeType.COUSIN, 'generic-vnf', 'vnfc').store('x'))).cap('x').unfold().dedup()"
+ "stored-query":"builder.store('x').union(builder.newInstance().createEdgeTraversal(EdgeType.TREE,'vserver','l-interface').store('x').union(builder.newInstance().createEdgeTraversal(EdgeType.TREE,'l-interface','l3-interface-ipv4-address-list').store('x').createEdgeTraversal(EdgeType.COUSIN,'l3-interface-ipv4-address-list','subnet').store('x').createEdgeTraversal(EdgeType.TREE,'subnet','l3-network').store('x'),builder.newInstance().createEdgeTraversal(EdgeType.TREE,'l-interface','l3-interface-ipv6-address-list').store('x').createEdgeTraversal(EdgeType.COUSIN,'l3-interface-ipv6-address-list','subnet').store('x').createEdgeTraversal(EdgeType.TREE,'subnet','l3-network').store('x')),builder.newInstance().createEdgeTraversal(EdgeType.TREE,'vserver','tenant').store('x').createEdgeTraversal(EdgeType.TREE,'tenant','cloud-region').store('x'),builder.newInstance().createEdgeTraversal(EdgeType.COUSIN,'vserver','pserver').store('x').union(builder.newInstance().createEdgeTraversal(EdgeType.COUSIN,'pserver','complex').store('x'),builder.newInstance().createEdgeTraversal(EdgeType.COUSIN,'pserver','availability-zone').store('x')),builder.newInstance().createEdgeTraversal(EdgeType.COUSIN,'vserver','generic-vnf').store('x').union(builder.newInstance().createEdgeTraversal(EdgeType.TREE,'generic-vnf','vf-module').store('x'),builder.newInstance().createEdgeTraversal(EdgeType.COUSIN,'generic-vnf','platform').store('x'),builder.newInstance().createEdgeTraversal(EdgeType.COUSIN,'generic-vnf','line-of-business').store('x'),builder.newInstance().createEdgeTraversal(EdgeType.COUSIN,'generic-vnf','virtual-data-center').store('x'),builder.newInstance().createEdgeTraversal(EdgeType.COUSIN,'generic-vnf','volume-group').store('x'),builder.newInstance().createEdgeTraversal(EdgeType.COUSIN,'generic-vnf','service-instance').union(builder.newInstance().createEdgeTraversal(EdgeType.COUSIN,'service-instance','owning-entity').store('x'),builder.newInstance().createEdgeTraversal(EdgeType.COUSIN,'service-instance','project').store('x')),builder.newInstance().createEdgeTraversal(EdgeType.COUSIN,'generic-vnf','vnfc').store('x')),builder.newInstance().createEdgeTraversal(EdgeType.COUSIN,'vserver','image').store('x'),builder.newInstance().createEdgeTraversal(EdgeType.COUSIN,'vserver','flavor').store('x'),builder.newInstance().createEdgeTraversal(EdgeType.COUSIN,'vserver','vf-module').store('x')).cap('x').unfold().dedup();"
}
},{
"vserverlogicallink-frompServer":{
@@ -236,7 +243,7 @@
}
},{
"vnf-topology-fromVnf":{
- "stored-query":"builder.store('x').union(builder.newInstance().createEdgeTraversal(EdgeType.COUSIN, 'generic-vnf', 'service-instance').store('x').union(builder.newInstance().createEdgeTraversal(EdgeType.TREE, 'service-instance', 'service-subscription').createEdgeTraversal(EdgeType.TREE, 'service-subscription', 'customer').store('x'),builder.newInstance().createEdgeTraversal(EdgeType.TREE, 'service-instance', 'allotted-resource').store('x')),builder.newInstance().createEdgeTraversal(EdgeType.TREE, 'generic-vnf', 'vf-module').store('x'),builder.newInstance().createEdgeTraversal(EdgeType.COUSIN, 'generic-vnf', 'volume-group').store('x'),builder.newInstance().createEdgeTraversal(EdgeType.TREE, 'generic-vnf', 'l-interface').union(builder.newInstance().createEdgeTraversal(EdgeType.TREE, 'l-interface', 'l3-interface-ipv4-address-list').store('x').createEdgeTraversal(EdgeType.COUSIN, 'l3-interface-ipv4-address-list', 'l3-network').store('x'),builder.newInstance().createEdgeTraversal(EdgeType.TREE, 'l-interface', 'l3-interface-ipv6-address-list').store('x').createEdgeTraversal(EdgeType.COUSIN, 'l3-interface-ipv6-address-list', 'l3-network').store('x'),),builder.newInstance().createEdgeTraversal(EdgeType.COUSIN, 'generic-vnf', 'vserver').store('x').union(builder.newInstance().createEdgeTraversal(EdgeType.TREE, 'vserver', 'tenant').store('x').createEdgeTraversal(EdgeType.TREE, 'tenant', 'cloud-region').store('x'),builder.newInstance().createEdgeTraversal(EdgeType.COUSIN, 'vserver', 'pserver').store('x'),builder.newInstance().createEdgeTraversal(EdgeType.TREE, 'vserver', 'l-interface').createEdgeTraversal(EdgeType.TREE, 'l-interface', 'l3-interface-ipv4-address-list').store('x').createEdgeTraversal(EdgeType.COUSIN, 'l3-interface-ipv4-address-list', 'l3-network').store('x'),builder.newInstance().createEdgeTraversal(EdgeType.TREE, 'vserver', 'l-interface').createEdgeTraversal(EdgeType.TREE, 'l-interface', 'l3-interface-ipv6-address-list').store('x').createEdgeTraversal(EdgeType.COUSIN, 'l3-interface-ipv6-address-list', 'l3-network').store('x'),)).cap('x').unfold().dedup()"
+ "stored-query":"builder.store('x').union(builder.newInstance().createEdgeTraversal(EdgeType.COUSIN, 'generic-vnf', 'service-instance').store('x').union(builder.newInstance().createEdgeTraversal(EdgeType.TREE, 'service-instance', 'service-subscription').store('x').createEdgeTraversal(EdgeType.TREE, 'service-subscription', 'customer').store('x'),builder.newInstance().createEdgeTraversal(EdgeType.TREE, 'service-instance', 'allotted-resource').store('x')),builder.newInstance().createEdgeTraversal(EdgeType.TREE, 'generic-vnf', 'vf-module').store('x'),builder.newInstance().createEdgeTraversal(EdgeType.COUSIN, 'generic-vnf', 'volume-group').store('x'),builder.newInstance().createEdgeTraversal(EdgeType.TREE, 'generic-vnf', 'l-interface').store('x').union(builder.newInstance().createEdgeTraversal(EdgeType.TREE, 'l-interface', 'l3-interface-ipv4-address-list').store('x').createEdgeTraversal(EdgeType.COUSIN, 'l3-interface-ipv4-address-list', 'l3-network').store('x'),builder.newInstance().createEdgeTraversal(EdgeType.TREE, 'l-interface', 'l3-interface-ipv6-address-list').store('x').createEdgeTraversal(EdgeType.COUSIN, 'l3-interface-ipv6-address-list', 'l3-network').store('x'),),builder.newInstance().createEdgeTraversal(EdgeType.COUSIN, 'generic-vnf', 'vserver').store('x').union(builder.newInstance().createEdgeTraversal(EdgeType.TREE, 'vserver', 'tenant').store('x').createEdgeTraversal(EdgeType.TREE, 'tenant', 'cloud-region').store('x'),builder.newInstance().createEdgeTraversal(EdgeType.COUSIN, 'vserver', 'pserver').store('x'),builder.newInstance().createEdgeTraversal(EdgeType.TREE, 'vserver', 'l-interface').store('x').union(builder.newInstance().createEdgeTraversal(EdgeType.TREE, 'l-interface', 'l3-interface-ipv4-address-list').store('x').createEdgeTraversal(EdgeType.COUSIN, 'l3-interface-ipv4-address-list', 'l3-network').store('x'),builder.newInstance().createEdgeTraversal(EdgeType.TREE, 'l-interface', 'l3-interface-ipv6-address-list').store('x').createEdgeTraversal(EdgeType.COUSIN, 'l3-interface-ipv6-address-list', 'l3-network').store('x'),))).cap('x').unfold().dedup()"
}
},{
"service-topology":{
@@ -247,25 +254,184 @@
"stored-query":"builder.store('x').union(builder.newInstance().createEdgeTraversal(EdgeType.TREE, 'service-instance', 'service-subscription').store('x').createEdgeTraversal(EdgeType.TREE, 'service-subscription', 'customer').store('x'),builder.newInstance().createEdgeTraversal(EdgeType.COUSIN, 'service-instance', 'forwarding-path').store('x').union(builder.newInstance().createEdgeTraversal(EdgeType.COUSIN, 'forwarding-path', 'configuration').store('x').createEdgeTraversal(EdgeType.TREE, 'configuration', 'evc').store('x'),builder.newInstance().createEdgeTraversal(EdgeType.TREE, 'forwarding-path', 'forwarder').store('x').union(builder.newInstance().createEdgeTraversal(EdgeType.COUSIN, 'forwarder', 'configuration').store('x').createEdgeTraversal(EdgeType.TREE, 'configuration', 'forwarder-evc').store('x'),builder.newInstance().createEdgeTraversal(EdgeType.COUSIN, 'forwarder', 'p-interface').store('x').createEdgeTraversal(EdgeType.TREE, 'p-interface', 'pnf').store('x'),builder.newInstance().createEdgeTraversal(EdgeType.COUSIN, 'forwarder', 'lag-interface').store('x').union(builder.newInstance().createEdgeTraversal(EdgeType.TREE, 'lag-interface', 'pnf').store('x'),builder.newInstance().createEdgeTraversal(EdgeType.COUSIN, 'lag-interface', 'logical-link').getVerticesByProperty('link-type', 'LAG').store('x'))))).cap('x').unfold().dedup()"
}
},{
- "count-vnf-byVnfType":{
+ "count-vnf-byVnfType":{
"stored-query":"builder.getVerticesByProperty('aai-node-type', 'generic-vnf').groupCount().by('vnf-type').store('x').unfold()"
- }
+ }
},{
- "pservers-withNoComplex":{
+ "pservers-withNoComplex":{
"stored-query":"builder.getVerticesByProperty('aai-node-type', 'pserver').where(builder.newInstance().not(builder.newInstance().both().getVerticesByProperty('aai-node-type', 'complex'))).store('x').unfold()"
- }
+ }
},{
"gfp-vserver-data":{
"stored-query":"builder.createEdgeTraversal(EdgeType.TREE, 'vserver', 'l-interface').union(builder.newInstance().createEdgeTraversal(EdgeType.TREE, 'l-interface', 'l3-interface-ipv4-address-list').store('x'),builder.newInstance().createEdgeTraversal(EdgeType.TREE, 'l-interface', 'l3-interface-ipv6-address-list').store('x'),builder.newInstance().createEdgeTraversal(EdgeType.TREE, 'l-interface', 'vlan').store('x')).cap('x').unfold().dedup()"
}
},{
- "gfp-vnf-data":{
+ "gfp-vnf-data":{
"stored-query":"builder.store('x').union(builder.newInstance().createEdgeTraversal(EdgeType.TREE, 'generic-vnf', 'l-interface').union(builder.newInstance().createEdgeTraversal(EdgeType.TREE, 'l-interface', 'l3-interface-ipv4-address-list').store('x'),builder.newInstance().createEdgeTraversal(EdgeType.TREE, 'l-interface', 'l3-interface-ipv6-address-list').store('x'),builder.newInstance().createEdgeTraversal(EdgeType.TREE, 'l-interface', 'vlan').store('x').union(builder.newInstance().createEdgeTraversal(EdgeType.TREE, 'vlan', 'l3-interface-ipv4-address-list').store('x'),builder.newInstance().createEdgeTraversal(EdgeType.TREE, 'vlan', 'l3-interface-ipv6-address-list').store('x'))),builder.newInstance().createEdgeTraversal(EdgeType.TREE, 'generic-vnf', 'lag-interface').createEdgeTraversal(EdgeType.TREE, 'lag-interface', 'l-interface').store('x').createEdgeTraversal(EdgeType.TREE, 'l-interface', 'vlan').union(builder.newInstance().createEdgeTraversal(EdgeType.TREE, 'vlan', 'l3-interface-ipv4-address-list').store('x'),builder.newInstance().createEdgeTraversal(EdgeType.TREE, 'vlan', 'l3-interface-ipv6-address-list').store('x')),builder.newInstance().createEdgeTraversal(EdgeType.COUSIN, 'generic-vnf', 'vnf-image').store('x'),builder.newInstance().createEdgeTraversal(EdgeType.COUSIN, 'generic-vnf', 'network-profile').store('x')).cap('x').unfold().dedup()"
}
},{
+
+ "related-to":{
+ "query":{
+ "required-properties":["startingNodeType","relatedToNodeType"]
+ },
+ "stored-query":"builder.createEdgeTraversal(startingNodeType, relatedToNodeType).store('x').cap('x').unfold().dedup()"
+ }
+ },{
+ "gfp-vserver":{
+ "stored-query":"builder.where(builder.newInstance().createEdgeTraversal(EdgeType.TREE, 'vserver', 'tenant'))"
+ }
+ },{
+ "sriov-topology-fromVnf":{
+ "stored-query":"builder.store('x').createEdgeTraversal(EdgeType.COUSIN, 'generic-vnf', 'vserver').store('x').createEdgeTraversal(EdgeType.TREE, 'vserver', 'l-interface').createEdgeTraversal(EdgeType.TREE, 'l-interface', 'sriov-vf').store('x').createEdgeTraversal(EdgeType.COUSIN, 'sriov-vf', 'sriov-pf').createEdgeTraversal(EdgeType.TREE, 'sriov-pf','p-interface').createEdgeTraversal(EdgeType.COUSIN, 'p-interface', 'physical-link').store('x').cap('x').unfold().dedup()"
+ }
+ },{
+ "vserver-l-interfaces-fromVnfc":{
+ "query":{
+ "optional-properties":["networkName"]
+ },
+ "stored-query":"builder.where(builder.newInstance().createEdgeTraversal(EdgeType.COUSIN, 'vnfc', 'vserver').createEdgeTraversal(EdgeType.TREE, 'vserver', 'l-interface').getVerticesByProperty('network-name',networkName)).createEdgeTraversal(EdgeType.COUSIN, 'vnfc', 'vserver').store('x').createEdgeTraversal(EdgeType.TREE, 'vserver', 'l-interface').getVerticesByProperty('network-name',networkName).store('x').createEdgeTraversal(EdgeType.TREE, 'l-interface', 'l-interface').store('x').createEdgeTraversal(EdgeType.TREE, 'l-interface', 'vlan').store('x').cap('x').unfold().dedup()"
+ }
+ },{
+ "vnfs-vlans-fromServiceInstance":{
+ "stored-query":"builder.createEdgeTraversal(EdgeType.COUSIN, 'service-instance', 'configuration').union(builder.newInstance().createEdgeTraversal(EdgeType.COUSIN, 'configuration', 'generic-vnf').store('x'), builder.newInstance().createEdgeTraversal(EdgeType.COUSIN, 'configuration', 'l-interface').createEdgeTraversal(EdgeType.TREE, 'l-interface', 'vlan').store('x')).cap('x').unfold().dedup()"
+ }
+ },{
+ "getClfiRoadmTailSummary":{
+ "stored-query":"builder.store('x').union(builder.newInstance().createEdgeTraversal(EdgeType.COUSIN,'logical-link', 'p-interface').store('x').createEdgeTraversal(EdgeType.TREE,'p-interface', 'pnf').store('x'), builder.newInstance().createEdgeTraversal(EdgeType.COUSIN,'logical-link', 'logical-link').store('x').createEdgeTraversal(EdgeType.COUSIN,'logical-link', 'service-instance').store('x').createEdgeTraversal(EdgeType.TREE,'service-instance', 'service-subscription').store('x').createEdgeTraversal(EdgeType.TREE,'service-subscription', 'customer').store('x')).cap('x').unfold().dedup()"
+ }
+ },{
+ "getRouterRoadmTailSummary":{
+ "stored-query":"builder.store('x').createEdgeTraversal(EdgeType.TREE,'pnf', 'p-interface').store('x').createEdgeTraversal(EdgeType.COUSIN,'p-interface', 'logical-link').store('x').union(builder.newInstance().createEdgeTraversal(EdgeType.COUSIN,'logical-link', 'p-interface').store('x').createEdgeTraversal(EdgeType.TREE,'p-interface', 'pnf').store('x'), builder.newInstance().createEdgeTraversal(EdgeType.COUSIN,'logical-link', 'logical-link').store('x').createEdgeTraversal(EdgeType.COUSIN,'logical-link', 'service-instance').store('x').createEdgeTraversal(EdgeType.TREE,'service-instance', 'service-subscription').store('x').createEdgeTraversal(EdgeType.TREE,'service-subscription', 'customer').store('x')).cap('x').unfold().dedup()"
+ }
+ },{
+ "topology-summary-fromCloudRegion":{
+ "stored-query": "builder.store('x').union(builder.newInstance().createEdgeTraversal(EdgeType.TREE, 'cloud-region', 'tenant').store('x').createEdgeTraversal(EdgeType.TREE, 'tenant', 'vserver').store('x').union(builder.newInstance().createEdgeTraversal(EdgeType.COUSIN, 'vserver', 'pserver').store('x'), builder.newInstance().createEdgeTraversal(EdgeType.COUSIN, 'vserver', 'vnfc').store('x'), builder.newInstance().createEdgeTraversal(EdgeType.COUSIN, 'vserver', 'generic-vnf').store('x').createEdgeTraversal(EdgeType.COUSIN, 'generic-vnf', 'vnfc').store('x')),builder.newInstance().createEdgeTraversal(EdgeType.COUSIN, 'cloud-region', 'pserver').store('x')).cap('x').unfold().dedup()"
+ }
+ }, {
+ "vservers-fromPserver-tree": {
+ "stored-query": "builder.createEdgeTraversal(EdgeType.COUSIN, 'pserver', 'vserver').tree()"
+ }
+ },{
+ "cloud-region-and-source-FromConfiguration":{
+ "stored-query":"builder.createEdgeTraversal(EdgeType.COUSIN, 'configuration','logical-link').createEdgeTraversalWithLabels(EdgeType.COUSIN, 'logical-link', 'l-interface',new ArrayList<>(Arrays.asList('org.onap.relationships.inventory.Source'))).createEdgeTraversal(EdgeType.TREE, 'l-interface', 'vserver').union(builder.newInstance().createEdgeTraversal(EdgeType.TREE, 'vserver', 'tenant').createEdgeTraversal(EdgeType.TREE, 'tenant', 'cloud-region').store('x'),builder.newInstance().createEdgeTraversal(EdgeType.COUSIN, 'vserver', 'vf-module').createEdgeTraversal(EdgeType.TREE, 'vf-module', 'generic-vnf').store('x')).cap('x').unfold().dedup()"
+ }
+ },{
+ "destination-FromConfiguration":{
+ "stored-query":"builder.createEdgeTraversal(EdgeType.COUSIN, 'configuration','logical-link').union(builder.newInstance().createEdgeTraversalWithLabels(EdgeType.COUSIN, 'logical-link', 'l-interface', new ArrayList<>(Arrays.asList('org.onap.relationships.inventory.Destination'))).createEdgeTraversal(EdgeType.TREE, 'l-interface', 'vserver').createEdgeTraversal(EdgeType.COUSIN, 'vserver', 'vf-module').createEdgeTraversal(EdgeType.TREE, 'vf-module', 'generic-vnf').store('x'),builder.newInstance().createEdgeTraversal(EdgeType.COUSIN, 'logical-link', 'generic-vnf').createEdgeTraversal(EdgeType.COUSIN, 'generic-vnf', 'pnf').store('x')).cap('x').unfold().dedup()"
+ }
+ },{
+ "topology-summary-fromTenant":{
+ "stored-query":"builder.store('x').union(builder.newInstance().createEdgeTraversal(EdgeType.TREE, 'tenant', 'cloud-region').store('x'),builder.newInstance().createEdgeTraversal(EdgeType.TREE, 'tenant', 'vserver').store('x').union(builder.newInstance().createEdgeTraversal(EdgeType.COUSIN, 'vserver', 'generic-vnf').store('x'),builder.newInstance().createEdgeTraversal(EdgeType.COUSIN, 'vserver', 'pserver').store('x'))).cap('x').unfold().dedup()"
+ }
+ },{
+ "vfModule-fromServiceInstance":{
+ "stored-query":"builder.createEdgeTraversal(EdgeType.COUSIN, 'service-instance','generic-vnf').createEdgeTraversal(EdgeType.TREE, 'generic-vnf', 'vf-module').store('x').cap('x').unfold().dedup()"
+ }
+ },{
+ "getComplexByPnfName":{
+ "stored-query":"builder.store('x').createEdgeTraversal(EdgeType.COUSIN,'pnf', 'complex').store('x').cap('x').unfold().dedup()"
+ }
+ },{
+ "getComplexFromHostname":{
+ "stored-query":"builder.createEdgeTraversal(EdgeType.COUSIN,'pserver', 'complex').tree()"
+ }
+ },{
+ "instance-groups-byCloudRegion":{
+ "query":{
+ "required-properties":["type","role","function"]
+ },
+ "stored-query":"builder.createEdgeTraversal(EdgeType.COUSIN, 'cloud-region', 'instance-group').getVerticesByProperty('instance-group-type', type).getVerticesByProperty('instance-group-role', role).getVerticesByProperty('instance-group-function', function).store('x').cap('x').unfold().dedup()"
+ }
+ },{
+ "network-collection-ByServiceInstance":{
+ "stored-query":"builder.store('x').createEdgeTraversal(EdgeType.COUSIN, 'service-instance', 'collection').store('x').createEdgeTraversal(EdgeType.COUSIN, 'collection', 'instance-group').store('x').createEdgeTraversal(EdgeType.COUSIN, 'instance-group', 'l3-network').store('x').cap('x').unfold().dedup()"
+ }
+ },{
"containment-path":{
"stored-query":"builder.until(builder.newInstance().not(builder.newInstance().getParentEdge())).repeat(builder.newInstance().getParentVertex()).path()"
}
- }
- ]
+ },{
+ "getSvcSubscriberModelInfo":{
+ "stored-query":"builder.store('x').union(builder.newInstance().createEdgeTraversal(EdgeType.TREE, 'service-instance', 'service-subscription').store('x'),builder.newInstance().createPrivateEdgeTraversal(EdgeType.COUSIN, 'service-instance', 'model-ver').store('x')).cap('x').unfold().dedup()"
+ }
+ },
+ {
+ "getLogicalLinkByCloudRegionId": {
+ "stored-query": "builder.store('x').createEdgeTraversal(EdgeType.COUSIN, 'cloud-region', 'logical-link').store('x').cap('x').unfold().dedup()"
+ }
+ },{
+ "getPinterfacePhysicalLinkBySvcInstId":{
+ "stored-query":"builder.store('x').createEdgeTraversal(EdgeType.COUSIN,'service-instance', 'generic-vnf').store('x').createEdgeTraversal(EdgeType.COUSIN,'generic-vnf', 'vserver').store('x').createEdgeTraversal(EdgeType.COUSIN,'vserver', 'pserver').store('x').createEdgeTraversal(EdgeType.TREE,'pserver', 'p-interface').store('x').createEdgeTraversal(EdgeType.COUSIN,'p-interface', 'physical-link').store('x').cap('x').unfold().dedup()"
+ }
+ },{
+ "topology-detail-fromVnf":{
+ "stored-query":"builder.store('x').union(builder.newInstance().createEdgeTraversal(EdgeType.COUSIN, 'generic-vnf', 'vserver').store('x').union(builder.newInstance().createEdgeTraversal(EdgeType.COUSIN, 'vserver', 'vnfc').store('x'),builder.newInstance().createEdgeTraversal(EdgeType.TREE, 'vserver', 'tenant').store('x').createEdgeTraversal(EdgeType.TREE, 'tenant', 'cloud-region').store('x').createEdgeTraversal(EdgeType.TREE, 'cloud-region', 'availability-zone').store('x'),builder.newInstance().createEdgeTraversal(EdgeType.COUSIN, 'vserver', 'image').store('x'),builder.newInstance().createEdgeTraversal(EdgeType.COUSIN, 'vserver', 'flavor').store('x'),builder.newInstance().createEdgeTraversal(EdgeType.COUSIN, 'vserver', 'pserver').store('x').createEdgeTraversal(EdgeType.COUSIN, 'pserver', 'complex').store('x'),builder.newInstance().createEdgeTraversal(EdgeType.TREE, 'vserver', 'l-interface').store('x').union(builder.newInstance().createEdgeTraversal(EdgeType.TREE, 'l-interface','l3-interface-ipv4-address-list').store('x'),builder.newInstance().createEdgeTraversal(EdgeType.TREE, 'l-interface', 'l3-interface-ipv6-address-list').store('x'))),builder.newInstance().createEdgeTraversal(EdgeType.COUSIN, 'generic-vnf', 'service-instance').store('x'),builder.newInstance().createEdgeTraversal(EdgeType.TREE, 'generic-vnf', 'vf-module').createEdgeTraversal(EdgeType.COUSIN, 'vf-module', 'volume-group').store('x')).cap('x').unfold().dedup()"}
+ },{
+ "vnf-to-service-instance":{
+ "stored-query":"builder.store('x').createEdgeTraversal(EdgeType.COUSIN, 'generic-vnf', 'service-instance').store('x').createEdgeTraversal(EdgeType.COUSIN, 'service-instance', 'generic-vnf').store('x').cap('x').unfold().dedup()"}
+ },{
+ "getServiceTopology":{
+ "stored-query":"builder.union(builder.newInstance().createEdgeTraversal(EdgeType.COUSIN, 'service-instance', 'generic-vnf').union(builder.newInstance().createEdgeTraversal(EdgeType.TREE, 'generic-vnf', 'l-interface').union(builder.newInstance().createEdgeTraversal(EdgeType.TREE, 'l-interface', 'l3-interface-ipv4-address-list'),builder.newInstance().createEdgeTraversal(EdgeType.TREE, 'l-interface', 'l3-interface-ipv6-address-list'),builder.newInstance().createEdgeTraversal(EdgeType.TREE, 'l-interface', 'vlan').union(builder.newInstance().createEdgeTraversal(EdgeType.TREE, 'vlan', 'l3-interface-ipv4-address-list'),builder.newInstance().createEdgeTraversal(EdgeType.TREE, 'vlan', 'l3-interface-ipv6-address-list'))),builder.newInstance().createEdgeTraversal(EdgeType.COUSIN, 'generic-vnf', 'vserver').union(builder.newInstance().createEdgeTraversal(EdgeType.TREE, 'vserver', 'l-interface').union(builder.newInstance().createEdgeTraversal(EdgeType.TREE, 'l-interface', 'l3-interface-ipv4-address-list'),builder.newInstance().createEdgeTraversal(EdgeType.TREE, 'l-interface', 'l3-interface-ipv6-address-list'),builder.newInstance().createEdgeTraversal(EdgeType.TREE, 'l-interface', 'vlan').union(builder.newInstance().createEdgeTraversal(EdgeType.TREE, 'vlan', 'l3-interface-ipv4-address-list'),builder.newInstance().createEdgeTraversal(EdgeType.TREE, 'vlan', 'l3-interface-ipv6-address-list'))),builder.newInstance().createEdgeTraversal(EdgeType.COUSIN, 'vserver', 'pserver').createEdgeTraversal(EdgeType.COUSIN, 'pserver', 'complex'))),builder.newInstance().createEdgeTraversal(EdgeType.COUSIN, 'service-instance', 'allotted-resource').createEdgeTraversal(EdgeType.TREE, 'allotted-resource', 'service-instance').createEdgeTraversal(EdgeType.COUSIN, 'service-instance', 'generic-vnf').union(builder.newInstance().createEdgeTraversal(EdgeType.TREE, 'generic-vnf', 'l-interface').union(builder.newInstance().createEdgeTraversal(EdgeType.TREE, 'l-interface', 'l3-interface-ipv4-address-list'),builder.newInstance().createEdgeTraversal(EdgeType.TREE, 'l-interface', 'l3-interface-ipv6-address-list'),builder.newInstance().createEdgeTraversal(EdgeType.TREE, 'l-interface', 'vlan').union(builder.newInstance().createEdgeTraversal(EdgeType.TREE, 'vlan', 'l3-interface-ipv4-address-list'),builder.newInstance().createEdgeTraversal(EdgeType.TREE, 'vlan', 'l3-interface-ipv6-address-list'))),builder.newInstance().createEdgeTraversal(EdgeType.COUSIN, 'generic-vnf', 'vserver').union(builder.newInstance().createEdgeTraversal(EdgeType.TREE, 'vserver', 'l-interface').union(builder.newInstance().createEdgeTraversal(EdgeType.TREE, 'l-interface', 'l3-interface-ipv4-address-list'),builder.newInstance().createEdgeTraversal(EdgeType.TREE, 'l-interface', 'l3-interface-ipv6-address-list'),builder.newInstance().createEdgeTraversal(EdgeType.TREE, 'l-interface', 'vlan').union(builder.newInstance().createEdgeTraversal(EdgeType.TREE, 'vlan', 'l3-interface-ipv4-address-list'),builder.newInstance().createEdgeTraversal(EdgeType.TREE, 'vlan', 'l3-interface-ipv6-address-list')))))).tree()"}
+ },
+ {
+ "getL3networkCloudRegionByNetworkRole": {
+ "stored-query": "builder.store('x').createEdgeTraversal(EdgeType.COUSIN, 'l3-network', 'generic-vnf').store('x').createEdgeTraversal(EdgeType.COUSIN, 'generic-vnf', 'vserver').store('x').createEdgeTraversal(EdgeType.TREE, 'vserver', 'tenant').store('x').createEdgeTraversal(EdgeType.TREE, 'tenant', 'cloud-region').store('x').cap('x').unfold().dedup()"
+ }
+ },{
+ "getDHVLogicalLink": {
+ "stored-query": "builder.createEdgeTraversal(EdgeType.TREE, 'generic-vnf', 'l-interface').createEdgeTraversal(EdgeType.TREE, 'l-interface', 'vlan').createEdgeTraversal(EdgeType.COUSIN, 'vlan', 'logical-link').tree()"
+ }
+ },
+ {
+ "pserver-fromHostnameFirstToken": {
+ "query":{
+ "required-properties":["hostnameFirstToken","sourcesOfTruth"]
+ },
+ "stored-query": "builder.getVerticesStartsWithProperty('hostname', hostnameFirstToken).getVerticesByProperty('source-of-truth', new ArrayList<>(Arrays.asList(sourcesOfTruth)))"
+ }
+ },
+ {
+ "pserver-fromFqdnFirstToken": {
+ "query":{
+ "required-properties":["fqdnFirstToken","sourcesOfTruth"]
+ },
+ "stored-query": "builder.getVerticesStartsWithProperty('fqdn', fqdnFirstToken).getVerticesByProperty('source-of-truth', new ArrayList<>(Arrays.asList(sourcesOfTruth)))"
+ }
+ },
+ {
+ "getLinterface-fromNewvce": {
+ "query":{
+ "required-properties":["interfaceRole1","interfaceRole2"]
+ },
+ "stored-query": "builder.createEdgeTraversal(EdgeType.TREE, 'newvce', 'l-interface').getVerticesByProperty('interface-role', interfaceRole1).createEdgeTraversal(EdgeType.COUSIN, 'l-interface', 'logical-link').createEdgeTraversal(EdgeType.COUSIN, 'logical-link', 'l-interface').getVerticesByProperty('interface-role', interfaceRole2).store('x').cap('x').unfold().dedup()"
+ }
+ },
+ {
+ "l-interface-to-CP": {
+ "query":{
+ "required-properties":["isProviderNetwork"]
+ },
+ "stored-query": "builder.union(builder.newInstance().createEdgeTraversal(EdgeType.TREE, 'vnfc', 'cp').union(builder.newInstance().createEdgeTraversal(EdgeType.COUSIN, 'cp', 'vlan-tag').store('x'),builder.newInstance().createEdgeTraversal(EdgeType.COUSIN, 'cp', 'l3-network').getVerticesByBooleanProperty('is-provider-network', isProviderNetwork).store('x')),builder.newInstance().createEdgeTraversal(EdgeType.COUSIN, 'vnfc', 'vserver').union(builder.newInstance().createEdgeTraversal(EdgeType.TREE, 'vserver', 'l-interface').store('x'))).cap('x').unfold().dedup()"
+ }
+ },
+ {
+ "getNetworks": {
+ "query":{
+ "required-properties":["networkRole","cloudRegionId"]
+ },
+ "stored-query": "builder.createEdgeTraversal(EdgeType.COUSIN, 'owning-entity','service-instance').createEdgeTraversal(EdgeType.COUSIN, 'service-instance', 'l3-network').getVerticesByProperty('network-role', networkRole).where(builder.newInstance().createEdgeTraversal(EdgeType.COUSIN, 'l3-network', 'cloud-region').getVerticesByProperty('cloud-region-id', cloudRegionId)).store('x').cap('x').unfold().dedup()"
+ }
+ },
+ {
+ "fabric-information-fromVnf":{
+ "stored-query":"builder.store('x').createEdgeTraversal(EdgeType.COUSIN, 'generic-vnf', 'vserver').store('x').union(builder.newInstance().createEdgeTraversal(EdgeType.TREE, 'vserver', 'l-interface').createEdgeTraversal(EdgeType.TREE, 'l-interface', 'sriov-vf').createEdgeTraversal(EdgeType.COUSIN, 'sriov-vf', 'sriov-pf').createEdgeTraversal(EdgeType.TREE, 'sriov-pf', 'p-interface').store('x').createEdgeTraversal(EdgeType.TREE, 'p-interface', 'pserver').store('x'), builder.newInstance().createEdgeTraversal(EdgeType.COUSIN, 'vserver', 'vnfc').createEdgeTraversal(EdgeType.TREE, 'vnfc', 'cp').createEdgeTraversal(EdgeType.COUSIN, 'cp', 'vlan-tag').store('x')).cap('x').unfold().dedup()"
+ }
+ },
+ {
+ "getNetworksByServiceInstance": {
+ "stored-query": "builder.createEdgeTraversal(EdgeType.COUSIN, 'service-instance', 'l3-network').store('x').union(builder.newInstance().createEdgeTraversal(EdgeType.COUSIN, 'l3-network', 'vlan-tag').store('x'),builder.newInstance().createEdgeTraversal(EdgeType.COUSIN, 'l3-network', 'l3-network').store('x').createEdgeTraversal(EdgeType.COUSIN, 'l3-network', 'vlan-tag').store('x')).cap('x').unfold().dedup()"
+ }
+ }
+ ]
}
diff --git a/aai-traversal/src/main/scripts/common_functions.sh b/aai-traversal/src/main/scripts/common_functions.sh
index 8bd881a..3aeb865 100644
--- a/aai-traversal/src/main/scripts/common_functions.sh
+++ b/aai-traversal/src/main/scripts/common_functions.sh
@@ -29,7 +29,7 @@ execute_spring_jar(){
shift 2;
- EXECUTABLE_JAR=$(ls ${PROJECT_HOME}/lib/aai-traversal-*SNAPSHOT.jar);
+ EXECUTABLE_JAR=$(ls ${PROJECT_HOME}/lib/*.jar);
JAVA_OPTS="${JAVA_PRE_OPTS}";
JAVA_OPTS="-DAJSC_HOME=$PROJECT_HOME";
@@ -40,6 +40,14 @@ execute_spring_jar(){
JAVA_OPTS="$JAVA_OPTS -Dlogback.configurationFile=${logbackFile}";
JAVA_OPTS="${JAVA_OPTS} ${JAVA_POST_OPTS}";
+ export SOURCE_NAME=$(grep '^schema.source.name=' ${PROJECT_HOME}/resources/application.properties | cut -d"=" -f2-);
+ # Needed for the schema ingest library beans
+ eval $(grep '^schema\.' ${PROJECT_HOME}/resources/application.properties | \
+ sed 's/^\(.*\)$/JAVA_OPTS="$JAVA_OPTS -D\1"/g' | \
+ sed 's/${server.local.startpath}/${PROJECT_HOME}\/resources/g'| \
+ sed 's/${schema.source.name}/'${SOURCE_NAME}'/g'\
+ )
+
${JAVA_HOME}/bin/java ${JVM_OPTS} ${JAVA_OPTS} -jar ${EXECUTABLE_JAR} "$@"
}
diff --git a/aai-traversal/src/main/scripts/install/instutils.sh b/aai-traversal/src/main/scripts/install/instutils.sh
deleted file mode 100644
index ab94a9c..0000000
--- a/aai-traversal/src/main/scripts/install/instutils.sh
+++ /dev/null
@@ -1,725 +0,0 @@
-#!/bin/ksh
-#
-# ============LICENSE_START=======================================================
-# org.onap.aai
-# ================================================================================
-# Copyright © 2017 AT&T Intellectual Property. All rights reserved.
-# ================================================================================
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-# ============LICENSE_END=========================================================
-#
-# ECOMP is a trademark and service mark of AT&T Intellectual Property.
-#
-
-ECHO=${ECHO:-echo}
-
-q_flags="-qq -k$$"
-
-show_install=${PROJECT_HOME}/install/show_install
-
-############################################################################
-# checkgroup groupname gid
-# checks if group is already in /etc/group and if it has the right gid
-# if it's not there, it adds it
-# gid can be DC if you don't care
-############################################################################
-checkgroup () {
- ecode=0
- OFILE=/tmp/group.$$
- getent group "$1" > $OFILE
- if [ $? -eq 0 ]
- then
- CHECKGID=$( grep "^$1:" $OFILE | cut -f3 -d: 2>/dev/null )
- CHECKGROUPPRESENT=$( grep "^$1:" $OFILE | cut -f1 -d: 2>/dev/null )
- CHECKGROUP=$( grep ":$2:" $OFILE | cut -f1 -d: 2>/dev/null )
- fi
- if [ "${CHECKGID}" = "" -a "${CHECKGROUP}" = "" ]
- then
- ${ECHO} "Adding $1 group ..."
- if [ "$2" = "DC" ]
- then
- groupadd $1
- else
- groupadd -g $2 $1
- fi
- if [ "$?" != "0" ]
- then
- ${ECHO} "Cannot add group $1, continuing..."
- ecode=1
- fi
- else
- if [ "${CHECKGROUPPRESENT}" = "$1" ]
- then
- if [ "$2" != "DC" ]
- then
- if [ "${CHECKGID}" != "$2" ]
- then
- ${ECHO} "ERROR: $1 group added but with wrong gid \"${CHECKGID}\"; should be $2"
- ecode=1
- fi
- if [ "${CHECKGROUP}" != "$1" ]
- then
- ${ECHO} "ERROR: wrong group \"${CHECKGROUP}\" for gid $2, group should be $1"
- ecode=1
- fi
- else
- ${ECHO} "$1 group has already been added"
- fi
- fi
- fi
- rm -f $OFILE
- return ${ecode}
-}
-
-############################################################################
-# checkuser username uid homedir shell group
-# checks if the username/uid/homedir/shell combo is already in /etc/passwd
-# if not, it adds it
-# if the login is there and the uid belongs to a different user, it errors
-# if the login is there and the shell is not correct, it errors
-# uid may be DC for don't care
-############################################################################
-checkuser () {
- ecode=0
- OFILE=/tmp/user.$$
- getent passwd $1 > $OFILE
- if [ $? -eq 0 ]
- then
- CHECKUID=$( grep "^$1:" $OFILE | cut -f3 -d: 2>/dev/null )
- CHECKLOGIN=$( grep ":x:$2:" $OFILE | cut -f1 -d: 2>/dev/null )
- CHECKLOGINPRESENT=$( grep "^$1:" $OFILE | cut -f1 -d: 2>/dev/null )
- CHECKSHELL=$( grep "^$1:" $OFILE | cut -f7 -d: 2>/dev/null )
- CHECKHOME=$( grep "^$1:" $OFILE | cut -f6 -d: 2>/dev/null )
- fi
-
- if [ ! -d $3 ]
- then
- mkdir -p $3
- if [ "$?" != "0" ]
- then
- ${ECHO} "mkdir -p $3 failed"
- ecode=1
- fi
- chmod -R 755 $3
- fi
- if [ "${CHECKUID}" = "" -a "${CHECKLOGIN}" = "" ]
- then
- ${ECHO} "Adding $1 login ..."
- if [ "$2" = "DC" ]
- then
- useradd -g $5 -d $3 -s $4 -c "$1 LOGIN" -m $1
- else
- useradd -u $2 -g $5 -d $3 -s $4 -c "$1 LOGIN" -m $1
- fi
- if [ "$?" != "0" ]
- then
- ${ECHO} "Cannot add $1 login, continuing..."
- ecode=1
- fi
- elif [ "${CHECKLOGINPRESENT}" = "$1" -a "$2" = "DC" -a "${CHECKSHELL}" = "$4" -a "${CHECKHOME}" = "$3" ]
- then
- ${ECHO} "The '$1' login has already been added to system with UID ${CHECKUID}."
-
- elif [ "${CHECKUID}" = "$2" -a "${CHECKLOGIN}" = "$1" -a "${CHECKSHELL}" = "$4" -a "${CHECKHOME}" = "$3" ]
- then
- ${ECHO} "The '$1' login has already been added to system."
- else
- if [ "$2" != "DC" -a "${CHECKUID}" != "$2" ]
- then
- ${ECHO} "ERROR: $1 login added but with wrong uid \"${CHECKUID}\"; should be $2"
- ecode=1
- fi
- if [ "$2" != "DC" -a "${CHECKLOGIN}" != "$1" ]
- then
- ${ECHO} "ERROR: wrong login \"${CHECKLOGIN}\" for uid $2, login should be $1"
- ecode=1
- fi
- if [ "${CHECKHOME}" != "$3" ]
- then
- ${ECHO} "ERROR: wrong home directory \"${CHECKHOME}\" for login $1, should be $3"
- ecode=1
- fi
- if [ "${CHECKSHELL}" != "$4" ]
- then
- ${ECHO} "ERROR: $1 login not set up with $4"
- ecode=1
- fi
- fi
- rm -f $OFILE
- return ${ecode}
-}
-
-############################################################################
-# checkhome username homedir action
-# if the user doesn't exist, it errors
-# checks if the username has homedir as its home directory
-# if not and action is null, it modifies it
-# if not and action is mod, it modifies it
-# if not and action is error, it errors
-############################################################################
-checkhome () {
- ecode=0
- OFILE=/tmp/user.$$
- getent passwd $1 > $OFILE
- if [ $? -eq 0 ]
- then
- CHECKUID=$( grep "^$1:" $OFILE | cut -f3 -d: 2>/dev/null )
- CHECKGID=$( grep "^$1:" $OFILE | cut -f4 -d: 2>/dev/null )
- CHECKHOME=$( grep "^$1:" $OFILE | cut -f6 -d: 2>/dev/null )
-
- if [ "${CHECKHOME}" = "$2" ]
- then
- if [ ! -d $2 ]
- then
- mkdir -p $2
- if [ "$?" != "0" ]
- then
- ${ECHO} "mkdir -p $2 failed"
- ecode=1
- fi
- chown ${CHECKUID}:${CHECKGID} $2
- chmod -R 755 $2
- fi
- else
- # modify the user to set the new home dir and move any current home dir to there
- usermod -d $2 -m $1
- if [ "$?" != "0" ]
- then
- ${ECHO} "usermod -d $2 -m $1 failed"
- ecode=1
- fi
- fi
- else
- ${ECHO} "user $1 doesn't exist"
- ecode=1
- fi
-
- rm -f $OFILE
- return ${ecode}
-}
-
-##################################################################
-#checkloginsforpwds checks /etc/shadow for logins without passwords
-# the first argument is a list of logins to check
-##################################################################
-checkloginsforpwds () {
- for i in $1
- do
- CHECK_LOGIN=$( grep "^${i}:" /etc/shadow | grep "!!" )
- if [ "${CHECK_LOGIN}" != "" ]
- then
- NOPWD="${NOPWD} ${i}"
- fi
- done
-
- if [ "${NOPWD}" != "" ]
- then
- ${ECHO} ""
- ${ECHO} "REMINDER: The following logins must have a passwords assigned to them.\n"
- ${ECHO} "##############################################################"
- ${ECHO} " ${NOPWD} "
- ${ECHO} "##############################################################"
- ${ECHO} ""
- ${ECHO} " This must be done by executing the following command:"
- ${ECHO} ""
- ${ECHO} " $ passwd <login>"
- ${ECHO} ""
- ${ECHO} " After typing the \"passwd\" command you will be prompted for"
- ${ECHO} " the password for the login."
- ${ECHO} ""
- fi
-}
-
-##################################################################
-# checkassignpasswords checks /etc/shadow for logins without passwords
-# and then asks the user to assign one
-# the first argument is a list of logins to check
-##################################################################
-checkassignpasswords () {
- for i in $1
- do
- CHECK_LOGIN=$( grep "^${i}:" /etc/shadow | grep LK )
- if [ "${CHECK_LOGIN}" != "" ]
- then
- ${ECHO} "Please assign a password for the '${i}' login"
- passwd ${i}
- ${ECHO}
- fi
- done
-}
-
-############################################################################
-# copywithperms origfile destfile owner group perms [save suffix]
-# copies origfile to destfile, giving destfile ownership and permssions
-# from owner, group, and perms. If the sixth argument is "save", the
-# original is saved in the same place with the seventh argument as the
-# suffix. If the seventh arg is null, $$ is used
-############################################################################
-copywithperms () {
- SAVE=0
- ECODE=0
- if [ "$6" = "save" -a -f "$2" ]
- then
- if [ "$7" = "" ]
- then
- cp $2 $2.$$
- else
- cp $2 $2.$7
- fi
- fi
- if [ -f $1 ]
- then
- cp $1 $2
- ECODE=$?
- chown ${3}:${4} $2
- chmod $5 $2
- else
- ${ECHO} "$1 is not a file. No copy done!"
- fi
- return ${ECODE}
-}
-
-############################################################################
-# mkdirwithperms dirname owner group perms ifExist
-# makes directory dirname , giving dirname ownership and permssions
-# from owner, group, and perms.
-# perms can be DC if you don't care
-# ifExist can be rm, error, dontcreate
-############################################################################
-mkdirwithperms () {
- ECODE=0
- if [ -f $1 ]
- then
- ECODE=1
- ${ECHO} "$1 exists but is a file. No mkdir done!"
- elif [ -d $1 ]
- then
- if [ "$5" = "rm" ]
- then
- rm -rf $1
- mkdir -p $1
- if [ "$?" != "0" ]
- then
- ${ECHO} "mkdir -p $1 failed"
- ECODE=1
- fi
- elif [ "$5" = "error" ]
- then
- ECODE=1
- ${ECHO} "$1 is a directory. No mkdir done!"
- elif [ "$5" != "dontcreate" ]
- then
- mkdir -p $1
- if [ "$?" != "0" ]
- then
- ${ECHO} "mkdir -p $1 failed"
- ECODE=1
- fi
- fi
- else
- mkdir -p $1
- if [ "$?" != "0" ]
- then
- ${ECHO} "mkdir -p $1 failed"
- ECODE=1
- fi
- fi
- if [ "${ECODE}" = "0" ]
- then
- chown ${2}:${3} $1
- if [ "$4" != "DC" ]
- then
- chmod $4 $1
- fi
- fi
- return ${ECODE}
-}
-
-
-############################################################################
-# chownwithperms owner group file mode
-# changes the ownership and mode for the specified file
-############################################################################
-chownwithperms () {
- chown ${1}:${2} $3
- chmod $4 $3
-}
-
-verifywhosrunning () {
- userid=$( id | cut -f2 -d"(" | cut -f1 -d")" )
- if [ "${userid}" != "$1" ]
- then
- ${ECHO} "You must be $1 to run $0"
- exit 1
- fi
-}
-
-replaceline() {
-
- name=$1
- value=$2
- file=$3
-
- if [ -z "${file}" ]
- then
- ${ECHO} "replaceline: ERROR: insufficient arguments: $1 $2" >&2
- return 1
- fi
-
- if [ -n "$4" ]
- then
- ${ECHO} "replaceline: ERROR: too many arguments: $1 $2 $3 $4" >&2
- return 1
- fi
-
- if [ -f ${file} ]
- then
- grep -v "^${name}=" ${file} > ${file}.$$
- ${ECHO} "${name}=${value}" >> ${file}.$$
- mv -f ${file}.$$ ${file}
- else
- ${ECHO} "${name}=${value}" > ${file}
- fi
-}
-
-replaceline_with_quotes() {
-
- name=$1
- value=$2
- file=$3
-
- if [ -z "${file}" ]
- then
- ${ECHO} "replaceline: ERROR: insufficient arguments: $1 $2" >&2
- return 1
- fi
-
- if [ -n "$4" ]
- then
- ${ECHO} "replaceline: ERROR: too many arguments: $1 $2 $3 $4" >&2
- return 1
- fi
-
- if [ -f ${file} ]
- then
- grep -v "^${name}=" ${file} > ${file}.$$
- ${ECHO} "${name}=\"${value}\"" >> ${file}.$$
- mv -f ${file}.$$ ${file}
- else
- ${ECHO} "${name}=\"${value}\"" > ${file}
- fi
-}
-
-# this deleteline will not actually delete the entry
-# but only delete the value leaving the name=
-# when siteconf.pl went from Boilerplate to Fillin,
-# we changed this because Fillin can handle null values.
-
-deleteline() {
-
- name=$1
- file=$2
-
- if [ -z "${file}" ]
- then
- ${ECHO} "deleteline: ERROR: insufficient arguments" >&2
- return 1
- fi
-
- if [ -f ${file} ]
- then
- cp ${file} ${file}.$$
- lno=$( grep -n "^${name}=" ${file} | cut -d: -f1 )
- if [ "${lno}" != "" ]
- then
- sed "${lno}d" ${file} > ${file}.$$
- fi
- ${ECHO} "${name}=" >> ${file}.$$
- mv -f ${file}.$$ ${file}
- else
- ${ECHO} "${name}=" > ${file}
- fi
-}
-
-# dropline will drop the line from the file
-# unlike the deleteline function above
-
-dropline() {
-
- name=$1
- file=$2
-
- if [ -z "${file}" ]
- then
- ${ECHO} "dropline: ERROR: insufficient arguments" >&2
- return 1
- fi
-
- if [ -f ${file} ]
- then
- grep -v "^${name}=" ${file} > ${file}.$$
- mv -f ${file}.$$ ${file}
- fi
-}
-
-pause_install() {
-
- if [ "${Pause}" = "1" ]
- then
- if ${chkyn} -y "Continue with ${Itype}?"
- then
- return 0
- else
- ${ECHO} "${PNAME}: quitting" >&2
- exit 1
- fi
- fi
-}
-
-get_ITYPE() {
- ITYPE=$( ${chkyn} -fer ${q_flags} -h\? ${ITYPE:+-D"${ITYPE}"} -H \
-" If you are doing a fresh install, answer 'I' or answer 'U' for upgrade." \
-"Is this a fresh 'install' or 'upgrade' (I or U):${ITYPE:+ [${ITYPE}]}" \
- '^[IU]$' \
-'*** ERROR *** Entry must be I or U.' )
-}
-
-
-###
-# Change an /etc/group entry to allow a give user to change group into it.
-# arg1 = comma-sep group list (e.g., sylantro,other)
-# arg2 = user
-###
-addUserToGroup()
-{
- if [ -z "$1" -o -z "$2" ]
- then
- ${ECHO} "addUserToGroup failed, need two args, group and user"
- return 1
- else
- usermod -G $1 $2
- fi
- return 0
-}
-
-################### BACKUP AND RESTORE METHODS ########################
-################### VARIABLES ##########################
-################### VARIABLES ##########################
-################### VARIABLES ##########################
-################### VARIABLES ##########################
-
-NO_FILE_INDICATOR="__NO_PREVIOUS_FILE__"
-SAVE_SUFFIX=${Project}save
-
-################### SUBROUTINES ##########################
-################### SUBROUTINES ##########################
-################### SUBROUTINES ##########################
-################### SUBROUTINES ##########################
-################### SUBROUTINES ##########################
-
-##############################################################################
-# Purpose: make a backup copy of a file in such a way that the backup
-# won't be lost by re-running your script PLUS give you a predictable name
-# for the most recent back up to use when you roll back.
-#
-# Input:
-# - Arg1 = file to back up
-#
-# Requirement:
-# - Remove $1.save before calling this function or else a copy won't be made.
-# - Make sure to set the value of env value TODAY to use as a suffix.
-#
-# Description:
-# Copy $1 to $1.${SAVE_SUFFIX}.${TODAY}, then link that to $1.save.
-#
-##############################################################################
-make_backup_copy ()
-{
- if [ -z "${TODAY}" ]
- then
- ${ECHO} "make_backup_copy - TODAY variable is unset" >&2
- return 1
- fi
-
- if [ -f $1.${SAVE_SUFFIX}.${TODAY} -a -h $1.save ]
- then
- ${ECHO} "Note: backup already exists for $1"
- else
- # if existing file doesn't exist, set up for later delete by rollback
- if [ ! -f $1 -a ! -h $1 ]
- then
- ${ECHO} ${NO_FILE_INDICATOR} > $1
- fi
- cp -p $1 $1.${SAVE_SUFFIX}.${TODAY}
- ln -s $1.${SAVE_SUFFIX}.${TODAY} $1.save
- fi
-}
-
-################################################################################
-# Purpose: Find the actual file that belongs to $1, which can be a symbolic
-# link.
-#
-# Input:
-# - Arg1 = path to file or link
-# - Arg2 = true if you want _SRCFILE to be null if no actual file is
-# found. If Arg2 is NOT true, then _SRCFILE is set to Arg1.
-#
-# Side Effect:
-# Sets value of _SRCFILE variable
-################################################################################
-find_source_file ()
-{
- if [ -z "$1" ]
- then
- ${ECHO} "find_source_file - needs at least one argument" >&2
- return 1
- fi
-
- ls -l $1 > /tmp/tls$$
- cat /tmp/tls$$ | sed 's/ */ /g' |cut -f11 > /tmp/cuts$$
- _SRCFILE=$( cat /tmp/cuts$$ )
-
- if [ "$_SRCFILE" = "" ]
- then
- if [ "$2" != "true" ]
- then
- _SRCFILE=$1
- fi
- fi
- rm -f /tmp/tls$$ /tmp/cuts$$
-}
-
-#######################################################################
-# Purpose: Expands template file using data in COPT variable.
-# Diffs expanded template against existing file and installs if different.
-# If arg5 = true, sets _config_changes=1 so you know that changes were installed
-#
-# Makes its own backup copy using make_backup_copy.
-# Does install if different using install_if_different.
-#
-# Input:
-# Arg1 = template path without .tmpl extension
-# Arg2 = install path
-# Arg3 = owner and group (e.g., root:other)
-# Arg4 = permissions (e.g., 750)
-# Arg5 = true/false, if expanded file is different than installed .
-# Set _config_changes to 1 if Arg5 is true. Otherwise, don't touch
-# _config_changes
-#
-# Requirement: set COPT to the value of the -c option to siteconf.pl
-#
-# Side Effect: sets _config_changes=1 if changes were installed
-#######################################################################
-install_from_template ()
-{
- if [ -z "${COPT}" ]
- then
- ${ECHO} "install_from_template - COPT is unset" >&2
- return 1
- fi
-
- TMPL=$( basename ${1} )
- OFILE=/tmp/${TMPL}
- if [ -f ${1}.tmpl ]
- then
-
- ${PROJECT_HOME}/bin/siteconf.pl -t ${1}.tmpl -c ${COPT} -o ${OFILE}
- install_if_different ${OFILE} ${2} ${3} ${4} ${5}
-
- else
- ${ECHO} "install_from_template: ERROR: Missing ${TMPL}.tmpl" >&2
- fi
- rm -f ${OFILE}
-}
-
-
-#######################################################################
-# Purpose: Copies source to destination if the two are different.
-# If arg5 = true, sets _config_changes=1 so you know that changes were installed
-#
-# Makes its own backup copy using make_backup_copy.
-#
-# Input:
-# Arg1 = source path
-# Arg2 = install path
-# Arg3 = owner and group (e.g., root:other)
-# Arg4 = permissions (e.g., 750)
-# Arg5 = true/false, if expanded file is different than installed .
-# Set _config_changes to 1 if Arg5 is true. Otherwise, don't touch
-# _config_changes
-#
-# Side Effect: sets _config_changes=1 if changes were installed
-#######################################################################
-install_if_different()
-{
- # Take backup before changing.
- # Only change if different.
- if [ -f ${2} ]
- then
- diff ${1} ${2} > /dev/null
- diffrc=$?
- if [ "${diffrc}" != "0" ]
- then
- ${ECHO} "Installing ${2}"
- make_backup_copy ${2}
- mv -f ${1} ${2}
- chown ${3} ${2}
- chmod ${4} ${2}
- if [ "${5}" = "true" ]
- then
- _config_changes=1
- fi
- fi
- else
- # creates backup containing ${NO_FILE_INDICATOR} for rollback removal
- make_backup_copy ${2}
- mv -f ${1} ${2}
- chown ${3} ${2}
- chmod ${4} ${2}
- if [ "${5}" = "true" ]
- then
- _config_changes=1
- fi
- fi
-}
-###################################################################
-# Purpose: rollback a file whose backup was made with make_backup_copy
-#
-# Input:
-# Arg1 is path of installed file. Subroutine will look for ${1}.save
-# Arg2 = true/false, if expanded file is different than installed,
-# set _config_changes to 1 if Arg2 is true. Otherwise, don't touch
-# _config_changes
-#
-# Side Effect: sets _config_changes=1 if changes were rolled back
-###################################################################
-rollback_from_save ()
-{
- if [ -f ${1}.save -o -h ${1}.save ]
- then
- find_source_file ${1}.save false
- ${ECHO} "rollback_from_save: rolling back to $( basename ${_SRCFILE} )"
- grep ${NO_FILE_INDICATOR} ${_SRCFILE} > /dev/null
- if [ $? -eq 0 ]
- then
- rm -f ${_SRCFILE} ${1}
- else
- mv -f ${_SRCFILE} ${1}
- fi
- if [ "${2}" = "true" ]
- then
- _config_changes=1
- fi
- rm -f ${1}.save
- fi
-}
diff --git a/aai-traversal/src/main/scripts/putTool.sh b/aai-traversal/src/main/scripts/putTool.sh
index 6630d8f..593d0c9 100644
--- a/aai-traversal/src/main/scripts/putTool.sh
+++ b/aai-traversal/src/main/scripts/putTool.sh
@@ -50,12 +50,10 @@ display_usage() {
cat <<EOF
Usage: $0 [options]
- 1. Usage: putTool.sh <resource-path> <json payload file> <optional HTTP Response code> <optional -display>
+ 1. Usage: putTool.sh <resource-path> <json payload file> <optional -display>
2. This script requires two arguments, a resource path and a file path to a json file containing the payload.
- 3. Example: query?format=xxxx customquery.json (possible formats are simple, raw, console, count, graphson, id, pathed, resource and resource_and_url)
- 4. Adding the optional HTTP Response code will allow the script to ignore HTTP failure codes that match the input parameter.
- 5. Adding the optional "-display" argument will display all data returned from the request, instead of just a response code.
-
+ 3. Example: resource-path and payload for a particular customer is: business/customers/customer/JohnDoe customerpayload.json
+ 4. Adding the optional "-display" argument will display all data returned from the request.
EOF
}
if [ $# -eq 0 ]; then
@@ -130,24 +128,30 @@ else
fi
fi
+fname=$JSONFILE
+if [ -f /tmp/$(basename $JSONFILE) ]; then
+ fname=/tmp/$(basename $JSONFILE)
+elif [ ! -f $JSONFILE ]; then
+ echo "The file $JSONFILE does not exist"
+ exit -1
+fi
+
if [ $MISSING_PROP = false ]; then
if [ $USEBASICAUTH = false ]; then
AUTHSTRING="--cert $PROJECT_HOME/resources/etc/auth/aaiClientPublicCert.pem --key $PROJECT_HOME/resources/etc/auth/aaiClientPrivateKey.pem"
else
AUTHSTRING="-u $CURLUSER:$CURLPASSWORD"
fi
-
if [ $RETURNRESPONSE = true ]; then
- curl --request PUT -sL -k $AUTHSTRING -H "Content-Type: application/json" -H "X-FromAppId: $XFROMAPPID" -H "X-TransactionId: $XTRANSID" -H "Accept: application/json" -T $JSONFILE $RESTURL$RESOURCE | python -mjson.tool
+ curl --request PUT -sL -k $AUTHSTRING -H "X-FromAppId: $XFROMAPPID" -H "X-TransactionId: $XTRANSID" -H "Accept: application/json" -H "Content-Type: application/json" -T $fname $RESTURL$RESOURCE | jq '.'
RC=$?
else
- result=`curl --request PUT -sL -w "%{http_code}" -o /dev/null -k $AUTHSTRING -H "Content-Type: application/json" -H "X-FromAppId: $XFROMAPPID" -H "X-TransactionId: $XTRANSID" -H "Accept: application/json" -T $JSONFILE $RESTURL$RESOURCE`
+ result=`curl --request PUT -w "%{http_code}" -o /dev/null -k $AUTHSTRING -H "X-FromAppId: $XFROMAPPID" -H "X-TransactionId: $XTRANSID" -H "Accept: application/json" -H "Content-Type: application/json" -T $fname $RESTURL$RESOURCE`
#echo "result is $result."
RC=0;
if [ $? -eq 0 ]; then
case $result in
+([0-9])?)
- #if [[ "$result" -eq 412 || "$result" -ge 200 && $result -lt 300 ]]
if [[ "$result" -ge 200 && $result -lt 300 ]]
then
echo "PUT result is OK, $result"
@@ -184,4 +188,4 @@ else
fi
echo `date` " Done $0, returning $RC"
-exit $RC
+exit $RC \ No newline at end of file
diff --git a/aai-traversal/src/main/swm/package/nix/common/deinstall.env b/aai-traversal/src/main/swm/package/nix/common/deinstall.env
deleted file mode 100644
index fb0a9f5..0000000
--- a/aai-traversal/src/main/swm/package/nix/common/deinstall.env
+++ /dev/null
@@ -1,10 +0,0 @@
-
-# This file is used to set the environment which the install_*.sh files
-# will use when executing. Only set variables that must be derived at
-# installation time here. For variables that should be set by the installer
-# in SWM, add VariableDescriptor elements to the descriptor.xml. Place
-# logical steps in the install_preproc.sh or install_postproc.sh.
-
-. `dirname $0`/common.env
-
-AAI_USER=aaiadmin;export AAI_USER
diff --git a/aai-traversal/src/main/swm/package/nix/common/install_postproc.sh b/aai-traversal/src/main/swm/package/nix/common/install_postproc.sh
deleted file mode 100644
index ab5f2b7..0000000
--- a/aai-traversal/src/main/swm/package/nix/common/install_postproc.sh
+++ /dev/null
@@ -1,39 +0,0 @@
-#!/bin/sh
-
-###
-# ============LICENSE_START=======================================================
-# org.onap.aai
-# ================================================================================
-# Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
-# ================================================================================
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-# ============LICENSE_END=========================================================
-###
-
-##############################################################################
-# - SCLD GRM SERVICE
-# - Copyright 2009 AT&T Intellectual Properties
-##############################################################################
-
-
-. `dirname $0`/install.env
-
-cd ${ROOT_DIR};
-
-TEMPLATE_YAML_FILE=${ROOT_DIR}/docker-compose.template.yaml
-YAML_FILE=${ROOT_DIR}/docker-compose.yaml
-
-sh ${UTILPATH}/findreplace.sh ${TEMPLATE_YAML_FILE} ${YAML_FILE} || exit 200
-rm ${TEMPLATE_YAML_FILE}
-
-exit 0
diff --git a/aai-traversal/src/main/swm/package/nix/deinstall/preproc/pre_proc b/aai-traversal/src/main/swm/package/nix/deinstall/preproc/pre_proc
deleted file mode 100644
index 5f88c41..0000000
--- a/aai-traversal/src/main/swm/package/nix/deinstall/preproc/pre_proc
+++ /dev/null
@@ -1,4 +0,0 @@
-#!/bin/sh
-
-cd ../../common
-exec sh -x ./deinstall_preproc.sh
diff --git a/aai-traversal/src/main/swm/package/nix/dist_files/opt/app/aai-traversal/docker-compose.template.yaml b/aai-traversal/src/main/swm/package/nix/dist_files/opt/app/aai-traversal/docker-compose.template.yaml
deleted file mode 100644
index 7d31b8b..0000000
--- a/aai-traversal/src/main/swm/package/nix/dist_files/opt/app/aai-traversal/docker-compose.template.yaml
+++ /dev/null
@@ -1,51 +0,0 @@
-#
-# ============LICENSE_START=======================================================
-# org.onap.aai
-# ================================================================================
-# Copyright © 2017 AT&T Intellectual Property. All rights reserved.
-# ================================================================================
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-# ============LICENSE_END=========================================================
-#
-# ECOMP is a trademark and service mark of AT&T Intellectual Property.
-#
-
-# SCLD_ENV is for the environment context for dme2
-# AAI_CHEF_ENV is used for both dme2 properites and
-# also used by chef to generate appropriate properties
-
-version: '2'
-services:
- aai-traversal:
- image: __REGISTRY__/__NAMESPACE__/aai-traversal:__IMAGE_VERSION__
- network_mode: host
- environment:
- - LOCAL_USER_ID=__LOCAL_USER_ID__
- - LOCAL_GROUP_ID=__LOCAL_GROUP_ID__
- volumes:
- - /opt/aai/logroot/AAI-GQ:/opt/aai/logroot/AAI-GQ
- - /opt/app/aai-traversal/appconfig/aai-client-cert.p12:/opt/app/aai-traversal/resources/etc/auth/aai-client-cert.p12
- - /opt/app/aai-traversal/appconfig/tomcat_keystore:/opt/app/aai-traversal/resources/etc/auth/tomcat_keystore
- - /opt/app/aai-traversal/appconfig/aai_policy.json:/opt/app/aai-traversal/resources/etc/auth/aai_policy.json
- - /opt/app/aai-traversal/appconfig/aaiconfig.properties:/opt/app/aai-traversal/resources/etc/appprops/aaiconfig.properties
- - /opt/app/aai-traversal/appconfig/application.properties:/opt/app/aai-traversal/resources/application.properties
- - /opt/app/aai-traversal/appconfig/dme2.properties:/opt/app/aai-traversal/resources/dme2.properties
- - /opt/app/aai-traversal/appconfig/localhost-access-logback.xml:/opt/app/aai-traversal/resources/localhost-access-logback.xml
- - /opt/app/aai-traversal/appconfig/logback.xml:/opt/app/aai-traversal/resources/logback.xml
- - /opt/app/aai-traversal/appconfig/janusgraph-cached.properties:/opt/app/aai-traversal/resources/etc/appprops/janusgraph-cached.properties
- - /opt/app/aai-traversal/appconfig/janusgraph-realtime.properties:/opt/app/aai-traversal/resources/etc/appprops/janusgraph-realtime.properties
- logging:
- driver: "json-file"
- options:
- max-size: "30m"
- max-file: "5"
diff --git a/aai-traversal/src/main/swm/package/nix/dist_files/opt/app/aai-traversal/execTool.sh b/aai-traversal/src/main/swm/package/nix/dist_files/opt/app/aai-traversal/execTool.sh
deleted file mode 100644
index ab634c0..0000000
--- a/aai-traversal/src/main/swm/package/nix/dist_files/opt/app/aai-traversal/execTool.sh
+++ /dev/null
@@ -1,58 +0,0 @@
-#!/bin/bash
-
-export WORKING_DIR="$( cd "$(dirname "$0")" ; pwd -P )/"
-
-DOCKER_COMPOSE_CMD="docker-compose -f ${WORKING_DIR}/docker-compose.yaml";
-
-ARG=$1;
-
-if [ -z "$ARG" ]; then
- echo "Error: You need to at least provide one argument which is the script to execute";
- exit 1;
-fi;
-
-if [ "${ARG}" = "--debug" ]; then
-
- SCRIPT_NAME=$2;
-
- if [ -z "$SCRIPT_NAME" ]; then
- echo "Error: You need to provide the tool name after specifying the --debug flag";
- exit 1;
- fi;
-
- shift 2;
-
-else
- SCRIPT_NAME=$1;
- shift 1;
-fi;
-
-CONTAINER_NAME=$(${DOCKER_COMPOSE_CMD} ps -q aai-traversal);
-
-if [ $? -ne 0 ]; then
- echo "Error: seems like the container is not running, please run the commands to start aai-traversal";
- exit 1;
-fi;
-
-if [ ${SCRIPT_NAME} = "putTool.sh" ]; then
-
- PAYLOAD_FILE=$2;
-
- if [ ! -z "${PAYLOAD_FILE}" ] && [ -f "${PAYLOAD_FILE}" ]; then
- docker cp ${PAYLOAD_FILE} ${CONTAINER_NAME}:/tmp/$(basename ${PAYLOAD_FILE})
- fi;
-fi;
-
-${DOCKER_COMPOSE_CMD} exec --user aaiadmin aai-traversal ls /opt/app/aai-traversal/scripts/${SCRIPT_NAME} && {
-
- if [ "${ARG}" = "--debug" ]; then
- ${DOCKER_COMPOSE_CMD} exec --user aaiadmin aai-traversal bash -x /opt/app/aai-traversal/scripts/${SCRIPT_NAME} "$@"
- else
- ${DOCKER_COMPOSE_CMD} exec --user aaiadmin aai-traversal /opt/app/aai-traversal/scripts/${SCRIPT_NAME} "$@"
- fi;
-
- exit 0;
-} || {
- echo "Unable to find the tool in the /opt/app/aai-traversal/scripts";
- exit 1;
-}
diff --git a/aai-traversal/src/main/swm/package/nix/dist_files/opt/app/aai-traversal/kill_resources.sh b/aai-traversal/src/main/swm/package/nix/dist_files/opt/app/aai-traversal/kill_resources.sh
deleted file mode 100644
index 00855da..0000000
--- a/aai-traversal/src/main/swm/package/nix/dist_files/opt/app/aai-traversal/kill_resources.sh
+++ /dev/null
@@ -1,7 +0,0 @@
-#!/bin/bash
-
-. /etc/profile.d/aai.sh
-PROJECT_HOME=/opt/app/aai-traversal
-
-docker-compose -f ${PROJECT_HOME}/docker-compose.yaml stop && \
- docker-compose -f ${PROJECT_HOME}/docker-compose.yaml rm -f
diff --git a/aai-traversal/src/main/swm/package/nix/dist_files/opt/app/aai-traversal/start_resources.sh b/aai-traversal/src/main/swm/package/nix/dist_files/opt/app/aai-traversal/start_resources.sh
deleted file mode 100644
index 61819d4..0000000
--- a/aai-traversal/src/main/swm/package/nix/dist_files/opt/app/aai-traversal/start_resources.sh
+++ /dev/null
@@ -1,6 +0,0 @@
-#!/bin/bash
-
-. /etc/profile.d/aai.sh
-PROJECT_HOME=/opt/app/aai-traversal
-
-docker-compose -f ${PROJECT_HOME}/docker-compose.yaml up -d || exit 200
diff --git a/aai-traversal/src/main/swm/package/nix/dist_files/opt/app/aai-traversal/stop_resources.sh b/aai-traversal/src/main/swm/package/nix/dist_files/opt/app/aai-traversal/stop_resources.sh
deleted file mode 100644
index 009e597..0000000
--- a/aai-traversal/src/main/swm/package/nix/dist_files/opt/app/aai-traversal/stop_resources.sh
+++ /dev/null
@@ -1,6 +0,0 @@
-#!/bin/bash
-
-. /etc/profile.d/aai.sh
-PROJECT_HOME=/opt/app/aai-traversal
-
-docker-compose -f ${PROJECT_HOME}/docker-compose.yaml stop || exit 200
diff --git a/aai-traversal/src/main/swm/package/nix/initinst/postproc/post_proc b/aai-traversal/src/main/swm/package/nix/initinst/postproc/post_proc
deleted file mode 100644
index d017750..0000000
--- a/aai-traversal/src/main/swm/package/nix/initinst/postproc/post_proc
+++ /dev/null
@@ -1,4 +0,0 @@
-#!/bin/sh
-
-cd ../../common
-exec sh -x ./install_postproc.sh
diff --git a/aai-traversal/src/main/swm/package/nix/install/postproc/post_proc b/aai-traversal/src/main/swm/package/nix/install/postproc/post_proc
deleted file mode 100644
index d017750..0000000
--- a/aai-traversal/src/main/swm/package/nix/install/postproc/post_proc
+++ /dev/null
@@ -1,4 +0,0 @@
-#!/bin/sh
-
-cd ../../common
-exec sh -x ./install_postproc.sh
diff --git a/aai-traversal/src/main/swm/package/nix/install/preproc/pre_proc b/aai-traversal/src/main/swm/package/nix/install/preproc/pre_proc
deleted file mode 100644
index 3f1b26f..0000000
--- a/aai-traversal/src/main/swm/package/nix/install/preproc/pre_proc
+++ /dev/null
@@ -1,4 +0,0 @@
-#!/bin/sh
-
-cd ../../common
-exec sh -x ./install_preproc.sh
diff --git a/aai-traversal/src/test/java/org/onap/aai/AAIGremlinQueryTest.java b/aai-traversal/src/test/java/org/onap/aai/AAIGremlinQueryTest.java
index a2be3d0..0a9ec97 100644
--- a/aai-traversal/src/test/java/org/onap/aai/AAIGremlinQueryTest.java
+++ b/aai-traversal/src/test/java/org/onap/aai/AAIGremlinQueryTest.java
@@ -20,12 +20,13 @@
package org.onap.aai;
import com.jayway.jsonpath.JsonPath;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.runner.RunWith;
+import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource;
+import org.janusgraph.core.JanusGraphTransaction;
+import org.junit.*;
import org.onap.aai.config.PropertyPasswordConfiguration;
+import org.onap.aai.dbmap.AAIGraph;
import org.onap.aai.exceptions.AAIException;
+import org.onap.aai.util.AAIConfig;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.context.embedded.LocalServerPort;
import org.springframework.boot.test.context.SpringBootTest;
@@ -33,16 +34,19 @@ import org.springframework.context.annotation.Import;
import org.springframework.http.*;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.TestPropertySource;
-import org.springframework.test.context.junit4.SpringRunner;
+import org.springframework.test.context.junit4.rules.SpringClassRule;
+import org.springframework.test.context.junit4.rules.SpringMethodRule;
import org.springframework.web.client.RestTemplate;
-import javax.ws.rs.core.Response;
-import java.io.UnsupportedEncodingException;
-import java.util.*;
+import java.util.Base64;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Map;
+import static org.hamcrest.CoreMatchers.containsString;
import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.MatcherAssert.assertThat;
-import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.fail;
/**
* A sample junit test using spring boot that provides the ability to spin
@@ -55,18 +59,17 @@ import static org.junit.Assert.assertNotNull;
* This can be used to potentially replace a lot of the fitnesse tests since
* they will be testing against the same thing except fitnesse uses hbase
*/
-@RunWith(SpringRunner.class)
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT, classes = TraversalApp.class)
@TestPropertySource(locations = "classpath:application-test.properties")
@ContextConfiguration(initializers = PropertyPasswordConfiguration.class)
@Import(TraversalTestConfiguration.class)
public class AAIGremlinQueryTest {
- private HttpTestUtil httpTestUtil;
+ @ClassRule
+ public static final SpringClassRule springClassRule = new SpringClassRule();
- private String pserverUri;
-
- private String hostname;
+ @Rule
+ public final SpringMethodRule springMethodRule = new SpringMethodRule();
@Autowired
RestTemplate restTemplate;
@@ -80,20 +83,50 @@ public class AAIGremlinQueryTest {
private String baseUrl;
- @Before
- public void setup() throws Exception {
+ @BeforeClass
+ public static void setupConfig() throws AAIException {
+ System.setProperty("AJSC_HOME", "./");
+ System.setProperty("BUNDLECONFIG_DIR", "src/main/resources/");
+ AAIConfig.init();
+ }
+
+ public void createGraph(){
+
+ JanusGraphTransaction transaction = AAIGraph.getInstance().getGraph().newTransaction();
+
+ boolean success = true;
- httpTestUtil = new HttpTestUtil();
+ try {
- hostname = UUID.randomUUID().toString();
+ GraphTraversalSource g = transaction.traversal();
- pserverUri ="/aai/v11/cloud-infrastructure/pservers/pserver/" + hostname;
+ g.addV()
+ .property("aai-node-type", "pserver")
+ .property("hostname", "test-pserver")
+ .property("in-maint", false)
+ .property("source-of-truth", "JUNIT")
+ .property("aai-uri", "/cloud-infrastructure/pservers/pserver/test-pserver")
+ .next();
- Map<String, String> pserverMap = new HashMap<>();
- pserverMap.put("hostname", hostname);
- String payload = PayloadUtil.getTemplatePayload("pserver.json", pserverMap);
- httpTestUtil.doPut(pserverUri, payload);
+ } catch(Exception ex){
+ success = false;
+ } finally {
+ if(success){
+ transaction.commit();
+ } else {
+ transaction.rollback();
+ fail("Unable to setup the graph");
+ }
+ }
+ }
+
+ @Before
+ public void setup() throws Exception {
+ AAIConfig.init();
+ AAIGraph.getInstance();
+
+ createGraph();
headers = new HttpHeaders();
headers.setAccept(Collections.singletonList(MediaType.APPLICATION_JSON));
@@ -109,9 +142,9 @@ public class AAIGremlinQueryTest {
}
@Test
- public void testPserverCount() throws Exception {
+ public void testPserverCountUsingGremlin() throws Exception {
Map<String, String> gremlinQueryMap = new HashMap<>();
- gremlinQueryMap.put("gremlin-query", "g.V().has('hostname', '" + hostname + "').count()");
+ gremlinQueryMap.put("gremlin-query", "g.V().has('hostname', 'test-pserver').count()");
String payload = PayloadUtil.getTemplatePayload("gremlin-query.json", gremlinQueryMap);
@@ -127,19 +160,49 @@ public class AAIGremlinQueryTest {
assertThat(result, is("1"));
}
+ @Test
+ public void testPserverCountUsingDsl() throws Exception {
+ Map<String, String> dslQuerymap = new HashMap<>();
+ dslQuerymap.put("dsl-query", "pserver*('hostname', 'test-pserver')");
+
+ String payload = PayloadUtil.getTemplatePayload("dsl-query.json", dslQuerymap);
+
+ ResponseEntity responseEntity = null;
+
+ String endpoint = "/aai/v11/dsl?format=console";
+
+ httpEntity = new HttpEntity(payload, headers);
+ responseEntity = restTemplate.exchange(baseUrl + endpoint, HttpMethod.PUT, httpEntity, String.class);
+ assertThat(responseEntity.getStatusCode(), is(HttpStatus.OK));
+
+ String result = JsonPath.read(responseEntity.getBody().toString(), "$.results[0].result");
+ assertThat(result, containsString("v["));
+ }
+
@After
- public void tearDown() throws UnsupportedEncodingException, AAIException {
+ public void tearDown() {
+
+ JanusGraphTransaction transaction = AAIGraph.getInstance().getGraph().newTransaction();
+ boolean success = true;
+
+ try {
- Response response = httpTestUtil.doGet(pserverUri);
+ GraphTraversalSource g = transaction.traversal();
- assertNotNull("Expected the response to be returned", response);
- assertThat(response.getStatus(), is(200));
+ g.V().has("source-of-truth", "JUNIT")
+ .toList()
+ .forEach(v -> v.remove());
- String body = response.getEntity().toString();
- String resourceVersion = JsonPath.read(body, "$.resource-version");
+ } catch(Exception ex){
+ success = false;
+ } finally {
+ if(success){
+ transaction.commit();
+ } else {
+ transaction.rollback();
+ fail("Unable to teardown the graph");
+ }
+ }
- response = httpTestUtil.doDelete(pserverUri, resourceVersion);
- assertNotNull("Expected the response to be returned", response);
- assertThat(response.getStatus(), is(204));
}
}
diff --git a/aai-traversal/src/test/java/org/onap/aai/AAISetup.java b/aai-traversal/src/test/java/org/onap/aai/AAISetup.java
new file mode 100644
index 0000000..42964eb
--- /dev/null
+++ b/aai-traversal/src/test/java/org/onap/aai/AAISetup.java
@@ -0,0 +1,141 @@
+/**
+ * ============LICENSE_START=======================================================
+ * org.onap.aai
+ * ================================================================================
+ * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY 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;
+
+import static org.junit.Assert.assertNotNull;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.Map;
+
+import org.apache.commons.io.IOUtils;
+import org.junit.BeforeClass;
+import org.onap.aai.config.*;
+import org.onap.aai.dbgraphmap.SearchGraph;
+import org.onap.aai.edges.EdgeIngestor;
+import org.onap.aai.introspection.LoaderFactory;
+import org.onap.aai.nodes.NodeIngestor;
+import org.onap.aai.rest.db.HttpEntry;
+import org.onap.aai.rest.dsl.DslQueryProcessor;
+import org.onap.aai.rest.search.GremlinServerSingleton;
+import org.onap.aai.serialization.db.EdgeSerializer;
+import org.onap.aai.setup.AAIConfigTranslator;
+import org.onap.aai.setup.SchemaVersion;
+import org.onap.aai.setup.SchemaVersions;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.test.context.ContextConfiguration;
+import org.onap.aai.introspection.MoxyLoader;
+import org.onap.aai.setup.SchemaLocationsBean;
+import org.junit.ClassRule;
+import org.junit.Rule;
+import org.springframework.test.context.TestPropertySource;
+import org.springframework.test.context.junit4.rules.SpringClassRule;
+import org.springframework.test.context.junit4.rules.SpringMethodRule;
+
+@ContextConfiguration(classes = {
+ SchemaLocationsBean.class,
+ SchemaVersions.class,
+ AAIConfigTranslator.class,
+ EdgeIngestor.class,
+ EdgeSerializer.class,
+ NodeIngestor.class,
+ SpringContextAware.class,
+ IntrospectionConfig.class ,
+ RestBeanConfig.class,
+ SearchConfiguration.class,
+ DslConfiguration.class,
+ GremlinServerSingleton.class
+})
+@TestPropertySource(properties = {
+ "schema.uri.base.path = /aai",
+ "schema.ingest.file = src/test/resources/application-test.properties"
+})
+public abstract class AAISetup {
+ @Autowired
+ protected NodeIngestor nodeIngestor;
+
+ @Autowired
+ protected LoaderFactory loaderFactory;
+
+ @Autowired
+ protected Map<SchemaVersion, MoxyLoader> moxyLoaderInstance;
+
+ @Autowired
+ protected HttpEntry traversalHttpEntry;
+
+ @Autowired
+ protected HttpEntry traversalUriHttpEntry;
+
+ @Autowired
+ protected SearchGraph searchGraph;
+
+ @Autowired
+ protected EdgeSerializer edgeSer;
+
+ @Autowired
+ protected EdgeIngestor edgeIngestor;
+
+ @Autowired
+ protected DslQueryProcessor dslQueryProcessor;
+
+ @Autowired
+ protected SchemaVersions schemaVersions;
+
+ @Autowired
+ protected GremlinServerSingleton gremlinServerSingleton;
+
+ @Value("${schema.uri.base.path}")
+ protected String basePath;
+
+ @ClassRule
+ public static final SpringClassRule springClassRule = new SpringClassRule();
+
+ @Rule
+ public final SpringMethodRule springMethodRule = new SpringMethodRule();
+
+ @BeforeClass
+ public static void setupBundleconfig() throws Exception {
+ System.setProperty("AJSC_HOME", "./");
+ System.setProperty("BUNDLECONFIG_DIR", "src/main/resources/");
+
+ }
+
+ public String getPayload(String filename) throws IOException {
+
+ InputStream inputStream = getClass()
+ .getClassLoader()
+ .getResourceAsStream(filename);
+
+ String message = String.format("Unable to find the %s in src/test/resources", filename);
+ assertNotNull(message, inputStream);
+
+ String resource = IOUtils.toString(inputStream);
+ return resource;
+ }
+}
+
+
+
+
+
+
+
+
diff --git a/aai-traversal/src/test/java/org/onap/aai/HttpTestUtil.java b/aai-traversal/src/test/java/org/onap/aai/HttpTestUtil.java
index 7284593..79e6cac 100644
--- a/aai-traversal/src/test/java/org/onap/aai/HttpTestUtil.java
+++ b/aai-traversal/src/test/java/org/onap/aai/HttpTestUtil.java
@@ -23,20 +23,20 @@ import com.att.eelf.configuration.EELFLogger;
import com.att.eelf.configuration.EELFManager;
import org.javatuples.Pair;
import org.mockito.Mockito;
+import org.onap.aai.config.SpringContextAware;
import org.onap.aai.dbmap.DBConnectionType;
import org.onap.aai.exceptions.AAIException;
import org.onap.aai.introspection.Introspector;
import org.onap.aai.introspection.Loader;
-import org.onap.aai.introspection.ModelType;
-import org.onap.aai.introspection.Version;
import org.onap.aai.parsers.query.QueryParser;
import org.onap.aai.parsers.uri.URIToObject;
import org.onap.aai.rest.db.DBRequest;
import org.onap.aai.rest.db.HttpEntry;
import org.onap.aai.restcore.HttpMethod;
import org.onap.aai.restcore.RESTAPI;
-import org.onap.aai.serialization.engines.QueryStyle;
import org.onap.aai.serialization.engines.TransactionalGraphEngine;
+import org.onap.aai.setup.SchemaVersion;
+import org.onap.aai.setup.SchemaVersions;
import javax.ws.rs.core.*;
import java.io.UnsupportedEncodingException;
@@ -64,8 +64,11 @@ public class HttpTestUtil extends RESTAPI {
protected List<String> aaiRequestContextList;
protected List<MediaType> outputMediaTypes;
+ private SchemaVersions schemaVersions;
+
public void init(){
+ schemaVersions = SpringContextAware.getBean(SchemaVersions.class);
httpHeaders = Mockito.mock(HttpHeaders.class);
uriInfo = Mockito.mock(UriInfo.class);
@@ -110,24 +113,26 @@ public class HttpTestUtil extends RESTAPI {
String [] arr = uri.split("/");
- Version version = null;
+ SchemaVersion version = null;
if(arr != null && arr.length > 1){
if(arr[0].matches("^v\\d+")){
- version = Version.valueOf(arr[0]);
+ version = new SchemaVersion(arr[0]);
uri = uri.replaceAll("^v\\d+", "");
}
}
if(version == null){
- version = Version.getLatest();
+ version = schemaVersions.getDefaultVersion();
}
Mockito.when(uriInfo.getPath()).thenReturn(uri);
DBConnectionType type = DBConnectionType.REALTIME;
- HttpEntry httpEntry = new HttpEntry(version, ModelType.MOXY, QueryStyle.TRAVERSAL, type);
- Loader loader = httpEntry.getLoader();
- dbEngine = httpEntry.getDbEngine();
+ HttpEntry resourceHttpEntry = SpringContextAware.getBean("traversalHttpEntry", HttpEntry.class);
+ resourceHttpEntry.setHttpEntryProperties(version, type);
+ // HttpEntry httpEntry = new HttpEntry(version, ModelType.MOXY, QueryStyle.TRAVERSAL, type);
+ Loader loader = resourceHttpEntry.getLoader();
+ dbEngine = resourceHttpEntry.getDbEngine();
URI uriObject = UriBuilder.fromPath(uri).build();
URIToObject uriToObject = new URIToObject(loader, uriObject);
@@ -157,7 +162,7 @@ public class HttpTestUtil extends RESTAPI {
List<DBRequest> dbRequestList = new ArrayList<>();
dbRequestList.add(dbRequest);
- Pair<Boolean, List<Pair<URI, Response>>> responsesTuple = httpEntry.process(dbRequestList, "JUNIT");
+ Pair<Boolean, List<Pair<URI, Response>>> responsesTuple = resourceHttpEntry.process(dbRequestList, "JUNIT");
response = responsesTuple.getValue1().get(0).getValue1();
} catch (AAIException e) {
@@ -202,23 +207,27 @@ public class HttpTestUtil extends RESTAPI {
String [] arr = uri.split("/");
- Version version = null;
+ SchemaVersion version = null;
if(arr != null && arr.length > 1){
if(arr[0].matches("^v\\d+")){
- version = Version.valueOf(arr[0]);
+ version = new SchemaVersion(arr[0]);
uri = uri.replaceAll("^v\\d+", "");
}
}
if(version == null){
- version = Version.getLatest();
+ version = schemaVersions.getDefaultVersion();
}
DBConnectionType type = DBConnectionType.REALTIME;
- HttpEntry httpEntry = new HttpEntry(version, ModelType.MOXY, QueryStyle.TRAVERSAL, type);
- Loader loader = httpEntry.getLoader();
- dbEngine = httpEntry.getDbEngine();
+
+ //HttpEntry httpEntry = new HttpEntry(version, ModelType.MOXY, QueryStyle.TRAVERSAL, type);
+ HttpEntry resourceHttpEntry = SpringContextAware.getBean("traversalHttpEntry", HttpEntry.class);
+ resourceHttpEntry.setHttpEntryProperties(version, type);
+
+ Loader loader = resourceHttpEntry.getLoader();
+ dbEngine = resourceHttpEntry.getDbEngine();
URI uriObject = UriBuilder.fromPath(uri).build();
URIToObject uriToObject = new URIToObject(loader, uriObject);
@@ -240,7 +249,7 @@ public class HttpTestUtil extends RESTAPI {
List<DBRequest> dbRequestList = new ArrayList<>();
dbRequestList.add(dbRequest);
- Pair<Boolean, List<Pair<URI, Response>>> responsesTuple = httpEntry.process(dbRequestList, "JUNIT");
+ Pair<Boolean, List<Pair<URI, Response>>> responsesTuple = resourceHttpEntry.process(dbRequestList, "JUNIT");
response = responsesTuple.getValue1().get(0).getValue1();
} catch (AAIException e) {
@@ -283,11 +292,11 @@ public class HttpTestUtil extends RESTAPI {
String [] arr = uri.split("/");
- Version version = null;
+ SchemaVersion version = null;
if(arr != null && arr.length > 1){
if(arr[0].matches("^v\\d+")){
- version = Version.valueOf(arr[0]);
+ version = new SchemaVersion(arr[0]);
if(!uri.contains("relationship-list/relationship")){
uri = uri.replaceAll("^v\\d+", "");
}
@@ -295,14 +304,16 @@ public class HttpTestUtil extends RESTAPI {
}
if(version == null){
- version = Version.getLatest();
+ version = schemaVersions.getDefaultVersion();
}
Mockito.when(uriInfo.getPath()).thenReturn(uri);
DBConnectionType type = DBConnectionType.REALTIME;
- HttpEntry httpEntry = new HttpEntry(version, ModelType.MOXY, QueryStyle.TRAVERSAL, type);
- Loader loader = httpEntry.getLoader();
- dbEngine = httpEntry.getDbEngine();
+ HttpEntry resourceHttpEntry = SpringContextAware.getBean("traversalHttpEntry", HttpEntry.class);
+ resourceHttpEntry.setHttpEntryProperties(version, type);
+ // HttpEntry httpEntry = new HttpEntry(version, ModelType.MOXY, QueryStyle.TRAVERSAL, type);
+ Loader loader = resourceHttpEntry.getLoader();
+ dbEngine = resourceHttpEntry.getDbEngine();
URI uriObject = UriBuilder.fromPath(uri).build();
URIToObject uriToObject = new URIToObject(loader, uriObject);
@@ -330,7 +341,7 @@ public class HttpTestUtil extends RESTAPI {
List<DBRequest> dbRequestList = new ArrayList<>();
dbRequestList.add(dbRequest);
- Pair<Boolean, List<Pair<URI, Response>>> responsesTuple = httpEntry.process(dbRequestList, "JUNIT");
+ Pair<Boolean, List<Pair<URI, Response>>> responsesTuple = resourceHttpEntry.process(dbRequestList, "JUNIT");
response = responsesTuple.getValue1().get(0).getValue1();
} catch (AAIException e) {
diff --git a/aai-traversal/src/test/java/org/onap/aai/QueryParameterTest.java b/aai-traversal/src/test/java/org/onap/aai/QueryParameterTest.java
new file mode 100644
index 0000000..3956b70
--- /dev/null
+++ b/aai-traversal/src/test/java/org/onap/aai/QueryParameterTest.java
@@ -0,0 +1,188 @@
+/**
+ * ============LICENSE_START=======================================================
+ * org.onap.aai
+ * ================================================================================
+ * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY 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;
+
+import com.att.eelf.configuration.EELFLogger;
+import com.att.eelf.configuration.EELFManager;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.onap.aai.config.PropertyPasswordConfiguration;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.context.embedded.LocalServerPort;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.context.annotation.Import;
+import org.springframework.http.*;
+import org.springframework.test.context.ContextConfiguration;
+import org.springframework.test.context.TestPropertySource;
+import org.springframework.test.context.junit4.SpringRunner;
+import org.springframework.web.client.RestTemplate;
+
+import javax.ws.rs.core.Response;
+import java.util.*;
+
+import static org.hamcrest.Matchers.containsString;
+import static org.hamcrest.core.Is.is;
+import static org.junit.Assert.assertThat;
+
+@RunWith(SpringRunner.class)
+@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT, classes = TraversalApp.class)
+@TestPropertySource(locations = "classpath:application-test.properties")
+@ContextConfiguration(initializers = PropertyPasswordConfiguration.class)
+@Import(TraversalTestConfiguration.class)
+public class QueryParameterTest {
+
+ private static final EELFLogger LOGGER = EELFManager.getInstance().getLogger(QueryParameterTest.class);
+
+ private HttpTestUtil httpTestUtil;
+
+ private String configurationId;
+
+ private String configurationUri;
+
+ private String configurationId2;
+
+ private String configurationUri2;
+
+
+ @Autowired
+ RestTemplate restTemplate;
+
+ @LocalServerPort
+ int randomPort;
+
+ private HttpEntity httpEntity;
+
+ private HttpHeaders headers;
+
+ private String baseUrl;
+ private String customerId;
+ private String customerUri;
+ private String customerId2;
+ private String customerUri2;
+
+ private String vnfId;
+ private String vnfUri;
+
+ private String vnfId2;
+ private String vnfUri2;
+
+ private String serviceInstanceId;
+ private String serviceInstanceName;
+ private String serviceInstanceId2;
+ private String serviceInstanceName2;
+
+ @Before
+ public void setup() throws Exception {
+
+ httpTestUtil = new HttpTestUtil();
+
+ configurationId = "test-" + UUID.randomUUID().toString();
+ configurationUri ="/aai/v13/network/configurations/configuration/" + configurationId;
+ Map<String, String> configurationMap = new HashMap<>();
+ configurationMap.put("configuration-id", configurationId);
+ String payload = PayloadUtil.getTemplatePayload("configuration.json", configurationMap);
+ httpTestUtil.doPut(configurationUri, payload);
+
+ configurationId2 = "test-" + UUID.randomUUID().toString();
+ configurationUri2 ="/aai/v13/network/configurations/configuration/" + configurationId2;
+ configurationMap.put("configuration-id", configurationId2);
+ payload = PayloadUtil.getTemplatePayload("configuration.json", configurationMap);
+ httpTestUtil.doPut(configurationUri2, payload);
+
+ customerId = "test-" + UUID.randomUUID().toString();
+ serviceInstanceId = "test-service-instance1";
+ serviceInstanceName = "test service instance1";
+
+ customerUri ="/aai/v13/business/network/customers/customer/" + customerId;
+ Map<String, String> customerMap = new HashMap<>();
+ customerMap.put("customer-id", customerId);
+ customerMap.put("service-instance-id", serviceInstanceId);
+ customerMap.put("configuration-id1", configurationId);
+ customerMap.put("configuration-id2", configurationId2);
+ customerMap.put("service-instance-name", serviceInstanceName);
+ payload = PayloadUtil.getTemplatePayload("customer-with-configurations.json", customerMap);
+ httpTestUtil.doPut(customerUri, payload);
+
+ customerId2 = "test-" + UUID.randomUUID().toString();
+ serviceInstanceId2 = "test-service-instance2";
+ serviceInstanceName2 = "test service instance1";
+ customerUri2 ="/aai/v13/business/customers/customer/" + customerId2;
+
+ customerMap = new HashMap<>();
+ customerMap.put("customer-id", customerId2);
+ customerMap.put("service-instance-id", serviceInstanceId2);
+ customerMap.put("service-instance-name", serviceInstanceName2);
+ payload = PayloadUtil.getTemplatePayload("customer-with-serviceinstance.json", customerMap);
+ httpTestUtil.doPut(customerUri2, payload);
+
+ vnfId = "test-" + UUID.randomUUID().toString();
+ vnfUri ="/aai/v13/network/generic-vnfs/generic-vnf/" + vnfId;
+ Map<String, String> vnfMap = new HashMap<>();
+ vnfMap.put("vnf-id", vnfId);
+ vnfMap.put("configuration-id", configurationId);
+ vnfMap.put("interface-name", "test-interface-name1");
+ vnfMap.put("vlan-interface", "test-vlan-name1");
+ payload = PayloadUtil.getTemplatePayload("generic-vnf-to-configuration.json", vnfMap);
+ httpTestUtil.doPut(vnfUri, payload);
+
+ vnfId2 = "test-" + UUID.randomUUID().toString();
+ vnfUri2 ="/aai/v13/network/generic-vnfs/generic-vnf/" + vnfId2;
+ vnfMap = new HashMap<>();
+ vnfMap.put("vnf-id", vnfId2);
+ vnfMap.put("configuration-id", configurationId2);
+ vnfMap.put("interface-name", "test-interface-name2");
+ vnfMap.put("vlan-interface", "test-vlan-name2");
+ payload = PayloadUtil.getTemplatePayload("generic-vnf-to-configuration.json", vnfMap);
+ httpTestUtil.doPut(vnfUri2, payload);
+
+ headers = new HttpHeaders();
+
+ headers.setAccept(Collections.singletonList(MediaType.APPLICATION_JSON));
+ headers.setContentType(MediaType.APPLICATION_JSON);
+ headers.add("Real-Time", "true");
+ headers.add("X-FromAppId", "JUNIT");
+ headers.add("X-TransactionId", "JUNIT");
+ String authorization = Base64.getEncoder().encodeToString("AAI:AAI".getBytes("UTF-8"));
+ headers.add("Authorization", "Basic " + authorization);
+
+ baseUrl = "https://localhost:" + randomPort;
+ }
+
+ @Test
+ public void testQueryApi() throws Exception {
+
+ String endpoint = "/aai/v13/query?format=pathed";
+
+ Map<String, String> customQueryMap = new HashMap<>();
+ String service = serviceInstanceName.replaceAll(" ", "+");
+ System.out.println("Service " + service);
+ customQueryMap.put("start", "nodes/service-instances?service-instance-name=" + service);
+ customQueryMap.put("query", "containment-path");
+
+ String payload = PayloadUtil.getTemplatePayload("custom-query.json", customQueryMap);
+ httpEntity = new HttpEntity(payload, headers);
+ ResponseEntity responseEntity = restTemplate.exchange(baseUrl + endpoint, HttpMethod.PUT, httpEntity, String.class);
+ LOGGER.info("Response of custom query : {}", responseEntity.getBody().toString());
+ assertThat(responseEntity.getStatusCode(), is(HttpStatus.OK));
+ assertThat(responseEntity.getBody().toString(), containsString(customerUri2));
+ }
+
+}
diff --git a/aai-traversal/src/test/java/org/onap/aai/SubgraphPruneTest.java b/aai-traversal/src/test/java/org/onap/aai/SubgraphPruneTest.java
new file mode 100644
index 0000000..efb9e89
--- /dev/null
+++ b/aai-traversal/src/test/java/org/onap/aai/SubgraphPruneTest.java
@@ -0,0 +1,129 @@
+/**
+ * ============LICENSE_START=======================================================
+ * org.onap.aai
+ * ================================================================================
+ * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY 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;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.onap.aai.config.PropertyPasswordConfiguration;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.context.embedded.LocalServerPort;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.context.annotation.Import;
+import org.springframework.http.*;
+import org.springframework.test.context.ContextConfiguration;
+import org.springframework.test.context.TestPropertySource;
+import org.springframework.test.context.junit4.SpringRunner;
+import org.springframework.web.client.RestTemplate;
+
+import javax.ws.rs.core.Response;
+import java.util.*;
+
+import static org.hamcrest.core.Is.is;
+import static org.junit.Assert.assertThat;
+
+@RunWith(SpringRunner.class)
+@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT, classes = TraversalApp.class)
+@TestPropertySource(locations = "classpath:application-test.properties")
+@ContextConfiguration(initializers = PropertyPasswordConfiguration.class)
+@Import(TraversalTestConfiguration.class)
+public class SubgraphPruneTest {
+
+
+ private HttpTestUtil httpTestUtil;
+
+ private String pserverUri;
+
+ private String hostname;
+
+ @Autowired
+ RestTemplate restTemplate;
+
+ @LocalServerPort
+ int randomPort;
+
+ private HttpEntity httpEntity;
+
+ private HttpHeaders headers;
+
+ private String baseUrl;
+
+ private String vserverId;
+
+ @Before
+ public void setup() throws Exception {
+
+ httpTestUtil = new HttpTestUtil();
+
+ hostname = "test-" + UUID.randomUUID().toString();
+ pserverUri ="/aai/v11/cloud-infrastructure/pservers/pserver/" + hostname;
+ Map<String, String> pserverMap = new HashMap<>();
+ pserverMap.put("hostname", hostname);
+ String payload = PayloadUtil.getTemplatePayload("pserver.json", pserverMap);
+ httpTestUtil.doPut(pserverUri, payload);
+
+ Map<String, String> cloudRegionMap = new HashMap<>();
+
+ vserverId = "some-vserver-id-id1111";
+
+ cloudRegionMap.put("cloud-owner", "some-owner-id1111");
+ cloudRegionMap.put("cloud-region-id", "some-region-id1111");
+ cloudRegionMap.put("tenant-id", "some-tenant-id1111");
+ cloudRegionMap.put("tenant-name", "some-tenant-name-id1111");
+ cloudRegionMap.put("vserver-id", vserverId);
+ cloudRegionMap.put("vserver-name", "some-vserver-name-id1111");
+ cloudRegionMap.put("pserver-uri", pserverUri);
+
+ String cloudRegionPayload = PayloadUtil.getTemplatePayload("cloud-region-with-vserver.json", cloudRegionMap);
+ String cloudRegionUri = "/aai/v11/cloud-infrastructure/cloud-regions/cloud-region/some-owner-id1111/some-region-id1111";
+
+ Response response = httpTestUtil.doPut(cloudRegionUri, cloudRegionPayload);
+
+ headers = new HttpHeaders();
+
+ headers.setAccept(Collections.singletonList(MediaType.APPLICATION_JSON));
+ headers.setContentType(MediaType.APPLICATION_JSON);
+ headers.add("Real-Time", "true");
+ headers.add("X-FromAppId", "JUNIT");
+ headers.add("X-TransactionId", "JUNIT");
+ String authorization = Base64.getEncoder().encodeToString("AAI:AAI".getBytes("UTF-8"));
+ headers.add("Authorization", "Basic " + authorization);
+
+ baseUrl = "https://localhost:" + randomPort;
+ }
+
+ @Test
+ public void testSubgraphPruneWorksAsExpectedWithValidResults() throws Exception {
+
+ Map<String, String> gremlinQueryMap = new HashMap<>();
+ // Having the cap('x') here causes the subgraph to fail
+ gremlinQueryMap.put("gremlin-query", "g.V().has('vserver-id', '" + vserverId + "').store('x').out().has('aai-node-type', 'pserver').store('x').cap('x').unfold()");
+
+ String payload = PayloadUtil.getTemplatePayload("gremlin-query.json", gremlinQueryMap);
+ String endpoint = "/aai/v13/query?format=console&subgraph=prune";
+
+ httpEntity = new HttpEntity(payload, headers);
+ ResponseEntity responseEntity = null;
+ responseEntity = restTemplate.exchange(baseUrl + endpoint, HttpMethod.PUT, httpEntity, String.class);
+ System.out.println(responseEntity.getBody().toString());
+ assertThat(responseEntity.getStatusCode(), is(HttpStatus.OK));
+ }
+
+}
diff --git a/aai-traversal/src/test/java/org/onap/aai/dbgraphgen/ModelBasedProcessingInvalidDataTest.java b/aai-traversal/src/test/java/org/onap/aai/dbgraphgen/ModelBasedProcessingInvalidDataTest.java
index 62bc7ce..e1515e3 100644
--- a/aai-traversal/src/test/java/org/onap/aai/dbgraphgen/ModelBasedProcessingInvalidDataTest.java
+++ b/aai-traversal/src/test/java/org/onap/aai/dbgraphgen/ModelBasedProcessingInvalidDataTest.java
@@ -19,963 +19,949 @@
*/
package org.onap.aai.dbgraphgen;
-import static org.junit.Assert.*;
-import static org.mockito.Matchers.any;
-import static org.mockito.Matchers.anyMap;
-import static org.mockito.Matchers.anyMapOf;
-import static org.mockito.Mockito.*;
-
-import com.bazaarvoice.jolt.modifier.DataType;
import com.google.common.collect.ArrayListMultimap;
-import com.google.common.collect.LinkedListMultimap;
import com.google.common.collect.Multimap;
-import org.janusgraph.graphdb.olap.computer.VertexMapJob;
-import org.janusgraph.graphdb.types.VertexLabelVertex;
+import org.apache.tinkerpop.gremlin.structure.Vertex;
import org.janusgraph.graphdb.types.system.BaseVertexLabel;
import org.janusgraph.graphdb.types.system.EmptyVertex;
-import org.janusgraph.graphdb.types.vertices.EdgeLabelVertex;
-import org.janusgraph.graphdb.types.vertices.PropertyKeyVertex;
-import org.apache.commons.lang.ObjectUtils;
-import org.apache.tinkerpop.gremlin.structure.Graph;
-import org.apache.tinkerpop.gremlin.structure.T;
-import org.apache.tinkerpop.gremlin.structure.Vertex;
-import org.apache.tinkerpop.gremlin.structure.VertexProperty;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.runner.RunWith;
-import org.mockito.*;
+import org.mockito.Mock;
+import org.mockito.MockitoAnnotations;
import org.mockito.runners.MockitoJUnitRunner;
+import org.onap.aai.AAISetup;
import org.onap.aai.db.DbMethHelper;
import org.onap.aai.db.props.AAIProperties;
import org.onap.aai.exceptions.AAIException;
import org.onap.aai.introspection.Loader;
-import org.onap.aai.introspection.LoaderFactory;
import org.onap.aai.introspection.ModelType;
-import org.onap.aai.introspection.exceptions.AAIUnknownObjectException;
import org.onap.aai.serialization.db.DBSerializer;
import org.onap.aai.serialization.engines.TransactionalGraphEngine;
-import javax.inject.Inject;
import java.util.*;
+
+import static org.junit.Assert.*;
+import static org.mockito.Matchers.any;
+import static org.mockito.Matchers.anyMapOf;
+import static org.mockito.Mockito.when;
+
@RunWith(MockitoJUnitRunner.class)
-public class ModelBasedProcessingInvalidDataTest {
-
- @Mock
- private static TransactionalGraphEngine dbEngine;
- private static Loader loader;
- @Mock
- private static DBSerializer serializer;
- ModelBasedProcessing processor;
-
- @Mock
- private ModelBasedProcessing mockProcessor;
-
-
- @Mock
- private DbMethHelper dbMethHelper;
-
- @BeforeClass
- public static void configure() throws Exception {
- System.setProperty("AJSC_HOME", ".");
- System.setProperty("BUNDLECONFIG_DIR", "src/main/resources");
- loader = LoaderFactory.createLoaderForVersion(ModelType.MOXY, AAIProperties.LATEST);
-
-
- }
-
- @Before
- public void init() {
- MockitoAnnotations.initMocks(this);
- processor = new ModelBasedProcessing(loader, dbEngine, serializer);
-
- dbMethHelper = new DbMethHelper(loader, dbEngine);
-
- }
-
- @Test
- public void getStartNodesAndModVersionIdsTest() throws AAIException {
-
-
- List<Map<String, Object>> startNodeFilterArrayOfHashes = new ArrayList<Map<String, Object>>();
- Map<String, Object> map = new HashMap<String, Object>();
- map.put("test", new Object());
- startNodeFilterArrayOfHashes.add(map);
- Map<String, String> result=new HashMap<>();
-
- Map<String, String> result1 = mockProcessor.getStartNodesAndModVersionIds("test", "test",
- "test", "test", "test",
- "test", startNodeFilterArrayOfHashes,
- "test");
- assertNotNull(result);
-
- }
-
-
- @Test(expected = NullPointerException.class)
- public void getStartNodesAndModVersionIdsTest2() throws AAIException {
- List<Map<String, Object>> startNodeFilterArrayOfHashes = new ArrayList<Map<String, Object>>();
- Map<String, Object> map = new HashMap<String, Object>();
- map.put("test", new Object());
- startNodeFilterArrayOfHashes.add(map);
- Map<String, String> result1 = processor.getStartNodesAndModVersionIds("test", "test",
- "", "test", "test",
- "test", startNodeFilterArrayOfHashes,
- "test");
- assertNotNull(result1);
- }
-
-
- @Test(expected = NullPointerException.class)
- public void getStartNodesAndModVersionIdsTest3() throws AAIException {
- List<Map<String, Object>> startNodeFilterArrayOfHashes = new ArrayList<Map<String, Object>>();
- Map<String, Object> map = new HashMap<String, Object>();
- map.put("test", new Object());
- startNodeFilterArrayOfHashes.add(map);
- Map<String, String> result1 = processor.getStartNodesAndModVersionIds("test", "test",
- "", "", "test",
- "test", startNodeFilterArrayOfHashes,
- "test");
- assertNotNull(result1);
- }
-
-
- @Test(expected = AAIException.class)
- public void getStartNodesAndModVersionIdsTest4() throws AAIException {
- List<Map<String, Object>> startNodeFilterArrayOfHashes = new ArrayList<Map<String, Object>>();
- Map<String, Object> map = new HashMap<String, Object>();
- map.put("test", new Object());
- startNodeFilterArrayOfHashes.add(map);
- Map<String, String> result1 = processor.getStartNodesAndModVersionIds("test", "test",
- "", "", "",
- "test", startNodeFilterArrayOfHashes,
- "test");
- assertNotNull(result1);
- }
-
-
- @Test(expected = AAIException.class)
- public void getStartNodesAndModVersionIdsTest5() throws AAIException {
- List<Map<String, Object>> startNodeFilterArrayOfHashes = new ArrayList<Map<String, Object>>();
- Map<String, Object> map = new HashMap<String, Object>();
- map.put("test", new Object());
- startNodeFilterArrayOfHashes.add(map);
- Map<String, String> result1 = processor.getStartNodesAndModVersionIds("test", "test",
- "", "", "",
- "", startNodeFilterArrayOfHashes,
- "test");
- assertNotNull(result1);
- }
-
-
- @Test(expected = AAIException.class)
- public void getStartNodesAndModVersionIdsNullTest() throws AAIException {
- List<Map<String, Object>> startNodeFilterArrayOfHashes = new ArrayList<Map<String, Object>>();
-
- Map<String, String> result = null;
- result = processor.getStartNodesAndModVersionIds("test", "test",
- "", "", "",
- "", startNodeFilterArrayOfHashes,
- "test");
-
- assertNotNull(result);
- }
-
-
- @Test(expected = NullPointerException.class)
- public void getStartNodesAndModVersionIdsNullTest1() throws AAIException {
- List<Map<String, Object>> startNodeFilterArrayOfHashes = new ArrayList<Map<String, Object>>();
-
- Map<String, String> result = null;
- result = processor.getStartNodesAndModVersionIds("test", "test",
- "Test", "", "",
- "", startNodeFilterArrayOfHashes,
- "test");
-
- assertNotNull(result);
- }
-
- @Test(expected = NullPointerException.class)
- public void getStartNodesAndModVersionIdsNullTest2() throws AAIException {
- List<Map<String, Object>> startNodeFilterArrayOfHashes = new ArrayList<Map<String, Object>>();
-
- Map<String, String> result = null;
- result = processor.getStartNodesAndModVersionIds("test", "test",
- "", "test", "",
- "", startNodeFilterArrayOfHashes,
- "test");
- assertNotNull(result);
- }
-
-
- @Test(expected = NullPointerException.class)
- public void getStartNodesAndModVersionIdsNullTest3() throws AAIException {
- List<Map<String, Object>> startNodeFilterArrayOfHashes = new ArrayList<Map<String, Object>>();
-
- Map<String, String> result = null;
- result = processor.getStartNodesAndModVersionIds("test", "test",
- "", "", "test",
- "", startNodeFilterArrayOfHashes,
- "test");
- assertNotNull(result);
- }
-
- @Test(expected = NullPointerException.class)
- public void getModelVerTopWidgetTypeTest() throws AAIException {
- Vertex vertex = new EmptyVertex();
- //Mockito.when(mockProcessor.getModelVerTopWidgetType(Mockito.any(Vertex.class), Mockito.any(String.class))).thenReturn("Sucess");
- String result = processor.getModelVerTopWidgetType(vertex, "test");
- assertEquals("result has -local tacked on the end as it should", "Sucess", result
- );
-
- }
-
- @Test(expected = NullPointerException.class)
- public void getModelVerTopWidgetType() throws AAIException {
+public class ModelBasedProcessingInvalidDataTest extends AAISetup {
+
+ @Mock
+ private static TransactionalGraphEngine dbEngine;
+ private static Loader loader;
+ @Mock
+ private static DBSerializer serializer;
+ ModelBasedProcessing processor;
+
+ @Mock
+ private ModelBasedProcessing mockProcessor;
+
+
+ @Mock
+ private DbMethHelper dbMethHelper;
+
+ @BeforeClass
+ public static void configure() throws Exception {
+ System.setProperty("AJSC_HOME", ".");
+ System.setProperty("BUNDLECONFIG_DIR", "src/main/resources");
+ }
+
+ @Before
+ public void init() {
+ MockitoAnnotations.initMocks(this);
+ loader = loaderFactory.createLoaderForVersion(ModelType.MOXY, schemaVersions.getDefaultVersion());
+ processor = new ModelBasedProcessing(loader, dbEngine, serializer);
+
+ dbMethHelper = new DbMethHelper(loader, dbEngine);
+
+ }
+
+ @Test
+ public void getStartNodesAndModVersionIdsTest() throws AAIException {
+
+
+ List<Map<String, Object>> startNodeFilterArrayOfHashes = new ArrayList<Map<String, Object>>();
+ Map<String, Object> map = new HashMap<String, Object>();
+ map.put("test", new Object());
+ startNodeFilterArrayOfHashes.add(map);
+ Map<String, String> result = new HashMap<>();
+
+ Map<String, String> result1 = mockProcessor.getStartNodesAndModVersionIds("test", "test",
+ "test", "test", "test",
+ "test", startNodeFilterArrayOfHashes,
+ "test");
+ assertNotNull(result);
+
+ }
+
+
+ @Test(expected = NullPointerException.class)
+ public void getStartNodesAndModVersionIdsTest2() throws AAIException {
+ List<Map<String, Object>> startNodeFilterArrayOfHashes = new ArrayList<Map<String, Object>>();
+ Map<String, Object> map = new HashMap<String, Object>();
+ map.put("test", new Object());
+ startNodeFilterArrayOfHashes.add(map);
+ Map<String, String> result1 = processor.getStartNodesAndModVersionIds("test", "test",
+ "", "test", "test",
+ "test", startNodeFilterArrayOfHashes,
+ "test");
+ assertNotNull(result1);
+ }
+
+
+ @Test(expected = NullPointerException.class)
+ public void getStartNodesAndModVersionIdsTest3() throws AAIException {
+ List<Map<String, Object>> startNodeFilterArrayOfHashes = new ArrayList<Map<String, Object>>();
+ Map<String, Object> map = new HashMap<String, Object>();
+ map.put("test", new Object());
+ startNodeFilterArrayOfHashes.add(map);
+ Map<String, String> result1 = processor.getStartNodesAndModVersionIds("test", "test",
+ "", "", "test",
+ "test", startNodeFilterArrayOfHashes,
+ "test");
+ assertNotNull(result1);
+ }
+
+
+ @Test(expected = AAIException.class)
+ public void getStartNodesAndModVersionIdsTest4() throws AAIException {
+ List<Map<String, Object>> startNodeFilterArrayOfHashes = new ArrayList<Map<String, Object>>();
+ Map<String, Object> map = new HashMap<String, Object>();
+ map.put("test", new Object());
+ startNodeFilterArrayOfHashes.add(map);
+ Map<String, String> result1 = processor.getStartNodesAndModVersionIds("test", "test",
+ "", "", "",
+ "test", startNodeFilterArrayOfHashes,
+ "test");
+ assertNotNull(result1);
+ }
+
+
+ @Test(expected = AAIException.class)
+ public void getStartNodesAndModVersionIdsTest5() throws AAIException {
+ List<Map<String, Object>> startNodeFilterArrayOfHashes = new ArrayList<Map<String, Object>>();
+ Map<String, Object> map = new HashMap<String, Object>();
+ map.put("test", new Object());
+ startNodeFilterArrayOfHashes.add(map);
+ Map<String, String> result1 = processor.getStartNodesAndModVersionIds("test", "test",
+ "", "", "",
+ "", startNodeFilterArrayOfHashes,
+ "test");
+ assertNotNull(result1);
+ }
+
+
+ @Test(expected = AAIException.class)
+ public void getStartNodesAndModVersionIdsNullTest() throws AAIException {
+ List<Map<String, Object>> startNodeFilterArrayOfHashes = new ArrayList<Map<String, Object>>();
+
+ Map<String, String> result = null;
+ result = processor.getStartNodesAndModVersionIds("test", "test",
+ "", "", "",
+ "", startNodeFilterArrayOfHashes,
+ "test");
+
+ assertNotNull(result);
+ }
+
+
+ @Test(expected = NullPointerException.class)
+ public void getStartNodesAndModVersionIdsNullTest1() throws AAIException {
+ List<Map<String, Object>> startNodeFilterArrayOfHashes = new ArrayList<Map<String, Object>>();
+
+ Map<String, String> result = null;
+ result = processor.getStartNodesAndModVersionIds("test", "test",
+ "Test", "", "",
+ "", startNodeFilterArrayOfHashes,
+ "test");
+
+ assertNotNull(result);
+ }
+
+ @Test(expected = NullPointerException.class)
+ public void getStartNodesAndModVersionIdsNullTest2() throws AAIException {
+ List<Map<String, Object>> startNodeFilterArrayOfHashes = new ArrayList<Map<String, Object>>();
+
+ Map<String, String> result = null;
+ result = processor.getStartNodesAndModVersionIds("test", "test",
+ "", "test", "",
+ "", startNodeFilterArrayOfHashes,
+ "test");
+ assertNotNull(result);
+ }
+
+
+ @Test(expected = NullPointerException.class)
+ public void getStartNodesAndModVersionIdsNullTest3() throws AAIException {
+ List<Map<String, Object>> startNodeFilterArrayOfHashes = new ArrayList<Map<String, Object>>();
+
+ Map<String, String> result = null;
+ result = processor.getStartNodesAndModVersionIds("test", "test",
+ "", "", "test",
+ "", startNodeFilterArrayOfHashes,
+ "test");
+ assertNotNull(result);
+ }
+
+ @Test(expected = NullPointerException.class)
+ public void getModelVerTopWidgetTypeTest() throws AAIException {
+ Vertex vertex = new EmptyVertex();
+ //Mockito.when(mockProcessor.getModelVerTopWidgetType(Mockito.any(Vertex.class), Mockito.any(String.class))).thenReturn("Sucess");
+ String result = processor.getModelVerTopWidgetType(vertex, "test");
+ assertEquals("result has -local tacked on the end as it should", "Sucess", result
+ );
+
+ }
+
+ @Test(expected = NullPointerException.class)
+ public void getModelVerTopWidgetType() throws AAIException {
/*Mockito.when(mockProcessor.getModelVerTopWidgetType(Mockito.any(String.class),
Mockito.any(String.class), Mockito.any(String.class),
Mockito.any(String.class), Mockito.any(String.class))
).thenReturn("Sucess");*/
- String result = processor.getModelVerTopWidgetType("test", "test", "test", "Test", "test");
- assertEquals("result has -local tacked on the end as it should", "Sucess", result
- );
+ String result = processor.getModelVerTopWidgetType("test", "test", "test", "Test", "test");
+ assertEquals("result has -local tacked on the end as it should", "Sucess", result
+ );
- }
+ }
- @Test(expected = AAIException.class)
- public void queryByModel() throws AAIException {
+ @Test(expected = AAIException.class)
+ public void queryByModel() throws AAIException {
/*Mockito.when(mockProcessor.getModelVerTopWidgetType(Mockito.any(String.class),
Mockito.any(String.class), Mockito.any(String.class),
Mockito.any(String.class), Mockito.any(String.class))
).thenReturn("Sucess");*/
- List<ResultSet> result = processor.queryByModel("test", "test",
- "test", "test", "test",
- "generic-vnf", null,
- "test");
- assertEquals("result has -local tacked on the end as it should", 0, result.size());
-
-
- }
+ List<ResultSet> result = processor.queryByModel("test", "test",
+ "test", "test", "test",
+ "generic-vnf", null,
+ "test");
+ assertEquals("result has -local tacked on the end as it should", 0, result.size());
- @Test(expected = NullPointerException.class)
- public void queryByModel_Timed() throws AAIException {
- List<Map<String, Object>> startNodeFilterArrayOfHashes = new ArrayList<Map<String, Object>>();
- Map<String, Object> map = new HashMap<String, Object>();
- map.put("test", new Object());
- startNodeFilterArrayOfHashes.add(map);
- List<ResultSet> result = processor.queryByModel_Timed("test", "test",
- "test", "test", "test",
- "test", startNodeFilterArrayOfHashes,
- "test");
- assertEquals("result has -local tacked on the end as it should", 0, result.size());
-
+ }
- }
- @Mock
- Map<String, Object> startNodeFilterHash;
-
- @Test(expected = NullPointerException.class)
- public void runDeleteByModel() throws AAIException {
- Map<String, String> resultMock = new HashMap<String, String>();
+ @Test(expected = NullPointerException.class)
+ public void queryByModel_Timed() throws AAIException {
+ List<Map<String, Object>> startNodeFilterArrayOfHashes = new ArrayList<Map<String, Object>>();
+ Map<String, Object> map = new HashMap<String, Object>();
+ map.put("test", new Object());
+ startNodeFilterArrayOfHashes.add(map);
+ List<ResultSet> result = processor.queryByModel_Timed("test", "test",
+ "test", "test", "test",
+ "test", startNodeFilterArrayOfHashes,
+ "test");
+ assertEquals("result has -local tacked on the end as it should", 0, result.size());
+
- // when(mockProcessor.getNodeUsingUniqueId(any(String.class),any(String.class),any(String.class),any(String.class),any(String.class))).thenReturn(vertex);
- when(mockProcessor.runDeleteByModel(any(String.class),
- any(String.class), any(String.class),
- any(String.class), anyMapOf(String.class, Object.class), any(String.class), any(String.class))
- ).thenReturn(resultMock);
- Map<String, String> result = processor.runDeleteByModel("test", "test",
- "test", "test", startNodeFilterHash,
- "test",
- "test");
- assertEquals("result has -local tacked on the end as it should", result.size(), resultMock.size());
+ }
+ @Mock
+ Map<String, Object> startNodeFilterHash;
+
+ @Test(expected = NullPointerException.class)
+ public void runDeleteByModel() throws AAIException {
+ Map<String, String> resultMock = new HashMap<String, String>();
- }
-
- Optional<Vertex> vertext = Optional.empty();
-
- @Test(expected = AAIException.class)
- public void runDeleteByModelWithNullParams() throws AAIException {
- Map<String, String> resultMock = new HashMap<String, String>();
-
-
- Map<String, String> result = processor.runDeleteByModel("test", "test",
- null, null, null,
- "test",
- "test");
-
- assertNotNull(result);
-
- }
-
- @Test(expected = NullPointerException.class)
- public void runDeleteByModelWithNullParams1() throws AAIException {
-
- Map<String, String> result1 = processor.runDeleteByModel("test", "test",
- null, "unknown", null,
- "test",
- "test");
- assertNotNull(result1);
-
- }
-
-
- @Test(expected = NullPointerException.class)
- public void runDeleteByModelWithNullParams2() throws AAIException {
-
- Map<String, String> result1 = processor.runDeleteByModel("test", "test",
- null, "unknown", null,
- "test",
- "test");
- assertNotNull(result1);
-
- }
-
- @Test(expected = AAIException.class)
- public void queryByNamedQuery() throws AAIException{
- String transId="test";
- String fromAppId="test";
- String namedQueryUuid="test";
- ArrayList <Map<String,Object>> startNodeFilterArrayOfHashes=new ArrayList<Map<String,Object>>();
- String apiVer="test";
- List<ResultSet> result=processor.queryByNamedQuery(transId,fromAppId,namedQueryUuid,startNodeFilterArrayOfHashes,apiVer);
- assertNotNull(result);
- }
-
- @Test(expected = AAIException.class)
- public void queryByNamedQuery1() throws AAIException{
- String transId="teet";
- String fromAppId="test";
- String namedQueryUuid="test";
- String secondaryFilterCutPoint="test";
- List <Map<String,Object>> startNodeFilterArrayOfHashes=new ArrayList<Map<String,Object>>();
- String apiVer="test";
- Map<String,Object> secondaryFilterHash=new HashMap<String,Object>();
- List<ResultSet> result=processor.queryByNamedQuery(transId,fromAppId,namedQueryUuid,startNodeFilterArrayOfHashes,apiVer,secondaryFilterCutPoint,secondaryFilterHash);
- assertNotNull(result);
- }
-
- @Test
- public void deleteAsNeededFromResultSet() throws AAIException {
- Vertex vert = new BaseVertexLabel("Test");
- Map<String, String> resultMock = new HashMap<String, String>();
- ResultSet resultSet = new ResultSet();
- resultSet.setVert(null);
-
- Map<String, String> result = processor.deleteAsNeededFromResultSet("test", "test",
- resultSet, "test", "test",
- "test",
- resultMock);
-
- assertEquals(result.size(), 0);
-
- resultSet.setVert(vert);
-
- Map<String, String> result1 = processor.deleteAsNeededFromResultSet("test", "test",
- resultSet, "test", "test",
- "test",
- resultMock);
-
- assertEquals(result.size(), 0);
-
-
- }
-
- @Test(expected = NullPointerException.class)
- public void pruneResultSetTest() throws AAIException {
- ResultSet rs = new ResultSet();
- Vertex v = new BaseVertexLabel(AAIProperties.NODE_TYPE);
- rs.setVert(v);
- List<ResultSet> rsList = new ArrayList<ResultSet>();
- ResultSet rs1 = new ResultSet();
- rsList.add(rs1);
- rs.setSubResultSet(rsList);
- Map<String, Object> map = new HashMap<String, Object>();
- map.put("test", new Object());
- ResultSet resultSet = processor.pruneResultSet(rs, "testr", map);
- assertNotNull(resultSet);
-
- }
-
- @Test(expected = NullPointerException.class)
- public void satisfiesFiltersTest() throws AAIException {
- ResultSet rs = new ResultSet();
- Vertex v = new BaseVertexLabel(AAIProperties.NODE_TYPE);
- rs.setVert(v);
- rs.getVert().property(AAIProperties.NODE_TYPE);
- List<ResultSet> rsList = new ArrayList<ResultSet>();
- ResultSet rs1 = new ResultSet();
- rsList.add(rs1);
- rs.setSubResultSet(rsList);
- Map<String, Object> map = new HashMap<String, Object>();
-
- map.put("modern.vertex-id", new Object());
-
- boolean result = processor.satisfiesFilters(rs, map);
- assertEquals(result, true);
- }
-
- @Test
- public void satisfiesFiltersTest1() throws AAIException {
- ResultSet rs = new ResultSet();
- Vertex v = new BaseVertexLabel(AAIProperties.NODE_TYPE);
- rs.setVert(v);
- List<ResultSet> rsList = new ArrayList<ResultSet>();
- ResultSet rs1 = new ResultSet();
- rsList.add(rs1);
- rs.setSubResultSet(rsList);
- Map<String, Object> map = new HashMap<String, Object>();
- //map.put("test.filter",new Object());
-
- boolean result = processor.satisfiesFilters(rs, map);
- assertEquals(result, false);
- }
-
- @Test(expected = AAIException.class)
- public void satisfiesFiltersTest2() throws AAIException {
- ResultSet rs = new ResultSet();
- Vertex v = new BaseVertexLabel(AAIProperties.NODE_TYPE);
- rs.setVert(v);
- List<ResultSet> rsList = new ArrayList<ResultSet>();
- ResultSet rs1 = new ResultSet();
- rsList.add(rs1);
- rs.setSubResultSet(rsList);
- Map<String, Object> map = new HashMap<String, Object>();
- map.put("testfilter", new Object());
-
- boolean result = processor.satisfiesFilters(rs, map);
- assertEquals(result, false);
- }
-
- @Test
- public void collapseForDoNotOutputTest() throws AAIException {
- ResultSet rs = new ResultSet();
- rs.setDoNotOutputFlag("true");
- List<ResultSet> rsList = new ArrayList<ResultSet>();
- ResultSet rs1 = new ResultSet();
- rsList.add(rs1);
- rs.setSubResultSet(rsList);
- List<ResultSet> result = processor.collapseForDoNotOutput(rs);
- assertEquals(result.size(), 1);
- }
-
- @Test(expected = NullPointerException.class)
- public void collectInstanceDataTest() throws AAIException {
-
- BaseVertexLabel bs = new BaseVertexLabel("test");
- //bs.setId(80);
- EmptyVertex ev = new EmptyVertex();
- //ev.setId(50l);
- Vertex thisLevelElemVtx = ev;
-
-
- Multimap<String, String> thisMap = ArrayListMultimap.create();
- List<String> vidsTraversed = new ArrayList<String>();
- // only applies when collecting data using the default model for delete
- Multimap<String, String> validNextStepMap = ArrayListMultimap.create();
- Map<String, String> namedQueryElementHash = new HashMap<String, String>();
- namedQueryElementHash.put("test", "test");
- Map<String, String> delKeyHash = new HashMap<String, String>();
-
- ResultSet rs = processor.collectInstanceData("test", "test", thisLevelElemVtx, "test", validNextStepMap, vidsTraversed, 1, delKeyHash, namedQueryElementHash, "test");
- }
-
- @Test(expected = NullPointerException.class)
- public void genTopoMap4ModelVerTest() throws
- AAIException {
- Vertex vertext = new EmptyVertex();
- Multimap<String, String> map = processor.genTopoMap4ModelVer("test", "test", vertext, "test");
- assertNotEquals(map, null);
- }
-
- @Test(expected = AAIException.class)
- public void genTopoMap4ModelVerTestNull() throws
- AAIException {
- Vertex vertext = null;
- Multimap<String, String> map = processor.genTopoMap4ModelVer("test", "test", vertext, "test");
- assertNotEquals(map, null);
- }
-
- @Test
- public void makeSureItsAnArrayListTest() {
- String input = "model-versionId,modelTestID,modelTestid2;";
- List<String> result = processor.makeSureItsAnArrayList(input);
- assertTrue(result.size() > 0);
- }
-
- @Test(expected = AAIException.class)
- public void getModConstraintHashTest() throws AAIException {
- Vertex modelElementVtx = new EmptyVertex();
- //modelElementVtx.property(AAIProperties.NODE_TYPE,"Model");
- Vertex modelElementVtx1 = new EmptyVertex();
- Map<String, Vertex> currentHash = new HashMap<String, Vertex>();
- currentHash.put("constraint", modelElementVtx1);
- Map<String, Vertex> result = processor.getModConstraintHash(modelElementVtx, currentHash);
- assertTrue(result.size() > 0);
- }
-
- @Test(expected = AAIException.class)
- public void getModConstraintHashTestNull() throws AAIException {
- Vertex modelElementVtx = null;
- //modelElementVtx.property(AAIProperties.NODE_TYPE,"Model");
- Vertex modelElementVtx1 =null;
- Map<String, Vertex> currentHash = new HashMap<String, Vertex>();
- currentHash.put("constraint", modelElementVtx1);
- Map<String, Vertex> result = processor.getModConstraintHash(modelElementVtx, currentHash);
- assertTrue(result.size() > 0);
- }
-
- @Test(expected = NullPointerException.class)
- public void getTopElementForSvcOrResModelVerTest() throws AAIException {
- Vertex modelElementVtx = new EmptyVertex();
- //modelElementVtx.property(AAIProperties.NODE_TYPE,"Model");
- Vertex modelElementVtx1 = new EmptyVertex();
- Map<String, Vertex> currentHash = new HashMap<String, Vertex>();
- currentHash.put("constraint", modelElementVtx1);
- Vertex result = processor.getTopElementForSvcOrResModelVer(modelElementVtx, "test");
- assertNotEquals(result, null);
- }
-
- @Test
- public void getNamedQueryPropOverRideTest() throws AAIException {
- String transId = "test";
- String fromAppId = "test";
- Vertex namedQueryElementVertex = new EmptyVertex();
- Vertex instanceVertex = new EmptyVertex();
- String apiVer = "test";
-
- namedQueryElementVertex.properties("property-collect-list", "");
-
- Map<String, Object> result = processor.getNamedQueryPropOverRide(transId, fromAppId, namedQueryElementVertex, instanceVertex, apiVer);
- assertNotEquals(result, null);
- }
-
- @Test(expected = NullPointerException.class)
- public void getNamedQueryPropOverRideTestNull() throws AAIException {
- String transId = "test";
- String fromAppId = "test";
- Vertex namedQueryElementVertex = null;
- Vertex instanceVertex = new EmptyVertex();
- String apiVer = "test";
-
- namedQueryElementVertex.properties("property-collect-list", "");
-
- Map<String, Object> result = processor.getNamedQueryPropOverRide(transId, fromAppId, namedQueryElementVertex, instanceVertex, apiVer);
- assertNotEquals(result, null);
- }
-
- @Test(expected = NullPointerException.class)
- public void namedQueryConstraintSaysStopTest() throws AAIException {
- String transId = "test";
- String fromAppId = "test";
- Vertex namedQueryElementVertex = new EmptyVertex();
- Vertex instanceVertex = new EmptyVertex();
- String apiVer = "test";
-
- namedQueryElementVertex.properties("property-collect-list", "");
-
- boolean result = processor.namedQueryConstraintSaysStop(transId, fromAppId, namedQueryElementVertex, instanceVertex, apiVer);
- assertTrue(result);
- }
-
- @Test(expected = NullPointerException.class)
- public void namedQueryConstraintSaysStopTestNull() throws AAIException {
- String transId = "test";
- String fromAppId = "test";
- Vertex namedQueryElementVertex = null;
- Vertex instanceVertex = new EmptyVertex();
- String apiVer = "test";
-
- namedQueryElementVertex.properties("property-collect-list", "");
-
- boolean result = processor.namedQueryConstraintSaysStop(transId, fromAppId, namedQueryElementVertex, instanceVertex, apiVer);
- assertTrue(result);
- }
-
- @Test(expected = AAIException.class)
- public void namedQuerynamedQueryElementVertexNullTest() throws AAIException {
- String transId = "test";
- String fromAppId = "test";
- Vertex namedQueryElementVertex = null;
- Vertex instanceVertex = null;
- String apiVer = "test";
-
-
- boolean result = processor.namedQueryConstraintSaysStop(transId, fromAppId, namedQueryElementVertex, instanceVertex, apiVer);
- assertTrue(result);
- }
-
- @Test(expected = NullPointerException.class)
-
- public void getNamedQueryExtraDataLookupTest() throws Exception {
-
- String transId = "test";
- String fromAppId = "test";
- Vertex namedQueryElementVertex = new EmptyVertex();
- Vertex instanceVertex = new EmptyVertex();
- String apiVer = "test";
-
- namedQueryElementVertex.properties("property-collect-list", "");
-
- Map<String, Object> result = processor.getNamedQueryExtraDataLookup(transId, fromAppId, namedQueryElementVertex, instanceVertex, apiVer);
-
- assertTrue(result.size() > 0);
- }
-
- @Test(expected = NullPointerException.class)
- public void collectNQElementHash() throws AAIException {
- String transId = "test";
- String fromAppId = "test";
- Vertex thisLevelElemVtx = new EmptyVertex();
- String incomingTrail = "test";
- Map<String, String> currentHash = new HashMap<String, String>();
- ArrayList<String> vidsTraversed = new ArrayList<String>();
- int levelCounter = 1;
-
- Map<String, String> result = processor.collectNQElementHash(transId, fromAppId,
- thisLevelElemVtx, incomingTrail, currentHash,
- vidsTraversed, levelCounter);
-
- assertNotEquals(result, null);
- }
-
- @Test(expected = NullPointerException.class)
- public void collectDeleteKeyHash() throws AAIException {
- String transId = "test";
- String fromAppId = "test";
- Vertex thisLevelElemVtx = new EmptyVertex();
- String incomingTrail = "test";
- Map<String, String> currentHash = new HashMap<String, String>();
- ArrayList<String> vidsTraversed = new ArrayList<String>();
- int levelCounter = 1;
- Map<String, Vertex> modConstraintHash = new HashMap<String, Vertex>();
- String overRideModelId = "test";
- String overRideModelVersionId = "test";
-
- Map<String, String> result = processor.collectDeleteKeyHash(transId, fromAppId,
- thisLevelElemVtx, incomingTrail, currentHash,
- vidsTraversed, levelCounter, modConstraintHash, overRideModelId, overRideModelVersionId);
-
- assertNotEquals(result, null);
- }
-
- @Test
- public void getLinkageConnectNodeTypesTest() throws AAIException {
- List<String> linkagePtList = new ArrayList<String>();
- linkagePtList.add("modern\\|testdata\\|");
- Set<String> result = processor.getLinkageConnectNodeTypes(linkagePtList);
- assertNotEquals(result, null);
-
- }
-
- @Test(expected = AAIException.class)
- public void getLinkageConnectNodeTypesTest1() throws AAIException {
-
- Set<String> result1 = processor.getLinkageConnectNodeTypes(null);
- assertNotEquals(result1, null);
-
- List<String> linkagePtList = new ArrayList<String>();
- linkagePtList.add("moderntestdata");
- Set<String> result = processor.getLinkageConnectNodeTypes(linkagePtList);
- assertNotEquals(result, null);
- }
-
- @Test(expected = NullPointerException.class)
- public void collectTopology4ModelVerTest() throws AAIException {
- String transId = "test";
- String fromAppId = "test";
- Multimap<String, String> thisMap = ArrayListMultimap.create();
- Vertex thisLevelElemVtx = new EmptyVertex();
- String incomingTrail = "test";
- Map<String, Vertex> currentHash = new HashMap<String, Vertex>();
- List<String> vidsTraversed = new ArrayList<String>();
- int levelCounter = 1;
-
- Multimap<String, String> result = processor.collectTopology4ModelVer(transId, fromAppId,
- thisLevelElemVtx, incomingTrail, thisMap, vidsTraversed, levelCounter, currentHash
- , "test", "test");
-
- assertNotEquals(result, null);
- }
-
- @Test(expected = AAIException.class)
- public void check4EdgeRuleTest() throws AAIException {
- processor.check4EdgeRule("test", "test");
- }
-
- @Test(expected = AAIException.class)
- public void collectTopology4LinkagePointTest() throws AAIException {
- String transId = "test";
- String fromAppId = "test";
- String linkagePointStrVal = "test";
- String incomingTrail = "test";
- Multimap<String, String> currentMap = ArrayListMultimap.create();
-
- Multimap<String, String> result = processor.collectTopology4LinkagePoint(transId, fromAppId, linkagePointStrVal, incomingTrail, currentMap);
- assertNotEquals(result, null);
-
- }
-
- @Test(expected = AAIException.class)
- public void getNextStepElementsFromSet() throws AAIException {
- Vertex constrElemSetVtx = new EmptyVertex();
- constrElemSetVtx.<String>property(AAIProperties.NODE_TYPE);
- Map<String, Object> result = processor.getNextStepElementsFromSet(constrElemSetVtx);
- assertNotEquals(result, null);
- }
-
- @Test(expected = NullPointerException.class)
- public void genTopoMap4NamedQTest() throws AAIException {
- String transId = "test";
- String fromAppId = "test";
- Vertex queryVertex = new EmptyVertex();
- String namedQueryUuid = "E44533334343";
- Multimap<String, String> result = processor.genTopoMap4NamedQ(transId, fromAppId, queryVertex, namedQueryUuid);
- assertNotEquals(result, null);
- }
-
- @Test(expected = NullPointerException.class)
- public void collectTopology4NamedQTest() throws AAIException {
- String transId = "test";
- String fromAppId = "test";
- Multimap<String, String> thisMap = ArrayListMultimap.create();
- Vertex thisLevelElemVtx = new EmptyVertex();
- String incomingTrail = "test";
- Map<String, Vertex> currentHash = new HashMap<String, Vertex>();
- List<String> vidsTraversed = new ArrayList<String>();
- int levelCounter = 1;
-
- Multimap<String, String> result = processor.collectTopology4NamedQ(transId, fromAppId,
- thisLevelElemVtx, incomingTrail, thisMap, vidsTraversed, levelCounter);
- assertNotEquals(result, null);
- }
-
- @Test(expected = NullPointerException.class)
- public void getModelThatNqElementRepresentsTest() throws AAIException {
- Vertex thisLevelElemVtx = new EmptyVertex();
- String incomingTrail = "test";
- Vertex vertex = processor.getModelThatNqElementRepresents(thisLevelElemVtx, incomingTrail);
- assertNotEquals(vertex, null);
- }
-
- @Test(expected = NullPointerException.class)
- public void getModelGivenModelVer() throws AAIException {
- Vertex thisLevelElemVtx = new EmptyVertex();
- String incomingTrail = "test";
- Vertex vertex = processor.getModelGivenModelVer(thisLevelElemVtx, incomingTrail);
- assertNotEquals(vertex, null);
- }
-
- @Test(expected = AAIException.class)
- public void getModelTypeFromModel() throws AAIException {
- Vertex thisLevelElemVtx = new EmptyVertex();
- String incomingTrail = "test";
- String vertex = processor.getModelTypeFromModel(thisLevelElemVtx, incomingTrail);
- assertNotEquals(vertex, null);
- }
-
- @Test(expected = NullPointerException.class)
- public void getModelTypeFromModelVer() throws AAIException {
- Vertex thisLevelElemVtx = new EmptyVertex();
- String incomingTrail = "test";
- String vertex = processor.getModelTypeFromModelVer(thisLevelElemVtx, incomingTrail);
- assertNotEquals(vertex, null);
- }
-
- @Test(expected = NullPointerException.class)
- public void getModelElementStepName() throws AAIException {
- Vertex thisLevelElemVtx = new EmptyVertex();
- String incomingTrail = "test";
- String vertex = processor.getModelElementStepName(thisLevelElemVtx, incomingTrail);
- assertNotEquals(vertex, null);
- }
-
- @Test(expected = AAIException.class)
- public void nodeTypeSupportsPersona() throws AAIException {
- String incomingTrail = "";
- boolean vertex = processor.nodeTypeSupportsPersona(incomingTrail);
- assertFalse(vertex);
-
-
- incomingTrail = "test";
- boolean vertex1 = processor.nodeTypeSupportsPersona(incomingTrail);
- assertTrue(vertex1);
- }
-
- @Test(expected = NullPointerException.class)
- public void getNqElementWidgetType() throws AAIException{
- String appId="test";
- String transID="test";
- Vertex thisLevelElemVtx = new EmptyVertex();
- String incomingTrail = "test";
- String vertex1 = processor.getNqElementWidgetType(appId,transID,thisLevelElemVtx,incomingTrail);
- assertNotEquals(vertex1,null);
- }
-
-
- @Test(expected = NullPointerException.class)
- public void getModElementWidgetType() throws AAIException{
- String appId="test";
- String transID="test";
- Vertex thisLevelElemVtx = new EmptyVertex();
- String incomingTrail = "test";
- String vertex1 = processor.getModElementWidgetType(thisLevelElemVtx,incomingTrail);
- assertNotEquals(vertex1,null);
- }
-
- @Test(expected = NullPointerException.class)
- public void getNodeUsingUniqueId() throws AAIException{
- String appId="test";
- String transID="test";
- String nodeType = "generic-vnf";
- String idPropertyName = "test";
- String uniqueIdVal="test";
- Vertex vertex1 = processor.getNodeUsingUniqueId(transID,appId,nodeType,idPropertyName,uniqueIdVal);
- assertNotEquals(vertex1,null);
- }
-
-
- @Test(expected = AAIException.class)
- public void getNodeUsingUniqueIdNull() throws AAIException{
- String appId="test";
- String transID="test";
- String nodeType = "generic-vnf";
- String idPropertyName = "test";
- String uniqueIdVal="";
- Vertex vertex1 = null;
- vertex1= processor.getNodeUsingUniqueId(transID,appId,nodeType,idPropertyName,uniqueIdVal);
- assertNotEquals(vertex1,null);
-
- }
-
-
- @Test(expected = AAIException.class)
- public void getNodeUsingUniqueIdNull1() throws AAIException{
- String appId="test";
- String transID="test";
- String nodeType = "generic-vnf";
- String idPropertyName="";
- String uniqueIdVal="test";
- Vertex vertex1 = null;
- vertex1= processor.getNodeUsingUniqueId(transID,appId,nodeType,idPropertyName,uniqueIdVal);
- assertNotEquals(vertex1,null);
-
-
- }
-
-
- @Test(expected = AAIException.class)
- public void getNodeUsingUniqueIdNull2() throws AAIException{
- String appId="test";
- String transID="test";
- String nodeType = "";
- String idPropertyName="test";
- String uniqueIdVal="test";
- Vertex vertex1 = null;
- vertex1= processor.getNodeUsingUniqueId(transID,appId,nodeType,idPropertyName,uniqueIdVal);
- assertNotEquals(vertex1,null);
-
-
- }
-
- @Test(expected = NullPointerException.class)
- public void getModelVersUsingName() throws AAIException{
- String appId="test";
- String transID="test";
- String modelName = "test";
-
- List<Vertex> result= processor.getModelVersUsingName(transID,appId,modelName);
- assertNotEquals(result,null);
- }
-
-
- @Test(expected = AAIException.class)
- public void getModelVersUsingNameNull() throws AAIException{
- String appId="test";
- String transID="test";
- String modelName = "";
-
- List<Vertex> result= processor.getModelVersUsingName(transID,appId,modelName);
- assertNotEquals(result,null);
- }
-
-
- @Test(expected = NullPointerException.class)
- public void getModVersUsingModelInvId() throws AAIException{
- String appId="test";
- String transID="test";
- String modelName = "test";
-
- Iterator<Vertex> result= processor.getModVersUsingModelInvId(transID,appId,modelName);
- assertNotEquals(result,null);
- }
-
- @Test(expected = AAIException.class)
- public void getModVersUsingModelInvIdNull() throws AAIException{
- String appId="test";
- String transID="test";
- String modelName = "";
-
- Iterator<Vertex> result= processor.getModVersUsingModelInvId(transID,appId,modelName);
- assertNotEquals(result,null);
- }
-
- @Test(expected = NullPointerException.class)
- public void getModVersUsingModel() throws AAIException{
- String appId="test";
- String transID="test";
- String modelName = "test";
- Vertex thisLevelElemVtx = new EmptyVertex();
- List<Vertex> result= processor.getModVersUsingModel(transID,appId,thisLevelElemVtx);
- assertNotEquals(result,null);
- }
-
- @Test(expected = AAIException.class)
- public void getModVersUsingModel1() throws AAIException{
- String appId="test";
- String transID="test";
-
- Vertex thisLevelElemVtx = null;
- List<Vertex> result= processor.getModVersUsingModel(transID,appId,thisLevelElemVtx);
- assertNotEquals(result,null);
- }
-
- @Test(expected = NullPointerException.class)
- public void getModelVerIdsUsingName() throws AAIException{
- String appId="test";
- String transID="test";
-
- String modelName= "test";
- List<String> result= processor.getModelVerIdsUsingName(transID,appId,modelName);
- assertNotEquals(result,null);
- }
-
- @Test(expected = AAIException.class)
- public void getModelVerIdsUsingName1() throws AAIException{
- String appId="test";
- String transID="test";
-
- String modelName= "";
- List<String> result= processor.getModelVerIdsUsingName(transID,appId,modelName);
- assertNotEquals(result,null);
- }
-
- @Test(expected =NullPointerException.class)
- public void validateModel() throws AAIException{
- String appId="test";
- String transID="test";
-
- String modelVersionId= "test";
- String modelInvId= "test";
- String modelName= "test";
- processor.validateModel(transID,appId,modelName,modelVersionId);
-
-
- }
+ // when(mockProcessor.getNodeUsingUniqueId(any(String.class),any(String.class),any(String.class),any(String.class),any(String.class))).thenReturn(vertex);
+ when(mockProcessor.runDeleteByModel(any(String.class),
+ any(String.class), any(String.class),
+ any(String.class), anyMapOf(String.class, Object.class), any(String.class), any(String.class))
+ ).thenReturn(resultMock);
+ Map<String, String> result = processor.runDeleteByModel("test", "test",
+ "test", "test", startNodeFilterHash,
+ "test",
+ "test");
+ assertEquals("result has -local tacked on the end as it should", result.size(), resultMock.size());
+ }
+
+ Optional<Vertex> vertext = Optional.empty();
+
+ @Test(expected = AAIException.class)
+ public void runDeleteByModelWithNullParams() throws AAIException {
+ Map<String, String> resultMock = new HashMap<String, String>();
+
+
+ Map<String, String> result = processor.runDeleteByModel("test", "test",
+ null, null, null,
+ "test",
+ "test");
+
+ assertNotNull(result);
+
+ }
+
+ @Test(expected = NullPointerException.class)
+ public void runDeleteByModelWithNullParams1() throws AAIException {
+
+ Map<String, String> result1 = processor.runDeleteByModel("test", "test",
+ null, "unknown", null,
+ "test",
+ "test");
+ assertNotNull(result1);
+
+ }
+
+
+ @Test(expected = NullPointerException.class)
+ public void runDeleteByModelWithNullParams2() throws AAIException {
+
+ Map<String, String> result1 = processor.runDeleteByModel("test", "test",
+ null, "unknown", null,
+ "test",
+ "test");
+ assertNotNull(result1);
+
+ }
+
+ @Test(expected = AAIException.class)
+ public void queryByNamedQuery() throws AAIException {
+ String transId = "test";
+ String fromAppId = "test";
+ String namedQueryUuid = "test";
+ ArrayList<Map<String, Object>> startNodeFilterArrayOfHashes = new ArrayList<Map<String, Object>>();
+ String apiVer = "test";
+ List<ResultSet> result = processor.queryByNamedQuery(transId, fromAppId, namedQueryUuid, startNodeFilterArrayOfHashes, apiVer);
+ assertNotNull(result);
+ }
+
+ @Test(expected = AAIException.class)
+ public void queryByNamedQuery1() throws AAIException {
+ String transId = "teet";
+ String fromAppId = "test";
+ String namedQueryUuid = "test";
+ String secondaryFilterCutPoint = "test";
+ List<Map<String, Object>> startNodeFilterArrayOfHashes = new ArrayList<Map<String, Object>>();
+ String apiVer = "test";
+ Map<String, Object> secondaryFilterHash = new HashMap<String, Object>();
+ List<ResultSet> result = processor.queryByNamedQuery(transId, fromAppId, namedQueryUuid, startNodeFilterArrayOfHashes, apiVer, secondaryFilterCutPoint, secondaryFilterHash);
+ assertNotNull(result);
+ }
+
+ @Test
+ public void deleteAsNeededFromResultSet() throws AAIException {
+ Vertex vert = new BaseVertexLabel("Test");
+ Map<String, String> resultMock = new HashMap<String, String>();
+ ResultSet resultSet = new ResultSet();
+ resultSet.setVert(null);
+
+ Map<String, String> result = processor.deleteAsNeededFromResultSet("test", "test",
+ resultSet, "test", "test",
+ "test",
+ resultMock);
+
+ assertEquals(result.size(), 0);
+
+ resultSet.setVert(vert);
+
+ Map<String, String> result1 = processor.deleteAsNeededFromResultSet("test", "test",
+ resultSet, "test", "test",
+ "test",
+ resultMock);
+
+ assertEquals(result.size(), 0);
+
+
+ }
+
+ @Test(expected = NullPointerException.class)
+ public void pruneResultSetTest() throws AAIException {
+ ResultSet rs = new ResultSet();
+ Vertex v = new BaseVertexLabel(AAIProperties.NODE_TYPE);
+ rs.setVert(v);
+ List<ResultSet> rsList = new ArrayList<ResultSet>();
+ ResultSet rs1 = new ResultSet();
+ rsList.add(rs1);
+ rs.setSubResultSet(rsList);
+ Map<String, Object> map = new HashMap<String, Object>();
+ map.put("test", new Object());
+ ResultSet resultSet = processor.pruneResultSet(rs, "testr", map);
+ assertNotNull(resultSet);
+
+ }
+
+ @Test(expected = NullPointerException.class)
+ public void satisfiesFiltersTest() throws AAIException {
+ ResultSet rs = new ResultSet();
+ Vertex v = new BaseVertexLabel(AAIProperties.NODE_TYPE);
+ rs.setVert(v);
+ rs.getVert().property(AAIProperties.NODE_TYPE);
+ List<ResultSet> rsList = new ArrayList<ResultSet>();
+ ResultSet rs1 = new ResultSet();
+ rsList.add(rs1);
+ rs.setSubResultSet(rsList);
+ Map<String, Object> map = new HashMap<String, Object>();
+
+ map.put("modern.vertex-id", new Object());
+
+ boolean result = processor.satisfiesFilters(rs, map);
+ assertEquals(result, true);
+ }
+
+ @Test
+ public void satisfiesFiltersTest1() throws AAIException {
+ ResultSet rs = new ResultSet();
+ Vertex v = new BaseVertexLabel(AAIProperties.NODE_TYPE);
+ rs.setVert(v);
+ List<ResultSet> rsList = new ArrayList<ResultSet>();
+ ResultSet rs1 = new ResultSet();
+ rsList.add(rs1);
+ rs.setSubResultSet(rsList);
+ Map<String, Object> map = new HashMap<String, Object>();
+ //map.put("test.filter",new Object());
+
+ boolean result = processor.satisfiesFilters(rs, map);
+ assertEquals(result, false);
+ }
+
+ @Test(expected = AAIException.class)
+ public void satisfiesFiltersTest2() throws AAIException {
+ ResultSet rs = new ResultSet();
+ Vertex v = new BaseVertexLabel(AAIProperties.NODE_TYPE);
+ rs.setVert(v);
+ List<ResultSet> rsList = new ArrayList<ResultSet>();
+ ResultSet rs1 = new ResultSet();
+ rsList.add(rs1);
+ rs.setSubResultSet(rsList);
+ Map<String, Object> map = new HashMap<String, Object>();
+ map.put("testfilter", new Object());
+
+ boolean result = processor.satisfiesFilters(rs, map);
+ assertEquals(result, false);
+ }
+
+ @Test
+ public void collapseForDoNotOutputTest() throws AAIException {
+ ResultSet rs = new ResultSet();
+ rs.setDoNotOutputFlag("true");
+ List<ResultSet> rsList = new ArrayList<ResultSet>();
+ ResultSet rs1 = new ResultSet();
+ rsList.add(rs1);
+ rs.setSubResultSet(rsList);
+ List<ResultSet> result = processor.collapseForDoNotOutput(rs);
+ assertEquals(result.size(), 1);
+ }
+
+ @Test(expected = NullPointerException.class)
+ public void collectInstanceDataTest() throws AAIException {
+
+ BaseVertexLabel bs = new BaseVertexLabel("test");
+ //bs.setId(80);
+ EmptyVertex ev = new EmptyVertex();
+ //ev.setId(50l);
+ Vertex thisLevelElemVtx = ev;
+
+
+ Multimap<String, String> thisMap = ArrayListMultimap.create();
+ List<String> vidsTraversed = new ArrayList<String>();
+ // only applies when collecting data using the default model for delete
+ Multimap<String, String> validNextStepMap = ArrayListMultimap.create();
+ Map<String, String> namedQueryElementHash = new HashMap<String, String>();
+ namedQueryElementHash.put("test", "test");
+ Map<String, String> delKeyHash = new HashMap<String, String>();
+
+ ResultSet rs = processor.collectInstanceData("test", "test", thisLevelElemVtx, "test", validNextStepMap, vidsTraversed, 1, delKeyHash, namedQueryElementHash, "test");
+ }
+
+ @Test(expected = NullPointerException.class)
+ public void genTopoMap4ModelVerTest() throws
+ AAIException {
+ Vertex vertext = new EmptyVertex();
+ Multimap<String, String> map = processor.genTopoMap4ModelVer("test", "test", vertext, "test");
+ assertNotEquals(map, null);
+ }
+
+ @Test(expected = AAIException.class)
+ public void genTopoMap4ModelVerTestNull() throws
+ AAIException {
+ Vertex vertext = null;
+ Multimap<String, String> map = processor.genTopoMap4ModelVer("test", "test", vertext, "test");
+ assertNotEquals(map, null);
+ }
+
+ @Test
+ public void makeSureItsAnArrayListTest() {
+ String input = "model-versionId,modelTestID,modelTestid2;";
+ List<String> result = processor.makeSureItsAnArrayList(input);
+ assertTrue(result.size() > 0);
+ }
+
+ @Test(expected = AAIException.class)
+ public void getModConstraintHashTest() throws AAIException {
+ Vertex modelElementVtx = new EmptyVertex();
+ //modelElementVtx.property(AAIProperties.NODE_TYPE,"Model");
+ Vertex modelElementVtx1 = new EmptyVertex();
+ Map<String, Vertex> currentHash = new HashMap<String, Vertex>();
+ currentHash.put("constraint", modelElementVtx1);
+ Map<String, Vertex> result = processor.getModConstraintHash(modelElementVtx, currentHash);
+ assertTrue(result.size() > 0);
+ }
+
+ @Test(expected = AAIException.class)
+ public void getModConstraintHashTestNull() throws AAIException {
+ Vertex modelElementVtx = null;
+ //modelElementVtx.property(AAIProperties.NODE_TYPE,"Model");
+ Vertex modelElementVtx1 = null;
+ Map<String, Vertex> currentHash = new HashMap<String, Vertex>();
+ currentHash.put("constraint", modelElementVtx1);
+ Map<String, Vertex> result = processor.getModConstraintHash(modelElementVtx, currentHash);
+ assertTrue(result.size() > 0);
+ }
+
+ @Test(expected = NullPointerException.class)
+ public void getTopElementForSvcOrResModelVerTest() throws AAIException {
+ Vertex modelElementVtx = new EmptyVertex();
+ //modelElementVtx.property(AAIProperties.NODE_TYPE,"Model");
+ Vertex modelElementVtx1 = new EmptyVertex();
+ Map<String, Vertex> currentHash = new HashMap<String, Vertex>();
+ currentHash.put("constraint", modelElementVtx1);
+ Vertex result = processor.getTopElementForSvcOrResModelVer(modelElementVtx, "test");
+ assertNotEquals(result, null);
+ }
+
+ @Test
+ public void getNamedQueryPropOverRideTest() throws AAIException {
+ String transId = "test";
+ String fromAppId = "test";
+ Vertex namedQueryElementVertex = new EmptyVertex();
+ Vertex instanceVertex = new EmptyVertex();
+ String apiVer = "test";
+
+ namedQueryElementVertex.properties("property-collect-list", "");
+
+ Map<String, Object> result = processor.getNamedQueryPropOverRide(transId, fromAppId, namedQueryElementVertex, instanceVertex, apiVer);
+ assertNotEquals(result, null);
+ }
+
+ @Test(expected = NullPointerException.class)
+ public void getNamedQueryPropOverRideTestNull() throws AAIException {
+ String transId = "test";
+ String fromAppId = "test";
+ Vertex namedQueryElementVertex = null;
+ Vertex instanceVertex = new EmptyVertex();
+ String apiVer = "test";
+
+ namedQueryElementVertex.properties("property-collect-list", "");
+
+ Map<String, Object> result = processor.getNamedQueryPropOverRide(transId, fromAppId, namedQueryElementVertex, instanceVertex, apiVer);
+ assertNotEquals(result, null);
+ }
+
+ @Test(expected = NullPointerException.class)
+ public void namedQueryConstraintSaysStopTest() throws AAIException {
+ String transId = "test";
+ String fromAppId = "test";
+ Vertex namedQueryElementVertex = new EmptyVertex();
+ Vertex instanceVertex = new EmptyVertex();
+ String apiVer = "test";
+
+ namedQueryElementVertex.properties("property-collect-list", "");
+
+ boolean result = processor.namedQueryConstraintSaysStop(transId, fromAppId, namedQueryElementVertex, instanceVertex, apiVer);
+ assertTrue(result);
+ }
+
+ @Test(expected = NullPointerException.class)
+ public void namedQueryConstraintSaysStopTestNull() throws AAIException {
+ String transId = "test";
+ String fromAppId = "test";
+ Vertex namedQueryElementVertex = null;
+ Vertex instanceVertex = new EmptyVertex();
+ String apiVer = "test";
+
+ namedQueryElementVertex.properties("property-collect-list", "");
+
+ boolean result = processor.namedQueryConstraintSaysStop(transId, fromAppId, namedQueryElementVertex, instanceVertex, apiVer);
+ assertTrue(result);
+ }
+
+ @Test(expected = AAIException.class)
+ public void namedQuerynamedQueryElementVertexNullTest() throws AAIException {
+ String transId = "test";
+ String fromAppId = "test";
+ Vertex namedQueryElementVertex = null;
+ Vertex instanceVertex = null;
+ String apiVer = "test";
+
+
+ boolean result = processor.namedQueryConstraintSaysStop(transId, fromAppId, namedQueryElementVertex, instanceVertex, apiVer);
+ assertTrue(result);
+ }
+
+ @Test(expected = NullPointerException.class)
+
+ public void getNamedQueryExtraDataLookupTest() throws Exception {
+
+ String transId = "test";
+ String fromAppId = "test";
+ Vertex namedQueryElementVertex = new EmptyVertex();
+ Vertex instanceVertex = new EmptyVertex();
+ String apiVer = "test";
+
+ namedQueryElementVertex.properties("property-collect-list", "");
+
+ Map<String, Object> result = processor.getNamedQueryExtraDataLookup(transId, fromAppId, namedQueryElementVertex, instanceVertex, apiVer);
+
+ assertTrue(result.size() > 0);
+ }
+
+ @Test(expected = NullPointerException.class)
+ public void collectNQElementHash() throws AAIException {
+ String transId = "test";
+ String fromAppId = "test";
+ Vertex thisLevelElemVtx = new EmptyVertex();
+ String incomingTrail = "test";
+ Map<String, String> currentHash = new HashMap<String, String>();
+ ArrayList<String> vidsTraversed = new ArrayList<String>();
+ int levelCounter = 1;
+
+ Map<String, String> result = processor.collectNQElementHash(transId, fromAppId,
+ thisLevelElemVtx, incomingTrail, currentHash,
+ vidsTraversed, levelCounter);
+
+ assertNotEquals(result, null);
+ }
+
+ @Test(expected = NullPointerException.class)
+ public void collectDeleteKeyHash() throws AAIException {
+ String transId = "test";
+ String fromAppId = "test";
+ Vertex thisLevelElemVtx = new EmptyVertex();
+ String incomingTrail = "test";
+ Map<String, String> currentHash = new HashMap<String, String>();
+ ArrayList<String> vidsTraversed = new ArrayList<String>();
+ int levelCounter = 1;
+ Map<String, Vertex> modConstraintHash = new HashMap<String, Vertex>();
+ String overRideModelId = "test";
+ String overRideModelVersionId = "test";
+
+ Map<String, String> result = processor.collectDeleteKeyHash(transId, fromAppId,
+ thisLevelElemVtx, incomingTrail, currentHash,
+ vidsTraversed, levelCounter, modConstraintHash, overRideModelId, overRideModelVersionId);
+
+ assertNotEquals(result, null);
+ }
+
+ @Test
+ public void getLinkageConnectNodeTypesTest() throws AAIException {
+ List<String> linkagePtList = new ArrayList<String>();
+ linkagePtList.add("modern\\|testdata\\|");
+ Set<String> result = processor.getLinkageConnectNodeTypes(linkagePtList);
+ assertNotEquals(result, null);
+
+ }
+
+ @Test(expected = AAIException.class)
+ public void getLinkageConnectNodeTypesTest1() throws AAIException {
+
+ Set<String> result1 = processor.getLinkageConnectNodeTypes(null);
+ assertNotEquals(result1, null);
+
+ List<String> linkagePtList = new ArrayList<String>();
+ linkagePtList.add("moderntestdata");
+ Set<String> result = processor.getLinkageConnectNodeTypes(linkagePtList);
+ assertNotEquals(result, null);
+ }
+
+ @Test(expected = NullPointerException.class)
+ public void collectTopology4ModelVerTest() throws AAIException {
+ String transId = "test";
+ String fromAppId = "test";
+ Multimap<String, String> thisMap = ArrayListMultimap.create();
+ Vertex thisLevelElemVtx = new EmptyVertex();
+ String incomingTrail = "test";
+ Map<String, Vertex> currentHash = new HashMap<String, Vertex>();
+ List<String> vidsTraversed = new ArrayList<String>();
+ int levelCounter = 1;
+
+ Multimap<String, String> result = processor.collectTopology4ModelVer(transId, fromAppId,
+ thisLevelElemVtx, incomingTrail, thisMap, vidsTraversed, levelCounter, currentHash
+ , "test", "test");
+
+ assertNotEquals(result, null);
+ }
+
+ @Test(expected = AAIException.class)
+ public void check4EdgeRuleTest() throws AAIException {
+ processor.check4EdgeRule("test", "test");
+ }
+
+ @Test(expected = AAIException.class)
+ public void collectTopology4LinkagePointTest() throws AAIException {
+ String transId = "test";
+ String fromAppId = "test";
+ String linkagePointStrVal = "test";
+ String incomingTrail = "test";
+ Multimap<String, String> currentMap = ArrayListMultimap.create();
+
+ Multimap<String, String> result = processor.collectTopology4LinkagePoint(transId, fromAppId, linkagePointStrVal, incomingTrail, currentMap);
+ assertNotEquals(result, null);
+
+ }
+
+ @Test(expected = AAIException.class)
+ public void getNextStepElementsFromSet() throws AAIException {
+ Vertex constrElemSetVtx = new EmptyVertex();
+ constrElemSetVtx.<String>property(AAIProperties.NODE_TYPE);
+ Map<String, Object> result = processor.getNextStepElementsFromSet(constrElemSetVtx);
+ assertNotEquals(result, null);
+ }
+
+ @Test(expected = NullPointerException.class)
+ public void genTopoMap4NamedQTest() throws AAIException {
+ String transId = "test";
+ String fromAppId = "test";
+ Vertex queryVertex = new EmptyVertex();
+ String namedQueryUuid = "E44533334343";
+ Multimap<String, String> result = processor.genTopoMap4NamedQ(transId, fromAppId, queryVertex, namedQueryUuid);
+ assertNotEquals(result, null);
+ }
+
+ @Test(expected = NullPointerException.class)
+ public void collectTopology4NamedQTest() throws AAIException {
+ String transId = "test";
+ String fromAppId = "test";
+ Multimap<String, String> thisMap = ArrayListMultimap.create();
+ Vertex thisLevelElemVtx = new EmptyVertex();
+ String incomingTrail = "test";
+ Map<String, Vertex> currentHash = new HashMap<String, Vertex>();
+ List<String> vidsTraversed = new ArrayList<String>();
+ int levelCounter = 1;
+
+ Multimap<String, String> result = processor.collectTopology4NamedQ(transId, fromAppId,
+ thisLevelElemVtx, incomingTrail, thisMap, vidsTraversed, levelCounter);
+ assertNotEquals(result, null);
+ }
+
+ @Test(expected = NullPointerException.class)
+ public void getModelThatNqElementRepresentsTest() throws AAIException {
+ Vertex thisLevelElemVtx = new EmptyVertex();
+ String incomingTrail = "test";
+ Vertex vertex = processor.getModelThatNqElementRepresents(thisLevelElemVtx, incomingTrail);
+ assertNotEquals(vertex, null);
+ }
+
+ @Test(expected = NullPointerException.class)
+ public void getModelGivenModelVer() throws AAIException {
+ Vertex thisLevelElemVtx = new EmptyVertex();
+ String incomingTrail = "test";
+ Vertex vertex = processor.getModelGivenModelVer(thisLevelElemVtx, incomingTrail);
+ assertNotEquals(vertex, null);
+ }
+
+ @Test(expected = AAIException.class)
+ public void getModelTypeFromModel() throws AAIException {
+ Vertex thisLevelElemVtx = new EmptyVertex();
+ String incomingTrail = "test";
+ String vertex = processor.getModelTypeFromModel(thisLevelElemVtx, incomingTrail);
+ assertNotEquals(vertex, null);
+ }
+
+ @Test(expected = NullPointerException.class)
+ public void getModelTypeFromModelVer() throws AAIException {
+ Vertex thisLevelElemVtx = new EmptyVertex();
+ String incomingTrail = "test";
+ String vertex = processor.getModelTypeFromModelVer(thisLevelElemVtx, incomingTrail);
+ assertNotEquals(vertex, null);
+ }
+
+ @Test(expected = NullPointerException.class)
+ public void getModelElementStepName() throws AAIException {
+ Vertex thisLevelElemVtx = new EmptyVertex();
+ String incomingTrail = "test";
+ String vertex = processor.getModelElementStepName(thisLevelElemVtx, incomingTrail);
+ assertNotEquals(vertex, null);
+ }
+
+ @Test(expected = AAIException.class)
+ public void nodeTypeSupportsPersona() throws AAIException {
+ String incomingTrail = "";
+ boolean vertex = processor.nodeTypeSupportsPersona(incomingTrail);
+ assertFalse(vertex);
+
+
+ incomingTrail = "test";
+ boolean vertex1 = processor.nodeTypeSupportsPersona(incomingTrail);
+ assertTrue(vertex1);
+ }
+
+ @Test(expected = NullPointerException.class)
+ public void getNqElementWidgetType() throws AAIException {
+ String appId = "test";
+ String transID = "test";
+ Vertex thisLevelElemVtx = new EmptyVertex();
+ String incomingTrail = "test";
+ String vertex1 = processor.getNqElementWidgetType(appId, transID, thisLevelElemVtx, incomingTrail);
+ assertNotEquals(vertex1, null);
+ }
+
+
+ @Test(expected = NullPointerException.class)
+ public void getModElementWidgetType() throws AAIException {
+ String appId = "test";
+ String transID = "test";
+ Vertex thisLevelElemVtx = new EmptyVertex();
+ String incomingTrail = "test";
+ String vertex1 = processor.getModElementWidgetType(thisLevelElemVtx, incomingTrail);
+ assertNotEquals(vertex1, null);
+ }
+
+ @Test(expected = NullPointerException.class)
+ public void getNodeUsingUniqueId() throws AAIException {
+ String appId = "test";
+ String transID = "test";
+ String nodeType = "generic-vnf";
+ String idPropertyName = "test";
+ String uniqueIdVal = "test";
+ Vertex vertex1 = processor.getNodeUsingUniqueId(transID, appId, nodeType, idPropertyName, uniqueIdVal);
+ assertNotEquals(vertex1, null);
+ }
+
+
+ @Test(expected = AAIException.class)
+ public void getNodeUsingUniqueIdNull() throws AAIException {
+ String appId = "test";
+ String transID = "test";
+ String nodeType = "generic-vnf";
+ String idPropertyName = "test";
+ String uniqueIdVal = "";
+ Vertex vertex1 = null;
+ vertex1 = processor.getNodeUsingUniqueId(transID, appId, nodeType, idPropertyName, uniqueIdVal);
+ assertNotEquals(vertex1, null);
+
+ }
+
+
+ @Test(expected = AAIException.class)
+ public void getNodeUsingUniqueIdNull1() throws AAIException {
+ String appId = "test";
+ String transID = "test";
+ String nodeType = "generic-vnf";
+ String idPropertyName = "";
+ String uniqueIdVal = "test";
+ Vertex vertex1 = null;
+ vertex1 = processor.getNodeUsingUniqueId(transID, appId, nodeType, idPropertyName, uniqueIdVal);
+ assertNotEquals(vertex1, null);
+
+
+ }
+
+
+ @Test(expected = AAIException.class)
+ public void getNodeUsingUniqueIdNull2() throws AAIException {
+ String appId = "test";
+ String transID = "test";
+ String nodeType = "";
+ String idPropertyName = "test";
+ String uniqueIdVal = "test";
+ Vertex vertex1 = null;
+ vertex1 = processor.getNodeUsingUniqueId(transID, appId, nodeType, idPropertyName, uniqueIdVal);
+ assertNotEquals(vertex1, null);
+
+
+ }
+
+ @Test(expected = NullPointerException.class)
+ public void getModelVersUsingName() throws AAIException {
+ String appId = "test";
+ String transID = "test";
+ String modelName = "test";
+
+ List<Vertex> result = processor.getModelVersUsingName(transID, appId, modelName);
+ assertNotEquals(result, null);
+ }
+
+
+ @Test(expected = AAIException.class)
+ public void getModelVersUsingNameNull() throws AAIException {
+ String appId = "test";
+ String transID = "test";
+ String modelName = "";
+
+ List<Vertex> result = processor.getModelVersUsingName(transID, appId, modelName);
+ assertNotEquals(result, null);
+ }
+
+
+ @Test(expected = NullPointerException.class)
+ public void getModVersUsingModelInvId() throws AAIException {
+ String appId = "test";
+ String transID = "test";
+ String modelName = "test";
+
+ Iterator<Vertex> result = processor.getModVersUsingModelInvId(transID, appId, modelName);
+ assertNotEquals(result, null);
+ }
+
+ @Test(expected = AAIException.class)
+ public void getModVersUsingModelInvIdNull() throws AAIException {
+ String appId = "test";
+ String transID = "test";
+ String modelName = "";
+
+ Iterator<Vertex> result = processor.getModVersUsingModelInvId(transID, appId, modelName);
+ assertNotEquals(result, null);
+ }
+
+ @Test(expected = NullPointerException.class)
+ public void getModVersUsingModel() throws AAIException {
+ String appId = "test";
+ String transID = "test";
+ String modelName = "test";
+ Vertex thisLevelElemVtx = new EmptyVertex();
+ List<Vertex> result = processor.getModVersUsingModel(transID, appId, thisLevelElemVtx);
+ assertNotEquals(result, null);
+ }
+
+ @Test(expected = AAIException.class)
+ public void getModVersUsingModel1() throws AAIException {
+ String appId = "test";
+ String transID = "test";
+
+ Vertex thisLevelElemVtx = null;
+ List<Vertex> result = processor.getModVersUsingModel(transID, appId, thisLevelElemVtx);
+ assertNotEquals(result, null);
+ }
+
+ @Test(expected = NullPointerException.class)
+ public void getModelVerIdsUsingName() throws AAIException {
+ String appId = "test";
+ String transID = "test";
+
+ String modelName = "test";
+ List<String> result = processor.getModelVerIdsUsingName(transID, appId, modelName);
+ assertNotEquals(result, null);
+ }
+
+ @Test(expected = AAIException.class)
+ public void getModelVerIdsUsingName1() throws AAIException {
+ String appId = "test";
+ String transID = "test";
+
+ String modelName = "";
+ List<String> result = processor.getModelVerIdsUsingName(transID, appId, modelName);
+ assertNotEquals(result, null);
+ }
+
+ @Test(expected = NullPointerException.class)
+ public void validateModel() throws AAIException {
+ String appId = "test";
+ String transID = "test";
+
+ String modelVersionId = "test";
+ String modelInvId = "test";
+ String modelName = "test";
+ processor.validateModel(transID, appId, modelName, modelVersionId);
+
+
+ }
+
}
diff --git a/aai-traversal/src/test/java/org/onap/aai/dbgraphgen/ModelBasedProcessingTest.java b/aai-traversal/src/test/java/org/onap/aai/dbgraphgen/ModelBasedProcessingTest.java
index afb9b17..1f05785 100644
--- a/aai-traversal/src/test/java/org/onap/aai/dbgraphgen/ModelBasedProcessingTest.java
+++ b/aai-traversal/src/test/java/org/onap/aai/dbgraphgen/ModelBasedProcessingTest.java
@@ -2,7 +2,7 @@
* ============LICENSE_START=======================================================
* org.onap.aai
* ================================================================================
- * Copyright © 2017 AT&T Intellectual Property. All rights reserved.
+ * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -16,13 +16,14 @@
* See the License for the specific language governing permissions and
* limitations under the License.
* ============LICENSE_END=========================================================
- *
- * ECOMP is a trademark and service mark of AT&T Intellectual Property.
*/
package org.onap.aai.dbgraphgen;
-import com.google.common.collect.ArrayListMultimap;
-import com.google.common.collect.Multimap;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource;
import org.apache.tinkerpop.gremlin.structure.Graph;
import org.apache.tinkerpop.gremlin.structure.T;
@@ -33,28 +34,25 @@ import org.junit.BeforeClass;
import org.junit.Test;
import org.mockito.Mockito;
import org.mockito.MockitoAnnotations;
+import org.onap.aai.AAISetup;
import org.onap.aai.db.props.AAIProperties;
import org.onap.aai.dbmap.DBConnectionType;
import org.onap.aai.exceptions.AAIException;
import org.onap.aai.introspection.Loader;
-import org.onap.aai.introspection.LoaderFactory;
import org.onap.aai.introspection.ModelType;
-import org.onap.aai.introspection.Version;
import org.onap.aai.parsers.exceptions.AAIIdentityMapParseException;
import org.onap.aai.serialization.db.DBSerializer;
-import org.onap.aai.serialization.db.EdgeRules;
-import org.onap.aai.serialization.engines.JanusGraphDBEngine;
import org.onap.aai.serialization.engines.QueryStyle;
+import org.onap.aai.serialization.engines.JanusGraphDBEngine;
import org.onap.aai.serialization.engines.TransactionalGraphEngine;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
+import com.google.common.collect.ArrayListMultimap;
+import com.google.common.collect.Multimap;
+import org.onap.aai.setup.SchemaVersion;
-public class ModelBasedProcessingTest {
+public class ModelBasedProcessingTest extends AAISetup{
- private static final Version version = Version.getLatest();
+ private SchemaVersion version;
private static final ModelType introspectorFactoryType = ModelType.MOXY;
private static final QueryStyle queryStyle = QueryStyle.TRAVERSAL;
private static final DBConnectionType type = DBConnectionType.REALTIME;
@@ -81,7 +79,6 @@ public class ModelBasedProcessingTest {
private static TransactionalGraphEngine.Admin admin;
DBSerializer serializer;
private static Loader loader;
- EdgeRules rules;
ModelBasedProcessing modelBasedProcessor;
@@ -106,8 +103,9 @@ public class ModelBasedProcessingTest {
@Before
public void init() throws AAIException {
MockitoAnnotations.initMocks(this);
- rules = EdgeRules.getInstance();
- loader = LoaderFactory.createLoaderForVersion(introspectorFactoryType, AAIProperties.LATEST);
+ version = schemaVersions.getDefaultVersion();
+ //rules = EdgeRules.getInstance();
+ loader = loaderFactory.createLoaderForVersion(introspectorFactoryType, version);
TransactionalGraphEngine newDbEngine = new JanusGraphDBEngine(queryStyle, type, loader);
dbEngine = Mockito.spy(newDbEngine);
serializer = new DBSerializer(version, dbEngine, introspectorFactoryType, "JUNIT");
@@ -135,17 +133,17 @@ public class ModelBasedProcessingTest {
"new-data-del-flag", "F");
GraphTraversalSource g = graph.traversal();
- rules.addTreeEdge(g, model, modelVersion);
- rules.addTreeEdge(g, modelElement, modelConstraint);
- rules.addTreeEdge(g, constrainedElementSet, modelConstraint);
- rules.addTreeEdge(g, modelVersion, modelElement);
- rules.addTreeEdge(g, modelElement, constrainedElementSet);
- rules.addTreeEdge(g, constrainedElementSet, elementChoiceSet);
- rules.addTreeEdge(g, modelElement, elementChoiceSet);
- rules.addTreeEdge(g, namedQuery, namedQueryElement);
- rules.addTreeEdge(g, namedQueryElement, namedQueryElement);
- rules.addEdge(g, modelVersion, modelElement);
- rules.addEdge(g, model, namedQueryElement);
+ edgeSer.addTreeEdge(g, model, modelVersion);
+ edgeSer.addTreeEdge(g, modelElement, modelConstraint);
+ edgeSer.addTreeEdge(g, constrainedElementSet, modelConstraint);
+ edgeSer.addTreeEdge(g, modelVersion, modelElement);
+ edgeSer.addTreeEdge(g, modelElement, constrainedElementSet);
+ edgeSer.addTreeEdge(g, constrainedElementSet, elementChoiceSet);
+ edgeSer.addTreeEdge(g, modelElement, elementChoiceSet);
+ edgeSer.addTreeEdge(g, namedQuery, namedQueryElement);
+ edgeSer.addTreeEdge(g, namedQueryElement, namedQueryElement);
+ edgeSer.addEdge(g, modelVersion, modelElement);
+ edgeSer.addEdge(g, model, namedQueryElement);
return g;
}
@@ -438,10 +436,10 @@ public class ModelBasedProcessingTest {
Vertex modelElementV = graph.addVertex(T.label, "model-element", T.id, "22", AAI_NODE_TYPE, "model-element");
GraphTraversalSource gts = serviceGraph.traversal();
- EdgeRules rules4Service = EdgeRules.getInstance();
- rules4Service.addTreeEdge(gts, modelV, modelVerV);
- rules4Service.addTreeEdge(gts, modelElementV, modelVerV);
- rules4Service.addEdge(gts, modelElementV, modelVerV);
+ //EdgeRules rules4Service = EdgeRules.getInstance();
+ edgeSer.addTreeEdge(gts, modelV, modelVerV);
+ edgeSer.addTreeEdge(gts, modelElementV, modelVerV);
+ edgeSer.addEdge(gts, modelElementV, modelVerV);
Mockito.when(dbEngine.asAdmin()).thenReturn(admin);
Mockito.when(admin.getReadOnlyTraversalSource()).thenReturn(gts);
modelBasedProcessor.genTopoMap4ModelVer(TRANSACTION_ID, FROM_APP_ID, modelVerV, MODEL_VERSION_ID_VALUE);
@@ -517,8 +515,7 @@ public class ModelBasedProcessingTest {
Vertex instanceVertexV = graph.addVertex(T.label, "instance-vertex", T.id, "32", AAI_NODE_TYPE, "instance-vertex", "property-name", "property-name");
GraphTraversalSource gts = serviceGraph.traversal();
- EdgeRules rules4Service = EdgeRules.getInstance();
- rules4Service.addTreeEdge(gts, namedQueryElementV, propertyContraintV);
+ edgeSer.addTreeEdge(gts, namedQueryElementV, propertyContraintV);
Mockito.when(dbEngine.asAdmin()).thenReturn(admin);
Mockito.when(admin.getReadOnlyTraversalSource()).thenReturn(gts);
@@ -536,8 +533,8 @@ public class ModelBasedProcessingTest {
Vertex instanceVertexV = graph.addVertex(T.label, "instance-vertex", T.id, "35", AAI_NODE_TYPE, "instance-vertex", "property-name", "property-name");
GraphTraversalSource gts = serviceGraph.traversal();
- EdgeRules rules4Service = EdgeRules.getInstance();
- rules4Service.addTreeEdge(gts, namedQueryElementV, propertyContraintV);
+ //EdgeRules rules4Service = EdgeRules.getInstance();
+ edgeSer.addTreeEdge(gts, namedQueryElementV, propertyContraintV);
Mockito.when(dbEngine.asAdmin()).thenReturn(admin);
Mockito.when(admin.getReadOnlyTraversalSource()).thenReturn(gts);
@@ -556,8 +553,7 @@ public class ModelBasedProcessingTest {
Vertex instanceVertexV = graph.addVertex(T.label, "instance-vertex", T.id, "38", AAI_NODE_TYPE, "instance-vertex", "property-name", "property-name");
GraphTraversalSource gts = serviceGraph.traversal();
- EdgeRules rules4Service = EdgeRules.getInstance();
- rules4Service.addTreeEdge(gts, namedQueryElementV, propertyContraintV);
+ edgeSer.addTreeEdge(gts, namedQueryElementV, propertyContraintV);
Mockito.when(dbEngine.asAdmin()).thenReturn(admin);
Mockito.when(admin.getReadOnlyTraversalSource()).thenReturn(gts);
@@ -576,8 +572,7 @@ public class ModelBasedProcessingTest {
Vertex instanceVertexV = graph.addVertex(T.label, "instance-vertex", T.id, "41", AAI_NODE_TYPE, "instance-vertex", "property-name", "property-name");
GraphTraversalSource gts = serviceGraph.traversal();
- EdgeRules rules4Service = EdgeRules.getInstance();
- rules4Service.addTreeEdge(gts, namedQueryElementV, propertyContraintV);
+ edgeSer.addTreeEdge(gts, namedQueryElementV, propertyContraintV);
Mockito.when(dbEngine.asAdmin()).thenReturn(admin);
Mockito.when(admin.getReadOnlyTraversalSource()).thenReturn(gts);
@@ -596,8 +591,7 @@ public class ModelBasedProcessingTest {
Vertex instanceVertexV = graph.addVertex(T.label, "instance-vertex", T.id, "44", AAI_NODE_TYPE, "instance-vertex", "property-name", "property-name");
GraphTraversalSource gts = serviceGraph.traversal();
- EdgeRules rules4Service = EdgeRules.getInstance();
- rules4Service.addTreeEdge(gts, namedQueryElementV, propertyContraintV);
+ edgeSer.addTreeEdge(gts, namedQueryElementV, propertyContraintV);
Mockito.when(dbEngine.asAdmin()).thenReturn(admin);
Mockito.when(admin.getReadOnlyTraversalSource()).thenReturn(gts);
@@ -615,8 +609,7 @@ public class ModelBasedProcessingTest {
"source-node-property", "source-node-property", "source-node-type", "generic-vnf");
Vertex instanceVertexV = graph.addVertex(T.label, "instance-vertex", T.id, "47", AAI_NODE_TYPE, "instance-vertex", "property-name", "property-name");
GraphTraversalSource gts = serviceGraph.traversal();
- EdgeRules rules4Service = EdgeRules.getInstance();
- rules4Service.addTreeEdge(gts, namedQueryElementV, relatedLookUpV);
+ edgeSer.addTreeEdge(gts, namedQueryElementV, relatedLookUpV);
Mockito.when(dbEngine.asAdmin()).thenReturn(admin);
Mockito.when(admin.getReadOnlyTraversalSource()).thenReturn(gts);
@@ -635,8 +628,7 @@ public class ModelBasedProcessingTest {
"target-node-property", "generic-vnf", "property-collect-list", "property-collect-list");
Vertex instanceVertexV = graph.addVertex(T.label, "instance-vertex", T.id, "53", AAI_NODE_TYPE, "instance-vertex", "property-name", "property-name");
GraphTraversalSource gts = serviceGraph.traversal();
- EdgeRules rules4Service = EdgeRules.getInstance();
- rules4Service.addTreeEdge(gts, namedQueryElementV, relatedLookUpV);
+ edgeSer.addTreeEdge(gts, namedQueryElementV, relatedLookUpV);
Mockito.when(dbEngine.asAdmin()).thenReturn(admin);
Mockito.when(admin.getReadOnlyTraversalSource()).thenReturn(gts);
@@ -654,8 +646,7 @@ public class ModelBasedProcessingTest {
"source-node-property", "source-node-property", "source-node-type", "generic-vnf", "target-node-type", "generic-vnf", "target-node-property", "generic-vnf");
Vertex instanceVertexV = graph.addVertex(T.label, "instance-vertex", T.id, "56", AAI_NODE_TYPE, "instance-vertex", "source-node-property", "source-node-property");
GraphTraversalSource gts = serviceGraph.traversal();
- EdgeRules rules4Service = EdgeRules.getInstance();
- rules4Service.addTreeEdge(gts, namedQueryElementV, relatedLookUpV);
+ edgeSer.addTreeEdge(gts, namedQueryElementV, relatedLookUpV);
Mockito.when(dbEngine.asAdmin()).thenReturn(admin);
Mockito.when(admin.getReadOnlyTraversalSource()).thenReturn(gts);
@@ -737,10 +728,9 @@ public class ModelBasedProcessingTest {
Vertex modelElementV = graph.addVertex(T.label, "model-element", T.id, "59", AAI_NODE_TYPE, "model-element");
GraphTraversalSource gts = serviceGraph.traversal();
- EdgeRules rules4Service = EdgeRules.getInstance();
- rules4Service.addTreeEdge(gts, modelV, modelVerV);
- rules4Service.addTreeEdge(gts, modelElementV, modelVerV);
- rules4Service.addEdge(gts, modelElementV, modelVerV);
+ edgeSer.addTreeEdge(gts, modelV, modelVerV);
+ edgeSer.addTreeEdge(gts, modelElementV, modelVerV);
+ edgeSer.addEdge(gts, modelElementV, modelVerV);
Mockito.when(dbEngine.asAdmin()).thenReturn(admin);
Mockito.when(admin.getReadOnlyTraversalSource()).thenReturn(gts);
modelBasedProcessor.getModelVerTopWidgetType(modelVerV, "");
@@ -755,10 +745,9 @@ public class ModelBasedProcessingTest {
Vertex modelElementV = graph.addVertex(T.label, "model-element", T.id, "62", AAI_NODE_TYPE, "model-element");
GraphTraversalSource gts = serviceGraph.traversal();
- EdgeRules rules4Service = EdgeRules.getInstance();
- rules4Service.addTreeEdge(gts, modelV, modelVerV);
- rules4Service.addTreeEdge(gts, modelElementV, modelVerV);
- rules4Service.addEdge(gts, modelElementV, modelVerV);
+ edgeSer.addTreeEdge(gts, modelV, modelVerV);
+ edgeSer.addTreeEdge(gts, modelElementV, modelVerV);
+ edgeSer.addEdge(gts, modelElementV, modelVerV);
Mockito.when(dbEngine.asAdmin()).thenReturn(admin);
Mockito.when(admin.getReadOnlyTraversalSource()).thenReturn(gts);
modelBasedProcessor.getModelElementStepName(modelElementV, "");
@@ -801,10 +790,9 @@ public class ModelBasedProcessingTest {
Vertex modelElementV = graph.addVertex(T.label, "model-element", T.id, "65", AAI_NODE_TYPE, "model-element");
GraphTraversalSource gts = serviceGraph.traversal();
- EdgeRules rules4Service = EdgeRules.getInstance();
- rules4Service.addTreeEdge(gts, modelV, modelVerV);
- rules4Service.addTreeEdge(gts, modelElementV, modelVerV);
- rules4Service.addEdge(gts, modelElementV, modelVerV);
+ edgeSer.addTreeEdge(gts, modelV, modelVerV);
+ edgeSer.addTreeEdge(gts, modelElementV, modelVerV);
+ edgeSer.addEdge(gts, modelElementV, modelVerV);
Mockito.when(dbEngine.asAdmin()).thenReturn(admin);
Mockito.when(admin.getReadOnlyTraversalSource()).thenReturn(gts);
@@ -891,8 +879,7 @@ public class ModelBasedProcessingTest {
//Vertex modelElementV = graph.addVertex(T.label, "model-element", T.id, "68", AAI_NODE_TYPE, "model-element");
GraphTraversalSource gts = serviceGraph.traversal();
- EdgeRules rules4Service = EdgeRules.getInstance();
- rules4Service.addTreeEdge(gts, modelV, modelVerV);
+ edgeSer.addTreeEdge(gts, modelV, modelVerV);
//rules4Service.addTreeEdge(gts, modelElementV, modelVerV);
//rules4Service.addEdge(gts, modelElementV, modelVerV);
Mockito.when(dbEngine.asAdmin()).thenReturn(admin);
diff --git a/aai-traversal/src/test/java/org/onap/aai/dbgraphmap/SearchGraphEdgeRuleTest.java b/aai-traversal/src/test/java/org/onap/aai/dbgraphmap/SearchGraphEdgeRuleTest.java
index 92f4960..9d3a615 100644
--- a/aai-traversal/src/test/java/org/onap/aai/dbgraphmap/SearchGraphEdgeRuleTest.java
+++ b/aai-traversal/src/test/java/org/onap/aai/dbgraphmap/SearchGraphEdgeRuleTest.java
@@ -25,17 +25,20 @@ import org.junit.Ignore;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;
-
+import org.onap.aai.edges.exceptions.EdgeRuleNotFoundException;
import org.onap.aai.exceptions.AAIException;
+import org.springframework.beans.factory.annotation.Autowired;
@Ignore
public class SearchGraphEdgeRuleTest {
@Rule
public ExpectedException expectedEx = ExpectedException.none();
+ @Autowired
+ SearchGraph searchGraph;
@Test
- public void getEdgeLabelTest() throws AAIException {
- String[] label = SearchGraph.getEdgeLabel("customer", "service-subscription");
+ public void getEdgeLabelTest() throws AAIException, EdgeRuleNotFoundException {
+ String[] label = searchGraph.getEdgeLabel("customer", "service-subscription");
assertEquals("subscribesTo", label[0]);
}
@@ -46,7 +49,7 @@ public class SearchGraphEdgeRuleTest {
String nodeTypeB = "service";
expectedEx.expect(AAIException.class);
expectedEx.expectMessage("No EdgeRule found for passed nodeTypes: complex, service.");
- SearchGraph.getEdgeLabel(nodeTypeA, nodeTypeB);
+ searchGraph.getEdgeLabel(nodeTypeA, nodeTypeB);
}
@Test
@@ -55,6 +58,6 @@ public class SearchGraphEdgeRuleTest {
String nodeTypeB = "B";
expectedEx.expect(AAIException.class);
expectedEx.expectMessage("No EdgeRule found for passed nodeTypes: A, B.");
- SearchGraph.getEdgeLabel(nodeTypeA, nodeTypeB);
+ searchGraph.getEdgeLabel(nodeTypeA, nodeTypeB);
}
}
diff --git a/aai-traversal/src/test/java/org/onap/aai/dbgraphmap/SearchGraphNamedQueryTest.java b/aai-traversal/src/test/java/org/onap/aai/dbgraphmap/SearchGraphNamedQueryTest.java
index ea0fdaa..243fc6e 100644
--- a/aai-traversal/src/test/java/org/onap/aai/dbgraphmap/SearchGraphNamedQueryTest.java
+++ b/aai-traversal/src/test/java/org/onap/aai/dbgraphmap/SearchGraphNamedQueryTest.java
@@ -22,7 +22,6 @@ package org.onap.aai.dbgraphmap;
import com.google.gson.JsonObject;
import com.google.gson.JsonParser;
-import org.apache.commons.io.IOUtils;
import org.junit.Before;
import org.junit.Test;
import org.mockito.Mockito;
@@ -33,7 +32,7 @@ import org.onap.aai.exceptions.AAIException;
import org.onap.aai.extensions.AAIExtensionMap;
import org.onap.aai.introspection.*;
import org.onap.aai.serialization.engines.QueryStyle;
-import org.onap.aai.util.AAIApiVersion;
+import org.onap.aai.setup.SchemaVersion;
import org.onap.aai.util.AAIConstants;
import javax.servlet.http.HttpServletRequest;
@@ -41,31 +40,23 @@ import javax.ws.rs.core.*;
import java.io.File;
import java.io.IOException;
-import java.io.InputStream;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.*;
import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
import static org.mockito.Matchers.anyObject;
import static org.mockito.Mockito.*;
+import org.onap.aai.AAISetup;
-public class SearchGraphNamedQueryTest {
-
- private SearchGraph searchGraph;
+public class SearchGraphNamedQueryTest extends AAISetup{
protected static final MediaType APPLICATION_JSON = MediaType.valueOf("application/json");
private static final Set<Integer> VALID_HTTP_STATUS_CODES = new HashSet<>();
- private final static Version version = Version.getLatest();
- private final static ModelType introspectorFactoryType = ModelType.MOXY;
- private final static QueryStyle queryStyle = QueryStyle.TRAVERSAL;
- private final static DBConnectionType type = DBConnectionType.REALTIME;
-
static {
VALID_HTTP_STATUS_CODES.add(200);
VALID_HTTP_STATUS_CODES.add(201);
@@ -141,7 +132,7 @@ public class SearchGraphNamedQueryTest {
}
private String addVersionToUri(String uri ) {
- return "/aai/" + Version.getLatest() + "/" + uri;
+ return "/aai/" + schemaVersions.getDefaultVersion() + "/" + uri;
}
@Before
@@ -149,12 +140,7 @@ public class SearchGraphNamedQueryTest {
httpTestUtil = new HttpTestUtil();
- System.setProperty("AJSC_HOME", ".");
- System.setProperty("BUNDLECONFIG_DIR", "src/main/resources");
-
- searchGraph = new SearchGraph();
-
httpHeaders = mock(HttpHeaders.class);
headersMultiMap = new MultivaluedHashMap<>();
@@ -211,10 +197,10 @@ public class SearchGraphNamedQueryTest {
Mockito.when(request.getContentType()).thenReturn("application/json");
aaiExtMap.setUri("/search/named-query");
- aaiExtMap.setApiVersion(AAIApiVersion.get());
+ aaiExtMap.setApiVersion(schemaVersions.getDefaultVersion().toString());
aaiExtMap.setServletRequest(request);
- SearchGraph searchGraph = new SearchGraph();
+
response = searchGraph.runNamedQuery("JUNIT", "JUNIT", queryParameters, DBConnectionType.REALTIME, aaiExtMap);
System.out.println("response was\n" + response.getEntity().toString());
assertEquals("Expected success from query", 200, response.getStatus());
@@ -245,10 +231,10 @@ public class SearchGraphNamedQueryTest {
Mockito.when(request.getContentType()).thenReturn("application/json");
aaiExtMap.setUri("/search/named-query");
- aaiExtMap.setApiVersion(AAIApiVersion.get());
+ aaiExtMap.setApiVersion(schemaVersions.getDefaultVersion().toString());
aaiExtMap.setServletRequest(request);
- SearchGraph searchGraph = new SearchGraph();
+
response = searchGraph.runNamedQuery("JUNIT", "JUNIT", queryParameters, DBConnectionType.REALTIME, aaiExtMap);
assertEquals("Expected success from query", 200, response.getStatus());
boolean hasModelName = response.getEntity().toString().indexOf("junit-model-name") > 0 ? true : false;
@@ -326,10 +312,10 @@ public class SearchGraphNamedQueryTest {
Mockito.when(request.getContentType()).thenReturn("application/json");
aaiExtMap.setUri("/search/named-query");
- aaiExtMap.setApiVersion(AAIApiVersion.get());
+ aaiExtMap.setApiVersion(schemaVersions.getDefaultVersion().toString());
aaiExtMap.setServletRequest(request);
- SearchGraph searchGraph = new SearchGraph();
+
response = searchGraph.runNamedQuery("JUNIT", "JUNIT", queryParameters, DBConnectionType.REALTIME, aaiExtMap);
assertEquals("Expected success from query", 200, response.getStatus());
boolean hasModelName = response.getEntity().toString().indexOf("example-model-name-val-closed-loop") > 0 ? true : false;
@@ -392,10 +378,10 @@ public class SearchGraphNamedQueryTest {
Mockito.when(request.getContentType()).thenReturn("application/json");
aaiExtMap.setUri("/search/named-query");
- aaiExtMap.setApiVersion(AAIApiVersion.get());
+ aaiExtMap.setApiVersion(schemaVersions.getDefaultVersion().toString());
aaiExtMap.setServletRequest(request);
- SearchGraph searchGraph = new SearchGraph();
+
response = searchGraph.runNamedQuery("JUNIT", "JUNIT", queryParameters, DBConnectionType.REALTIME, aaiExtMap);
assertEquals("Expected success from query", 200, response.getStatus());
boolean hasModelName = response.getEntity().toString().indexOf("example-model-name-val-component-list") > 0 ? true : false;
diff --git a/aai-traversal/src/test/java/org/onap/aai/dbgraphmap/SearchGraphTest.java b/aai-traversal/src/test/java/org/onap/aai/dbgraphmap/SearchGraphTest.java
index 87ebb8f..a048ffc 100644
--- a/aai-traversal/src/test/java/org/onap/aai/dbgraphmap/SearchGraphTest.java
+++ b/aai-traversal/src/test/java/org/onap/aai/dbgraphmap/SearchGraphTest.java
@@ -24,15 +24,12 @@ import org.janusgraph.graphdb.types.system.EmptyVertex;
import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource;
import org.apache.tinkerpop.gremlin.structure.Graph;
import org.apache.tinkerpop.gremlin.structure.Vertex;
-import org.apache.tinkerpop.gremlin.structure.VertexProperty;
import org.eclipse.persistence.dynamic.DynamicEntity;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
-import org.mockito.InjectMocks;
-import org.mockito.Mock;
import org.mockito.Mockito;
-import org.onap.aai.dbgraphgen.ModelBasedProcessing;
+import org.onap.aai.AAISetup;
import org.onap.aai.dbmap.DBConnectionType;
import org.onap.aai.exceptions.AAIException;
import org.onap.aai.extensions.AAIExtensionMap;
@@ -43,27 +40,27 @@ import org.onap.aai.serialization.engines.QueryStyle;
import org.onap.aai.serialization.engines.JanusGraphDBEngine;
import org.onap.aai.serialization.engines.TransactionalGraphEngine;
import org.onap.aai.serialization.queryformats.utils.UrlBuilder;
+import org.onap.aai.setup.SchemaVersion;
import javax.servlet.http.HttpServletRequest;
import javax.ws.rs.core.*;
import java.net.URI;
-import java.sql.ResultSet;
import java.util.*;
import java.util.stream.Stream;
import static org.mockito.Matchers.anyObject;
import static org.mockito.Mockito.*;
-public class SearchGraphTest {
+public class SearchGraphTest extends AAISetup{
- private SearchGraph searchGraph;
+
protected static final MediaType APPLICATION_JSON = MediaType.valueOf("application/json");
private static final Set<Integer> VALID_HTTP_STATUS_CODES = new HashSet<>();
- private final static Version version = Version.getLatest();
+ private SchemaVersion version;
private final static ModelType introspectorFactoryType = ModelType.MOXY;
private final static QueryStyle queryStyle = QueryStyle.TRAVERSAL;
private final static DBConnectionType type = DBConnectionType.REALTIME;
@@ -96,11 +93,7 @@ public class SearchGraphTest {
@Before
public void setup(){
- System.setProperty("AJSC_HOME", ".");
- System.setProperty("BUNDLECONFIG_DIR", "src/main/resources");
-
- searchGraph = new SearchGraph();
-
+ version = schemaVersions.getDefaultVersion();
httpHeaders = mock(HttpHeaders.class);
uriInfo = mock(UriInfo.class);
@@ -134,24 +127,24 @@ public class SearchGraphTest {
Mockito.doReturn(null).when(queryParameters).remove(anyObject());
when(httpHeaders.getMediaType()).thenReturn(APPLICATION_JSON);
- loader = LoaderFactory.createLoaderForVersion(introspectorFactoryType, version);
+ loader = loaderFactory.createLoaderForVersion(introspectorFactoryType, version);
dbEngine = new JanusGraphDBEngine(
queryStyle,
type,
loader);
}
-@Test(expected = AAIException.class)
+ @Test(expected = AAIException.class)
public void runNodesQuery() throws AAIException{
DBSerializer serializer = new DBSerializer(version, dbEngine, introspectorFactoryType, "JUNIT");
- UrlBuilder urlBuilder = new UrlBuilder(version, serializer);
+ UrlBuilder urlBuilder = new UrlBuilder(version, serializer, schemaVersions, basePath);
searchGraph.runNodesQuery(httpHeaders,"",null,
null,dbEngine,loader,urlBuilder);
}
@Test(expected = AAIException.class)
public void runNodesQueryNull() throws AAIException{
DBSerializer serializer = new DBSerializer(version, dbEngine, introspectorFactoryType, "JUNIT");
- UrlBuilder urlBuilder = new UrlBuilder(version, serializer);
+ UrlBuilder urlBuilder = new UrlBuilder(version, serializer, schemaVersions, basePath);
searchGraph.runNodesQuery(httpHeaders,"nnn",null,
null,dbEngine,loader,urlBuilder);
}
@@ -165,7 +158,7 @@ public class SearchGraphTest {
includeStrings.add("cloud-region");
DBSerializer serializer = new DBSerializer(version, dbEngine, introspectorFactoryType, "JUNIT");
- UrlBuilder urlBuilder = new UrlBuilder(version, serializer);
+ UrlBuilder urlBuilder = new UrlBuilder(version, serializer, schemaVersions, basePath);
Response response = searchGraph.runGenericQuery(httpHeaders, "service-instance", keys, includeStrings, 1, dbEngine, loader, urlBuilder);
System.out.println(response);
}
@@ -181,7 +174,7 @@ public class SearchGraphTest {
includeStrings.add("cloud-region");
DBSerializer serializer = new DBSerializer(version, dbEngine, introspectorFactoryType, "JUNIT");
- UrlBuilder urlBuilder = new UrlBuilder(version, serializer);
+ UrlBuilder urlBuilder = new UrlBuilder(version, serializer, schemaVersions, basePath);
Response response = searchGraph.runGenericQuery(httpHeaders, null, keys, includeStrings, 1, dbEngine, loader, urlBuilder);
System.out.println(response);
}
@@ -196,7 +189,7 @@ public class SearchGraphTest {
includeStrings.add("cloud-region");
DBSerializer serializer = new DBSerializer(version, dbEngine, introspectorFactoryType, "JUNIT");
- UrlBuilder urlBuilder = new UrlBuilder(version, serializer);
+ UrlBuilder urlBuilder = new UrlBuilder(version, serializer, schemaVersions, basePath);
Response response = searchGraph.runGenericQuery(httpHeaders, "", null, includeStrings, 1, dbEngine, loader, urlBuilder);
System.out.println(response);
}
@@ -211,7 +204,7 @@ public class SearchGraphTest {
includeStrings.add("cloud-region");
DBSerializer serializer = new DBSerializer(version, dbEngine, introspectorFactoryType, "JUNIT");
- UrlBuilder urlBuilder = new UrlBuilder(version, serializer);
+ UrlBuilder urlBuilder = new UrlBuilder(version, serializer, schemaVersions, basePath);
Response response = searchGraph.runGenericQuery(httpHeaders, "", keys, null, 1, dbEngine, loader, urlBuilder);
System.out.println(response);
}
diff --git a/aai-traversal/src/test/java/org/onap/aai/rest/AbstractSpringRestTest.java b/aai-traversal/src/test/java/org/onap/aai/rest/AbstractSpringRestTest.java
new file mode 100644
index 0000000..7235fa3
--- /dev/null
+++ b/aai-traversal/src/test/java/org/onap/aai/rest/AbstractSpringRestTest.java
@@ -0,0 +1,135 @@
+/**
+ * ============LICENSE_START=======================================================
+ * org.onap.aai
+ * ================================================================================
+ * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY 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.rest;
+
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.fasterxml.jackson.databind.ObjectWriter;
+import org.apache.tinkerpop.gremlin.process.traversal.P;
+import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource;
+import org.janusgraph.core.JanusGraph;
+import org.janusgraph.core.JanusGraphTransaction;
+import org.junit.*;
+import org.onap.aai.TraversalApp;
+import org.onap.aai.TraversalTestConfiguration;
+import org.onap.aai.config.PropertyPasswordConfiguration;
+import org.onap.aai.dbmap.AAIGraph;
+import org.onap.aai.exceptions.AAIException;
+import org.onap.aai.nodes.NodeIngestor;
+import org.onap.aai.util.AAIConfig;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.context.embedded.LocalServerPort;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.context.annotation.Import;
+import org.springframework.http.HttpEntity;
+import org.springframework.http.HttpHeaders;
+import org.springframework.http.MediaType;
+import org.springframework.test.context.ContextConfiguration;
+import org.springframework.test.context.TestPropertySource;
+import org.springframework.test.context.junit4.rules.SpringClassRule;
+import org.springframework.test.context.junit4.rules.SpringMethodRule;
+import org.springframework.web.client.RestTemplate;
+
+import java.io.UnsupportedEncodingException;
+import java.util.Base64;
+import java.util.Collections;
+
+@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT, classes = TraversalApp.class)
+@TestPropertySource(locations = "classpath:application-test.properties")
+@ContextConfiguration(initializers = PropertyPasswordConfiguration.class)
+@Import(TraversalTestConfiguration.class)
+public abstract class AbstractSpringRestTest {
+
+ @ClassRule
+ public static final SpringClassRule springClassRule = new SpringClassRule();
+
+ @Rule
+ public final SpringMethodRule springMethodRule = new SpringMethodRule();
+
+ @Autowired
+ protected RestTemplate restTemplate;
+
+ @Autowired
+ protected NodeIngestor nodeIngestor;
+
+ @LocalServerPort
+ protected int randomPort;
+
+ protected HttpEntity httpEntity;
+
+ protected String baseUrl;
+ protected HttpHeaders headers ;
+
+ @BeforeClass
+ public static void setupConfig() throws AAIException {
+ System.setProperty("AJSC_HOME", "./");
+ System.setProperty("BUNDLECONFIG_DIR", "src/main/resources/");
+ }
+
+ @Before
+ public void setup() throws AAIException, UnsupportedEncodingException {
+
+ AAIConfig.init();
+ AAIGraph.getInstance();
+
+ createTestGraph();
+ headers = new HttpHeaders();
+
+ headers.setAccept(Collections.singletonList(MediaType.APPLICATION_JSON));
+ headers.setContentType(MediaType.APPLICATION_JSON);
+ headers.add("Real-Time", "true");
+ headers.add("X-FromAppId", "JUNIT");
+ headers.add("X-TransactionId", "JUNIT");
+ String authorization = Base64.getEncoder().encodeToString("AAI:AAI".getBytes("UTF-8"));
+ headers.add("Authorization", "Basic " + authorization);
+ httpEntity = new HttpEntity(headers);
+ baseUrl = "https://localhost:" + randomPort;
+ }
+
+ /*
+ * Inheritors please override this one
+ */
+ public void createTestGraph(){
+
+ }
+ @After
+ public void tearDown(){
+
+ JanusGraph janusGraph = AAIGraph.getInstance().getGraph();
+ JanusGraphTransaction transaction = janusGraph.newTransaction();
+
+ boolean success = true;
+
+ try {
+ GraphTraversalSource g = transaction.traversal();
+ g.V().has("source-of-truth", P.within("JUNIT", "AAI-EXTENSIONS"))
+ .toList()
+ .stream()
+ .forEach(v -> v.remove());
+ } catch(Exception ex){
+ success = false;
+ } finally {
+ if(success){
+ transaction.commit();
+ } else {
+ transaction.rollback();
+ }
+ }
+ }
+}
diff --git a/aai-traversal/src/test/java/org/onap/aai/rest/BadQueryFormatTest.java b/aai-traversal/src/test/java/org/onap/aai/rest/BadQueryFormatTest.java
new file mode 100644
index 0000000..a566499
--- /dev/null
+++ b/aai-traversal/src/test/java/org/onap/aai/rest/BadQueryFormatTest.java
@@ -0,0 +1,109 @@
+/**
+ * ============LICENSE_START=======================================================
+ * org.onap.aai
+ * ================================================================================
+ * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY 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.rest;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.onap.aai.HttpTestUtil;
+import org.onap.aai.PayloadUtil;
+import org.onap.aai.TraversalApp;
+import org.onap.aai.TraversalTestConfiguration;
+import org.onap.aai.config.PropertyPasswordConfiguration;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.context.embedded.LocalServerPort;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.context.annotation.Import;
+import org.springframework.http.*;
+import org.springframework.test.context.ContextConfiguration;
+import org.springframework.test.context.TestPropertySource;
+import org.springframework.test.context.junit4.SpringRunner;
+import org.springframework.web.client.RestTemplate;
+
+import java.util.Base64;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Map;
+
+import static org.hamcrest.Matchers.containsString;
+import static org.hamcrest.Matchers.is;
+import static org.hamcrest.junit.MatcherAssert.assertThat;
+
+@RunWith(SpringRunner.class)
+@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT, classes = TraversalApp.class)
+@TestPropertySource(locations = "classpath:application-test.properties")
+@ContextConfiguration(initializers = PropertyPasswordConfiguration.class)
+@Import(TraversalTestConfiguration.class)
+public class BadQueryFormatTest {
+
+ private HttpTestUtil httpTestUtil;
+
+ private String pserverUri;
+
+ private String hostname;
+
+ @Autowired
+ RestTemplate restTemplate;
+
+ @LocalServerPort
+ int randomPort;
+
+ private HttpEntity httpEntity;
+
+ private HttpHeaders headers;
+
+ private String baseUrl;
+
+ @Before
+ public void setup() throws Exception {
+
+ headers = new HttpHeaders();
+
+ headers.setAccept(Collections.singletonList(MediaType.APPLICATION_JSON));
+ headers.setContentType(MediaType.APPLICATION_JSON);
+ headers.add("Real-Time", "true");
+ headers.add("X-FromAppId", "JUNIT");
+ headers.add("X-TransactionId", "JUNIT");
+ String authorization = Base64.getEncoder().encodeToString("AAI:AAI".getBytes("UTF-8"));
+ headers.add("Authorization", "Basic " + authorization);
+
+ baseUrl = "https://localhost:" + randomPort;
+ }
+
+ @Test
+ public void testPserverCount() throws Exception {
+ Map<String, String> gremlinQueryMap = new HashMap<>();
+ gremlinQueryMap.put("gremlin-query", "g.V().has('hostname', '" + hostname + "').count()");
+
+ String payload = PayloadUtil.getTemplatePayload("gremlin-query.json", gremlinQueryMap);
+
+ ResponseEntity responseEntity = null;
+
+ String endpoint = "/aai/v11/query?format=hello";
+
+ httpEntity = new HttpEntity(payload, headers);
+ responseEntity = restTemplate.exchange(baseUrl + endpoint, HttpMethod.PUT, httpEntity, String.class);
+
+ System.out.println(responseEntity.getBody());
+ assertThat(responseEntity.getStatusCode(), is(HttpStatus.BAD_REQUEST));
+ assertThat(responseEntity.getBody().toString(), containsString("Bad Parameter Passed:Unsupported format query parameter hello in request"));
+ }
+
+}
diff --git a/aai-traversal/src/test/java/org/onap/aai/rest/DslConsumerTest.java b/aai-traversal/src/test/java/org/onap/aai/rest/DslConsumerTest.java
new file mode 100644
index 0000000..0e539ba
--- /dev/null
+++ b/aai-traversal/src/test/java/org/onap/aai/rest/DslConsumerTest.java
@@ -0,0 +1,113 @@
+/**
+ * ============LICENSE_START=======================================================
+ * org.onap.aai
+ * ================================================================================
+ * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY 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.rest;
+
+import static org.hamcrest.CoreMatchers.containsString;
+import static org.hamcrest.CoreMatchers.is;
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.Matchers.containsString;
+import static org.hamcrest.Matchers.is;
+import static org.hamcrest.junit.MatcherAssert.assertThat;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.fail;
+
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Map;
+
+import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource;
+import org.janusgraph.core.JanusGraphTransaction;
+import org.junit.Before;
+import org.junit.Test;
+import org.onap.aai.PayloadUtil;
+import org.onap.aai.dbmap.AAIGraph;
+import org.onap.aai.util.AAIConfig;
+import org.springframework.http.HttpEntity;
+import org.springframework.http.HttpHeaders;
+import org.springframework.http.HttpMethod;
+import org.springframework.http.HttpStatus;
+import org.springframework.http.MediaType;
+import org.springframework.http.ResponseEntity;
+import org.springframework.web.util.UriComponentsBuilder;
+
+import com.att.eelf.configuration.EELFLogger;
+import com.att.eelf.configuration.EELFManager;
+import com.jayway.jsonpath.JsonPath;
+
+public class DslConsumerTest extends AbstractSpringRestTest {
+
+ private static final EELFLogger LOGGER = EELFManager.getInstance().getLogger(DslConsumerTest.class);
+
+ @Override
+ public void createTestGraph() {
+ JanusGraphTransaction transaction = AAIGraph.getInstance().getGraph().newTransaction();
+ boolean success = true;
+ try {
+ GraphTraversalSource g = transaction.traversal();
+ g.addV().property("aai-node-type", "pserver").property("hostname", "test-pserver-dsl")
+ .property("in-maint", false).property("source-of-truth", "JUNIT")
+ .property("aai-uri", "/cloud-infrastructure/pservers/pserver/test-pserver").next();
+ } catch (Exception ex) {
+ success = false;
+ } finally {
+ if (success) {
+ transaction.commit();
+ } else {
+ transaction.rollback();
+ fail("Unable to setup the graph");
+ }
+ }
+ }
+
+ @Test
+ public void testDslQuery() throws Exception {
+
+ String endpoint = "/aai/v14/dsl?format=console";
+ Map<String, String> dslQueryMap = new HashMap<>();
+ dslQueryMap.put("dsl-query", "pserver*('hostname','test-pserver-dsl')");
+ String payload = PayloadUtil.getTemplatePayload("dsl-query.json", dslQueryMap);
+ httpEntity = new HttpEntity(payload, headers);
+ ResponseEntity responseEntity = restTemplate.exchange(baseUrl + endpoint, HttpMethod.PUT, httpEntity,
+ String.class);
+ LOGGER.debug("Response for PUT request with uri {} : {}", baseUrl + endpoint, responseEntity.getBody());
+ System.out.println(responseEntity.getBody());
+ assertNotNull("Response from /aai/v14/dsl is not null", responseEntity);
+ assertEquals("Expected the response to be 500", HttpStatus.OK, responseEntity.getStatusCode());
+ }
+
+ @Test
+ public void testDslQueryException() throws Exception {
+ Map<String, String> dslQuerymap = new HashMap<>();
+ dslQuerymap.put("dsl-query", "xserver");
+
+ String payload = PayloadUtil.getTemplatePayload("dsl-query.json", dslQuerymap);
+
+ ResponseEntity responseEntity = null;
+
+ String endpoint = "/aai/v11/dsl?format=console";
+
+ httpEntity = new HttpEntity(payload, headers);
+ responseEntity = restTemplate.exchange(baseUrl + endpoint, HttpMethod.PUT, httpEntity, String.class);
+ assertEquals("Expected the response to be 400", HttpStatus.INTERNAL_SERVER_ERROR,
+ responseEntity.getStatusCode());
+ }
+
+}
diff --git a/aai-traversal/src/test/java/org/onap/aai/rest/GfpVserverDataStoredQueryTest.java b/aai-traversal/src/test/java/org/onap/aai/rest/GfpVserverDataStoredQueryTest.java
index d5b695a..841b18e 100644
--- a/aai-traversal/src/test/java/org/onap/aai/rest/GfpVserverDataStoredQueryTest.java
+++ b/aai-traversal/src/test/java/org/onap/aai/rest/GfpVserverDataStoredQueryTest.java
@@ -27,13 +27,13 @@ import org.janusgraph.core.JanusGraphTransaction;
import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource;
import org.junit.After;
import org.junit.Before;
-import org.junit.Ignore;
import org.junit.Test;
import org.mockito.Mockito;
+import org.onap.aai.AAISetup;
import org.onap.aai.HttpTestUtil;
import org.onap.aai.PayloadUtil;
import org.onap.aai.dbmap.AAIGraph;
-import org.onap.aai.introspection.Version;
+import org.onap.aai.setup.SchemaVersion;
import javax.servlet.http.HttpServletRequest;
import javax.ws.rs.core.*;
@@ -47,7 +47,7 @@ import static org.mockito.Matchers.anyObject;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
-public class GfpVserverDataStoredQueryTest {
+public class GfpVserverDataStoredQueryTest extends AAISetup{
private static final EELFLogger logger = EELFManager.getInstance().getLogger(GfpVserverDataStoredQueryTest.class);
@@ -66,13 +66,17 @@ public class GfpVserverDataStoredQueryTest {
private QueryConsumer queryConsumer;
- private static final Version VERSION = Version.v11;
- private static final String CLOUD_REGION_URI = "/aai/" + VERSION.toString()
- + "/cloud-infrastructure/cloud-regions/"
- + "cloud-region/testOwner1/testRegion1";
+ private SchemaVersion version;
+ private String cloudRegionUri;
@Before
public void setup() throws Exception {
+
+ version = schemaVersions.getDefaultVersion();
+
+ cloudRegionUri = "/aai/" + version.toString()
+ + "/cloud-infrastructure/cloud-regions/"
+ + "cloud-region/testOwner1/testRegion1";
httpTestUtil = new HttpTestUtil();
Map<String, String> templateValues = new HashMap<>();
@@ -91,14 +95,14 @@ public class GfpVserverDataStoredQueryTest {
String cloudRegionPayload = PayloadUtil.
getTemplatePayload("cloud-region-with-linterface.json", templateValues);
- Response response = httpTestUtil.doPut(CLOUD_REGION_URI, cloudRegionPayload);
+ Response response = httpTestUtil.doPut(cloudRegionUri, cloudRegionPayload);
logger.info("Response status received {}", response.getEntity());
assertNotNull("Expected the response to be not null", response);
assertEquals("Expecting the cloud region to be created", 201, response.getStatus());
logger.info("Successfully created the cloud region with linterface");
- queryConsumer = new QueryConsumer();
+ queryConsumer = new QueryConsumer(traversalUriHttpEntry, schemaVersions, gremlinServerSingleton, basePath);
httpHeaders = mock(HttpHeaders.class);
@@ -128,14 +132,14 @@ public class GfpVserverDataStoredQueryTest {
when(httpHeaders.getMediaType()).thenReturn(APPLICATION_JSON);
}
- @Ignore("This is more of a performance test to ensure no failure when too many starting vertexes")
@Test
public void testStoredQueryVerifyDoesNotThrowMethodTooLargeWhenLargeNumberOfStartingVertexes() throws Exception {
// Add hundred thousand vserver vertexes to properly
// test the scenario where the application was
// failing with method too large
- addVservers(1000000);
+ String vservers = System.getProperty("perf.vservers.count", "1000");
+ addVservers(Integer.parseInt(vservers));
Map<String, String> templateValues = new HashMap<>();
@@ -148,7 +152,7 @@ public class GfpVserverDataStoredQueryTest {
templateValues.put("query", "gfp-vserver-data");
String payload = PayloadUtil.getTemplatePayload("custom-query.json", templateValues);
- String query = String.format("/aai/%s/query?format=resource_and_url", VERSION.toString());
+ String query = String.format("/aai/%s/query?format=resource_and_url", version.toString());
UriInfo uriInfo = Mockito.mock(UriInfo.class);
HttpServletRequest httpServletRequest = Mockito.mock(HttpServletRequest.class);
@@ -159,7 +163,7 @@ public class GfpVserverDataStoredQueryTest {
Response response = queryConsumer.executeQuery(
payload,
- VERSION.toString(),
+ version.toString(),
query,
"resource_and_url", "" +
"no_op",
@@ -185,7 +189,7 @@ public class GfpVserverDataStoredQueryTest {
templateValues.put("query", "fake-query");
String payload = PayloadUtil.getTemplatePayload("custom-query.json", templateValues);
- String query = String.format("/aai/%s/query?format=resource_and_url", VERSION.toString());
+ String query = String.format("/aai/%s/query?format=resource_and_url", version.toString());
UriInfo uriInfo = Mockito.mock(UriInfo.class);
HttpServletRequest httpServletRequest = Mockito.mock(HttpServletRequest.class);
@@ -196,7 +200,7 @@ public class GfpVserverDataStoredQueryTest {
Response response = queryConsumer.executeQuery(
payload,
- VERSION.toString(),
+ version.toString(),
query,
"resource_and_url", "" +
"no_op",
@@ -223,7 +227,7 @@ public class GfpVserverDataStoredQueryTest {
templateValues.put("query", "gfp-vserver-data");
String payload = PayloadUtil.getTemplatePayload("custom-query.json", templateValues);
- String query = String.format("/aai/%s/query?format=resource_and_url", VERSION.toString());
+ String query = String.format("/aai/%s/query?format=resource_and_url", version.toString());
UriInfo uriInfo = Mockito.mock(UriInfo.class);
HttpServletRequest httpServletRequest = Mockito.mock(HttpServletRequest.class);
@@ -234,7 +238,7 @@ public class GfpVserverDataStoredQueryTest {
Response response = queryConsumer.executeQuery(
payload,
- VERSION.toString(),
+ version.toString(),
query,
"resource_and_url", "" +
"no_op",
@@ -245,10 +249,10 @@ public class GfpVserverDataStoredQueryTest {
String entity = response.getEntity().toString();
- assertEquals("Expected the response to be 500 but got this returned: " + entity,
- 500, response.getStatus());
+ assertEquals("Expected the response to be 404 but got this returned: " + entity,
+ 404, response.getStatus());
- assertThat(entity, containsString("Internal Error:groovy.lang.MissingPropertyException"));
+ assertThat(entity, containsString("Start URI returned no vertexes, please check the start URI"));
}
@After
diff --git a/aai-traversal/src/test/java/org/onap/aai/rest/RecentApiTest.java b/aai-traversal/src/test/java/org/onap/aai/rest/RecentApiTest.java
new file mode 100644
index 0000000..ff2c98f
--- /dev/null
+++ b/aai-traversal/src/test/java/org/onap/aai/rest/RecentApiTest.java
@@ -0,0 +1,95 @@
+/**
+ * ============LICENSE_START=======================================================
+ * org.onap.aai
+ * ================================================================================
+ * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY 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.rest;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+
+import org.junit.Test;
+import org.springframework.http.HttpEntity;
+import org.springframework.http.HttpMethod;
+import org.springframework.http.HttpStatus;
+import org.springframework.http.ResponseEntity;
+import org.springframework.web.util.UriComponentsBuilder;
+
+import com.att.eelf.configuration.EELFLogger;
+import com.att.eelf.configuration.EELFManager;
+
+public class RecentApiTest extends AbstractSpringRestTest {
+
+ private static final EELFLogger LOGGER = EELFManager.getInstance().getLogger(RecentApiTest.class);
+
+ @Test
+ public void testRecentsQuery() {
+
+ String endpoint = "/aai/recents/v14/pserver";
+ httpEntity = new HttpEntity(headers);
+ UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(baseUrl + endpoint).queryParam("hours", "190");
+ ResponseEntity responseEntity = restTemplate.exchange(builder.toUriString(), HttpMethod.GET, httpEntity,
+ String.class);
+ LOGGER.debug("Response for PUT request with uri {} : {}", builder.toUriString(), responseEntity.getBody());
+ assertNotNull("Response from /aai/recents/v14/pserver is null", responseEntity);
+ assertEquals("Expected the response to be 400", HttpStatus.OK, responseEntity.getStatusCode());
+
+ }
+
+ @Test
+ public void testRecentsQueryException() {
+ String endpoint = "/aai/recents/v14/xserver";
+ httpEntity = new HttpEntity(headers);
+ UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(baseUrl + endpoint).queryParam("hours", "190");
+ ResponseEntity responseEntity = restTemplate.exchange(builder.toUriString(), HttpMethod.GET, httpEntity,
+ String.class);
+
+ LOGGER.debug("Response for PUT request with uri {} : {}", builder.toUriString(), responseEntity.getBody());
+ assertNotNull("Response from /aai/recents/v14/pserver is null", responseEntity);
+ assertEquals("Expected the response to be 400", HttpStatus.BAD_REQUEST, responseEntity.getStatusCode());
+ }
+
+ @Test
+ public void testRecentsQueryExceptionHours() {
+ String endpoint = "/aai/recents/v14/pserver";
+ httpEntity = new HttpEntity(headers);
+ UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(baseUrl + endpoint).queryParam("hours", "200");
+
+ ResponseEntity responseEntity = restTemplate.exchange(builder.toUriString(), HttpMethod.GET, httpEntity,
+ String.class);
+ LOGGER.debug("Response for PUT request with uri {} : {}", builder.toUriString(), responseEntity.getBody());
+ assertNotNull("Response from /aai/recents/v14/pserver is null", responseEntity);
+ assertEquals("Expected the response to be 400", HttpStatus.BAD_REQUEST,
+ responseEntity.getStatusCode());
+
+ }
+
+ @Test
+ public void testRecentsQueryExceptionDateTime() {
+ String endpoint = "/aai/recents/v14/pserver";
+ httpEntity = new HttpEntity(headers);
+ UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(baseUrl + endpoint).queryParam("date-time",
+ "200");
+
+ ResponseEntity responseEntity = restTemplate.exchange(builder.toUriString(), HttpMethod.GET, httpEntity,
+ String.class);
+ LOGGER.debug("Response for PUT request with uri {} : {}", builder.toUriString(), responseEntity.getBody());
+ assertNotNull("Response from /aai/recents/v14/pserver is null", responseEntity);
+ assertEquals("Expected the response to be 400", HttpStatus.BAD_REQUEST,
+ responseEntity.getStatusCode());
+ }
+}
diff --git a/aai-traversal/src/test/java/org/onap/aai/rest/SearchProviderRestTest.java b/aai-traversal/src/test/java/org/onap/aai/rest/SearchProviderRestTest.java
new file mode 100644
index 0000000..d53fa56
--- /dev/null
+++ b/aai-traversal/src/test/java/org/onap/aai/rest/SearchProviderRestTest.java
@@ -0,0 +1,102 @@
+/**
+ * ============LICENSE_START=======================================================
+ * org.onap.aai
+ * ================================================================================
+ * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY 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.rest;
+
+import com.att.eelf.configuration.EELFLogger;
+import com.att.eelf.configuration.EELFManager;
+import org.junit.Test;
+import org.springframework.http.*;
+import org.springframework.web.util.UriComponentsBuilder;
+
+import java.util.Collections;
+
+import static org.hamcrest.CoreMatchers.containsString;
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+
+public class SearchProviderRestTest extends AbstractSpringRestTest {
+
+ private static final EELFLogger LOGGER = EELFManager.getInstance().getLogger(SearchProviderRestTest.class);
+
+ @Test
+ public void testNodesQueryInvalidData() {
+
+ String endpoint = "/aai/latest/search/nodes-query";
+
+ httpEntity = new HttpEntity(headers);
+
+ UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(baseUrl + endpoint)
+ .queryParam("key", "cloud-region.cloud-owner:test-aic")
+ .queryParam("include", "cloud-region");
+
+ ResponseEntity responseEntity = restTemplate.exchange(builder.toUriString(), HttpMethod.GET, httpEntity, String.class);
+
+ LOGGER.debug("Response for GET request with uri {} : {}", builder.toUriString(), responseEntity.getBody());
+
+ assertNotNull("Response from /aai/latest/search is null", responseEntity);
+ assertEquals("Expected the response to be 400", HttpStatus.BAD_REQUEST, responseEntity.getStatusCode());
+ }
+
+ @Test
+ public void testGenericQueryInvalidData() {
+
+ String endpoint = "/aai/latest/search/generic-query";
+
+ httpEntity = new HttpEntity(headers);
+
+ UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(baseUrl + endpoint)
+ .queryParam("key", "cloud-region.cloud-owner:test-aic")
+ .queryParam("include", "cloud-region");
+
+ ResponseEntity responseEntity = restTemplate.exchange(builder.toUriString(), HttpMethod.GET, httpEntity, String.class);
+
+ LOGGER.debug("Response for GET request with uri {} : {}", builder.toUriString(), responseEntity.getBody());
+
+ assertNotNull("Response from /aai/latest/search is null", responseEntity);
+ assertEquals("Expected the response to be 400", HttpStatus.BAD_REQUEST, responseEntity.getStatusCode());
+ }
+
+ @Test
+ public void testGenericQueryBypassTimeout(){
+ headers = new HttpHeaders();
+
+ headers.setAccept(Collections.singletonList(MediaType.APPLICATION_JSON));
+ headers.setContentType(MediaType.APPLICATION_JSON);
+ headers.add("Real-Time", "true");
+ headers.add("X-TransactionId", "JUNIT");
+
+ httpEntity = new HttpEntity(headers);
+ String endpoint = "/aai/latest/search/generic-query";
+
+ UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(baseUrl + endpoint)
+ .queryParam("key", "cloud-region.cloud-owner:test-aic")
+ .queryParam("include", "cloud-region")
+ .queryParam("start-node-type", "cloud-region");
+
+ ResponseEntity responseEntity = restTemplate.exchange(builder.toUriString(), HttpMethod.GET, httpEntity, String.class);
+
+ LOGGER.debug("Response for GET request with uri {} : {}", builder.toUriString(), responseEntity.getBody());
+
+ assertNotNull("Response from /aai/latest/search is null", responseEntity);
+ assertEquals("Expected the response to be 400", HttpStatus.BAD_REQUEST, responseEntity.getStatusCode());
+ assertThat(responseEntity.getBody().toString(), containsString("4009"));
+ }
+}
diff --git a/aai-traversal/src/test/java/org/onap/aai/rest/dsl/DslQueryProcessorTest.java b/aai-traversal/src/test/java/org/onap/aai/rest/dsl/DslQueryProcessorTest.java
index cd20266..abd98e9 100644
--- a/aai-traversal/src/test/java/org/onap/aai/rest/dsl/DslQueryProcessorTest.java
+++ b/aai-traversal/src/test/java/org/onap/aai/rest/dsl/DslQueryProcessorTest.java
@@ -26,29 +26,28 @@ import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;
+import org.onap.aai.AAISetup;
import org.onap.aai.exceptions.AAIException;
/**
* The Class DslMain.
*/
-public class DslQueryProcessorTest {
-
-
+public class DslQueryProcessorTest extends AAISetup {
+
+
@Test
public void cloudRegion1Test() throws AAIException {
- DslQueryProcessor dslTest = new DslQueryProcessor();
+ String aaiQuery = "cloud-region* !('cloud-owner','coid')('cloud-region-id','cr id') LIMIT 10";
- String aaiQuery = "cloud-region* !('cloud-owner','coid')('cloud-region-id','crid') LIMIT 10";
String dslQuery = "builder.getVerticesByProperty('aai-node-type', 'cloud-region').getVerticesExcludeByProperty('cloud-owner','coid')"
- + ".getVerticesByProperty('cloud-region-id','crid').store('x').cap('x').unfold().dedup().limit(10)";
+ + ".getVerticesByProperty('cloud-region-id','cr id').store('x').cap('x').unfold().dedup().limit(10)";
- String query = dslTest.parseAaiQuery(aaiQuery);
+ String query = dslQueryProcessor.parseAaiQuery(aaiQuery);
assertEquals(dslQuery, query);
}
@Test
public void cloudRegion_entitlementTest() throws AAIException {
- DslQueryProcessor dslTest = new DslQueryProcessor();
String aaiQuery = "generic-vnf (> vserver > tenant > cloud-region*('cloud-region-id','One')) > entitlement*";
String dslQuery = "builder.getVerticesByProperty('aai-node-type', 'generic-vnf').where("
@@ -58,16 +57,15 @@ public class DslQueryProcessorTest {
+ ".getVerticesByProperty('cloud-region-id','One').store('x'))"
+ ".createEdgeTraversal(EdgeType.TREE, 'generic-vnf','entitlement').store('x').cap('x').unfold().dedup()";
- String query = dslTest.parseAaiQuery(aaiQuery);
+ String query = dslQueryProcessor.parseAaiQuery(aaiQuery);
assertEquals(dslQuery, query);
}
@Test
public void complex_az_fromComplexTest() throws AAIException {
- DslQueryProcessor dslTest = new DslQueryProcessor();
String aaiQuery = "cloud-region('cloud-owner','coid')('cloud-region-id','crid') > [ availability-zone* , complex*]";
- String query = dslTest.parseAaiQuery(aaiQuery);
+ String query = dslQueryProcessor.parseAaiQuery(aaiQuery);
String dslQuery = "builder.getVerticesByProperty('aai-node-type', 'cloud-region')"
+ ".getVerticesByProperty('cloud-owner','coid').getVerticesByProperty('cloud-region-id','crid')"
+ ".union(builder.newInstance().createEdgeTraversal(EdgeType.TREE, 'cloud-region','availability-zone').store('x')"
@@ -75,35 +73,32 @@ public class DslQueryProcessorTest {
assertEquals(dslQuery, query);
}
-
+
@Test
public void cloudRegion_fromComplex1Test() throws AAIException {
- DslQueryProcessor dslTest = new DslQueryProcessor();
String builderQuery = "builder.getVerticesByProperty('aai-node-type', 'complex').getVerticesByProperty('country','count-name')"
+ ".createEdgeTraversal(EdgeType.COUSIN, 'complex','cloud-region').store('x').cap('x').unfold().dedup()";
String aaiQuery = "complex('country','count-name') > cloud-region*";
- String query = dslTest.parseAaiQuery(aaiQuery);
+ String query = dslQueryProcessor.parseAaiQuery(aaiQuery);
assertEquals(builderQuery, query);
}
-
+
@Test
public void cloudRegion_fromComplex2Test() throws AAIException {
- DslQueryProcessor dslTest = new DslQueryProcessor();
String builderQuery = "builder.getVerticesByProperty('aai-node-type', 'complex').getVerticesByProperty('country','count-name')"
+ ".createEdgeTraversal(EdgeType.COUSIN, 'complex','cloud-region').getVerticesByProperty('cloud-region-version','crv')"
+ ".store('x').cap('x').unfold().dedup()";
String aaiQuery = "complex('country','count-name') > cloud-region*('cloud-region-version','crv')";
- String query = dslTest.parseAaiQuery(aaiQuery);
+ String query = dslQueryProcessor.parseAaiQuery(aaiQuery);
assertEquals(builderQuery, query);
}
-
+
@Test
public void cloudRegion_fromNfTypeTest() throws AAIException {
- DslQueryProcessor dslTest = new DslQueryProcessor();
String builderQuery = "builder.getVerticesByProperty('aai-node-type', 'image').getVerticesByProperty('application-vendor','F5')"
+ ".createEdgeTraversal(EdgeType.COUSIN, 'image','vserver')"
@@ -112,13 +107,12 @@ public class DslQueryProcessorTest {
+ ".store('x').cap('x').unfold().dedup()";
String aaiQuery = "image('application-vendor','F5') > vserver (>generic-vnf('vnf-name','ZALL1MMSC03')) > tenant > cloud-region*";
- String query = dslTest.parseAaiQuery(aaiQuery);
+ String query = dslQueryProcessor.parseAaiQuery(aaiQuery);
assertEquals(builderQuery, query);
}
-
+
@Test
public void cloudRegion_fromNfTypeVendorVersionTest() throws AAIException {
- DslQueryProcessor dslTest = new DslQueryProcessor();
String builderQuery = "builder.getVerticesByProperty('aai-node-type', 'image').getVerticesByProperty('application-vendor','vendor')"
+ ".createEdgeTraversal(EdgeType.COUSIN, 'image','vserver').where("
@@ -128,14 +122,13 @@ public class DslQueryProcessorTest {
String aaiQuery = "image('application-vendor','vendor') > vserver( >generic-vnf('nf-type', 'nfType') ) > tenant > cloud-region*";
- String query = dslTest.parseAaiQuery(aaiQuery);
+ String query = dslQueryProcessor.parseAaiQuery(aaiQuery);
assertEquals(builderQuery, query);
}
@Test
public void cloud_region_fromVnfTest() throws AAIException {
- DslQueryProcessor dslTest = new DslQueryProcessor();
String builderQuery = "builder.getVerticesByProperty('aai-node-type', 'generic-vnf').getVerticesByProperty('vnf-id','vnfId')"
+ ".createEdgeTraversal(EdgeType.COUSIN, 'generic-vnf','vnfc').store('x')"
@@ -146,14 +139,13 @@ public class DslQueryProcessorTest {
String aaiQuery = "generic-vnf('vnf-id','vnfId') > vnfc* > vserver* > tenant* > cloud-region*";
- String query = dslTest.parseAaiQuery(aaiQuery);
+ String query = dslQueryProcessor.parseAaiQuery(aaiQuery);
assertEquals(builderQuery, query);
}
-
+
@Test
public void cloud_region_sitesTest() throws AAIException {
- DslQueryProcessor dslTest = new DslQueryProcessor();
String builderQuery = "builder.getVerticesByProperty('aai-node-type', 'cloud-region')."
+ "getVerticesByProperty('cloud-owner','co').store('x').createEdgeTraversal(EdgeType.COUSIN, "
@@ -161,14 +153,13 @@ public class DslQueryProcessorTest {
String aaiQuery = "cloud-region*('cloud-owner','co') > complex*";
- String query = dslTest.parseAaiQuery(aaiQuery);
+ String query = dslQueryProcessor.parseAaiQuery(aaiQuery);
assertEquals(builderQuery, query);
}
-
+
@Test
public void complex_fromVnf2Test() throws AAIException {
- DslQueryProcessor dslTest = new DslQueryProcessor();
String builderQuery = "builder.getVerticesByProperty('aai-node-type', 'generic-vnf').getVerticesByProperty('vnf-Id','vnfId').store('x').union("
+ "builder.newInstance().createEdgeTraversal(EdgeType.COUSIN, 'generic-vnf','pserver').store('x')"
@@ -181,15 +172,14 @@ public class DslQueryProcessorTest {
String aaiQuery = "generic-vnf*('vnf-Id','vnfId') > " + "[ pserver* > complex*, "
+ " vserver > pserver* > complex* " + "]";
- String query = dslTest.parseAaiQuery(aaiQuery);
+ String query = dslQueryProcessor.parseAaiQuery(aaiQuery);
assertEquals(builderQuery, query);
}
-
+
@Test
public void complex_fromVnfTest() throws AAIException {
- DslQueryProcessor dslTest = new DslQueryProcessor();
-
+
String builderQuery = "builder.getVerticesByProperty('aai-node-type', 'generic-vnf').getVerticesByProperty('vnf-Id','vnfId').store('x').union("
+ "builder.newInstance().createEdgeTraversal(EdgeType.COUSIN, 'generic-vnf','pserver').store('x')"
+ ".createEdgeTraversal(EdgeType.COUSIN, 'pserver','complex').store('x'),"
@@ -201,17 +191,16 @@ public class DslQueryProcessorTest {
String aaiQuery = "generic-vnf*('vnf-Id','vnfId') > " + "[ pserver* > complex*, "
+ " vserver > pserver* > complex* " + "]";
- String query = dslTest.parseAaiQuery(aaiQuery);
+ String query = dslQueryProcessor.parseAaiQuery(aaiQuery);
assertEquals(builderQuery, query);
}
@Test
public void fn_topology1Test() throws AAIException {
- DslQueryProcessor dslTest = new DslQueryProcessor();
String builderQuery = "builder.getVerticesByProperty('aai-node-type', 'business')"
- + ".createEdgeTraversal(EdgeType.COUSIN, 'business','customer').getVerticesByProperty('customer-id','a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb')"
+ + ".getVerticesByProperty('customer-id','a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb')"
+ ".createEdgeTraversal(EdgeType.TREE, 'customer','service-subscription').getVerticesByProperty('service-subscription-id','Nimbus')"
+ ".createEdgeTraversal(EdgeType.TREE, 'service-subscription','service-instance').getVerticesByProperty('service-instance-id','sid')"
+ ".createEdgeTraversal(EdgeType.COUSIN, 'service-instance','generic-vnf').store('x')"
@@ -224,9 +213,68 @@ public class DslQueryProcessorTest {
+ " > service-instance('service-instance-id','sid') > generic-vnf* "
+ " > [ vnfc* , vserver*, pserver* , pnf* ]";
- String query = dslTest.parseAaiQuery(aaiQuery);
+ String query = dslQueryProcessor.parseAaiQuery(aaiQuery);
assertEquals(builderQuery, query);
}
+ @Test
+ public void vnf_Dsl() throws AAIException {
+
+ String builderQuery = "builder.getVerticesByProperty('aai-node-type', 'generic-vnf').where(builder.newInstance().union(builder.newInstance().createEdgeTraversal(EdgeType.COUSIN, 'generic-vnf','pserver')"
+ + ".getVerticesByProperty('hostname','hostname1'),builder.newInstance().createEdgeTraversal(EdgeType.COUSIN, 'generic-vnf','vserver')"
+ + ".createEdgeTraversal(EdgeType.COUSIN, 'vserver','pserver').getVerticesByProperty('hostname','hostname1'))).store('x').cap('x').unfold().dedup()";
+
+ String aaiQuery = "generic-vnf* (> [pserver('hostname','hostname1'), "
+ + "vserver > pserver('hostname','hostname1')])";
+ String query = dslQueryProcessor.parseAaiQuery(aaiQuery);
+
+ assertEquals(builderQuery, query);
+ }
+
+ @Test
+ public void hasPropertyTest() throws AAIException {
+ String aaiQuery = "cloud-region* ('cloud-owner')";
+ String dslQuery = "builder.getVerticesByProperty('aai-node-type', 'cloud-region').getVerticesByProperty('cloud-owner').store('x').cap('x').unfold().dedup()";
+
+ String query = dslQueryProcessor.parseAaiQuery(aaiQuery);
+ assertEquals(dslQuery, query);
+ }
+
+ @Test
+ public void hasPropertyValuesTest() throws AAIException {
+ String aaiQuery = "cloud-region* ('cloud-owner','cloud-owner1','cloud-owner2')";
+ String dslQuery = "builder.getVerticesByProperty('aai-node-type', 'cloud-region').getVerticesByProperty('cloud-owner', new ArrayList<>(Arrays.asList('cloud-owner1','cloud-owner2'))).store('x').cap('x').unfold().dedup()";
+
+ String query = dslQueryProcessor.parseAaiQuery(aaiQuery);
+ assertEquals(dslQuery, query);
+ }
+
+ @Test
+ public void hasNotPropertyValuesTest() throws AAIException {
+ String aaiQuery = "cloud-region* !('cloud-owner','cloud-owner1','cloud-owner2')";
+ String dslQuery = "builder.getVerticesByProperty('aai-node-type', 'cloud-region').getVerticesExcludeByProperty('cloud-owner', new ArrayList<>(Arrays.asList('cloud-owner1','cloud-owner2'))).store('x').cap('x').unfold().dedup()";
+
+ String query = dslQueryProcessor.parseAaiQuery(aaiQuery);
+ assertEquals(dslQuery, query);
+ }
+
+ @Test
+ public void hasNotPropertyNullValuesTest() throws AAIException {
+ String aaiQuery = "cloud-region* !('cloud-owner',' ',' null ')";
+ String dslQuery = "builder.getVerticesByProperty('aai-node-type', 'cloud-region').getVerticesExcludeByProperty('cloud-owner', new ArrayList<>(Arrays.asList('','null'))).store('x').cap('x').unfold().dedup()";
+
+ String query = dslQueryProcessor.parseAaiQuery(aaiQuery);
+ assertEquals(dslQuery, query);
+ }
+
+ @Test
+ public void hasNotPropertyTest() throws AAIException {
+ String aaiQuery = "cloud-region* !('cloud-owner')";
+ String dslQuery = "builder.getVerticesByProperty('aai-node-type', 'cloud-region').getVerticesExcludeByProperty('cloud-owner').store('x').cap('x').unfold().dedup()";
+
+ String query = dslQueryProcessor.parseAaiQuery(aaiQuery);
+ assertEquals(dslQuery, query);
+ }
+
}
diff --git a/aai-traversal/src/test/java/org/onap/aai/rest/retired/RetiredConsumerSpringTest.java b/aai-traversal/src/test/java/org/onap/aai/rest/retired/RetiredConsumerSpringTest.java
new file mode 100644
index 0000000..6664465
--- /dev/null
+++ b/aai-traversal/src/test/java/org/onap/aai/rest/retired/RetiredConsumerSpringTest.java
@@ -0,0 +1,65 @@
+/**
+ * ============LICENSE_START=======================================================
+ * org.onap.aai
+ * ================================================================================
+ * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY 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.rest.retired;
+
+import com.att.eelf.configuration.EELFLogger;
+import com.att.eelf.configuration.EELFManager;
+import org.junit.Test;
+import org.onap.aai.rest.AbstractSpringRestTest;
+import org.springframework.http.HttpMethod;
+import org.springframework.http.HttpStatus;
+import org.springframework.http.ResponseEntity;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import static org.junit.Assert.assertEquals;
+
+public class RetiredConsumerSpringTest extends AbstractSpringRestTest {
+
+ private static final EELFLogger LOGGER = EELFManager.getInstance().getLogger(RetiredConsumerSpringTest.class);
+
+ private Map<String, HttpStatus> httpStatusMap;
+
+ @Test
+ public void testOldVersionsEndpointReturnRetired(){
+ setupOldVersions();
+ executeRestCalls();
+ }
+
+ protected void executeRestCalls() {
+ httpStatusMap.forEach((url, status) -> {
+ ResponseEntity responseEntity;
+ responseEntity = restTemplate.exchange(baseUrl + url, HttpMethod.GET, httpEntity, String.class);
+ LOGGER.debug("For url {} expected status {} actual status {} and body {}", url, status, responseEntity.getStatusCodeValue(), responseEntity.getBody());
+ assertEquals(status, responseEntity.getStatusCode());
+ });
+ }
+
+ private void setupOldVersions() {
+ httpStatusMap = new HashMap<>();
+
+ httpStatusMap.put("/aai/v2/search/generic-query", HttpStatus.GONE);
+ httpStatusMap.put("/aai/v3/search/generic-query", HttpStatus.GONE);
+ httpStatusMap.put("/aai/v4/search/generic-query", HttpStatus.GONE);
+ httpStatusMap.put("/aai/v5/search/generic-query", HttpStatus.GONE);
+ httpStatusMap.put("/aai/v6/search/generic-query", HttpStatus.GONE);
+ }
+}
diff --git a/aai-traversal/src/test/java/org/onap/aai/rest/search/CloudRegionAndSourceFromConfigurationQueryTest.java b/aai-traversal/src/test/java/org/onap/aai/rest/search/CloudRegionAndSourceFromConfigurationQueryTest.java
new file mode 100644
index 0000000..87e421d
--- /dev/null
+++ b/aai-traversal/src/test/java/org/onap/aai/rest/search/CloudRegionAndSourceFromConfigurationQueryTest.java
@@ -0,0 +1,102 @@
+/**
+ * ============LICENSE_START=======================================================
+ * org.onap.aai
+ * ================================================================================
+ * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY 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.rest.search;
+
+import java.util.Map;
+
+import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversal;
+import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource;
+import org.apache.tinkerpop.gremlin.structure.T;
+import org.apache.tinkerpop.gremlin.structure.Vertex;
+import org.junit.Test;
+import org.onap.aai.exceptions.AAIException;
+import org.onap.aai.serialization.db.exceptions.NoEdgeRuleFoundException;
+
+public class CloudRegionAndSourceFromConfigurationQueryTest extends QueryTest {
+
+ public CloudRegionAndSourceFromConfigurationQueryTest() throws AAIException, NoEdgeRuleFoundException {
+ super();
+ }
+
+ @Test
+ public void test() {
+ super.run();
+ }
+
+ @Override
+ protected void createGraph() throws AAIException, NoEdgeRuleFoundException {
+ //Set up the test graph
+ Vertex config = graph.addVertex(T.label, "configuration", T.id, "0", "aai-node-type", "configuration", "configuration-id", "configuration");
+ Vertex logicalLink = graph.addVertex(T.label, "l", T.id, "1", "aai-node-type", "logical-link", "link-name", "link-name-0");
+ Vertex lInterface = graph.addVertex(T.label, "l-interface", T.id, "2", "aai-node-type", "l-interface", "interface-name", "interface-name-0");
+ Vertex vserver = graph.addVertex(T.label, "vserver", T.id, "3", "aai-node-type", "vserver", "vserver-id", "vserver-id-0", "vserver-name", "vserver-name-0");
+ Vertex tenant = graph.addVertex(T.label, "tenant", T.id, "4", "aai-node-type", "tenant", "tenant-id", "tenantid01", "tenant-name", "tenantName01");
+ Vertex cloudregion = graph.addVertex(T.label, "cloud-region", T.id, "5", "aai-node-type", "cloud-region", "cloud-region-id", "cloud-region-id-0", "cloud-region-owner", "cloud-owner-name-0","cloud-region-version","cloud-region-version-0");
+
+ Vertex vfmodule = graph.addVertex(T.label, "vf-module", T.id, "6", "aai-node-type", "vf-module", "vf-module-id", "vf-module-id-0", "vf-module-name", "vf-module-name0");
+ Vertex gnvf = graph.addVertex(T.label, "generic-vnf", T.id, "7", "aai-node-type", "generic-vnf", "vnf-id", "vnf-id-0", "vnf-name", "vnf-name-0");
+
+
+ Vertex lInterface1 = graph.addVertex(T.label, "l-interface", T.id, "12", "aai-node-type", "l-interface", "interface-name", "interface-name-1");
+ Vertex vserver1 = graph.addVertex(T.label, "vserver", T.id, "13", "aai-node-type", "vserver", "vserver-id", "vserver-id-1", "vserver-name", "vserver-name-1");
+ Vertex tenant1 = graph.addVertex(T.label, "tenant", T.id, "14", "aai-node-type", "tenant", "tenant-id", "tenantid11", "tenant-name", "tenantName11");
+ Vertex cloudregion1 = graph.addVertex(T.label, "cloud-region", T.id, "15", "aai-node-type", "cloud-region", "cloud-region-id", "cloud-region-id-1", "cloud-region-owner", "cloud-owner-name-1","cloud-region-version","cloud-region-version-1");
+
+ Vertex vfmodule1 = graph.addVertex(T.label, "vf-module", T.id, "16", "aai-node-type", "vf-module", "vf-module-id", "vf-module-id-1", "vf-module-name", "vf-module-name1");
+ Vertex gnvf1 = graph.addVertex(T.label, "generic-vnf", T.id, "17", "aai-node-type", "generic-vnf", "vnf-id", "vnf-id-1", "vnf-name", "vnf-name-1");
+
+
+ GraphTraversalSource g = graph.traversal();
+ rules.addEdge(g, config, logicalLink);
+ rules.addEdge(g, logicalLink, lInterface,"org.onap.relationships.inventory.Source");
+ rules.addTreeEdge(g, lInterface, vserver);
+ rules.addTreeEdge(g, vserver, tenant);
+ rules.addTreeEdge(g, tenant, cloudregion);
+ rules.addEdge(g, vserver, vfmodule);
+ rules.addTreeEdge(g, vfmodule, gnvf);
+
+ rules.addEdge(g, logicalLink, lInterface1,"tosca.relationships.network.LinksTo");//false
+ rules.addTreeEdge(g, lInterface1, vserver1);//false
+ rules.addTreeEdge(g, vserver1, tenant1);//false
+ rules.addTreeEdge(g, tenant1, cloudregion1);//false
+ rules.addEdge(g, vserver1, vfmodule1);//false
+ rules.addTreeEdge(g, vfmodule1, gnvf1);//false
+
+
+ expectedResult.add(cloudregion);
+ expectedResult.add(gnvf);
+ }
+
+ @Override
+ protected String getQueryName() {
+ return "cloud-region-and-source-FromConfiguration";
+ }
+
+ @Override
+ protected void addStartNode(GraphTraversal<Vertex, Vertex> g) {
+ g.has("aai-node-type", "configuration").has("configuration-id", "configuration");
+ }
+
+ @Override
+ protected void addParam(Map<String, Object> params) {
+ return;
+ }
+
+}
diff --git a/aai-traversal/src/test/java/org/onap/aai/rest/search/CloudRegionFromVnfTest.java b/aai-traversal/src/test/java/org/onap/aai/rest/search/CloudRegionFromVnfTest.java
index e23f416..d364f34 100644
--- a/aai-traversal/src/test/java/org/onap/aai/rest/search/CloudRegionFromVnfTest.java
+++ b/aai-traversal/src/test/java/org/onap/aai/rest/search/CloudRegionFromVnfTest.java
@@ -51,17 +51,34 @@ public class CloudRegionFromVnfTest extends QueryTest {
"vserver-id", "vservId", "vserver-name", "vservName", "vserver-selflink", "me/self");
Vertex cr = graph.addVertex(T.id, "30", "aai-node-type", "cloud-region", "cloud-owner", "some guy", "cloud-region-id", "crId");
Vertex tenant = graph.addVertex(T.id, "40", "aai-node-type", "tenant", "tenant-id", "ten1", "tenant-name", "tenName");
+ Vertex pserv = graph.addVertex(T.id, "50", "aai-node-type", "pserver", "hostname", "hostname1", "in-maint", "false");
+ Vertex vserv2 = graph.addVertex(T.id, "60", "aai-node-type", "vserver",
+ "vserver-id", "vservId2", "vserver-name", "vservName2", "vserver-selflink", "me/self");
+ Vertex pserv2 = graph.addVertex(T.id, "70", "aai-node-type", "pserver", "hostname", "hostname2", "in-maint", "false");
+ Vertex tenant2 = graph.addVertex(T.id, "80", "aai-node-type", "tenant", "tenant-id", "ten2", "tenant-name", "tenName2");
+ Vertex cr2 = graph.addVertex(T.id, "90", "aai-node-type", "cloud-region", "cloud-owner", "some guy2", "cloud-region-id", "crId2");
GraphTraversalSource g = graph.traversal();
rules.addEdge(g, gv, vnfc);
rules.addEdge(g, vnfc, vserv);
+ rules.addEdge(g, vserv, pserv);
rules.addTreeEdge(g, cr, tenant);
rules.addTreeEdge(g, tenant, vserv);
+ rules.addEdge(g, gv, vserv2);
+ rules.addEdge(g, vserv2, pserv2);
+ rules.addTreeEdge(g, vserv2, tenant2);
+ rules.addTreeEdge(g, tenant2, cr2);
+ expectedResult.add(gv);
expectedResult.add(cr);
expectedResult.add(tenant);
expectedResult.add(vnfc);
expectedResult.add(vserv);
+ expectedResult.add(pserv);
+ expectedResult.add(cr2);
+ expectedResult.add(tenant2);
+ expectedResult.add(vserv2);
+ expectedResult.add(pserv2);
}
@Override
diff --git a/aai-traversal/src/test/java/org/onap/aai/rest/search/ContainmentPathQueryTest.java b/aai-traversal/src/test/java/org/onap/aai/rest/search/ContainmentPathQueryTest.java
index 01ba701..1a7edb4 100644
--- a/aai-traversal/src/test/java/org/onap/aai/rest/search/ContainmentPathQueryTest.java
+++ b/aai-traversal/src/test/java/org/onap/aai/rest/search/ContainmentPathQueryTest.java
@@ -2,7 +2,7 @@
* ============LICENSE_START=======================================================
* org.onap.aai
* ================================================================================
- * Copyright © 2017 AT&T Intellectual Property. All rights reserved.
+ * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -16,8 +16,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
* ============LICENSE_END=========================================================
- *
- * ECOMP is a trademark and service mark of AT&T Intellectual Property.
*/
package org.onap.aai.rest.search;
diff --git a/aai-traversal/src/test/java/org/onap/aai/rest/search/DestinationFromConfigurationQueryTest.java b/aai-traversal/src/test/java/org/onap/aai/rest/search/DestinationFromConfigurationQueryTest.java
new file mode 100644
index 0000000..47c7d84
--- /dev/null
+++ b/aai-traversal/src/test/java/org/onap/aai/rest/search/DestinationFromConfigurationQueryTest.java
@@ -0,0 +1,100 @@
+/**
+ * ============LICENSE_START=======================================================
+ * org.onap.aai
+ * ================================================================================
+ * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY 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.rest.search;
+
+
+import java.util.Map;
+
+import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversal;
+import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource;
+import org.apache.tinkerpop.gremlin.structure.T;
+import org.apache.tinkerpop.gremlin.structure.Vertex;
+import org.junit.Test;
+import org.onap.aai.exceptions.AAIException;
+import org.onap.aai.serialization.db.exceptions.NoEdgeRuleFoundException;
+
+public class DestinationFromConfigurationQueryTest extends QueryTest {
+
+ public DestinationFromConfigurationQueryTest() throws AAIException, NoEdgeRuleFoundException {
+ super();
+ }
+
+ @Test
+ public void test() {
+ super.run();
+ }
+
+ @Override
+ protected void createGraph() throws AAIException, NoEdgeRuleFoundException {
+ //Set up the test graph
+ Vertex config = graph.addVertex(T.label, "configuration", T.id, "0", "aai-node-type", "configuration", "configuration-id", "configuration");
+ Vertex logicalLink = graph.addVertex(T.label, "l", T.id, "1", "aai-node-type", "logical-link", "link-name", "link-name-0");
+ Vertex lInterface = graph.addVertex(T.label, "l-interface", T.id, "2", "aai-node-type", "l-interface", "interface-name", "interface-name-0");
+ Vertex vserver = graph.addVertex(T.label, "vserver", T.id, "3", "aai-node-type", "vserver", "vserver-id", "vserver-id-0", "vserver-name", "vserver-name-0");
+ Vertex vfmodule = graph.addVertex(T.label, "vf-module", T.id, "4", "aai-node-type", "vf-module", "vf-module-id", "vf-module-id-0", "vf-module-name", "vf-module-name0");
+
+ Vertex gnvf = graph.addVertex(T.label, "generic-vnf", T.id, "5", "aai-node-type", "generic-vnf", "vnf-id", "vnf-id-0", "vnf-name", "vnf-name-0");
+
+ Vertex logicalLink1 = graph.addVertex(T.label, "l", T.id, "11", "aai-node-type", "logical-link", "link-name", "link-name-1");
+ Vertex lInterface1 = graph.addVertex(T.label, "l-interface", T.id, "12", "aai-node-type", "l-interface", "interface-name", "interface-name-1");
+ Vertex vserver1 = graph.addVertex(T.label, "vserver", T.id, "13", "aai-node-type", "vserver", "vserver-id", "vserver-id-1", "vserver-name", "vserver-name-1");
+ Vertex vfmodule1 = graph.addVertex(T.label, "vf-module", T.id, "14", "aai-node-type", "vf-module", "vf-module-id", "vf-module-id-1", "vf-module-name", "vf-module-name1");
+
+ Vertex gnvf1 = graph.addVertex(T.label, "generic-vnf", T.id, "15", "aai-node-type", "generic-vnf", "vnf-id", "vnf-id-1", "vnf-name", "vnf-name-1");
+ Vertex pnf1 = graph.addVertex(T.label, "pnf", T.id, "16", "aai-node-type", "pnf", "pnf-name", "pnfname-1");
+
+
+ GraphTraversalSource g = graph.traversal();
+ rules.addEdge(g, config, logicalLink);
+ rules.addEdge(g, logicalLink, lInterface,"org.onap.relationships.inventory.Destination");
+ rules.addTreeEdge(g, lInterface, vserver);
+ rules.addEdge(g, vserver, vfmodule);
+ rules.addTreeEdge(g, vfmodule, gnvf);
+
+ rules.addEdge(g, logicalLink, lInterface1,"tosca.relationships.network.LinksTo");//false
+ rules.addTreeEdge(g, lInterface1, vserver1);//false
+ rules.addEdge(g, vserver1, vfmodule1);//false
+ rules.addTreeEdge(g, vfmodule1, gnvf1);//false
+
+ rules.addEdge(g, config, logicalLink1);
+ rules.addEdge(g, logicalLink1, gnvf1);
+ rules.addEdge(g, gnvf1, pnf1);
+
+
+ expectedResult.add(gnvf);
+ expectedResult.add(pnf1);
+ }
+
+ @Override
+ protected String getQueryName() {
+ return "destination-FromConfiguration";
+ }
+
+ @Override
+ protected void addStartNode(GraphTraversal<Vertex, Vertex> g) {
+ g.has("aai-node-type", "configuration").has("configuration-id", "configuration");
+ }
+
+ @Override
+ protected void addParam(Map<String, Object> params) {
+ return;
+ }
+
+}
diff --git a/aai-traversal/src/test/java/org/onap/aai/rest/search/GetClfiRoadmTailSummaryTest.java b/aai-traversal/src/test/java/org/onap/aai/rest/search/GetClfiRoadmTailSummaryTest.java
new file mode 100644
index 0000000..9ddd2e3
--- /dev/null
+++ b/aai-traversal/src/test/java/org/onap/aai/rest/search/GetClfiRoadmTailSummaryTest.java
@@ -0,0 +1,105 @@
+/**
+ * ============LICENSE_START=======================================================
+ * org.onap.aai
+ * ================================================================================
+ * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY 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.rest.search;
+
+import java.util.Map;
+
+import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversal;
+import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource;
+import org.apache.tinkerpop.gremlin.structure.T;
+import org.apache.tinkerpop.gremlin.structure.Vertex;
+import org.junit.Test;
+import org.onap.aai.exceptions.AAIException;
+import org.onap.aai.serialization.db.exceptions.NoEdgeRuleFoundException;
+
+public class GetClfiRoadmTailSummaryTest extends QueryTest {
+
+ public GetClfiRoadmTailSummaryTest() throws AAIException, NoEdgeRuleFoundException {
+ super();
+ }
+
+ @Test
+ public void run() {
+ super.run();
+ }
+
+ @Override
+ protected void createGraph() throws AAIException, NoEdgeRuleFoundException {
+ Vertex serviceInstance = graph.addVertex(T.label, "service-instance", T.id, "1", "aai-node-type", "service-instance",
+ "service-instance-id", "service-instance-id-1", "service-instance-name", "service-instance-name-1");
+ Vertex serviceSubscription = graph.addVertex(T.label, "service-subscription", T.id, "2", "aai-node-type", "service-subscription",
+ "service-type", "service-subcription-1");
+ Vertex customer = graph.addVertex(T.label, "customer", T.id, "3", "aai-node-type", "customer", ""
+ + "global-customer-id", "customer-id-1", "subscriber-name", "customer-name1", "subscriber-type", "customer-type1");
+ Vertex logicalLink1 = graph.addVertex(T.label, "logical-link", T.id, "4", "aai-node-type", "logical-link", "link-name", "logical-link-1");
+ Vertex logicalLink2 = graph.addVertex(T.label, "logical-link", T.id, "5", "aai-node-type", "logical-link", "link-name", "logical-link-2");
+ Vertex pInterface1 = graph.addVertex(T.label, "p-interface", T.id, "6", "aai-node-type", "p-interface", "interface-name", "p-interface-1");
+ Vertex pInterface2 = graph.addVertex(T.label, "p-interface", T.id, "7", "aai-node-type", "p-interface", "interface-name", "p-interface-2");
+ Vertex pInterface3 = graph.addVertex(T.label, "p-interface", T.id, "8", "aai-node-type", "p-interface", "interface-name", "p-interface-3");
+ Vertex pnf1 = graph.addVertex(T.label, "pnf", T.id, "9", "aai-node-type", "pnf", "pnf-name", "pnf1name");
+ Vertex pnf2 = graph.addVertex(T.label, "pnf", T.id, "10", "aai-node-type", "pnf", "pnf-name", "pnf2name");
+
+ Vertex lInterface1 = graph.addVertex(T.label, "l-interface", T.id, "11", "aai-node-type", "l-interface", "interface-name", "l-interface-1");
+
+ GraphTraversalSource g = graph.traversal();
+ rules.addTreeEdge(g, customer, serviceSubscription);
+ rules.addTreeEdge(g, serviceSubscription, serviceInstance);
+
+ rules.addEdge(g, serviceInstance, logicalLink1);
+ rules.addEdge(g, logicalLink2, logicalLink1);
+ rules.addEdge(g, logicalLink2, pInterface1);
+ rules.addEdge(g, logicalLink2, pInterface2);
+ rules.addEdge(g, logicalLink2, pInterface3);
+
+ rules.addTreeEdge(g, pnf1, pInterface1);
+ rules.addTreeEdge(g, pnf2, pInterface2);
+ rules.addTreeEdge(g, pnf2, pInterface3);
+
+ rules.addEdge(g, logicalLink1, lInterface1);//false
+
+ expectedResult.add(logicalLink1);
+ expectedResult.add(pInterface1);
+ expectedResult.add(pnf1);
+ expectedResult.add(pInterface2);
+ expectedResult.add(pInterface3);
+ expectedResult.add(pnf2);
+ expectedResult.add(logicalLink2);
+ expectedResult.add(serviceInstance);
+ expectedResult.add(serviceSubscription);
+ expectedResult.add(customer);
+ }
+
+ @Override
+ protected String getQueryName() {
+ return "getClfiRoadmTailSummary";
+ }
+
+ @Override
+ protected void addStartNode(GraphTraversal<Vertex, Vertex> g) {
+ g.has("aai-node-type", "logical-link").has("link-name", "logical-link-2");
+ }
+
+ @Override
+ protected void addParam(Map<String, Object> params) {
+ return;
+ }
+
+
+}
diff --git a/aai-traversal/src/test/java/org/onap/aai/rest/search/GetComplexByPnfNameQueryTest.java b/aai-traversal/src/test/java/org/onap/aai/rest/search/GetComplexByPnfNameQueryTest.java
new file mode 100644
index 0000000..1d79466
--- /dev/null
+++ b/aai-traversal/src/test/java/org/onap/aai/rest/search/GetComplexByPnfNameQueryTest.java
@@ -0,0 +1,75 @@
+/**
+ * ============LICENSE_START=======================================================
+ * org.onap.aai
+ * ================================================================================
+ * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY 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.rest.search;
+
+import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversal;
+import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource;
+import org.apache.tinkerpop.gremlin.structure.T;
+import org.apache.tinkerpop.gremlin.structure.Vertex;
+import org.junit.Test;
+import org.onap.aai.exceptions.AAIException;
+import org.onap.aai.serialization.db.exceptions.NoEdgeRuleFoundException;
+
+import java.util.Map;
+
+public class GetComplexByPnfNameQueryTest extends QueryTest {
+ public GetComplexByPnfNameQueryTest () throws AAIException, NoEdgeRuleFoundException {
+ super();
+ }
+
+ @Test
+ public void run() {
+ super.run();
+ }
+
+ @Override
+ protected void createGraph() throws AAIException, NoEdgeRuleFoundException {
+
+ // Set up the test graph
+ Vertex pnf1 = graph.addVertex(T.label, "pnf", T.id, "0", "aai-node-type", "pnf", "pnf-name", "pnf1name", "equip-vendor", "equip-vendor1", "equip-model","equip-model1");
+ Vertex complex1 = graph.addVertex(T.label, "complex", T.id, "1", "aai-node-type", "complex", "physical-location-id", "physical-location-id-1");
+
+ // adding extra vertices and edges which shouldn't be picked.
+ Vertex pnf2 = graph.addVertex(T.label, "pnf", T.id, "2", "aai-node-type", "pnf", "pnf-name", "pnf2name", "equip-vendor", "equip-vendor2", "equip-model","equip-model2");
+ Vertex complex2 = graph.addVertex(T.label, "complex", T.id, "3", "aai-node-type", "complex", "physical-location-id", "physical-location-id-2");
+
+ GraphTraversalSource g = graph.traversal();
+ rules.addEdge(g, pnf1, complex1);
+ rules.addEdge(g, pnf2, complex2);
+
+ expectedResult.add(pnf1);
+ expectedResult.add(complex1);
+ }
+
+ @Override
+ protected String getQueryName() {
+ return "getComplexByPnfName";
+ }
+
+ @Override
+ protected void addStartNode(GraphTraversal<Vertex, Vertex> g) {
+ g.has("aai-node-type", "pnf").has("pnf-name", "pnf1name");
+ }
+
+ @Override
+ protected void addParam(Map<String, Object> params) {
+ return;
+ }
+}
diff --git a/aai-traversal/src/test/java/org/onap/aai/rest/search/GetComplexFromHostnameQueryTest.java b/aai-traversal/src/test/java/org/onap/aai/rest/search/GetComplexFromHostnameQueryTest.java
new file mode 100644
index 0000000..694b1c5
--- /dev/null
+++ b/aai-traversal/src/test/java/org/onap/aai/rest/search/GetComplexFromHostnameQueryTest.java
@@ -0,0 +1,77 @@
+/**
+ * ============LICENSE_START=======================================================
+ * org.onap.aai
+ * ================================================================================
+ * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY 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.rest.search;
+
+import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversal;
+import org.apache.tinkerpop.gremlin.process.traversal.step.util.Tree;
+import org.apache.tinkerpop.gremlin.structure.T;
+import org.apache.tinkerpop.gremlin.structure.Vertex;
+import org.junit.Test;
+import org.onap.aai.exceptions.AAIException;
+import org.onap.aai.serialization.db.exceptions.NoEdgeRuleFoundException;
+
+import java.util.Map;
+
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+
+public class GetComplexFromHostnameQueryTest extends TreeQueryTest {
+ public GetComplexFromHostnameQueryTest () throws AAIException, NoEdgeRuleFoundException {
+ super();
+ }
+
+ @SuppressWarnings("rawtypes")
+ @Test
+ public void run() {
+ super.run();
+ Tree tree = treeList.get(0);
+ Vertex pserver1 = graph.traversal().V().has("aai-node-type","pserver").has("hostname","pserver-name-1").next();
+ Vertex pserver2 = graph.traversal().V().has("aai-node-type","pserver").has("hostname","pserver-name-2").next();
+ Vertex complex1 = graph.traversal().V().has("aai-node-type", "complex").has( "physical-location-id", "physical-location-id-1").next();
+ assertTrue(tree.containsKey(pserver1));
+ assertTrue(((Tree) tree.get(pserver1)).containsKey(complex1));
+ assertFalse(tree.containsKey(pserver2));
+ }
+
+ @Override
+ protected void createGraph() throws AAIException, NoEdgeRuleFoundException {
+
+ // Set up the test graph
+ Vertex pserver1 = graph.addVertex(T.label, "pserver", T.id, "0", "aai-node-type", "pserver", "hostname", "pserver-name-1");
+ Vertex pserver2 = graph.addVertex(T.label, "pserver", T.id, "4", "aai-node-type", "pserver", "hostname", "pserver-name-2");
+ Vertex complex1 = graph.addVertex(T.label, "complex", T.id, "1", "aai-node-type", "complex", "physical-location-id", "physical-location-id-1");
+ rules.addEdge(gts, pserver1, complex1);
+ rules.addEdge(gts, pserver2, complex1);
+ }
+
+ @Override
+ protected String getQueryName() {
+ return "getComplexFromHostname";
+ }
+
+ @Override
+ protected void addStartNode(GraphTraversal<Vertex, Vertex> g) {
+ g.has("aai-node-type", "pserver").has("hostname", "pserver-name-1");
+ }
+
+ @Override
+ protected void addParam(Map<String, Object> params) {
+ }
+}
diff --git a/aai-traversal/src/test/java/org/onap/aai/rest/search/GetDHVLogicalLinkTest.java b/aai-traversal/src/test/java/org/onap/aai/rest/search/GetDHVLogicalLinkTest.java
new file mode 100644
index 0000000..6659d20
--- /dev/null
+++ b/aai-traversal/src/test/java/org/onap/aai/rest/search/GetDHVLogicalLinkTest.java
@@ -0,0 +1,116 @@
+/**
+ * ============LICENSE_START=======================================================
+ * org.onap.aai
+ * ================================================================================
+ * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY 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.rest.search;
+
+import java.util.Map;
+
+import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversal;
+import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource;
+import org.apache.tinkerpop.gremlin.process.traversal.step.util.Tree;
+import org.apache.tinkerpop.gremlin.structure.T;
+import org.apache.tinkerpop.gremlin.structure.Vertex;
+import org.junit.Test;
+import org.onap.aai.exceptions.AAIException;
+import org.onap.aai.serialization.db.exceptions.NoEdgeRuleFoundException;
+
+import static org.junit.Assert.*;
+
+public class GetDHVLogicalLinkTest extends TreeQueryTest {
+ public GetDHVLogicalLinkTest() throws AAIException, NoEdgeRuleFoundException {
+ super();
+ }
+
+ @Test
+ public void run() {
+ super.run();
+
+ Tree tree = treeList.get(0);
+ Vertex gvnf1 = graph.traversal().V().has("aai-node-type", "generic-vnf").has("vnfname", "vnfname1").next();
+ Vertex linterface1 = graph.traversal().V().has("aai-node-type", "l-interface").has("network-name", "networkName1").next();
+ Vertex vlan1 = graph.traversal().V().has("aai-node-type", "vlan").has("vlan-interface", "vlan-interface1").next();
+ Vertex logicalLink1 = graph.traversal().V().has("aai-node-type", "logical-link").has("link-type", "linkType1").next();
+
+ Vertex gvnf2 = graph.traversal().V().has("aai-node-type", "generic-vnf").has("vnfname", "vnfname2").next();
+
+ assertTrue(tree.containsKey(gvnf1));
+ assertTrue(((Tree) tree.get(gvnf1)).containsKey(linterface1));
+ assertTrue(((Tree)(((Tree) tree.get(gvnf1)).get(linterface1))).containsKey(vlan1));
+ assertTrue(((Tree)((Tree)(((Tree) tree.get(gvnf1)).get(linterface1))).get(vlan1)).containsKey(logicalLink1));
+
+ assertFalse(tree.containsKey(gvnf2));
+ }
+ @Override
+ protected void createGraph() throws AAIException, NoEdgeRuleFoundException {
+
+
+ //Set up the test graph
+ Vertex gvnf1 = graph.addVertex(T.label, "generic-vnf", T.id, "0", "aai-node-type", "generic-vnf", "vnfname", "vnfname1", "vnf-name", "vnfname1", "vnf-type", "vnftype1");
+
+
+ Vertex linterface1 = graph.addVertex(T.label, "l-interface", T.id, "1", "aai-node-type", "l-interface",
+ "l-interface-id", "l-interface-id0", "l-interface-name", "l-interface-name1","network-name","networkName1");
+
+ Vertex vlan1 = graph.addVertex(T.label, "vlan", T.id, "2", "aai-node-type", "vlan", "vlan-interface", "vlan-interface1");
+
+ Vertex logicalLink1 = graph.addVertex(T.label, "logical-link", T.id, "3", "aai-node-type", "logical-link",
+ "link-name", "linkName1", "in-maint", "false", "link-type","linkType1");
+
+ //Set up the test graph for false test cases
+ Vertex gvnf2 = graph.addVertex(T.label, "generic-vnf", T.id, "4", "aai-node-type", "generic-vnf", "vnfname", "vnfname2", "vnf-name", "vnfname2", "vnf-type", "vnftype2");
+
+
+ Vertex linterface2 = graph.addVertex(T.label, "l-interface", T.id, "5", "aai-node-type", "l-interface",
+ "l-interface-id", "l-interface-id2", "l-interface-name", "l-interface-name2","network-name","networkName2");
+
+ Vertex vlan2 = graph.addVertex(T.label, "vlan", T.id, "6", "aai-node-type", "vlan", "vlan-interface", "vlan-interface2");
+
+ Vertex logicalLink2 = graph.addVertex(T.label, "logical-link", T.id, "7", "aai-node-type", "logical-link",
+ "link-name", "linkName2", "in-maint", "false", "link-type","linkType2");
+
+
+ //GraphTraversalSource g = graph.traversal();
+
+ rules.addTreeEdge(gts, gvnf1, linterface1); // true
+ rules.addTreeEdge(gts, linterface1, vlan1); // true
+ rules.addEdge(gts, vlan1, logicalLink1); // true
+
+ rules.addTreeEdge(gts, gvnf2, linterface2); // false
+ rules.addTreeEdge(gts, linterface2, vlan2); // false
+ rules.addEdge(gts, vlan2, logicalLink2); // false
+
+ expectedResult.add(gvnf1);
+ expectedResult.add(linterface1);
+ expectedResult.add(vlan1);
+ expectedResult.add(logicalLink1);
+
+ }
+ @Override
+ protected String getQueryName() {
+ return "getDHVLogicalLink";
+ }
+ @Override
+ protected void addStartNode(GraphTraversal<Vertex, Vertex> g) {
+ g.has("aai-node-type", "generic-vnf").has("vnfname", "vnfname1"); }
+
+ @Override
+ protected void addParam(Map<String, Object> params) {
+ return;
+ }
+}
diff --git a/aai-traversal/src/test/java/org/onap/aai/rest/search/GetL3networkCloudRegionByNetworkRoleQueryTest.java b/aai-traversal/src/test/java/org/onap/aai/rest/search/GetL3networkCloudRegionByNetworkRoleQueryTest.java
new file mode 100644
index 0000000..a9fedcd
--- /dev/null
+++ b/aai-traversal/src/test/java/org/onap/aai/rest/search/GetL3networkCloudRegionByNetworkRoleQueryTest.java
@@ -0,0 +1,91 @@
+/**
+ * ============LICENSE_START=======================================================
+ * org.onap.aai
+ * ================================================================================
+ * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY 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.rest.search;
+
+import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversal;
+import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource;
+import org.apache.tinkerpop.gremlin.structure.T;
+import org.apache.tinkerpop.gremlin.structure.Vertex;
+import org.junit.Test;
+import org.onap.aai.exceptions.AAIException;
+import org.onap.aai.serialization.db.exceptions.NoEdgeRuleFoundException;
+
+import java.util.Map;
+
+public class GetL3networkCloudRegionByNetworkRoleQueryTest extends QueryTest {
+ public GetL3networkCloudRegionByNetworkRoleQueryTest () throws AAIException, NoEdgeRuleFoundException {
+ super();
+ }
+
+ @Test
+ public void run() {
+ super.run();
+ }
+
+ @Override
+ protected void createGraph() throws AAIException, NoEdgeRuleFoundException {
+
+ // Set up the test graph
+ Vertex l3Network1 = graph.addVertex(T.label, "l3-network", T.id, "0", "aai-node-type", "l3-network", "network-id", "networkId1", "network-name", "networkName1", "network-role","networkRole1");
+ Vertex genericVnf1 = graph.addVertex(T.label, "generic-vnf", T.id, "1", "aai-node-type", "generic-vnf", "vnf-id", "vnfId1", "vnf-name", "vnfName1", "vnf-type", "vnfType1");
+ Vertex vserver1 = graph.addVertex(T.label, "vserver", T.id, "2", "aai-node-type", "vserver", "vserver-id", "vserverId1", "vserver-name", "vserverName1", "vserver-selflink", "vserverSelfLink1");
+ Vertex tenant1 = graph.addVertex(T.label, "tenant", T.id, "3", "aai-node-type", "tenant", "tenant-id", "tenantId1", "tenant-name" ,"tenantName1");
+ Vertex cloudRegion1 = graph.addVertex(T.label, "cloud-region", T.id, "4", "aai-node-type", "cloud-region", "cloud-owner", "cloudOwner1", "cloud-region-id", "cloudRegionId1");
+
+ // adding extra vertices and edges which shouldn't be picked.
+ Vertex l3Network2 = graph.addVertex(T.label, "l3-network", T.id, "5", "aai-node-type", "l3-network", "network-id", "networkId2", "network-name", "networkName2", "network-role","networkRole2");
+ Vertex genericVnf2 = graph.addVertex(T.label, "generic-vnf", T.id, "6", "aai-node-type", "generic-vnf", "vnf-id", "vnfId2", "vnf-name", "vnfName2", "vnf-type", "vnfType2");
+ Vertex vserver2 = graph.addVertex(T.label, "vserver", T.id, "7", "aai-node-type", "vserver", "vserver-id", "vserverId2", "vserver-name", "vserverName2", "vserver-selflink", "vserverSelfLink2");
+ Vertex tenant2 = graph.addVertex(T.label, "tenant", T.id, "8", "aai-node-type", "tenant", "tenant-id", "tenantId2", "tenant-name" ,"tenantName2");
+ Vertex cloudRegion2 = graph.addVertex(T.label, "cloud-region", T.id, "9", "aai-node-type", "cloud-region", "cloud-owner", "cloudOwner2", "cloud-region-id", "cloudRegionId2");
+
+ GraphTraversalSource g = graph.traversal();
+ rules.addEdge(g, l3Network1, genericVnf1);
+ rules.addEdge(g, genericVnf1, vserver1);
+ rules.addTreeEdge(g, vserver1, tenant1);
+ rules.addTreeEdge(g, tenant1, cloudRegion1);
+
+ rules.addEdge(g, l3Network2, genericVnf2);
+ rules.addEdge(g, genericVnf2, vserver2);
+ rules.addTreeEdge(g, vserver2, tenant2);
+ rules.addTreeEdge(g, tenant2, cloudRegion2);
+
+ expectedResult.add(l3Network1);
+ expectedResult.add(genericVnf1);
+ expectedResult.add(vserver1);
+ expectedResult.add(tenant1);
+ expectedResult.add(cloudRegion1);
+ }
+
+ @Override
+ protected String getQueryName() {
+ return "getL3networkCloudRegionByNetworkRole";
+ }
+
+ @Override
+ protected void addStartNode(GraphTraversal<Vertex, Vertex> g) {
+ g.has("aai-node-type", "l3-network").has("network-id", "networkId1").has("network-role", "networkRole1");
+ }
+
+ @Override
+ protected void addParam(Map<String, Object> params) {
+ return;
+ }
+}
diff --git a/aai-traversal/src/test/java/org/onap/aai/rest/search/GetLinterfaceFromNewvceTest.java b/aai-traversal/src/test/java/org/onap/aai/rest/search/GetLinterfaceFromNewvceTest.java
new file mode 100644
index 0000000..fbb77b8
--- /dev/null
+++ b/aai-traversal/src/test/java/org/onap/aai/rest/search/GetLinterfaceFromNewvceTest.java
@@ -0,0 +1,121 @@
+/**
+ * ============LICENSE_START=======================================================
+ * org.onap.aai
+ * ================================================================================
+ * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY 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.rest.search;
+
+import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversal;
+import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource;
+import org.apache.tinkerpop.gremlin.structure.T;
+import org.apache.tinkerpop.gremlin.structure.Vertex;
+import org.junit.Test;
+import org.onap.aai.exceptions.AAIException;
+import org.onap.aai.serialization.db.exceptions.NoEdgeRuleFoundException;
+
+import java.util.Map;
+
+public class GetLinterfaceFromNewvceTest extends QueryTest {
+ public GetLinterfaceFromNewvceTest () throws AAIException, NoEdgeRuleFoundException {
+ super();
+ }
+
+ @Test
+ public void run() {
+ super.run();
+ }
+
+ @Override
+ protected void createGraph() throws AAIException, NoEdgeRuleFoundException {
+
+ // Set up the test graph
+ Vertex newvce = graph.addVertex(T.label, "newvce", T.id, "0", "aai-node-type", "newvce", "vnf-id2", "vnfId2-1", "vnf-name", "vnfName-1", "vnf-type", "vnfType-1");
+ Vertex linterfaceNewvce1 = graph.addVertex(T.label, "l-interface", T.id, "1", "aai-node-type", "l-interface", "l-interface-id", "lInterfaceId-10",
+ "l-interface-name", "lInterfaceName-1", "interface-role", "UPLINK");
+ Vertex linterfaceNewvce2 = graph.addVertex(T.label, "l-interface", T.id, "2", "aai-node-type", "l-interface", "l-interface-id", "lInterfaceId-20",
+ "l-interface-name", "lInterfaceName-1", "interface-role", "CUSTOMER");
+ Vertex linterfaceNewvce3 = graph.addVertex(T.label, "l-interface", T.id, "3", "aai-node-type", "l-interface", "l-interface-id", "lInterfaceId-30",
+ "l-interface-name", "lInterfaceName-3", "interface-role", "CUSTOMER-UPLINK");
+
+ Vertex logicalLink1 = graph.addVertex(T.label, "logical-link", T.id, "4", "aai-node-type", "logical-link", "link-name", "linkName-1", "in-maint", "false", "link-type","linkType-1");
+
+ // 1 generic-vnf with 2 lags each has 1 linterface
+ Vertex genericvnf1 = graph.addVertex(T.label, "generic-vnf", T.id, "5", "aai-node-type", "generic-vnf", "vnf-id", "vnfId-1","vnf-name", "vnfName-1");
+ Vertex lagint1 = graph.addVertex(T.label, "lag-interface", T.id, "6", "aai-node-type", "lag-interface","interface-name", "lagIntName-1");
+ Vertex linterface1 = graph.addVertex(T.label, "l-interface", T.id, "7", "aai-node-type", "l-interface", "l-interface-id", "lInterfaceId-1",
+ "l-interface-name", "lInterfaceName-1", "interface-role", "CUSTOMER");
+
+ Vertex linterface2 = graph.addVertex(T.label, "l-interface", T.id, "9", "aai-node-type", "l-interface", "l-interface-id", "lInterfaceId-2",
+ "l-interface-name", "lInterfaceName-2", "interface-role", "CUSTOMER-UPLINK");
+ Vertex linterface3 = graph.addVertex(T.label, "l-interface", T.id, "10", "aai-node-type", "l-interface", "l-interface-id", "lInterfaceId-3",
+ "l-interface-name", "lInterfaceName-3", "interface-role", "UPLINK");
+ Vertex linterface4 = graph.addVertex(T.label, "l-interface", T.id, "11", "aai-node-type", "l-interface", "l-interface-id", "lInterfaceId-4", "l-interface-name", "lInterfaceName-4", "interface-role", "CUSTOMER-UPLINK");
+
+ Vertex lagint2 = graph.addVertex(T.label, "lag-interface", T.id, "8", "aai-node-type", "lag-interface","interface-name", "lagIntName-2");
+ Vertex linterface21 = graph.addVertex(T.label, "l-interface", T.id, "20", "aai-node-type", "l-interface", "l-interface-id", "lInterfaceId-21",
+ "l-interface-name", "lInterfaceName-2", "interface-role", "CUSTOMER-UPLINK");
+
+ Vertex genericvnf2 = graph.addVertex(T.label, "generic-vnf", T.id, "12", "aai-node-type", "generic-vnf", "vnf-id", "vnfId-2","vnf-name", "vnfName-2");
+ Vertex linterface31 = graph.addVertex(T.label, "l-interface", T.id, "13", "aai-node-type", "l-interface", "l-interface-id", "lInterfaceId-21", "l-interface-name", "lInterfaceName-21", "interface-role", "CUSTOMER-UPLINK");
+ Vertex lagint3 = graph.addVertex(T.label, "lag-interface", T.id, "14", "aai-node-type", "lag-interface","interface-name", "lagIntName-22");
+
+
+ GraphTraversalSource g = graph.traversal();
+ rules.addTreeEdge(g, newvce, linterfaceNewvce1); // true
+ rules.addTreeEdge(g, newvce, linterfaceNewvce2);
+ rules.addTreeEdge(g, newvce, linterfaceNewvce3);
+ rules.addEdge(g, linterfaceNewvce1, logicalLink1); // true
+ rules.addEdge(g, linterfaceNewvce2, logicalLink1);
+
+ rules.addTreeEdge(g, genericvnf1, lagint1);
+ rules.addTreeEdge(g, lagint1, linterface1);
+
+ rules.addTreeEdge(g, lagint1, linterface2); // true
+ rules.addTreeEdge(g, lagint1, linterface3);
+ rules.addTreeEdge(g, lagint1, linterface4); // true
+ rules.addTreeEdge(g, lagint2, linterface21);
+
+ rules.addEdge(g, linterface2, logicalLink1); // true
+ rules.addEdge(g, linterface4, logicalLink1); // true
+ rules.addEdge(g, linterface21, logicalLink1); // true
+
+ rules.addTreeEdge(g, genericvnf2, lagint3);
+ rules.addTreeEdge(g, lagint2, linterface31);
+
+
+ expectedResult.add(linterface2);
+ expectedResult.add(linterface4);
+ expectedResult.add(linterface21);
+
+ }
+
+ @Override
+ protected String getQueryName() {
+ return "getLinterface-fromNewvce";
+ }
+
+ @Override
+ protected void addStartNode(GraphTraversal<Vertex, Vertex> g) {
+ g.has("aai-node-type", "newvce").has("vnf-id2", "vnfId2-1");
+ }
+
+ @Override
+ protected void addParam(Map<String, Object> params) {
+ params.put("interfaceRole1", "UPLINK");
+ params.put("interfaceRole2", "CUSTOMER-UPLINK");
+ }
+} \ No newline at end of file
diff --git a/aai-traversal/src/test/java/org/onap/aai/rest/search/GetNetworksTest.java b/aai-traversal/src/test/java/org/onap/aai/rest/search/GetNetworksTest.java
new file mode 100644
index 0000000..8e34236
--- /dev/null
+++ b/aai-traversal/src/test/java/org/onap/aai/rest/search/GetNetworksTest.java
@@ -0,0 +1,92 @@
+package org.onap.aai.rest.search;
+/**
+ * ============LICENSE_START=======================================================
+ * org.onap.aai
+ * ================================================================================
+ * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+import java.util.Map;
+
+import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversal;
+import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource;
+import org.apache.tinkerpop.gremlin.structure.T;
+import org.apache.tinkerpop.gremlin.structure.Vertex;
+import org.junit.Test;
+import org.onap.aai.exceptions.AAIException;
+import org.onap.aai.serialization.db.exceptions.NoEdgeRuleFoundException;
+
+public class GetNetworksTest extends QueryTest {
+
+ public GetNetworksTest() throws AAIException, NoEdgeRuleFoundException {
+ super();
+ }
+
+ @Test
+ public void test() {
+ super.run();
+ }
+
+ @Override
+ protected void createGraph() throws AAIException, NoEdgeRuleFoundException {
+ //Set up the test graph
+ Vertex owningentity = graph.addVertex(T.label, "owning-entity", T.id, "1", "aai-node-type", "owning-entity", "owning-entity-id", "owning-entity-id-0", "owning-entity-name", "owning-entity-name-0");
+ Vertex serviceinstance = graph.addVertex(T.label, "service-instance", T.id, "2", "aai-node-type", "service-instance", "service-instance-id", "service-instance-id-0");
+ Vertex l3network = graph.addVertex(T.label, "l3-network", T.id, "3", "aai-node-type", "l3-network", "network-id", "network-id-0", "network-role", "network-role-0", "is-bound-to-vpn", "false", "is-provider-network", "false", "is-shared-network", "false", "is-external-network", "false");
+ Vertex cloudregion = graph.addVertex(T.label, "cloud-region", T.id, "10", "aai-node-type", "cloud-region", "cloud-region-id", "cloud-region-id-0", "cloud-region-owner", "cloud-owner-name-0","cloud-region-version","cloud-region-version-0");
+ Vertex l3network2 = graph.addVertex(T.label, "l3-network", T.id, "8", "aai-node-type", "l3-network", "network-id", "network-id-2", "network-role", "network-role-2", "is-bound-to-vpn", "false", "is-provider-network", "false", "is-shared-network", "false", "is-external-network", "false");
+ Vertex l3network3 = graph.addVertex(T.label, "l3-network", T.id, "9", "aai-node-type", "l3-network", "network-id", "network-id-0", "network-role", "network-role-3", "is-bound-to-vpn", "false", "is-provider-network", "false", "is-shared-network", "false", "is-external-network", "false");
+ Vertex cloudregion2 = graph.addVertex(T.label, "cloud-region", T.id, "11", "aai-node-type", "cloud-region", "cloud-region-id", "cloud-region-id-2", "cloud-region-owner", "cloud-owner-name-0","cloud-region-version","cloud-region-version-0");
+
+ Vertex owningentity1 = graph.addVertex(T.label, "owning-entity", T.id, "4", "aai-node-type", "owning-entity", "owning-entity-id", "owning-entity-id-1", "owning-entity-name", "owning-entity-name-1");
+ Vertex serviceinstance1 = graph.addVertex(T.label, "service-instance", T.id, "5", "aai-node-type", "service-instance", "service-instance-id", "service-instance-id-1");
+ Vertex l3network1 = graph.addVertex(T.label, "l3-network", T.id, "6", "aai-node-type", "l3-network", "network-id", "network-id-1", "is-bound-to-vpn", "false", "is-provider-network", "false", "is-shared-network", "false", "is-external-network", "false");
+ Vertex cloudregion1 = graph.addVertex(T.label, "cloud-region", T.id, "7", "aai-node-type", "cloud-region", "cloud-region-id", "cloud-region-id-1", "cloud-region-owner", "cloud-owner-name-1","cloud-region-version","cloud-region-version-1");
+
+
+ GraphTraversalSource g = graph.traversal();
+ rules.addEdge(g, owningentity, serviceinstance);
+ rules.addEdge(g, serviceinstance, l3network);
+ rules.addEdge(g, l3network, cloudregion);
+ rules.addEdge(g, serviceinstance, l3network2);
+ rules.addEdge(g, l3network2, cloudregion);
+ rules.addEdge(g, l3network3, cloudregion2);
+ rules.addEdge(g, serviceinstance, l3network3);
+
+ rules.addEdge(g, owningentity1, serviceinstance1);
+ rules.addEdge(g, serviceinstance1, l3network1); //false
+ rules.addEdge(g, l3network1, cloudregion1);
+
+ expectedResult.add(l3network);
+ }
+
+ @Override
+ protected String getQueryName() {
+ return "getNetworks";
+ }
+
+ @Override
+ protected void addStartNode(GraphTraversal<Vertex, Vertex> g) {
+ g.has("aai-node-type", "owning-entity").has("owning-entity-id", "owning-entity-id-0");
+ }
+
+ @Override
+ protected void addParam(Map<String, Object> params) {
+ params.put("networkRole", "network-role-0");
+ params.put("cloudRegionId", "cloud-region-id-0");
+ }
+
+}
diff --git a/aai-traversal/src/test/java/org/onap/aai/rest/search/GetPinterfacePhysicalLinkBySvcInstIdTest.java b/aai-traversal/src/test/java/org/onap/aai/rest/search/GetPinterfacePhysicalLinkBySvcInstIdTest.java
new file mode 100644
index 0000000..b271183
--- /dev/null
+++ b/aai-traversal/src/test/java/org/onap/aai/rest/search/GetPinterfacePhysicalLinkBySvcInstIdTest.java
@@ -0,0 +1,106 @@
+/**
+ * ============LICENSE_START=======================================================
+ * org.onap.aai
+ * ================================================================================
+ * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY 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.rest.search;
+
+
+import java.util.Map;
+
+import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversal;
+import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource;
+import org.apache.tinkerpop.gremlin.structure.T;
+import org.apache.tinkerpop.gremlin.structure.Vertex;
+import org.junit.Test;
+import org.onap.aai.exceptions.AAIException;
+import org.onap.aai.serialization.db.exceptions.NoEdgeRuleFoundException;
+
+public class GetPinterfacePhysicalLinkBySvcInstIdTest extends QueryTest {
+
+ public GetPinterfacePhysicalLinkBySvcInstIdTest() throws AAIException, NoEdgeRuleFoundException {
+ super();
+ }
+
+ @Test
+ public void test() {
+ super.run();
+ }
+
+ @Override
+ protected void createGraph() throws AAIException, NoEdgeRuleFoundException {
+ //Set up the test graph
+ Vertex serviceinstance = graph.addVertex(T.label, "service-instance", T.id, "0", "aai-node-type", "service-instance", "service-instance-id", "s-instance-id1");
+ Vertex serviceinstance1 = graph.addVertex(T.label, "service-instance", T.id, "1", "aai-node-type", "service-instance", "service-instance-id", "s-instance-id2");
+
+ Vertex gnvf = graph.addVertex(T.label, "generic-vnf", T.id, "2", "aai-node-type", "generic-vnf", "vnf-id", "vnf-id-1", "vnf-name", "vnf-name-1");
+ Vertex gnvf1 = graph.addVertex(T.label, "generic-vnf", T.id, "3", "aai-node-type", "generic-vnf", "vnf-id", "vnf-id-2", "vnf-name", "vnf-name-2");
+
+ Vertex pserver = graph.addVertex(T.label, "pserver", T.id, "4", "aai-node-type", "pserver", "hostname", "pservername1");
+ Vertex pserver1 = graph.addVertex(T.label, "pserver", T.id, "5", "aai-node-type", "pserver", "hostname", "pservername2");
+
+ Vertex vserver = graph.addVertex(T.label, "vserver", T.id, "6", "aai-node-type", "vserver", "vserver-id", "vserverid1");
+ Vertex vserver1 = graph.addVertex(T.label, "vserver", T.id, "7", "aai-node-type", "vserver", "vserver-id", "vserverid2");
+
+ Vertex pInterface = graph.addVertex(T.label, "p-interface", T.id, "8", "aai-node-type", "p-interface", "interface-name", "p-interface-1");
+ Vertex pInterface1 = graph.addVertex(T.label, "p-interface", T.id, "9", "aai-node-type", "p-interface", "interface-name", "p-interface-2");
+
+ Vertex plink = graph.addVertex(T.label, "physical-link", T.id, "10", "aai-node-type", "physical-link", "link-name", "link-name-1" );
+ Vertex plink1 = graph.addVertex(T.label, "physical-link", T.id, "11", "aai-node-type", "physical-link", "link-name", "link-name-2" );
+
+
+
+ GraphTraversalSource g = graph.traversal();
+
+ rules.addEdge(g, serviceinstance, gnvf);
+ rules.addEdge(g, gnvf, vserver);
+ rules.addEdge(g, vserver, pserver);
+ rules.addTreeEdge(g, pserver, pInterface);
+ rules.addEdge(g, pInterface, plink);
+
+ rules.addEdge(g, serviceinstance1, gnvf1);
+ rules.addEdge(g, gnvf1, vserver1);
+ rules.addEdge(g, vserver1, pserver1);
+ rules.addTreeEdge(g, pserver1, pInterface1);
+ rules.addEdge(g, pInterface1, plink1);
+
+ expectedResult.add(serviceinstance);
+ expectedResult.add(gnvf);
+ expectedResult.add(vserver);
+ expectedResult.add(pserver);
+ expectedResult.add(pInterface);
+ expectedResult.add(plink);
+
+
+ }
+
+ @Override
+ protected String getQueryName() {
+ return "getPinterfacePhysicalLinkBySvcInstId";
+ }
+
+ @Override
+ protected void addStartNode(GraphTraversal<Vertex, Vertex> g) {
+ g.has("aai-node-type", "service-instance").has("service-instance-id", "s-instance-id1");
+ }
+
+ @Override
+ protected void addParam(Map<String, Object> params) {
+ return;
+ }
+
+}
diff --git a/aai-traversal/src/test/java/org/onap/aai/rest/search/GetRouterRoadmTailSummaryTest.java b/aai-traversal/src/test/java/org/onap/aai/rest/search/GetRouterRoadmTailSummaryTest.java
new file mode 100644
index 0000000..dc6d148
--- /dev/null
+++ b/aai-traversal/src/test/java/org/onap/aai/rest/search/GetRouterRoadmTailSummaryTest.java
@@ -0,0 +1,104 @@
+/**
+ * ============LICENSE_START=======================================================
+ * org.onap.aai
+ * ================================================================================
+ * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY 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.rest.search;
+
+import java.util.Map;
+
+import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversal;
+import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource;
+import org.apache.tinkerpop.gremlin.structure.T;
+import org.apache.tinkerpop.gremlin.structure.Vertex;
+import org.junit.Test;
+import org.onap.aai.exceptions.AAIException;
+import org.onap.aai.serialization.db.exceptions.NoEdgeRuleFoundException;
+
+public class GetRouterRoadmTailSummaryTest extends QueryTest{
+
+ public GetRouterRoadmTailSummaryTest() throws AAIException, NoEdgeRuleFoundException {
+ super();
+ }
+
+ @Test
+ public void run() {
+ super.run();
+ }
+
+ @Override
+ protected void createGraph() throws AAIException, NoEdgeRuleFoundException {
+ Vertex serviceInstance = graph.addVertex(T.label, "service-instance", T.id, "1", "aai-node-type", "service-instance",
+ "service-instance-id", "service-instance-id-1", "service-instance-name", "service-instance-name-1");
+ Vertex serviceSubscription = graph.addVertex(T.label, "service-subscription", T.id, "2", "aai-node-type", "service-subscription",
+ "service-type", "service-subcription-1");
+ Vertex customer = graph.addVertex(T.label, "customer", T.id, "3", "aai-node-type", "customer", ""
+ + "global-customer-id", "customer-id-1", "subscriber-name", "customer-name1", "subscriber-type", "customer-type1");
+ Vertex logicalLink1 = graph.addVertex(T.label, "logical-link", T.id, "4", "aai-node-type", "logical-link", "link-name", "logical-link-1");
+ Vertex logicalLink2 = graph.addVertex(T.label, "logical-link", T.id, "5", "aai-node-type", "logical-link", "link-name", "logical-link-2");
+ Vertex pInterface1 = graph.addVertex(T.label, "p-interface", T.id, "6", "aai-node-type", "p-interface", "interface-name", "p-interface-1");
+ Vertex pInterface2 = graph.addVertex(T.label, "p-interface", T.id, "7", "aai-node-type", "p-interface", "interface-name", "p-interface-2");
+ Vertex pInterface3 = graph.addVertex(T.label, "p-interface", T.id, "8", "aai-node-type", "p-interface", "interface-name", "p-interface-3");
+ Vertex pnf1 = graph.addVertex(T.label, "pnf", T.id, "9", "aai-node-type", "pnf", "pnf-name", "pnf1name");
+ Vertex pnf2 = graph.addVertex(T.label, "pnf", T.id, "10", "aai-node-type", "pnf", "pnf-name", "pnf2name");
+
+ Vertex lInterface1 = graph.addVertex(T.label, "l-interface", T.id, "11", "aai-node-type", "l-interface", "interface-name", "l-interface-1");
+
+ GraphTraversalSource g = graph.traversal();
+ rules.addTreeEdge(g, customer, serviceSubscription);
+ rules.addTreeEdge(g, serviceSubscription, serviceInstance);
+
+ rules.addEdge(g, serviceInstance, logicalLink1);
+ rules.addEdge(g, logicalLink2, logicalLink1);
+ rules.addEdge(g, logicalLink2, pInterface1);
+ rules.addEdge(g, logicalLink2, pInterface2);
+ rules.addEdge(g, logicalLink2, pInterface3);
+
+ rules.addTreeEdge(g, pInterface1, pnf1);
+ rules.addTreeEdge(g, pInterface2, pnf2);
+ rules.addTreeEdge(g, pInterface3, pnf2);
+
+ rules.addEdge(g, logicalLink2, lInterface1);//false
+
+ expectedResult.add(pnf1);
+ expectedResult.add(pInterface1);
+ expectedResult.add(logicalLink1);
+ expectedResult.add(pInterface2);
+ expectedResult.add(pInterface3);
+ expectedResult.add(pnf2);
+ expectedResult.add(logicalLink2);
+ expectedResult.add(serviceInstance);
+ expectedResult.add(serviceSubscription);
+ expectedResult.add(customer);
+ }
+
+ @Override
+ protected String getQueryName() {
+ return "getRouterRoadmTailSummary";
+ }
+
+ @Override
+ protected void addStartNode(GraphTraversal<Vertex, Vertex> g) {
+ g.has("aai-node-type", "pnf").has("pnf-name", "pnf1name");
+ }
+
+ @Override
+ protected void addParam(Map<String, Object> params) {
+ return;
+ }
+
+}
diff --git a/aai-traversal/src/test/java/org/onap/aai/rest/search/GetServiceTopologyTest.java b/aai-traversal/src/test/java/org/onap/aai/rest/search/GetServiceTopologyTest.java
new file mode 100644
index 0000000..5475ea8
--- /dev/null
+++ b/aai-traversal/src/test/java/org/onap/aai/rest/search/GetServiceTopologyTest.java
@@ -0,0 +1,220 @@
+/**
+ * ============LICENSE_START=======================================================
+ * org.onap.aai
+ * ================================================================================
+ * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY 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.rest.search;
+
+import static org.junit.Assert.*;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Map;
+
+import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversal;
+import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource;
+import org.apache.tinkerpop.gremlin.process.traversal.step.util.Tree;
+import org.apache.tinkerpop.gremlin.structure.T;
+import org.apache.tinkerpop.gremlin.structure.Vertex;
+import org.junit.Test;
+import org.onap.aai.exceptions.AAIException;
+import org.onap.aai.serialization.db.exceptions.NoEdgeRuleFoundException;
+
+public class GetServiceTopologyTest extends TreeQueryTest {
+
+ public GetServiceTopologyTest() throws AAIException, NoEdgeRuleFoundException {
+ super();
+ }
+
+ @Override
+ protected void createGraph() throws AAIException, NoEdgeRuleFoundException {
+ //Set up the test graph
+
+
+
+ Vertex customer = graph.addVertex(T.label, "customer", T.id, "1", "aai-node-type", "customer", "global-customer-id", "customer-id-1", "subscriber-name", "customer-name1", "subscriber-type", "customer-type1");
+ Vertex serviceSubscription = graph.addVertex(T.label, "service-subscription", T.id, "2", "aai-node-type", "service-subscription", "service-type", "service-subcription-1");
+
+ Vertex serviceInstanceOne = graph.addVertex(T.label, "service-instance", T.id, "3", "aai-node-type", "service-instance", "service-instance-id", "service-instance-id-1", "service-instance-name", "service-instance-name-1");
+ Vertex genericVnfOne = graph.addVertex(T.label, "generic-vnf", T.id, "4", "aai-node-type", "generic-vnf", "vnf-name", "vnf-name", "vnf-type", "test", "vnf-id", "vnf-test=1");
+ Vertex lInterfaceOne = graph.addVertex(T.label, "l-interface", T.id, "5", "aai-node-type", "l-interface", "interface-name", "test-l-interface-one");
+ Vertex l3Ipv4AddressListOne = graph.addVertex(T.label, "l3-interface-ipv4-address-list", T.id, "6", "aai-node-type", "l3-interface-ipv4-address-list", "l3-interface-ipv4-address", "test1");
+ Vertex l3Ipv6AddressListOne = graph.addVertex(T.label, "l3-interface-ipv6-address-list", T.id, "7", "aai-node-type", "l3-interface-ipv6-address-list", "l3-interface-ipv6-address", "test2");
+
+ Vertex vlanOne = graph.addVertex(T.label, "vlan", T.id, "8", "aai-node-type", "vlan", "vlan-interface", "test-vlan-one");
+ Vertex l3Ipv4AddressListTwo = graph.addVertex(T.label, "l3-interface-ipv4-address-list", T.id, "9", "aai-node-type", "l3-interface-ipv4-address-list", "l3-interface-ipv4-address", "test3");
+ Vertex l3Ipv6AddressListTwo = graph.addVertex(T.label, "l3-interface-ipv6-address-list", T.id, "10", "aai-node-type", "l3-interface-ipv6-address-list", "l3-interface-ipv6-address", "test4");
+
+ Vertex vserverOne = graph.addVertex(T.label, "vserver", T.id, "11", "aai-node-type", "vserver", "vserver-id-one", "test-vserver", "vserver-selflink", "test", "vserver-name", "test-vserver");
+ Vertex lInterfaceTwo = graph.addVertex(T.label, "l-interface", T.id, "12", "aai-node-type", "l-interface", "interface-name", "test-l-interface-two");
+ Vertex l3Ipv4AddressListThree = graph.addVertex(T.label, "l3-interface-ipv4-address-list", T.id, "13", "aai-node-type", "l3-interface-ipv4-address-list", "l3-interface-ipv4-address", "test5");
+ Vertex l3Ipv6AddressListThree = graph.addVertex(T.label, "l3-interface-ipv6-address-list", T.id, "14", "aai-node-type", "l3-interface-ipv6-address-list", "l3-interface-ipv6-address", "test6");
+
+ Vertex vlanTwo = graph.addVertex(T.label, "vlan", T.id, "15", "aai-node-type", "vlan", "vlan-interface", "test-vlan-two");
+ Vertex l3Ipv4AddressListFour = graph.addVertex(T.label, "l3-interface-ipv4-address-list", T.id, "16", "aai-node-type", "l3-interface-ipv4-address-list", "l3-interface-ipv4-address", "test7");
+ Vertex l3Ipv6AddressListFour = graph.addVertex(T.label, "l3-interface-ipv6-address-list", T.id, "17", "aai-node-type", "l3-interface-ipv6-address-list", "l3-interface-ipv6-address", "test8");
+
+ Vertex pserver = graph.addVertex(T.label, "pserver", T.id, "18", "aai-node-type", "pserver", "hostname", "test-pserver");
+ Vertex complex = graph.addVertex(T.label, "complex", T.id, "19", "aai-node-type", "complex", "physical-location-id", "test-complex");
+
+ Vertex allottedResource = graph.addVertex(T.label, "allotted-resource", T.id, "20", "aai-node-type", "allotted-resource", "id", "test-resource");
+ Vertex serviceInstanceTwo = graph.addVertex(T.label, "service-instance", T.id, "21", "aai-node-type", "service-instance", "service-instance-id", "service-instance-id-2", "service-instance-name", "service-instance-name-1");
+ Vertex genericVnfTwo = graph.addVertex(T.label, "generic-vnf", T.id, "22", "aai-node-type", "generic-vnf", "vnf-name", "vnf-name", "vnf-type", "test", "vnf-id", "vnf-test-2");
+ Vertex lInterfaceThree = graph.addVertex(T.label, "l-interface", T.id, "23", "aai-node-type", "l-interface", "interface-name", "test-l-interface-three");
+ Vertex l3Ipv4AddressListFive = graph.addVertex(T.label, "l3-interface-ipv4-address-list", T.id, "24", "aai-node-type", "l3-interface-ipv4-address-list", "l3-interface-ipv4-address", "test9");
+ Vertex l3Ipv6AddressListFive = graph.addVertex(T.label, "l3-interface-ipv6-address-list", T.id, "25", "aai-node-type", "l3-interface-ipv6-address-list", "l3-interface-ipv6-address", "test10");
+
+ Vertex vlanThree = graph.addVertex(T.label, "vlan", T.id, "26", "aai-node-type", "vlan", "vlan-interface", "test-vlan-three");
+ Vertex l3Ipv4AddressListSix = graph.addVertex(T.label, "l3-interface-ipv4-address-list", T.id, "27", "aai-node-type", "l3-interface-ipv4-address-list", "l3-interface-ipv4-address", "test11");
+ Vertex l3Ipv6AddressListSix = graph.addVertex(T.label, "l3-interface-ipv6-address-list", T.id, "28", "aai-node-type", "l3-interface-ipv6-address-list", "l3-interface-ipv6-address", "test12");
+
+ Vertex vserverTwo = graph.addVertex(T.label, "vserver", T.id, "29", "aai-node-type", "vserver", "vserver-id", "test-vserver", "vserver-selflink", "test", "vserver-name", "test-vserver=two");
+ Vertex lInterfaceFour = graph.addVertex(T.label, "l-interface", T.id, "30", "aai-node-type", "l-interface", "interface-name", "test-l-interface-four");
+ Vertex l3Ipv4AddressListSeven = graph.addVertex(T.label, "l3-interface-ipv4-address-list", T.id, "31", "aai-node-type", "l3-interface-ipv4-address-list", "l3-interface-ipv4-address", "test13");
+ Vertex l3Ipv6AddressListSeven = graph.addVertex(T.label, "l3-interface-ipv6-address-list", T.id, "32", "aai-node-type", "l3-interface-ipv6-address-list", "l3-interface-ipv6-address", "test14");
+
+ Vertex vlanFour = graph.addVertex(T.label, "vlan", T.id, "33", "aai-node-type", "vlan", "vlan-interface", "test-vlan-four");
+ Vertex l3Ipv4AddressListEight = graph.addVertex(T.label, "l3-interface-ipv4-address-list", T.id, "34", "aai-node-type", "l3-interface-ipv4-address-list", "l3-interface-ipv4-address", "test15");
+ Vertex l3Ipv6AddressListEight = graph.addVertex(T.label, "l3-interface-ipv6-address-list", T.id, "35", "aai-node-type", "l3-interface-ipv6-address-list", "l3-interface-ipv6-address", "test16");
+
+
+ GraphTraversalSource g = graph.traversal();
+
+
+ rules.addTreeEdge(g, customer, serviceSubscription);
+ rules.addTreeEdge(g, serviceSubscription, serviceInstanceOne);
+
+ rules.addEdge(g, serviceInstanceOne, genericVnfOne);
+ rules.addTreeEdge(g, genericVnfOne, lInterfaceOne);
+ rules.addTreeEdge(g, lInterfaceOne, l3Ipv4AddressListOne);
+ rules.addTreeEdge(g, lInterfaceOne, l3Ipv6AddressListOne);
+
+ rules.addTreeEdge(g, lInterfaceOne, vlanOne);
+ rules.addTreeEdge(g, vlanOne, l3Ipv4AddressListTwo);
+ rules.addTreeEdge(g, vlanOne, l3Ipv6AddressListTwo);
+
+ rules.addEdge(g, genericVnfOne, vserverOne);
+ rules.addTreeEdge(g, vserverOne, lInterfaceTwo);
+ rules.addTreeEdge(g, lInterfaceTwo, l3Ipv4AddressListThree);
+ rules.addTreeEdge(g, lInterfaceTwo, l3Ipv6AddressListThree);
+ rules.addTreeEdge(g, lInterfaceTwo, vlanTwo);
+ rules.addTreeEdge(g, vlanTwo, l3Ipv4AddressListFour);
+ rules.addTreeEdge(g, vlanTwo, l3Ipv6AddressListFour);
+ rules.addEdge(g, vserverOne, pserver);
+ rules.addEdge(g, pserver, complex);
+
+ rules.addEdge(g, serviceInstanceOne, allottedResource);
+ rules.addTreeEdge(g, allottedResource, serviceInstanceTwo);
+
+ rules.addEdge(g, serviceInstanceTwo, genericVnfTwo);
+ rules.addTreeEdge(g, genericVnfTwo, lInterfaceThree);
+ rules.addTreeEdge(g, lInterfaceThree, l3Ipv4AddressListFive);
+ rules.addTreeEdge(g, lInterfaceThree, l3Ipv6AddressListFive);
+
+ rules.addTreeEdge(g, lInterfaceThree, vlanThree);
+ rules.addTreeEdge(g, vlanThree, l3Ipv4AddressListSix);
+ rules.addTreeEdge(g, vlanThree, l3Ipv6AddressListSix);
+
+ rules.addEdge(g, genericVnfTwo, vserverTwo);
+ rules.addTreeEdge(g, vserverTwo, lInterfaceFour);
+ rules.addTreeEdge(g, lInterfaceFour, l3Ipv4AddressListSeven);
+ rules.addTreeEdge(g, lInterfaceFour, l3Ipv6AddressListSeven);
+ rules.addTreeEdge(g, lInterfaceFour, vlanFour);
+ rules.addTreeEdge(g, vlanFour, l3Ipv4AddressListEight);
+ rules.addTreeEdge(g, vlanFour, l3Ipv6AddressListEight);
+
+
+
+
+ expectedResult.add(serviceInstanceOne);
+ expectedResult.add(genericVnfOne);
+ expectedResult.add(lInterfaceOne);
+ expectedResult.add(l3Ipv4AddressListOne);
+ expectedResult.add(l3Ipv6AddressListOne);
+ expectedResult.add(vlanOne);
+ expectedResult.add(l3Ipv4AddressListTwo);
+ expectedResult.add(l3Ipv6AddressListTwo);
+
+
+ expectedResult.add(vserverOne);
+ expectedResult.add(lInterfaceTwo);
+ expectedResult.add(l3Ipv4AddressListThree);
+ expectedResult.add(l3Ipv6AddressListThree);
+
+ expectedResult.add(vlanTwo);
+ expectedResult.add(l3Ipv4AddressListFour);
+ expectedResult.add(l3Ipv6AddressListFour);
+
+ expectedResult.add(pserver);
+ expectedResult.add(complex);
+
+ expectedResult.add(allottedResource);
+ expectedResult.add(serviceInstanceTwo);
+ expectedResult.add(genericVnfTwo);
+ expectedResult.add(lInterfaceThree);
+ expectedResult.add(l3Ipv4AddressListFive);
+ expectedResult.add(l3Ipv6AddressListFive);
+
+ expectedResult.add(vlanThree);
+ expectedResult.add(l3Ipv4AddressListSix);
+ expectedResult.add(l3Ipv6AddressListSix);
+
+ expectedResult.add(vserverTwo);
+ expectedResult.add(lInterfaceFour);
+ expectedResult.add(l3Ipv4AddressListSeven);
+ expectedResult.add(l3Ipv6AddressListSeven);
+ expectedResult.add(vlanFour);
+ expectedResult.add(l3Ipv4AddressListEight);
+ expectedResult.add(l3Ipv6AddressListEight);
+
+ }
+
+ @Test
+ public void run() {
+ super.run();
+ Tree tree = treeList.get(0);
+ ArrayList<Vertex> actualResult = new ArrayList<Vertex>();
+ int i = 1;
+ do {
+ actualResult.addAll(tree.getObjectsAtDepth(i));
+ i++;
+ } while(!tree.getObjectsAtDepth(i).isEmpty());
+
+ assertEquals("result has expected number of values", actualResult.size(), expectedResult.size());
+ int size = actualResult.size() == expectedResult.size() ? expectedResult.size() : 0;
+ for(i = 0; i < size; i++) {
+ assertTrue("result has node " + expectedResult.get(i), actualResult.contains(expectedResult.get(i)));
+ }
+
+ }
+
+ @Override
+ protected String getQueryName() {
+ return "getServiceTopology";
+ }
+
+ @Override
+ protected void addStartNode(GraphTraversal<Vertex, Vertex> g) {
+ g.has("aai-node-type", "service-instance").has("service-instance-id", "service-instance-id-1");
+ }
+
+ @Override
+ protected void addParam(Map<String, Object> params) {
+ return;
+ }
+
+}
diff --git a/aai-traversal/src/test/java/org/onap/aai/rest/search/GfpVserverDataQueryTest.java b/aai-traversal/src/test/java/org/onap/aai/rest/search/GfpVserverDataQueryTest.java
index 77cd524..8724785 100644
--- a/aai-traversal/src/test/java/org/onap/aai/rest/search/GfpVserverDataQueryTest.java
+++ b/aai-traversal/src/test/java/org/onap/aai/rest/search/GfpVserverDataQueryTest.java
@@ -53,6 +53,7 @@ public class GfpVserverDataQueryTest extends QueryTest {
GraphTraversalSource g = graph.traversal();
+
rules.addTreeEdge(g, tenant, cloudregion);
rules.addTreeEdge(g, vserver, tenant);
rules.addEdge(g, genericvnf, vserver);
diff --git a/aai-traversal/src/test/java/org/onap/aai/rest/search/GfpVserverQueryTest.java b/aai-traversal/src/test/java/org/onap/aai/rest/search/GfpVserverQueryTest.java
new file mode 100644
index 0000000..286319f
--- /dev/null
+++ b/aai-traversal/src/test/java/org/onap/aai/rest/search/GfpVserverQueryTest.java
@@ -0,0 +1,69 @@
+/**
+ * ============LICENSE_START=======================================================
+ * org.onap.aai
+ * ================================================================================
+ * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY 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.rest.search;
+
+import java.util.Map;
+
+import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversal;
+import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource;
+import org.apache.tinkerpop.gremlin.structure.T;
+import org.apache.tinkerpop.gremlin.structure.Vertex;
+import org.junit.Test;
+
+import org.onap.aai.exceptions.AAIException;
+import org.onap.aai.serialization.db.exceptions.NoEdgeRuleFoundException;
+
+public class GfpVserverQueryTest extends QueryTest {
+ public GfpVserverQueryTest() throws AAIException, NoEdgeRuleFoundException {
+ super();
+ }
+ @Test
+ public void run() {
+ super.run();
+ }
+ @Override
+ protected void createGraph() throws AAIException, NoEdgeRuleFoundException {
+ //set up test graph
+ Vertex cloudregion = graph.addVertex(T.label, "cloud-region", T.id, "1", "aai-node-type", "cloud-region", "cloud-region-id", "regionid0", "cloud-owner", "cloudOwnername0");
+ Vertex tenant = graph.addVertex(T.label, "tenant", T.id, "2", "aai-node-type", "tenant", "tenant-id", "tenantid0", "tenant-name", "tenantName0");
+ Vertex vserver = graph.addVertex(T.label, "vserver", T.id, "3", "aai-node-type", "vserver", "vserver-id", "vserverid0");
+ Vertex linterface = graph.addVertex(T.label, "l-interface", T.id, "4", "aai-node-type", "l-interface", "l-interface-id", "l-interface-id0", "l-interface-name", "l-interface-name0");
+ GraphTraversalSource g = graph.traversal();
+
+ rules.addTreeEdge(g, tenant, cloudregion);
+ rules.addTreeEdge(g, vserver, tenant);
+ rules.addTreeEdge(g, linterface, vserver);
+
+ expectedResult.add(vserver);
+ }
+ @Override
+ protected String getQueryName() {
+ return "gfp-vserver";
+ }
+ @Override
+ protected void addStartNode(GraphTraversal<Vertex, Vertex> g) {
+ g.has("aai-node-type", "vserver");
+ }
+
+ @Override
+ protected void addParam(Map<String, Object> params) {
+ return;
+ }
+} \ No newline at end of file
diff --git a/aai-traversal/src/test/java/org/onap/aai/rest/search/GremlinServerImplTest.java b/aai-traversal/src/test/java/org/onap/aai/rest/search/GremlinServerImplTest.java
deleted file mode 100644
index 1391bbf..0000000
--- a/aai-traversal/src/test/java/org/onap/aai/rest/search/GremlinServerImplTest.java
+++ /dev/null
@@ -1,161 +0,0 @@
-/**
- * ============LICENSE_START=======================================================
- * org.onap.aai
- * ================================================================================
- * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY 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.rest.search;
-
-import org.janusgraph.core.JanusGraph;
-import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversal;
-import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource;
-import org.apache.tinkerpop.gremlin.structure.Graph;
-import org.apache.tinkerpop.gremlin.structure.T;
-import org.apache.tinkerpop.gremlin.structure.Vertex;
-import org.junit.Assert;
-import org.junit.Before;
-import org.junit.Test;
-import org.mockito.Mockito;
-import org.onap.aai.dbmap.DBConnectionType;
-import org.onap.aai.exceptions.AAIException;
-import org.onap.aai.introspection.Loader;
-import org.onap.aai.introspection.LoaderFactory;
-import org.onap.aai.introspection.ModelType;
-import org.onap.aai.introspection.Version;
-import org.onap.aai.serialization.engines.QueryStyle;
-import org.onap.aai.serialization.engines.JanusGraphDBEngine;
-import org.onap.aai.serialization.engines.TransactionalGraphEngine;
-import org.onap.aai.serialization.queryformats.SubGraphStyle;
-
-import javax.ws.rs.core.*;
-import java.net.URI;
-import java.util.*;
-
-import static org.mockito.Matchers.anyObject;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.when;
-
-public class GremlinServerImplTest {
-
- GremlinServerImpl gremlinServerImpl;
-
- protected static final MediaType APPLICATION_JSON = MediaType.valueOf("application/json");
-
- private static final Set<Integer> VALID_HTTP_STATUS_CODES = new HashSet<>();
-
- private final static Version version = Version.getLatest();
- private final static ModelType introspectorFactoryType = ModelType.MOXY;
- private final static QueryStyle queryStyle = QueryStyle.TRAVERSAL;
- private final static DBConnectionType type = DBConnectionType.REALTIME;
-
- static {
- VALID_HTTP_STATUS_CODES.add(200);
- VALID_HTTP_STATUS_CODES.add(201);
- VALID_HTTP_STATUS_CODES.add(204);
- }
-
- private GenericQueryProcessor genericQueryProcessor;
- private HttpHeaders httpHeaders;
-
- private UriInfo uriInfo;
-
- private MultivaluedMap<String, String> headersMultiMap;
- private MultivaluedMap<String, String> queryParameters;
-
- private List<String> aaiRequestContextList;
-
- private List<MediaType> outputMediaTypes;
-
- private Loader loader;
- private JanusGraph graph;
-
- private Graph tx;
-
- private GraphTraversalSource g;
- private TransactionalGraphEngine dbEngine;
-
-
-
-@Before
- public void setup()throws AAIException{
-
- httpHeaders = mock(HttpHeaders.class);
- uriInfo = mock(UriInfo.class);
-
- headersMultiMap = new MultivaluedHashMap<>();
- queryParameters = Mockito.spy(new MultivaluedHashMap<>());
-
- headersMultiMap.add("X-FromAppId", "JUNIT");
- headersMultiMap.add("X-TransactionId", UUID.randomUUID().toString());
- headersMultiMap.add("Real-Time", "true");
- headersMultiMap.add("Accept", "application/json");
- headersMultiMap.add("aai-request-context", "");
-
- outputMediaTypes = new ArrayList<>();
- outputMediaTypes.add(APPLICATION_JSON);
-
- aaiRequestContextList = new ArrayList<>();
- aaiRequestContextList.add("");
-
- when(httpHeaders.getAcceptableMediaTypes()).thenReturn(outputMediaTypes);
- when(httpHeaders.getRequestHeaders()).thenReturn(headersMultiMap);
- when(httpHeaders.getRequestHeader("X-FromAppId")).thenReturn(Arrays.asList("JUNIT"));
- when(httpHeaders.getRequestHeader("X-TransactionId")).thenReturn(Arrays.asList("JUNIT"));
-
- when(httpHeaders.getRequestHeader("aai-request-context")).thenReturn(aaiRequestContextList);
-
-
- when(uriInfo.getQueryParameters()).thenReturn(queryParameters);
- when(uriInfo.getQueryParameters(false)).thenReturn(queryParameters);
-
- // TODO - Check if this is valid since RemoveDME2QueryParameters seems to be very unreasonable
- Mockito.doReturn(null).when(queryParameters).remove(anyObject());
-
- when(httpHeaders.getMediaType()).thenReturn(APPLICATION_JSON);
- loader = LoaderFactory.createLoaderForVersion(introspectorFactoryType, version);
- dbEngine = new JanusGraphDBEngine(
- queryStyle,
- type,
- loader);
- GenericQueryProcessor.Builder builder=new GenericQueryProcessor.Builder(dbEngine);
-builder.queryFrom(URI.create("te"));
-builder.queryFrom("te", "gremlin");
-builder.create();
-builder.processWith(QueryProcessorType.GREMLIN_SERVER);
- builder.processWith(QueryProcessorType.LOCAL_GROOVY);
-
- gremlinServerImpl= new GremlinServerImpl(builder);
- }
-
- @Test(expected = NullPointerException.class)
- public void processSubGraphTest() throws Exception{
- GraphTraversal<Vertex, Vertex> g=Mockito.mock(GraphTraversal.class);
- g.has("cloud-region-id", "cloud-region-id-1");
- gremlinServerImpl.processSubGraph(SubGraphStyle.prune,g);
-}
-
- @Test(expected = RuntimeException.class)
- public void executeTest() throws Exception{
- GraphTraversal<Vertex, Vertex> g=Mockito.mock(GraphTraversal.class);
- g.has("cloud-region-id", "cloud-region-id-1");
- //Mockito.when(etPath()).thenReturn("testpath");
- List<Object> re= gremlinServerImpl.execute(SubGraphStyle.prune);
- Assert.assertNotNull(re);
- }
-
-
-
-}
diff --git a/aai-traversal/src/test/java/org/onap/aai/rest/search/GroovyShellImplTest.java b/aai-traversal/src/test/java/org/onap/aai/rest/search/GroovyShellImplTest.java
index 0bbb04f..97045df 100644
--- a/aai-traversal/src/test/java/org/onap/aai/rest/search/GroovyShellImplTest.java
+++ b/aai-traversal/src/test/java/org/onap/aai/rest/search/GroovyShellImplTest.java
@@ -19,26 +19,20 @@
*/
package org.onap.aai.rest.search;
-import org.janusgraph.core.JanusGraph;
import groovy.lang.MissingPropertyException;
import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversal;
-import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource;
-import org.apache.tinkerpop.gremlin.structure.Graph;
import org.apache.tinkerpop.gremlin.structure.Vertex;
-import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import org.mockito.Mockito;
+import org.onap.aai.AAISetup;
import org.onap.aai.dbmap.DBConnectionType;
-import org.onap.aai.exceptions.AAIException;
import org.onap.aai.introspection.Loader;
-import org.onap.aai.introspection.LoaderFactory;
import org.onap.aai.introspection.ModelType;
-import org.onap.aai.introspection.Version;
-import org.onap.aai.serialization.engines.QueryStyle;
import org.onap.aai.serialization.engines.JanusGraphDBEngine;
+import org.onap.aai.serialization.engines.QueryStyle;
import org.onap.aai.serialization.engines.TransactionalGraphEngine;
-import org.onap.aai.serialization.queryformats.SubGraphStyle;
+import org.onap.aai.setup.SchemaVersion;
import javax.ws.rs.core.*;
import java.net.URI;
@@ -48,7 +42,7 @@ import static org.mockito.Matchers.anyObject;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
-public class GroovyShellImplTest {
+public class GroovyShellImplTest extends AAISetup{
GroovyShellImpl groovyShellImpl ;
@@ -56,18 +50,19 @@ public class GroovyShellImplTest {
private static final Set<Integer> VALID_HTTP_STATUS_CODES = new HashSet<>();
- private final static Version version = Version.getLatest();
+ private SchemaVersion version;
+
private final static ModelType introspectorFactoryType = ModelType.MOXY;
private final static QueryStyle queryStyle = QueryStyle.TRAVERSAL;
private final static DBConnectionType type = DBConnectionType.REALTIME;
+
static {
VALID_HTTP_STATUS_CODES.add(200);
VALID_HTTP_STATUS_CODES.add(201);
VALID_HTTP_STATUS_CODES.add(204);
}
- private GenericQueryProcessor genericQueryProcessor;
private HttpHeaders httpHeaders;
private UriInfo uriInfo;
@@ -80,18 +75,12 @@ public class GroovyShellImplTest {
private List<MediaType> outputMediaTypes;
private Loader loader;
- private JanusGraph graph;
-
- private Graph tx;
-
- private GraphTraversalSource g;
private TransactionalGraphEngine dbEngine;
+ @Before
+ public void setup() {
-
-@Before
- public void setup()throws AAIException{
-
+ version = schemaVersions.getDefaultVersion();
httpHeaders = mock(HttpHeaders.class);
uriInfo = mock(UriInfo.class);
@@ -125,31 +114,27 @@ public class GroovyShellImplTest {
Mockito.doReturn(null).when(queryParameters).remove(anyObject());
when(httpHeaders.getMediaType()).thenReturn(APPLICATION_JSON);
- loader = LoaderFactory.createLoaderForVersion(introspectorFactoryType, version);
+ loader = loaderFactory.createLoaderForVersion(introspectorFactoryType, version);
dbEngine = new JanusGraphDBEngine(
queryStyle,
type,
loader);
- GenericQueryProcessor.Builder builder=new GenericQueryProcessor.Builder(dbEngine);
-builder.queryFrom(URI.create("te"));
-builder.queryFrom("te", "gremlin");
-builder.create();
-builder.processWith(QueryProcessorType.GREMLIN_SERVER);
- builder.processWith(QueryProcessorType.LOCAL_GROOVY);
-
- groovyShellImpl= new GroovyShellImpl(builder);
+ GenericQueryProcessor.Builder builder = new GenericQueryProcessor.Builder(dbEngine, gremlinServerSingleton);
+ builder.queryFrom(URI.create("te"));
+ builder.queryFrom("te", "gremlin");
+ builder.create();
+ builder.processWith(QueryProcessorType.GREMLIN_SERVER);
+ builder.processWith(QueryProcessorType.LOCAL_GROOVY);
+
+ groovyShellImpl = new GroovyShellImpl(builder);
}
@Test(expected = MissingPropertyException.class)
- public void processSubGraphTest() throws Exception{
- GraphTraversal<Vertex, Vertex> g=Mockito.mock(GraphTraversal.class);
+ public void processSubGraphTest() throws Exception {
+ GraphTraversal<Vertex, Vertex> g = Mockito.mock(GraphTraversal.class);
g.has("cloud-region-id", "cloud-region-id-1");
Map<String, Object> params = new HashMap<>();
- groovyShellImpl.runQuery("vnfs-fromServiceInstance",params);
-}
-
-
-
-
+ groovyShellImpl.runQuery("vnfs-fromServiceInstance", params);
+ }
}
diff --git a/aai-traversal/src/test/java/org/onap/aai/rest/search/InstanceGroupsByCloudRegionQueryTest.java b/aai-traversal/src/test/java/org/onap/aai/rest/search/InstanceGroupsByCloudRegionQueryTest.java
new file mode 100644
index 0000000..0dbb911
--- /dev/null
+++ b/aai-traversal/src/test/java/org/onap/aai/rest/search/InstanceGroupsByCloudRegionQueryTest.java
@@ -0,0 +1,78 @@
+/**
+ * ============LICENSE_START=======================================================
+ * org.onap.aai
+ * ================================================================================
+ * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY 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.rest.search;
+
+import java.util.Map;
+
+import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversal;
+import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource;
+import org.apache.tinkerpop.gremlin.structure.T;
+import org.apache.tinkerpop.gremlin.structure.Vertex;
+import org.junit.Test;
+import org.onap.aai.exceptions.AAIException;
+import org.onap.aai.serialization.db.exceptions.NoEdgeRuleFoundException;
+
+public class InstanceGroupsByCloudRegionQueryTest extends QueryTest {
+
+ public InstanceGroupsByCloudRegionQueryTest() throws AAIException, NoEdgeRuleFoundException {
+ super();
+ }
+
+ @Test
+ public void test() {
+ super.run();
+ }
+
+ @Override
+ protected void createGraph() throws AAIException, NoEdgeRuleFoundException {
+ //Set up the test graph
+ Vertex cloudregion = graph.addVertex(T.label, "cloud-region", T.id, "1", "aai-node-type", "cloud-region", "cloud-region-id", "cloud-region-id-0", "cloud-region-owner", "cloud-owner-name-0","cloud-region-version","cloud-region-version-0");
+ Vertex instancegroup = graph.addVertex(T.label, "instance-group", T.id, "2", "aai-node-type", "instance-group", "id", "id-0", "instance-group-type", "instance-group-type-0","instance-group-role","instance-group-role-0","instance-group-function","instance-group-function-0","instance-group-description","instance-group-description-0");
+
+ Vertex cloudregion1 = graph.addVertex(T.label, "cloud-region", T.id, "3", "aai-node-type", "cloud-region", "cloud-region-id", "cloud-region-id-1", "cloud-region-owner", "cloud-owner-name-1","cloud-region-version","cloud-region-version-1");
+ Vertex instancegroup1 = graph.addVertex(T.label, "instance-group", T.id, "4", "aai-node-type", "instance-group", "id", "id-1", "instance-group-type", "instance-group-type-1","instance-group-role","instance-group-role-1","instance-group-function","instance-group-function-1","instance-group-description","instance-group-description-1");
+
+
+ GraphTraversalSource g = graph.traversal();
+ rules.addEdge(g, cloudregion, instancegroup);
+
+ rules.addEdge(g, cloudregion1, instancegroup1); //false
+
+ expectedResult.add(instancegroup);
+ }
+
+ @Override
+ protected String getQueryName() {
+ return "instance-groups-byCloudRegion";
+ }
+
+ @Override
+ protected void addStartNode(GraphTraversal<Vertex, Vertex> g) {
+ g.has("aai-node-type", "cloud-region").has("cloud-region-owner", "cloud-owner-name-0").has("cloud-region-id", "cloud-region-id-0");
+ }
+
+ @Override
+ protected void addParam(Map<String, Object> params) {
+ params.put("role", "instance-group-role-0");
+ params.put("type", "instance-group-type-0");
+ params.put("function", "instance-group-function-0");
+ }
+
+}
diff --git a/aai-traversal/src/test/java/org/onap/aai/rest/search/LinkedDevices_NewvceVserverTest.java b/aai-traversal/src/test/java/org/onap/aai/rest/search/LinkedDevices_NewvceVserverTest.java
index 8d6ef91..c828c67 100644
--- a/aai-traversal/src/test/java/org/onap/aai/rest/search/LinkedDevices_NewvceVserverTest.java
+++ b/aai-traversal/src/test/java/org/onap/aai/rest/search/LinkedDevices_NewvceVserverTest.java
@@ -68,7 +68,7 @@ public class LinkedDevices_NewvceVserverTest extends QueryTest {
"interface-name", "lint3", "is-port-mirrored", "true", "in-maint", "true", "is-ip-unnumbered", "false");
Vertex cloudregion = graph.addVertex(T.label, "cloud-region", T.id, "50", "aai-node-type", "cloud-region",
- "cloud-owner", "onap", "cloud-region-id", "crId");
+ "cloud-owner", "att", "cloud-region-id", "crId");
Vertex tenant = graph.addVertex(T.label, "tenant", T.id, "60", "aai-node-type", "tenant",
"tenant-id", "tenId", "tenant-name", "verity");
Vertex vserver = graph.addVertex(T.label, "vserver", T.id, "30", "aai-node-type", "vserver",
diff --git a/aai-traversal/src/test/java/org/onap/aai/rest/search/LogicalLinkByCloudRegionIdTest.java b/aai-traversal/src/test/java/org/onap/aai/rest/search/LogicalLinkByCloudRegionIdTest.java
new file mode 100644
index 0000000..a231ccd
--- /dev/null
+++ b/aai-traversal/src/test/java/org/onap/aai/rest/search/LogicalLinkByCloudRegionIdTest.java
@@ -0,0 +1,75 @@
+/**
+ * ============LICENSE_START=======================================================
+ * org.onap.aai
+ * ================================================================================
+ * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY 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.rest.search;
+
+import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversal;
+import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource;
+import org.apache.tinkerpop.gremlin.structure.T;
+import org.apache.tinkerpop.gremlin.structure.Vertex;
+import org.junit.Test;
+import org.onap.aai.exceptions.AAIException;
+import org.onap.aai.serialization.db.exceptions.NoEdgeRuleFoundException;
+
+import java.util.Map;
+
+public class LogicalLinkByCloudRegionIdTest extends QueryTest {
+ public LogicalLinkByCloudRegionIdTest () throws AAIException, NoEdgeRuleFoundException {
+ super();
+ }
+
+ @Test
+ public void run() {
+ super.run();
+ }
+
+ @Override
+ protected void createGraph() throws AAIException, NoEdgeRuleFoundException {
+
+ // Set up the test graph
+ Vertex cloudRegion1 = graph.addVertex(T.label, "cloud-region", T.id, "0", "aai-node-type", "cloud-region", "cloud-owner", "cloudOwner1", "cloud-region-id", "cloudRegionId1");
+ Vertex logicalLink1 = graph.addVertex(T.label, "logical-link", T.id, "1", "aai-node-type", "logical-link", "link-name", "linkName1", "in-maint", "false", "link-type","linkType1");
+
+ // adding extra vertices and edges which shouldn't be picked.
+ Vertex cloudRegion2 = graph.addVertex(T.label, "cloud-region", T.id, "2", "aai-node-type", "cloud-region", "cloud-owner", "cloudOwner2", "cloud-region-id", "cloudRegionId3");
+ Vertex logicalLink2 = graph.addVertex(T.label, "logical-link", T.id, "3", "aai-node-type", "logical-link", "link-name", "linkName2", "in-maint", "false", "link-type","linkType4");
+
+ GraphTraversalSource g = graph.traversal();
+ rules.addEdge(g, cloudRegion1, logicalLink1);
+ rules.addEdge(g, cloudRegion2, logicalLink2);
+
+ expectedResult.add(cloudRegion1);
+ expectedResult.add(logicalLink1);
+ }
+
+ @Override
+ protected String getQueryName() {
+ return "getLogicalLinkByCloudRegionId";
+ }
+
+ @Override
+ protected void addStartNode(GraphTraversal<Vertex, Vertex> g) {
+ g.has("aai-node-type", "cloud-region").has("cloud-region-id", "cloudRegionId1");
+ }
+
+ @Override
+ protected void addParam(Map<String, Object> params) {
+ return;
+ }
+} \ No newline at end of file
diff --git a/aai-traversal/src/test/java/org/onap/aai/rest/search/ModelAndNamedQueryRestProviderTest.java b/aai-traversal/src/test/java/org/onap/aai/rest/search/ModelAndNamedQueryRestProviderTest.java
index 793723e..1fc8bbd 100644
--- a/aai-traversal/src/test/java/org/onap/aai/rest/search/ModelAndNamedQueryRestProviderTest.java
+++ b/aai-traversal/src/test/java/org/onap/aai/rest/search/ModelAndNamedQueryRestProviderTest.java
@@ -23,18 +23,19 @@ import com.att.eelf.configuration.EELFLogger;
import com.att.eelf.configuration.EELFManager;
import org.apache.commons.io.IOUtils;
import org.junit.Before;
+import org.junit.Ignore;
import org.junit.Test;
import org.mockito.Mockito;
+import org.onap.aai.AAISetup;
import org.onap.aai.dbmap.DBConnectionType;
import org.onap.aai.introspection.Loader;
-import org.onap.aai.introspection.LoaderFactory;
import org.onap.aai.introspection.ModelType;
-import org.onap.aai.introspection.Version;
import org.onap.aai.serialization.db.DBSerializer;
import org.onap.aai.serialization.engines.QueryStyle;
import org.onap.aai.serialization.engines.JanusGraphDBEngine;
import org.onap.aai.serialization.engines.TransactionalGraphEngine;
import org.onap.aai.serialization.queryformats.utils.UrlBuilder;
+import org.onap.aai.setup.SchemaVersion;
import javax.servlet.http.HttpServletRequest;
import javax.ws.rs.core.*;
@@ -48,13 +49,13 @@ import static org.mockito.Matchers.anyObject;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
-public class ModelAndNamedQueryRestProviderTest {
+public class ModelAndNamedQueryRestProviderTest extends AAISetup{
protected static final MediaType APPLICATION_JSON = MediaType.valueOf("application/json");
private static final Set<Integer> VALID_HTTP_STATUS_CODES = new HashSet<>();
- private static final Version version = Version.getLatest();
+ private SchemaVersion version;
private static final ModelType introspectorFactoryType = ModelType.MOXY;
private static final QueryStyle queryStyle = QueryStyle.TRAVERSAL;
private static final DBConnectionType type = DBConnectionType.REALTIME;
@@ -85,11 +86,10 @@ public class ModelAndNamedQueryRestProviderTest {
@Before
public void setup(){
+ version = schemaVersions.getDefaultVersion();
logger.info("Starting the setup for the integration tests of Rest Endpoints");
- System.setProperty("AJSC_HOME", ".");
- System.setProperty("BUNDLECONFIG_DIR", "src/main/resources");
-
- modelAndNamedQueryRestProvider = new ModelAndNamedQueryRestProvider();
+
+ modelAndNamedQueryRestProvider = new ModelAndNamedQueryRestProvider(searchGraph, schemaVersions);
httpHeaders = mock(HttpHeaders.class);
uriInfo = mock(UriInfo.class);
@@ -125,7 +125,7 @@ public class ModelAndNamedQueryRestProviderTest {
Mockito.doReturn(null).when(queryParameters).remove(anyObject());
when(httpHeaders.getMediaType()).thenReturn(APPLICATION_JSON);
- loader = LoaderFactory.createLoaderForVersion(introspectorFactoryType, version);
+ loader = loaderFactory.createLoaderForVersion(introspectorFactoryType, version);
dbEngine = new JanusGraphDBEngine(
queryStyle,
type,
@@ -159,9 +159,6 @@ public class ModelAndNamedQueryRestProviderTest {
when(httpHeaders.getRequestHeader("X-FromAppId")).thenThrow(IllegalArgumentException.class);
when(httpHeaders.getAcceptableMediaTypes()).thenReturn(outputMediaTypes);
- DBSerializer serializer = new DBSerializer(version, dbEngine, introspectorFactoryType, "JUNIT");
- UrlBuilder urlBuilder = new UrlBuilder(version, serializer);
-
Response response = modelAndNamedQueryRestProvider.getNamedQueryResponse(
httpHeaders,
null,
@@ -173,6 +170,7 @@ public class ModelAndNamedQueryRestProviderTest {
assertEquals(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(), response.getStatus());
}
+ @Ignore("This test is too dependent on the cpu time to timeout and will fail randomly")
@Test
public void testNamedQueryCallTimeoutThrown() throws Exception {
diff --git a/aai-traversal/src/test/java/org/onap/aai/rest/search/NetworkCollectionByServiceInstanceTest.java b/aai-traversal/src/test/java/org/onap/aai/rest/search/NetworkCollectionByServiceInstanceTest.java
new file mode 100644
index 0000000..bb44704
--- /dev/null
+++ b/aai-traversal/src/test/java/org/onap/aai/rest/search/NetworkCollectionByServiceInstanceTest.java
@@ -0,0 +1,103 @@
+/**
+ * ============LICENSE_START=======================================================
+ * org.onap.aai
+ * ================================================================================
+ * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY 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.rest.search;
+
+import java.util.Map;
+
+import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversal;
+import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource;
+import org.apache.tinkerpop.gremlin.structure.T;
+import org.apache.tinkerpop.gremlin.structure.Vertex;
+import org.junit.Test;
+import org.onap.aai.exceptions.AAIException;
+import org.onap.aai.serialization.db.exceptions.NoEdgeRuleFoundException;
+
+public class NetworkCollectionByServiceInstanceTest extends QueryTest{
+ public NetworkCollectionByServiceInstanceTest() throws AAIException, NoEdgeRuleFoundException {
+ super();
+ }
+
+ @Test
+ public void run() {
+ super.run();
+ }
+ @Override
+ protected void createGraph() throws AAIException, NoEdgeRuleFoundException {
+
+
+ //Set up the test graph
+ Vertex serviceinstance1 = graph.addVertex(T.label, "service-instance", T.id, "0", "aai-node-type",
+ "service-instance", "service-instance-id", "service-instance-id-1", "service-instance-name",
+ "service-instance-name-1");
+
+ Vertex collection1 = graph.addVertex(T.label, "collection", T.id, "1", "aai-node-type", "collection");
+
+ Vertex instancegroup1 = graph.addVertex(T.label, "instance-group", T.id, "2", "aai-node-type", "instance-group",
+ "id", "id-0", "instance-group-type", "instance-group-type-0","instance-group-role","instance-group-role-0",
+ "instance-group-function","instance-group-function-0","instance-group-description","instance-group-description-0");
+
+ Vertex l3network1 = graph.addVertex(T.label, "l3-network", T.id, "3", "aai-node-type", "l3-network");
+
+
+
+ Vertex serviceinstance2 = graph.addVertex(T.label, "service-instance", T.id, "4", "aai-node-type",
+ "service-instance", "service-instance-id", "service-instance-id-2", "service-instance-name",
+ "service-instance-name-1");
+
+ Vertex collection2 = graph.addVertex(T.label, "collection", T.id, "5", "aai-node-type", "collection");
+
+ Vertex instancegroup2 = graph.addVertex(T.label, "instance-group", T.id, "6", "aai-node-type", "instance-group",
+ "id", "id-0", "instance-group-type", "instance-group-type-0","instance-group-role","instance-group-role-0",
+ "instance-group-function","instance-group-function-0","instance-group-description","instance-group-description-0");
+
+ Vertex l3network2 = graph.addVertex(T.label, "l3-network", T.id, "7", "aai-node-type", "l3-network");
+
+ GraphTraversalSource g = graph.traversal();
+
+ rules.addEdge(g, serviceinstance1, collection1); // True
+ rules.addEdge(g, collection1, instancegroup1); // True
+ rules.addEdge(g, instancegroup1, l3network1); // True
+
+ rules.addEdge(g, serviceinstance2, collection2); // False
+ rules.addEdge(g, collection2, instancegroup2); // False
+ rules.addEdge(g, instancegroup2, l3network2);// False
+
+ expectedResult.add(serviceinstance1);
+ expectedResult.add(collection1);
+ expectedResult.add(instancegroup1);
+ expectedResult.add(l3network1);
+
+ }
+ @Override
+ protected String getQueryName() {
+ return "network-collection-ByServiceInstance";
+ }
+ @Override
+ protected void addStartNode(GraphTraversal<Vertex, Vertex> g) {
+ g.has("aai-node-type", "service-instance").has("service-instance-id", "service-instance-id-1");
+ }
+
+ @Override
+ protected void addParam(Map<String, Object> params) {
+ return;
+ }
+}
+
+
diff --git a/aai-traversal/src/test/java/org/onap/aai/rest/search/PathQueryTest.java b/aai-traversal/src/test/java/org/onap/aai/rest/search/PathQueryTest.java
index 5e1b729..84d7a59 100644
--- a/aai-traversal/src/test/java/org/onap/aai/rest/search/PathQueryTest.java
+++ b/aai-traversal/src/test/java/org/onap/aai/rest/search/PathQueryTest.java
@@ -2,7 +2,7 @@
* ============LICENSE_START=======================================================
* org.onap.aai
* ================================================================================
- * Copyright © 2017 AT&T Intellectual Property. All rights reserved.
+ * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -16,8 +16,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
* ============LICENSE_END=========================================================
- *
- * ECOMP is a trademark and service mark of AT&T Intellectual Property.
*/
package org.onap.aai.rest.search;
diff --git a/aai-traversal/src/test/java/org/onap/aai/rest/search/PendingTopologyDetailTest.java b/aai-traversal/src/test/java/org/onap/aai/rest/search/PendingTopologyDetailTest.java
index bb73030..9de2607 100644
--- a/aai-traversal/src/test/java/org/onap/aai/rest/search/PendingTopologyDetailTest.java
+++ b/aai-traversal/src/test/java/org/onap/aai/rest/search/PendingTopologyDetailTest.java
@@ -50,6 +50,7 @@ public class PendingTopologyDetailTest extends QueryTest {
Vertex servinst = graph.addVertex(T.label, "service-instance", T.id, "4", "aai-node-type", "service-instance", "service-instance-id", "servInstId0", "service-type", "servType0");
Vertex owningentity = graph.addVertex(T.label, "owning-entity", T.id, "5", "aai-node-type", "owning-entity", "owning-entity-id", "entityId0", "owning-entity-name", "entityName0");
Vertex project = graph.addVertex(T.label, "project", T.id, "6", "aai-node-type", "project", "project-name", "project0");
+ Vertex vfmodule = graph.addVertex(T.label, "vf-module", T.id, "38", "aai-node-type", "vf-module", "vf-module-id", "1");
Vertex vnfc = graph.addVertex(T.label, "vnfc", T.id, "7", "aai-node-type", "vnfc", "vnfc-name", "vnfc0", "nfc-naming-code", "namingCode0", "nfc-function", "function0");
Vertex vserver = graph.addVertex(T.label, "vserver", T.id, "8", "aai-node-type", "vserver", "vserver-id", "vserverid0");
Vertex linterface = graph.addVertex(T.label, "l-interface", T.id, "9", "aai-node-type", "l-interface", "l-interface-id", "l-interface-id0", "l-interface-name", "l-interface-name0");
@@ -69,7 +70,8 @@ public class PendingTopologyDetailTest extends QueryTest {
Vertex genericvnf1 = graph.addVertex(T.label, "generic-vnf", T.id, "40", "aai-node-type", "generic-vnf", "vnf-id", "vnf-id-1", "vnf-name", "vnf-name-1");
Vertex platform1 = graph.addVertex(T.label, "platform", T.id, "41", "aai-node-type", "platform", "platform-name", "platform1");
-
+
+ Vertex vfmodule2 = graph.addVertex(T.label, "vf-module", T.id, "39", "aai-node-type", "vf-module", "vf-module-id", "2");
Vertex genericvnf2 = graph.addVertex(T.label, "generic-vnf", T.id, "30", "aai-node-type", "generic-vnf", "vnf-id", "vnf-id-2", "vnf-name", "vnf-name2");
Vertex vnfc2 = graph.addVertex(T.label, "vnfc", T.id, "31", "aai-node-type", "vnfc", "vnfc-name", "vnfc2", "nfc-naming-code", "namingCode2", "nfc-function", "function2");
Vertex vipipv4addresslist2 = graph.addVertex(T.label, "vip-ipv4-address-list", T.id, "32", "aai-node-type", "vip-ipv4-address-list", "vip-ipv4-addres", "vip-ipv4-address2");
@@ -85,7 +87,9 @@ public class PendingTopologyDetailTest extends QueryTest {
rules.addEdge(g, genericvnf, servinst);
rules.addEdge(g, owningentity, servinst);
rules.addEdge(g, project, servinst);
- rules.addEdge(g, genericvnf, vnfc);
+ rules.addTreeEdge(g, genericvnf, vfmodule);
+ rules.addEdge(g, vfmodule, vnfc);
+ //rules.addEdge(g, genericvnf, vnfc);
rules.addEdge(g, vnfc, vserver);
rules.addTreeEdge(g, vserver, tenant);
rules.addTreeEdge(g, tenant, cloudregion);
@@ -111,7 +115,8 @@ public class PendingTopologyDetailTest extends QueryTest {
// false
- rules.addEdge(g, genericvnf2, vnfc2);
+ rules.addTreeEdge(g, genericvnf2, vfmodule2);
+ rules.addEdge(g, vfmodule2, vnfc2);
rules.addTreeEdge(g, vipipv4addresslist2, cloudregion);
rules.addTreeEdge(g, vipipv6addresslist2, cloudregion);
rules.addEdge(g, vnfc2, vipipv4addresslist2);
@@ -129,6 +134,7 @@ public class PendingTopologyDetailTest extends QueryTest {
expectedResult.add(lineofbusiness);
expectedResult.add(owningentity);
expectedResult.add(project);
+ expectedResult.add(vfmodule);
expectedResult.add(vnfc);
expectedResult.add(l3inter1ipv4addresslist);
expectedResult.add(subnet4);
diff --git a/aai-traversal/src/test/java/org/onap/aai/rest/search/PserverFromFqdnFirstTokenTest.java b/aai-traversal/src/test/java/org/onap/aai/rest/search/PserverFromFqdnFirstTokenTest.java
new file mode 100644
index 0000000..6b3fcb2
--- /dev/null
+++ b/aai-traversal/src/test/java/org/onap/aai/rest/search/PserverFromFqdnFirstTokenTest.java
@@ -0,0 +1,74 @@
+/**
+ * ============LICENSE_START=======================================================
+ * org.onap.aai
+ * ================================================================================
+ * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY 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.rest.search;
+
+
+import java.util.Map;
+
+import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversal;
+import org.apache.tinkerpop.gremlin.structure.T;
+import org.apache.tinkerpop.gremlin.structure.Vertex;
+import org.junit.Test;
+import org.onap.aai.exceptions.AAIException;
+import org.onap.aai.serialization.db.exceptions.NoEdgeRuleFoundException;
+
+public class PserverFromFqdnFirstTokenTest extends QueryTest {
+
+ public PserverFromFqdnFirstTokenTest() throws AAIException, NoEdgeRuleFoundException {
+ super();
+ }
+
+ @Test
+ public void test() {
+ super.run();
+ }
+
+ @Override
+ protected void createGraph() throws AAIException, NoEdgeRuleFoundException {
+ //Set up the test graph
+ Vertex pserver1 = graph.addVertex(T.label, "pserver", T.id, "1", "aai-node-type", "pserver", "hostname", "hostname-10", "fqdn", "fqdn-1.abc.com", "source-of-truth", "RCT");
+ Vertex pserver2 = graph.addVertex(T.label, "pserver", T.id, "5", "aai-node-type", "pserver", "hostname", "hostname-20", "fqdn", "fqdn-2.abc.com", "source-of-truth", "RCT");
+ Vertex pserver3 = graph.addVertex(T.label, "pserver", T.id, "6", "aai-node-type", "pserver", "hostname", "hostname-30", "fqdn", "fqdn-13.abc.com", "source-of-truth", "AAIRctFeed");
+ Vertex pserver4 = graph.addVertex(T.label, "pserver", T.id, "7", "aai-node-type", "pserver", "hostname", "hostname-40", "fqdn", "fqdn-12.abc.com", "source-of-truth", "RO");
+ Vertex pserver5 = graph.addVertex(T.label, "pserver", T.id, "8", "aai-node-type", "pserver", "hostname", "hostname-50", "fqdn", "fqdn-20.abc.com", "source-of-truth", "RO");
+
+ expectedResult.add(pserver1);
+ expectedResult.add(pserver3);
+
+ }
+
+ @Override
+ protected String getQueryName() {
+ return "pserver-fromFqdnFirstToken";
+ }
+
+ @Override
+ protected void addStartNode(GraphTraversal<Vertex, Vertex> g) {
+ g.has("aai-node-type","pserver");
+ }
+
+ @Override
+ protected void addParam(Map<String, Object> params) {
+ params.put("fqdnFirstToken", "fqdn-1");
+ params.put("sourcesOfTruth", "RCT', 'AAIRctFeed"); //placement of single quotes is intentional, values between the first and last values must be in single quotes
+
+ }
+
+}
diff --git a/aai-traversal/src/test/java/org/onap/aai/rest/search/PserverFromHostnameFirstTokenTest.java b/aai-traversal/src/test/java/org/onap/aai/rest/search/PserverFromHostnameFirstTokenTest.java
new file mode 100644
index 0000000..9fe290b
--- /dev/null
+++ b/aai-traversal/src/test/java/org/onap/aai/rest/search/PserverFromHostnameFirstTokenTest.java
@@ -0,0 +1,75 @@
+/**
+ * ============LICENSE_START=======================================================
+ * org.onap.aai
+ * ================================================================================
+ * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY 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.rest.search;
+
+
+import java.util.Map;
+
+import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversal;
+import org.apache.tinkerpop.gremlin.structure.T;
+import org.apache.tinkerpop.gremlin.structure.Vertex;
+import org.junit.Test;
+import org.onap.aai.exceptions.AAIException;
+import org.onap.aai.serialization.db.exceptions.NoEdgeRuleFoundException;
+
+public class PserverFromHostnameFirstTokenTest extends QueryTest {
+
+ public PserverFromHostnameFirstTokenTest() throws AAIException, NoEdgeRuleFoundException {
+ super();
+ }
+
+ @Test
+ public void test() {
+ super.run();
+ }
+
+ @Override
+ protected void createGraph() throws AAIException, NoEdgeRuleFoundException {
+ //Set up the test graph
+ Vertex pserver1 = graph.addVertex(T.label, "pserver", T.id, "1", "aai-node-type", "pserver", "hostname", "hostname-1.abc.com", "source-of-truth", "RO");
+ Vertex pserver2 = graph.addVertex(T.label, "pserver", T.id, "5", "aai-node-type", "pserver", "hostname", "hostname-2.abc.com", "source-of-truth", "RO");
+ Vertex pserver3 = graph.addVertex(T.label, "pserver", T.id, "6", "aai-node-type", "pserver", "hostname", "hostname-13.abc.com", "source-of-truth", "AAI-EXTENSIONS");
+ Vertex pserver4 = graph.addVertex(T.label, "pserver", T.id, "7", "aai-node-type", "pserver", "hostname", "hostname-12.abc.com", "source-of-truth", "RCT");
+ Vertex pserver5 = graph.addVertex(T.label, "pserver", T.id, "8", "aai-node-type", "pserver", "hostname", "hostname-20.abc.com", "source-of-truth", "RO");
+
+
+ expectedResult.add(pserver1);
+ expectedResult.add(pserver3);
+
+ }
+
+ @Override
+ protected String getQueryName() {
+ return "pserver-fromHostnameFirstToken";
+ }
+
+ @Override
+ protected void addStartNode(GraphTraversal<Vertex, Vertex> g) {
+ g.has("aai-node-type","pserver");
+ }
+
+ @Override
+ protected void addParam(Map<String, Object> params) {
+ params.put("hostnameFirstToken", "hostname-1");
+ params.put("sourcesOfTruth", "RO', 'AAI-EXTENSIONS"); //placement of single quotes is intentional, values between the first and last values must be in single quotes
+
+ }
+
+}
diff --git a/aai-traversal/src/test/java/org/onap/aai/rest/search/PserverfromConfigurationFilterInterfaceIdTest.java b/aai-traversal/src/test/java/org/onap/aai/rest/search/PserverfromConfigurationFilterInterfaceIdTest.java
index e77b479..eb0fd25 100644
--- a/aai-traversal/src/test/java/org/onap/aai/rest/search/PserverfromConfigurationFilterInterfaceIdTest.java
+++ b/aai-traversal/src/test/java/org/onap/aai/rest/search/PserverfromConfigurationFilterInterfaceIdTest.java
@@ -53,6 +53,8 @@ public class PserverfromConfigurationFilterInterfaceIdTest extends QueryTest {
"in-maint", "true", "is-ip-unnumbered", "false", "interface-id", "interface-id1");
Vertex pnf1 = graph.addVertex(T.label, "pnf", T.id, "17", "aai-node-type", "pnf", "pnf-name", "pnf1name", "equip-vendor", "equip-vendor1", "equip-model",
"equip-model1");
+
+ Vertex vserver1 = graph.addVertex(T.label, "vserver", T.id, "22", "aai-node-type", "vserver", "vserver-id", "vserver-id-1", "vserver-name", "vserver-name-1");
// Following are extra nodes that should not be picked up in
// expectedResults
@@ -69,7 +71,8 @@ public class PserverfromConfigurationFilterInterfaceIdTest extends QueryTest {
rules.addEdge(g, config1, loglink2);
rules.addEdge(g, lint1, loglink1);
rules.addEdge(g, lint2, loglink1);
- rules.addEdge(g, loglink1, pserver1);
+ rules.addTreeEdge(g, vserver1,lint1);
+ rules.addEdge(g, vserver1, pserver1);
rules.addEdge(g, loglink1, gvnf1);
rules.addEdge(g, gvnf1, pnf1);
diff --git a/aai-traversal/src/test/java/org/onap/aai/rest/search/PserverfromConfigurationTest.java b/aai-traversal/src/test/java/org/onap/aai/rest/search/PserverfromConfigurationTest.java
index b3fbab1..8a39e1d 100644
--- a/aai-traversal/src/test/java/org/onap/aai/rest/search/PserverfromConfigurationTest.java
+++ b/aai-traversal/src/test/java/org/onap/aai/rest/search/PserverfromConfigurationTest.java
@@ -53,6 +53,7 @@ public class PserverfromConfigurationTest extends QueryTest {
"in-maint", "true", "is-ip-unnumbered", "false", "interface-id", "interface-id1");
Vertex pnf1 = graph.addVertex(T.label, "pnf", T.id, "17", "aai-node-type", "pnf", "pnf-name", "pnf1name", "equip-vendor", "equip-vendor1", "equip-model",
"equip-model1");
+ Vertex vserver1 = graph.addVertex(T.label, "vserver", T.id, "22", "aai-node-type", "vserver", "vserver-id", "vserver-id-1", "vserver-name", "vserver-name-1");
// Following are extra nodes that should not be picked up in
// expectedResults
@@ -70,7 +71,8 @@ public class PserverfromConfigurationTest extends QueryTest {
rules.addEdge(g, config1, loglink1);
rules.addEdge(g, lint1, loglink1);
rules.addEdge(g, lint2, loglink1);
- rules.addEdge(g, loglink1, pserver1);
+ rules.addTreeEdge(g, vserver1,lint1);
+ rules.addEdge(g, vserver1, pserver1);
rules.addEdge(g, loglink1, gvnf1);
rules.addEdge(g, gvnf1, pnf1);
diff --git a/aai-traversal/src/test/java/org/onap/aai/rest/search/QueryCountTest.java b/aai-traversal/src/test/java/org/onap/aai/rest/search/QueryCountTest.java
index 13e3953..9ab2284 100644
--- a/aai-traversal/src/test/java/org/onap/aai/rest/search/QueryCountTest.java
+++ b/aai-traversal/src/test/java/org/onap/aai/rest/search/QueryCountTest.java
@@ -2,7 +2,7 @@
* ============LICENSE_START=======================================================
* org.onap.aai
* ================================================================================
- * Copyright © 2017 AT&T Intellectual Property. All rights reserved.
+ * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -16,8 +16,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
* ============LICENSE_END=========================================================
- *
- * ECOMP is a trademark and service mark of AT&T Intellectual Property.
*/
package org.onap.aai.rest.search;
diff --git a/aai-traversal/src/test/java/org/onap/aai/rest/search/QueryPnfFromModelTest.java b/aai-traversal/src/test/java/org/onap/aai/rest/search/QueryPnfFromModelTest.java
new file mode 100644
index 0000000..95290fb
--- /dev/null
+++ b/aai-traversal/src/test/java/org/onap/aai/rest/search/QueryPnfFromModelTest.java
@@ -0,0 +1,81 @@
+/**
+ * ============LICENSE_START=======================================================
+ * org.onap.aai
+ * ================================================================================
+ * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY 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.rest.search;
+
+import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversal;
+import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource;
+import org.apache.tinkerpop.gremlin.structure.T;
+import org.apache.tinkerpop.gremlin.structure.Vertex;
+import org.junit.Test;
+import org.onap.aai.exceptions.AAIException;
+import org.onap.aai.serialization.db.exceptions.NoEdgeRuleFoundException;
+
+import java.util.Map;
+
+public class QueryPnfFromModelTest extends QueryTest {
+ public QueryPnfFromModelTest() throws AAIException, NoEdgeRuleFoundException {
+ super();
+ }
+
+ @Test
+ public void run() {
+ super.run();
+ }
+
+ @Override
+ protected void createGraph() throws AAIException, NoEdgeRuleFoundException {
+
+
+ Vertex serviceInst1 = graph.addVertex(T.label, "service-instance", T.id, "1", "aai-node-type", "service-instance", "service-instance-id",
+ "service-instance1", "model-invariant-id", "miid1", "model-version-id", "mvid1");
+ Vertex pnf1 = graph.addVertex(T.label, "pnf", T.id, "2", "aai-node-type", "pnf", "pnf-name", "pnf1name", "equip-vendor", "equip-vendor1", "equip-model",
+ "equip-model1");
+
+ Vertex serviceInst2 = graph.addVertex(T.label, "service-instance", T.id, "3", "aai-node-type", "service-instance", "service-instance-id",
+ "service-instance2", "model-invariant-id", "miid2", "model-version-id", "mvid2");
+ Vertex pnf2 = graph.addVertex(T.label, "pnf", T.id, "4", "aai-node-type", "pnf", "pnf-name", "pnf2name", "equip-vendor", "equip-vendor2", "equip-model",
+ "equip-model2");
+
+
+ GraphTraversalSource g = graph.traversal();
+ rules.addEdge(g, serviceInst1, pnf1);
+
+ rules.addEdge(g, serviceInst2, pnf2);//false
+
+
+ expectedResult.add(pnf1);
+ }
+
+ @Override
+ protected String getQueryName() {
+ return "pnf-from-model";
+ }
+
+ @Override
+ protected void addStartNode(GraphTraversal<Vertex, Vertex> g) {
+ g.has("model-invariant-id", "miid1").has("model-version-id", "mvid1");
+ }
+
+ @Override
+ protected void addParam(Map<String, Object> params) {
+ params.put("equipVendor", "equip-vendor1");
+ params.put("equipModel", "equip-model1");
+ }
+}
diff --git a/aai-traversal/src/test/java/org/onap/aai/rest/search/QueryTest.java b/aai-traversal/src/test/java/org/onap/aai/rest/search/QueryTest.java
index f9e467c..29cd505 100644
--- a/aai-traversal/src/test/java/org/onap/aai/rest/search/QueryTest.java
+++ b/aai-traversal/src/test/java/org/onap/aai/rest/search/QueryTest.java
@@ -2,7 +2,7 @@
* ============LICENSE_START=======================================================
* org.onap.aai
* ================================================================================
- * Copyright © 2017 AT&T Intellectual Property. All rights reserved.
+ * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -16,8 +16,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
* ============LICENSE_END=========================================================
- *
- * ECOMP is a trademark and service mark of AT&T Intellectual Property.
*/
package org.onap.aai.rest.search;
@@ -28,16 +26,37 @@ import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSo
import org.apache.tinkerpop.gremlin.structure.Graph;
import org.apache.tinkerpop.gremlin.structure.Vertex;
import org.apache.tinkerpop.gremlin.tinkergraph.structure.TinkerGraph;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.ClassRule;
+import org.junit.Rule;
+import org.junit.runner.RunWith;
+import org.junit.runners.Parameterized;
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
+import org.onap.aai.config.IntrospectionConfig;
+import org.onap.aai.config.SpringContextAware;
+import org.onap.aai.edges.EdgeIngestor;
+import org.onap.aai.edges.exceptions.AmbiguousRuleChoiceException;
+import org.onap.aai.edges.exceptions.EdgeRuleNotFoundException;
import org.onap.aai.exceptions.AAIException;
import org.onap.aai.introspection.Loader;
import org.onap.aai.introspection.LoaderFactory;
import org.onap.aai.introspection.ModelType;
-import org.onap.aai.introspection.Version;
+import org.onap.aai.nodes.NodeIngestor;
+import org.onap.aai.setup.AAIConfigTranslator;
+import org.onap.aai.setup.SchemaLocationsBean;
+import org.onap.aai.setup.SchemaVersion;
+import org.onap.aai.setup.SchemaVersions;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.test.context.ContextConfiguration;
+import org.springframework.test.context.TestPropertySource;
+import org.springframework.test.context.junit4.rules.SpringClassRule;
+import org.springframework.test.context.junit4.rules.SpringMethodRule;
import org.onap.aai.query.builder.GremlinTraversal;
import org.onap.aai.restcore.search.GremlinGroovyShellSingleton;
-import org.onap.aai.serialization.db.EdgeRules;
+import org.onap.aai.restcore.search.GroovyQueryBuilderSingleton;
+import org.onap.aai.serialization.db.EdgeSerializer;
import org.onap.aai.serialization.db.exceptions.NoEdgeRuleFoundException;
import org.onap.aai.serialization.engines.QueryStyle;
import org.onap.aai.serialization.engines.TransactionalGraphEngine;
@@ -49,39 +68,92 @@ import static org.junit.Assert.assertEquals;
import static org.mockito.Matchers.any;
import static org.mockito.Mockito.when;
+@RunWith(Parameterized.class)
+@ContextConfiguration(classes = {
+ SchemaLocationsBean.class,
+ SchemaVersions.class,
+ AAIConfigTranslator.class,
+ EdgeIngestor.class,
+ EdgeSerializer.class,
+ NodeIngestor.class,
+ SpringContextAware.class,
+ GremlinServerSingleton.class,
+ IntrospectionConfig.class
+})
+@TestPropertySource(properties = {
+ "schema.uri.base.path = /aai",
+ "schema.ingest.file = src/test/resources/application-test.properties"
+})
public abstract class QueryTest {
+ @ClassRule
+ public static final SpringClassRule springClassRule = new SpringClassRule();
+
+ @Rule
+ public final SpringMethodRule springMethodRule = new SpringMethodRule();
+
protected EELFLogger logger;
protected Graph graph;
- protected GremlinServerSingleton gremlinServerSingleton;
protected GremlinGroovyShellSingleton shell;
@Mock protected TransactionalGraphEngine dbEngine;
protected final List<Vertex> expectedResult = new ArrayList<>();
- protected final EdgeRules rules = EdgeRules.getInstance();
+
+ @Autowired
+ protected EdgeIngestor edgeRules;
+
+ @Autowired
+ protected EdgeSerializer rules;
+
+ @Autowired
+ protected LoaderFactory loaderFactory;
+
+ @Autowired
+ protected SchemaVersions schemaVersions;
+
+ @Autowired
+ protected GremlinServerSingleton gremlinServerSingleton;
+
protected Loader loader;
protected GraphTraversalSource gts;
+ @Parameterized.Parameter(value = 0)
+ public SchemaVersion version;
+
+ @Parameterized.Parameters(name = "Version.{0}")
+ public static Collection<Object[]> data() {
+ return Arrays.asList(new Object[][]{
+ {new SchemaVersion("v11")},
+ {new SchemaVersion("v12")},
+ {new SchemaVersion("v13")},
+ {new SchemaVersion("v14")}
+ });
+ }
+
protected String query;
+
LinkedHashMap <String, Object> params;
- public QueryTest() throws AAIException, NoEdgeRuleFoundException {
- setUp();
- logger = EELFManager.getInstance().getLogger(getClass());
- setUpQuery();
+ @BeforeClass
+ public static void setupBundleconfig() {
+ System.setProperty("AJSC_HOME", "./");
+ System.setProperty("BUNDLECONFIG_DIR", "src/main/resources/");
}
- protected void setUp() throws AAIException, NoEdgeRuleFoundException {
+ @Before
+ public void setUp() throws AAIException, NoEdgeRuleFoundException, EdgeRuleNotFoundException, AmbiguousRuleChoiceException {
System.setProperty("AJSC_HOME", ".");
System.setProperty("BUNDLECONFIG_DIR", "src/main/resources");
+ logger = EELFManager.getInstance().getLogger(getClass());
MockitoAnnotations.initMocks(this);
graph = TinkerGraph.open();
gts = graph.traversal();
createGraph();
- gremlinServerSingleton = GremlinServerSingleton.getInstance();
shell = GremlinGroovyShellSingleton.getInstance();
- loader = LoaderFactory.createLoaderForVersion(ModelType.MOXY, Version.getLatest());
+ loader = loaderFactory.createLoaderForVersion(ModelType.MOXY, version);
+ setUpQuery();
}
+
protected void setUpQuery() {
query = gremlinServerSingleton.getStoredQueryFromConfig(getQueryName());
params = new LinkedHashMap <>();
@@ -128,12 +200,12 @@ public abstract class QueryTest {
.collect(Collectors.joining(","));
}
- protected abstract void createGraph() throws AAIException, NoEdgeRuleFoundException;
-
+ protected abstract void createGraph() throws AAIException, NoEdgeRuleFoundException, EdgeRuleNotFoundException, AmbiguousRuleChoiceException;
+
protected abstract String getQueryName();
-
+
protected abstract void addStartNode(GraphTraversal<Vertex, Vertex> g);
-
+
protected abstract void addParam(Map<String, Object> params);
}
diff --git a/aai-traversal/src/test/java/org/onap/aai/rest/search/RelatedToBothCousinAndTreeCustomQueryTest.java b/aai-traversal/src/test/java/org/onap/aai/rest/search/RelatedToBothCousinAndTreeCustomQueryTest.java
new file mode 100644
index 0000000..85f4e3b
--- /dev/null
+++ b/aai-traversal/src/test/java/org/onap/aai/rest/search/RelatedToBothCousinAndTreeCustomQueryTest.java
@@ -0,0 +1,88 @@
+/**
+ * ============LICENSE_START=======================================================
+ * org.onap.aai
+ * ================================================================================
+ * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY 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.rest.search;
+import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversal;
+import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource;
+import org.apache.tinkerpop.gremlin.structure.T;
+import org.apache.tinkerpop.gremlin.structure.Vertex;
+import org.junit.Test;
+import org.onap.aai.exceptions.AAIException;
+import org.onap.aai.serialization.db.exceptions.NoEdgeRuleFoundException;
+
+import java.util.Map;
+
+public class RelatedToBothCousinAndTreeCustomQueryTest extends QueryTest{
+
+ public RelatedToBothCousinAndTreeCustomQueryTest() throws AAIException, NoEdgeRuleFoundException {
+ super();
+ }
+
+ @Test
+ public void run() {
+ super.run();
+ }
+ @Override
+ protected void createGraph() throws AAIException, NoEdgeRuleFoundException {
+
+ Vertex lagInterface1 = graph.addVertex(T.label, "lag-interface", T.id, "1", "aai-node-type", "lag-interface", "interface-name", "lag-int1");
+
+ Vertex lInterface1 = graph.addVertex(T.label, "l-interface", T.id, "2", "aai-node-type", "l-interface", "interface-name", "l-interfaceid01");
+ Vertex lInterface2 = graph.addVertex(T.label, "l-interface", T.id, "3", "aai-node-type", "l-interface", "interface-name", "l-interfaceid02");
+ Vertex lInterface3 = graph.addVertex(T.label, "l-interface", T.id, "4", "aai-node-type", "l-interface", "interface-name", "l-interfaceid03");
+ Vertex lInterface4 = graph.addVertex(T.label, "l-interface", T.id, "5", "aai-node-type", "l-interface", "interface-name", "l-interfaceid04");
+ Vertex lInterface5 = graph.addVertex(T.label, "l-interface", T.id, "6", "aai-node-type", "l-interface", "interface-name", "l-interfaceid05");
+ Vertex lInterface6 = graph.addVertex(T.label, "l-interface", T.id, "7", "aai-node-type", "l-interface", "interface-name", "l-interfaceid06");
+
+ GraphTraversalSource g = graph.traversal();
+ rules.addEdge(g, lagInterface1, lInterface1);
+ rules.addEdge(g, lagInterface1, lInterface2);
+ rules.addEdge(g, lagInterface1, lInterface3);
+ rules.addTreeEdge(g, lagInterface1, lInterface4);
+ rules.addTreeEdge(g, lagInterface1, lInterface5);
+ rules.addTreeEdge(g, lagInterface1, lInterface6);
+
+ expectedResult.add(lInterface1);
+ expectedResult.add(lInterface2);
+ expectedResult.add(lInterface3);
+ expectedResult.add(lInterface4);
+ expectedResult.add(lInterface5);
+ expectedResult.add(lInterface6);
+
+ }
+
+ @Override
+ protected String getQueryName() {
+ return "related-to";
+ }
+
+ @Override
+ protected void addStartNode(GraphTraversal<Vertex, Vertex> g) {
+ g.has("interface-name", "lag-int1");
+ }
+
+ @Override
+ protected void addParam(Map<String, Object> params) {
+ params.put("startingNodeType", "lag-interface");
+ params.put("relatedToNodeType", "l-interface");
+
+
+ }
+
+}
diff --git a/aai-traversal/src/test/java/org/onap/aai/rest/search/RelatedToCustomQueryTest.java b/aai-traversal/src/test/java/org/onap/aai/rest/search/RelatedToCustomQueryTest.java
new file mode 100644
index 0000000..b8a8156
--- /dev/null
+++ b/aai-traversal/src/test/java/org/onap/aai/rest/search/RelatedToCustomQueryTest.java
@@ -0,0 +1,78 @@
+/**
+ * ============LICENSE_START=======================================================
+ * org.onap.aai
+ * ================================================================================
+ * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY 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.rest.search;
+import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversal;
+import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource;
+import org.apache.tinkerpop.gremlin.structure.T;
+import org.apache.tinkerpop.gremlin.structure.Vertex;
+import org.junit.Test;
+import org.onap.aai.exceptions.AAIException;
+import org.onap.aai.serialization.db.exceptions.NoEdgeRuleFoundException;
+
+import java.util.Map;
+public class RelatedToCustomQueryTest extends QueryTest{
+
+ public RelatedToCustomQueryTest() throws AAIException, NoEdgeRuleFoundException {
+ super();
+ }
+
+ @Test
+ public void run() {
+ super.run();
+ }
+ @Override
+ protected void createGraph() throws AAIException, NoEdgeRuleFoundException {
+
+ Vertex genericvnf1 = graph.addVertex(T.label, "generic-vnf", T.id, "1", "aai-node-type", "generic-vnf", "vnf-id", "genvnf1", "vnf-name", "genvnfname1", "nf-type", "sample-nf-type");
+
+ Vertex vserver1 = graph.addVertex(T.label, "vserver", T.id, "2", "aai-node-type", "vserver", "vserver-id", "vserverid01");
+ Vertex vserver2 = graph.addVertex(T.label, "vserver", T.id, "3", "aai-node-type", "vserver", "vserver-id", "vserverid02");
+ Vertex vserver3 = graph.addVertex(T.label, "vserver", T.id, "4", "aai-node-type", "vserver", "vserver-id", "vserverid03");
+
+ GraphTraversalSource g = graph.traversal();
+ rules.addEdge(g, genericvnf1, vserver1);
+ rules.addEdge(g, genericvnf1, vserver2);
+ rules.addEdge(g, genericvnf1, vserver3);
+
+ expectedResult.add(vserver1);
+ expectedResult.add(vserver2);
+ expectedResult.add(vserver3);
+
+ }
+
+ @Override
+ protected String getQueryName() {
+ return "related-to";
+ }
+
+ @Override
+ protected void addStartNode(GraphTraversal<Vertex, Vertex> g) {
+ g.has("vnf-id", "genvnf1");
+ }
+
+ @Override
+ protected void addParam(Map<String, Object> params) {
+ params.put("startingNodeType", "generic-vnf");
+ params.put("relatedToNodeType", "vserver");
+
+
+ }
+
+}
diff --git a/aai-traversal/src/test/java/org/onap/aai/rest/search/RelatedToTreeCustomQueryTest.java b/aai-traversal/src/test/java/org/onap/aai/rest/search/RelatedToTreeCustomQueryTest.java
new file mode 100644
index 0000000..8998b90
--- /dev/null
+++ b/aai-traversal/src/test/java/org/onap/aai/rest/search/RelatedToTreeCustomQueryTest.java
@@ -0,0 +1,77 @@
+/**
+ * ============LICENSE_START=======================================================
+ * org.onap.aai
+ * ================================================================================
+ * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY 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.rest.search;
+import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversal;
+import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource;
+import org.apache.tinkerpop.gremlin.structure.T;
+import org.apache.tinkerpop.gremlin.structure.Vertex;
+import org.junit.Test;
+import org.onap.aai.exceptions.AAIException;
+import org.onap.aai.serialization.db.exceptions.NoEdgeRuleFoundException;
+
+import java.util.Map;
+
+public class RelatedToTreeCustomQueryTest extends QueryTest {
+
+ public RelatedToTreeCustomQueryTest() throws AAIException, NoEdgeRuleFoundException {
+ super();
+ }
+
+ @Test
+ public void run() {
+ super.run();
+ }
+ @Override
+ protected void createGraph() throws AAIException, NoEdgeRuleFoundException {
+
+ Vertex genericvnf1 = graph.addVertex(T.label, "generic-vnf", T.id, "1", "aai-node-type", "generic-vnf", "vnf-id", "genvnf1", "vnf-name", "genvnfname1", "nf-type", "sample-nf-type");
+
+ Vertex entitlement1 = graph.addVertex(T.label, "entitlement", T.id, "2", "aai-node-type", "entitlement", "group-uuid", "entitlementid01", "resource-uuid", "rentitlementid01");
+ Vertex entitlement2 = graph.addVertex(T.label, "entitlement", T.id, "3", "aai-node-type", "entitlement", "group-uuid", "entitlementid02", "resource-uuid", "rentitlementid02");
+ Vertex entitlement3 = graph.addVertex(T.label, "entitlement", T.id, "4", "aai-node-type", "entitlement", "group-uuid", "entitlementid03", "resource-uuid", "rentitlementid03");
+
+ GraphTraversalSource g = graph.traversal();
+ rules.addTreeEdge(g, genericvnf1, entitlement1);
+ rules.addTreeEdge(g, genericvnf1, entitlement2);
+ rules.addTreeEdge(g, genericvnf1, entitlement3);
+
+ expectedResult.add(entitlement1);
+ expectedResult.add(entitlement2);
+ expectedResult.add(entitlement3);
+
+ }
+
+ @Override
+ protected String getQueryName() {
+ return "related-to";
+ }
+
+ @Override
+ protected void addStartNode(GraphTraversal<Vertex, Vertex> g) {
+ g.has("vnf-id", "genvnf1");
+ }
+
+ @Override
+ protected void addParam(Map<String, Object> params) {
+ params.put("startingNodeType", "generic-vnf");
+ params.put("relatedToNodeType", "entitlement");
+ }
+
+}
diff --git a/aai-traversal/src/test/java/org/onap/aai/rest/search/SearchProviderTest.java b/aai-traversal/src/test/java/org/onap/aai/rest/search/SearchProviderTest.java
index 9b34d5f..b69f992 100644
--- a/aai-traversal/src/test/java/org/onap/aai/rest/search/SearchProviderTest.java
+++ b/aai-traversal/src/test/java/org/onap/aai/rest/search/SearchProviderTest.java
@@ -25,33 +25,33 @@ import org.junit.Before;
import org.junit.Ignore;
import org.junit.Test;
import org.mockito.Mockito;
+import org.onap.aai.AAISetup;
import org.onap.aai.dbmap.DBConnectionType;
import org.onap.aai.introspection.Loader;
-import org.onap.aai.introspection.LoaderFactory;
import org.onap.aai.introspection.ModelType;
-import org.onap.aai.introspection.Version;
-import org.onap.aai.serialization.db.DBSerializer;
-import org.onap.aai.serialization.engines.JanusGraphDBEngine;
import org.onap.aai.serialization.engines.QueryStyle;
+import org.onap.aai.serialization.engines.JanusGraphDBEngine;
import org.onap.aai.serialization.engines.TransactionalGraphEngine;
-import org.onap.aai.serialization.queryformats.utils.UrlBuilder;
+import org.onap.aai.setup.SchemaVersion;
import javax.ws.rs.core.*;
import java.util.*;
+import static org.hamcrest.Matchers.containsString;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertThat;
import static org.mockito.Matchers.anyObject;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
-public class SearchProviderTest {
+public class SearchProviderTest extends AAISetup{
protected static final MediaType APPLICATION_JSON = MediaType.valueOf("application/json");
private static final Set<Integer> VALID_HTTP_STATUS_CODES = new HashSet<>();
- private static final Version version = Version.getLatest();
+ private SchemaVersion version;
private static final ModelType introspectorFactoryType = ModelType.MOXY;
private static final QueryStyle queryStyle = QueryStyle.TRAVERSAL;
private static final DBConnectionType type = DBConnectionType.REALTIME;
@@ -83,10 +83,9 @@ public class SearchProviderTest {
@Before
public void setup(){
logger.info("Starting the setup for the integration tests of Rest Endpoints");
- System.setProperty("AJSC_HOME", ".");
- System.setProperty("BUNDLECONFIG_DIR", "src/main/resources");
-
- searchProvider = new SearchProvider();
+ version = schemaVersions.getDefaultVersion();
+
+ searchProvider = new SearchProvider(loaderFactory, searchGraph, schemaVersions, basePath);
httpHeaders = mock(HttpHeaders.class);
uriInfo = mock(UriInfo.class);
@@ -122,7 +121,7 @@ public class SearchProviderTest {
Mockito.doReturn(null).when(queryParameters).remove(anyObject());
when(httpHeaders.getMediaType()).thenReturn(APPLICATION_JSON);
- loader = LoaderFactory.createLoaderForVersion(introspectorFactoryType, version);
+ loader = loaderFactory.createLoaderForVersion(introspectorFactoryType, version);
dbEngine = new JanusGraphDBEngine(
queryStyle,
type,
@@ -130,45 +129,6 @@ public class SearchProviderTest {
}
@Test
- public void testNodesQueryInvalidData() throws Exception {
-
- List<String> keys = new ArrayList<>();
- keys.add("cloud-region.cloud-owner:test-aic");
-
- List<String> includeStrings = new ArrayList<>();
- includeStrings.add("cloud-region");
-
- DBSerializer serializer = new DBSerializer(version, dbEngine, introspectorFactoryType, "JUNIT");
- UrlBuilder urlBuilder = new UrlBuilder(version, serializer);
-
- Response response = searchProvider.getNodesQueryResponse(
- httpHeaders,
- null,
- "cloud-region",
- keys,
- includeStrings,
- version.toString(),
- uriInfo
- );
-
- assertNotNull(response);
- assertEquals(Response.Status.BAD_REQUEST.getStatusCode(), response.getStatus());
-
- response = searchProvider.getNodesQueryResponse(
- httpHeaders,
- null,
- "cloud-region",
- keys,
- includeStrings,
- "latest",
- uriInfo
- );
-
- assertNotNull(response);
- assertEquals(Response.Status.BAD_REQUEST.getStatusCode(), response.getStatus());
- }
-
- @Test
public void testNodesQueryInvalidHeaders() throws Exception {
List<String> keys = new ArrayList<>();
@@ -182,9 +142,6 @@ public class SearchProviderTest {
when(httpHeaders.getRequestHeader("X-FromAppId")).thenThrow(IllegalArgumentException.class);
when(httpHeaders.getAcceptableMediaTypes()).thenReturn(outputMediaTypes);
- DBSerializer serializer = new DBSerializer(version, dbEngine, introspectorFactoryType, "JUNIT");
- UrlBuilder urlBuilder = new UrlBuilder(version, serializer);
-
Response response = searchProvider.getNodesQueryResponse(
httpHeaders,
null,
@@ -199,6 +156,8 @@ public class SearchProviderTest {
assertEquals(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(), response.getStatus());
}
+ //TODO fix test
+ @Ignore("Test has a time dependency and fails based on system perf")
@Test
public void testNodesQueryTimeoutThrown() throws Exception {
@@ -214,9 +173,6 @@ public class SearchProviderTest {
when(httpHeaders.getRequestHeaders()).thenReturn(headersMultiMap);
when(httpHeaders.getAcceptableMediaTypes()).thenReturn(outputMediaTypes);
- DBSerializer serializer = new DBSerializer(version, dbEngine, introspectorFactoryType, "JUNIT");
- UrlBuilder urlBuilder = new UrlBuilder(version, serializer);
-
Response response = searchProvider.getNodesQueryResponse(
httpHeaders,
null,
@@ -229,7 +185,7 @@ public class SearchProviderTest {
assertNotNull(response);
assertEquals(Response.Status.BAD_REQUEST.getStatusCode(), response.getStatus());
- assertEquals(true, response.getEntity().toString().contains("7406"));
+ assertThat(response.getEntity().toString(), containsString("7406"));
}
@Test
@@ -247,9 +203,6 @@ public class SearchProviderTest {
when(httpHeaders.getRequestHeaders()).thenReturn(headersMultiMap);
when(httpHeaders.getAcceptableMediaTypes()).thenReturn(outputMediaTypes);
- DBSerializer serializer = new DBSerializer(version, dbEngine, introspectorFactoryType, "JUNIT");
- UrlBuilder urlBuilder = new UrlBuilder(version, serializer);
-
Response response = searchProvider.getNodesQueryResponse(
httpHeaders,
null,
@@ -262,83 +215,11 @@ public class SearchProviderTest {
assertNotNull(response);
assertEquals(Response.Status.BAD_REQUEST.getStatusCode(), response.getStatus());
- assertEquals(true, response.getEntity().toString().contains("4009"));
+ assertThat(response.getEntity().toString(), containsString("4009"));
}
-
- @Test
- public void testGenericQueryInvalidData() throws Exception {
-
- List<String> keys = new ArrayList<>();
- keys.add("cloud-region.cloud-owner:test-aic");
-
- List<String> includeStrings = new ArrayList<>();
- includeStrings.add("cloud-region");
-
- DBSerializer serializer = new DBSerializer(version, dbEngine, introspectorFactoryType, "JUNIT");
- UrlBuilder urlBuilder = new UrlBuilder(version, serializer);
-
- Response response = searchProvider.getGenericQueryResponse(
- httpHeaders,
- null,
- "cloud-region",
- keys,
- includeStrings,
- 0,
- version.toString(),
- uriInfo
- );
-
- assertNotNull(response);
- assertEquals(Response.Status.BAD_REQUEST.getStatusCode(), response.getStatus());
-
- response = searchProvider.getNodesQueryResponse(
- httpHeaders,
- null,
- "cloud-region",
- keys,
- includeStrings,
- "latest",
- uriInfo
- );
-
- assertNotNull(response);
- assertEquals(Response.Status.BAD_REQUEST.getStatusCode(), response.getStatus());
- }
-
- @Test
- public void testGenericQueryInvalidHeaders() throws Exception {
-
- List<String> keys = new ArrayList<>();
- keys.add("cloud-region.cloud-owner:test-aic");
-
- List<String> includeStrings = new ArrayList<>();
- includeStrings.add("cloud-region");
-
- httpHeaders = mock(HttpHeaders.class);
-
- when(httpHeaders.getRequestHeader("X-FromAppId")).thenThrow(IllegalArgumentException.class);
- when(httpHeaders.getAcceptableMediaTypes()).thenReturn(outputMediaTypes);
-
- DBSerializer serializer = new DBSerializer(version, dbEngine, introspectorFactoryType, "JUNIT");
- UrlBuilder urlBuilder = new UrlBuilder(version, serializer);
-
- Response response = searchProvider.getGenericQueryResponse(
- httpHeaders,
- null,
- "cloud-region",
- keys,
- includeStrings,
- 0,
- version.toString(),
- uriInfo
- );
-
- assertNotNull(response);
- assertEquals(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(), response.getStatus());
- }
-
- @Ignore("This test is very specific to the server vm specification")
+ //TODO fix test
+ @Ignore("Test has a time dependency and fails based on system perf")
@Test
public void testGenericQueryTimeoutThrown() throws Exception {
@@ -355,8 +236,6 @@ public class SearchProviderTest {
when(httpHeaders.getAcceptableMediaTypes()).thenReturn(outputMediaTypes);
- DBSerializer serializer = new DBSerializer(version, dbEngine, introspectorFactoryType, "JUNIT");
- UrlBuilder urlBuilder = new UrlBuilder(version, serializer);
Response response = searchProvider.getGenericQueryResponse(
httpHeaders,
@@ -371,41 +250,7 @@ public class SearchProviderTest {
assertNotNull(response);
assertEquals(Response.Status.BAD_REQUEST.getStatusCode(), response.getStatus());
- assertEquals(true, response.getEntity().toString().contains("7406"));
+ assertThat(response.getEntity().toString(), containsString("7406"));
}
- @Test
- public void testGenericQueryBypassTimeout() throws Exception {
-
- List<String> keys = new ArrayList<>();
- keys.add("cloud-region.cloud-owner:test-aic");
-
- List<String> includeStrings = new ArrayList<>();
- includeStrings.add("cloud-region");
-
- httpHeaders = mock(HttpHeaders.class);
-
- headersMultiMap.putSingle("X-FromAppId", "JUNITTESTAPP2");
- when(httpHeaders.getRequestHeaders()).thenReturn(headersMultiMap);
-
- when(httpHeaders.getAcceptableMediaTypes()).thenReturn(outputMediaTypes);
-
- DBSerializer serializer = new DBSerializer(version, dbEngine, introspectorFactoryType, "JUNIT");
- UrlBuilder urlBuilder = new UrlBuilder(version, serializer);
-
- Response response = searchProvider.getGenericQueryResponse(
- httpHeaders,
- null,
- "cloud-region",
- keys,
- includeStrings,
- 0,
- version.toString(),
- uriInfo
- );
-
- assertNotNull(response);
- assertEquals(Response.Status.BAD_REQUEST.getStatusCode(), response.getStatus());
- assertEquals(true, response.getEntity().toString().contains("4009"));
- }
}
diff --git a/aai-traversal/src/test/java/org/onap/aai/rest/search/SimpleFormatTest.java b/aai-traversal/src/test/java/org/onap/aai/rest/search/SimpleFormatTest.java
index 531437f..d6ad59a 100644
--- a/aai-traversal/src/test/java/org/onap/aai/rest/search/SimpleFormatTest.java
+++ b/aai-traversal/src/test/java/org/onap/aai/rest/search/SimpleFormatTest.java
@@ -19,46 +19,48 @@
*/
package org.onap.aai.rest.search;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
-import static org.mockito.Mockito.spy;
-import static org.mockito.Mockito.when;
-
-import java.util.ArrayList;
-import java.util.List;
-
+import com.google.gson.JsonObject;
import org.apache.tinkerpop.gremlin.structure.Graph;
import org.apache.tinkerpop.gremlin.structure.T;
import org.apache.tinkerpop.gremlin.structure.Vertex;
import org.apache.tinkerpop.gremlin.tinkergraph.structure.TinkerGraph;
+import org.junit.Before;
import org.junit.Test;
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
+import org.onap.aai.AAISetup;
import org.onap.aai.dbmap.DBConnectionType;
import org.onap.aai.exceptions.AAIException;
import org.onap.aai.introspection.Loader;
-import org.onap.aai.introspection.LoaderFactory;
import org.onap.aai.introspection.ModelType;
-import org.onap.aai.introspection.Version;
import org.onap.aai.serialization.db.DBSerializer;
-import org.onap.aai.serialization.db.EdgeRules;
+
import org.onap.aai.serialization.db.exceptions.NoEdgeRuleFoundException;
-import org.onap.aai.serialization.engines.QueryStyle;
import org.onap.aai.serialization.engines.JanusGraphDBEngine;
+import org.onap.aai.serialization.engines.QueryStyle;
import org.onap.aai.serialization.engines.TransactionalGraphEngine;
import org.onap.aai.serialization.queryformats.RawFormat;
import org.onap.aai.serialization.queryformats.exceptions.AAIFormatVertexException;
import org.onap.aai.serialization.queryformats.utils.UrlBuilder;
+import org.springframework.test.annotation.DirtiesContext;
-import com.google.gson.JsonObject;
+import java.util.ArrayList;
+import java.util.List;
-public class SimpleFormatTest {
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+import static org.mockito.Mockito.spy;
+import static org.mockito.Mockito.when;
+
+@DirtiesContext(classMode = DirtiesContext.ClassMode.BEFORE_CLASS)
+public class SimpleFormatTest extends AAISetup{
+
protected Graph graph;
private TransactionalGraphEngine dbEngine;
protected final List<Vertex> expectedResult = new ArrayList<>();
- protected final EdgeRules rules = EdgeRules.getInstance();
+
protected Loader loader;
private DBSerializer serializer;
@@ -68,16 +70,11 @@ public class SimpleFormatTest {
Vertex vfmodule = null;
- public SimpleFormatTest() throws AAIException, NoEdgeRuleFoundException {
- setUp();
- }
-
+ @Before
public void setUp() throws AAIException, NoEdgeRuleFoundException {
- System.setProperty("AJSC_HOME", ".");
- System.setProperty("BUNDLECONFIG_DIR", "src/main/resources");
MockitoAnnotations.initMocks(this);
graph = TinkerGraph.open();
- loader = LoaderFactory.createLoaderForVersion(ModelType.MOXY, Version.v10);
+ loader = loaderFactory.createLoaderForVersion(ModelType.MOXY, schemaVersions.getRelatedLinkVersion());
vfmodule = graph.addVertex(T.label, "vf-module",
T.id, "5",
"aai-node-type", "vf-module",
@@ -96,7 +93,7 @@ public class SimpleFormatTest {
"contrail-service-instance-fqdn", "example-contrail-service-instance-fqdn-val-68205");
final ModelType factoryType = ModelType.MOXY;
- Loader loader = LoaderFactory.createLoaderForVersion(factoryType, Version.v10);
+ Loader loader = loaderFactory.createLoaderForVersion(factoryType, schemaVersions.getRelatedLinkVersion());
dbEngine = spy(new JanusGraphDBEngine(
QueryStyle.TRAVERSAL,
DBConnectionType.CACHED,
@@ -106,7 +103,7 @@ public class SimpleFormatTest {
TransactionalGraphEngine.Admin spyAdmin = spy(dbEngine.asAdmin());
when(spyAdmin.getTraversalSource()).thenReturn(graph.traversal());
when(dbEngine.asAdmin()).thenReturn(spyAdmin);
- serializer = new DBSerializer(Version.v10, dbEngine, factoryType, "Junit");
+ serializer = new DBSerializer(schemaVersions.getRelatedLinkVersion(), dbEngine, factoryType, "Junit");
_simpleFormat = new RawFormat.Builder(loader, serializer, urlBuilder).modelDriven().build();
dbEngine.startTransaction();
}
@@ -116,7 +113,7 @@ public class SimpleFormatTest {
assertNotNull(dbEngine.tx());
System.out.println(dbEngine.tx());
assertNotNull(graph.traversal());
- JsonObject json = _simpleFormat.createPropertiesObject(vfmodule);
+ JsonObject json = _simpleFormat.createPropertiesObject(vfmodule).get();
json.entrySet().stream().forEach((System.out::println));
assertTrue(json.has("model-invariant-id"));
diff --git a/aai-traversal/src/test/java/org/onap/aai/rest/search/SriovTopologyFromVnfQueryTest.java b/aai-traversal/src/test/java/org/onap/aai/rest/search/SriovTopologyFromVnfQueryTest.java
new file mode 100644
index 0000000..cceab09
--- /dev/null
+++ b/aai-traversal/src/test/java/org/onap/aai/rest/search/SriovTopologyFromVnfQueryTest.java
@@ -0,0 +1,109 @@
+/**
+ * ============LICENSE_START=======================================================
+ * org.onap.aai
+ * ================================================================================
+ * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY 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.rest.search;
+
+import java.util.Map;
+
+import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversal;
+import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource;
+import org.apache.tinkerpop.gremlin.structure.T;
+import org.apache.tinkerpop.gremlin.structure.Vertex;
+import org.junit.Test;
+import org.onap.aai.exceptions.AAIException;
+import org.onap.aai.serialization.db.exceptions.NoEdgeRuleFoundException;
+
+public class SriovTopologyFromVnfQueryTest extends QueryTest {
+ public SriovTopologyFromVnfQueryTest() throws AAIException, NoEdgeRuleFoundException {
+ super();
+ }
+
+ @Test
+ public void run() {
+ super.run();
+ }
+ @Override
+ protected void createGraph() throws AAIException, NoEdgeRuleFoundException {
+
+
+ //Set up the test graph
+ Vertex gvnf1 = graph.addVertex(T.label, "generic-vnf", T.id, "0", "aai-node-type", "generic-vnf",
+ "vnf-id", "gvnf1", "vnf-name", "genvnfname1", "nf-type", "sample-nf-type");
+ Vertex vserver1 = graph.addVertex(T.label, "vserver", T.id, "1", "aai-node-type", "vserver","vserver-name", "vservername1");
+ Vertex lint1 = graph.addVertex(T.label, "l-interface", T.id, "2", "aai-node-type", "l-interface",
+ "interface-name", "lint1", "is-port-mirrored", "true", "in-maint", "true", "is-ip-unnumbered", "false");
+
+ Vertex sriovVf1 = graph.addVertex(T.label, "sriov-vf", T.id, "3", "aai-node-type", "sriov-vf", "pci-id", "pcIid1");
+ Vertex sriovPf1 = graph.addVertex(T.label, "sriov-pf", T.id, "4", "aai-node-type", "sriov-pf", "pf-pci-id", "pfPciId1");
+
+ Vertex pint1 = graph.addVertex(T.label, "p-interface", T.id, "5", "aai-node-type", "p-interface", "interface-name", "ge0/0/0");
+ Vertex plink1 = graph.addVertex(T.label, "physical-link", T.id, "6", "aai-node-type", "physical-link", "link-name", "ge0/0/0-to-xe0/0/0");
+
+
+ Vertex gvnf2 = graph.addVertex(T.label, "generic-vnf", T.id, "10", "aai-node-type", "generic-vnf",
+ "vnf-id", "gvnf2", "vnf-name", "genvnfname2", "nf-type", "sample-nf-type1");
+ Vertex vserver2 = graph.addVertex(T.label, "vserver", T.id, "11", "aai-node-type", "vserver","vserver-name", "vservername2");
+ Vertex lint2 = graph.addVertex(T.label, "l-interface", T.id, "12", "aai-node-type", "l-interface",
+ "interface-name", "lint2", "is-port-mirrored", "true", "in-maint", "true", "is-ip-unnumbered", "false");
+
+ Vertex sriovVf2 = graph.addVertex(T.label, "sriov-vf", T.id, "13", "aai-node-type", "sriov-vf", "pci-id", "pcIid2");
+ Vertex sriovPf2 = graph.addVertex(T.label, "sriov-pf", T.id, "14", "aai-node-type", "sriov-pf", "pf-pci-id", "pfPciId2");
+
+ Vertex pint2 = graph.addVertex(T.label, "p-interface", T.id, "15", "aai-node-type", "p-interface", "interface-name", "ge0/0/1");
+ Vertex plink2 = graph.addVertex(T.label, "physical-link", T.id, "16", "aai-node-type", "physical-link", "link-name", "ge0/0/0-to-xe0/0/1");
+
+
+
+ GraphTraversalSource g = graph.traversal();
+
+ rules.addEdge(g, gvnf1, vserver1);
+ rules.addTreeEdge(g, vserver1, lint1);
+ rules.addTreeEdge(g, lint1, sriovVf1);
+ rules.addEdge(g, sriovVf1, sriovPf1);
+ rules.addTreeEdge(g, sriovPf1, pint1);
+ rules.addEdge(g, pint1, plink1);
+
+ rules.addEdge(g, gvnf2, vserver2);//false
+ rules.addTreeEdge(g, vserver2, lint2);//false
+ rules.addTreeEdge(g, lint2, sriovVf2);//false
+ rules.addEdge(g, sriovVf2, sriovPf2);//false
+ rules.addTreeEdge(g, sriovPf2, pint2);//false
+ rules.addEdge(g, pint2, plink2);//false
+
+
+ expectedResult.add(gvnf1);
+ expectedResult.add(vserver1);
+ expectedResult.add(sriovVf1);
+ expectedResult.add(plink1);
+
+ }
+ @Override
+ protected String getQueryName() {
+ return "sriov-topology-fromVnf";
+ }
+ @Override
+ protected void addStartNode(GraphTraversal<Vertex, Vertex> g) {
+ g.has("aai-node-type","generic-vnf").has("vnf-id", "gvnf1").has("vnf-name", "genvnfname1");
+ }
+
+ @Override
+ protected void addParam(Map<String, Object> params) {
+ return;
+ }
+}
diff --git a/aai-traversal/src/test/java/org/onap/aai/rest/search/TopologyDetailFromVnfQueryTest.java b/aai-traversal/src/test/java/org/onap/aai/rest/search/TopologyDetailFromVnfQueryTest.java
new file mode 100644
index 0000000..c553d05
--- /dev/null
+++ b/aai-traversal/src/test/java/org/onap/aai/rest/search/TopologyDetailFromVnfQueryTest.java
@@ -0,0 +1,163 @@
+/**
+ * ============LICENSE_START=======================================================
+ * org.onap.aai
+ * ================================================================================
+ * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY 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.rest.search;
+
+import java.util.Map;
+
+import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversal;
+import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource;
+import org.apache.tinkerpop.gremlin.structure.T;
+import org.apache.tinkerpop.gremlin.structure.Vertex;
+import org.junit.Test;
+
+import org.onap.aai.exceptions.AAIException;
+import org.onap.aai.serialization.db.exceptions.NoEdgeRuleFoundException;
+
+public class TopologyDetailFromVnfQueryTest extends QueryTest {
+
+ public TopologyDetailFromVnfQueryTest() throws AAIException, NoEdgeRuleFoundException {
+ super();
+ }
+
+ @Test
+ public void run() {
+ super.run();
+ }
+
+ @Override
+ protected void createGraph() throws AAIException, NoEdgeRuleFoundException {
+ Vertex gnvf1 = graph.addVertex(T.label, "generic-vnf", T.id, "1", "aai-node-type", "generic-vnf", "vnf-id", "vnfuuid", "vnf-name", "vnf-name-1", "service-id", "service-id-1");
+ Vertex gnvf2 = graph.addVertex(T.label, "generic-vnf", T.id, "2", "aai-node-type", "generic-vnf", "vnf-id", "vnf-id-2", "vnf-name", "vnf-name-2", "service-id", "service-id-wrong");
+
+ Vertex vserver1 = graph.addVertex(T.label, "vserver", T.id, "3", "aai-node-type", "vserver", "vserver-id", "vserver-id-1", "vserver-name", "vserver-name-1", "vserver-selflink", "vserver-selflink-1");
+ Vertex vserver2 = graph.addVertex(T.label, "vserver", T.id, "4", "aai-node-type", "vserver", "vserver-id", "vserver-id-2", "vserver-name", "vserver-name-2", "vserver-selflink", "vserver-selflink-2");
+
+ Vertex vnfc1 = graph.addVertex(T.label, "vnfc", T.id, "5", "aai-node-type", "vnfc", "vnfc-name", "vnfc-name-1", "nfc-naming-code", "nfc-naming-code-1");
+ Vertex vnfc2 = graph.addVertex(T.label, "vnfc", T.id, "6", "aai-node-type", "vnfc", "vnfc-name", "vnfc-name-2", "nfc-naming-code", "nfc-naming-code-2");
+
+ Vertex tenant1 = graph.addVertex(T.label, "tenant-id", T.id, "7", "aai-node-type", "tenant", "tenant-id", "TenantID", "tenant-name", "TenantName");
+ Vertex tenant2 = graph.addVertex(T.label, "tenant-id", T.id, "8", "aai-node-type", "tenant", "tenant-id", "TenantID2", "tenant-name", "TenantName2");
+
+ Vertex flavor1 = graph.addVertex(T.label, "flavor", T.id, "9", "aai-node-type", "flavor", "flavor-id", "flavor-id-1", "flavor-name", "flavor-name-1", "flavor-selflink", "flavor-selflink-1");
+ Vertex image1 = graph.addVertex(T.label, "image", T.id, "10", "aai-node-type", "image", "image-id", "image-id-1", "image-name", "image-name-1", "image-os-distro", "image-os-distro-1", "image-os-version", "image-os-version-1");
+
+ Vertex flavor2 = graph.addVertex(T.label, "flavor", T.id, "11", "aai-node-type", "flavor", "flavor-id", "flavor-id-2", "flavor-name", "flavor-name-2", "flavor-selflink", "flavor-selflink-2");
+ Vertex image2 = graph.addVertex(T.label, "image", T.id, "12", "aai-node-type", "image", "image-id", "image-id-2", "image-name", "image-name-2", "image-os-distro", "image-os-distro-2", "image-os-version", "image-os-version-2");
+
+ Vertex linter1 = graph.addVertex(T.label, "l-interface", T.id, "13", "aai-node-type", "l-interface", "l-interface-id", "l-interface-id-1", "l-interface-name", "l-interface-name1");
+ Vertex linter2 = graph.addVertex(T.label, "l-interface", T.id, "14", "aai-node-type", "l-interface", "l-interface-id", "l-interface-id-2", "l-interface-name", "l-interface-name2");
+
+ Vertex l3inter1ipv4addresslist = graph.addVertex(T.label, "interface-ipv4-address-list", T.id, "15", "aai-node-type", "l3-interface-ipv4-address-list", "l3-interface-ipv4-address", "l3-interface-ipv4-address-1");
+ Vertex l3inter1ipv4addresslist2 = graph.addVertex(T.label, "interface-ipv4-address-list", T.id, "16", "aai-node-type", "l3-interface-ipv4-address-list", "l3-interface-ipv4-address", "l3-interface-ipv4-address-2");
+
+ Vertex l3inter1ipv6addresslist = graph.addVertex(T.label, "l3-interface-ipv6-address-list", T.id, "17", "aai-node-type", "l3-interface-ipv6-address-list", "l3-interface-ipv6-address", "l3-interface-ipv6-address-1");
+ Vertex l3inter1ipv6addresslist2 = graph.addVertex(T.label, "l3-interface-ipv6-address-list", T.id, "18", "aai-node-type", "l3-interface-ipv6-address-list", "l3-interface-ipv6-address", "l3-interface-ipv6-address-2");
+
+ Vertex cloudRegion1 = graph.addVertex(T.label, "cloud-region", T.id, "19", "aai-node-type", "cloud-region", "cloud-owner", "CloudOwner1", "cloud-region-id", "CloudRegionId1");
+ Vertex cloudRegion2 = graph.addVertex(T.label, "cloud-region", T.id, "20", "aai-node-type", "cloud-region", "cloud-owner", "CloudOwner2", "cloud-region-id", "CloudRegionId2");
+
+ Vertex availibityzone1 = graph.addVertex(T.label, "availability-zone", T.id, "21", "aai-node-type", "availability-zone", "availability-zone-name", "az-name-1", "hypervisor-type", "hypervisortype-1");
+
+ Vertex pserver1 = graph.addVertex(T.label, "pserver", T.id, "22", "aai-node-type", "pserver", "pserver-id", "PserverID1", "hostname", "PserverHostName1");
+ Vertex pserver2 = graph.addVertex(T.label, "pserver", T.id, "23", "aai-node-type", "pserver", "pserver-id", "PserverID2", "hostname", "PserverHostName2"); //false
+
+ Vertex serviceinstance1 = graph.addVertex(T.label, "service-instance", T.id, "24", "aai-node-type", "service-instance", "service-instance-id", "service-instance-id-1", "service-instance-name", "service-instance-name-1");
+ Vertex serviceinstance2 = graph.addVertex(T.label, "service-instance", T.id, "25", "aai-node-type", "service-instance", "service-instance-id", "servInstId-2", "service-type", "servType-2", "service-role", "servRole-2");
+
+ Vertex vfmodule1 = graph.addVertex(T.label, "vf-module", T.id, "26", "aai-node-type", "vf-module", "vf-module-id", "vf-module-id-1", "vf-module-name", "vf-module-name1");
+ Vertex vfmodule2 = graph.addVertex(T.label, "vf-module", T.id, "27", "aai-node-type", "vf-module", "vf-module-id", "vf-module-id-2", "vf-module-name", "vf-module-name2");
+
+ Vertex volumegroup1 = graph.addVertex(T.label, "volume-group", T.id, "28", "aai-node-type", "volume-group", "volume-group-id", "volume-group-id-1", "volume-group-name", "volume-group-name1");
+ Vertex volumegroup2 = graph.addVertex(T.label, "volume-group", T.id, "29", "aai-node-type", "volume-group", "volume-group-id", "volume-group-id-2", "volume-group-name", "volume-group-name2");
+
+ Vertex complex = graph.addVertex(T.label, "complex", T.id, "30", "aai-node-type", "complex");
+
+
+ GraphTraversalSource g = graph.traversal();//true
+
+ rules.addEdge(g, gnvf1, vserver1);//true
+
+ rules.addEdge(g, vserver1, vnfc1);//true
+ rules.addEdge(g, vserver2, vnfc1);//true
+
+ rules.addTreeEdge(g, vserver1, tenant1);//true
+ rules.addTreeEdge(g, tenant1, cloudRegion1);//true
+ rules.addTreeEdge(g, cloudRegion1,availibityzone1 );//true
+ rules.addEdge(g, vserver1, image1);//true
+ rules.addEdge(g, vserver1, flavor1);//true
+ rules.addEdge(g, vserver1, pserver1);//true
+ rules.addEdge(g, vserver2, image1);
+ rules.addEdge(g, vserver2, flavor1);
+ rules.addEdge(g, pserver1, complex);//true
+
+ rules.addTreeEdge(g, vserver1, linter1);//true
+ rules.addTreeEdge(g, linter1, l3inter1ipv4addresslist);//true
+ rules.addTreeEdge(g, linter1, l3inter1ipv6addresslist);//true
+
+ rules.addEdge(g, gnvf1, serviceinstance1);//true
+ rules.addTreeEdge(g, gnvf1, vfmodule1);//true
+ rules.addEdge(g, vfmodule1, volumegroup1);
+
+ //---------------------------------------------------
+
+ //rules.addTreeEdge(g, vserver1, tenant2);//false
+ //rules.addTreeEdge(g, vserver2, linter1);//false
+ //rules.addEdge(g, vserver1, vnfc2);//false
+
+
+
+ expectedResult.add(gnvf1);
+ expectedResult.add(vnfc1);
+ expectedResult.add(vserver1);
+ expectedResult.add(tenant1);
+ expectedResult.add(cloudRegion1);
+ expectedResult.add(image1);
+ expectedResult.add(flavor1);
+ expectedResult.add(pserver1);
+ expectedResult.add(complex);
+
+ expectedResult.add(serviceinstance1);
+ expectedResult.add(availibityzone1);
+ expectedResult.add(volumegroup1);
+ expectedResult.add(linter1);
+ expectedResult.add(l3inter1ipv4addresslist);
+ expectedResult.add(l3inter1ipv6addresslist);
+
+
+ }
+
+ @Override
+ protected String getQueryName() {
+ return "topology-detail-fromVnf";
+ }
+
+ @Override
+ protected void addStartNode(GraphTraversal<Vertex, Vertex> g) {
+ g.has("vnf-id", "vnfuuid");
+
+ }
+
+ @Override
+ protected void addParam(Map<String, Object> params) {
+ //return;
+ params.put("serviceId", "service-id-1");
+ }
+
+}
diff --git a/aai-traversal/src/test/java/org/onap/aai/rest/search/TopologyDetailFromVserverQueryTest.java b/aai-traversal/src/test/java/org/onap/aai/rest/search/TopologyDetailFromVserverQueryTest.java
index 6d9dd6c..d9821d0 100644
--- a/aai-traversal/src/test/java/org/onap/aai/rest/search/TopologyDetailFromVserverQueryTest.java
+++ b/aai-traversal/src/test/java/org/onap/aai/rest/search/TopologyDetailFromVserverQueryTest.java
@@ -61,28 +61,44 @@ public class TopologyDetailFromVserverQueryTest extends QueryTest {
Vertex pserver = graph.addVertex(T.label, "pserver", T.id, "17", "aai-node-type", "pserver", "hostname", "pservername1");
Vertex complex = graph.addVertex(T.label, "pserver", T.id, "18", "aai-node-type", "complex", "physical-location-id", "locationId", "physical-location-type", "locationType", "physical-location-id", "locationId",
"city", "cityName", "state", "stateName", "postal-code", "zip", "country", "countryName");
-
+ Vertex availabilityZone = graph.addVertex(T.label, "availability-zone", T.id, "19", "aai-node-type", "availability-zone", "availability-zone-name", "azName0", "hypervisor-type", "ht0");
+ Vertex virtualDataCenter = graph.addVertex(T.label, "virtual-data-center", T.id, "20", "aai-node-type", "virtual-data-center", "vdc-id", "vdcId0", "vdc-name", "vdcName0");
+ Vertex volumeGroup = graph.addVertex(T.label, "volume-group", T.id, "21", "aai-node-type", "volume-group", "volume-group-id", "vgId0", "volume-group-name", "vgName0", "vnf-type", "vnfType0");
+ Vertex image = graph.addVertex(T.label, "image", T.id, "22", "aai-node-type", "image", "image-id", "imageId0", "image-name", "imageName0", "image-os-distro", "imageOsDistro0", "image-os-version", "imageOsVersion0", "image-selflink", "imageSl0");
+ Vertex flavor = graph.addVertex(T.label, "flavor", T.id, "23", "aai-node-type", "flavor", "flavor-id", "flavorId0", "flavor-name", "flavorName0", "flavor-selflink", "flavorSl0");
+ Vertex vfModule = graph.addVertex(T.label, "vf-module", T.id, "24", "aai-node-type", "vf-module", "vf-module-id", "vfmId0", "is-base-vf-module", "true");
+ Vertex genericvnf2 = graph.addVertex(T.label, "generic-vnf", T.id, "25", "aai-node-type", "generic-vnf", "vnf-id", "vnfid1", "nf-type", "sample-nf-type");
+ Vertex vfModule2 = graph.addVertex(T.label, "vf-module", T.id, "26", "aai-node-type", "vf-module", "vf-module-id", "vfmId1", "is-base-vf-module", "true");
+
GraphTraversalSource g = graph.traversal();
rules.addTreeEdge(g, tenant, cloudregion);
rules.addTreeEdge(g, vserver, tenant);
rules.addEdge(g, pserver, vserver);
rules.addEdge(g, complex, pserver);
+ rules.addEdge(g, availabilityZone, pserver);
rules.addEdge(g, genericvnf, vserver);
+ rules.addTreeEdge(g, genericvnf, vfModule); // related to the genericvnf only, not the vserver
rules.addEdge(g, genericvnf, platform);
rules.addEdge(g, genericvnf, lineofbusiness);
rules.addEdge(g, genericvnf, vnfc);
rules.addEdge(g, genericvnf, servinst);
+ rules.addEdge(g, virtualDataCenter, genericvnf);
+ rules.addEdge(g, volumeGroup, genericvnf);
rules.addEdge(g, owningentity, servinst);
rules.addEdge(g, project, servinst);
rules.addTreeEdge(g, linterface, vserver);
rules.addTreeEdge(g, l3inter1ipv4addresslist, linterface);
- rules.addEdge(g, l3inter1ipv4addresslist, subnet4);
- rules.addTreeEdge(g, l3network4, subnet4);
- rules.addTreeEdge(g, l3inter1ipv6addresslist, linterface);
- rules.addEdge(g, l3inter1ipv6addresslist, subnet6);
- rules.addTreeEdge(g, l3network6, subnet6);
-
+ rules.addEdge(g, l3inter1ipv4addresslist, subnet4);
+ rules.addTreeEdge(g, l3network4, subnet4);
+ rules.addTreeEdge(g, l3inter1ipv6addresslist, linterface);
+ rules.addEdge(g, l3inter1ipv6addresslist, subnet6);
+ rules.addTreeEdge(g, l3network6, subnet6);
+ rules.addEdge(g, image, vserver);
+ rules.addEdge(g, flavor, vserver);
+ rules.addTreeEdge(g, genericvnf2, vfModule2);
+ rules.addEdge(g, vserver, vfModule2);
+
expectedResult.add(vserver);
expectedResult.add(linterface);
expectedResult.add(l3inter1ipv4addresslist);
@@ -91,14 +107,23 @@ public class TopologyDetailFromVserverQueryTest extends QueryTest {
expectedResult.add(l3inter1ipv6addresslist);
expectedResult.add(subnet6);
expectedResult.add(l3network6);
+ expectedResult.add(tenant);
expectedResult.add(cloudregion);
+ expectedResult.add(pserver);
expectedResult.add(complex);
+ expectedResult.add(availabilityZone);
expectedResult.add(genericvnf);
+ expectedResult.add(vfModule); // related to the genericvnf only, not the vserver
expectedResult.add(platform);
expectedResult.add(lineofbusiness);
+ expectedResult.add(virtualDataCenter);
+ expectedResult.add(volumeGroup);
expectedResult.add(owningentity);
expectedResult.add(project);
expectedResult.add(vnfc);
+ expectedResult.add(image);
+ expectedResult.add(flavor);
+ expectedResult.add(vfModule2); // related to the vserver
}
@Override
protected String getQueryName() {
diff --git a/aai-traversal/src/test/java/org/onap/aai/rest/search/TopologySummaryFromCloudRegionQueryTest.java b/aai-traversal/src/test/java/org/onap/aai/rest/search/TopologySummaryFromCloudRegionQueryTest.java
new file mode 100644
index 0000000..0377182
--- /dev/null
+++ b/aai-traversal/src/test/java/org/onap/aai/rest/search/TopologySummaryFromCloudRegionQueryTest.java
@@ -0,0 +1,118 @@
+/**
+ * ============LICENSE_START=======================================================
+ * org.onap.aai
+ * ================================================================================
+ * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY 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.rest.search;
+
+import java.util.Map;
+
+import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversal;
+import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource;
+import org.apache.tinkerpop.gremlin.structure.T;
+import org.apache.tinkerpop.gremlin.structure.Vertex;
+import org.junit.Test;
+
+import org.onap.aai.exceptions.AAIException;
+import org.onap.aai.serialization.db.exceptions.NoEdgeRuleFoundException;
+
+public class TopologySummaryFromCloudRegionQueryTest extends QueryTest{
+
+ public TopologySummaryFromCloudRegionQueryTest() throws AAIException, NoEdgeRuleFoundException{
+ super();
+ }
+
+ @Test
+ public void run() {
+ super.run();
+ }
+
+ @Override
+ protected void createGraph() throws AAIException, NoEdgeRuleFoundException {
+ Vertex region = graph.addVertex(T.label, "cloud-region", T.id, "1", "aai-node-type", "cloud-region", "cloud-region-id", "cloud-region-id-1",
+ "cloud-region-owner", "cloud-region-owner-1","cloud-region-version","cloud-region-version-1");
+ Vertex tenant = graph.addVertex(T.label, "tenant", T.id, "2", "aai-node-type", "tenant", "tenant-id", "tenant-id-1",
+ "tenant-name", "tenant-name-1");
+ Vertex vserver = graph.addVertex(T.label, "vserver", T.id, "3", "aai-node-type", "vserver", "vserver-id", "vserver-id-1",
+ "vserver-name", "vserver-name-1");
+ Vertex vnf = graph.addVertex(T.label, "generic-vnf", T.id, "4", "aai-node-type", "generic-vnf", "vnf-id", "vnf-uuid-1",
+ "vnf-name", "vnf-name=1");
+ Vertex vnfc = graph.addVertex(T.label, "vnfc", T.id, "13", "aai-node-type", "vnfc", "vnfc-name", "VnfcName", "nfc-naming-code",
+ "NfcNamingCode", "nfc-function", "NfcFunction", "in-maint", "false", "is-closed-loop-disabled", "false");
+ Vertex vnfc2 = graph.addVertex(T.label, "vnfc", T.id, "15", "aai-node-type", "vnfc", "vnfc-name", "VnfcName3", "nfc-naming-code",
+ "NfcNamingCode3", "nfc-function", "NfcFunction3", "in-maint", "false", "is-closed-loop-disabled", "false");
+ Vertex pserver = graph.addVertex(T.label, "pserver", T.id, "5", "aai-node-type", "pserver", "hostname", "pserver-hostname-1");
+ Vertex pserver2 = graph.addVertex(T.label, "pserver", T.id, "6", "aai-node-type", "pserver", "hostname", "pserver-hostname-2");
+
+ Vertex region_exclude = graph.addVertex(T.label, "cloud-region", T.id, "7", "aai-node-type", "cloud-region", "cloud-region-id", "cloud-region-id-2",
+ "cloud-region-owner", "cloud-region-owner-2","cloud-region-version","cloud-region-version-2");
+ Vertex tenant_exclude = graph.addVertex(T.label, "tenant", T.id, "8", "aai-node-type", "tenant", "tenant-id", "tenant-id-2",
+ "tenant-name", "tenant-name-2");
+ Vertex vserver_exclude = graph.addVertex(T.label, "vserver", T.id, "9", "aai-node-type", "vserver", "vserver-id", "vserver-id-2",
+ "vserver-name", "vserver-name-2");
+ Vertex vnf_exclude = graph.addVertex(T.label, "generic-vnf", T.id, "10", "aai-node-type", "generic-vnf", "vnf-id", "vnf-uuid-2",
+ "vnf-name", "vnf-name=2");
+ Vertex vnfc_exclude = graph.addVertex(T.label, "vnfc", T.id, "14", "aai-node-type", "vnfc", "vnfc-name", "VnfcName2", "nfc-naming-code",
+ "NfcNamingCode2", "nfc-function", "NfcFunction2", "in-maint", "false", "is-closed-loop-disabled", "false");
+ Vertex vnfc_exclude2 = graph.addVertex(T.label, "vnfc", T.id, "16", "aai-node-type", "vnfc", "vnfc-name", "VnfcName4", "nfc-naming-code",
+ "NfcNamingCode4", "nfc-function", "NfcFunction4", "in-maint", "false", "is-closed-loop-disabled", "false");
+ Vertex pserver_exclude = graph.addVertex(T.label, "pserver", T.id, "11", "aai-node-type", "pserver", "hostname", "pserver-hostname-2");
+ Vertex pserver2_exclude = graph.addVertex(T.label, "pserver", T.id, "12", "aai-node-type", "pserver", "hostname", "pserver-hostname-3");
+
+ GraphTraversalSource g = graph.traversal();
+ rules.addTreeEdge(g, region, tenant);
+ rules.addTreeEdge(g, tenant, vserver);
+ rules.addEdge(g, vserver, pserver);
+ rules.addEdge(g, vserver, vnf);
+ rules.addEdge(g, vnf, vnfc);
+ rules.addEdge(g, vserver, vnfc2);
+ rules.addEdge(g, region, pserver2);
+
+ rules.addTreeEdge(g, region_exclude, tenant_exclude);
+ rules.addTreeEdge(g, tenant_exclude, vserver_exclude);
+ rules.addEdge(g, vserver_exclude, pserver_exclude);
+ rules.addEdge(g, vserver_exclude, vnf_exclude);
+ rules.addEdge(g, vnf_exclude, vnfc_exclude);
+ rules.addEdge(g, vserver_exclude, vnfc_exclude2);
+ rules.addEdge(g, region_exclude, pserver2_exclude);
+
+ expectedResult.add(region);
+ expectedResult.add(tenant);
+ expectedResult.add(vserver);
+ expectedResult.add(pserver);
+ expectedResult.add(vnf);
+ expectedResult.add(vnfc);
+ expectedResult.add(vnfc2);
+ expectedResult.add(pserver2);
+ }
+
+ @Override
+ protected String getQueryName() {
+ return "topology-summary-fromCloudRegion";
+ }
+
+ @Override
+ protected void addStartNode(GraphTraversal<Vertex, Vertex> g) {
+ g.has("cloud-region-id", "cloud-region-id-1").has("cloud-region-owner", "cloud-region-owner-1");
+ }
+
+ @Override
+ protected void addParam(Map<String, Object> params) {
+ return;
+ }
+
+}
diff --git a/aai-traversal/src/test/java/org/onap/aai/rest/search/TopologySummaryFromTenantTest.java b/aai-traversal/src/test/java/org/onap/aai/rest/search/TopologySummaryFromTenantTest.java
new file mode 100644
index 0000000..36c7396
--- /dev/null
+++ b/aai-traversal/src/test/java/org/onap/aai/rest/search/TopologySummaryFromTenantTest.java
@@ -0,0 +1,93 @@
+/**
+ * ============LICENSE_START=======================================================
+ * org.onap.aai
+ * ================================================================================
+ * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY 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.rest.search;
+
+import java.util.Map;
+
+import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversal;
+import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource;
+import org.apache.tinkerpop.gremlin.structure.T;
+import org.apache.tinkerpop.gremlin.structure.Vertex;
+import org.junit.Test;
+import org.onap.aai.exceptions.AAIException;
+import org.onap.aai.serialization.db.exceptions.NoEdgeRuleFoundException;
+
+public class TopologySummaryFromTenantTest extends QueryTest {
+
+ public TopologySummaryFromTenantTest() throws AAIException,NoEdgeRuleFoundException {
+ super();
+ }
+
+ @Test
+ public void run() {
+ super.run();
+ }
+
+ @Override
+ protected void createGraph() throws AAIException, NoEdgeRuleFoundException {
+ Vertex tenant = graph.addVertex(T.label, "tenant-id", T.id, "0", "aai-node-type", "tenant", "tenant-id", "TenantID", "tenant-name", "TenantName");
+ Vertex cloudRegion = graph.addVertex(T.label, "cloud-region", T.id, "1", "aai-node-type", "cloud-region", "cloud-owner", "CloudOwner", "cloud-region-id", "CloudRegionId");
+ Vertex vserver = graph.addVertex(T.label, "vserver", T.id, "2", "aai-node-type", "vserver", "vserver-id", "vservId-1", "vserver-name", "vserv-name-1", "vserver-selflink", "me/self");
+ Vertex genericVnf = graph.addVertex(T.label, "generic-vnf", T.id, "3", "aai-node-type", "generic-vnf", "vnf-id", "VnfID", "vnf-name", "VnfName", "vnf-type", "VnfType");
+ Vertex pserver = graph.addVertex(T.label, "pserver", T.id, "4", "aai-node-type", "pserver", "pserver-id", "PserverID", "hostname", "PserverHostName");
+
+ Vertex tenant2 = graph.addVertex(T.label, "tenant-id2", T.id, "5", "aai-node-type", "tenant", "tenant-id", "TenantID2", "tenant-name", "TenantName2");
+ Vertex cloudRegion2 = graph.addVertex(T.label, "cloud-region2", T.id, "6", "aai-node-type", "cloud-region", "cloud-owner", "CloudOwner2", "cloud-region-id", "CloudRegionId2");
+ Vertex vserver2 = graph.addVertex(T.label, "vserver2", T.id, "7", "aai-node-type", "vserver", "vserver-id", "vservId-2", "vserver-name", "vserv-name-2", "vserver-selflink", "me/self"); //false
+ Vertex genericVnf2 = graph.addVertex(T.label, "generic-vnf2", T.id, "8", "aai-node-type", "generic-vnf", "vnf-id", "VnfID2", "vnf-name", "VnfName2", "vnf-type", "VnfType"); //false
+ Vertex pserver2 = graph.addVertex(T.label, "pserver2", T.id, "9", "aai-node-type", "pserver", "pserver-id", "PserverID2", "hostname", "PserverHostName2"); //false
+
+ GraphTraversalSource g = graph.traversal();
+ rules.addTreeEdge(g, tenant, cloudRegion);
+ rules.addTreeEdge(g, tenant, vserver);
+ rules.addEdge(g, vserver, genericVnf);
+ rules.addEdge(g, vserver, pserver);
+
+ //tenant2
+ rules.addTreeEdge(g, tenant2, cloudRegion2);//false
+ rules.addTreeEdge(g, tenant2, vserver2);//false
+ rules.addEdge(g, vserver2, genericVnf2); //false
+ rules.addEdge(g, vserver2, pserver2); //false
+
+
+ expectedResult.add(tenant);
+ expectedResult.add(cloudRegion);
+ expectedResult.add(vserver);
+ expectedResult.add(genericVnf);
+ expectedResult.add(pserver);
+
+ }
+
+ @Override
+ protected String getQueryName() {
+ return "topology-summary-fromTenant";
+ }
+
+ @Override
+ protected void addStartNode(GraphTraversal<Vertex, Vertex> g) {
+ g.has("aai-node-type", "tenant").has("tenant-id","TenantID");
+ }
+
+ @Override
+ protected void addParam(Map<String, Object> params) {
+ return;
+ }
+
+}
diff --git a/aai-traversal/src/test/java/org/onap/aai/rest/search/TreeQueryTest.java b/aai-traversal/src/test/java/org/onap/aai/rest/search/TreeQueryTest.java
index 1ec880c..109cfc1 100644
--- a/aai-traversal/src/test/java/org/onap/aai/rest/search/TreeQueryTest.java
+++ b/aai-traversal/src/test/java/org/onap/aai/rest/search/TreeQueryTest.java
@@ -2,7 +2,7 @@
* ============LICENSE_START=======================================================
* org.onap.aai
* ================================================================================
- * Copyright © 2017 AT&T Intellectual Property. All rights reserved.
+ * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -16,8 +16,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
* ============LICENSE_END=========================================================
- *
- * ECOMP is a trademark and service mark of AT&T Intellectual Property.
*/
package org.onap.aai.rest.search;
diff --git a/aai-traversal/src/test/java/org/onap/aai/rest/search/UcpeTopologyQueryTest.java b/aai-traversal/src/test/java/org/onap/aai/rest/search/UcpeTopologyQueryTest.java
index d4eac58..4503717 100644
--- a/aai-traversal/src/test/java/org/onap/aai/rest/search/UcpeTopologyQueryTest.java
+++ b/aai-traversal/src/test/java/org/onap/aai/rest/search/UcpeTopologyQueryTest.java
@@ -53,9 +53,9 @@ public class UcpeTopologyQueryTest extends QueryTest {
Vertex tenant = graph.addVertex(T.label, "tenant", T.id, "5", "aai-node-type", "tenant", "tenant-id", "tenantuuid", "tenant-name", "tenantname");
Vertex cloudregion = graph.addVertex(T.label, "cloud-region", T.id, "6", "aai-node-type", "cloud-region", "cloud-region-id", "clouduuid", "cloud-region-owner", "cloudOwnername");
Vertex vnf1 = graph.addVertex(T.label, "generic-vnf", T.id, "7", "aai-node-type", "generic-vnf", "vnf-id", "vnf1uuid");
- Vertex vnf1image = graph.addVertex(T.label, "vnf-image", T.id, "8", "aai-node-type", "vnf-image", "vnf-image-uuid", "vnf1imageuuid");
+ Vertex vnf1image = graph.addVertex(T.label, "vnf-image", T.id, "8", "aai-node-type", "vnf-image", "att-uuid", "vnf1imageuuid");
Vertex vnf2 = graph.addVertex(T.label, "generic-vnf", T.id, "9", "aai-node-type", "generic-vnf", "vnf-id", "vnf1uuid");
- Vertex vnf2image = graph.addVertex(T.label, "vnf-image", T.id, "10", "aai-node-type", "vnf-image", "vnf-image-uuid", "vnf2imageuuid");
+ Vertex vnf2image = graph.addVertex(T.label, "vnf-image", T.id, "10", "aai-node-type", "vnf-image", "att-uuid", "vnf2imageuuid");
Vertex pnf = graph.addVertex(T.label, "pnf", T.id, "11", "aai-node-type", "pnf", "pnf-name", "pnf1name");
Vertex pnfint = graph.addVertex(T.label, "p-interface", T.id, "12", "aai-node-type", "p-interface", "interface-name", "ge0/0/0");
Vertex plink1 = graph.addVertex(T.label, "physical-link", T.id, "13", "aai-node-type", "physical-link", "link-name", "ge0/0/0-to-xe0/0/0");
diff --git a/aai-traversal/src/test/java/org/onap/aai/rest/search/VfModuleFromServiceInstanceTest.java b/aai-traversal/src/test/java/org/onap/aai/rest/search/VfModuleFromServiceInstanceTest.java
new file mode 100644
index 0000000..0d2d11a
--- /dev/null
+++ b/aai-traversal/src/test/java/org/onap/aai/rest/search/VfModuleFromServiceInstanceTest.java
@@ -0,0 +1,84 @@
+/**
+ * ============LICENSE_START=======================================================
+ * org.onap.aai
+ * ================================================================================
+ * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY 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.rest.search;
+
+
+import java.util.Map;
+
+import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversal;
+import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource;
+import org.apache.tinkerpop.gremlin.structure.T;
+import org.apache.tinkerpop.gremlin.structure.Vertex;
+import org.junit.Test;
+import org.onap.aai.exceptions.AAIException;
+import org.onap.aai.serialization.db.exceptions.NoEdgeRuleFoundException;
+
+public class VfModuleFromServiceInstanceTest extends QueryTest {
+
+ public VfModuleFromServiceInstanceTest() throws AAIException, NoEdgeRuleFoundException {
+ super();
+ }
+
+ @Test
+ public void test() {
+ super.run();
+ }
+
+ @Override
+ protected void createGraph() throws AAIException, NoEdgeRuleFoundException {
+ //Set up the test graph
+ Vertex serviceinstance = graph.addVertex(T.label, "service-instance", T.id, "0", "aai-node-type", "service-instance", "service-instance-id", "s-instance-id1");
+ Vertex vfmodule = graph.addVertex(T.label, "vf-module", T.id, "2", "aai-node-type", "vf-module", "vf-module-id", "vf-module-id-0", "vf-module-name", "vf-module-name0");
+
+ Vertex gnvf = graph.addVertex(T.label, "generic-vnf", T.id, "1", "aai-node-type", "generic-vnf", "vnf-id", "vnf-id-0", "vnf-name", "vnf-name-0");
+
+
+ Vertex serviceinstance1 = graph.addVertex(T.label, "service-instance", T.id, "10", "aai-node-type", "service-instance", "service-instance-id", "s-instance-id11");
+ Vertex vfmodule1 = graph.addVertex(T.label, "vf-module", T.id, "12", "aai-node-type", "vf-module", "vf-module-id", "vf-module-id-01", "vf-module-name", "vf-module-name01");
+
+ Vertex gnvf1 = graph.addVertex(T.label, "generic-vnf", T.id, "11", "aai-node-type", "generic-vnf", "vnf-id", "vnf-id-01", "vnf-name", "vnf-name-01");
+
+ GraphTraversalSource g = graph.traversal();
+ rules.addEdge(g, serviceinstance, gnvf);
+ rules.addTreeEdge(g, gnvf, vfmodule);
+
+ rules.addEdge(g, serviceinstance1, gnvf1); //false
+ rules.addTreeEdge(g, gnvf1, vfmodule1); //false
+
+ expectedResult.add(vfmodule);
+
+ }
+
+ @Override
+ protected String getQueryName() {
+ return "vfModule-fromServiceInstance";
+ }
+
+ @Override
+ protected void addStartNode(GraphTraversal<Vertex, Vertex> g) {
+ g.has("aai-node-type", "service-instance").has("service-instance-id", "s-instance-id1");
+ }
+
+ @Override
+ protected void addParam(Map<String, Object> params) {
+ return;
+ }
+
+}
diff --git a/aai-traversal/src/test/java/org/onap/aai/rest/search/VnfToServiceInstanceQueryTest.java b/aai-traversal/src/test/java/org/onap/aai/rest/search/VnfToServiceInstanceQueryTest.java
new file mode 100644
index 0000000..dfd36b7
--- /dev/null
+++ b/aai-traversal/src/test/java/org/onap/aai/rest/search/VnfToServiceInstanceQueryTest.java
@@ -0,0 +1,75 @@
+/**
+ * ============LICENSE_START=======================================================
+ * org.onap.aai
+ * ================================================================================
+ * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY 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.rest.search;
+
+import java.util.Map;
+
+import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversal;
+import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource;
+import org.apache.tinkerpop.gremlin.structure.T;
+import org.apache.tinkerpop.gremlin.structure.Vertex;
+import org.junit.Test;
+import org.onap.aai.exceptions.AAIException;
+import org.onap.aai.serialization.db.exceptions.NoEdgeRuleFoundException;
+
+public class VnfToServiceInstanceQueryTest extends QueryTest {
+ public VnfToServiceInstanceQueryTest() throws AAIException, NoEdgeRuleFoundException {
+ super();
+ }
+
+ @Test
+ public void run() {
+ super.run();
+ }
+ @Override
+ protected void createGraph() throws AAIException, NoEdgeRuleFoundException {
+
+
+ //Set up the test graph
+ Vertex serviceinstance1 = graph.addVertex(T.label, "service-instance", T.id, "1", "aai-node-type", "service-instance", "service-instance-id", "service-instance-id-1", "service-instance-name", "service-instance-name-1");
+ Vertex serviceinstance2 = graph.addVertex(T.label, "service-instance", T.id, "2", "aai-node-type", "service-instance", "service-instance-id", "service-instance-id-2", "service-instance-name", "service-instance-name-2");
+
+ Vertex vnf1 = graph.addVertex(T.label, "generic-vnf", T.id, "3", "aai-node-type", "generic-vnf", "vnf-id", "vnfid1", "vnf-name", "vnfname1", "vnf-type", "vnftype1");
+ Vertex vnf2 = graph.addVertex(T.label, "generic-vnf", T.id, "4", "aai-node-type", "generic-vnf", "vnf-id", "vnfid2", "vnf-name", "vnfname2", "vnf-type", "vnftype1");
+
+ GraphTraversalSource g = graph.traversal();
+
+ rules.addEdge(g, vnf1, serviceinstance1);//true
+ rules.addEdge(g, vnf2, serviceinstance1);
+
+ expectedResult.add(vnf1);
+ expectedResult.add(serviceinstance1);
+ expectedResult.add(vnf2);
+
+ }
+ @Override
+ protected String getQueryName() {
+ return "vnf-to-service-instance";
+ }
+ @Override
+ protected void addStartNode(GraphTraversal<Vertex, Vertex> g) {
+ g.has("aai-node-type", "generic-vnf").has("vnf-id", "vnfid1");
+ }
+
+ @Override
+ protected void addParam(Map<String, Object> params) {
+ return;
+ }
+}
diff --git a/aai-traversal/src/test/java/org/onap/aai/rest/search/VnfTopologyFromServiceInstanceTest.java b/aai-traversal/src/test/java/org/onap/aai/rest/search/VnfTopologyFromServiceInstanceTest.java
deleted file mode 100644
index 120f3ac..0000000
--- a/aai-traversal/src/test/java/org/onap/aai/rest/search/VnfTopologyFromServiceInstanceTest.java
+++ /dev/null
@@ -1,126 +0,0 @@
-/**
- * ============LICENSE_START=======================================================
- * org.onap.aai
- * ================================================================================
- * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY 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.rest.search;
-
-import java.util.Map;
-
-import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversal;
-import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource;
-import org.apache.tinkerpop.gremlin.structure.T;
-import org.apache.tinkerpop.gremlin.structure.Vertex;
-import org.junit.Test;
-import org.onap.aai.exceptions.AAIException;
-import org.onap.aai.serialization.db.exceptions.NoEdgeRuleFoundException;
-
-public class VnfTopologyFromServiceInstanceTest extends QueryTest {
- public VnfTopologyFromServiceInstanceTest() throws AAIException, NoEdgeRuleFoundException {
- super();
- }
-
- @Test
- public void run() {
- super.run();
- }
-
- @Override
- protected void createGraph() throws AAIException, NoEdgeRuleFoundException {
- //Set up the test graph
- Vertex gnvf1 = graph.addVertex(T.label, "generic-vnf", T.id, "0", "aai-node-type", "generic-vnf", "vnf-id", "vnf-id-1", "vnf-name", "vnf-name-1");
- Vertex serviceinstance = graph.addVertex(T.label, "service-instance", T.id, "1", "aai-node-type", "service-instance", "service-instance-id", "service-instance-id-1", "service-instance-name", "service-instance-name-1");
- Vertex servicesubscription = graph.addVertex(T.label, "service-subscription", T.id, "2", "aai-node-type", "service-subscription", "service-subscription-id", "service-subscription-id-1","service-subscription-name","service-subscription-name1");
- Vertex customer = graph.addVertex(T.label, "customer", T.id, "3", "aai-node-type", "customer", "customer-id", "customer-id-1", "customer-name", "customer-name1");
- Vertex allottedresource = graph.addVertex(T.label, "allotted-resource", T.id, "4", "aai-node-type", "allotted-resource", "allotted-resource-id", "allotted-resource-id-1", "allotted-resource-name", "allotted-resource-name1");
- Vertex vfmodule = graph.addVertex(T.label, "vf-module", T.id, "5", "aai-node-type", "vf-module", "vf-module-id", "vf-module-id-1", "vf-module-name", "vf-module-name1");
- Vertex volumegroup = graph.addVertex(T.label, "volume-group", T.id, "6", "aai-node-type", "volume-group", "volume-group-id", "volume-group-id-1", "volume-group-name", "volume-group-name1");
- Vertex linter1 = graph.addVertex(T.label, "l-interface", T.id, "7", "aai-node-type", "l-interface", "l-interface-id", "l-interface-id-1", "l-interface-name", "l-interface-name1");
- Vertex l3inter1ipv4addresslist = graph.addVertex(T.label, "interface-ipv4-address-list", T.id, "8", "aai-node-type", "l3-interface-ipv4-address-list", "l3-interface-ipv4-address-list-id", "l3-interface-ipv4-address-list-id-1", "l3-interface-ipv6-address-list-name", "l3-interface-ipv6-address-list-name1");
- Vertex l3network1 = graph.addVertex(T.label, "l3-network", T.id, "9", "aai-node-type", "l3-network", "ll3-network-id", "l3-network-id-1", "l3-network-name", "l3-network-name1");
- Vertex l3inter1ipv6addresslist = graph.addVertex(T.label, "l3-interface-ipv6-address-list", T.id, "10", "aai-node-type", "l3-interface-ipv6-address-list", "l3-interface-ipv6-address-list-id", "l3-interface-ipv6-address-list-id-1", "l3-interface-ipv6-address-list-name", "l3-interface-ipv6-address-list-name1");
- Vertex vserver = graph.addVertex(T.label, "vserver", T.id, "11", "aai-node-type", "vserver", "vserver-name1", "vservername1");
- Vertex tenant = graph.addVertex(T.label, "tenant", T.id, "12", "aai-node-type", "tenant", "tenant-name1", "tenant-name-1","tenant-id", "tenant-id-1");
- Vertex region1 = graph.addVertex(T.label, "cloud-region", T.id, "13", "aai-node-type", "cloud-region", "cloud-owner", "cloudOwner1");
- Vertex pserver = graph.addVertex(T.label, "pserver", T.id, "14", "aai-node-type", "pserver", "hostname", "pservername");
- Vertex linter2 = graph.addVertex(T.label, "l-interface", T.id, "15", "aai-node-type", "l-interface", "l-interface-id", "l-interface-id-2", "l-interface-name", "l-interface-name2");
- Vertex l3inter2ipv4addresslist = graph.addVertex(T.label, "interface-ipv6-address-list", T.id, "16", "aai-node-type", "l3-interface-ipv6-address-list", "l3-interface-ipv6-address-list-id", "l3-interface-ipv6-address-list-id-2", "l3-interface-ipv6-address-list-name", "l3-interface-ipv6-address-list-name2");
- Vertex l3network2 = graph.addVertex(T.label, "l3-network", T.id, "17", "aai-node-type", "l3-network", "ll3-network-id", "l3-network-id-2", "l3-network-name", "l3-network-name2");
- Vertex l3inter2ipv6addresslist = graph.addVertex(T.label, "l3-interface-ipv6-address-list", T.id, "18", "aai-node-type", "l3-interface-ipv6-address-list", "l3-interface-ipv6-address-list-id", "l3-interface-ipv6-address-list-id-2", "l3-interface-ipv6-address-list-name", "l3-interface-ipv6-address-list-name2");
- Vertex l3network3 = graph.addVertex(T.label, "l3-network", T.id, "19", "aai-node-type", "l3-network", "ll3-network-id", "l3-network-id-3", "l3-network-name", "l3-network-name3");
- Vertex l3network4 = graph.addVertex(T.label, "l3-network", T.id, "20", "aai-node-type", "l3-network", "ll3-network-id", "l3-network-id-4", "l3-network-name", "l3-network-name4");
-
-
-
- GraphTraversalSource g = graph.traversal();
- rules.addEdge(g, gnvf1, serviceinstance);//false
- rules.addTreeEdge(g, serviceinstance, servicesubscription);//true
- rules.addTreeEdge(g, servicesubscription, customer);//true
- rules.addTreeEdge(g, serviceinstance, allottedresource);//true
- rules.addTreeEdge(g, gnvf1, vfmodule);//true
- rules.addEdge(g, gnvf1, volumegroup);//false
- rules.addTreeEdge(g, gnvf1, linter1);//true
- rules.addTreeEdge(g, linter1, l3inter1ipv4addresslist);//true
- rules.addEdge(g, l3inter1ipv4addresslist, l3network1);//false
- rules.addTreeEdge(g, linter1, l3inter1ipv6addresslist);//true
- rules.addEdge(g, l3inter1ipv6addresslist, l3network2);//false
- rules.addEdge(g, gnvf1, vserver);//false
- rules.addTreeEdge(g, vserver, tenant);//true
- rules.addTreeEdge(g, tenant, region1);//true
- rules.addEdge(g, vserver, pserver);//false
- rules.addTreeEdge(g, vserver, linter2);//false
- rules.addTreeEdge(g, linter2, l3inter2ipv4addresslist);//false
- rules.addEdge(g, l3inter2ipv4addresslist, l3network3);//false
- rules.addTreeEdge(g, linter2, l3inter2ipv6addresslist);//true
- rules.addEdge(g, l3inter2ipv6addresslist, l3network4);//true
-
-
- expectedResult.add(gnvf1);
- expectedResult.add(serviceinstance);
- expectedResult.add(customer);
- expectedResult.add(allottedresource);
- expectedResult.add(vfmodule);
- expectedResult.add(volumegroup);
- expectedResult.add(l3inter1ipv4addresslist);
- expectedResult.add(l3network1);
- expectedResult.add(l3inter1ipv6addresslist);
- expectedResult.add(l3network2);
- expectedResult.add(vserver);
- expectedResult.add(tenant);
- expectedResult.add(region1);
- expectedResult.add(pserver);
- expectedResult.add(l3inter2ipv4addresslist);
- expectedResult.add(l3network3);
- expectedResult.add(l3inter2ipv6addresslist);
- expectedResult.add(l3network4);
-
- }
-
- @Override
- protected String getQueryName() {
- return "vnf-topology-fromServiceInstance";
- }
- @Override
- protected void addStartNode(GraphTraversal<Vertex, Vertex> g) {
- g.has("service-instance-name", "service-instance-name-1");
-
- }
- @Override
- protected void addParam(Map<String, Object> params) {
- return;
- }
-}
diff --git a/aai-traversal/src/test/java/org/onap/aai/rest/search/VnfTopologyFromVnfTest.java b/aai-traversal/src/test/java/org/onap/aai/rest/search/VnfTopologyFromVnfTest.java
index 235e217..4441d3f 100644
--- a/aai-traversal/src/test/java/org/onap/aai/rest/search/VnfTopologyFromVnfTest.java
+++ b/aai-traversal/src/test/java/org/onap/aai/rest/search/VnfTopologyFromVnfTest.java
@@ -92,10 +92,12 @@ public class VnfTopologyFromVnfTest extends QueryTest {
expectedResult.add(gnvf1);
expectedResult.add(serviceinstance);
+ expectedResult.add(servicesubscription);
expectedResult.add(customer);
expectedResult.add(allottedresource);
expectedResult.add(vfmodule);
expectedResult.add(volumegroup);
+ expectedResult.add(linter1);
expectedResult.add(l3inter1ipv4addresslist);
expectedResult.add(l3network1);
expectedResult.add(l3inter1ipv6addresslist);
@@ -104,7 +106,7 @@ public class VnfTopologyFromVnfTest extends QueryTest {
expectedResult.add(tenant);
expectedResult.add(region1);
expectedResult.add(pserver);
- expectedResult.add(vserver);
+ expectedResult.add(linter2);
expectedResult.add(l3inter2ipv4addresslist);
expectedResult.add(l3network3);
expectedResult.add(l3inter2ipv6addresslist);
diff --git a/aai-traversal/src/test/java/org/onap/aai/rest/search/VnfsVlansFromServiceInstanceTest.java b/aai-traversal/src/test/java/org/onap/aai/rest/search/VnfsVlansFromServiceInstanceTest.java
new file mode 100644
index 0000000..f7c517e
--- /dev/null
+++ b/aai-traversal/src/test/java/org/onap/aai/rest/search/VnfsVlansFromServiceInstanceTest.java
@@ -0,0 +1,103 @@
+package org.onap.aai.rest.search; /**
+ * ============LICENSE_START=======================================================
+ * org.onap.aai
+ * ================================================================================
+ * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY 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.rest.search;
+
+import java.util.Map;
+
+import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversal;
+import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource;
+import org.apache.tinkerpop.gremlin.structure.T;
+import org.apache.tinkerpop.gremlin.structure.Vertex;
+import org.junit.Test;
+import org.onap.aai.exceptions.AAIException;
+import org.onap.aai.serialization.db.exceptions.NoEdgeRuleFoundException;
+
+public class VnfsVlansFromServiceInstanceTest extends QueryTest {
+ public VnfsVlansFromServiceInstanceTest() throws AAIException, NoEdgeRuleFoundException {
+ super();
+ }
+
+ @Test
+ public void run() {
+ super.run();
+ }
+ @Override
+ protected void createGraph() throws AAIException, NoEdgeRuleFoundException {
+
+
+ //Set up the test graph
+ Vertex serviceinstance1 = graph.addVertex(T.label, "service-instance", T.id, "0", "aai-node-type",
+ "service-instance", "service-instance-id", "service-instance-id-1", "service-instance-name",
+ "service-instance-name-1");
+
+ Vertex config1 = graph.addVertex(T.label, "configuration", T.id, "1", "aai-node-type", "configuration", "configuration-id", "configuration1");
+
+ Vertex gvnf1 = graph.addVertex(T.label, "generic-vnf", T.id, "2", "aai-node-type", "generic-vnf",
+ "vnf-id", "gvnf1", "vnf-name", "genvnfname1", "nf-type", "sample-nf-type");
+
+ Vertex linterface1 = graph.addVertex(T.label, "l-interface", T.id, "3", "aai-node-type", "l-interface", "l-interface-id", "l-interface-id0", "l-interface-name", "l-interface-name0","network-name","networkName0");
+
+ Vertex vlan1 = graph.addVertex(T.label, "vlan", T.id, "4", "aai-node-type", "vlan", "vlan-interface", "vlan-interface1");
+
+
+ Vertex serviceinstance2 = graph.addVertex(T.label, "service-instance", T.id, "5", "aai-node-type",
+ "service-instance", "service-instance-id", "service-instance-id-2", "service-instance-name",
+ "service-instance-name-1");
+
+ Vertex config2 = graph.addVertex(T.label, "configuration", T.id, "6", "aai-node-type", "configuration", "configuration-id", "configuration2");
+
+ Vertex gvnf2 = graph.addVertex(T.label, "generic-vnf", T.id, "7", "aai-node-type", "generic-vnf",
+ "vnf-id", "gvnf2", "vnf-name", "genvnfname2", "nf-type", "sample-nf-type");
+
+ Vertex linterface2 = graph.addVertex(T.label, "l-interface", T.id, "8", "aai-node-type", "l-interface", "l-interface-id", "l-interface-id2", "l-interface-name", "l-interface-name2","network-name","networkName1");
+
+ Vertex vlan2 = graph.addVertex(T.label, "vlan", T.id, "9", "aai-node-type", "vlan", "vlan-interface", "vlan-interface2");
+
+ GraphTraversalSource g = graph.traversal();
+
+ rules.addEdge(g, serviceinstance1, config1); // True
+ rules.addEdge(g, config1, gvnf1); // True
+ rules.addEdge(g, config1, linterface1); // True
+ rules.addTreeEdge(g, linterface1, vlan1); // True
+
+ rules.addEdge(g, serviceinstance2, config2); // False
+ rules.addEdge(g, config2, gvnf2); // False
+ rules.addEdge(g, config2, linterface2);// False
+ rules.addTreeEdge(g, linterface2, vlan2); // False
+
+ expectedResult.add(gvnf1);
+ expectedResult.add(vlan1);
+
+ }
+ @Override
+ protected String getQueryName() {
+ return "vnfs-vlans-fromServiceInstance";
+ }
+ @Override
+ protected void addStartNode(GraphTraversal<Vertex, Vertex> g) {
+ g.has("aai-node-type", "service-instance").has("service-instance-id", "service-instance-id-1");
+ }
+
+ @Override
+ protected void addParam(Map<String, Object> params) {
+ return;
+ }
+}*/ \ No newline at end of file
diff --git a/aai-traversal/src/test/java/org/onap/aai/rest/search/VserverFromPserverTreeTest.java b/aai-traversal/src/test/java/org/onap/aai/rest/search/VserverFromPserverTreeTest.java
new file mode 100644
index 0000000..79d070a
--- /dev/null
+++ b/aai-traversal/src/test/java/org/onap/aai/rest/search/VserverFromPserverTreeTest.java
@@ -0,0 +1,86 @@
+/**
+ * ============LICENSE_START=======================================================
+ * org.onap.aai
+ * ================================================================================
+ * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY 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.rest.search;
+
+import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversal;
+import org.apache.tinkerpop.gremlin.process.traversal.step.util.Tree;
+import org.apache.tinkerpop.gremlin.structure.T;
+import org.apache.tinkerpop.gremlin.structure.Vertex;
+import org.junit.Test;
+import org.onap.aai.exceptions.AAIException;
+import org.onap.aai.serialization.db.exceptions.NoEdgeRuleFoundException;
+
+import java.util.Map;
+
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+
+public class VserverFromPserverTreeTest extends TreeQueryTest {
+
+ public VserverFromPserverTreeTest() throws AAIException, NoEdgeRuleFoundException {
+ super();
+ }
+
+ @Override
+ protected void createGraph() throws AAIException, NoEdgeRuleFoundException {
+ Vertex p1 = graph.addVertex(T.label, "pserver", T.id, "0", "aai-node-type", "pserver", "hostname", "pserver-name-1");
+ Vertex p2 = graph.addVertex(T.label, "pserver", T.id, "1", "aai-node-type", "pserver", "hostname", "pserver-name-2");
+ Vertex v1 = graph.addVertex(T.label, "vserver", T.id, "2", "aai-node-type", "vserver", "vserver-id", "vservId-1", "vserver-name", "vserv-name-1", "vserver-selflink", "me/self");
+ Vertex v2 = graph.addVertex(T.label, "vserver", T.id, "3", "aai-node-type", "vserver", "vserver-id", "vservId-2", "vserver-name", "vserv-name-2", "vserver-selflink", "me/self");
+ Vertex v3 = graph.addVertex(T.label, "vserver", T.id, "4", "aai-node-type", "vserver", "vserver-id", "vservId-3", "vserver-name", "vserv-name-3", "vserver-selflink", "me/self");
+
+ rules.addEdge(gts, p1, v1);
+ rules.addEdge(gts, p1, v2);
+ rules.addEdge(gts, p1, v3);
+ }
+
+ @Test
+ public void run() {
+ super.run();
+ Tree tree = treeList.get(0);
+
+ Vertex p1 = graph.traversal().V().has("aai-node-type","pserver").has("hostname","pserver-name-1").next();
+ Vertex p2 = graph.traversal().V().has("aai-node-type","pserver").has("hostname","pserver-name-2").next();
+ Vertex v1 = graph.traversal().V().has("aai-node-type", "vserver").has("vserver-id","vservId-1").next();
+ Vertex v2 = graph.traversal().V().has("aai-node-type", "vserver").has("vserver-id","vservId-2").next();
+ Vertex v3 = graph.traversal().V().has("aai-node-type", "vserver").has("vserver-id","vservId-3").next();
+
+ assertTrue(tree.containsKey(p1));
+ assertTrue(((Tree) tree.get(p1)).containsKey(v1));
+ assertTrue(((Tree) tree.get(p1)).containsKey(v2));
+ assertTrue(((Tree) tree.get(p1)).containsKey(v3));
+ assertFalse(tree.containsKey(p2));
+ }
+
+ @Override
+ protected String getQueryName() {
+ return "vservers-fromPserver-tree";
+ }
+
+ @Override
+ protected void addStartNode(GraphTraversal<Vertex, Vertex> g) {
+ g.has("aai-node-type", "pserver").has("hostname", "pserver-name-1");
+ }
+
+ @Override
+ protected void addParam(Map<String, Object> params) {
+
+ }
+}
diff --git a/aai-traversal/src/test/java/org/onap/aai/rest/search/VserverFromVnfQueryTest.java b/aai-traversal/src/test/java/org/onap/aai/rest/search/VserverFromVnfQueryTest.java
index ae95c42..3dd7b25 100644
--- a/aai-traversal/src/test/java/org/onap/aai/rest/search/VserverFromVnfQueryTest.java
+++ b/aai-traversal/src/test/java/org/onap/aai/rest/search/VserverFromVnfQueryTest.java
@@ -19,8 +19,6 @@
*/
package org.onap.aai.rest.search;
-import static org.junit.Assert.*;
-
import java.util.Map;
import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversal;
@@ -53,6 +51,16 @@ public class VserverFromVnfQueryTest extends QueryTest {
Vertex ipv4 = graph.addVertex(T.id, "40", "aai-node-type", "l3-interface-ipv4-address-list", "l3-interface-ipv4-address", "0.0.0.0");
Vertex ipv6 = graph.addVertex(T.id, "50", "aai-node-type", "l3-interface-ipv6-address-list", "l3-interface-ipv6-address", "0.0.0.0");
+
+ Vertex gv1 = graph.addVertex(T.id, "60", "aai-node-type", "generic-vnf", "vnf-id", "gvId1", "vnf-name", "gvName1", "vnf-type", "some-type1");
+ Vertex vnfc1 = graph.addVertex(T.id, "70", "aai-node-type", "vnfc",
+ "vnfc-name", "vnfcName11", "nfc-naming-code", "blue1", "nfc-function", "correct-function1");
+ Vertex vserv1 = graph.addVertex(T.id, "80", "aai-node-type", "vserver",
+ "vserver-id", "vservId1", "vserver-name", "vservName1", "vserver-selflink", "me/self1");
+ Vertex lint1 = graph.addVertex(T.id, "90", "aai-node-type", "l-interface", "interface-name", "lintName1");
+ Vertex ipv41 = graph.addVertex(T.id, "1", "aai-node-type", "l3-interface-ipv4-address-list", "l3-interface-ipv4-address", "0.0.0.0.1");
+ Vertex ipv61 = graph.addVertex(T.id, "2", "aai-node-type", "l3-interface-ipv6-address-list", "l3-interface-ipv6-address", "0.0.0.0.1");
+
GraphTraversalSource g = graph.traversal();
rules.addEdge(g, gv, vnfc);
rules.addEdge(g, vserv, vnfc);
@@ -60,6 +68,12 @@ public class VserverFromVnfQueryTest extends QueryTest {
rules.addTreeEdge(g, lint, ipv4);
rules.addTreeEdge(g, lint, ipv6);
+ rules.addEdge(g, gv1, vnfc1);//false
+ rules.addEdge(g, vserv1, vnfc1);//false
+ rules.addTreeEdge(g, vserv1, lint1);//false
+ rules.addTreeEdge(g, lint1, ipv41);//false
+ rules.addTreeEdge(g, lint1, ipv61);//false
+
expectedResult.add(vserv);
expectedResult.add(lint);
expectedResult.add(ipv4);
@@ -79,7 +93,7 @@ public class VserverFromVnfQueryTest extends QueryTest {
@Override
protected void addParam(Map<String, Object> params) {
- params.put("nfcFunction", "correct-function");
+ params.put("nfcNamingCode", "blue");
}
diff --git a/aai-traversal/src/test/java/org/onap/aai/rest/search/VserverLinterfacesFromVnfcTest.java b/aai-traversal/src/test/java/org/onap/aai/rest/search/VserverLinterfacesFromVnfcTest.java
new file mode 100644
index 0000000..2c1a0ea
--- /dev/null
+++ b/aai-traversal/src/test/java/org/onap/aai/rest/search/VserverLinterfacesFromVnfcTest.java
@@ -0,0 +1,98 @@
+/**
+ * ============LICENSE_START=======================================================
+ * org.onap.aai
+ * ================================================================================
+ * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY 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.rest.search;
+
+import static org.junit.Assert.*;
+
+import java.util.Map;
+
+import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversal;
+import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource;
+import org.apache.tinkerpop.gremlin.structure.T;
+import org.apache.tinkerpop.gremlin.structure.Vertex;
+import org.junit.Test;
+import org.onap.aai.exceptions.AAIException;
+import org.onap.aai.serialization.db.exceptions.NoEdgeRuleFoundException;
+
+public class VserverLinterfacesFromVnfcTest extends QueryTest {
+
+ public VserverLinterfacesFromVnfcTest() throws AAIException, NoEdgeRuleFoundException {
+ super();
+ }
+
+ @Test
+ public void run() {
+ super.run();
+ }
+
+ @Override
+ protected void createGraph() throws AAIException, NoEdgeRuleFoundException {
+ Vertex vnfc = graph.addVertex(T.label, "vnfc",T.id, "0", "aai-node-type", "vnfc",
+ "vnfc-name", "vnfcName1", "nfc-naming-code", "blue", "nfc-function", "correct-function");
+ Vertex vserv = graph.addVertex(T.label, "vserver",T.id, "1", "aai-node-type", "vserver",
+ "vserver-id", "vservId", "vserver-name", "vservName", "vserver-selflink", "me/self");
+ Vertex linterface = graph.addVertex(T.label, "l-interface", T.id, "2", "aai-node-type", "l-interface", "l-interface-id", "l-interface-id0", "l-interface-name", "l-interface-name0","network-name","networkName0");
+ Vertex linterface1 = graph.addVertex(T.label, "l-interface", T.id, "3", "aai-node-type", "l-interface", "l-interface-id", "l-interface-id1", "l-interface-name", "l-interface-name1","network-name","networkName1");
+ Vertex vlan = graph.addVertex(T.label, "vlan", T.id, "4", "aai-node-type", "vlan", "vlan-interface", "vlan-interface0");
+
+
+ Vertex vnfc1 = graph.addVertex(T.label, "vnfc",T.id, "10", "aai-node-type", "vnfc",
+ "vnfc-name", "vnfcName2", "nfc-naming-code", "blue-1", "nfc-function", "correct-function-1");
+ Vertex vserv1 = graph.addVertex(T.label, "vserver",T.id, "11", "aai-node-type", "vserver",
+ "vserver-id", "vservId1", "vserver-name", "vservName1", "vserver-selflink", "me/self-1");
+ Vertex linterface2 = graph.addVertex(T.label, "l-interface", T.id, "12", "aai-node-type", "l-interface", "l-interface-id", "l-interface-id2", "l-interface-name", "l-interface-name2","network-name","networkName2");
+ Vertex linterface21 = graph.addVertex(T.label, "l-interface", T.id, "13", "aai-node-type", "l-interface", "l-interface-id", "l-interface-id21", "l-interface-name", "l-interface-name21","network-name","networkName21");
+ Vertex vlan1 = graph.addVertex(T.label, "vlan", T.id, "14", "aai-node-type", "vlan", "vlan-interface", "vlan-interface1");
+
+
+ GraphTraversalSource g = graph.traversal();
+ rules.addEdge(g, vnfc,vserv);
+ rules.addTreeEdge(g, vserv, linterface);
+ rules.addTreeEdge(g, linterface, linterface1);
+ rules.addTreeEdge(g, linterface1, vlan);
+
+ rules.addEdge(g, vnfc1,vserv1);//false
+ rules.addTreeEdge(g, vserv1, linterface2);//false
+ rules.addTreeEdge(g, linterface2, linterface21);//false
+ rules.addTreeEdge(g, linterface21, vlan1);//false
+
+ expectedResult.add(vserv);
+ expectedResult.add(linterface);
+ expectedResult.add(linterface1);
+ expectedResult.add(vlan);
+ }
+
+ @Override
+ protected String getQueryName() {
+ return "vserver-l-interfaces-fromVnfc";
+ }
+
+ @Override
+ protected void addStartNode(GraphTraversal<Vertex, Vertex> g) {
+ g.has("aai-node-type", "vnfc").has("vnfc-name", "vnfcName1");
+ }
+
+ @Override
+ protected void addParam(Map<String, Object> params) {
+ params.put("networkName", "networkName0");
+ }
+
+
+}
diff --git a/aai-traversal/src/test/java/org/onap/aai/rest/search/getSvcSubscriberModelInfoTest.java b/aai-traversal/src/test/java/org/onap/aai/rest/search/getSvcSubscriberModelInfoTest.java
new file mode 100644
index 0000000..c854f43
--- /dev/null
+++ b/aai-traversal/src/test/java/org/onap/aai/rest/search/getSvcSubscriberModelInfoTest.java
@@ -0,0 +1,76 @@
+/**
+ * ============LICENSE_START=======================================================
+ * org.onap.aai
+ * ================================================================================
+ * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY 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.rest.search;
+
+import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversal;
+import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource;
+import org.apache.tinkerpop.gremlin.structure.T;
+import org.apache.tinkerpop.gremlin.structure.Vertex;
+import org.junit.Test;
+import org.onap.aai.edges.exceptions.AmbiguousRuleChoiceException;
+import org.onap.aai.edges.exceptions.EdgeRuleNotFoundException;
+import org.onap.aai.exceptions.AAIException;
+import org.onap.aai.serialization.db.exceptions.NoEdgeRuleFoundException;
+
+import java.util.Map;
+
+public class getSvcSubscriberModelInfoTest extends QueryTest {
+
+ public getSvcSubscriberModelInfoTest() throws AAIException, NoEdgeRuleFoundException {
+ super();
+ }
+ @Test
+ public void run() {
+ super.run();
+ }
+
+
+
+ @Override
+ protected void createGraph() throws AAIException, EdgeRuleNotFoundException, AmbiguousRuleChoiceException {
+
+ Vertex serviceInstance = graph.addVertex(T.label, "service-instance", T.id, "1", "aai-node-type", "service-instance", "service-instance-id", "service-instance-id-1", "service-instance-name", "service-instance-name-1");
+ Vertex serviceSubscription = graph.addVertex(T.label, "service-subscription", T.id, "2", "aai-node-type", "service-subscription", "service-type", "service-subcription-1");
+ Vertex modelver = graph.addVertex(T.label, "model-ver", T.id, "3", "aai-node-type", "model-ver");
+
+ GraphTraversalSource g = graph.traversal();
+ rules.addTreeEdge(g, serviceInstance, serviceSubscription);
+ rules.addPrivateEdge(g, serviceInstance, modelver,null);
+
+ expectedResult.add(serviceInstance);
+ expectedResult.add(serviceSubscription);
+ expectedResult.add(modelver);
+
+ }
+
+
+ @Override
+ protected String getQueryName() {
+ return "getSvcSubscriberModelInfo";
+ }
+ @Override
+ protected void addStartNode(GraphTraversal<Vertex, Vertex> g) {
+ g.has("aai-node-type", "service-instance").has("service-instance-id", "service-instance-id-1");
+ }
+ @Override
+ protected void addParam(Map<String, Object> params) {
+ return;
+ }
+}
diff --git a/aai-traversal/src/test/java/org/onap/aai/rest/util/ValidateEncodingTest.java b/aai-traversal/src/test/java/org/onap/aai/rest/util/ValidateEncodingTest.java
index 3cfb775..bf7612b 100644
--- a/aai-traversal/src/test/java/org/onap/aai/rest/util/ValidateEncodingTest.java
+++ b/aai-traversal/src/test/java/org/onap/aai/rest/util/ValidateEncodingTest.java
@@ -76,6 +76,7 @@ public class ValidateEncodingTest {
assertEquals(false, validator.validate(mockUriInfo));
}
+
@Test
public void goodQueryParams() throws UnsupportedEncodingException {
MultivaluedHashMap<String, String> map = new MultivaluedHashMap<String, String>();
@@ -88,7 +89,19 @@ public class ValidateEncodingTest {
assertEquals(true, validator.validate(mockUriInfo));
}
-
+
+ @Test
+ public void testWhenQueryParameterHasPlusSignItShouldPass() throws UnsupportedEncodingException {
+
+ MultivaluedHashMap<String, String> map = new MultivaluedHashMap<String, String>();
+ map.putSingle("some-key", "test+one+two+three");
+ UriInfo mockUriInfo = getMockUriInfo("", map);
+
+ ValidateEncoding validator = ValidateEncoding.getInstance();
+
+ assertEquals(true, validator.validate(mockUriInfo));
+ }
+
private UriInfo getMockUriInfo(String path, MultivaluedMap<String, String> map) {
UriInfo mockUriInfo = Mockito.mock(UriInfo.class);
Mockito.when(mockUriInfo.getPath(false)).thenReturn(path);
diff --git a/aai-traversal/src/test/java/org/onap/aai/retiredcustomer/RetiredConsumerTest.java b/aai-traversal/src/test/java/org/onap/aai/retiredcustomer/RetiredConsumerTest.java
deleted file mode 100644
index 6a3ae9f..0000000
--- a/aai-traversal/src/test/java/org/onap/aai/retiredcustomer/RetiredConsumerTest.java
+++ /dev/null
@@ -1,127 +0,0 @@
-/**
- * ============LICENSE_START=======================================================
- * org.onap.aai
- * ================================================================================
- * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY 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.retiredcustomer;
-
-import com.att.eelf.configuration.EELFLogger;
-import com.att.eelf.configuration.EELFManager;
-import org.junit.Before;
-import org.junit.Test;
-import org.mockito.Mockito;
-import org.onap.aai.introspection.Version;
-import org.onap.aai.rest.retired.RetiredConsumer;
-
-import javax.ws.rs.core.*;
-import java.util.*;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.mockito.Matchers.anyObject;
-import static org.mockito.Mockito.when;
-
-public abstract class RetiredConsumerTest {
-
- protected static final MediaType APPLICATION_JSON = MediaType.valueOf("application/json");
-
- private static final Set<Integer> VALID_HTTP_STATUS_CODES = new HashSet<>();
-
- static {
- VALID_HTTP_STATUS_CODES.add(200);
- VALID_HTTP_STATUS_CODES.add(201);
- VALID_HTTP_STATUS_CODES.add(204);
- }
-
- protected RetiredConsumer retiredConsumer;
- protected HttpHeaders httpHeaders;
- protected UriInfo uriInfo;
-
- private MultivaluedMap<String, String> headersMultiMap;
- private MultivaluedMap<String, String> queryParameters;
-
- private List<String> aaiRequestContextList;
-
- private List<MediaType> outputMediaTypes;
-
- private static final EELFLogger logger = EELFManager.getInstance().getLogger(RetiredConsumer.class.getName());
-
- @Before
- public void setup(){
- logger.info("Starting the setup for the integration tests of Rest Endpoints");
-
- retiredConsumer = getRetiredConsumer();
- httpHeaders = Mockito.mock(HttpHeaders.class);
- uriInfo = Mockito.mock(UriInfo.class);
-
- headersMultiMap = new MultivaluedHashMap<>();
- queryParameters = Mockito.spy(new MultivaluedHashMap<>());
-
- headersMultiMap.add("X-FromAppId", "JUNIT");
- headersMultiMap.add("X-TransactionId", UUID.randomUUID().toString());
- headersMultiMap.add("Real-Time", "true");
- headersMultiMap.add("Accept", "application/json");
- headersMultiMap.add("aai-request-context", "");
-
- outputMediaTypes = new ArrayList<>();
- outputMediaTypes.add(APPLICATION_JSON);
-
- aaiRequestContextList = new ArrayList<>();
- aaiRequestContextList.add("");
-
- when(httpHeaders.getAcceptableMediaTypes()).thenReturn(outputMediaTypes);
- when(httpHeaders.getRequestHeaders()).thenReturn(headersMultiMap);
-
- when(httpHeaders.getRequestHeader("aai-request-context")).thenReturn(aaiRequestContextList);
-
-
- when(uriInfo.getQueryParameters()).thenReturn(queryParameters);
- when(uriInfo.getQueryParameters(false)).thenReturn(queryParameters);
-
- // TODO - Check if this is valid since RemoveDME2QueryParameters seems to be very unreasonable
- Mockito.doReturn(null).when(queryParameters).remove(anyObject());
-
- when(httpHeaders.getMediaType()).thenReturn(APPLICATION_JSON);
- }
-
- @Test
- public void testRetiredForAllEndPoints(){
- when(uriInfo.getPath()).thenReturn("/aai/v3/cloud-infrastructure/pservers/pserver/test-pserver1");
-
- Response response = retiredConsumer.createMessageGet(Version.getLatest().toString(), httpHeaders, uriInfo, null);
- assertNotNull(response);
- assertEquals(Response.Status.GONE.getStatusCode(), response.getStatus());
-
- response = retiredConsumer.createMessagePost(Version.getLatest().toString(), httpHeaders, uriInfo, null);
- assertNotNull(response);
- assertEquals(Response.Status.GONE.getStatusCode(), response.getStatus());
-
- response = retiredConsumer.createMessagePatch(Version.getLatest().toString(), httpHeaders, uriInfo, null);
- assertNotNull(response);
- assertEquals(Response.Status.GONE.getStatusCode(), response.getStatus());
-
- response = retiredConsumer.createMessagePut(Version.getLatest().toString(), httpHeaders, uriInfo, null);
- assertNotNull(response);
- assertEquals(Response.Status.GONE.getStatusCode(), response.getStatus());
-
- response = retiredConsumer.createMessageDelete(Version.getLatest().toString(), httpHeaders, uriInfo, null);
- assertNotNull(response);
- assertEquals(Response.Status.GONE.getStatusCode(), response.getStatus());
- }
-
- public abstract RetiredConsumer getRetiredConsumer();
-}
diff --git a/aai-traversal/src/test/resources/application-test.properties b/aai-traversal/src/test/resources/application-test.properties
index 9b6934b..e9ecb99 100644
--- a/aai-traversal/src/test/resources/application-test.properties
+++ b/aai-traversal/src/test/resources/application-test.properties
@@ -10,7 +10,9 @@ spring.jersey.type=filter
server.contextPath=/
spring.autoconfigure.exclude=org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration,org.springframework.boot.autoconfigure.orm.jpa.HibernateJpaAutoConfiguration
-spring.profiles.active=production
+spring.jersey.application-path=${schema.uri.base.path}
+
+spring.profiles.active=production,one-way-ssl
#The max number of active threads in this pool
server.tomcat.max-threads=200
#The minimum number of threads always kept alive
@@ -18,14 +20,8 @@ server.tomcat.min-Spare-Threads=25
#The number of milliseconds before an idle thread shutsdown, unless the number of active threads are less or equal to minSpareThreads
server.tomcat.max-idle-time=60000
-
-#Add this properties only if you want to change the URL, AJSC Framework interceptors will intercept
-#com.att.ajsc.common.interceptors.PreInterceptor.url=/**
-#com.att.ajsc.common.interceptors.PostInterceptor.url=/**
-
#Servlet context parameters
server.context_parameters.p-name=value #context parameter with p-name as key and value as value.
-kubernetes.namespace=org-onap-aai
# If you get an application startup failure that the port is already taken
# If thats not it, please check if the key-store file path makes sense
@@ -42,29 +38,38 @@ server.ssl.client-auth=want
server.ssl.key-store-type=JKS
# JMS bind address host port
-jms.bind.address=tcp://localhost:61647
-dmaap.ribbon.eureka.enabled=false
+jms.bind.address=tcp://localhost:61646
+
dmaap.ribbon.listOfServers=localhost:3904
-# Number of milliseconds to wait before making ping requests again
-dmaap.ribbon.ServerListRefreshInterval=75000
-dmaap.ribbon.NFLoadBalancerPingInterval=75000
-dmaap.ribbon.NFLoadBalancerRuleClassName=com.netflix.loadbalancer.AvailabilityFilteringRule
-dmaap.ribbon.NFLoadBalancerPingClassName=org.onap.aai.config.HttpPingImpl
-dmaap.ribbon.EnableMarkingServerDownOnReachingFailureLimit=true
-dmaap.ribbon.ServerDownFailureLimit=1
-# This needs to be verified but it seems that adding this property should automatically
-# Make the dmaap client change the url from http to https depending on the server
-dmaap.ribbon.securePorts=3905
-# Custom Dmaap Specific Configuration
-dmaap.ribbon.health.endpoint=/topics/AAI-EVENT
-# Number of seconds to wait for the ping to work and might need to increase this if the pings are all failing
-dmaap.ribbon.pingport.timeout=3
+# Schema related attributes for the oxm and edges
+# Any additional schema related attributes should start with prefix schema
+schema.configuration.location=N/A
+# Choose if the oxm schema is onap or other system
+schema.source.name=onap
+# Location of where the oxm files are
+schema.nodes.location=${server.local.startpath}/schema/${schema.source.name}/oxm/
+# Location of where the dbedgerules files are
+schema.edges.location=${server.local.startpath}/schema/${schema.source.name}/dbedgerules/
+# Location of where the stored queries are
+schema.queries.location=${server.local.startpath}/schema/${schema.source.name}/query/
+
+schema.ingest.file=${server.local.startpath}/application-test.properties
-niws.loadbalancer.dmaap.filterCircuitTripped=true
-niws.loadbalancer.dmaap.connectionFailureCountThreshold=3
-niws.loadbalancer.dmaap.circuitTripMaxTimeoutSeconds=180
-#dmaap.ribbon.retryableStatusCodes=404,503
-#dmaap.ribbon.retryableStatusCodes.MaxAutoRetriesNextServer=2
-#dmaap.ribbon.retryableStatusCodes.MaxAutoRetries=2
-#dmaap.ribbon.retryableStatusCodes.OkToRetryOnAllOperations=true
+# Schema Version Related Attributes
+schema.uri.base.path=/aai
+# Lists all of the versions in the schema
+schema.version.list=v8,v9,v10,v11,v12,v13,v14
+# Specifies from which version should the depth parameter to default to zero
+schema.version.depth.start=v9
+# Specifies from which version should the related link be displayed in response payload
+schema.version.related.link.start=v10
+# Specifies from which version should the client see only the uri excluding host info
+# Before this version server base will also be included
+schema.version.app.root.start=v11
+# Specifies from which version should the namespace be changed
+schema.version.namespace.change.start=v12
+# Specifies from which version should the client start seeing the edge label in payload
+schema.version.edge.label.start=v12
+# Specifies the version that the application should default to
+schema.version.api.default=v14
diff --git a/aai-traversal/src/test/resources/bundleconfig-local/etc/appprops/error.properties b/aai-traversal/src/test/resources/bundleconfig-local/etc/appprops/error.properties
deleted file mode 100644
index ba71275..0000000
--- a/aai-traversal/src/test/resources/bundleconfig-local/etc/appprops/error.properties
+++ /dev/null
@@ -1,172 +0,0 @@
-# Adding comment trying to trigger a build
-#------------------------------------------------------------------------------- ----------
-#Key=Disposition:Category:Severity:Error Code:HTTP ResponseCode:RESTError Code:Error Message
-#------------------------------------------------------------------------------- ----------
-# testing code, please don't change unless error utility source code changes
-AAI_TESTING=5:2:WARN:0000:400:0001:Error code for testing
-
-# General success
-AAI_0000=0:0:INFO:0000:200:0000:Success
-
-# health check success
-AAI_0001=0:0:INFO:0001:200:0001:Success X-FromAppId=%1 X-TransactionId=%2
-AAI_0002=0:0:INFO:0002:200:0001:Successful health check
-
-# Success with additional info
-AAI_0003=0:3:INFO:0003:202:0003:Success with additional info performing %1 on %2. Added %3 with key %4
-AAI_0004=0:3:INFO:0004:202:0003:Added prerequisite object to db
-
-#--- aairest: 3000-3299
-# svc errors
-AAI_3000=5:2:INFO:3000:400:3000:Invalid input performing %1 on %2
-AAI_3001=5:6:INFO:3001:404:3001:Resource not found for %1 using id %2
-AAI_3002=5:1:WARN:3002:400:3002:Error writing output performing %1 on %2
-AAI_3003=5:1:WARN:3003:400:3003:Failed to make edge to missing target node of type %3 with keys %4 performing %1 on %2
-AAI_3005=5:6:WARN:3005:404:3001:Node cannot be directly accessed for read, must be accessed via ancestor(s)
-AAI_3006=5:6:WARN:3006:404:3001:Node cannot be directly accessed for write, must be accessed via ancestor(s)
-AAI_3007=5:6:INFO:3007:410:3007:This version (%1) of the API is retired, please migrate to %2
-AAI_3008=5:6:WARN:3008:400:3008:URI is not encoded in UTF-8
-AAI_3009=5:6:WARN:3009:400:3002:Malformed URL
-AAI_3010=5:6:WARN:3010:400:3002:Cannot write via this URL
-AAI_3011=5:6:WARN:3011:400:3000:Unknown XML namespace used in payload
-AAI_3012=5:6:WARN:3012:400:3012:Unrecognized AAI function
-AAI_3013=5:6:WARN:3013:400:3013:Query payload missing required parameters %1
-AAI_3014=5:6:WARN:3014:400:3014:Query payload is invalid %1
-# pol errors
-AAI_3100=5:1:WARN:3100:400:3100:Unsupported operation %1
-AAI_3101=5:1:WARN:3101:403:3101:Attempt by client %1 to execute API %2
-AAI_3102=5:1:WARN:3102:400:3102:Error parsing input performing %1 on %2
-AAI_3300=5:1:WARN:3300:403:3300:Unauthorized
-AAI_3301=5:1:WARN:3301:401:3301:Stale credentials
-AAI_3302=5:1:WARN:3302:401:3301:Not authenticated
-AAI_3303=5:1:WARN:3303:403:3300:Too many objects would be returned by this request, please refine your request and retry
-
-#--- aaigen: 4000-4099
-AAI_4000=5:4:ERROR:4000:500:3002:Internal Error
-AAI_4001=5:4:FATAL:4001:500:3002:Configuration file not found
-AAI_4002=5:4:FATAL:4002:500:3002:Error reading Configuration file
-AAI_4003=5:4:ERROR:4003:500:3002:Error writing to log file
-AAI_4004=5:4:FATAL:4004:500:3002:Error reading/parsing the error properties file
-AAI_4005=5:4:FATAL:4005:500:3002:Missing or invalid configuration parameter
-AAI_4006=5:4:FATAL:4006:500:3002:Unexpected error in service
-AAI_4007=5:4:WARN:4007:500:3102:Input parsing error
-AAI_4008=5:4:ERROR:4008:500:3002:Output parsing error
-AAI_4009=4:0:WARN:4009:400:3000:Invalid X-FromAppId in header
-AAI_4010=4:0:WARN:4010:400:3000:Invalid X-TransactionId in header
-AAI_4011=5:4:ERROR:4011:500:3002:Missing data for REST error response
-AAI_4014=4:0:WARN:4014:400:3000:Invalid Accept header
-AAI_4015=4:0:WARN:4015:400:3000:You must provide at least one indexed property
-AAI_4016=4:0:WARN:4016:400:3000:The depth parameter must be a number or the string "all"
-AAI_4017=5:2:INFO:4017:400:3000:Could not set property
-AAI_4018=5:2:WARN:4018:400:3000:Unable to convert the string to integer
-#--- aaidbmap: 5102-5199
-AAI_5102=5:4:FATAL:5102:500:3002:Graph database is null after open
-AAI_5105=5:4:ERROR:5105:500:3002:Unexpected error reading/updating database
-AAI_5106=5:4:WARN:5106:404:3001:Node not found
-AAI_5107=5:2:WARN:5107:400:3000:Required information missing
-AAI_5108=5:2:WARN:5108:200:0:Unexpected information in request being ignored
-
-#--- aaidbgen: 6101-6199
-AAI_6101=5:4:ERROR:6101:500:3002:null TitanGraph object passed
-AAI_6102=5:4:WARN:6102:400:3000:Passed-in property is not valid for this nodeType
-AAI_6103=5:4:WARN:6103:400:3000:Required Node-property not found in input data
-AAI_6104=5:4:WARN:6104:400:3000:Required Node-property was passed with no data
-AAI_6105=5:4:WARN:6105:400:3000:Node-Key-Property not defined in DbMaps
-AAI_6106=5:4:WARN:6106:400:3000:Passed-in property is not valid for this edgeType
-AAI_6107=5:4:WARN:6107:400:3000:Required Edge-property not found in input data
-AAI_6108=5:4:WARN:6108:400:3000:Required Edge-property was passed with no data
-AAI_6109=5:4:WARN:6109:400:3000:Bad dependent Node value
-AAI_6110=5:4:ERROR:6110:400:3100:Node cannot be deleted
-AAI_6111=5:4:WARN:6111:400:3000:JSON processing error
-AAI_6112=5:4:ERROR:6112:400:3000:More than one node found by getUniqueNode()
-AAI_6114=5:4:INFO:6114:404:3001:Node Not Found
-AAI_6115=5:4:ERROR:6115:400:3000:Unrecognized NodeType
-AAI_6116=5:4:ERROR:6116:400:3000:Unrecognized Property
-AAI_6117=5:4:ERROR:6117:400:3000:Uniqueness constraint violated
-AAI_6118=5:4:WARN:6118:400:3000:Required Field not passed.
-AAI_6120=5:4:WARN:6120:400:3000:Bad Parameter Passed
-AAI_6121=5:4:ERROR:6121:400:3000:Problem with internal AAI reference data
-AAI_6122=5:4:ERROR:6122:400:3000:Data Set not complete in DB for this request
-AAI_6123=5:4:ERROR:6123:500:3000:Bad Data found by DataGrooming Tool - Investigate
-AAI_6124=5:4:ERROR:6124:500:3000:File read/write error
-AAI_6125=5:4:WARN:6125:500:3000:Problem Pulling Data Set
-AAI_6126=5:4:ERROR:6126:400:3000:Edge cannot be deleted
-AAI_6127=5:4:INFO:6127:404:3001:Edge Not Found
-AAI_6128=5:4:INFO:6128:500:3000:Unexpected error
-AAI_6129=5:4:INFO:6129:404:3003:Error making edge to target node
-AAI_6130=5:4:WARN:6130:412:3000:Precondition Required
-AAI_6131=5:4:WARN:6131:412:3000:Precondition Failed
-AAI_6132=5:4:WARN:6132:400:3000:Bad Model Definition
-AAI_6133=5:4:WARN:6133:400:3000:Bad Named Query Definition
-AAI_6134=5:4:ERROR:6134:500:6134:Could not persist transaction to storage back end. Exhausted retry amount
-AAI_6135=5:4:WARN:6135:412:3000:Resource version specified on create
-AAI_6136=5:4:ERROR:6136:400:3000:Object cannot hold multiple items
-AAI_6137=5:4:ERROR:6137:400:3000:Cannot perform writes on multiple vertices
-AAI_6138=5:4:ERROR:6138:400:3000:Cannot delete multiple vertices
-AAI_6139=5:4:ERROR:6139:404:3000:Attempted to add edge to vertex that does not exist
-AAI_6140=5:4:ERROR:6140:400:3000:Edge multiplicity violated
-AAI_6141=5:4:WARN:6141:400:3000:Please Refine Query
-AAI_6142=5:4:INFO:6142:400:3000:Retrying transaction
-AAI_6143=5:4:INFO:6143:400:3000:Ghost vertex found
-AAI_6144=5:4:WARN:6144:400:3000:Cycle found in graph
-AAI_6145=5:4:ERROR:6145:400:3000:Cannot create a nested/containment edge via relationship
-AAI_6146=5:4:ERROR:6146:400:3000:Ambiguous identity map found, use a URI instead
-AAI_6147=5:4:ERROR:6147:400:3000:Payload Limit Reached, reduce payload
-
-#--- aaicsvp: 7101-7199
-AAI_7101=5:4:ERROR:7101:500:3002:Unexpected error in CSV file processing
-AAI_7102=5:4:ERROR:7102:500:3002:Error in cleanup temporary directory
-#AAI_7103=4:2:ERROR:7103:500:3002:Unsupported user
-AAI_7104=5:4:ERROR:7104:500:3002:Failed to create directory
-AAI_7105=5:4:ERROR:7105:500:3002:Temporary directory exists
-AAI_7106=5:4:ERROR:7106:500:3002:Cannot delete
-AAI_7107=5:4:ERROR:7107:500:3002:Input file does not exist
-AAI_7108=5:4:ERROR:7108:500:3002:Output file does not exist
-AAI_7109=5:4:ERROR:7109:500:3002:Error closing file
-AAI_7110=5:4:ERROR:7110:500:3002:Error loading/reading properties file
-AAI_7111=5:4:ERROR:7111:500:3002:Error executing shell script
-AAI_7112=5:4:ERROR:7112:500:3002:Error creating output file
-AAI_7113=5:4:ERROR:7113:500:3002:Trailer record error
-AAI_7114=5:4:ERROR:7114:500:3002:Input file error
-AAI_7115=5:4:ERROR:7115:500:3002:Unexpected error
-AAI_7116=5:4:ERROR:7116:500:3002:Request error
-AAI_7117=5:4:ERROR:7117:500:3002:Error in get http client object
-AAI_7118=5:4:ERROR:7118:500:3002:Script Error
-AAI_7119=5:4:ERROR:7119:500:3002:Unknown host
-
-#--- aaisdnc: 7201-7299
-AAI_7202=5:4:ERROR:7202:500:3002:Error getting connection to odl
-AAI_7203=5:4:ERROR:7203:500:3002:Unexpected error calling DataChangeNotification API
-AAI_7204=5:4:ERROR:7204:500:3002:Error returned by DataChangeNotification API
-AAI_7205=5:4:ERROR:7205:500:3002:Unexpected error running notifySDNCOnUpdate
-#AAI_7206=5:4:ERROR:7206:500:3002:Invalid data returned from ODL
-
-#--- NotificationEvent, using UEB space
-AAI_7350=5:4:ERROR:7305:500:3002:Notification event creation failed
-
-#--- aairestctlr: 7401-7499
-AAI_7401=5:4:ERROR:7401:500:3002:Error connecting to AAI REST API
-AAI_7402=5:4:ERROR:7402:500:3002:Unexpected error
-AAI_7403=5:4:WARN:7403:400:3001:Request error
-AAI_7404=5:4:INFO:7404:404:3001:Node not found
-AAI_7405=5:4:WARN:7405:200:0:UUID not formatted correctly, generating UUID
-AAI_7406=5:4:ERROR:7406:400:7406:Request Timed Out
-
-#--- aaicsiovals: 7501-7599
-#AAI_7501=5:4:WARN:7501:500:3002:Error getting connection to CSI-OVALS
-AAI_7502=5:4:WARN:7502:500:3002:Bad parameter when trying to build request for CSI-OVALS
-AAI_7503=5:4:WARN:7503:500:3002:Error returned by CSI-OVALS
-
-#--- aaiauth: 9101-9199
-AAI_9101=5:0:WARN:9101:403:3300:User is not authorized to perform function
-#AAI_9102=5:0:WARN:9102:401:3301:Refresh credentials from source
-#AAI_9103=5:0:WARN:9103:403:3300:User not found
-#AAI_9104=5:0:WARN:9104:401:3302:Authentication error
-#AAI_9105=5:0:WARN:9105:403:3300:Authorization error
-#AAI_9106=5:0:WARN:9106:403:3300:Invalid AppId
-#AAI_9107=5:0:WARN:9107:403:3300:No Username in Request
-AAI_9107=5:0:WARN:9107:403:3300:SSL is not provided in request, please contact admin
-
-#--- aaiinstar: 9201-9299
-#AAI_9201=5:4:ERROR:9201:500:3002:Unable to send notification
-AAI_9202=5:4:ERROR:9202:500:3002:Unable to start a thread
diff --git a/aai-traversal/src/test/resources/payloads/templates/cloud-region-with-vserver.json b/aai-traversal/src/test/resources/payloads/templates/cloud-region-with-vserver.json
new file mode 100644
index 0000000..08d5b02
--- /dev/null
+++ b/aai-traversal/src/test/resources/payloads/templates/cloud-region-with-vserver.json
@@ -0,0 +1,32 @@
+{
+ "cloud-owner": "${cloud-owner}",
+ "cloud-region-id": "${cloud-region-id}",
+ "tenants": {
+ "tenant": [
+ {
+ "tenant-id": "${tenant-id}",
+ "tenant-name": "${tenant-name}",
+ "vservers": {
+ "vserver": [
+ {
+ "vserver-id": "${vserver-id}",
+ "vserver-name": "${vserver-name}",
+ "vserver-name2": "vserver-name-2",
+ "vserver-selflink": "vserver-selflink-1",
+ "in-maint": false,
+ "is-closed-loop-disabled": false,
+ "relationship-list": {
+ "relationship": [
+ {
+ "related-to": "pserver",
+ "related-link": "${pserver-uri}"
+ }
+ ]
+ }
+ }
+ ]
+ }
+ }
+ ]
+ }
+}
diff --git a/aai-traversal/src/test/resources/payloads/templates/configuration.json b/aai-traversal/src/test/resources/payloads/templates/configuration.json
new file mode 100644
index 0000000..d40b2b8
--- /dev/null
+++ b/aai-traversal/src/test/resources/payloads/templates/configuration.json
@@ -0,0 +1,5 @@
+{
+ "configuration-id": "US-11821-conf-id2-vk250x",
+ "configuration-type": "US-12001-configuration-type2",
+ "configuration-sub-type": "configuration-sub-type2"
+} \ No newline at end of file
diff --git a/aai-traversal/src/test/resources/payloads/templates/customer-with-configurations.json b/aai-traversal/src/test/resources/payloads/templates/customer-with-configurations.json
new file mode 100644
index 0000000..c77eeea
--- /dev/null
+++ b/aai-traversal/src/test/resources/payloads/templates/customer-with-configurations.json
@@ -0,0 +1,46 @@
+{
+ "global-customer-id": "${customer-id}",
+ "subscriber-name": "customer-subscriber-name",
+ "subscriber-type": "CUST",
+ "service-subscriptions": {
+ "service-subscription": [
+ {
+ "service-type": "VVIG",
+ "service-instances": {
+ "service-instance": [
+ {
+ "service-instance-id": "${service-instance-id}",
+ "service-instance-name": "${service-instance-name}",
+ "relationship-list": {
+ "relationship": [
+ {
+ "related-to": "configuration",
+ "relationship-label": "org.onap.relationships.inventory.Uses",
+ "related-link": "/aai/v13/network/configurations/configuration/${configuration-id1}",
+ "relationship-data": [
+ {
+ "relationship-key": "configuration.configuration-id",
+ "relationship-value": "${configuration-id1}"
+ }
+ ]
+ },
+ {
+ "related-to": "configuration",
+ "relationship-label": "org.onap.relationships.inventory.Uses",
+ "related-link": "/aai/v13/network/configurations/configuration/${configuration-id2}",
+ "relationship-data": [
+ {
+ "relationship-key": "configuration.configuration-id",
+ "relationship-value": "${configuration-id2}"
+ }
+ ]
+ }
+ ]
+ }
+ }
+ ]
+ }
+ }
+ ]
+ }
+} \ No newline at end of file
diff --git a/aai-traversal/src/test/resources/payloads/templates/customer-with-serviceinstance.json b/aai-traversal/src/test/resources/payloads/templates/customer-with-serviceinstance.json
new file mode 100644
index 0000000..b60a8b5
--- /dev/null
+++ b/aai-traversal/src/test/resources/payloads/templates/customer-with-serviceinstance.json
@@ -0,0 +1,20 @@
+{
+ "global-customer-id": "${customer-id}",
+ "subscriber-name": "customer-subscriber-name",
+ "subscriber-type": "CUST",
+ "service-subscriptions": {
+ "service-subscription": [
+ {
+ "service-type": "VVIG",
+ "service-instances": {
+ "service-instance": [
+ {
+ "service-instance-id": "${service-instance-id}",
+ "service-instance-name": "${service-instance-name}"
+ }
+ ]
+ }
+ }
+ ]
+ }
+} \ No newline at end of file
diff --git a/aai-traversal/src/test/resources/payloads/templates/customer.json b/aai-traversal/src/test/resources/payloads/templates/customer.json
new file mode 100644
index 0000000..a4b967c
--- /dev/null
+++ b/aai-traversal/src/test/resources/payloads/templates/customer.json
@@ -0,0 +1,5 @@
+{
+ "global-customer-id": "global-cust-id1",
+ "subscriber-name": "customer-subscriber-name",
+ "subscriber-type": "CUST"
+} \ No newline at end of file
diff --git a/aai-traversal/src/test/resources/payloads/templates/dsl-query.json b/aai-traversal/src/test/resources/payloads/templates/dsl-query.json
new file mode 100644
index 0000000..60057b4
--- /dev/null
+++ b/aai-traversal/src/test/resources/payloads/templates/dsl-query.json
@@ -0,0 +1,4 @@
+{
+ "dsl": "${dsl-query}"
+}
+
diff --git a/aai-traversal/src/test/resources/payloads/templates/generic-vnf-to-configuration.json b/aai-traversal/src/test/resources/payloads/templates/generic-vnf-to-configuration.json
new file mode 100644
index 0000000..c617412
--- /dev/null
+++ b/aai-traversal/src/test/resources/payloads/templates/generic-vnf-to-configuration.json
@@ -0,0 +1,72 @@
+{
+ "vnf-id": "${vnf-id}",
+ "vnf-name": "vnf-name1",
+ "vnf-type": "vnf-type1",
+ "prov-status": "PROV",
+ "license-key": "1123456",
+ "equipment-role": "Test123-Eq-Role",
+ "in-maint": false,
+ "is-closed-loop-disabled": false,
+ "relationship-list": {
+ "relationship": [
+ {
+ "related-to": "configuration",
+ "relationship-label": "org.onap.relationships.inventory.Uses",
+ "related-link": "/aai/v13/network/configurations/configuration/${configuration-id}",
+ "relationship-data": [
+ {
+ "relationship-key": "configuration.configuration-id",
+ "relationship-value": "${configuration-id}"
+ }
+ ]
+ }
+ ]
+ },
+ "l-interfaces": {
+ "l-interface": [
+ {
+ "interface-name": "${interface-name}",
+ "interface-role": "ijWc",
+ "network-name": "network-name1",
+ "interface-description": "3W6lisag9rH",
+ "is-port-mirrored": false,
+ "in-maint": true,
+ "is-ip-unnumbered": false,
+ "relationship-list": {
+ "relationship": [
+ {
+ "related-to": "configuration",
+ "relationship-label": "org.onap.relationships.inventory.AppliesTo",
+ "related-link": "/aai/v13/network/configurations/configuration/${configuration-id}",
+ "relationship-data": [
+ {
+ "relationship-key": "configuration.configuration-id",
+ "relationship-value": "${configuration-id}"
+ }
+ ]
+ }
+ ]
+ },
+ "vlans": {
+ "vlan": [
+ {
+ "vlan-interface": "${vlan-interface}",
+ "in-maint": false,
+ "is-ip-unnumbered": false,
+ "l3-interface-ipv4-address-list": [
+ {
+ "l3-interface-ipv4-address": "135.190.177.164"
+ }
+ ],
+ "l3-interface-ipv6-address-list": [
+ {
+ "l3-interface-ipv6-address": "135.190.177.165"
+ }
+ ]
+ }
+ ]
+ }
+ }
+ ]
+ }
+} \ No newline at end of file
diff --git a/aai-traversal/src/test/resources/payloads/templates/generic-vnf.json b/aai-traversal/src/test/resources/payloads/templates/generic-vnf.json
new file mode 100644
index 0000000..7b59251
--- /dev/null
+++ b/aai-traversal/src/test/resources/payloads/templates/generic-vnf.json
@@ -0,0 +1,7 @@
+{
+ "vnf-id": "${vnf-id}",
+ "vnf-type": "someval",
+ "vnf-name": "someval",
+ "model-invariant-id": "${model-invariant-id}",
+ "model-version-id": "${model-version-id}"
+}
diff --git a/aai-traversal/src/test/resources/payloads/templates/model-ver.json b/aai-traversal/src/test/resources/payloads/templates/model-ver.json
new file mode 100644
index 0000000..e20e0a3
--- /dev/null
+++ b/aai-traversal/src/test/resources/payloads/templates/model-ver.json
@@ -0,0 +1,5 @@
+{
+ "model-version-id": "${model-version-id}",
+ "model-name": "${model-name}",
+ "model-version": "${model-version}"
+} \ No newline at end of file
diff --git a/aai-traversal/src/test/resources/payloads/templates/model.json b/aai-traversal/src/test/resources/payloads/templates/model.json
new file mode 100644
index 0000000..7eaa4c6
--- /dev/null
+++ b/aai-traversal/src/test/resources/payloads/templates/model.json
@@ -0,0 +1,4 @@
+{
+ "model-invariant-id": "${model-invariant-id}",
+ "model-type": "some-type"
+} \ No newline at end of file
diff --git a/pom.xml b/pom.xml
index 3155651..e686655 100644
--- a/pom.xml
+++ b/pom.xml
@@ -12,10 +12,16 @@
<module>aai-traversal</module>
</modules>
<properties>
+ <!--
+ Nexus Proxy Properties and Snapshot Locations
+ Ideally this can be overwritten at runtime per internal environment specific values at runtime
+ -->
<nexusproxy>https://nexus.onap.org</nexusproxy>
<site.path>/content/sites/site/org/onap/aai/traversal/${project.artifactId}/${project.version}</site.path>
<release.path>/content/repositories/releases/</release.path>
<snapshot.path>/content/repositories/snapshots/</snapshot.path>
+ <!-- GMaven plugin uses this property to figure out the name of the docker tag -->
+ <aai.project.version>${project.version}</aai.project.version>
</properties>
<build>
<pluginManagement>