diff options
author | Kajur, Harish (vk250x) <vk250x@att.com> | 2018-08-12 23:40:04 -0400 |
---|---|---|
committer | Kajur, Harish (vk250x) <vk250x@att.com> | 2018-08-13 02:49:05 -0400 |
commit | 538aad3add38a0ce4ef6ac25333d50bba7b05ac5 (patch) | |
tree | b0155c033b80bb6d6d316bd92cd5f280e4542e56 /aai-resources/src | |
parent | 96b7ed4bff9a2259f1f28f288caa6cc11c97db59 (diff) |
Update resources ms to use ingest library
Change the code to replace ModelIngestor
with the NodeIngestor and replace the EdgeRules
with the EdgeIngestor and EdgeSerializer
Edge Ingestor for getting the rules from json files
Edge Serializer for creating the edges between vertexes
Node Ingestor is responsible for the multiple oxm files
Issue-ID: AAI-1462
Change-Id: I555916911dc4076ac017173d63478b3b76b36e42
Signed-off-by: Kajur, Harish (vk250x) <vk250x@att.com>
Diffstat (limited to 'aai-resources/src')
259 files changed, 5218 insertions, 18626 deletions
diff --git a/aai-resources/src/main/assembly/descriptor.xml b/aai-resources/src/main/assembly/descriptor.xml index 6dc677b..08e253f 100644 --- a/aai-resources/src/main/assembly/descriptor.xml +++ b/aai-resources/src/main/assembly/descriptor.xml @@ -1,32 +1,32 @@ -<assembly xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.2"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.2 http://maven.apache.org/xsd/assembly-1.1.2.xsd">
- <id>build</id>
- <includeBaseDirectory>false</includeBaseDirectory>
- <formats>
- <format>dir</format>
- </formats>
- <fileSets>
- <fileSet>
- <directory>${project.basedir}/src/main/resources</directory>
- <outputDirectory>./resources</outputDirectory>
- <includes>
- <include>**/*</include>
- </includes>
- </fileSet>
- <fileSet>
- <directory>${project.basedir}/src/main/scripts</directory>
- <outputDirectory>./bin</outputDirectory>
- <includes>
- <include>**/*</include>
- </includes>
- </fileSet>
- <fileSet>
- <directory>${project.build.directory}</directory>
- <outputDirectory>./lib</outputDirectory>
- <includes>
- <include>${project.artifactId}-${project.version}.jar</include>
- </includes>
- </fileSet>
- </fileSets>
-</assembly>
+<assembly xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.2" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.2 http://maven.apache.org/xsd/assembly-1.1.2.xsd"> + <id>build</id> + <includeBaseDirectory>false</includeBaseDirectory> + <formats> + <format>dir</format> + </formats> + <fileSets> + <fileSet> + <directory>${project.basedir}/src/main/resources</directory> + <outputDirectory>./resources</outputDirectory> + <includes> + <include>**/*</include> + </includes> + </fileSet> + <fileSet> + <directory>${project.basedir}/src/main/scripts</directory> + <outputDirectory>./bin</outputDirectory> + <includes> + <include>**/*</include> + </includes> + </fileSet> + <fileSet> + <directory>${project.build.directory}</directory> + <outputDirectory>./lib</outputDirectory> + <includes> + <include>${project.artifactId}-${project.version}.jar</include> + </includes> + </fileSet> + </fileSets> +</assembly> diff --git a/aai-resources/src/main/docker/Dockerfile b/aai-resources/src/main/docker/Dockerfile index be8af9c..ec38c02 100644 --- a/aai-resources/src/main/docker/Dockerfile +++ b/aai-resources/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 @@ -16,6 +16,8 @@ ENTRYPOINT ["/bin/bash", "/opt/app/aai-resources/docker-entrypoint.sh"] RUN mkdir -p /opt/aaihome/aaiadmin /opt/aai/logroot/AAI-RES VOLUME /opt/aai/logroot/AAI-RES +VOLUME /tmp +VOLUME /opt/tools COPY /maven/aai-resources/ . diff --git a/aai-resources/src/main/docker/docker-entrypoint.sh b/aai-resources/src/main/docker/docker-entrypoint.sh index 6f9ed65..6323320 100644 --- a/aai-resources/src/main/docker/docker-entrypoint.sh +++ b/aai-resources/src/main/docker/docker-entrypoint.sh @@ -72,34 +72,37 @@ if [ -f ${APP_HOME}/aai.sh ]; then exit 0; fi; +fi; - # If in the environment file skip create db schema there is a value set - # Then it will skip the create db schema at startup - # This is a workaround that will be there temporarily - # Ideally createDBSchema should be run from chef - # Or run without having to startup the application - if [ -z ${SKIP_CREATE_DB_SCHEMA_AT_STARTUP} ]; then - gosu aaiadmin /opt/app/aai-resources/scripts/createDBSchema.sh || exit 1 - fi; +mkdir -p /opt/app/aai-resources/logs/gc +chown -R aaiadmin:aaiadmin /opt/app/aai-resources/logs/gc + +if [ -f ${APP_HOME}/resources/aai-resources-swm-vars.sh ]; then + source ${APP_HOME}/resources/aai-resources-swm-vars.sh; +fi; + +if [ ! -z "${HEAP_SIZE}" ]; then + MIN_HEAP_SIZE=${HEAP_SIZE}; + MAX_HEAP_SIZE=${HEAP_SIZE}; 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-resources/logs/gc/aai_gc.log"; +JVM_OPTS="${JVM_OPTS} -XX:HeapDumpPath=/opt/app/aai-resources/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"; @@ -115,19 +118,19 @@ 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-resources/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-resources/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}"; JAVA_OPTS="${JAVA_OPTS} -DBUNDLECONFIG_DIR=./resources"; 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} -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-resources/src/main/java/org/onap/aai/IncreaseNodesTool.java b/aai-resources/src/main/java/org/onap/aai/IncreaseNodesTool.java new file mode 100644 index 0000000..5f94141 --- /dev/null +++ b/aai-resources/src/main/java/org/onap/aai/IncreaseNodesTool.java @@ -0,0 +1,153 @@ +/** + * ============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 java.io.UnsupportedEncodingException; +import java.util.ArrayList; +import java.util.List; +import java.util.UUID; + +import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource; +import org.apache.tinkerpop.gremlin.structure.Vertex; +import org.janusgraph.core.JanusGraph; +import org.janusgraph.core.JanusGraphTransaction; +import org.onap.aai.dbmap.AAIGraph; +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.exceptions.AAIUnknownObjectException; +import org.onap.aai.setup.SchemaVersions; +import org.onap.aai.util.AAISystemExitUtil; +import org.onap.aai.util.PositiveNumValidator; + +import com.beust.jcommander.JCommander; +import com.beust.jcommander.Parameter; +import org.springframework.context.ApplicationContext; +import org.springframework.context.annotation.AnnotationConfigApplicationContext; + +public class IncreaseNodesTool { + + public static long nodeCount = 0; + + private LoaderFactory loaderFactory; + private SchemaVersions schemaVersions; + + public IncreaseNodesTool(LoaderFactory loaderFactory, SchemaVersions schemaVersions){ + this.loaderFactory = loaderFactory; + this.schemaVersions = schemaVersions; + } + + public static void main(String[] args) throws AAIUnknownObjectException, UnsupportedEncodingException { + + AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext( + "org.onap.aai.config", + "org.onap.aai.setup" + ); + + LoaderFactory loaderFactory = context.getBean(LoaderFactory.class); + SchemaVersions schemaVersions = context.getBean(SchemaVersions.class); + + IncreaseNodesTool increaseNodesTool = new IncreaseNodesTool(loaderFactory, schemaVersions); + JanusGraph janusGraph = AAIGraph.getInstance().getGraph(); + increaseNodesTool.run(janusGraph,args); + AAISystemExitUtil.systemExitCloseAAIGraph(0); + + } + + + public void run(JanusGraph janusGraph, String[] args) throws AAIUnknownObjectException, UnsupportedEncodingException { + CommandLineArgs cArgs = new CommandLineArgs(); + JCommander jCommander = new JCommander(cArgs,args); + jCommander.setProgramName(IncreaseNodesTool.class.getSimpleName()); + + Loader loader = loaderFactory.createLoaderForVersion(ModelType.MOXY, schemaVersions.getDefaultVersion()); + Introspector obj = loader.introspectorFromName(cArgs.nodeType); + + List<String> propList = new ArrayList<String>(); + propList.addAll(obj.getRequiredProperties()); + + + nodeCount = Long.parseLong(cArgs.numberOfNodes); + addVertex(janusGraph, cArgs.nodeType,propList,cArgs); + } + + /*** + * adds a vertex based on user inputs of node type number of nodes and the node uri + * /cloud-infrastructure/pservers/pserver/ + * /network/pnfs/pnf/ + * /cloud-infrastructure/pservers/pserver/random-056fd6c4-7313-4fa0-b854-0d9983bdb0ab/DevB/p-interfaces/p-interface/ + * @param nodeType + * @param propList + * @param cArgs + */ + public void addVertex(JanusGraph janusGraph, String nodeType, List<String> propList,CommandLineArgs cArgs){ + + long startTime = System.currentTimeMillis(); + + try (JanusGraphTransaction transaction = janusGraph.newTransaction()) { + boolean success = true; + + try { + GraphTraversalSource g = transaction.traversal(); + for (long i = 1; i <= nodeCount; i++) { + String randomId = UUID.randomUUID().toString(); + Vertex v = g.addV().next(); + v.property("aai-node-type", nodeType); + v.property("source-of-truth", "IncreaseNodesTool"); + v.property("aai-uri", cArgs.uri+"random-"+randomId); + + for(String propName : propList){ + if(propName.equals("in-maint")){ + v.property(propName,"false"); + } + v.property(propName, "random-" + randomId); + System.out.println("node " + i + " added " + propList.get(0)+": " + "random-"+randomId); + } + } + } catch (Exception ex) { + success = false; + } finally { + if (success) { + transaction.commit(); + System.out.println("Transaction Committed"); + long endTime = System.currentTimeMillis(); + System.out.println("Total Time: "+ ((endTime - startTime)/ 1000.0) + "seconds"); + } else { + transaction.rollback(); + } + } + } + } + +} + +class CommandLineArgs { + + @Parameter(names = "-numberOfNodes", description = "how many nodes you would like to enter", required = true , validateWith = PositiveNumValidator.class) + public String numberOfNodes; + + @Parameter(names = "-nodeType", description = "They aai-node-type of the node being entered", required = true) + public String nodeType; + + @Parameter(names = "-uri", description = "uri to be passed for the node") + public String uri; +} + diff --git a/aai-resources/src/main/java/org/onap/aai/Profiles.java b/aai-resources/src/main/java/org/onap/aai/Profiles.java index f17d6b9..f0419d8 100644 --- a/aai-resources/src/main/java/org/onap/aai/Profiles.java +++ b/aai-resources/src/main/java/org/onap/aai/Profiles.java @@ -22,6 +22,7 @@ package org.onap.aai; public final class Profiles { public static final String DMAAP = "dmaap"; + public static final String DME2 = "dme2"; public static final String ONE_WAY_SSL = "one-way-ssl"; public static final String TWO_WAY_SSL = "two-way-ssl"; diff --git a/aai-resources/src/main/java/org/onap/aai/ResourcesApp.java b/aai-resources/src/main/java/org/onap/aai/ResourcesApp.java index 057ac16..988b057 100644 --- a/aai-resources/src/main/java/org/onap/aai/ResourcesApp.java +++ b/aai-resources/src/main/java/org/onap/aai/ResourcesApp.java @@ -19,15 +19,21 @@ */ package org.onap.aai; -import com.att.eelf.configuration.EELFLogger; -import com.att.eelf.configuration.EELFManager; +import java.util.Map; +import java.util.UUID; + +import javax.annotation.PostConstruct; +import javax.annotation.PreDestroy; + 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.migration.MigrationControllerInternal; +import org.onap.aai.logging.LoggingContext.StatusCode; import org.onap.aai.util.AAIConfig; +import org.slf4j.MDC; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.EnableAutoConfiguration; @@ -37,10 +43,11 @@ 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.onap.aai.nodes.NodeIngestor; -import javax.annotation.PostConstruct; -import javax.annotation.PreDestroy; -import java.util.UUID; + +import com.att.eelf.configuration.EELFLogger; +import com.att.eelf.configuration.EELFManager; @SpringBootApplication // Component Scan provides a way to look for spring beans @@ -50,6 +57,7 @@ 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" @@ -64,10 +72,21 @@ public class ResourcesApp { private static final EELFLogger logger = EELFManager.getInstance().getLogger(ResourcesApp.class.getName()); private static final String APP_NAME = "aai-resources"; + 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,22 +99,22 @@ public class ResourcesApp { 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..."); // Setting this property to allow for encoded slash (/) in the path parameter // 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(); + LoggingContext.restoreIfPossible(); } @PreDestroy @@ -104,29 +123,46 @@ public class ResourcesApp { AAIGraph.getInstance().graphShutdown(); } - public static void main(String[] args) { + public static void main(String[] args) throws AAIException { setDefaultProps(); + + LoggingContext.save(); + LoggingContext.component("init"); + LoggingContext.partnerName("NA"); + LoggingContext.targetEntity(APP_NAME); + LoggingContext.requestId(UUID.randomUUID().toString()); + LoggingContext.serviceName(APP_NAME); + LoggingContext.targetServiceName("contextInitialized"); + LoggingContext.statusCode(StatusCode.COMPLETE); + + SpringApplication app = new SpringApplication(ResourcesApp.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"), env.getProperty("server.port") ); - if ("true".equals(AAIConfig.get("aai.run.migrations", "false"))) { - MigrationControllerInternal migrations = new MigrationControllerInternal(); - migrations.run(new String[]{"--commit"}); - } + // The main reason this was moved from the constructor is due + // to the SchemaGenerator needs the bean and during the constructor + // the Spring Context is not yet initialized + + AAIConfig.init(); + AAIGraph.getInstance(); logger.info("Resources MicroService Started"); logger.error("Resources MicroService Started"); logger.debug("Resources MicroService Started"); + System.out.println("Resources Microservice Started"); + + LoggingContext.restoreIfPossible(); } public static void setDefaultProps(){ @@ -150,6 +186,5 @@ public class ResourcesApp { System.setProperty("BUNDLECONFIG_DIR", "aai-resources/src/main/resources"); } } - } } diff --git a/aai-resources/src/main/java/org/onap/aai/config/ErrorHandler.java b/aai-resources/src/main/java/org/onap/aai/config/ErrorHandler.java new file mode 100644 index 0000000..22e12a6 --- /dev/null +++ b/aai-resources/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-resources/src/main/java/org/onap/aai/dbgen/DataSnapshot.java b/aai-resources/src/main/java/org/onap/aai/dbgen/DataSnapshot.java deleted file mode 100644 index 982a1bb..0000000 --- a/aai-resources/src/main/java/org/onap/aai/dbgen/DataSnapshot.java +++ /dev/null @@ -1,270 +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.dbgen; - -import java.io.ByteArrayOutputStream; -import java.io.File; -import java.io.FileInputStream; -import java.io.IOException; -import java.io.InputStream; -import java.util.Properties; - -import org.apache.tinkerpop.gremlin.structure.io.IoCore; -import org.apache.tinkerpop.gremlin.structure.io.graphson.LegacyGraphSONReader; -import org.onap.aai.dbmap.AAIGraph; -import org.onap.aai.exceptions.AAIException; -import org.onap.aai.logging.ErrorLogHelper; -import org.onap.aai.util.AAIConfig; -import org.onap.aai.util.AAIConstants; -import org.onap.aai.util.AAISystemExitUtil; -import org.onap.aai.util.FormatDate; - -import com.att.eelf.configuration.Configuration; -import com.att.eelf.configuration.EELFLogger; -import com.att.eelf.configuration.EELFManager; -import org.janusgraph.core.JanusGraph; -import org.janusgraph.core.util.JanusGraphCleanup; - -public class DataSnapshot { - - private static final String OLD_SNAPSHOT_FILE_ = "oldSnapshotFile "; - private static final String _COULD_NOT_BE_FOUND = " could not be found."; - private static final String _COULD_NOT_BE_READ = " could not be read."; - private static final String _HAD_NO_DATA = " had no data."; - - /** - * The main method. - * - * @param args - * the arguments - */ - public static void main(String[] args) { - // Set the logging file properties to be used by EELFManager - System.setProperty("aai.service.name", DataSnapshot.class.getSimpleName()); - Properties props = System.getProperties(); - props.setProperty(Configuration.PROPERTY_LOGGING_FILE_NAME, AAIConstants.AAI_DATA_SNAPSHOT_LOGBACK_PROPS); - props.setProperty(Configuration.PROPERTY_LOGGING_FILE_PATH, AAIConstants.AAI_HOME_ETC_APP_PROPERTIES); - - Boolean dbClearFlag = false; - JanusGraph graph = null; - String command = "JUST_TAKE_SNAPSHOT"; // This is the default - String oldSnapshotFileName = ""; - if (args.length == 1) { - command = args[0]; - } - if (args.length == 2) { - // If they pass in a RELOAD_ENTIRE_DB argument, then we will be - // reloading the database - // from the filename passed in -which will be expected to be found - // in our snapshot directory. - command = args[0]; - oldSnapshotFileName = args[1]; - } - ByteArrayOutputStream baos = new ByteArrayOutputStream(); - try { - AAIConfig.init(); - ErrorLogHelper.loadProperties(); - System.out.println("Command = " + command + ", oldSnapshotFileName = " + oldSnapshotFileName); - String targetDir = AAIConstants.AAI_HOME + AAIConstants.AAI_FILESEP + "logs" + AAIConstants.AAI_FILESEP + "data" + AAIConstants.AAI_FILESEP + "dataSnapshots"; - - // Make sure the dataSnapshots directory is there - new File(targetDir).mkdirs(); - - System.out.println(" ---- NOTE --- about to open graph (takes a little while)\n"); - - graph = AAIGraph.getInstance().getGraph(); - - if (graph == null) { - String emsg = "Not able to get a graph object in DataSnapshot.java\n"; - System.out.println(emsg); - AAISystemExitUtil.systemExitCloseAAIGraph(1); - } - - if ("JUST_TAKE_SNAPSHOT".equals(command)) { - // ------------------------------------------ - // They just want to take a snapshot. - // ------------------------------------------ - FormatDate fd = new FormatDate("yyyyMMddHHmm", "GMT"); - String dteStr = fd.getDateTime(); - String newSnapshotOutFname = targetDir + AAIConstants.AAI_FILESEP + "dataSnapshot.graphSON." + dteStr; - - graph.io(IoCore.graphson()).writeGraph(newSnapshotOutFname); - - System.out.println("Snapshot written to " + newSnapshotOutFname); - /**** - * Don't really want to do this every hour ************** int - * vCount = 0; Iterator vIt = - * graph.query().vertices().iterator(); while( vIt.hasNext() ){ - * vCount++; vIt.next(); } System.out.println( - * "A little after taking the snapshot, we see: " + vCount + - * " vertices in the db."); - ************/ - } else if ("CLEAR_ENTIRE_DATABASE".equals(command)) { - // ------------------------------------------------------------------ - // They are calling this to clear the db before re-loading it - // later - // ------------------------------------------------------------------ - - // First - make sure the backup file they will be using can be - // found and has data - if (oldSnapshotFileName.isEmpty()) { - String emsg = "No oldSnapshotFileName passed to DataSnapshot."; - System.out.println(emsg); - AAISystemExitUtil.systemExitCloseAAIGraph(1); - } - String oldSnapshotFullFname = targetDir + AAIConstants.AAI_FILESEP + oldSnapshotFileName; - File f = new File(oldSnapshotFullFname); - if (!f.exists()) { - String emsg = OLD_SNAPSHOT_FILE_ + oldSnapshotFullFname + _COULD_NOT_BE_FOUND; - System.out.println(emsg); - AAISystemExitUtil.systemExitCloseAAIGraph(1); - } else if (!f.canRead()) { - String emsg = OLD_SNAPSHOT_FILE_ + oldSnapshotFullFname + _COULD_NOT_BE_READ; - System.out.println(emsg); - AAISystemExitUtil.systemExitCloseAAIGraph(1); - } else if (f.length() == 0) { - String emsg = OLD_SNAPSHOT_FILE_ + oldSnapshotFullFname + _HAD_NO_DATA; - System.out.println(emsg); - AAISystemExitUtil.systemExitCloseAAIGraph(1); - } - - System.out.println("\n>>> WARNING <<<< "); - System.out.println(">>> All data and schema in this database will be removed at this point. <<<"); - System.out.println(">>> Processing will begin in 5 seconds. <<<"); - System.out.println(">>> WARNING <<<< "); - - try { - // Give them a chance to back out of this - Thread.sleep(5000); - } catch (java.lang.InterruptedException ie) { - System.out.println(" DB Clearing has been aborted. "); - Thread.currentThread().interrupt(); - AAISystemExitUtil.systemExitCloseAAIGraph(1); - } - - System.out.println(" Begin clearing out old data. "); - graph.close(); - JanusGraphCleanup.clear(graph); - System.out.println(" Done clearing data. "); - System.out.println(">>> IMPORTANT - NOTE >>> you need to run the SchemaGenerator (use GenTester) before "); - System.out.println(" reloading data or the data will be put in without indexes. "); - dbClearFlag = true; - - } else if ("RELOAD_LEGACY_DATA".equals(command)) { - // ------------------------------------------------------------------- - // They want to restore the database from an old snapshot file - // ------------------------------------------------------------------- - if (oldSnapshotFileName.isEmpty()) { - String emsg = "No oldSnapshotFileName passed to DataSnapshot when RELOAD_LEGACY_DATA used."; - System.out.println(emsg); - AAISystemExitUtil.systemExitCloseAAIGraph(1); - } - String oldSnapshotFullFname = targetDir + AAIConstants.AAI_FILESEP + oldSnapshotFileName; - File f = new File(oldSnapshotFullFname); - if (!f.exists()) { - String emsg = OLD_SNAPSHOT_FILE_ + oldSnapshotFullFname + _COULD_NOT_BE_FOUND; - System.out.println(emsg); - AAISystemExitUtil.systemExitCloseAAIGraph(1); - } else if (!f.canRead()) { - String emsg = OLD_SNAPSHOT_FILE_ + oldSnapshotFullFname + _COULD_NOT_BE_READ; - System.out.println(emsg); - AAISystemExitUtil.systemExitCloseAAIGraph(1); - } else if (f.length() == 0) { - String emsg = OLD_SNAPSHOT_FILE_ + oldSnapshotFullFname + _HAD_NO_DATA; - System.out.println(emsg); - AAISystemExitUtil.systemExitCloseAAIGraph(1); - } - - System.out.println("We will load data IN from the file = " + oldSnapshotFullFname); - System.out.println(" Begin reloading JanusGraph 0.5 data. "); - - LegacyGraphSONReader lgr = LegacyGraphSONReader.build().create(); - InputStream is = new FileInputStream(oldSnapshotFullFname); - lgr.readGraph(is, graph); - - System.out.println("Completed the inputGraph command, now try to commit()... "); - graph.tx().commit(); - System.out.println("Completed reloading JanusGraph 0.5 data."); - - long vCount = graph.traversal().V().count().next(); - System.out.println("A little after repopulating from an old snapshot, we see: " + vCount + " vertices in the db."); - } else if (command.equals("RELOAD_DATA")) { - // ------------------------------------------------------------------- - // They want to restore the database from an old snapshot file - // ------------------------------------------------------------------- - if (oldSnapshotFileName.equals("")) { - String emsg = "No oldSnapshotFileName passed to DataSnapshot when RELOAD_DATA used."; - System.out.println(emsg); - AAISystemExitUtil.systemExitCloseAAIGraph(1); - } - String oldSnapshotFullFname = targetDir + AAIConstants.AAI_FILESEP + oldSnapshotFileName; - File f = new File(oldSnapshotFullFname); - if (!f.exists()) { - String emsg = OLD_SNAPSHOT_FILE_ + oldSnapshotFullFname + _COULD_NOT_BE_FOUND; - System.out.println(emsg); - AAISystemExitUtil.systemExitCloseAAIGraph(1); - } else if (!f.canRead()) { - String emsg = OLD_SNAPSHOT_FILE_ + oldSnapshotFullFname + _COULD_NOT_BE_READ; - System.out.println(emsg); - AAISystemExitUtil.systemExitCloseAAIGraph(1); - } else if (f.length() == 0) { - String emsg = OLD_SNAPSHOT_FILE_ + oldSnapshotFullFname + _HAD_NO_DATA; - System.out.println(emsg); - AAISystemExitUtil.systemExitCloseAAIGraph(1); - } - - System.out.println("We will load data IN from the file = " + oldSnapshotFullFname); - System.out.println(" Begin reloading data. "); - graph.io(IoCore.graphson()).readGraph(oldSnapshotFullFname); - System.out.println("Completed the inputGraph command, now try to commit()... "); - graph.tx().commit(); - System.out.println("Completed reloading data."); - - long vCount = graph.traversal().V().count().next(); - - System.out.println("A little after repopulating from an old snapshot, we see: " + vCount + " vertices in the db."); - } else { - String emsg = "Bad command passed to DataSnapshot: [" + command + "]"; - System.out.println(emsg); - AAISystemExitUtil.systemExitCloseAAIGraph(1); - } - - } catch (AAIException e) { - ErrorLogHelper.logError("AAI_6128", e.getMessage()); - } catch (Exception ex) { - ErrorLogHelper.logError("AAI_6128", ex.getMessage()); - } finally { - if (!dbClearFlag && graph != null && graph.isOpen()) { - // Any changes that worked correctly should have already done - // thier commits. - graph.tx().rollback(); - graph.close(); - } - try { - baos.close(); - } catch (IOException iox) { - } - } - - AAISystemExitUtil.systemExitCloseAAIGraph(0); - - }// End of main() - -} diff --git a/aai-resources/src/main/java/org/onap/aai/dbgen/DupeTool.java b/aai-resources/src/main/java/org/onap/aai/dbgen/DupeTool.java deleted file mode 100644 index 1e323b0..0000000 --- a/aai-resources/src/main/java/org/onap/aai/dbgen/DupeTool.java +++ /dev/null @@ -1,1877 +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.dbgen; -import java.io.FileInputStream; -import java.io.InputStream; - -import java.util.ArrayList; -import java.util.Collection; -import java.util.HashMap; -import java.util.Iterator; -import java.util.Map; -import java.util.Map.Entry; - -import java.util.Properties; -import java.util.UUID; -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.Direction; -import org.apache.tinkerpop.gremlin.structure.Edge; -import org.apache.tinkerpop.gremlin.structure.Graph; -import org.apache.tinkerpop.gremlin.structure.Vertex; -import org.apache.tinkerpop.gremlin.structure.VertexProperty; -import org.onap.aai.db.props.AAIProperties; -import org.onap.aai.dbmap.AAIGraphConfig; -import org.onap.aai.dbmap.AAIGraph; -import org.onap.aai.exceptions.AAIException; -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.logging.ErrorLogHelper; -import org.onap.aai.logging.LogFormatTools; -import org.onap.aai.logging.LoggingContext; -import org.onap.aai.logging.LoggingContext.StatusCode; -import org.onap.aai.util.AAIConfig; -import org.onap.aai.util.AAIConstants; -import org.slf4j.MDC; - -import com.att.eelf.configuration.Configuration; -import com.att.eelf.configuration.EELFLogger; -import com.att.eelf.configuration.EELFManager; -import org.janusgraph.core.JanusGraphFactory; -import org.janusgraph.core.JanusGraph; - - - -public class DupeTool { - - private static final String FROMAPPID = "AAI-DB"; - private static final String TRANSID = UUID.randomUUID().toString(); - private static final String COULD_NOT_FIND_EDGE_ID_ = " >>> COULD NOT FIND VERTEX on the other side of this edge edgeId = "; - private static final String AAI_NODE_TYPE = "aai-node-type"; - private static final String KEEP_VID = "KeepVid"; - private static final String INMEMORY = "inmemory"; - - private static String graphType = "realdb"; - - public static boolean SHOULD_EXIT_VM = true; - - public static int EXIT_VM_STATUS_CODE = -1; - - public static void exit(int statusCode){ - if(SHOULD_EXIT_VM){ - System.exit(1); - } - EXIT_VM_STATUS_CODE = statusCode; - } - - - /** - * The main method. - * - * @param args the arguments - */ - public static void main(String[] args) { - System.setProperty("aai.service.name", DupeTool.class.getSimpleName()); - // Set the logging file properties to be used by EELFManager - Properties props = System.getProperties(); - props.setProperty(Configuration.PROPERTY_LOGGING_FILE_NAME, "dupeTool-logback.xml"); - props.setProperty(Configuration.PROPERTY_LOGGING_FILE_PATH, AAIConstants.AAI_HOME_ETC_APP_PROPERTIES); - EELFLogger logger = EELFManager.getInstance().getLogger(DupeTool.class.getSimpleName()); - MDC.put("logFilenameAppender", DupeTool.class.getSimpleName()); - - LoggingContext.init(); - LoggingContext.partnerName(FROMAPPID); - LoggingContext.serviceName(AAIConstants.AAI_RESOURCES_MS); - LoggingContext.component("dupeTool"); - LoggingContext.targetEntity(AAIConstants.AAI_RESOURCES_MS); - LoggingContext.targetServiceName("main"); - LoggingContext.requestId(TRANSID); - LoggingContext.statusCode(StatusCode.COMPLETE); - LoggingContext.responseCode(LoggingContext.SUCCESS); - - String defVersion = "v9"; - try { - defVersion = AAIConfig.get(AAIConstants.AAI_DEFAULT_API_VERSION_PROP); - } - catch ( AAIException ae ){ - String emsg = "Error trying to get default API Version property \n"; - System.out.println(emsg); - LoggingContext.statusCode(StatusCode.ERROR); - LoggingContext.responseCode(LoggingContext.DATA_ERROR); - logger.error(emsg); - exit(0); - } - - Loader loader= null; - try { - loader = LoaderFactory.createLoaderForVersion(ModelType.MOXY, AAIProperties.LATEST); - - } - catch (Exception ex){ - LoggingContext.statusCode(StatusCode.ERROR); - LoggingContext.responseCode(LoggingContext.UNKNOWN_ERROR); - logger.error("ERROR - Could not do the moxyMod.init() " + LogFormatTools.getStackTop(ex)); - exit(1); - } - JanusGraph graph1 = null; - JanusGraph graph2 = null; - Graph gt1 = null; - Graph gt2 = null; - - boolean specialTenantRule = false; - - try { - AAIConfig.init(); - int maxRecordsToFix = AAIConstants.AAI_DUPETOOL_DEFAULT_MAX_FIX; - int sleepMinutes = AAIConstants.AAI_DUPETOOL_DEFAULT_SLEEP_MINUTES; - int timeWindowMinutes = 0; // A value of 0 means that we will not have a time-window -- we will look - // at all nodes of the passed-in nodeType. - long windowStartTime = 0; // Translation of the window into a starting timestamp - - try { - String maxFixStr = AAIConfig.get("aai.dupeTool.default.max.fix"); - if( maxFixStr != null && !maxFixStr.isEmpty() ){ - maxRecordsToFix = Integer.parseInt(maxFixStr); - } - String sleepStr = AAIConfig.get("aai.dupeTool.default.sleep.minutes"); - if( sleepStr != null && !sleepStr.isEmpty() ){ - sleepMinutes = Integer.parseInt(sleepStr); - } - } - catch ( Exception e ){ - // Don't worry, we'll just use the defaults that we got from AAIConstants - logger.warn("WARNING - could not pick up aai.dupeTool values from aaiconfig.properties file. Will use defaults. "); - } - - String nodeTypeVal = ""; - String userIdVal = ""; - String filterParams = ""; - Boolean skipHostCheck = false; - Boolean autoFix = false; - String argStr4Msg = ""; - Introspector obj = null; - - if (args != null && args.length > 0) { - // They passed some arguments in that will affect processing - for (int i = 0; i < args.length; i++) { - String thisArg = args[i]; - argStr4Msg = argStr4Msg + " " + thisArg; - - if ("-nodeType".equals(thisArg)) { - i++; - if (i >= args.length) { - LoggingContext.statusCode(StatusCode.ERROR); - LoggingContext.responseCode(LoggingContext.BUSINESS_PROCESS_ERROR); - logger.error(" No value passed with -nodeType option. "); - exit(0); - } - nodeTypeVal = args[i]; - argStr4Msg = argStr4Msg + " " + nodeTypeVal; - } - else if ("-sleepMinutes".equals(thisArg)) { - i++; - if (i >= args.length) { - LoggingContext.statusCode(StatusCode.ERROR); - LoggingContext.responseCode(LoggingContext.BUSINESS_PROCESS_ERROR); - logger.error("No value passed with -sleepMinutes option."); - exit(0); - } - String nextArg = args[i]; - try { - sleepMinutes = Integer.parseInt(nextArg); - } catch (Exception e) { - LoggingContext.statusCode(StatusCode.ERROR); - LoggingContext.responseCode(LoggingContext.BUSINESS_PROCESS_ERROR); - logger.error("Bad value passed with -sleepMinutes option: [" - + nextArg + "]"); - exit(0); - } - argStr4Msg = argStr4Msg + " " + sleepMinutes; - } - else if ("-maxFix".equals(thisArg)) { - i++; - if (i >= args.length) { - LoggingContext.statusCode(StatusCode.ERROR); - LoggingContext.responseCode(LoggingContext.BUSINESS_PROCESS_ERROR); - logger.error("No value passed with -maxFix option."); - exit(0); - } - String nextArg = args[i]; - try { - maxRecordsToFix = Integer.parseInt(nextArg); - } catch (Exception e) { - LoggingContext.statusCode(StatusCode.ERROR); - LoggingContext.responseCode(LoggingContext.BUSINESS_PROCESS_ERROR); - logger.error("Bad value passed with -maxFix option: [" - + nextArg + "]"); - exit(0); - } - argStr4Msg = argStr4Msg + " " + maxRecordsToFix; - } - else if ("-timeWindowMinutes".equals(thisArg)) { - i++; - if (i >= args.length) { - LoggingContext.statusCode(StatusCode.ERROR); - LoggingContext.responseCode(LoggingContext.BUSINESS_PROCESS_ERROR); - logger.error("No value passed with -timeWindowMinutes option."); - exit(0); - } - String nextArg = args[i]; - try { - timeWindowMinutes = Integer.parseInt(nextArg); - } catch (Exception e) { - LoggingContext.statusCode(StatusCode.ERROR); - LoggingContext.responseCode(LoggingContext.BUSINESS_PROCESS_ERROR); - logger.error("Bad value passed with -timeWindowMinutes option: [" - + nextArg + "]"); - exit(0); - } - argStr4Msg = argStr4Msg + " " + timeWindowMinutes; - } - else if ("-skipHostCheck".equals(thisArg)) { - skipHostCheck = true; - } - else if ("-specialTenantRule".equals(thisArg)) { - specialTenantRule = true; - } - else if ("-autoFix".equals(thisArg)) { - autoFix = true; - } - else if ("-userId".equals(thisArg)) { - i++; - if (i >= args.length) { - LoggingContext.statusCode(StatusCode.ERROR); - LoggingContext.responseCode(LoggingContext.BUSINESS_PROCESS_ERROR); - logger.error(" No value passed with -userId option. "); - exit(0); - } - userIdVal = args[i]; - argStr4Msg = argStr4Msg + " " + userIdVal; - } - else if ("-params4Collect".equals(thisArg)) { - i++; - if (i >= args.length) { - LoggingContext.statusCode(StatusCode.ERROR); - LoggingContext.responseCode(LoggingContext.BUSINESS_PROCESS_ERROR); - logger.error(" No value passed with -params4Collect option. "); - exit(0); - } - filterParams = args[i]; - argStr4Msg = argStr4Msg + " " + filterParams; - } - else { - LoggingContext.statusCode(StatusCode.ERROR); - LoggingContext.responseCode(LoggingContext.BUSINESS_PROCESS_ERROR); - logger.error(" Unrecognized argument passed to DupeTool: [" - + thisArg + "]. "); - logger.error(" Valid values are: -action -userId -vertexId -edgeId -overRideProtection "); - exit(0); - } - } - } - - userIdVal = userIdVal.trim(); - if( (userIdVal.length() < 6) || "AAIADMIN".equalsIgnoreCase(userIdVal) ){ - String emsg = "userId parameter is required. [" + userIdVal + "] passed to DupeTool(). userId must be not empty and not aaiadmin \n"; - System.out.println(emsg); - LoggingContext.statusCode(StatusCode.ERROR); - LoggingContext.responseCode(LoggingContext.BUSINESS_PROCESS_ERROR); - logger.error(emsg); - exit(0); - } - - nodeTypeVal = nodeTypeVal.trim(); - if( nodeTypeVal.isEmpty() ){ - String emsg = " nodeType is a required parameter for DupeTool().\n"; - System.out.println(emsg); - LoggingContext.statusCode(StatusCode.ERROR); - LoggingContext.responseCode(LoggingContext.BUSINESS_PROCESS_ERROR); - logger.error(emsg); - exit(0); - } - obj = loader.introspectorFromName(nodeTypeVal); - - if (skipHostCheck) { - logger.info(" We will skip the HostCheck as requested. "); - } - - if( timeWindowMinutes > 0 ){ - // Translate the window value (ie. 30 minutes) into a unix timestamp like - // we use in the db - so we can select data created after that time. - windowStartTime = figureWindowStartTime( timeWindowMinutes ); - } - - String msg = ""; - msg = "DupeTool called with these params: [" + argStr4Msg + "]"; - System.out.println(msg); - logger.info(msg); - - // Determine what the key fields are for this nodeType (and we want them ordered) - ArrayList <String> keyPropNamesArr = new ArrayList<String>(obj.getKeys()); - - // Determine what kinds of nodes (if any) this nodeType is dependent on for uniqueness - ArrayList<String> depNodeTypeList = new ArrayList<String>(); - Collection<String> depNTColl = obj.getDependentOn(); - Iterator<String> ntItr = depNTColl.iterator(); - while( ntItr.hasNext() ){ - depNodeTypeList.add(ntItr.next()); - } - - // Based on the nodeType, window and filterData, figure out the vertices that we will be checking - System.out.println(" ---- NOTE --- about to open graph (takes a little while)--------\n"); - graph1 = setupGraph(logger); - gt1 = getGraphTransaction( graph1, logger ); - ArrayList<Vertex> verts2Check = new ArrayList<Vertex>(); - - verts2Check = figureOutNodes2Check( TRANSID, FROMAPPID, gt1, - nodeTypeVal, windowStartTime, filterParams, logger ); - - if( verts2Check == null || verts2Check.isEmpty() ){ - msg = " No vertices found to check. Used nodeType = [" + nodeTypeVal - + "], windowMinutes = " + timeWindowMinutes - + ", filterData = [" + filterParams + "]."; - logger.info( msg ); - System.out.println( msg ); - exit(0); - } - else { - msg = " Found " + verts2Check.size() + " nodes of type " + nodeTypeVal - + " to check using passed filterParams and windowStartTime. "; - logger.info( msg ); - System.out.println( msg ); - } - - ArrayList<String> firstPassDupeSets = new ArrayList <String>(); - ArrayList <String> secondPassDupeSets = new ArrayList <String>(); - Boolean isDependentOnParent = false; - if( !obj.getDependentOn().isEmpty() ){ - isDependentOnParent = true; - } - - if( isDependentOnParent ){ - firstPassDupeSets = getDupeSets4DependentNodes( TRANSID, FROMAPPID, gt1, - defVersion, nodeTypeVal, verts2Check, keyPropNamesArr, loader, - specialTenantRule, logger ); - } - else { - firstPassDupeSets = getDupeSets4NonDepNodes( TRANSID, FROMAPPID, gt1, - defVersion, nodeTypeVal, verts2Check, keyPropNamesArr, - specialTenantRule, loader, logger ); - } - - msg = " Found " + firstPassDupeSets.size() + " sets of duplicates for this request. "; - logger.info( msg ); - System.out.println( msg ); - if( !firstPassDupeSets.isEmpty() ){ - msg = " Here is what they look like: "; - logger.info( msg ); - System.out.println( msg ); - for( int x = 0; x < firstPassDupeSets.size(); x++ ){ - msg = " Set " + x + ": [" + firstPassDupeSets.get(x) +"] "; - logger.info( msg ); - System.out.println( msg ); - showNodeDetailsForADupeSet(gt1, firstPassDupeSets.get(x), logger); - } - } - - boolean didSomeDeletesFlag = false; - ArrayList <String> dupeSetsToFix = new ArrayList <String> (); - if( autoFix && firstPassDupeSets.isEmpty() ){ - msg = "AutoFix option is on, but no dupes were found on the first pass. Nothing to fix."; - logger.info( msg ); - System.out.println( msg ); - } - else if( autoFix ){ - // We will try to fix any dupes that we can - but only after sleeping for a - // time and re-checking the list of duplicates using a seperate transaction. - try { - msg = "\n\n----------- About to sleep for " + sleepMinutes + " minutes." - + " -----------\n\n"; - logger.info( msg ); - System.out.println( msg ); - int sleepMsec = sleepMinutes * 60 * 1000; - Thread.sleep(sleepMsec); - } catch (InterruptedException ie) { - msg = "\n >>> Sleep Thread has been Interrupted <<< "; - Thread.currentThread().interrupt(); - logger.info( msg ); - System.out.println( msg ); - exit(0); - } - - graph2 = setupGraph(logger); - gt2 = getGraphTransaction( graph2, logger ); - if( isDependentOnParent ){ - secondPassDupeSets = getDupeSets4DependentNodes( TRANSID, FROMAPPID, gt2, - defVersion, nodeTypeVal, verts2Check, keyPropNamesArr, loader, - specialTenantRule, logger ); - } - else { - secondPassDupeSets = getDupeSets4NonDepNodes( TRANSID, FROMAPPID, gt2, - defVersion, nodeTypeVal, verts2Check, keyPropNamesArr, - specialTenantRule, loader, logger ); - } - - dupeSetsToFix = figureWhichDupesStillNeedFixing( firstPassDupeSets, secondPassDupeSets, logger ); - msg = "\nAfter running a second pass, there were " + dupeSetsToFix.size() - + " sets of duplicates that we think can be deleted. "; - logger.info( msg ); - System.out.println( msg ); - if( !dupeSetsToFix.isEmpty()){ - msg = " Here is what the sets look like: "; - logger.info( msg ); - System.out.println( msg ); - for( int x = 0; x < dupeSetsToFix.size(); x++ ){ - msg = " Set " + x + ": [" + dupeSetsToFix.get(x) +"] "; - logger.info( msg ); - System.out.println( msg ); - showNodeDetailsForADupeSet(gt2, dupeSetsToFix.get(x), logger); - } - } - - if( !dupeSetsToFix.isEmpty() ){ - if( dupeSetsToFix.size() > maxRecordsToFix ){ - String infMsg = " >> WARNING >> Dupe list size (" - + dupeSetsToFix.size() - + ") is too big. The maxFix we are using is: " - + maxRecordsToFix - + ". No nodes will be deleted. (use the" - + " -maxFix option to override this limit.)"; - System.out.println(infMsg); - logger.info(infMsg); - } - else { - // Call the routine that fixes known dupes - didSomeDeletesFlag = deleteNonKeepers( gt2, dupeSetsToFix, logger ); - } - } - if( didSomeDeletesFlag ){ - gt2.tx().commit(); - } - } - - } catch (AAIException e) { - logger.error("Caught AAIException while running the dupeTool: " + LogFormatTools.getStackTop(e)); - ErrorLogHelper.logException(e); - } catch (Exception ex) { - logger.error("Caught exception while running the dupeTool: "+ LogFormatTools.getStackTop(ex)); - ErrorLogHelper.logError("AAI_6128", ex.getMessage() + ", resolve and rerun the dupeTool. "); - } finally { - if (gt1 != null && gt1.tx().isOpen()) { - // We don't change any data with gt1 - so just roll it back so it knows we're done. - try { - gt1.tx().rollback(); - } - catch (Exception ex) { - // Don't throw anything because JanusGraph sometimes is just saying that the graph is already closed - logger.warn("WARNING from final gt1.rollback() " + LogFormatTools.getStackTop(ex)); - } - } - - if (gt2 != null && gt2.tx().isOpen()) { - // Any changes that worked correctly should have already done - // their commits. - try { - gt2.tx().rollback(); - } catch (Exception ex) { - // Don't throw anything because JanusGraph sometimes is just saying that the graph is already closed - logger.warn("WARNING from final gt2.rollback() " + LogFormatTools.getStackTop(ex)); - } - } - - try { - if( graph1 != null && graph1.isOpen() ){ - closeGraph(graph1, logger); - } - } catch (Exception ex) { - // Don't throw anything because JanusGraph sometimes is just saying that the graph is already closed{ - logger.warn("WARNING from final graph1.shutdown() " + LogFormatTools.getStackTop(ex)); - } - - try { - if( graph2 != null && graph2.isOpen() ){ - closeGraph(graph2, logger); - } - } catch (Exception ex) { - // Don't throw anything because JanusGraph sometimes is just saying that the graph is already closed{ - logger.warn("WARNING from final graph2.shutdown() " + LogFormatTools.getStackTop(ex)); - } - } - - exit(0); - - }// end of main() - - - /** - * Collect Duplicate Sets for nodes that are NOT dependent on parent nodes. - * - * @param transId the trans id - * @param fromAppId the from app id - * @param g the g - * @param version the version - * @param nType the n type - * @param passedVertList the passed vert list - * @return the array list - */ - private static ArrayList<String> getDupeSets4NonDepNodes( String transId, - String fromAppId, Graph g, String version, String nType, - ArrayList<Vertex> passedVertList, - ArrayList <String> keyPropNamesArr, - Boolean specialTenantRule, Loader loader, EELFLogger logger ) { - - ArrayList<String> returnList = new ArrayList<String>(); - - // We've been passed a set of nodes that we want to check. - // They are all NON-DEPENDENT nodes meaning that they should be - // unique in the DB based on their KEY DATA alone. So, if - // we group them by their key data - if any key has more than one - // vertex mapped to it, those vertices are dupes. - // - // When we find duplicates, we return then as a String (there can be - // more than one duplicate for one set of key data): - // Each element in the returned arrayList might look like this: - // "1234|5678|keepVid=UNDETERMINED" (if there were 2 dupes, and we - // couldn't figure out which one to keep) - // or, "100017|200027|30037|keepVid=30037" (if there were 3 dupes and we - // thought the third one was the one that should survive) - - HashMap <String, ArrayList<String>> keyVals2VidHash = new HashMap <String, ArrayList<String>>(); - HashMap <String,Vertex> vtxHash = new HashMap <String,Vertex>(); - Iterator<Vertex> pItr = passedVertList.iterator(); - while (pItr.hasNext()) { - try { - Vertex tvx = pItr.next(); - String thisVid = tvx.id().toString(); - vtxHash.put(thisVid, tvx); - - // if there are more than one vertexId mapping to the same keyProps -- they are dupes - String hKey = getNodeKeyValString( tvx, keyPropNamesArr, logger ); - if( keyVals2VidHash.containsKey(hKey) ){ - // We've already seen this key - ArrayList <String> tmpVL = keyVals2VidHash.get(hKey); - tmpVL.add(thisVid); - keyVals2VidHash.put(hKey, tmpVL); - } - else { - // First time for this key - ArrayList <String> tmpVL = new ArrayList <String>(); - tmpVL.add(thisVid); - keyVals2VidHash.put(hKey, tmpVL); - } - } - catch (Exception e) { - logger.warn(" >>> Threw an error in getDupeSets4NonDepNodes - just absorb this error and move on. " + LogFormatTools.getStackTop(e)); - } - } - - for( Map.Entry<String, ArrayList<String>> entry : keyVals2VidHash.entrySet() ){ - ArrayList <String> vidList = entry.getValue(); - try { - if( !vidList.isEmpty() && vidList.size() > 1 ){ - // There are more than one vertex id's using the same key info - String dupesStr = ""; - ArrayList <Vertex> vertList = new ArrayList <Vertex> (); - for (int i = 0; i < vidList.size(); i++) { - String tmpVid = vidList.get(i); - dupesStr = dupesStr + tmpVid + "|"; - vertList.add(vtxHash.get(tmpVid)); - } - - if (dupesStr != "") { - Vertex prefV = getPreferredDupe(transId, fromAppId, - g, vertList, version, specialTenantRule, loader, logger); - if (prefV == null) { - // We could not determine which duplicate to keep - dupesStr = dupesStr + "KeepVid=UNDETERMINED"; - returnList.add(dupesStr); - } else { - dupesStr = dupesStr + "KeepVid=" + prefV.id(); - returnList.add(dupesStr); - } - } - } - } - catch (Exception e) { - logger.warn(" >>> Threw an error in getDupeSets4NonDepNodes - just absorb this error and move on. " + LogFormatTools.getStackTop(e)); - } - - } - return returnList; - - }// End of getDupeSets4NonDepNodes() - - - /** - * Collect Duplicate Sets for nodes that are dependent on parent nodes. - * - * @param transId the trans id - * @param fromAppId the from app id - * @param g the g - * @param version the version - * @param nType the n type - * @param passedVertList the passed vert list - * @param keyPropNamesArr Array (ordered) of keyProperty names - * @param specialTenantRule flag - * @param logger the logger - * @return the array list - */ - private static ArrayList<String> getDupeSets4DependentNodes( String transId, - String fromAppId, Graph g, String version, String nType, - ArrayList<Vertex> passedVertList, - ArrayList <String> keyPropNamesArr, Loader loader, - Boolean specialTenantRule, EELFLogger logger ) { - - // This is for nodeTypes that DEPEND ON A PARENT NODE FOR UNIQUNESS - - ArrayList<String> returnList = new ArrayList<String>(); - ArrayList<String> alreadyFoundDupeVidArr = new ArrayList<String>(); - - // We've been passed a set of nodes that we want to check. These are - // all nodes that ARE DEPENDENT on a PARENT Node for uniqueness. - // The first thing to do is to identify the key properties for the node-type - // and pull from the db just using those properties. - // Then, we'll check those nodes with their parent nodes to see if there - // are any duplicates. - // - // When we find duplicates, we return then as a String (there can be - // more than one duplicate for one set of key data): - // Each element in the returned arrayList might look like this: - // "1234|5678|keepVid=UNDETERMINED" (if there were 2 dupes, and we - // couldn't figure out which one to keep) - // or, "100017|200027|30037|keepVid=30037" (if there were 3 dupes and we - // thought the third one was the one that should survive) - HashMap<String, Object> checkVertHash = new HashMap <String,Object> (); - try { - Iterator<Vertex> pItr = passedVertList.iterator(); - while (pItr.hasNext()) { - Vertex tvx = pItr.next(); - String passedId = tvx.id().toString(); - if( !alreadyFoundDupeVidArr.contains(passedId) ){ - // We haven't seen this one before - so we should check it. - HashMap <String,Object> keyPropValsHash = getNodeKeyVals( tvx, keyPropNamesArr, logger ); - ArrayList <Vertex> tmpVertList = getNodeJustUsingKeyParams( transId, fromAppId, g, - nType, keyPropValsHash, version, logger ); - - if( tmpVertList.size() <= 1 ){ - // Even without a parent node, this thing is unique so don't worry about it. - } - else { - for( int i = 0; i < tmpVertList.size(); i++ ){ - Vertex tmpVtx = (tmpVertList.get(i)); - String tmpVid = tmpVtx.id().toString(); - alreadyFoundDupeVidArr.add(tmpVid); - - String hKey = getNodeKeyValString( tmpVtx, keyPropNamesArr, logger ); - if( checkVertHash.containsKey(hKey) ){ - // add it to an existing list - ArrayList <Vertex> tmpVL = (ArrayList <Vertex>)checkVertHash.get(hKey); - tmpVL.add(tmpVtx); - checkVertHash.put(hKey, tmpVL); - } - else { - // First time for this key - ArrayList <Vertex> tmpVL = new ArrayList <Vertex>(); - tmpVL.add(tmpVtx); - checkVertHash.put(hKey, tmpVL); - } - } - } - } - } - - // More than one node have the same key fields since they may - // depend on a parent node for uniqueness. Since we're finding - // more than one, we want to check to see if any of the - // vertices that have this set of keys are also pointing at the - // same 'parent' node. - // Note: for a given set of key data, it is possible that there - // could be more than one set of duplicates. - for (Entry<String, Object> lentry : checkVertHash.entrySet()) { - ArrayList <Vertex> thisIdSetList = (ArrayList <Vertex>)lentry.getValue(); - if (thisIdSetList == null || thisIdSetList.size() < 2) { - // Nothing to check for this set. - continue; - } - - HashMap<String, ArrayList<Vertex>> vertsGroupedByParentHash = groupVertsByDepNodes( - transId, fromAppId, g, version, nType, - thisIdSetList, loader); - for (Map.Entry<String, ArrayList<Vertex>> entry : vertsGroupedByParentHash - .entrySet()) { - ArrayList<Vertex> thisParentsVertList = entry - .getValue(); - if (thisParentsVertList.size() > 1) { - // More than one vertex found with the same key info - // hanging off the same parent/dependent node - String dupesStr = ""; - for (int i = 0; i < thisParentsVertList.size(); i++) { - dupesStr = dupesStr + thisParentsVertList.get(i).id() + "|"; - } - if (dupesStr != "") { - Vertex prefV = getPreferredDupe(transId, - fromAppId, g, thisParentsVertList, - version, specialTenantRule, loader, logger); - - if (prefV == null) { - // We could not determine which duplicate to keep - dupesStr = dupesStr + "KeepVid=UNDETERMINED"; - returnList.add(dupesStr); - } - else { - dupesStr = dupesStr + "KeepVid=" - + prefV.id().toString(); - returnList.add(dupesStr); - } - } - } - } - } - - } catch (Exception e) { - logger.warn(" >>> Threw an error in checkAndProcessDupes - just absorb this error and move on. " + LogFormatTools.getStackTop(e)); - } - - return returnList; - - }// End of getDupeSets4DependentNodes() - - - private static Graph getGraphTransaction(JanusGraph graph, EELFLogger logger){ - - Graph gt = null; - try { - if( graph != null ){ - gt = graph.newTransaction(); - } else { - String emsg = "could not get graph object in DupeTool. \n"; - System.out.println(emsg); - LoggingContext.statusCode(StatusCode.ERROR); - LoggingContext.responseCode(LoggingContext.AVAILABILITY_TIMEOUT_ERROR); - logger.error(emsg); - exit(0); - } - } - catch (Exception e) { - String msg = e.toString(); - System.out.println(msg); - LoggingContext.statusCode(StatusCode.ERROR); - LoggingContext.responseCode(LoggingContext.UNKNOWN_ERROR); - logger.error(msg); - exit(0); - } - - return gt; - - }// End of getGraphTransaction() - - - - public static void showNodeInfo(EELFLogger logger, Vertex tVert, Boolean displayAllVidsFlag ){ - - try { - Iterator<VertexProperty<Object>> pI = tVert.properties(); - String infStr = ">>> Found Vertex with VertexId = " + tVert.id() + ", properties: "; - System.out.println( infStr ); - logger.info(infStr); - while( pI.hasNext() ){ - VertexProperty<Object> tp = pI.next(); - infStr = " [" + tp.key() + "|" + tp.value() + "] "; - System.out.println( infStr ); - logger.info(infStr); - } - - ArrayList <String> retArr = collectEdgeInfoForNode( logger, tVert, displayAllVidsFlag ); - for( String infoStr : retArr ){ - System.out.println( infoStr ); - logger.info(infoStr); - } - } - catch (Exception e){ - String warnMsg = " -- Error -- trying to display edge info. [" + e.getMessage() + "]"; - System.out.println( warnMsg ); - LoggingContext.statusCode(StatusCode.ERROR); - LoggingContext.responseCode(LoggingContext.UNKNOWN_ERROR); - logger.warn(warnMsg); - LoggingContext.statusCode(StatusCode.COMPLETE); - LoggingContext.responseCode(LoggingContext.SUCCESS); - } - - }// End of showNodeInfo() - - public static ArrayList <String> collectEdgeInfoForNode( EELFLogger logger, Vertex tVert, boolean displayAllVidsFlag ){ - ArrayList <String> retArr = new ArrayList <String> (); - Direction dir = Direction.OUT; - for ( int i = 0; i <= 1; i++ ){ - if( i == 1 ){ - // Second time through we'll look at the IN edges. - dir = Direction.IN; - } - Iterator <Edge> eI = tVert.edges(dir); - if( ! eI.hasNext() ){ - retArr.add("No " + dir + " edges were found for this vertex. "); - } - while( eI.hasNext() ){ - Edge ed = eI.next(); - String lab = ed.label(); - Vertex vtx = null; - if( dir == Direction.OUT ){ - // get the vtx on the "other" side - vtx = ed.inVertex(); - } - else { - // get the vtx on the "other" side - vtx = ed.outVertex(); - } - if( vtx == null ){ - retArr.add(COULD_NOT_FIND_EDGE_ID_ + ed.id() + " <<< "); - continue; - } - - String nType = vtx.<String>property(AAI_NODE_TYPE).orElse(null); - if( displayAllVidsFlag ){ - // This should rarely be needed - String vid = vtx.id().toString(); - retArr.add("Found an " + dir + " edge (" + lab + ") between this vertex and a [" + nType + "] node with VtxId = " + vid ); - } - else { - // This is the normal case - retArr.add("Found an " + dir + " edge (" + lab + ") between this vertex and a [" + nType + "] node. "); - } - } - } - return retArr; - - }// end of collectEdgeInfoForNode() - - - private static long figureWindowStartTime( int timeWindowMinutes ){ - // Given a window size, calculate what the start-timestamp would be. - - if( timeWindowMinutes <= 0 ){ - // This just means that there is no window... - return 0; - } - long unixTimeNow = System.currentTimeMillis(); - long windowInMillis = timeWindowMinutes * 60l * 1000l; - - return unixTimeNow - windowInMillis; - } // End of figureWindowStartTime() - - - - /** - * Gets the node(s) just using key params. - * - * @param transId the trans id - * @param fromAppId the from app id - * @param graph the graph - * @param nodeType the node type - * @param keyPropsHash the key props hash - * @param apiVersion the api version - * @return the node just using key params - * @throws AAIException the AAI exception - */ - public static ArrayList <Vertex> getNodeJustUsingKeyParams( String transId, String fromAppId, Graph graph, String nodeType, - HashMap<String,Object> keyPropsHash, String apiVersion, EELFLogger logger ) throws AAIException{ - - ArrayList <Vertex> retVertList = new ArrayList <Vertex> (); - - // We assume that all NodeTypes have at least one key-property defined. - // Note - instead of key-properties (the primary key properties), a user could pass - // alternate-key values if they are defined for the nodeType. - ArrayList<String> kName = new ArrayList<String>(); - ArrayList<Object> kVal = new ArrayList<Object>(); - if( keyPropsHash == null || keyPropsHash.isEmpty() ) { - throw new AAIException("AAI_6120", " NO key properties passed for this getNodeJustUsingKeyParams() request. NodeType = [" + nodeType + "]. "); - } - - int i = -1; - for( Map.Entry<String, Object> entry : keyPropsHash.entrySet() ){ - i++; - kName.add(i, entry.getKey()); - kVal.add(i, entry.getValue()); - } - int topPropIndex = i; - Vertex tiV = null; - String propsAndValuesForMsg = ""; - Iterator<Vertex> verts = null; - GraphTraversalSource g = graph.traversal(); - try { - if( topPropIndex == 0 ){ - propsAndValuesForMsg = " (" + kName.get(0) + " = " + kVal.get(0) + ") "; - verts= g.V().has(kName.get(0),kVal.get(0)).has(AAI_NODE_TYPE,nodeType); - } - else if( topPropIndex == 1 ){ - propsAndValuesForMsg = " (" + kName.get(0) + " = " + kVal.get(0) + ", " - + kName.get(1) + " = " + kVal.get(1) + ") "; - verts = g.V().has(kName.get(0),kVal.get(0)).has(kName.get(1),kVal.get(1)).has(AAI_NODE_TYPE,nodeType); - } - else if( topPropIndex == 2 ){ - propsAndValuesForMsg = " (" + kName.get(0) + " = " + kVal.get(0) + ", " - + kName.get(1) + " = " + kVal.get(1) + ", " - + kName.get(2) + " = " + kVal.get(2) + ") "; - verts= g.V().has(kName.get(0),kVal.get(0)).has(kName.get(1),kVal.get(1)).has(kName.get(2),kVal.get(2)).has(AAI_NODE_TYPE,nodeType); - } - else if( topPropIndex == 3 ){ - propsAndValuesForMsg = " (" + kName.get(0) + " = " + kVal.get(0) + ", " - + kName.get(1) + " = " + kVal.get(1) + ", " - + kName.get(2) + " = " + kVal.get(2) + ", " - + kName.get(3) + " = " + kVal.get(3) + ") "; - verts= g.V().has(kName.get(0),kVal.get(0)).has(kName.get(1),kVal.get(1)).has(kName.get(2),kVal.get(2)).has(kName.get(3),kVal.get(3)).has(AAI_NODE_TYPE,nodeType); - } - else { - throw new AAIException("AAI_6114", " We only support 4 keys per nodeType for now \n"); - } - } - catch( Exception ex ){ - LoggingContext.statusCode(StatusCode.ERROR); - LoggingContext.responseCode(LoggingContext.DATA_ERROR); - logger.error( " ERROR trying to get node for: [" + propsAndValuesForMsg + "] " + LogFormatTools.getStackTop(ex)); - LoggingContext.statusCode(StatusCode.COMPLETE); - LoggingContext.responseCode(LoggingContext.SUCCESS); - } - - if( verts != null ){ - while( verts.hasNext() ){ - tiV = verts.next(); - retVertList.add(tiV); - } - } - - if( retVertList.isEmpty() ){ - logger.debug("DEBUG No node found for nodeType = [" + nodeType + - "], propsAndVal = " + propsAndValuesForMsg ); - } - - return retVertList; - - }// End of getNodeJustUsingKeyParams() - - - - /** - * Gets the node(s) just using key params. - * - * @param transId the trans id - * @param fromAppId the from app id - * @param graph the graph - * @param nodeType the node type - * @param windowStartTime the window start time - * @return the nodes - * @throws AAIException the AAI exception - */ - public static ArrayList <Vertex> figureOutNodes2Check( String transId, String fromAppId, - Graph graph, String nodeType, long windowStartTime, - String propsString, EELFLogger logger ) { - - ArrayList <Vertex> retVertList = new ArrayList <Vertex> (); - String msg = ""; - GraphTraversal<Vertex,Vertex> tgQ = graph.traversal().V().has(AAI_NODE_TYPE,nodeType); - String qStringForMsg = "graph.traversal().V().has(\"aai-node-type\"," + nodeType + ")"; - - if( propsString != null && !propsString.trim().isEmpty() ){ - propsString = propsString.trim(); - int firstPipeLoc = propsString.indexOf("|"); - if( firstPipeLoc <= 0 ){ - msg = "Bad props4Collect passed: [" + propsString + "]. \n Expecting a format like, 'propName1|propVal1,propName2|propVal2'"; - System.out.println(msg); - LoggingContext.statusCode(StatusCode.ERROR); - LoggingContext.responseCode(LoggingContext.DATA_ERROR); - logger.error(msg); - exit(0); - } - - // Note - if they're only passing on parameter, there won't be any commas - String [] paramArr = propsString.split(","); - for( int i = 0; i < paramArr.length; i++ ){ - int pipeLoc = paramArr[i].indexOf("|"); - if( pipeLoc <= 0 ){ - msg = "Bad propsString passed: [" + propsString + "]. \n Expecting a format like, 'propName1|propVal1,propName2|propVal2'"; - System.out.println(msg); - LoggingContext.statusCode(StatusCode.ERROR); - LoggingContext.responseCode(LoggingContext.DATA_ERROR); - logger.error(msg); - exit(0); - } - else { - String propName = paramArr[i].substring(0,pipeLoc); - String propVal = paramArr[i].substring(pipeLoc + 1); - tgQ = tgQ.has(propName,propVal); - qStringForMsg = qStringForMsg + ".has(" + propName + "," + propVal + ")"; - } - } - } - - if(tgQ != null) { - Iterator<Vertex> vertItor = tgQ; - while (vertItor.hasNext()) { - Vertex tiV = vertItor.next(); - if (windowStartTime <= 0) { - // We're not applying a time-window - retVertList.add(tiV); - continue; - } - - Object objTimeStamp = tiV.property("aai-created-ts").orElse(null); - if (objTimeStamp == null) { - // No timestamp - so just take it - retVertList.add(tiV); - continue; - } - - long thisNodeCreateTime = (long) objTimeStamp; - if (thisNodeCreateTime > windowStartTime) { - // It is in our window, so we can take it - retVertList.add(tiV); - } - } - } else { - msg = "Bad JanusGraphQuery object. "; - System.out.println(msg); - LoggingContext.statusCode(StatusCode.ERROR); - LoggingContext.responseCode(LoggingContext.AVAILABILITY_TIMEOUT_ERROR); - logger.error(msg); - exit(0); - } - - if( retVertList.isEmpty() ){ - logger.debug("DEBUG No node found for: [" + qStringForMsg + ", with aai-created-ts > " + windowStartTime ); - } - - return retVertList; - - }// End of figureOutNodes2Check() - - - /** - * Gets the preferred dupe. - * - * @param transId the trans id - * @param fromAppId the from app id - * @param g the g - * @param dupeVertexList the dupe vertex list - * @param ver the ver - * @param logger the logger - * @return Vertex - * @throws AAIException the AAI exception - */ - public static Vertex getPreferredDupe( String transId, - String fromAppId, Graph g, - ArrayList<Vertex> dupeVertexList, String ver, - Boolean specialTenantRule, Loader loader, EELFLogger logger ) - throws AAIException { - - // This method assumes that it is being passed a List of vertex objects - // which violate our uniqueness constraints. - - Vertex nullVtx = null; - - if (dupeVertexList == null) { - return nullVtx; - } - int listSize = dupeVertexList.size(); - if (listSize == 0) { - return nullVtx; - } - if (listSize == 1) { - return ( dupeVertexList.get(0)); - } - - Vertex vtxPreferred = null; - Vertex currentFaveVtx = dupeVertexList.get(0); - for (int i = 1; i < listSize; i++) { - Vertex vtxB = dupeVertexList.get(i); - vtxPreferred = pickOneOfTwoDupes(transId, fromAppId, g, - currentFaveVtx, vtxB, ver, specialTenantRule, loader, logger); - if (vtxPreferred == null) { - // We couldn't choose one - return nullVtx; - } else { - currentFaveVtx = vtxPreferred; - } - } - - return (currentFaveVtx); - - } // end of getPreferredDupe() - - - /** - * Pick one of two dupes. - * - * @param transId the trans id - * @param fromAppId the from app id - * @param g the g - * @param vtxA the vtx A - * @param vtxB the vtx B - * @param ver the ver - * @param specialTenantRule flag - * @param logger the logger - * @return Vertex - * @throws AAIException the AAI exception - */ - public static Vertex pickOneOfTwoDupes(String transId, - String fromAppId, Graph g, Vertex vtxA, - Vertex vtxB, String ver, Boolean specialTenantRule, Loader loader, EELFLogger logger) throws AAIException { - - Vertex nullVtx = null; - Vertex preferredVtx = null; - - Long vidA = new Long(vtxA.id().toString()); - Long vidB = new Long(vtxB.id().toString()); - - String vtxANodeType = ""; - String vtxBNodeType = ""; - Object obj = vtxA.<Object>property(AAI_NODE_TYPE).orElse(null); - if (obj != null) { - vtxANodeType = obj.toString(); - } - obj = vtxB.<Object>property(AAI_NODE_TYPE).orElse(null); - if (obj != null) { - vtxBNodeType = obj.toString(); - } - - if (vtxANodeType.isEmpty() || (!vtxANodeType.equals(vtxBNodeType))) { - // Either they're not really dupes or there's some bad data - so - // don't pick one - return nullVtx; - } - - // Check that node A and B both have the same key values (or else they - // are not dupes) - // (We'll check dep-node later) - Collection<String> keyProps = loader.introspectorFromName(vtxANodeType).getKeys(); - Iterator<String> keyPropI = keyProps.iterator(); - while (keyPropI.hasNext()) { - String propName = keyPropI.next(); - String vtxAKeyPropVal = ""; - obj = vtxA.<Object>property(propName).orElse(null); - if (obj != null) { - vtxAKeyPropVal = obj.toString(); - } - String vtxBKeyPropVal = ""; - obj = vtxB.<Object>property(propName).orElse(null); - if (obj != null) { - vtxBKeyPropVal = obj.toString(); - } - - if (vtxAKeyPropVal.equals("") - || (!vtxAKeyPropVal.equals(vtxBKeyPropVal))) { - // Either they're not really dupes or they are missing some key - // data - so don't pick one - return nullVtx; - } - } - - // Collect the vid's and aai-node-types of the vertices that each vertex - // (A and B) is connected to. - ArrayList<String> vtxIdsConn2A = new ArrayList<String>(); - ArrayList<String> vtxIdsConn2B = new ArrayList<String>(); - HashMap<String, String> nodeTypesConn2A = new HashMap<String, String>(); - HashMap<String, String> nodeTypesConn2B = new HashMap<String, String>(); - - ArrayList <String> retArr = new ArrayList <String> (); - Iterator <Edge> eAI = vtxA.edges(Direction.BOTH); - while( eAI.hasNext() ){ - Edge ed = eAI.next(); - Vertex tmpVtx; - if (vtxA.equals(ed.inVertex())) { - tmpVtx = ed.outVertex(); - } else { - tmpVtx = ed.inVertex(); - } - if( tmpVtx == null ){ - retArr.add(COULD_NOT_FIND_EDGE_ID_ + ed.id() + " <<< "); - } - else { - String conVid = tmpVtx.id().toString(); - String nt = ""; - obj = tmpVtx.<Object>property(AAI_NODE_TYPE).orElse(null); - if (obj != null) { - nt = obj.toString(); - } - nodeTypesConn2A.put(nt, conVid); - vtxIdsConn2A.add(conVid); - } - } - - Iterator <Edge> eBI = vtxB.edges(Direction.BOTH); - while( eBI.hasNext() ){ - Edge ed = eBI.next(); - Vertex tmpVtx; - - if (vtxB.equals(ed.inVertex())) { - tmpVtx = ed.outVertex(); - } else { - tmpVtx = ed.inVertex(); - } - if( tmpVtx == null ){ - retArr.add(COULD_NOT_FIND_EDGE_ID_ + ed.id() + " <<< "); - } - else { - String conVid = tmpVtx.id().toString(); - String nt = ""; - obj = tmpVtx.<Object>property(AAI_NODE_TYPE).orElse(null); - if (obj != null) { - nt = obj.toString(); - } - nodeTypesConn2B.put(nt, conVid); - vtxIdsConn2B.add(conVid); - } - } - - // 1 - If this kind of node needs a dependent node for uniqueness, then - // verify that they both nodes point to the same dependent - // node (otherwise they're not really duplicates) - // Note - there are sometimes more than one dependent node type since - // one nodeType can be used in different ways. But for a - // particular node, it will only have one dependent node that - // it's connected to. - Collection<String> depNodeTypes = loader.introspectorFromName(vtxANodeType).getDependentOn(); - if (depNodeTypes.isEmpty()) { - // This kind of node is not dependent on any other. That is ok. - } else { - String depNodeVtxId4A = ""; - String depNodeVtxId4B = ""; - Iterator<String> iter = depNodeTypes.iterator(); - while (iter.hasNext()) { - String depNodeType = iter.next(); - if (nodeTypesConn2A.containsKey(depNodeType)) { - // This is the dependent node type that vertex A is using - depNodeVtxId4A = nodeTypesConn2A.get(depNodeType); - } - if (nodeTypesConn2B.containsKey(depNodeType)) { - // This is the dependent node type that vertex B is using - depNodeVtxId4B = nodeTypesConn2B.get(depNodeType); - } - } - if (depNodeVtxId4A.isEmpty() - || (!depNodeVtxId4A.equals(depNodeVtxId4B))) { - // Either they're not really dupes or there's some bad data - so - // don't pick either one - return nullVtx; - } - } - - if (vtxIdsConn2A.size() == vtxIdsConn2B.size()) { - // 2 - If they both have edges to all the same vertices, then return - // the one with the lower vertexId. - - // OR (2b)-- if this is the SPECIAL case -- of - // "tenant|vserver vs. tenant|service-subscription" - // then we pick/prefer the one that's connected to - // the service-subscription. AAI-8172 - boolean allTheSame = true; - Iterator<String> iter = vtxIdsConn2A.iterator(); - while (iter.hasNext()) { - String vtxIdConn2A = iter.next(); - if (!vtxIdsConn2B.contains(vtxIdConn2A)) { - allTheSame = false; - break; - } - } - - if (allTheSame) { - if (vidA < vidB) { - preferredVtx = vtxA; - } else { - preferredVtx = vtxB; - } - } - else if ( specialTenantRule && vtxIdsConn2A.size() == 2 && "tenant".equals(vtxANodeType)){ - // They asked us to apply a special rule if it applies - // We're dealing with two tenant nodes which each just have - // two connections. One must be the parent (cloud-region) - // which we check in step 1 above. If one connects to - // a vserver and the other connects to a service-subscription, - // our special rule is to keep the one connected - // to the - if( nodeTypesConn2A.containsKey("vserver") && nodeTypesConn2B.containsKey("service-subscription") ){ - String infMsg = " WARNING >>> we are using the special tenant rule to choose to " + - " delete tenant vtxId = " + vidA + ", and keep tenant vtxId = " + vidB ; - System.out.println(infMsg); - logger.info( infMsg ); - preferredVtx = vtxB; - } - else if( nodeTypesConn2B.containsKey("vserver") && nodeTypesConn2A.containsKey("service-subscription") ){ - String infMsg = " WARNING >>> we are using the special tenant rule to choose to " + - " delete tenant vtxId = " + vidB + ", and keep tenant vtxId = " + vidA ; - System.out.println(infMsg); - logger.info( infMsg ); - preferredVtx = vtxA; - } - } - } else if (vtxIdsConn2A.size() > vtxIdsConn2B.size()) { - // 3 - VertexA is connected to more things than vtxB. - // We'll pick VtxA if its edges are a superset of vtxB's edges. - boolean missingOne = false; - Iterator<String> iter = vtxIdsConn2B.iterator(); - while (iter.hasNext()) { - String vtxIdConn2B = iter.next(); - if (!vtxIdsConn2A.contains(vtxIdConn2B)) { - missingOne = true; - break; - } - } - if (!missingOne) { - preferredVtx = vtxA; - } - } else if (vtxIdsConn2B.size() > vtxIdsConn2A.size()) { - // 4 - VertexB is connected to more things than vtxA. - // We'll pick VtxB if its edges are a superset of vtxA's edges. - boolean missingOne = false; - Iterator<String> iter = vtxIdsConn2A.iterator(); - while (iter.hasNext()) { - String vtxIdConn2A = iter.next(); - if (!vtxIdsConn2B.contains(vtxIdConn2A)) { - missingOne = true; - break; - } - } - if (!missingOne) { - preferredVtx = vtxB; - } - } else { - preferredVtx = nullVtx; - } - - return (preferredVtx); - - } // end of pickOneOfTwoDupes() - - - /** - * Group verts by dep nodes. - * - * @param transId the trans id - * @param fromAppId the from app id - * @param g the g - * @param version the version - * @param nType the n type - * @param passedVertList the passed vert list - * @param loader loader - * @return the hash map - * @throws AAIException the AAI exception - */ - private static HashMap<String, ArrayList<Vertex>> groupVertsByDepNodes( - String transId, String fromAppId, Graph g, String version, - String nType, ArrayList<Vertex> passedVertList, Loader loader) - throws AAIException { - - // Given a list of JanusGraph Vertices, group them together by dependent - // nodes. Ie. if given a list of ip address nodes (assumed to all - // have the same key info) they might sit under several different - // parent vertices. - // Under Normal conditions, there would only be one per parent -- but - // we're trying to find duplicates - so we allow for the case - // where more than one is under the same parent node. - - HashMap<String, ArrayList<Vertex>> retHash = new HashMap<String, ArrayList<Vertex>>(); - - // Find out what types of nodes the passed in nodes can depend on - ArrayList<String> depNodeTypeL = new ArrayList<String>(); - Collection<String> depNTColl = loader.introspectorFromName(nType).getDependentOn(); - Iterator<String> ntItr = depNTColl.iterator(); - while (ntItr.hasNext()) { - depNodeTypeL.add(ntItr.next()); - } - // For each vertex they passed us, we want find the vertex it - // is dependent on so we can keep track of who-all is connected - // to that parent. - if (passedVertList != null) { - Iterator<Vertex> iter = passedVertList.iterator(); - while (iter.hasNext()) { - Vertex thisVert = iter.next(); - Iterator <String> depNtItr = depNTColl.iterator(); - while (depNtItr.hasNext()) { - GraphTraversal<Vertex, Vertex> modPipe = null; - // NOTE -- if we change the direction of parent/child edges, we will need - // the "in" below to become "out" - modPipe = g.traversal().V(thisVert).in().has(AAI_NODE_TYPE, depNtItr.next() ); - if( modPipe == null || !modPipe.hasNext() ){ - //System.out.println("DEBUG - didn't find any [" + targetStep + "] connected to this guy (which is ok)"); - continue; - } - - while( modPipe.hasNext() ){ - Vertex depVert = modPipe.next(); - String parentVid = depVert.id().toString(); - if (retHash.containsKey(parentVid)) { - // add this vert to the list for this parent key - retHash.get(parentVid).add(thisVert); - } else { - // This is the first one we found on this parent - ArrayList<Vertex> vList = new ArrayList<Vertex>(); - vList.add(thisVert); - retHash.put(parentVid, vList); - } - } - } - } - } - - return retHash; - - }// end of groupVertsByDepNodes() - - - /** - * Delete non keepers if appropriate. - * - * @param g the g - * @param dupeInfoList the dupe info string - * @param logger the EELFLogger - * @return the boolean - */ - private static Boolean deleteNonKeepers(Graph g, - ArrayList<String> dupeInfoList, EELFLogger logger ) { - - // This assumes that each dupeInfoString is in the format of - // pipe-delimited vid's followed by either "keepVid=xyz" or "keepVid=UNDETERMINED" - // ie. "3456|9880|keepVid=3456" - - boolean didADelFlag = false; - for( int n = 0; n < dupeInfoList.size(); n++ ){ - String dupeInfoString = dupeInfoList.get(n); - boolean tmpFlag = deleteNonKeeperForOneSet( g, dupeInfoString, logger ); - didADelFlag = tmpFlag || didADelFlag; - } - - return didADelFlag; - - }// end of deleteNonKeepers() - - - /** - * Delete non keepers if appropriate. - * - * @param g the g - * @param dupeInfoString the dupe string - * @param logger the EELFLogger - * @return the boolean - */ - private static Boolean deleteNonKeeperForOneSet(Graph g, - String dupeInfoString, EELFLogger logger ) { - - Boolean deletedSomething = false; - // This assumes that each dupeInfoString is in the format of - // pipe-delimited vid's followed by either "keepVid=xyz" or "keepVid=UNDETERMINED" - // ie. "3456|9880|keepVid=3456" - - - String[] dupeArr = dupeInfoString.split("\\|"); - ArrayList<String> idArr = new ArrayList<String>(); - int lastIndex = dupeArr.length - 1; - for (int i = 0; i <= lastIndex; i++) { - if (i < lastIndex) { - // This is not the last entry, it is one of the dupes, - String vidString = dupeArr[i]; - idArr.add(vidString); - continue; - } - - // This is the last entry which should tell us if we have a - // preferred keeper - String prefString = dupeArr[i]; - if ("KeepVid=UNDETERMINED".equals(prefString)) { - // They sent us a bad string -- nothing should be deleted if - // no dupe could be tagged as preferred. - return false; - } - // If we know which to keep, then the prefString should look - // like, "KeepVid=12345" - String[] prefArr = prefString.split("="); - if (prefArr.length != 2 || !KEEP_VID.equals(prefArr[0])) { - String emsg = "Bad format. Expecting KeepVid=999999"; - System.out.println(emsg); - LoggingContext.statusCode(StatusCode.ERROR); - LoggingContext.responseCode(LoggingContext.DATA_ERROR); - logger.error(emsg); - LoggingContext.statusCode(StatusCode.COMPLETE); - LoggingContext.responseCode(LoggingContext.SUCCESS); - return false; - } - - String keepVidStr = prefArr[1]; - if (idArr.contains(keepVidStr)) { - idArr.remove(keepVidStr); - // So now, the idArr should just contain the vid's - // that we want to remove. - for (int x = 0; x < idArr.size(); x++) { - boolean okFlag = true; - String thisVid = idArr.get(x); - try { - long longVertId = Long.parseLong(thisVid); - Vertex vtx = g.traversal().V(longVertId).next(); - String msg = "--->>> We will delete node with VID = " + thisVid + " <<<---"; - System.out.println(msg); - logger.info(msg); - vtx.remove(); - } - catch (Exception e) { - okFlag = false; - String emsg = "ERROR trying to delete VID = " + thisVid + ", [" + e + "]"; - System.out.println(emsg); - LoggingContext.statusCode(StatusCode.ERROR); - LoggingContext.responseCode(LoggingContext.DATA_ERROR); - logger.error(emsg); - LoggingContext.statusCode(StatusCode.COMPLETE); - LoggingContext.responseCode(LoggingContext.SUCCESS); - } - if (okFlag) { - String infMsg = " DELETED VID = " + thisVid; - logger.info(infMsg); - System.out.println(infMsg); - deletedSomething = true; - } - } - } else { - String emsg = "ERROR - Vertex Id to keep not found in list of dupes. dupeInfoString = [" - + dupeInfoString + "]"; - LoggingContext.statusCode(StatusCode.ERROR); - LoggingContext.responseCode(LoggingContext.DATA_ERROR); - logger.error(emsg); - LoggingContext.statusCode(StatusCode.COMPLETE); - LoggingContext.responseCode(LoggingContext.SUCCESS); - System.out.println(emsg); - return false; - } - - }// for each vertex in a group - - return deletedSomething; - - }// end of deleteNonKeeperForOneSet() - - - /** - * Get values of the key properties for a node. - * - * @param tvx the vertex to pull the properties from - * @param keyPropNamesArr ArrayList (ordered) of key prop names - * @param logger the EELFLogger - * @return a hashMap of the propertyNames/values - */ - private static HashMap <String,Object> getNodeKeyVals( Vertex tvx, - ArrayList <String> keyPropNamesArr, EELFLogger logger ) { - - HashMap <String,Object> retHash = new HashMap <String,Object>(); - Iterator <String> propItr = keyPropNamesArr.iterator(); - while( propItr.hasNext() ){ - String propName = propItr.next(); - if( tvx != null ){ - Object propValObj = tvx.property(propName).orElse(null); - retHash.put(propName, propValObj); - } - } - return retHash; - - }// End of getNodeKeyVals() - - - /** - * Get values of the key properties for a node as a single string - * - * @param tvx the vertex to pull the properties from - * @param keyPropNamesArr collection of key prop names - * @param logger the EELFLogger - * @return a String of concatenated values - */ - private static String getNodeKeyValString( Vertex tvx, - ArrayList <String> keyPropNamesArr, EELFLogger logger ) { - - // -- NOTE -- for what we're using this for, we would need to - // guarantee that the properties are always in the same order - - String retString = ""; - Iterator <String> propItr = keyPropNamesArr.iterator(); - while( propItr.hasNext() ){ - String propName = propItr.next(); - if( tvx != null ){ - Object propValObj = tvx.property(propName).orElse(null); - retString = " " + retString + propValObj.toString(); - } - } - return retString; - - }// End of getNodeKeyValString() - - - /** - * Find duplicate sets from two dupe runs. - * - * @param firstPassDupeSets from the first pass - * @param secondPassDupeSets from the second pass - * @param logger logger - * @return commonDupeSets that are common to both passes and have a determined keeper - */ - private static ArrayList <String> figureWhichDupesStillNeedFixing( ArrayList <String>firstPassDupeSets, - ArrayList <String> secondPassDupeSets, EELFLogger logger ){ - - ArrayList <String> common2BothSet = new ArrayList <String> (); - - // We just want to look for entries from the first set which have identical (almost) - // entries in the secondary set. I say "almost" because the order of the - // vid's to delete may be in a different order, but we only want to use it if - // they have all the same values. Note also - we're just looking for - // the sets where we have a candidate to delete. - - // The duplicate-set Strings are in this format: - // "1234|5678|keepVid=UNDETERMINED" (if there were 2 dupes, and we - // couldn't figure out which one to keep) - // or, "100017|200027|30037|keepVid=30037" (if there were 3 dupes and we - // thought the third one was the one that should survive) - - if( firstPassDupeSets == null || firstPassDupeSets.isEmpty() - || secondPassDupeSets == null || secondPassDupeSets.isEmpty() ){ - // If either set is empty, then our return list has to be empty too - return common2BothSet; - } - - boolean needToParse = false; - for( int x = 0; x < secondPassDupeSets.size(); x++ ){ - String secPassDupeSetStr = secondPassDupeSets.get(x); - if( secPassDupeSetStr.endsWith("UNDETERMINED") ){ - // This is a set of dupes where we could not pick one - // to delete - so don't include it on our list for - // fixing. - } - else if( firstPassDupeSets.contains(secPassDupeSetStr) ){ - // We have lucked out and do not even need to parse this since - // it was in the other array with any dupes listed in the same order - // This is actually the most common scenario since there is - // usually only one dupe, so order doesn't matter. - common2BothSet.add(secPassDupeSetStr); - } - else { - // We'll need to do some parsing to check this one - needToParse = true; - } - } - - if( needToParse ){ - // Make a hash from the first and second Pass data - // where the key is the vid to KEEP and the value is an - // array of (String) vids that would get deleted. - HashMap <String,ArrayList<String>> firstPassHash = makeKeeperHashOfDupeStrings( firstPassDupeSets, common2BothSet, logger ); - - HashMap <String,ArrayList<String>> secPassHash = makeKeeperHashOfDupeStrings( secondPassDupeSets, common2BothSet, logger ); - - // Loop through the secondPass data and keep the ones - // that check out against the firstPass set. - for( Map.Entry<String, ArrayList<String>> entry : secPassHash.entrySet() ){ - boolean skipThisOne = false; - String secKey = entry.getKey(); - ArrayList <String> secList = entry.getValue(); - if( !firstPassHash.containsKey(secKey) ){ - // The second pass found this delete candidate, but not the first pass - skipThisOne = true; - } - else { - // They both think they should keep this VID, check the associated deletes for it. - ArrayList <String> firstList = firstPassHash.get(secKey); - for( int z = 0; z < secList.size(); z++ ){ - if( !firstList.contains(secList.get(z)) ){ - // The first pass did not think this needed to be deleted - skipThisOne = true; - } - } - } - if( skipThisOne ) { - continue; - } - - // Put the string back together and pass it back - // Not beautiful, but no time to make it nice right now... - // Put it back in the format: "3456|9880|keepVid=3456" - String thisDelSetStr = ""; - for( int z = 0; z < secList.size(); z++ ){ - if( z == 0 ){ - thisDelSetStr = secList.get(z); - } - else { - thisDelSetStr = thisDelSetStr + "|" + secList.get(z); - } - } - thisDelSetStr = thisDelSetStr + "|keepVid=" + secKey; - common2BothSet.add(thisDelSetStr); - } - } - return common2BothSet; - - }// figureWhichDupesStillNeedFixing - - - private static HashMap <String, ArrayList <String>> makeKeeperHashOfDupeStrings( ArrayList <String> dupeSets, - ArrayList <String> excludeSets, EELFLogger logger ){ - - HashMap <String,ArrayList<String>> keeperHash = new HashMap <String, ArrayList<String>>(); - - for( int x = 0; x < dupeSets.size(); x++ ){ - String tmpSetStr = dupeSets.get(x); - if( excludeSets.contains(tmpSetStr) ){ - // This isn't one of the ones we needed to parse. - continue; - } - - String[] dupeArr = tmpSetStr.split("\\|"); - ArrayList<String> delIdArr = new ArrayList<String>(); - int lastIndex = dupeArr.length - 1; - for (int i = 0; i <= lastIndex; i++) { - if (i < lastIndex) { - // This is not the last entry, it is one of the dupes - delIdArr.add(dupeArr[i]); - continue; - } - - // This is the last entry which should tell us if we - // have a preferred keeper and how many dupes we had - String prefString = dupeArr[i]; - if( i == 1 ){ - // There was only one dupe, so if we were gonna find - // it, we would have found it above with no parsing. - } - else if ("KeepVid=UNDETERMINED".equals(prefString)) { - // This one had no determined keeper, so we don't - // want it. - } - else { - // If we know which to keep, then the prefString - // should look like, "KeepVid=12345" - String[] prefArr = prefString.split("="); - if( prefArr.length != 2 || !KEEP_VID.equals(prefArr[0]) ) { - String infMsg = "Bad format in figureWhichDupesStillNeedFixing(). Expecting " + - " KeepVid=999999 but string looks like: [" + tmpSetStr + "]"; - System.out.println(infMsg); - logger.info(infMsg); - } - else { - keeperHash.put(prefArr[0], delIdArr); - } - } - - } - } - - return keeperHash; - - }// End makeHashOfDupeStrings() - - - /** - * Get values of the key properties for a node. - * - * @param g the g - * @param dupeInfoString - * @param logger the EELFLogger - * @return void - */ - static private void showNodeDetailsForADupeSet(Graph g, String dupeInfoString, EELFLogger logger) { - - // dang... parsing this string once again... - - String[] dupeArr = dupeInfoString.split("\\|"); - int lastIndex = dupeArr.length - 1; - for (int i = 0; i <= lastIndex; i++) { - if (i < lastIndex) { - // This is not the last entry, it is one of the dupes, - String vidString = dupeArr[i]; - long longVertId = Long.parseLong(vidString); - Vertex vtx = g.traversal().V(longVertId).next(); - showNodeInfo(logger, vtx, false); - } else { - // This is the last entry which should tell us if we have a - // preferred keeper - String prefString = dupeArr[i]; - if (prefString.equals("KeepVid=UNDETERMINED")) { - String msg = " Our algorithm cannot choose from among these, so they will all be kept. -------\n"; - System.out.println(msg); - logger.info(msg); - } else { - // If we know which to keep, then the prefString should look - // like, "KeepVid=12345" - String[] prefArr = prefString.split("="); - if (prefArr.length != 2 || (!prefArr[0].equals(KEEP_VID))) { - String emsg = "Bad format. Expecting KeepVid=999999"; - System.out.println(emsg); - LoggingContext.statusCode(StatusCode.ERROR); - LoggingContext.responseCode(LoggingContext.DATA_ERROR); - logger.error(emsg); - LoggingContext.statusCode(StatusCode.COMPLETE); - LoggingContext.responseCode(LoggingContext.SUCCESS); - } else { - String keepVidStr = prefArr[1]; - String msg = " vid = " + keepVidStr + " is the one that we would KEEP. ------\n"; - System.out.println(msg); - logger.info(msg); - } - } - } - } - - }// End of showNodeDetailsForADupeSet() - - private static int graphIndex = 1; - - public static JanusGraph setupGraph(EELFLogger logger){ - - JanusGraph janusGraph = null; - - - try (InputStream inputStream = new FileInputStream(AAIConstants.REALTIME_DB_CONFIG);){ - - Properties properties = new Properties(); - properties.load(inputStream); - - if(INMEMORY.equals(properties.get("storage.backend"))){ - janusGraph = AAIGraph.getInstance().getGraph(); - graphType = INMEMORY; - } else { - janusGraph = JanusGraphFactory.open(new AAIGraphConfig.Builder(AAIConstants.REALTIME_DB_CONFIG).forService(DupeTool.class.getSimpleName()).withGraphType("realtime" + graphIndex).buildConfiguration()); - graphIndex++; - } - } catch (Exception e) { - logger.error("Unable to open the graph", LogFormatTools.getStackTop(e)); - } - - return janusGraph; - } - - public static void closeGraph(JanusGraph graph, EELFLogger logger){ - - try { - if(INMEMORY.equals(graphType)) { - return; - } - if( graph != null && graph.isOpen() ){ - graph.tx().close(); - graph.close(); - } - } catch (Exception ex) { - // Don't throw anything because JanusGraph sometimes is just saying that the graph is already closed{ - logger.warn("WARNING from final graph.shutdown()", ex); - } - } -} - - diff --git a/aai-resources/src/main/java/org/onap/aai/dbgen/ForceDeleteTool.java b/aai-resources/src/main/java/org/onap/aai/dbgen/ForceDeleteTool.java deleted file mode 100644 index 42d401b..0000000 --- a/aai-resources/src/main/java/org/onap/aai/dbgen/ForceDeleteTool.java +++ /dev/null @@ -1,864 +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.dbgen; -import java.io.FileInputStream; -import java.io.InputStream; -import java.util.ArrayList; -import java.util.Iterator; -import java.util.Properties; -import java.util.Scanner; -import java.util.UUID; - -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.Direction; -import org.apache.tinkerpop.gremlin.structure.Edge; -import org.apache.tinkerpop.gremlin.structure.Vertex; -import org.apache.tinkerpop.gremlin.structure.VertexProperty; -import org.onap.aai.dbmap.AAIGraphConfig; -import org.onap.aai.dbmap.AAIGraph; -import org.onap.aai.exceptions.AAIException; -import org.onap.aai.logging.LogFormatTools; -import org.onap.aai.logging.LoggingContext; -import org.onap.aai.logging.LoggingContext.StatusCode; -import org.onap.aai.serialization.db.AAIDirection; -import org.onap.aai.serialization.db.EdgeProperty; -import org.onap.aai.util.AAIConfig; -import org.onap.aai.util.AAIConstants; -import org.slf4j.MDC; - -import com.att.eelf.configuration.Configuration; -import com.att.eelf.configuration.EELFLogger; -import com.att.eelf.configuration.EELFManager; -import org.janusgraph.core.JanusGraphFactory; -import org.janusgraph.core.JanusGraph; - - - -public class ForceDeleteTool { - private static final String FROMAPPID = "AAI-DB"; - private static final String TRANSID = UUID.randomUUID().toString(); - private static final String DELETE_NODE = "DELETE_NODE"; - private static final String DELETE_EDGE = "DELETE_EDGE"; - private static String graphType = "realdb"; - private static String FOUND_VERTEX_ID_ = ">>> Found Vertex with VertexId = "; - private static String PROPERTIES_ = ", properties: "; - private static String INMEMORY = "inmemory"; - - public static boolean SHOULD_EXIT_VM = true; - - public static int EXIT_VM_STATUS_CODE = -1; - - public static void exit(int statusCode){ - if(SHOULD_EXIT_VM){ - System.exit(1); - } - EXIT_VM_STATUS_CODE = statusCode; - } - - /* - * The main method. - * - * @param args the arguments - */ - public static void main(String[] args) { - - //SWGK 01/21/2016 - To suppress the warning message when the tool is run from the Terminal. - - System.setProperty("aai.service.name", ForceDelete.class.getSimpleName()); - // Set the logging file properties to be used by EELFManager - Properties props = System.getProperties(); - props.setProperty(Configuration.PROPERTY_LOGGING_FILE_NAME, "forceDelete-logback.xml"); - props.setProperty(Configuration.PROPERTY_LOGGING_FILE_PATH, AAIConstants.AAI_HOME_ETC_APP_PROPERTIES); - EELFLogger logger = EELFManager.getInstance().getLogger(ForceDeleteTool.class.getSimpleName()); - MDC.put("logFilenameAppender", ForceDeleteTool.class.getSimpleName()); - - LoggingContext.init(); - LoggingContext.partnerName(FROMAPPID); - LoggingContext.serviceName(AAIConstants.AAI_RESOURCES_MS); - LoggingContext.component("forceDeleteTool"); - LoggingContext.targetEntity(AAIConstants.AAI_RESOURCES_MS); - LoggingContext.targetServiceName("main"); - LoggingContext.requestId(TRANSID); - LoggingContext.statusCode(StatusCode.COMPLETE); - LoggingContext.responseCode(LoggingContext.SUCCESS); - - String actionVal = ""; - String userIdVal = ""; - String dataString = ""; - Boolean displayAllVidsFlag = false; // Note - This should rarely be needed - Boolean overRideProtection = false; // This should rarely be used - it overrides all our new checking - long vertexIdLong = 0; - String edgeIdStr = ""; - String argStr4Msg = ""; - - if (args != null && args.length > 0) { - // They passed some arguments in that will affect processing - for (int i = 0; i < args.length; i++) { - String thisArg = args[i]; - argStr4Msg = argStr4Msg + " " + thisArg; - - if (thisArg.equals("-action")) { - i++; - if (i >= args.length) { - LoggingContext.statusCode(StatusCode.ERROR); - LoggingContext.responseCode(LoggingContext.BUSINESS_PROCESS_ERROR); - logger.error(" No value passed with -action option. "); - exit(0); - } - actionVal = args[i]; - argStr4Msg = argStr4Msg + " " + actionVal; - } - else if ("-userId".equals(thisArg)) { - i++; - if (i >= args.length) { - LoggingContext.statusCode(StatusCode.ERROR); - LoggingContext.responseCode(LoggingContext.BUSINESS_PROCESS_ERROR); - logger.error(" No value passed with -userId option. "); - exit(0); - } - userIdVal = args[i]; - argStr4Msg = argStr4Msg + " " + userIdVal; - } - else if ("-overRideProtection".equals(thisArg)) { - overRideProtection = true; - } - else if ("-DISPLAY_ALL_VIDS".equals(thisArg)) { - displayAllVidsFlag = true; - } - else if ("-vertexId".equals(thisArg)) { - i++; - if (i >= args.length) { - LoggingContext.statusCode(StatusCode.ERROR); - LoggingContext.responseCode(LoggingContext.BUSINESS_PROCESS_ERROR); - logger.error(" No value passed with -vertexId option. "); - exit(0); - } - String nextArg = args[i]; - argStr4Msg = argStr4Msg + " " + nextArg; - try { - vertexIdLong = Long.parseLong(nextArg); - } catch (Exception e) { - LoggingContext.statusCode(StatusCode.ERROR); - LoggingContext.responseCode(LoggingContext.BUSINESS_PROCESS_ERROR); - logger.error("Bad value passed with -vertexId option: [" - + nextArg + "]"); - exit(0); - } - } - else if ("-params4Collect".equals(thisArg)) { - i++; - if (i >= args.length) { - LoggingContext.statusCode(StatusCode.ERROR); - LoggingContext.responseCode(LoggingContext.BUSINESS_PROCESS_ERROR); - logger.error(" No value passed with -params4Collect option. "); - exit(0); - } - dataString = args[i]; - argStr4Msg = argStr4Msg + " " + dataString; - } - else if ("-edgeId".equals(thisArg)) { - i++; - if (i >= args.length) { - LoggingContext.statusCode(StatusCode.ERROR); - LoggingContext.responseCode(LoggingContext.BUSINESS_PROCESS_ERROR); - logger.error(" No value passed with -edgeId option. "); - exit(0); - } - String nextArg = args[i]; - argStr4Msg = argStr4Msg + " " + nextArg; - edgeIdStr = nextArg; - } - else { - LoggingContext.statusCode(StatusCode.ERROR); - LoggingContext.responseCode(LoggingContext.BUSINESS_PROCESS_ERROR); - logger.error(" Unrecognized argument passed to ForceDeleteTool: [" - + thisArg + "]. "); - logger.error(" Valid values are: -action -userId -vertexId -edgeId -overRideProtection -params4Collect -DISPLAY_ALL_VIDS"); - exit(0); - } - } - } - - if( !"COLLECT_DATA".equals(actionVal) && !DELETE_NODE.equals(actionVal) && !DELETE_EDGE.equals(actionVal)){ - String emsg = "Bad action parameter [" + actionVal + "] passed to ForceDeleteTool(). Valid values = COLLECT_DATA or DELETE_NODE or DELETE_EDGE\n"; - System.out.println(emsg); - LoggingContext.statusCode(StatusCode.ERROR); - LoggingContext.responseCode(LoggingContext.BUSINESS_PROCESS_ERROR); - logger.error(emsg); - exit(0); - } - - if( DELETE_NODE.equals(actionVal) && vertexIdLong == 0 ){ - String emsg = "ERROR: No vertex ID passed on DELETE_NODE request. \n"; - System.out.println(emsg); - LoggingContext.statusCode(StatusCode.ERROR); - LoggingContext.responseCode(LoggingContext.BUSINESS_PROCESS_ERROR); - logger.error(emsg); - exit(0); - } - else if( DELETE_EDGE.equals(actionVal) && edgeIdStr.isEmpty()){ - String emsg = "ERROR: No edge ID passed on DELETE_EDGE request. \n"; - System.out.println(emsg); - LoggingContext.statusCode(StatusCode.ERROR); - LoggingContext.responseCode(LoggingContext.BUSINESS_PROCESS_ERROR); - logger.error(emsg); - exit(0); - } - - - userIdVal = userIdVal.trim(); - if( (userIdVal.length() < 6) || "AAIADMIN".equalsIgnoreCase(userIdVal) ){ - String emsg = "Bad userId parameter [" + userIdVal + "] passed to ForceDeleteTool(). must be not empty and not aaiadmin \n"; - System.out.println(emsg); - LoggingContext.statusCode(StatusCode.ERROR); - LoggingContext.responseCode(LoggingContext.BUSINESS_PROCESS_ERROR); - logger.error(emsg); - exit(0); - } - - String msg = ""; - JanusGraph graph = null; - try { - AAIConfig.init(); - System.out.println(" ---- NOTE --- about to open graph (takes a little while)--------\n"); - graph = setupGraph(logger); - if( graph == null ){ - String emsg = "could not get graph object in ForceDeleteTool() \n"; - System.out.println(emsg); - LoggingContext.statusCode(StatusCode.ERROR); - LoggingContext.responseCode(LoggingContext.AVAILABILITY_TIMEOUT_ERROR); - logger.error(emsg); - exit(0); - } - } - catch (AAIException e1) { - msg = e1.getErrorObject().toString(); - System.out.println(msg); - LoggingContext.statusCode(StatusCode.ERROR); - LoggingContext.responseCode(LoggingContext.UNKNOWN_ERROR); - logger.error(msg); - exit(0); - } - catch (Exception e2) { - msg = e2.toString(); - System.out.println(msg); - LoggingContext.statusCode(StatusCode.ERROR); - LoggingContext.responseCode(LoggingContext.UNKNOWN_ERROR); - logger.error(msg); - exit(0); - } - - msg = "ForceDelete called by: userId [" + userIdVal + "] with these params: [" + argStr4Msg + "]"; - System.out.println(msg); - logger.info(msg); - - ForceDelete fd = new ForceDelete(graph); - if( "COLLECT_DATA".equals(actionVal) ){ - // When doing COLLECT_DATA, we expect the dataString string to be comma separated - // name value pairs like this: - // "propName1|propVal1,propName2|propVal2" etc. We will look for a node or nodes - // that have properties that ALL match what was passed in. - - int resCount = 0; - int firstPipeLoc = dataString.indexOf("|"); - if( firstPipeLoc <= 0 ){ - msg = "Must use the -params4Collect option when collecting data with data string in a format like: 'propName1|propVal1,propName2|propVal2'"; - System.out.println(msg); - LoggingContext.statusCode(StatusCode.ERROR); - LoggingContext.responseCode(LoggingContext.BUSINESS_PROCESS_ERROR); - logger.error(msg); - exit(0); - } - GraphTraversal<Vertex, Vertex> g = null; - String qStringForMsg = null; - if (graph != null) { - g = graph.traversal().V(); - qStringForMsg = " graph.traversal().V()"; - // Note - if they're only passing on parameter, there won't be any commas - String[] paramArr = dataString.split(","); - for (int i = 0; i < paramArr.length; i++) { - int pipeLoc = paramArr[i].indexOf("|"); - if (pipeLoc <= 0) { - msg = "Must use the -params4Collect option when collecting data with data string in a format like: 'propName1|propVal1,propName2|propVal2'"; - System.out.println(msg); - LoggingContext.statusCode(StatusCode.ERROR); - LoggingContext.responseCode(LoggingContext.BUSINESS_PROCESS_ERROR); - logger.error(msg); - exit(0); - } else { - String propName = paramArr[i].substring(0, pipeLoc); - String propVal = paramArr[i].substring(pipeLoc + 1); - g = g.has(propName, propVal); - qStringForMsg = qStringForMsg + ".has(" + propName + "," + propVal + ")"; - } - } - } - if( (g != null)){ - Iterator<Vertex> vertItor = g; - while( vertItor.hasNext() ){ - resCount++; - Vertex v = vertItor.next(); - fd.showNodeInfo( logger, v, displayAllVidsFlag ); - int descendantCount = fd.countDescendants( logger, v, 0 ); - String infMsg = " Found " + descendantCount + " descendant nodes \n"; - System.out.println( infMsg ); - logger.info( infMsg ); - } - } - else { - msg = "Bad JanusGraphQuery object. "; - System.out.println(msg); - LoggingContext.statusCode(StatusCode.ERROR); - LoggingContext.responseCode(LoggingContext.DATA_ERROR); - logger.error(msg); - exit(0); - } - - String infMsg = "\n\n Found: " + resCount + " nodes for this query: [" + qStringForMsg + "]\n"; - System.out.println( infMsg ); - logger.info( infMsg ); - } - else if( DELETE_NODE.equals(actionVal) ){ - Iterator <Vertex> vtxItr = graph.vertices( vertexIdLong ); - if( vtxItr != null && vtxItr.hasNext() ) { - Vertex vtx = vtxItr.next(); - fd.showNodeInfo( logger, vtx, displayAllVidsFlag ); - int descendantCount = fd.countDescendants( logger, vtx, 0 ); - String infMsg = " Found " + descendantCount + " descendant nodes. Note - forceDelete does not cascade to " + - " child nodes, but they may become unreachable after the delete. \n"; - System.out.println( infMsg ); - logger.info( infMsg ); - - int edgeCount = fd.countEdges( logger, vtx ); - - infMsg = " Found total of " + edgeCount + " edges incident on this node. \n"; - System.out.println( infMsg ); - logger.info( infMsg ); - - if( fd.getNodeDelConfirmation(logger, userIdVal, vtx, descendantCount, edgeCount, overRideProtection) ){ - vtx.remove(); - graph.tx().commit(); - infMsg = ">>>>>>>>>> Removed node with vertexId = " + vertexIdLong; - logger.info( infMsg ); - System.out.println(infMsg); - } - else { - infMsg = " Delete Cancelled. "; - System.out.println(infMsg); - logger.info( infMsg ); - } - } - else { - String infMsg = ">>>>>>>>>> Vertex with vertexId = " + vertexIdLong + " not found."; - System.out.println( infMsg ); - logger.info( infMsg ); - } - } - else if( DELETE_EDGE.equals(actionVal) ){ - Edge thisEdge = null; - Iterator <Edge> edItr = graph.edges( edgeIdStr ); - if( edItr != null && edItr.hasNext() ) { - thisEdge = edItr.next(); - } - - if( thisEdge == null ){ - String infMsg = ">>>>>>>>>> Edge with edgeId = " + edgeIdStr + " not found."; - logger.info( infMsg ); - System.out.println(infMsg); - exit(0); - } - - if( fd.getEdgeDelConfirmation(logger, userIdVal, thisEdge, overRideProtection) ){ - thisEdge.remove(); - graph.tx().commit(); - String infMsg = ">>>>>>>>>> Removed edge with edgeId = " + edgeIdStr; - logger.info( infMsg ); - System.out.println(infMsg); - } - else { - String infMsg = " Delete Cancelled. "; - System.out.println(infMsg); - logger.info( infMsg ); - } - exit(0); - } - else { - String emsg = "Unknown action parameter [" + actionVal + "] passed to ForceDeleteTool(). Valid values = COLLECT_DATA, DELETE_NODE or DELETE_EDGE \n"; - System.out.println(emsg); - logger.info( emsg ); - exit(0); - } - - closeGraph(graph, logger); - exit(0); - - }// end of main() - - public static class ForceDelete { - - private final int MAXDESCENDENTDEPTH = 15; - private final JanusGraph graph; - public ForceDelete(JanusGraph graph) { - this.graph = graph; - } - public void showNodeInfo(EELFLogger logger, Vertex tVert, Boolean displayAllVidsFlag ){ - - try { - Iterator<VertexProperty<Object>> pI = tVert.properties(); - String infStr = FOUND_VERTEX_ID_ + tVert.id() + PROPERTIES_; - System.out.println( infStr ); - logger.info(infStr); - while( pI.hasNext() ){ - VertexProperty<Object> tp = pI.next(); - infStr = " [" + tp.key() + "|" + tp.value() + "] "; - System.out.println( infStr ); - logger.info(infStr); - } - - ArrayList <String> retArr = collectEdgeInfoForNode( logger, tVert, displayAllVidsFlag ); - for( String infoStr : retArr ){ - System.out.println( infoStr ); - logger.info(infoStr); - } - } - catch (Exception e){ - String warnMsg = " -- Error -- trying to display edge info. [" + e.getMessage() + "]"; - System.out.println( warnMsg ); - LoggingContext.statusCode(StatusCode.ERROR); - LoggingContext.responseCode(LoggingContext.DATA_ERROR); - logger.warn(warnMsg); - LoggingContext.successStatusFields(); - } - - }// End of showNodeInfo() - - - public void showPropertiesForEdge( EELFLogger logger, Edge tEd ){ - String infMsg = ""; - if( tEd == null ){ - infMsg = "null Edge object passed to showPropertiesForEdge()"; - System.out.print(infMsg); - logger.info(infMsg); - return; - } - - // Try to show the edge properties - try { - infMsg =" Label for this Edge = [" + tEd.label() + "] "; - System.out.print(infMsg); - logger.info(infMsg); - - infMsg =" EDGE Properties for edgeId = " + tEd.id() + ": "; - System.out.print(infMsg); - logger.info(infMsg); - Iterator <String> pI = tEd.keys().iterator(); - while( pI.hasNext() ){ - String propKey = pI.next(); - infMsg = "Prop: [" + propKey + "], val = [" - + tEd.property(propKey) + "] "; - System.out.print(infMsg); - logger.info(infMsg); - } - } - catch( Exception ex ){ - infMsg = " Could not retrieve properties for this edge. exMsg = [" - + ex.getMessage() + "] "; - System.out.println( infMsg ); - logger.info(infMsg); - } - - // Try to show what's connected to the IN side of this Edge - try { - infMsg = " Looking for the Vertex on the IN side of the edge: "; - System.out.print(infMsg); - logger.info(infMsg); - Vertex inVtx = tEd.inVertex(); - Iterator<VertexProperty<Object>> pI = inVtx.properties(); - String infStr = FOUND_VERTEX_ID_ + inVtx.id() - + PROPERTIES_; - System.out.println( infStr ); - logger.info(infStr); - while( pI.hasNext() ){ - VertexProperty<Object> tp = pI.next(); - infStr = " [" + tp.key() + "|" + tp.value() + "] "; - System.out.println( infStr ); - logger.info(infStr); - } - } - catch( Exception ex ){ - infMsg = " Could not retrieve vertex data for the IN side of " - + "the edge. exMsg = [" + ex.getMessage() + "] "; - System.out.println( infMsg ); - logger.info(infMsg); - } - - // Try to show what's connected to the OUT side of this Edge - try { - infMsg = " Looking for the Vertex on the OUT side of the edge: "; - System.out.print(infMsg); - logger.info(infMsg); - Vertex outVtx = tEd.outVertex(); - Iterator<VertexProperty<Object>> pI = outVtx.properties(); - String infStr = FOUND_VERTEX_ID_ + outVtx.id() - + PROPERTIES_; - System.out.println( infStr ); - logger.info(infStr); - while( pI.hasNext() ){ - VertexProperty<Object> tp = pI.next(); - infStr = " [" + tp.key() + "|" + tp.value() + "] "; - System.out.println( infStr ); - logger.info(infStr); - } - } - catch( Exception ex ){ - infMsg = " Could not retrieve vertex data for the OUT side of " - + "the edge. exMsg = [" + ex.getMessage() + "] "; - System.out.println( infMsg ); - logger.info(infMsg); - } - - }// end showPropertiesForEdge() - - - - public ArrayList <String> collectEdgeInfoForNode( EELFLogger logger, Vertex tVert, boolean displayAllVidsFlag ){ - ArrayList <String> retArr = new ArrayList <String> (); - Direction dir = Direction.OUT; - for ( int i = 0; i <= 1; i++ ){ - if( i == 1 ){ - // Second time through we'll look at the IN edges. - dir = Direction.IN; - } - Iterator <Edge> eI = tVert.edges(dir); - if( ! eI.hasNext() ){ - retArr.add("No " + dir + " edges were found for this vertex. "); - } - while( eI.hasNext() ){ - Edge ed = eI.next(); - String lab = ed.label(); - Vertex vtx = null; - if( dir == Direction.OUT ){ - // get the vtx on the "other" side - vtx = ed.inVertex(); - } - else { - // get the vtx on the "other" side - vtx = ed.outVertex(); - } - if( vtx == null ){ - retArr.add(" >>> COULD NOT FIND VERTEX on the other side of this edge edgeId = " + ed.id() + " <<< "); - continue; - } - - String nType = vtx.<String>property("aai-node-type").orElse(null); - if( displayAllVidsFlag ){ - // This should rarely be needed - String vid = vtx.id().toString(); - retArr.add("Found an " + dir + " edge (" + lab + ") between this vertex and a [" + nType + "] node with VtxId = " + vid ); - } - else { - // This is the normal case - retArr.add("Found an " + dir + " edge (" + lab + ") between this vertex and a [" + nType + "] node. "); - } - } - } - return retArr; - - }// end of collectEdgeInfoForNode() - - - public int countEdges( EELFLogger logger, Vertex vtx ){ - int edgeCount = 0; - try { - Iterator<Edge> edgesItr = vtx.edges(Direction.BOTH); - while( edgesItr.hasNext() ){ - edgesItr.next(); - edgeCount++; - } - } - catch (Exception e) { - String wMsg = "-- ERROR -- Stopping the counting of edges because of Exception [" + e.getMessage() + "]"; - System.out.println( wMsg ); - LoggingContext.statusCode(StatusCode.ERROR); - LoggingContext.responseCode(LoggingContext.DATA_ERROR); - logger.warn( wMsg ); - LoggingContext.successStatusFields(); - } - return edgeCount; - - }// end of countEdges() - - - public int countDescendants(EELFLogger logger, Vertex vtx, int levelVal ){ - int totalCount = 0; - int thisLevel = levelVal + 1; - - if( thisLevel > MAXDESCENDENTDEPTH ){ - String wMsg = "Warning -- Stopping the counting of descendents because we reached the max depth of " + MAXDESCENDENTDEPTH; - System.out.println( wMsg ); - LoggingContext.statusCode(StatusCode.ERROR); - LoggingContext.responseCode(LoggingContext.DATA_ERROR); - logger.warn( wMsg ); - return totalCount; - } - - try { - Iterator <Vertex> vertI = graph.traversal().V(vtx).union(__.outE().has(EdgeProperty.CONTAINS.toString(), AAIDirection.OUT.toString()).inV(), __.inE().has(EdgeProperty.CONTAINS.toString(), AAIDirection.IN.toString()).outV()); - while( vertI != null && vertI.hasNext() ){ - totalCount++; - Vertex childVtx = vertI.next(); - totalCount = totalCount + countDescendants( logger, childVtx, thisLevel ); - } - } - catch (Exception e) { - String wMsg = "Error -- Stopping the counting of descendents because of Exception [" + e.getMessage() + "]"; - System.out.println( wMsg ); - LoggingContext.statusCode(StatusCode.ERROR); - LoggingContext.responseCode(LoggingContext.DATA_ERROR); - logger.warn( wMsg ); - LoggingContext.successStatusFields(); - - } - - return totalCount; - }// end of countDescendants() - - - public boolean getEdgeDelConfirmation( EELFLogger logger, String uid, Edge ed, - Boolean overRideProtection ) { - - showPropertiesForEdge( logger, ed ); - System.out.print("\n Are you sure you want to delete this EDGE? (y/n): "); - Scanner s = new Scanner(System.in); - s.useDelimiter(""); - String confirm = s.next(); - s.close(); - - if (!"y".equalsIgnoreCase(confirm)) { - String infMsg = " User [" + uid + "] has chosen to abandon this delete request. "; - System.out.println("\n" + infMsg); - logger.info(infMsg); - return false; - } - else { - String infMsg = " User [" + uid + "] has confirmed this delete request. "; - System.out.println("\n" + infMsg); - logger.info(infMsg); - return true; - } - - } // End of getEdgeDelConfirmation() - - - public boolean getNodeDelConfirmation( EELFLogger logger, String uid, Vertex vtx, int edgeCount, - int descendantCount, Boolean overRideProtection ) { - String thisNodeType = ""; - try { - thisNodeType = vtx.<String>property("aai-node-type").orElse(null); - } - catch ( Exception nfe ){ - // Let the user know something is going on - but they can confirm the delete if they want to. - String infMsg = " -- WARNING -- could not get an aai-node-type for this vertex. -- WARNING -- "; - System.out.println( infMsg ); - LoggingContext.statusCode(StatusCode.ERROR); - LoggingContext.responseCode(LoggingContext.DATA_ERROR); - logger.warn( infMsg ); - LoggingContext.successStatusFields(); - } - - String ntListString = ""; - String maxDescString = ""; - String maxEdgeString = ""; - - int maxDescCount = 10; // default value - int maxEdgeCount = 10; // default value - ArrayList <String> protectedNTypes = new ArrayList <String> (); - protectedNTypes.add("cloud-region"); // default value - - try { - ntListString = AAIConfig.get("aai.forceDel.protected.nt.list"); - maxDescString = AAIConfig.get("aai.forceDel.protected.descendant.count"); - maxEdgeString = AAIConfig.get("aai.forceDel.protected.edge.count"); - } - catch ( Exception nfe ){ - // Don't worry, we will use default values - String infMsg = "-- WARNING -- could not get aai.forceDel.protected values from aaiconfig.properties -- will use default values. "; - System.out.println( infMsg ); - LoggingContext.statusCode(StatusCode.ERROR); - LoggingContext.responseCode(LoggingContext.DATA_ERROR); - logger.warn( infMsg ); - LoggingContext.successStatusFields(); - } - - if( maxDescString != null && !maxDescString.isEmpty() ){ - try { - maxDescCount = Integer.parseInt(maxDescString); - } - catch ( Exception nfe ){ - // Don't worry, we will leave "maxDescCount" set to the default value - } - } - - if( maxEdgeString != null && !maxEdgeString.isEmpty() ){ - try { - maxEdgeCount = Integer.parseInt(maxEdgeString); - } - catch ( Exception nfe ){ - // Don't worry, we will leave "maxEdgeCount" set to the default value - } - } - - if( ntListString != null && !ntListString.trim().isEmpty() ){ - String [] nodeTypes = ntListString.split("\\|"); - for( int i = 0; i < nodeTypes.length; i++ ){ - protectedNTypes.add(nodeTypes[i]); - } - } - - boolean giveProtOverRideMsg = false; - boolean giveProtErrorMsg = false; - if( descendantCount > maxDescCount ){ - // They are trying to delete a node with a lots of descendants - String infMsg = " >> WARNING >> This node has more descendant edges than the max ProtectedDescendantCount: " + edgeCount + ". Max = " + - maxEdgeCount + ". It can be DANGEROUS to delete one of these. << WARNING << "; - System.out.println(infMsg); - logger.info(infMsg); - if( ! overRideProtection ){ - // They cannot delete this kind of node without using the override option - giveProtErrorMsg = true; - } - else { - giveProtOverRideMsg = true; - } - } - - if( edgeCount > maxEdgeCount ){ - // They are trying to delete a node with a lot of edges - String infMsg = " >> WARNING >> This node has more edges than the max ProtectedEdgeCount: " + edgeCount + ". Max = " + - maxEdgeCount + ". It can be DANGEROUS to delete one of these. << WARNING << "; - System.out.println(infMsg); - logger.info(infMsg); - if( ! overRideProtection ){ - // They cannot delete this kind of node without using the override option - giveProtErrorMsg = true; - } - else { - giveProtOverRideMsg = true; - } - } - - if( thisNodeType != null && !thisNodeType.equals("") && protectedNTypes.contains(thisNodeType) ){ - // They are trying to delete a protected Node Type - String infMsg = " >> WARNING >> This node is a PROTECTED NODE-TYPE (" + thisNodeType + "). " + - " It can be DANGEROUS to delete one of these. << WARNING << "; - System.out.println(infMsg); - logger.info(infMsg); - if( ! overRideProtection ){ - // They cannot delete this kind of node without using the override option - giveProtErrorMsg = true; - } - else { - giveProtOverRideMsg = true; - } - } - - if( giveProtOverRideMsg ){ - String infMsg = " !!>> WARNING >>!! you are using the overRideProtection parameter which will let you do this potentially dangerous delete."; - System.out.println("\n" + infMsg); - logger.info(infMsg); - } - else if( giveProtErrorMsg ) { - String errMsg = " ERROR >> this kind of node can only be deleted if you pass the overRideProtection parameter."; - System.out.println("\n" + errMsg); - LoggingContext.statusCode(StatusCode.ERROR); - LoggingContext.responseCode(LoggingContext.BUSINESS_PROCESS_ERROR); - logger.error(errMsg); - LoggingContext.successStatusFields(); - return false; - } - - System.out.print("\n Are you sure you want to do this delete? (y/n): "); - Scanner s = new Scanner(System.in); - s.useDelimiter(""); - String confirm = s.next(); - s.close(); - - if (!"y".equalsIgnoreCase(confirm)) { - String infMsg = " User [" + uid + "] has chosen to abandon this delete request. "; - System.out.println("\n" + infMsg); - logger.info(infMsg); - return false; - } - else { - String infMsg = " User [" + uid + "] has confirmed this delete request. "; - System.out.println("\n" + infMsg); - logger.info(infMsg); - return true; - } - - } // End of getNodeDelConfirmation() - } - - public static JanusGraph setupGraph(EELFLogger logger){ - - JanusGraph janusGraph = null; - - try (InputStream inputStream = new FileInputStream(AAIConstants.REALTIME_DB_CONFIG);){ - - Properties properties = new Properties(); - properties.load(inputStream); - - if(INMEMORY.equals(properties.get("storage.backend"))){ - janusGraph = AAIGraph.getInstance().getGraph(); - graphType = INMEMORY; - } else { - janusGraph = JanusGraphFactory.open( - new AAIGraphConfig.Builder(AAIConstants.REALTIME_DB_CONFIG) - .forService(ForceDeleteTool.class.getSimpleName()) - .withGraphType("realtime1") - .buildConfiguration() - ); - } - } catch (Exception e) { - logger.error("Unable to open the graph", LogFormatTools.getStackTop(e)); - } - - return janusGraph; - } - - public static void closeGraph(JanusGraph graph, EELFLogger logger){ - - try { - if(INMEMORY.equals(graphType)) { - return; - } - if( graph != null && graph.isOpen() ){ - graph.tx().close(); - graph.close(); - } - } catch (Exception ex) { - // Don't throw anything because JanusGraph sometimes is just saying that the graph is already closed{ - logger.warn("WARNING from final graph.shutdown()", ex); - } - } -} - - diff --git a/aai-resources/src/main/java/org/onap/aai/dbgen/GraphMLTokens.java b/aai-resources/src/main/java/org/onap/aai/dbgen/GraphMLTokens.java deleted file mode 100644 index d43b57f..0000000 --- a/aai-resources/src/main/java/org/onap/aai/dbgen/GraphMLTokens.java +++ /dev/null @@ -1,56 +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.dbgen; - -/** - * A collection of tokens used for GraphML related data. - */ -public class GraphMLTokens { - public static final String GRAPHML = "graphml"; - public static final String XMLNS = "xmlns"; - public static final String GRAPHML_XMLNS = "http://graphml.graphdrawing.org/xmlns"; - public static final String G = "G"; - public static final String EDGEDEFAULT = "edgedefault"; - public static final String DIRECTED = "directed"; - public static final String KEY = "key"; - public static final String FOR = "for"; - public static final String ID = "id"; - public static final String ATTR_NAME = "attr.name"; - public static final String ATTR_TYPE = "attr.type"; - public static final String GRAPH = "graph"; - public static final String NODE = "node"; - public static final String EDGE = "edge"; - public static final String SOURCE = "source"; - public static final String TARGET = "target"; - public static final String DATA = "data"; - public static final String LABEL = "label"; - public static final String STRING = "string"; - public static final String FLOAT = "float"; - public static final String DOUBLE = "double"; - public static final String LONG = "long"; - public static final String BOOLEAN = "boolean"; - public static final String INT = "int"; - public static final String ARRAY = "array"; - public static final String SET = "set"; - public static final String LIST = "list"; - public static final String ITEM = "item"; - public static final String _DEFAULT = "_default"; - -} diff --git a/aai-resources/src/main/java/org/onap/aai/dbgen/SchemaMod.java b/aai-resources/src/main/java/org/onap/aai/dbgen/SchemaMod.java deleted file mode 100644 index 81adb68..0000000 --- a/aai-resources/src/main/java/org/onap/aai/dbgen/SchemaMod.java +++ /dev/null @@ -1,183 +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.dbgen; - -import java.util.Properties; - -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.logging.ErrorLogHelper; -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.util.AAIConfig; -import org.onap.aai.util.AAIConstants; -import org.onap.aai.util.UniquePropertyCheck; -import org.slf4j.MDC; - -import com.att.eelf.configuration.Configuration; -import com.att.eelf.configuration.EELFLogger; -import com.att.eelf.configuration.EELFManager; - -public class SchemaMod { - - - - /** - * The main method. - * - * @param args the arguments - */ - public static void main(String[] args) { - - SchemaMod.execute(args); - System.exit(0); - - }// End of main() - - /** - * Execute. - * - * @param args the args - */ - public static void execute(String[] args) { - - // Set the logging file properties to be used by EELFManager - Properties props = System.getProperties(); - props.setProperty(Configuration.PROPERTY_LOGGING_FILE_NAME, AAIConstants.AAI_SCHEMA_MOD_LOGBACK_PROPS); - props.setProperty(Configuration.PROPERTY_LOGGING_FILE_PATH, AAIConstants.AAI_HOME_ETC_APP_PROPERTIES); - - EELFLogger logger = EELFManager.getInstance().getLogger(UniquePropertyCheck.class.getSimpleName()); - MDC.put("logFilenameAppender", SchemaMod.class.getSimpleName()); - - // NOTE -- We're just working with properties that are used for NODES - // for now. - String propName = ""; - String targetDataType = ""; - String targetIndexInfo = ""; - String preserveDataFlag = ""; - - String usageString = "Usage: SchemaMod propertyName targetDataType targetIndexInfo preserveDataFlag \n"; - if (args.length != 4) { - String emsg = "Four Parameters are required. \n" + usageString; - logAndPrint(logger, emsg); - System.exit(1); - } else { - propName = args[0]; - targetDataType = args[1]; - targetIndexInfo = args[2]; - preserveDataFlag = args[3]; - } - - if (propName.equals("")) { - String emsg = "Bad parameter - propertyName cannot be empty. \n" + usageString; - logAndPrint(logger, emsg); - System.exit(1); - } else if (!targetDataType.equals("String") && !targetDataType.equals("Set<String>") - && !targetDataType.equals("Integer") && !targetDataType.equals("Long") - && !targetDataType.equals("Boolean")) { - String emsg = "Unsupported targetDataType. We only support String, Set<String>, Integer, Long or Boolean for now.\n" - + usageString; - logAndPrint(logger, emsg); - System.exit(1); - } else if (!targetIndexInfo.equals("uniqueIndex") && !targetIndexInfo.equals("index") - && !targetIndexInfo.equals("noIndex")) { - String emsg = "Unsupported IndexInfo. We only support: 'uniqueIndex', 'index' or 'noIndex'.\n" - + usageString; - logAndPrint(logger, emsg); - System.exit(1); - } - - try { - AAIConfig.init(); - ErrorLogHelper.loadProperties(); - } catch (Exception ae) { - String emsg = "Problem with either AAIConfig.init() or ErrorLogHelper.LoadProperties(). "; - logAndPrint(logger, emsg + "[" + ae.getMessage() + "]"); - System.exit(1); - } - - - // Give a big warning if the DbMaps.PropertyDataTypeMap value does not - // agree with what we're doing - String warningMsg = ""; - /*if (!dbMaps.PropertyDataTypeMap.containsKey(propName)) { - String emsg = "Property Name = [" + propName + "] not found in PropertyDataTypeMap. "; - logAndPrint(logger, emsg); - System.exit(1); - } else { - String currentDataType = dbMaps.PropertyDataTypeMap.get(propName); - if (!currentDataType.equals(targetDataType)) { - warningMsg = "TargetDataType [" + targetDataType + "] does not match what is in DbRules.java (" - + currentDataType + ")."; - } - }*/ - - if (!warningMsg.equals("")) { - logAndPrint(logger, "\n>>> WARNING <<<< "); - logAndPrint(logger, ">>> " + warningMsg + " <<<"); - } - - logAndPrint(logger, ">>> Processing will begin in 5 seconds (unless interrupted). <<<"); - try { - // Give them a chance to back out of this - Thread.sleep(5000); - } catch (java.lang.InterruptedException ie) { - logAndPrint(logger, " DB Schema Update has been aborted. "); - Thread.currentThread().interrupt(); - System.exit(1); - } - - logAndPrint(logger, " ---- NOTE --- about to open graph (takes a little while)\n"); - - Version version = Version.getLatest(); - QueryStyle queryStyle = QueryStyle.TRAVERSAL; - ModelType introspectorFactoryType = ModelType.MOXY; - Loader loader = LoaderFactory.createLoaderForVersion(introspectorFactoryType, version); - TransactionalGraphEngine engine = null; - try { - engine = new JanusGraphDBEngine(queryStyle, DBConnectionType.REALTIME, loader); - SchemaModInternal internal = new SchemaModInternal(engine, logger, propName, targetDataType, targetIndexInfo, new Boolean(preserveDataFlag)); - internal.execute(); - engine.startTransaction(); - engine.tx().close(); - } catch (Exception e) { - String emsg = "Not able to get a graph object in SchemaMod.java\n"; - logAndPrint(logger, e.getMessage()); - logAndPrint(logger, emsg); - System.exit(1); - } - } - /** - * Log and print. - * - * @param logger the logger - * @param msg the msg - */ - protected static void logAndPrint(EELFLogger logger, String msg) { - System.out.println(msg); - logger.info(msg); - } - - -} diff --git a/aai-resources/src/main/java/org/onap/aai/dbgen/SchemaModInternal.java b/aai-resources/src/main/java/org/onap/aai/dbgen/SchemaModInternal.java deleted file mode 100644 index 1aa33ee..0000000 --- a/aai-resources/src/main/java/org/onap/aai/dbgen/SchemaModInternal.java +++ /dev/null @@ -1,309 +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.dbgen; - -import java.util.ArrayList; -import java.util.Iterator; -import java.util.UUID; - -import org.apache.tinkerpop.gremlin.structure.Direction; -import org.apache.tinkerpop.gremlin.structure.Edge; -import org.apache.tinkerpop.gremlin.structure.Vertex; -import org.apache.tinkerpop.gremlin.structure.VertexProperty; -import org.onap.aai.serialization.engines.TransactionalGraphEngine; -import org.onap.aai.util.FormatDate; -import org.onap.aai.util.UniquePropertyCheck; - -import com.att.eelf.configuration.EELFLogger; -import org.janusgraph.core.Cardinality; -import org.janusgraph.core.PropertyKey; -import org.janusgraph.core.schema.JanusGraphManagement; - -public class SchemaModInternal { - private static final String FROMAPPID = "AAI-UTILS"; - private final String TRANSID = UUID.randomUUID().toString(); - private final TransactionalGraphEngine engine; - private final String propName; - private final Class<?> type; - private final String indexType; - private final boolean preserveData; - private final Cardinality cardinality; - private final EELFLogger logger; - - public SchemaModInternal(TransactionalGraphEngine engine, EELFLogger logger, String propName, String type, String indexType, boolean preserveData) { - this.engine = engine; - this.propName = propName; - this.type = determineClass(type); - this.indexType = indexType; - this.preserveData = preserveData; - this.cardinality = determineCardinality(type); - this.logger = logger; - } - - - private Class<?> determineClass(String type) { - final Class<?> result; - if (type.equals("String")) { - result = String.class; - } else if (type.equals("Set<String>")) { - result = String.class; - } else if (type.equals("Integer")) { - result = Integer.class; - } else if (type.equals("Boolean")) { - result = Boolean.class; - } else if (type.equals("Character")) { - result = Character.class; - } else if (type.equals("Long")) { - result = Long.class; - } else if (type.equals("Float")) { - result = Float.class; - } else if (type.equals("Double")) { - result = Double.class; - } else { - String emsg = "Not able translate the targetDataType [" + type + "] to a Class variable.\n"; - logAndPrint(logger, emsg); - throw new RuntimeException(emsg); - } - - return result; - } - private Cardinality determineCardinality(String type) { - if (type.equals("Set<String>")) { - return Cardinality.SET; - } else { - return Cardinality.SINGLE; - } - } - public void execute() { - JanusGraphManagement graphMgt = null; - boolean success = false; - try { - // Make sure this property is in the DB. - graphMgt = engine.asAdmin().getManagementSystem(); - if (graphMgt == null) { - String emsg = "Not able to get a graph Management object in SchemaMod.java\n"; - logAndPrint(logger, emsg); - System.exit(1); - } - PropertyKey origPropKey = graphMgt.getPropertyKey(propName); - if (origPropKey == null) { - String emsg = "The propName = [" + propName + "] is not defined in our graph. "; - logAndPrint(logger, emsg); - System.exit(1); - } - - if (indexType.equals("uniqueIndex")) { - // Make sure the data in the property being changed can have a - // unique-index put on it. - // Ie. if there are duplicate values, we will not be able to - // migrate the data back into the property. - Boolean foundDupesFlag = UniquePropertyCheck.runTheCheckForUniqueness(TRANSID, FROMAPPID, - engine.tx(), propName, logger); - if (foundDupesFlag) { - logAndPrint(logger, - "\n\n!!!!!! >> Cannot add a uniqueIndex for the property: [" + propName - + "] because duplicate values were found. See the log for details on which" - + " nodes have this value. \nThey will need to be resolved (by updating those values to new" - + " values or deleting unneeded nodes) using the standard REST-API \n"); - System.exit(1); - } - } - - // -------------- If we made it to here - we must be OK with making - // this change ------------ - - // Rename this property to a backup name (old name with "retired_" - // appended plus a dateStr) - - FormatDate fd = new FormatDate("MMddHHmm", "GMT"); - String dteStr= fd.getDateTime(); - - String retiredName = propName + "-" + dteStr + "-RETIRED"; - graphMgt.changeName(origPropKey, retiredName); - - // Create a new property using the original property name and the - // targetDataType - PropertyKey freshPropKey = graphMgt.makePropertyKey(propName).dataType(type) - .cardinality(cardinality).make(); - - // Create the appropriate index (if any) - if (indexType.equals("uniqueIndex")) { - String freshIndexName = propName + dteStr; - graphMgt.buildIndex(freshIndexName, Vertex.class).addKey(freshPropKey).unique().buildCompositeIndex(); - } else if (indexType.equals("index")) { - String freshIndexName = propName + dteStr; - graphMgt.buildIndex(freshIndexName, Vertex.class).addKey(freshPropKey).buildCompositeIndex(); - } - - logAndPrint(logger, "Committing schema changes with graphMgt.commit()"); - graphMgt.commit(); - engine.startTransaction(); - // Get A new graph object - logAndPrint(logger, " ---- NOTE --- about to open a second graph object (takes a little while)\n"); - - // For each node that has this property, update the new from the old - // and then remove the - // old property from that node - Iterator<Vertex> verts = engine.asAdmin().getTraversalSource().V().has(retiredName); - int vtxCount = 0; - ArrayList<String> alreadySeenVals = new ArrayList<String>(); - while (verts.hasNext()) { - vtxCount++; - Vertex tmpVtx = verts.next(); - String tmpVid = tmpVtx.id().toString(); - - Object origVal = tmpVtx.<Object> property(retiredName).orElse(null); - if (preserveData) { - tmpVtx.property(propName, origVal); - if (indexType.equals("uniqueIndex")) { - // We're working on a property that is being used as a - // unique index - String origValStr = ""; - if (origVal != null) { - origValStr = origVal.toString(); - } - if (alreadySeenVals.contains(origValStr)) { - // This property is supposed to be unique, but we've - // already seen this value in this loop - // This should have been caught up in the first part - // of SchemaMod, but since it wasn't, we - // will just log the problem. - logAndPrint(logger, - "\n\n ---------- ERROR - could not migrate the old data [" + origValStr - + "] for propertyName [" + propName - + "] because this property is having a unique index put on it."); - showPropertiesAndEdges(TRANSID, FROMAPPID, tmpVtx, logger); - logAndPrint(logger, "-----------------------------------\n"); - } else { - // Ok to add this prop in as a unique value - tmpVtx.property(propName, origVal); - logAndPrint(logger, - "INFO -- just did the add of the freshPropertyKey and updated it with the orig value (" - + origValStr + ")"); - } - alreadySeenVals.add(origValStr); - } else { - // We are not working with a unique index - tmpVtx.property(propName, origVal); - logAndPrint(logger, - "INFO -- just did the add of the freshPropertyKey and updated it with the orig value (" - + origVal.toString() + ")"); - } - } else { - // existing nodes just won't have that property anymore - // Not sure if we'd ever actually want to do this -- maybe - // we'd do this if the new - // data type was not compatible with the old? - } - tmpVtx.property(retiredName).remove(); - - logAndPrint(logger, "INFO -- just did the remove of the " + retiredName + " from this vertex. (vid=" - + tmpVid + ")"); - } - - success = true; - } catch (Exception ex) { - logAndPrint(logger, "Threw a regular Exception: "); - logAndPrint(logger, ex.getMessage()); - } finally { - if (graphMgt != null && graphMgt.isOpen()) { - // Any changes that worked correctly should have already done - // their commits. - graphMgt.rollback(); - } - if (engine != null) { - if (success) { - engine.commit(); - } else { - engine.rollback(); - } - } - } - } - - /** - * Show properties and edges. - * - * @param transId the trans id - * @param fromAppId the from app id - * @param tVert the t vert - * @param logger the logger - */ - private static void showPropertiesAndEdges(String transId, String fromAppId, Vertex tVert, EELFLogger logger) { - - if (tVert == null) { - logAndPrint(logger, "Null node passed to showPropertiesAndEdges."); - } else { - String nodeType = ""; - Object ob = tVert.<String> property("aai-node-type"); - if (ob == null) { - nodeType = "null"; - } else { - nodeType = ob.toString(); - } - - logAndPrint(logger, " AAINodeType/VtxID for this Node = [" + nodeType + "/" + tVert.id() + "]"); - logAndPrint(logger, " Property Detail: "); - Iterator<VertexProperty<Object>> pI = tVert.properties(); - while (pI.hasNext()) { - VertexProperty<Object> tp = pI.next(); - Object val = tp.value(); - logAndPrint(logger, "Prop: [" + tp.key() + "], val = [" + val + "] "); - } - - Iterator<Edge> eI = tVert.edges(Direction.BOTH); - if (!eI.hasNext()) { - logAndPrint(logger, "No edges were found for this vertex. "); - } - while (eI.hasNext()) { - Edge ed = eI.next(); - String lab = ed.label(); - Vertex vtx; - if (tVert.equals(ed.inVertex())) { - vtx = ed.outVertex(); - } else { - vtx = ed.inVertex(); - } - if (vtx == null) { - logAndPrint(logger, - " >>> COULD NOT FIND VERTEX on the other side of this edge edgeId = " + ed.id() + " <<< "); - } else { - String nType = vtx.<String> property("aai-node-type").orElse(null); - String vid = vtx.id().toString(); - logAndPrint(logger, "Found an edge (" + lab + ") from this vertex to a [" + nType - + "] node with VtxId = " + vid); - } - } - } - } // End of showPropertiesAndEdges() - - /** - * Log and print. - * - * @param logger the logger - * @param msg the msg - */ - protected static void logAndPrint(EELFLogger logger, String msg) { - System.out.println(msg); - logger.info(msg); - } - -} diff --git a/aai-resources/src/main/java/org/onap/aai/dbgen/UpdateEdgeTags.java b/aai-resources/src/main/java/org/onap/aai/dbgen/UpdateEdgeTags.java deleted file mode 100644 index aebc456..0000000 --- a/aai-resources/src/main/java/org/onap/aai/dbgen/UpdateEdgeTags.java +++ /dev/null @@ -1,76 +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.dbgen; - -import org.onap.aai.dbgen.tags.UpdateEdgeTagsCmd; -import org.onap.aai.exceptions.AAIException; -import org.onap.aai.logging.LoggingContext; -import org.onap.aai.logging.LoggingContext.StatusCode; -import org.onap.aai.util.AAIConstants; -import org.onap.aai.util.AAISystemExitUtil; - -import java.util.UUID; - - -public class UpdateEdgeTags { - - private static final String FROMAPPID = "AAI-DB"; - private static final String TRANSID = UUID.randomUUID().toString(); - - /** - * The main method. - * - * @param args the arguments - */ - public static void main(String[] args) { - - System.setProperty("aai.service.name", UpdateEdgeTags.class.getSimpleName()); - - if( args == null || args.length != 1 ){ - String msg = "usage: UpdateEdgeTags edgeRuleKey (edgeRuleKey can be either, all, or a rule key like 'nodeTypeA|nodeTypeB') \n"; - System.out.println(msg); - System.exit(1); - } - LoggingContext.init(); - LoggingContext.partnerName(FROMAPPID); - LoggingContext.serviceName(AAIConstants.AAI_RESOURCES_MS); - LoggingContext.component("updateEdgeTags"); - LoggingContext.targetEntity(AAIConstants.AAI_RESOURCES_MS); - LoggingContext.targetServiceName("main"); - LoggingContext.requestId(TRANSID); - LoggingContext.statusCode(StatusCode.COMPLETE); - LoggingContext.responseCode("0"); - - String edgeRuleKeyVal = args[0]; - - try { - UpdateEdgeTagsCmd edgeOp = new UpdateEdgeTagsCmd(edgeRuleKeyVal); - edgeOp.execute(); - } catch (AAIException e) { - e.printStackTrace(); - } finally { - AAISystemExitUtil.systemExitCloseAAIGraph(0); - } - - }// end of main() -} - - - diff --git a/aai-resources/src/main/java/org/onap/aai/dbgen/tags/UpdateEdgeTagsCmd.java b/aai-resources/src/main/java/org/onap/aai/dbgen/tags/UpdateEdgeTagsCmd.java deleted file mode 100644 index 6e10853..0000000 --- a/aai-resources/src/main/java/org/onap/aai/dbgen/tags/UpdateEdgeTagsCmd.java +++ /dev/null @@ -1,220 +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.dbgen.tags; - -import org.apache.tinkerpop.gremlin.structure.Edge; -import org.apache.tinkerpop.gremlin.structure.Graph; -import org.apache.tinkerpop.gremlin.structure.Vertex; -import org.janusgraph.core.JanusGraph; -import org.onap.aai.dbmap.AAIGraph; -import org.onap.aai.exceptions.AAIException; -import org.onap.aai.logging.ErrorLogHelper; -import org.onap.aai.serialization.db.EdgeRule; -import org.onap.aai.serialization.db.EdgeRules; -import org.onap.aai.util.AAIConfig; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import java.util.*; - -public class UpdateEdgeTagsCmd implements Command { - private JanusGraph graph; - private String rulesFilename; - private EdgeRules edgeRulesInstance = null; - private String[] edgeRuleKeys = null; - - private String filter = "all"; - private static final String FROMAPPID = "AAI-DB"; - private static final String TRANSID = UUID.randomUUID().toString(); - - - static final Logger logger = LoggerFactory.getLogger(UpdateEdgeTagsCmd.class); - - /** - * @param filter - */ - public UpdateEdgeTagsCmd(String filter) throws AAIException { - super(); - this.filter = filter; - createEdgeRuleSet(); - } - - /** - * @param filter - * @param rulesFilename - */ - public UpdateEdgeTagsCmd(String filter, String rulesFilename) { - super(); - this.rulesFilename = rulesFilename; - this.filter = filter; - this.createEdgeRuleSet(); - } - - @Override - public void execute() throws AAIException { - try { - ErrorLogHelper.loadProperties(); - if(graph == null) { - AAIConfig.init(); - logger.info(" ---- NOTE --- about to open graph (takes a little while)--------\n"); - graph = AAIGraph.getInstance().getGraph(); - } - if( graph == null ){ - String emsg = "null graph object in updateEdgeTags() \n"; - logger.info(emsg); - return; - } - } - catch (AAIException e1) { - String msg = e1.getErrorObject().toString(); - System.out.println(msg); - return; - } - catch (Exception e2) { - String msg = e2.toString(); - System.out.println(msg); - e2.printStackTrace(); - return; - } - - Graph g = graph.newTransaction(); - try { - Iterator<Edge> edgeItr = graph.traversal().E(); -/* - if("all".equalsIgnoreCase(filter)) { - edgeItr = graph.traversal().E(); - } else { - edgeItr = graph.traversal().E()..inV().property("aai-node-type",this.edgeRuleKeys[0]); - edgeItr = graph.traversal().E().inV().has("aai-node-type").values(this.edgeRuleKeys[0]).outV().has("aai-node-type").values(this.edgeRuleKeys[1]); - } -*/ - //Iterate over all the edges of the in memory graph - while( edgeItr != null && edgeItr.hasNext() ){ - - Edge thisEdge = edgeItr.next(); - //The filter can limit the application of changes to edges between vertices of one pair of node-types - //Other node type pairs found in in-memory graph are skipped - if(! passesFilter(thisEdge) ) { - continue; - } - - //Find the rules in the file between the node-type pair for the current in-memory edge - if( edgeRulesInstance.hasEdgeRule(thisEdge.inVertex().<String>property("aai-node-type").orElse(null),thisEdge.outVertex().<String>property("aai-node-type").orElse(null))) { - logger.info("key = " + thisEdge.inVertex().<String>property("aai-node-type").orElse(null)+"|"+ thisEdge.outVertex().<String>property("aai-node-type").orElse(null)+ ", label = " + thisEdge.label() - + ", for id = " + thisEdge.id().toString() + ", set: "+thisEdge.keys()+"\n"); - //Get the rule map from the FILE for the node-type pair, filtered by label found on the in-memory Edge; expecting one rule - //Note: the filter label does not work -- adding equals/contains(thisEdge.label() tests below - Map<String, EdgeRule> edgeRules =edgeRulesInstance.getEdgeRules(thisEdge.inVertex().<String>property("aai-node-type").orElse(null),thisEdge.outVertex().<String>property("aai-node-type").orElse(null), thisEdge.label()); -// Collection<EdgeRule> edgeRules = edgeRuleMultimap.get(derivedEdgeKey); - //Apply the Edge properties from the FILE rule to the in-memory Edge - for(EdgeRule e : edgeRules.values()) { - if(e.getLabel().equals(thisEdge.label())) { - logger.info("EdgeRule e: " + String.join("|",thisEdge.outVertex().<String>property("aai-node-type").orElse(null),thisEdge.inVertex().<String>property("aai-node-type").orElse(null),e.getLabel())); - edgeRulesInstance.addProperties(thisEdge, e); - } - } - //The FILE ruleset is broken? -- run away; discard all changes! - if(! edgeRules.containsKey(thisEdge.label())) { - // Couldn't find a rule for this edge - logger.error("Broken EdgeSet in edgeRuleFile: " + thisEdge.bothVertices()); - throw new AAIException("AAI_6120", "No EdgeRule found for nodeTypes: " + String.join("|",thisEdge.outVertex().<String>property("aai-node-type").orElse(null),thisEdge.inVertex().<String>property("aai-node-type").orElse(null),thisEdge.label())); - } - } else { - //The expected FILE ruleset could not be found -- run away; discard all changes! - logger.error("Missing EdgeSet in edgeRuleFile: " + thisEdge.bothVertices()); - throw new AAIException("AAI_6120", "No EdgeRule found for nodeTypes: " + String.join("|",thisEdge.outVertex().<String>property("aai-node-type").orElse(null),thisEdge.inVertex().<String>property("aai-node-type").orElse(null),thisEdge.label())); - } - - } // End of looping over all in-memory edges - graph.tx().commit(); - logger.info("- committed updates for listed edges " ); - } - catch (Exception e2) { - String msg = e2.toString(); - logger.error(msg); - e2.printStackTrace(); - if( g != null ){ - graph.tx().rollback(); - } - if(e2 instanceof AAIException) { - throw e2; - } - return; - } - finally { - try { - g.close(); - } - catch (Exception e) { - logger.error("Error occured while closing Transaction with graph" + e.getMessage()); - } - } - } - - - /** - * @return the rulesFilename - */ - public String getRulesFilename() { - return this.rulesFilename; - } - - /** - * @return the graph - */ - public JanusGraph getGraph() { - return this.graph; - } - - /** - * @param graph the graph to set - */ - public void setGraph(JanusGraph graph) { - this.graph = graph; - } - - private void createEdgeRuleSet() { - if(this.filter != null) this.edgeRuleKeys = filter.split("\\|"); - edgeRulesInstance = (this.rulesFilename == null) ? EdgeRules.getInstance() : EdgeRules.getInstance(rulesFilename); - return; - } - - private boolean passesFilter(Edge tEdge) { - if("all".equalsIgnoreCase(filter) ) { - logger.debug("EdgeRule PROCESSALL: " + String.join("|",tEdge.outVertex().<String>property("aai-node-type").orElse(null),tEdge.inVertex().<String>property("aai-node-type").orElse(null),tEdge.label())); - return true; - } - Iterator<Vertex> vItr = tEdge.bothVertices(); - - ArrayList<String> l = new ArrayList<String>(Arrays.asList(edgeRuleKeys)); - while( vItr != null && vItr.hasNext() ) { - Vertex v = vItr.next(); - int i = l.indexOf(v.property("aai-node-type").value()); - if (i >= 0) l.remove(i); - } - if(l.isEmpty()) { - logger.debug("EdgeRule filterPROCESS: " + String.join("|",tEdge.outVertex().<String>property("aai-node-type").orElse(null),tEdge.inVertex().<String>property("aai-node-type").orElse(null),tEdge.label())); - } - else { - logger.debug("EdgeRule filterSKIP: " + String.join("|",tEdge.outVertex().<String>property("aai-node-type").orElse(null),tEdge.inVertex().<String>property("aai-node-type").orElse(null),tEdge.label())); - } - return l.isEmpty(); - } -} diff --git a/aai-resources/src/main/java/org/onap/aai/interceptors/package-info.java b/aai-resources/src/main/java/org/onap/aai/interceptors/package-info.java index f6498af..ee9c334 100644 --- a/aai-resources/src/main/java/org/onap/aai/interceptors/package-info.java +++ b/aai-resources/src/main/java/org/onap/aai/interceptors/package-info.java @@ -33,4 +33,4 @@ * </code> * </pre> */ -package org.onap.aai.interceptors; +package org.onap.aai.interceptors;
\ No newline at end of file diff --git a/aai-resources/src/main/java/org/onap/aai/interceptors/post/AAIResponseFilterPriority.java b/aai-resources/src/main/java/org/onap/aai/interceptors/post/AAIResponseFilterPriority.java index d91e7f6..146f847 100644 --- a/aai-resources/src/main/java/org/onap/aai/interceptors/post/AAIResponseFilterPriority.java +++ b/aai-resources/src/main/java/org/onap/aai/interceptors/post/AAIResponseFilterPriority.java @@ -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 HEADER_MANIPULATION = 1000; + public static final int INVALID_RESPONSE_STATUS = 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; } diff --git a/aai-resources/src/main/java/org/onap/aai/interceptors/post/InvalidResponseStatus.java b/aai-resources/src/main/java/org/onap/aai/interceptors/post/InvalidResponseStatus.java new file mode 100644 index 0000000..7fd0b9c --- /dev/null +++ b/aai-resources/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-resources/src/main/java/org/onap/aai/interceptors/post/ResetLoggingContext.java b/aai-resources/src/main/java/org/onap/aai/interceptors/post/ResetLoggingContext.java index f8c5644..04f0391 100644 --- a/aai-resources/src/main/java/org/onap/aai/interceptors/post/ResetLoggingContext.java +++ b/aai-resources/src/main/java/org/onap/aai/interceptors/post/ResetLoggingContext.java @@ -26,6 +26,8 @@ import javax.servlet.http.HttpServletRequest; import javax.ws.rs.container.ContainerRequestContext; import javax.ws.rs.container.ContainerResponseContext; import javax.ws.rs.container.ContainerResponseFilter; +import javax.ws.rs.core.Response.Status; +import javax.ws.rs.core.Response.StatusType; import org.onap.aai.interceptors.AAIContainerFilter; import org.onap.aai.logging.LoggingContext; @@ -47,23 +49,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-resources/src/main/java/org/onap/aai/interceptors/post/ResponseHeaderManipulation.java b/aai-resources/src/main/java/org/onap/aai/interceptors/post/ResponseHeaderManipulation.java index 6d6dbd8..3809540 100644 --- a/aai-resources/src/main/java/org/onap/aai/interceptors/post/ResponseHeaderManipulation.java +++ b/aai-resources/src/main/java/org/onap/aai/interceptors/post/ResponseHeaderManipulation.java @@ -25,6 +25,7 @@ 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 org.onap.aai.interceptors.AAIContainerFilter; import org.onap.aai.interceptors.AAIHeaderProperties; @@ -32,6 +33,7 @@ import org.onap.aai.interceptors.AAIHeaderProperties; @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 +45,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-resources/src/main/java/org/onap/aai/interceptors/pre/AAIRequestFilterPriority.java b/aai-resources/src/main/java/org/onap/aai/interceptors/pre/AAIRequestFilterPriority.java index 0db7b44..c3d9d3b 100644 --- a/aai-resources/src/main/java/org/onap/aai/interceptors/pre/AAIRequestFilterPriority.java +++ b/aai-resources/src/main/java/org/onap/aai/interceptors/pre/AAIRequestFilterPriority.java @@ -31,9 +31,16 @@ public final class AAIRequestFilterPriority { public static final int HTTP_HEADER = 4000; + public static final int LATEST = 4250; + public static final int AUTHORIZATION = 4500; - public static final int HEADER_MANIPULATION = 5000; + public static final int RETIRED_SERVICE = 5000; + + public static final int VERSION = 5500; + + public static final int HEADER_MANIPULATION = 6000; + + public static final int REQUEST_MODIFICATION = 7000; - public static final int REQUEST_MODIFICATION = 6000; } diff --git a/aai-resources/src/main/java/org/onap/aai/interceptors/pre/OneWaySslAuthorization.java b/aai-resources/src/main/java/org/onap/aai/interceptors/pre/OneWaySslAuthorization.java index 8fe2d6e..1f8a6ec 100644 --- a/aai-resources/src/main/java/org/onap/aai/interceptors/pre/OneWaySslAuthorization.java +++ b/aai-resources/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-resources/src/main/java/org/onap/aai/interceptors/pre/RequestHeaderManipulation.java b/aai-resources/src/main/java/org/onap/aai/interceptors/pre/RequestHeaderManipulation.java index 7f74f1e..97562d2 100644 --- a/aai-resources/src/main/java/org/onap/aai/interceptors/pre/RequestHeaderManipulation.java +++ b/aai-resources/src/main/java/org/onap/aai/interceptors/pre/RequestHeaderManipulation.java @@ -39,15 +39,10 @@ import org.springframework.beans.factory.annotation.Autowired; @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 +51,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-resources/src/main/java/org/onap/aai/interceptors/pre/RequestModification.java b/aai-resources/src/main/java/org/onap/aai/interceptors/pre/RequestModification.java index 50e87b0..797f9c9 100644 --- a/aai-resources/src/main/java/org/onap/aai/interceptors/pre/RequestModification.java +++ b/aai-resources/src/main/java/org/onap/aai/interceptors/pre/RequestModification.java @@ -36,7 +36,7 @@ import javax.ws.rs.core.UriBuilder; import org.onap.aai.interceptors.AAIContainerFilter; @PreMatching -@Priority(AAIRequestFilterPriority.HEADER_VALIDATION) +@Priority(AAIRequestFilterPriority.REQUEST_MODIFICATION) public class RequestModification extends AAIContainerFilter implements ContainerRequestFilter { @Override diff --git a/aai-resources/src/main/java/org/onap/aai/interceptors/pre/RequestTransactionLogging.java b/aai-resources/src/main/java/org/onap/aai/interceptors/pre/RequestTransactionLogging.java index e9e8d5f..f9976c2 100644 --- a/aai-resources/src/main/java/org/onap/aai/interceptors/pre/RequestTransactionLogging.java +++ b/aai-resources/src/main/java/org/onap/aai/interceptors/pre/RequestTransactionLogging.java @@ -25,12 +25,14 @@ import java.io.IOException; import java.io.InputStream; import java.util.Random; import java.util.UUID; +import java.security.SecureRandom; 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 org.glassfish.jersey.message.internal.ReaderWriter; import org.glassfish.jersey.server.ContainerException; @@ -43,6 +45,7 @@ import org.onap.aai.util.HbaseSaltPrefixer; import org.springframework.beans.factory.annotation.Autowired; import com.google.gson.JsonObject; +import org.springframework.util.StringUtils; @PreMatching @Priority(AAIRequestFilterPriority.REQUEST_TRANS_LOGGING) @@ -51,6 +54,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 { @@ -59,17 +69,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) { } @@ -81,7 +108,7 @@ public class RequestTransactionLogging extends AAIContainerFilter implements Con JsonObject request = new JsonObject(); request.addProperty("ID", fullId); request.addProperty("Http-Method", requestContext.getMethod()); - request.addProperty("Content-Type", httpServletRequest.getContentType()); + request.addProperty(CONTENT_TYPE, httpServletRequest.getContentType()); request.addProperty("Headers", requestContext.getHeaders().toString()); ByteArrayOutputStream out = new ByteArrayOutputStream(); diff --git a/aai-resources/src/main/java/org/onap/aai/interceptors/pre/RetiredInterceptor.java b/aai-resources/src/main/java/org/onap/aai/interceptors/pre/RetiredInterceptor.java new file mode 100644 index 0000000..643793d --- /dev/null +++ b/aai-resources/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-resources/src/main/java/org/onap/aai/interceptors/pre/SetLoggingContext.java b/aai-resources/src/main/java/org/onap/aai/interceptors/pre/SetLoggingContext.java index c991017..368d071 100644 --- a/aai-resources/src/main/java/org/onap/aai/interceptors/pre/SetLoggingContext.java +++ b/aai-resources/src/main/java/org/onap/aai/interceptors/pre/SetLoggingContext.java @@ -64,6 +64,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-resources/src/main/java/org/onap/aai/interceptors/pre/TwoWaySslAuthorization.java b/aai-resources/src/main/java/org/onap/aai/interceptors/pre/TwoWaySslAuthorization.java new file mode 100644 index 0000000..d4e8c4f --- /dev/null +++ b/aai-resources/src/main/java/org/onap/aai/interceptors/pre/TwoWaySslAuthorization.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.interceptors.pre; + +import java.io.IOException; +import java.security.cert.X509Certificate; +import java.util.*; +import java.util.stream.Collectors; + +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 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.onap.aai.util.AAIConfig; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.context.annotation.Profile; + +@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-resources/src/main/java/org/onap/aai/interceptors/pre/VersionInterceptor.java b/aai-resources/src/main/java/org/onap/aai/interceptors/pre/VersionInterceptor.java new file mode 100644 index 0000000..f3c5768 --- /dev/null +++ b/aai-resources/src/main/java/org/onap/aai/interceptors/pre/VersionInterceptor.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.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.net.URI; +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")) { + 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-resources/src/main/java/org/onap/aai/interceptors/pre/VersionLatestInterceptor.java b/aai-resources/src/main/java/org/onap/aai/interceptors/pre/VersionLatestInterceptor.java new file mode 100644 index 0000000..61008b6 --- /dev/null +++ b/aai-resources/src/main/java/org/onap/aai/interceptors/pre/VersionLatestInterceptor.java @@ -0,0 +1,56 @@ +/** + * ============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 absolutePath = requestContext.getUriInfo().getAbsolutePath().toString(); + String latest = absolutePath.replaceFirst("latest", schemaVersions.getDefaultVersion().toString()); + requestContext.setRequestUri(URI.create(latest)); + return; + } + + } +} diff --git a/aai-resources/src/main/java/org/onap/aai/migration/EdgeMigrator.java b/aai-resources/src/main/java/org/onap/aai/migration/EdgeMigrator.java deleted file mode 100644 index 5149912..0000000 --- a/aai-resources/src/main/java/org/onap/aai/migration/EdgeMigrator.java +++ /dev/null @@ -1,144 +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.migration; - -import java.util.Map; -import java.util.List; -import java.util.ArrayList; -import org.javatuples.Pair; - -import org.apache.tinkerpop.gremlin.structure.Edge; -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.Vertex; -import org.onap.aai.db.props.AAIProperties; -import org.onap.aai.serialization.engines.TransactionalGraphEngine; -import org.onap.aai.serialization.db.EdgeRule; -import org.onap.aai.serialization.db.EdgeRules; - -/** - * A migration template for migrating all edge properties between "from" and "to" node from the DbedgeRules.json - * - */ -@MigrationPriority(0) -@MigrationDangerRating(1) -public abstract class EdgeMigrator extends Migrator { - - private boolean success = true; - private EdgeRules rules; - - public EdgeMigrator(TransactionalGraphEngine engine) { - super(engine); - rules = EdgeRules.getInstance(); - } - - public EdgeMigrator(TransactionalGraphEngine engine, List<Pair<String, String>> nodePairList) { - super(engine); - rules = EdgeRules.getInstance(); - } - - - /** - * Do not override this method as an inheritor of this class - */ - @Override - public void run() { - - executeModifyOperation(); - - } - - /** - * This is where inheritors should add their logic - */ - protected void executeModifyOperation() { - - changeEdgeProperties(); - - } - - protected void changeEdgeLabels() { - //TODO: when json file has edge label as well as edge property changes - } - - - - protected void changeEdgeProperties() { - try { - List<Pair<String, String>> nodePairList = this.getAffectedNodePairTypes(); - for (Pair<String, String> nodePair : nodePairList) { - - String NODE_A = nodePair.getValue0(); - String NODE_B = nodePair.getValue1(); - Map<String, EdgeRule> result = rules.getEdgeRules(NODE_A, NODE_B); - - GraphTraversal<Vertex, Vertex> g = this.engine.asAdmin().getTraversalSource().V(); - /* - * Find Out-Edges from Node A to Node B and change them - * Also Find Out-Edges from Node B to Node A and change them - */ - g.union(__.has(AAIProperties.NODE_TYPE, NODE_A).outE().where(__.inV().has(AAIProperties.NODE_TYPE, NODE_B)), - __.has(AAIProperties.NODE_TYPE, NODE_B).outE().where(__.inV().has(AAIProperties.NODE_TYPE, NODE_A))) - .sideEffect(t -> { - Edge e = t.get(); - try { - Vertex out = e.outVertex(); - Vertex in = e.inVertex(); - if (out == null || in == null) { - logger.error( - e.id() + " invalid because one vertex was null: out=" + out + " in=" + in); - } else { - if (result.containsKey(e.label())) { - EdgeRule rule = result.get(e.label()); - e.properties().forEachRemaining(prop -> prop.remove()); - rules.addProperties(e, rule); - } else { - logger.info("found vertices connected by unkwown label: out=" + out + " label=" - + e.label() + " in=" + in); - } - } - } catch (Exception e1) { - throw new RuntimeException(e1); - } - }).iterate(); - } - - } catch (Exception e) { - logger.error("error encountered", e); - success = false; - } - } - - @Override - public Status getStatus() { - if (success) { - return Status.SUCCESS; - } else { - return Status.FAILURE; - } - } - - /** - * List of node pairs("from" and "to"), you would like EdgeMigrator to migrate from json files - * @return - */ - public abstract List<Pair<String, String>> getAffectedNodePairTypes() ; - -} diff --git a/aai-resources/src/main/java/org/onap/aai/migration/EdgeSwingMigrator.java b/aai-resources/src/main/java/org/onap/aai/migration/EdgeSwingMigrator.java deleted file mode 100644 index 3ce5669..0000000 --- a/aai-resources/src/main/java/org/onap/aai/migration/EdgeSwingMigrator.java +++ /dev/null @@ -1,285 +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.migration; - - -import org.apache.tinkerpop.gremlin.structure.Direction; -import org.apache.tinkerpop.gremlin.structure.Edge; -import org.apache.tinkerpop.gremlin.structure.Property; -import org.apache.tinkerpop.gremlin.structure.Vertex; -import org.javatuples.Pair; -import org.onap.aai.db.props.AAIProperties; -import org.onap.aai.serialization.engines.TransactionalGraphEngine; - -import java.util.HashMap; -import java.util.Iterator; -import java.util.List; -import java.util.Map; - -/** - * A migration template for "swinging" edges that terminate on an old-node to a new target node. - * That is, given an oldNode and a newNode we will swing edges that terminate on the - * oldNode and terminate them on the newNode (actually we drop the old edges and add new ones). - * - * - * We allow the passing of some parameters to restrict what edges get swung over: - * > otherEndNodeTypeRestriction: only swing edges that terminate on the oldNode if the - * node at the other end of the edge is of this nodeType. - * > edgeLabelRestriction: Only swing edges that have this edgeLabel - * > edgeDirectionRestriction: Only swing edges that go this direction (from the oldNode) - * this is a required parameter. valid values are: BOTH, IN, OUT - * - */ -@MigrationPriority(0) -@MigrationDangerRating(1) -public abstract class EdgeSwingMigrator extends Migrator { - - private boolean success = true; - private String nodeTypeRestriction = null; - private String edgeLabelRestriction = null; - private String edgeDirRestriction = null; - private List<Pair<Vertex, Vertex>> nodePairList; - - - public EdgeSwingMigrator(TransactionalGraphEngine engine ) { - super(engine); - } - - - /** - * Do not override this method as an inheritor of this class - */ - @Override - public void run() { - executeModifyOperation(); - cleanupAsAppropriate(this.nodePairList); - } - - /** - * This is where inheritors should add their logic - */ - protected void executeModifyOperation() { - - try { - this.nodeTypeRestriction = this.getNodeTypeRestriction(); - this.edgeLabelRestriction = this.getEdgeLabelRestriction(); - this.edgeDirRestriction = this.getEdgeDirRestriction(); - nodePairList = this.getAffectedNodePairs(); - for (Pair<Vertex, Vertex> nodePair : nodePairList) { - Vertex fromNode = nodePair.getValue0(); - Vertex toNode = nodePair.getValue1(); - this.swingEdges(fromNode, toNode, - this.nodeTypeRestriction,this.edgeLabelRestriction,this.edgeDirRestriction); - } - } catch (Exception e) { - logger.error("error encountered", e); - success = false; - } - } - - - protected void swingEdges(Vertex oldNode, Vertex newNode, String nodeTypeRestr, String edgeLabelRestr, String edgeDirRestr) { - try { - // If the old and new Vertices aren't populated, throw an exception - if( oldNode == null ){ - logger.info ( "null oldNode passed to swingEdges() "); - success = false; - return; - } - else if( newNode == null ){ - logger.info ( "null newNode passed to swingEdges() "); - success = false; - return; - } - else if( edgeDirRestr == null || - (!edgeDirRestr.equals("BOTH") - && !edgeDirRestr.equals("IN") - && !edgeDirRestr.equals("OUT") ) - ){ - logger.info ( "invalid direction passed to swingEdges(). valid values are BOTH/IN/OUT "); - success = false; - return; - } - else if( edgeLabelRestr != null - && (edgeLabelRestr.trim().equals("none") || edgeLabelRestr.trim().equals("")) ){ - edgeLabelRestr = null; - } - else if( nodeTypeRestr == null || nodeTypeRestr.trim().equals("") ){ - nodeTypeRestr = "none"; - } - - String oldNodeType = oldNode.value(AAIProperties.NODE_TYPE); - String oldUri = oldNode.<String> property("aai-uri").isPresent() ? oldNode.<String> property("aai-uri").value() : "URI Not present"; - - String newNodeType = newNode.value(AAIProperties.NODE_TYPE); - String newUri = newNode.<String> property("aai-uri").isPresent() ? newNode.<String> property("aai-uri").value() : "URI Not present"; - - // If the nodeTypes don't match, throw an error - if( !oldNodeType.equals(newNodeType) ){ - logger.info ( "Can not swing edge from a [" + oldNodeType + "] node to a [" + - newNodeType + "] node. "); - success = false; - return; - } - - // Find and migrate any applicable OUT edges. - if( edgeDirRestr.equals("BOTH") || edgeDirRestr.equals("OUT") ){ - Iterator <Edge> edgeOutIter = null; - if( edgeLabelRestr == null ) { - edgeOutIter = oldNode.edges(Direction.OUT); - } - else { - edgeOutIter = oldNode.edges(Direction.OUT, edgeLabelRestr); - } - - while( edgeOutIter.hasNext() ){ - Edge oldOutE = edgeOutIter.next(); - String eLabel = oldOutE.label(); - Vertex otherSideNode4ThisEdge = oldOutE.inVertex(); - String otherSideNodeType = otherSideNode4ThisEdge.value(AAIProperties.NODE_TYPE); - if( nodeTypeRestr.equals("none") || nodeTypeRestr.toLowerCase().equals(otherSideNodeType) ){ - Iterator <Property<Object>> propsIter = oldOutE.properties(); - HashMap<String, String> propMap = new HashMap<String,String>(); - while( propsIter.hasNext() ){ - Property<Object> ep = propsIter.next(); - propMap.put(ep.key(), ep.value().toString()); - } - - String otherSideUri = otherSideNode4ThisEdge.<String> property("aai-uri").isPresent() ? otherSideNode4ThisEdge.<String> property("aai-uri").value() : "URI Not present"; - logger.info ( "\nSwinging [" + eLabel + "] OUT edge. \n >> Unchanged side is [" - + otherSideNodeType + "][" + otherSideUri + "] \n >> Edge used to go to [" + oldNodeType - + "][" + oldUri + "],\n >> now swung to [" + newNodeType + "][" + newUri + "]. "); - // remove the old edge - oldOutE.remove(); - - // add the new edge with properties that match the edge that was deleted. We don't want to - // change any edge properties - just swinging one end of the edge to a new node. - // NOTE - addEdge adds an OUT edge to the vertex passed as a parameter, so we are - // adding from the newNode side. - Edge newOutE = newNode.addEdge(eLabel, otherSideNode4ThisEdge); - - Iterator it = propMap.entrySet().iterator(); - while (it.hasNext()) { - Map.Entry pair = (Map.Entry)it.next(); - newOutE.property(pair.getKey().toString(), pair.getValue().toString() ); - } - - } - } - } - - // Find and migrate any applicable IN edges. - if( edgeDirRestr.equals("BOTH") || edgeDirRestr.equals("IN") ){ - Iterator <Edge> edgeInIter = null; - if( edgeLabelRestr == null ) { - edgeInIter = oldNode.edges(Direction.IN); - } - else { - edgeInIter = oldNode.edges(Direction.IN, edgeLabelRestr); - } - - while( edgeInIter.hasNext() ){ - Edge oldInE = edgeInIter.next(); - String eLabel = oldInE.label(); - Vertex otherSideNode4ThisEdge = oldInE.outVertex(); - String otherSideNodeType = otherSideNode4ThisEdge.value(AAIProperties.NODE_TYPE); - if( nodeTypeRestr.equals("none") || nodeTypeRestr.toLowerCase().equals(otherSideNodeType) ){ - Iterator <Property<Object>> propsIter = oldInE.properties(); - HashMap<String, String> propMap = new HashMap<String,String>(); - while( propsIter.hasNext() ){ - Property<Object> ep = propsIter.next(); - propMap.put(ep.key(), ep.value().toString()); - } - - String otherSideUri = otherSideNode4ThisEdge.<String> property("aai-uri").isPresent() ? otherSideNode4ThisEdge.<String> property("aai-uri").value() : "URI Not present"; - logger.info ( "\nSwinging [" + eLabel + "] IN edge. \n >> Unchanged side is [" - + otherSideNodeType + "][" + otherSideUri + "] \n >> Edge used to go to [" + oldNodeType - + "][" + oldUri + "],\n >> now swung to [" + newNodeType + "][" + newUri + "]. "); - - // remove the old edge - oldInE.remove(); - - // add the new edge with properties that match the edge that was deleted. We don't want to - // change any edge properties - just swinging one end of the edge to a new node. - // NOTE - addEdge adds an OUT edge to the vertex passed as a parameter, so we are - // adding from the node on the other-end of the original edge so we'll get - // an IN-edge to the newNode. - Edge newInE = otherSideNode4ThisEdge.addEdge(eLabel, newNode); - - Iterator it = propMap.entrySet().iterator(); - while (it.hasNext()) { - Map.Entry pair = (Map.Entry)it.next(); - newInE.property(pair.getKey().toString(), pair.getValue().toString() ); - } - } - } - } - - } catch (Exception e) { - logger.error("error encountered", e); - success = false; - } - } - - @Override - public Status getStatus() { - if (success) { - return Status.SUCCESS; - } else { - return Status.FAILURE; - } - } - - - /** - * Get the List of node pairs("from" and "to"), you would like EdgeSwingMigrator to migrate from json files - * @return - */ - public abstract List<Pair<Vertex, Vertex>> getAffectedNodePairs() ; - - - /** - * Get the nodeTypeRestriction that you want EdgeSwingMigrator to use - * @return - */ - public abstract String getNodeTypeRestriction() ; - - - /** - * Get the nodeTypeRestriction that you want EdgeSwingMigrator to use - * @return - */ - public abstract String getEdgeLabelRestriction() ; - - /** - * Get the nodeTypeRestriction that you want EdgeSwingMigrator to use - * @return - */ - public abstract String getEdgeDirRestriction() ; - - - - /** - * Cleanup (remove) the nodes that edges were moved off of if appropriate - * @return - */ - public abstract void cleanupAsAppropriate(List<Pair<Vertex, Vertex>> nodePairL); - -}
\ No newline at end of file diff --git a/aai-resources/src/main/java/org/onap/aai/migration/EventAction.java b/aai-resources/src/main/java/org/onap/aai/migration/EventAction.java deleted file mode 100644 index 830685b..0000000 --- a/aai-resources/src/main/java/org/onap/aai/migration/EventAction.java +++ /dev/null @@ -1,29 +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.migration; - -/** - * Used to describe the type of DMaaP event you would like to create - */ -public enum EventAction { - CREATE, - UPDATE, - DELETE -} diff --git a/aai-resources/src/main/java/org/onap/aai/migration/MigrationController.java b/aai-resources/src/main/java/org/onap/aai/migration/MigrationController.java deleted file mode 100644 index f5854f8..0000000 --- a/aai-resources/src/main/java/org/onap/aai/migration/MigrationController.java +++ /dev/null @@ -1,61 +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.migration; - -import java.util.UUID; - -import org.onap.aai.dbmap.AAIGraph; -import org.onap.aai.logging.LoggingContext; -import org.onap.aai.logging.LoggingContext.StatusCode; -import org.onap.aai.util.AAIConstants; - -/** - * Wrapper class to allow {@link org.onap.aai.migration.MigrationControllerInternal MigrationControllerInternal} - * to be run from a shell script - */ -public class MigrationController { - - /** - * The main method. - * - * @param args - * the arguments - */ - public static void main(String[] args) { - LoggingContext.init(); - LoggingContext.partnerName("Migration"); - LoggingContext.serviceName(AAIConstants.AAI_RESOURCES_MS); - LoggingContext.component("MigrationController"); - LoggingContext.targetEntity(AAIConstants.AAI_RESOURCES_MS); - LoggingContext.targetServiceName("main"); - LoggingContext.requestId(UUID.randomUUID().toString()); - LoggingContext.statusCode(StatusCode.COMPLETE); - LoggingContext.responseCode(LoggingContext.SUCCESS); - MigrationControllerInternal internal = new MigrationControllerInternal(); - - try { - internal.run(args); - } catch (Exception e) { - e.printStackTrace(); - } - AAIGraph.getInstance().graphShutdown(); - System.exit(0); - } -} diff --git a/aai-resources/src/main/java/org/onap/aai/migration/MigrationControllerInternal.java b/aai-resources/src/main/java/org/onap/aai/migration/MigrationControllerInternal.java deleted file mode 100644 index 62007c4..0000000 --- a/aai-resources/src/main/java/org/onap/aai/migration/MigrationControllerInternal.java +++ /dev/null @@ -1,477 +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.migration; - -import java.io.File; -import java.io.IOException; -import java.lang.reflect.InvocationTargetException; -import java.nio.file.Files; -import java.nio.file.Path; -import java.nio.file.Paths; -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; -import java.util.Properties; -import java.util.Set; -import java.util.stream.Collectors; - -import org.apache.activemq.broker.BrokerService; -import org.apache.commons.configuration.ConfigurationException; -import org.apache.commons.configuration.PropertiesConfiguration; -import org.apache.commons.lang.exception.ExceptionUtils; -import org.apache.tinkerpop.gremlin.structure.Graph; -import org.apache.tinkerpop.gremlin.structure.io.IoCore; -import org.onap.aai.db.props.AAIProperties; -import org.onap.aai.dbmap.AAIGraph; -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.LoggingContext; -import org.onap.aai.logging.LoggingContext.StatusCode; -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.util.AAIConstants; -import org.onap.aai.util.FormatDate; -import org.reflections.Reflections; -import org.slf4j.MDC; - -import com.att.eelf.configuration.Configuration; -import com.att.eelf.configuration.EELFLogger; -import com.att.eelf.configuration.EELFManager; -import com.beust.jcommander.JCommander; -import com.beust.jcommander.Parameter; - -/** - * Runs a series of migrations from a defined directory based on the presence of - * the {@link org.onap.aai.migration.Enabled Enabled} annotation - * - * It will also write a record of the migrations run to the database. - */ -public class MigrationControllerInternal { - - private EELFLogger logger; - private final int DANGER_ZONE = 10; - private static final String VERTEX_TYPE = "migration-list-" + Version.getLatest().toString(); - private final List<String> resultsSummary = new ArrayList<>(); - private BrokerService broker; - private final List<NotificationHelper> notifications = new ArrayList<>(); - private static final String SNAPSHOT_LOCATION = AAIConstants.AAI_HOME + AAIConstants.AAI_FILESEP + "logs" + AAIConstants.AAI_FILESEP + "data" + AAIConstants.AAI_FILESEP + "migrationSnapshots"; - /** - * The main method. - * - * @param args - * the arguments - */ - public void run(String[] args) { - // Set the logging file properties to be used by EELFManager - System.setProperty("aai.service.name", MigrationController.class.getSimpleName()); - Properties props = System.getProperties(); - props.setProperty(Configuration.PROPERTY_LOGGING_FILE_NAME, "migration-logback.xml"); - props.setProperty(Configuration.PROPERTY_LOGGING_FILE_PATH, AAIConstants.AAI_HOME_ETC_APP_PROPERTIES); - - logger = EELFManager.getInstance().getLogger(MigrationControllerInternal.class.getSimpleName()); - MDC.put("logFilenameAppender", MigrationController.class.getSimpleName()); - - boolean loadSnapshot = false; - - CommandLineArgs cArgs = new CommandLineArgs(); - - JCommander jCommander = new JCommander(cArgs, args); - jCommander.setProgramName(MigrationController.class.getSimpleName()); - - // Set flag to load from snapshot based on the presence of snapshot and - // graph storage backend of inmemory - if (cArgs.dataSnapshot != null && !cArgs.dataSnapshot.isEmpty()) { - try { - PropertiesConfiguration config = new PropertiesConfiguration(cArgs.config); - if (config.getString("storage.backend").equals("inmemory")) { - loadSnapshot = true; - System.setProperty("load.snapshot.file", "true"); - System.setProperty("snapshot.location", cArgs.dataSnapshot); - } - } catch (ConfigurationException e) { - LoggingContext.statusCode(StatusCode.ERROR); - LoggingContext.responseCode(LoggingContext.DATA_ERROR); - logAndPrint("ERROR: Could not load janusgraph configuration.\n" + ExceptionUtils.getFullStackTrace(e)); - return; - } - } - System.setProperty("realtime.db.config", cArgs.config); - logAndPrint("\n\n---------- Connecting to Graph ----------"); - AAIGraph.getInstance(); - - logAndPrint("---------- Connection Established ----------"); - Version version = AAIProperties.LATEST; - QueryStyle queryStyle = QueryStyle.TRAVERSAL; - ModelType introspectorFactoryType = ModelType.MOXY; - Loader loader = LoaderFactory.createLoaderForVersion(introspectorFactoryType, version); - TransactionalGraphEngine engine = new JanusGraphDBEngine(queryStyle, DBConnectionType.REALTIME, loader); - - if (cArgs.help) { - jCommander.usage(); - engine.rollback(); - return; - } - - Reflections reflections = new Reflections("org.onap.aai.migration"); - List<Class<? extends Migrator>> migratorClasses = new ArrayList<>(findClasses(reflections)); - //Displays list of migration classes which needs to be executed.Pass flag "-l" following by the class names - if (cArgs.list) { - listMigrationWithStatus(cArgs, migratorClasses, engine); - return; - } - - logAndPrint("---------- Looking for migration scripts to be executed. ----------"); - //Excluding any migration class when run migration from script.Pass flag "-e" following by the class names - if (!cArgs.excludeClasses.isEmpty()) { - migratorClasses = filterMigrationClasses(cArgs.excludeClasses, migratorClasses); - listMigrationWithStatus(cArgs, migratorClasses, engine); - } - List<Class<? extends Migrator>> migratorClassesToRun = createMigratorList(cArgs, migratorClasses); - - sortList(migratorClassesToRun); - - if (!cArgs.scripts.isEmpty() && migratorClassesToRun.isEmpty()) { - LoggingContext.statusCode(StatusCode.ERROR); - LoggingContext.responseCode(LoggingContext.BUSINESS_PROCESS_ERROR); - logAndPrint("\tERROR: Failed to find migrations " + cArgs.scripts + "."); - logAndPrint("---------- Done ----------"); - LoggingContext.successStatusFields(); - } - - logAndPrint("\tFound " + migratorClassesToRun.size() + " migration scripts."); - logAndPrint("---------- Executing Migration Scripts ----------"); - - - if (!cArgs.skipPreMigrationSnapShot) { - takePreSnapshotIfRequired(engine, cArgs, migratorClassesToRun); - } - - for (Class<? extends Migrator> migratorClass : migratorClassesToRun) { - String name = migratorClass.getSimpleName(); - Migrator migrator; - if (migratorClass.isAnnotationPresent(Enabled.class)) { - - try { - engine.startTransaction(); - if (!cArgs.forced && hasAlreadyRun(name, engine)) { - logAndPrint("Migration " + name + " has already been run on this database and will not be executed again. Use -f to force execution"); - continue; - } - migrator = migratorClass.getConstructor(TransactionalGraphEngine.class).newInstance(engine); - } catch (InstantiationException | IllegalAccessException | IllegalArgumentException | InvocationTargetException | NoSuchMethodException | SecurityException e) { - LoggingContext.statusCode(StatusCode.ERROR); - LoggingContext.responseCode(LoggingContext.DATA_ERROR); - logAndPrint("EXCEPTION caught initalizing migration class " + migratorClass.getSimpleName() + ".\n" + ExceptionUtils.getFullStackTrace(e)); - LoggingContext.successStatusFields(); - engine.rollback(); - continue; - } - logAndPrint("\tRunning " + migratorClass.getSimpleName() + " migration script."); - logAndPrint("\t\t See " + System.getProperty("AJSC_HOME") + "/logs/migration/" + migratorClass.getSimpleName() + "/* for logs."); - MDC.put("logFilenameAppender", migratorClass.getSimpleName() + "/" + migratorClass.getSimpleName()); - - migrator.run(); - - commitChanges(engine, migrator, cArgs); - } else { - logAndPrint("\tSkipping " + migratorClass.getSimpleName() + " migration script because it has been disabled."); - } - } - MDC.put("logFilenameAppender", MigrationController.class.getSimpleName()); - for (NotificationHelper notificationHelper : notifications) { - try { - notificationHelper.triggerEvents(); - } catch (AAIException e) { - LoggingContext.statusCode(StatusCode.ERROR); - LoggingContext.responseCode(LoggingContext.AVAILABILITY_TIMEOUT_ERROR); - logAndPrint("\tcould not event"); - logger.error("could not event", e); - LoggingContext.successStatusFields(); - } - } - logAndPrint("---------- Done ----------"); - - // Save post migration snapshot if snapshot was loaded - if (!cArgs.skipPostMigrationSnapShot) { - generateSnapshot(engine, "post"); - } - - outputResultsSummary(); - } - - /** - * This method is used to remove excluded classes from migration from the - * script command. - * - * @param excludeClasses - * : Classes to be removed from Migration - * @param migratorClasses - * : Classes to execute migration. - * @return - */ - private List<Class<? extends Migrator>> filterMigrationClasses( - List<String> excludeClasses, - List<Class<? extends Migrator>> migratorClasses) { - - List<Class<? extends Migrator>> filteredMigratorClasses = migratorClasses - .stream() - .filter(migratorClass -> !excludeClasses.contains(migratorClass - .getSimpleName())).collect(Collectors.toList()); - - return filteredMigratorClasses; - } - - private void listMigrationWithStatus(CommandLineArgs cArgs, - List<Class<? extends Migrator>> migratorClasses, TransactionalGraphEngine engine) { - sortList(migratorClasses); - engine.startTransaction(); - System.out.println("---------- List of all migrations ----------"); - migratorClasses.forEach(migratorClass -> { - boolean enabledAnnotation = migratorClass.isAnnotationPresent(Enabled.class); - String enabled = enabledAnnotation ? "Enabled" : "Disabled"; - StringBuilder sb = new StringBuilder(); - sb.append(migratorClass.getSimpleName()); - sb.append(" in package "); - sb.append(migratorClass.getPackage().getName().substring(migratorClass.getPackage().getName().lastIndexOf('.')+1)); - sb.append(" is "); - sb.append(enabled); - sb.append(" "); - sb.append("[" + getDbStatus(migratorClass.getSimpleName(), engine) + "]"); - System.out.println(sb.toString()); - }); - engine.rollback(); - System.out.println("---------- Done ----------"); - } - - private String getDbStatus(String name, TransactionalGraphEngine engine) { - if (hasAlreadyRun(name, engine)) { - return "Already executed in this env"; - } - return "Will be run on next execution if Enabled"; - } - - private boolean hasAlreadyRun(String name, TransactionalGraphEngine engine) { - return engine.asAdmin().getReadOnlyTraversalSource().V().has(AAIProperties.NODE_TYPE, VERTEX_TYPE).has(name, true).hasNext(); - } - private Set<Class<? extends Migrator>> findClasses(Reflections reflections) { - Set<Class<? extends Migrator>> migratorClasses = reflections.getSubTypesOf(Migrator.class); - /* - * TODO- Change this to make sure only classes in the specific $release are added in the runList - * Or add a annotation like exclude which folks again need to remember to add ?? - */ - - migratorClasses.remove(PropertyMigrator.class); - migratorClasses.remove(EdgeMigrator.class); - return migratorClasses; - } - - - private void takePreSnapshotIfRequired(TransactionalGraphEngine engine, CommandLineArgs cArgs, List<Class<? extends Migrator>> migratorClassesToRun) { - - /*int sum = 0; - for (Class<? extends Migrator> migratorClass : migratorClassesToRun) { - if (migratorClass.isAnnotationPresent(Enabled.class)) { - sum += migratorClass.getAnnotation(MigrationPriority.class).value(); - } - } - - if (sum >= DANGER_ZONE) { - - logAndPrint("Entered Danger Zone. Taking snapshot."); - }*/ - - //always take snapshot for now - - generateSnapshot(engine, "pre"); - - } - - - private List<Class<? extends Migrator>> createMigratorList(CommandLineArgs cArgs, - List<Class<? extends Migrator>> migratorClasses) { - List<Class<? extends Migrator>> migratorClassesToRun = new ArrayList<>(); - - for (Class<? extends Migrator> migratorClass : migratorClasses) { - if (!cArgs.scripts.isEmpty() && !cArgs.scripts.contains(migratorClass.getSimpleName())) { - continue; - } else { - migratorClassesToRun.add(migratorClass); - } - } - return migratorClassesToRun; - } - - - private void sortList(List<Class<? extends Migrator>> migratorClasses) { - Collections.sort(migratorClasses, (m1, m2) -> { - try { - if (m1.getAnnotation(MigrationPriority.class).value() > m2.getAnnotation(MigrationPriority.class).value()) { - return 1; - } else if (m1.getAnnotation(MigrationPriority.class).value() < m2.getAnnotation(MigrationPriority.class).value()) { - return -1; - } else { - return m1.getSimpleName().compareTo(m2.getSimpleName()); - } - } catch (Exception e) { - return 0; - } - }); - } - - - private void generateSnapshot(TransactionalGraphEngine engine, String phase) { - - FormatDate fd = new FormatDate("yyyyMMddHHmm", "GMT"); - String dateStr= fd.getDateTime(); - String fileName = SNAPSHOT_LOCATION + File.separator + phase + "Migration." + dateStr + ".graphson"; - logAndPrint("Saving snapshot of inmemory graph " + phase + " migration to " + fileName); - Graph transaction = null; - try { - - Path pathToFile = Paths.get(fileName); - if (!pathToFile.toFile().exists()) { - Files.createDirectories(pathToFile.getParent()); - } - transaction = engine.startTransaction(); - transaction.io(IoCore.graphson()).writeGraph(fileName); - engine.rollback(); - } catch (IOException e) { - LoggingContext.statusCode(StatusCode.ERROR); - LoggingContext.responseCode(LoggingContext.AVAILABILITY_TIMEOUT_ERROR); - logAndPrint("ERROR: Could not write in memory graph to " + phase + "Migration file. \n" + ExceptionUtils.getFullStackTrace(e)); - LoggingContext.successStatusFields(); - engine.rollback(); - } - - logAndPrint( phase + " migration snapshot saved to " + fileName); - } - /** - * Log and print. - * - * @param msg - * the msg - */ - protected void logAndPrint(String msg) { - System.out.println(msg); - logger.info(msg); - } - - /** - * Commit changes. - * - * @param engine - * the graph transaction - * @param migrator - * the migrator - * @param cArgs - */ - protected void commitChanges(TransactionalGraphEngine engine, Migrator migrator, CommandLineArgs cArgs) { - - String simpleName = migrator.getClass().getSimpleName(); - String message; - if (migrator.getStatus().equals(Status.FAILURE)) { - message = "Migration " + simpleName + " Failed. Rolling back."; - LoggingContext.statusCode(StatusCode.ERROR); - LoggingContext.responseCode(LoggingContext.DATA_ERROR); - logAndPrint("\t" + message); - LoggingContext.successStatusFields(); - migrator.rollback(); - } else if (migrator.getStatus().equals(Status.CHECK_LOGS)) { - message = "Migration " + simpleName + " encountered an anomaly, check logs. Rolling back."; - LoggingContext.statusCode(StatusCode.ERROR); - LoggingContext.responseCode(LoggingContext.DATA_ERROR); - logAndPrint("\t" + message); - LoggingContext.successStatusFields(); - migrator.rollback(); - } else { - MDC.put("logFilenameAppender", simpleName + "/" + simpleName); - - if (cArgs.commit) { - if (!engine.asAdmin().getTraversalSource().V().has(AAIProperties.NODE_TYPE, VERTEX_TYPE).hasNext()) { - engine.asAdmin().getTraversalSource().addV(AAIProperties.NODE_TYPE, VERTEX_TYPE).iterate(); - } - engine.asAdmin().getTraversalSource().V().has(AAIProperties.NODE_TYPE, VERTEX_TYPE) - .property(simpleName, true).iterate(); - MDC.put("logFilenameAppender", MigrationController.class.getSimpleName()); - notifications.add(migrator.getNotificationHelper()); - migrator.commit(); - message = "Migration " + simpleName + " Succeeded. Changes Committed."; - logAndPrint("\t"+ message +"\t"); - } else { - message = "--commit not specified. Not committing changes for " + simpleName + " to database."; - logAndPrint("\t" + message); - migrator.rollback(); - } - - } - - resultsSummary.add(message); - - } - - private void outputResultsSummary() { - logAndPrint("---------------------------------"); - logAndPrint("-------------Summary-------------"); - for (String result : resultsSummary) { - logAndPrint(result); - } - logAndPrint("---------------------------------"); - logAndPrint("---------------------------------"); - } - -} - -class CommandLineArgs { - - @Parameter(names = "--help", help = true) - public boolean help; - - @Parameter(names = "-c", description = "location of configuration file") - public String config; - - @Parameter(names = "-m", description = "names of migration scripts") - public List<String> scripts = new ArrayList<>(); - - @Parameter(names = "-l", description = "list the status of migrations") - public boolean list = false; - - @Parameter(names = "-d", description = "location of data snapshot", hidden = true) - public String dataSnapshot; - - @Parameter(names = "-f", description = "force migrations to be rerun") - public boolean forced = false; - - @Parameter(names = "--commit", description = "commit changes to graph") - public boolean commit = false; - - @Parameter(names = "-e", description = "exclude list of migrator classes") - public List<String> excludeClasses = new ArrayList<>(); - - @Parameter(names = "--skipPreMigrationSnapShot", description = "skips taking the PRE migration snapshot") - public boolean skipPreMigrationSnapShot = false; - - @Parameter(names = "--skipPostMigrationSnapShot", description = "skips taking the POST migration snapshot") - public boolean skipPostMigrationSnapShot = false; -} diff --git a/aai-resources/src/main/java/org/onap/aai/migration/MigrationDangerRating.java b/aai-resources/src/main/java/org/onap/aai/migration/MigrationDangerRating.java deleted file mode 100644 index 1d82dc3..0000000 --- a/aai-resources/src/main/java/org/onap/aai/migration/MigrationDangerRating.java +++ /dev/null @@ -1,41 +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.migration; - -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - - -/** - * Used to enable a migration to be picked up by the {@link com.openecomp.aai.migration.MigrationControllerInternal MigrationController} - * - * The larger the number, the more danger - * - * Range is 0-10 - */ -@Target(ElementType.TYPE) -@Retention(value = RetentionPolicy.RUNTIME) -public @interface MigrationDangerRating { - - int value(); - -} diff --git a/aai-resources/src/main/java/org/onap/aai/migration/MigrationPriority.java b/aai-resources/src/main/java/org/onap/aai/migration/MigrationPriority.java deleted file mode 100644 index 974b9c6..0000000 --- a/aai-resources/src/main/java/org/onap/aai/migration/MigrationPriority.java +++ /dev/null @@ -1,41 +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.migration; - -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - - -/** - * Used to enable a migration to be picked up by the {@link com.openecomp.aai.migration.MigrationControllerInternal MigrationController} - * - * The priority of the migration. - * - * Lower number has higher priority - */ -@Target(ElementType.TYPE) -@Retention(value = RetentionPolicy.RUNTIME) -public @interface MigrationPriority { - - int value(); - -} diff --git a/aai-resources/src/main/java/org/onap/aai/migration/Migrator.java b/aai-resources/src/main/java/org/onap/aai/migration/Migrator.java deleted file mode 100644 index fa6a88a..0000000 --- a/aai-resources/src/main/java/org/onap/aai/migration/Migrator.java +++ /dev/null @@ -1,281 +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.migration; - -import java.util.Collections; -import java.util.Iterator; -import java.util.Optional; - -import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.__; -import org.apache.tinkerpop.gremlin.structure.Direction; -import org.apache.tinkerpop.gremlin.structure.Edge; -import org.apache.tinkerpop.gremlin.structure.Property; -import org.apache.tinkerpop.gremlin.structure.Vertex; -import org.apache.tinkerpop.gremlin.structure.VertexProperty; -import org.json.JSONException; -import org.json.JSONObject; -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.Version; -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.db.exceptions.NoEdgeRuleFoundException; -import org.onap.aai.serialization.engines.TransactionalGraphEngine; - -import com.att.eelf.configuration.EELFLogger; -import com.att.eelf.configuration.EELFManager; - -/** - * This class defines an A&AI Migration - */ -@MigrationPriority(0) -@MigrationDangerRating(0) -public abstract class Migrator implements Runnable { - - protected EELFLogger logger = null; - - protected DBSerializer serializer = null; - protected Loader loader = null; - - protected TransactionalGraphEngine engine; - protected NotificationHelper notificationHelper; - - /** - * Instantiates a new migrator. - * - * @param g the g - */ - public Migrator(TransactionalGraphEngine engine){ - this.engine = engine; - initDBSerializer(); - this.notificationHelper = new NotificationHelper(loader, serializer, engine, "AAI-MIGRATION", this.getMigrationName()); - logger = EELFManager.getInstance().getLogger(this.getClass().getSimpleName()); - logger.info("\tInitilization of " + this.getClass().getSimpleName() + " migration script complete."); - } - - /** - * Gets the status. - * - * @return the status - */ - public abstract Status getStatus(); - - /** - * Rollback. - */ - public void rollback() { - engine.rollback(); - } - - /** - * Commit. - */ - public void commit() { - engine.commit(); - } - - - /** - * As string. - * - * @param v the v - * @return the string - */ - protected String asString(Vertex v) { - final JSONObject result = new JSONObject(); - Iterator<VertexProperty<Object>> properties = v.properties(); - Property<Object> pk = null; - try { - while (properties.hasNext()) { - pk = properties.next(); - result.put(pk.key(), pk.value()); - } - } catch (JSONException e) { - logger.error("Warning error reading vertex: " + e); - } - - return result.toString(); - } - - /** - * As string. - * - * @param edge the edge - * @return the string - */ - protected String asString(Edge edge) { - final JSONObject result = new JSONObject(); - Iterator<Property<Object>> properties = edge.properties(); - Property<Object> pk = null; - try { - while (properties.hasNext()) { - pk = properties.next(); - result.put(pk.key(), pk.value()); - } - } catch (JSONException e) { - logger.error("Warning error reading edge: " + e); - } - - return result.toString(); - } - - /** - * - * @param v - * @param numLeadingTabs number of leading \t char's - * @return - */ - protected String toStringForPrinting(Vertex v, int numLeadingTabs) { - String prefix = String.join("", Collections.nCopies(numLeadingTabs, "\t")); - if (v == null) { - return ""; - } - final StringBuilder sb = new StringBuilder(); - sb.append(prefix + v + "\n"); - v.properties().forEachRemaining(prop -> sb.append(prefix + prop + "\n")); - return sb.toString(); - } - - /** - * - * @param e - * @param numLeadingTabs number of leading \t char's - * @return - */ - protected String toStringForPrinting(Edge e, int numLeadingTabs) { - String prefix = String.join("", Collections.nCopies(numLeadingTabs, "\t")); - if (e == null) { - return ""; - } - final StringBuilder sb = new StringBuilder(); - sb.append(prefix + e + "\n"); - sb.append(prefix + e.label() + "\n"); - e.properties().forEachRemaining(prop -> sb.append(prefix + "\t" + prop + "\n")); - return sb.toString(); - } - - /** - * Checks for edge between. - * - * @param a a - * @param b b - * @param d d - * @param edgeLabel the edge label - * @return true, if successful - */ - protected boolean hasEdgeBetween(Vertex a, Vertex b, Direction d, String edgeLabel) { - - if (d.equals(Direction.OUT)) { - return engine.asAdmin().getReadOnlyTraversalSource().V(a).out(edgeLabel).where(__.otherV().hasId(b)).hasNext(); - } else { - return engine.asAdmin().getReadOnlyTraversalSource().V(a).in(edgeLabel).where(__.otherV().hasId(b)).hasNext(); - } - - } - - /** - * Creates the edge - * - * @param type the edge type - COUSIN or TREE - * @param out the out - * @param in the in - * @return the edge - */ - protected Edge createEdge(EdgeType type, Vertex out, Vertex in) throws AAIException { - Edge newEdge = null; - try { - if (type.equals(EdgeType.COUSIN)){ - newEdge = EdgeRules.getInstance().addEdge(this.engine.asAdmin().getTraversalSource(), out, in); - } else { - newEdge = EdgeRules.getInstance().addTreeEdge(this.engine.asAdmin().getTraversalSource(), out, in); - } - } catch (NoEdgeRuleFoundException e) { - throw new AAIException("AAI_6129", e); - } - return newEdge; - } - - /** - * Creates the TREE edge - * - * @param out the out - * @param in the in - * @return the edge - */ - protected Edge createTreeEdge(Vertex out, Vertex in) throws AAIException { - Edge newEdge = createEdge(EdgeType.TREE, out, in); - return newEdge; - } - - /** - * Creates the COUSIN edge - * - * @param out the out - * @param in the in - * @return the edge - */ - protected Edge createCousinEdge(Vertex out, Vertex in) throws AAIException { - Edge newEdge = createEdge(EdgeType.COUSIN, out, in); - return newEdge; - } - - protected Edge createCousinEdgeBestEffort(Vertex out, Vertex in) throws AAIException { - return EdgeRules.getInstance().addEdgeIfPossible(this.engine.asAdmin().getTraversalSource(), out, in); - } - private void initDBSerializer() { - Version version = AAIProperties.LATEST; - ModelType introspectorFactoryType = ModelType.MOXY; - loader = LoaderFactory.createLoaderForVersion(introspectorFactoryType, version); - try { - this.serializer = new DBSerializer(version, this.engine, introspectorFactoryType, this.getMigrationName()); - } catch (AAIException e) { - throw new RuntimeException("could not create seralizer", e); - } - } - - /** - * These are the node types you would like your traversal to process - * @return - */ - public abstract Optional<String[]> getAffectedNodeTypes(); - - /** - * used as the "fromAppId" when modifying vertices - * @return - */ - public abstract String getMigrationName(); - - /** - * updates all internal vertex properties - * @param v - * @param isNewVertex - */ - protected void touchVertexProperties(Vertex v, boolean isNewVertex) { - this.serializer.touchStandardVertexProperties(v, isNewVertex); - } - - public NotificationHelper getNotificationHelper() { - return this.notificationHelper; - } -} diff --git a/aai-resources/src/main/java/org/onap/aai/migration/NotificationHelper.java b/aai-resources/src/main/java/org/onap/aai/migration/NotificationHelper.java deleted file mode 100644 index 3319a08..0000000 --- a/aai-resources/src/main/java/org/onap/aai/migration/NotificationHelper.java +++ /dev/null @@ -1,105 +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.migration; - -import java.io.UnsupportedEncodingException; -import java.net.URI; -import java.util.HashMap; -import java.util.List; - -import javax.ws.rs.core.Response.Status; - -import org.apache.tinkerpop.gremlin.structure.Vertex; -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.rest.ueb.UEBNotification; -import org.onap.aai.serialization.db.DBSerializer; -import org.onap.aai.serialization.engines.TransactionalGraphEngine; -import org.onap.aai.serialization.engines.query.QueryEngine; - -import com.att.eelf.configuration.EELFLogger; -import com.att.eelf.configuration.EELFManager; - -/** - * Allows for DMaaP notifications from Migrations - */ -public class NotificationHelper { - - private static final EELFLogger LOGGER = EELFManager.getInstance().getLogger(NotificationHelper.class); - protected final DBSerializer serializer; - protected final Loader loader; - protected final TransactionalGraphEngine engine; - protected final String transactionId; - protected final String sourceOfTruth; - protected final UEBNotification notification; - - public NotificationHelper(Loader loader, DBSerializer serializer, TransactionalGraphEngine engine, String transactionId, String sourceOfTruth) { - this.loader = loader; - this.serializer = serializer; - this.engine = engine; - this.transactionId = transactionId; - this.sourceOfTruth = sourceOfTruth; - this.notification = new UEBNotification(loader); - } - - public void addEvent(Vertex v, Introspector obj, EventAction action, URI uri) throws UnsupportedEncodingException, AAIException { - HashMap<String, Introspector> relatedObjects = new HashMap<>(); - Status status = mapAction(action); - if (!obj.isTopLevel()) { - relatedObjects = this.getRelatedObjects(serializer, engine.getQueryEngine(), v); - } - notification.createNotificationEvent(transactionId, sourceOfTruth, status, uri, obj, relatedObjects); - - } - - private HashMap<String, Introspector> getRelatedObjects(DBSerializer serializer, QueryEngine queryEngine, Vertex v) throws AAIException { - HashMap<String, Introspector> relatedVertices = new HashMap<>(); - List<Vertex> vertexChain = queryEngine.findParents(v); - for (Vertex vertex : vertexChain) { - try { - final Introspector vertexObj = serializer.getVertexProperties(vertex); - relatedVertices.put(vertexObj.getObjectId(), vertexObj); - } catch (AAIUnknownObjectException | UnsupportedEncodingException e) { - LOGGER.warn("Unable to get vertex properties, partial list of related vertices returned"); - } - - } - - return relatedVertices; - } - - private Status mapAction(EventAction action) { - if (EventAction.CREATE.equals(action)) { - return Status.CREATED; - } else if (EventAction.UPDATE.equals(action)) { - return Status.OK; - } else if (EventAction.DELETE.equals(action)) { - return Status.NO_CONTENT; - } else { - return Status.OK; - } - } - - public void triggerEvents() throws AAIException { - notification.triggerEvents(); - } -} diff --git a/aai-resources/src/main/java/org/onap/aai/migration/PropertyMigrator.java b/aai-resources/src/main/java/org/onap/aai/migration/PropertyMigrator.java deleted file mode 100644 index ed43724..0000000 --- a/aai-resources/src/main/java/org/onap/aai/migration/PropertyMigrator.java +++ /dev/null @@ -1,132 +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.migration; - -import java.util.Optional; - -import org.apache.tinkerpop.gremlin.process.traversal.P; -import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversal; -import org.apache.tinkerpop.gremlin.structure.Vertex; -import org.onap.aai.db.props.AAIProperties; -import org.onap.aai.serialization.engines.TransactionalGraphEngine; - -import org.janusgraph.core.Cardinality; -import org.janusgraph.core.PropertyKey; -import org.janusgraph.core.schema.JanusGraphManagement; - -/** - * A migration template for migrating a property from one name to another - */ -@MigrationPriority(0) -@MigrationDangerRating(1) -public abstract class PropertyMigrator extends Migrator { - - protected final String OLD_FIELD; - protected final String NEW_FIELD; - protected final Class<?> fieldType; - protected final Cardinality cardinality; - protected final JanusGraphManagement graphMgmt; - - public PropertyMigrator(TransactionalGraphEngine engine, String oldName, String newName, Class<?> type, Cardinality cardinality) { - super(engine); - this.OLD_FIELD = oldName; - this.NEW_FIELD = newName; - this.fieldType = type; - this.cardinality = cardinality; - this.graphMgmt = engine.asAdmin().getManagementSystem(); - } - - /** - * Do not override this method as an inheritor of this class - */ - @Override - public void run() { - - modifySchema(); - executeModifyOperation(); - - } - - protected void modifySchema() { - this.addIndex(this.addProperty()); - graphMgmt.commit(); - } - - /** - * This is where inheritors should add their logic - */ - protected void executeModifyOperation() { - changePropertyName(); - } - - protected void changePropertyName() { - GraphTraversal<Vertex, Vertex> g = this.engine.asAdmin().getTraversalSource().V(); - if (this.getAffectedNodeTypes().isPresent()) { - g.has(AAIProperties.NODE_TYPE, P.within(this.getAffectedNodeTypes().get())); - } - g.has(OLD_FIELD).sideEffect(t -> { - final Vertex v = t.get(); - final String value = v.value(OLD_FIELD); - v.property(OLD_FIELD).remove(); - v.property(NEW_FIELD, value); - this.touchVertexProperties(v, false); - }).iterate(); - } - - @Override - public Status getStatus() { - GraphTraversal<Vertex, Vertex> g = this.engine.asAdmin().getTraversalSource().V(); - if (this.getAffectedNodeTypes().isPresent()) { - g.has(AAIProperties.NODE_TYPE, P.within(this.getAffectedNodeTypes().get())); - } - long result = g.has(OLD_FIELD).count().next(); - if (result == 0) { - return Status.SUCCESS; - } else { - return Status.FAILURE; - } - } - - protected Optional<PropertyKey> addProperty() { - - if (!graphMgmt.containsPropertyKey(this.NEW_FIELD)) { - logger.info(" PropertyKey [" + this.NEW_FIELD + "] created in the DB. "); - return Optional.of(graphMgmt.makePropertyKey(this.NEW_FIELD).dataType(this.fieldType).cardinality(this.cardinality) - .make()); - } else { - logger.info(" PropertyKey [" + this.NEW_FIELD + "] already existed in the DB. "); - return Optional.empty(); - } - - } - - protected void addIndex(Optional<PropertyKey> key) { - if (isIndexed() && key.isPresent()) { - if (graphMgmt.containsGraphIndex(key.get().name())) { - logger.debug(" Index [" + key.get().name() + "] already existed in the DB. "); - } else { - logger.info("Add index for PropertyKey: [" + key.get().name() + "]"); - graphMgmt.buildIndex(key.get().name(), Vertex.class).addKey(key.get()).buildCompositeIndex(); - } - } - } - public abstract boolean isIndexed(); - -} diff --git a/aai-resources/src/main/java/org/onap/aai/migration/Status.java b/aai-resources/src/main/java/org/onap/aai/migration/Status.java deleted file mode 100644 index 0338594..0000000 --- a/aai-resources/src/main/java/org/onap/aai/migration/Status.java +++ /dev/null @@ -1,29 +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.migration; - -/** - * Defines the status of the completed migration - */ -public enum Status { - SUCCESS, - CHECK_LOGS, - FAILURE -} diff --git a/aai-resources/src/main/java/org/onap/aai/migration/ValueMigrator.java b/aai-resources/src/main/java/org/onap/aai/migration/ValueMigrator.java deleted file mode 100644 index eb562a2..0000000 --- a/aai-resources/src/main/java/org/onap/aai/migration/ValueMigrator.java +++ /dev/null @@ -1,100 +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.migration; - -import java.util.Map; -import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversal; -import org.apache.tinkerpop.gremlin.structure.Vertex; -import org.onap.aai.db.props.AAIProperties; -import org.onap.aai.serialization.engines.TransactionalGraphEngine; -import org.janusgraph.core.schema.JanusGraphManagement; - -/** - * A migration template for filling in default values that are missing or are empty - */ -@MigrationPriority(0) -@MigrationDangerRating(1) -public abstract class ValueMigrator extends Migrator { - - protected final Map<String, Map<String, ?>> propertyValuePairByNodeType; - protected final Boolean updateExistingValues; - protected final JanusGraphManagement graphMgmt; - - /** - * - * @param engine - * @param propertyValuePairByNodeType - format {nodeType: { property: newValue}} - * @param updateExistingValues - if true, updates the value regardless if it already exists - */ - public ValueMigrator(TransactionalGraphEngine engine, Map propertyValuePairByNodeType, Boolean updateExistingValues) { - super(engine); - this.propertyValuePairByNodeType = propertyValuePairByNodeType; - this.updateExistingValues = updateExistingValues; - this.graphMgmt = engine.asAdmin().getManagementSystem(); - } - - /** - * Do not override this method as an inheritor of this class - */ - @Override - public void run() { - updateValues(); - } - - protected void updateValues() { - for (Map.Entry<String, Map<String, ?>> entry: propertyValuePairByNodeType.entrySet()) { - String nodeType = entry.getKey(); - Map<String, ?> propertyValuePair = entry.getValue(); - for (Map.Entry<String, ?> pair : propertyValuePair.entrySet()) { - String property = pair.getKey(); - Object newValue = pair.getValue(); - try { - GraphTraversal<Vertex, Vertex> g = this.engine.asAdmin().getTraversalSource().V() - .has(AAIProperties.NODE_TYPE, nodeType); - while (g.hasNext()) { - Vertex v = g.next(); - if (v.property(property).isPresent() && !updateExistingValues) { - String propertyValue = v.property(property).value().toString(); - if (propertyValue.isEmpty()) { - v.property(property, newValue); - logger.info(String.format("Node Type %s: Property %s is empty, adding value %s", - nodeType, property, newValue.toString())); - this.touchVertexProperties(v, false); - } else { - logger.info(String.format("Node Type %s: Property %s value already exists - skipping", - nodeType, property)); - } - } else { - logger.info(String.format("Node Type %s: Property %s does not exist or " + - "updateExistingValues flag is set to True - adding the property with value %s", - nodeType, property, newValue.toString())); - v.property(property, newValue); - this.touchVertexProperties(v, false); - } - } - } catch (Exception e) { - logger.error(String.format("caught exception updating aai-node-type %s's property %s's value to " + - "%s: %s", nodeType, property, newValue.toString(), e.getMessage())); - logger.error(e.getMessage()); - } - } - } - } -} diff --git a/aai-resources/src/main/java/org/onap/aai/migration/VertexMerge.java b/aai-resources/src/main/java/org/onap/aai/migration/VertexMerge.java deleted file mode 100644 index 304be1e..0000000 --- a/aai-resources/src/main/java/org/onap/aai/migration/VertexMerge.java +++ /dev/null @@ -1,244 +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.migration; - -import java.io.UnsupportedEncodingException; -import java.util.Collection; -import java.util.Collections; -import java.util.HashMap; -import java.util.HashSet; -import java.util.Iterator; -import java.util.Map; -import java.util.Optional; -import java.util.Set; - -import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource; -import org.apache.tinkerpop.gremlin.structure.Vertex; - -import org.onap.aai.db.props.AAIProperties; -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.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 com.att.eelf.configuration.EELFLogger; -import com.att.eelf.configuration.EELFManager; - -/** - * This class recursively merges two vertices passed in. - * <br> - * You can start with any two vertices, but after the vertices are merged based off the equality of their keys - * - */ -public class VertexMerge { - - private final EELFLogger logger = EELFManager.getInstance().getLogger(this.getClass().getSimpleName()); - - private final GraphTraversalSource g; - private final TransactionalGraphEngine engine; - private final DBSerializer serializer; - private final EdgeRules rules; - private final Loader loader; - private final NotificationHelper notificationHelper; - private final boolean hasNotifications; - private VertexMerge(Builder builder) { - this.engine = builder.getEngine(); - this.serializer = builder.getSerializer(); - this.g = engine.asAdmin().getTraversalSource(); - this.rules = EdgeRules.getInstance(); - this.loader = builder.getLoader(); - this.notificationHelper = builder.getHelper(); - this.hasNotifications = builder.isHasNotifications(); - } - - /** - * Merges vertices. forceCopy is a map of the form [{aai-node-type}:{set of properties}] - * @param primary - * @param secondary - * @param forceCopy - * @throws AAIException - * @throws UnsupportedEncodingException - */ - public void performMerge(Vertex primary, Vertex secondary, Map<String, Set<String>> forceCopy) throws AAIException, UnsupportedEncodingException { - final Optional<Introspector> secondarySnapshot; - if (this.hasNotifications) { - secondarySnapshot = Optional.of(serializer.getLatestVersionView(secondary)); - } else { - secondarySnapshot = Optional.empty(); - } - mergeProperties(primary, secondary, forceCopy); - - Collection<Vertex> secondaryChildren = this.engine.getQueryEngine().findChildren(secondary); - Collection<Vertex> primaryChildren = this.engine.getQueryEngine().findChildren(primary); - - mergeChildren(primary, secondary, primaryChildren, secondaryChildren, forceCopy); - - Collection<Vertex> secondaryCousins = this.engine.getQueryEngine().findCousinVertices(secondary); - Collection<Vertex> primaryCousins = this.engine.getQueryEngine().findCousinVertices(primary); - - secondaryCousins.removeAll(primaryCousins); - logger.info("removing vertex after merge: " + secondary ); - if (this.hasNotifications && secondarySnapshot.isPresent()) { - this.notificationHelper.addEvent(secondary, secondarySnapshot.get(), EventAction.DELETE, this.serializer.getURIForVertex(secondary, false)); - } - secondary.remove(); - for (Vertex v : secondaryCousins) { - this.rules.addEdgeIfPossible(g, v, primary); - } - if (this.hasNotifications) { - final Introspector primarySnapshot = serializer.getLatestVersionView(primary); - this.notificationHelper.addEvent(primary, primarySnapshot, EventAction.UPDATE, this.serializer.getURIForVertex(primary, false)); - } - } - - /** - * This method may go away if we choose to event on each modification performed - * @param primary - * @param secondary - * @param forceCopy - * @throws AAIException - * @throws UnsupportedEncodingException - */ - protected void performMergeHelper(Vertex primary, Vertex secondary, Map<String, Set<String>> forceCopy) throws AAIException, UnsupportedEncodingException { - mergeProperties(primary, secondary, forceCopy); - - Collection<Vertex> secondaryChildren = this.engine.getQueryEngine().findChildren(secondary); - Collection<Vertex> primaryChildren = this.engine.getQueryEngine().findChildren(primary); - - mergeChildren(primary, secondary, primaryChildren, secondaryChildren, forceCopy); - - Collection<Vertex> secondaryCousins = this.engine.getQueryEngine().findCousinVertices(secondary); - Collection<Vertex> primaryCousins = this.engine.getQueryEngine().findCousinVertices(primary); - - secondaryCousins.removeAll(primaryCousins); - secondary.remove(); - for (Vertex v : secondaryCousins) { - this.rules.addEdgeIfPossible(g, v, primary); - } - } - - private String getURI(Vertex v) throws UnsupportedEncodingException, AAIException { - Introspector obj = loader.introspectorFromName(v.<String>property(AAIProperties.NODE_TYPE).orElse("")); - this.serializer.dbToObject(Collections.singletonList(v), obj, 0, true, "false"); - return obj.getURI(); - - } - private void mergeChildren(Vertex primary, Vertex secondary, Collection<Vertex> primaryChildren, Collection<Vertex> secondaryChildren, Map<String, Set<String>> forceCopy) throws UnsupportedEncodingException, AAIException { - Map<String, Vertex> primaryMap = uriMap(primaryChildren); - Map<String, Vertex> secondaryMap = uriMap(secondaryChildren); - Set<String> primaryKeys = new HashSet<>(primaryMap.keySet()); - Set<String> secondaryKeys = new HashSet<>(secondaryMap.keySet()); - primaryKeys.retainAll(secondaryKeys); - final Set<String> mergeItems = new HashSet<>(primaryKeys); - primaryKeys = new HashSet<>(primaryMap.keySet()); - secondaryKeys = new HashSet<>(secondaryMap.keySet()); - secondaryKeys.removeAll(primaryKeys); - final Set<String> copyItems = new HashSet<>(secondaryKeys); - - for (String key : mergeItems) { - this.performMergeHelper(primaryMap.get(key), secondaryMap.get(key), forceCopy); - } - - for (String key : copyItems) { - this.rules.addTreeEdgeIfPossible(g, secondaryMap.get(key), primary); - this.serializer.getEdgeBetween(EdgeType.TREE, secondary, secondaryMap.get(key)).remove(); - } - - } - - private Map<String, Vertex> uriMap(Collection<Vertex> vertices) throws UnsupportedEncodingException, AAIException { - final Map<String, Vertex> result = new HashMap<>(); - for (Vertex v : vertices) { - result.put(getURI(v), v); - } - return result; - } - - private void mergeProperties(Vertex primary, Vertex secondary, Map<String, Set<String>> forceCopy) throws AAIUnknownObjectException { - final String primaryType = primary.<String>property(AAIProperties.NODE_TYPE).orElse(""); - final String secondaryType = secondary.<String>property(AAIProperties.NODE_TYPE).orElse(""); - - final Introspector secondaryObj = loader.introspectorFromName(secondaryType); - secondary.properties().forEachRemaining(prop -> { - if (!primary.property(prop.key()).isPresent() || forceCopy.getOrDefault(primaryType, new HashSet<String>()).contains(prop.key())) { - primary.property(prop.key(), prop.value()); - } - if (primary.property(prop.key()).isPresent() && secondary.property(prop.key()).isPresent() && secondaryObj.isListType(prop.key())) { - mergeCollection(primary, prop.key(), secondary.values(prop.key())); - } - }); - } - private void mergeCollection(Vertex primary, String propName, Iterator<Object> secondaryValues) { - secondaryValues.forEachRemaining(item -> { - primary.property(propName, item); - }); - } - - - public static class Builder { - private final TransactionalGraphEngine engine; - - private final DBSerializer serializer; - private final Loader loader; - private NotificationHelper helper = null; - private boolean hasNotifications = false; - public Builder(Loader loader, TransactionalGraphEngine engine, DBSerializer serializer) { - this.loader = loader; - this.engine = engine; - this.serializer = serializer; - } - - public Builder addNotifications(NotificationHelper helper) { - this.helper = helper; - this.hasNotifications = true; - return this; - } - - - public VertexMerge build() { - return new VertexMerge(this); - } - - protected TransactionalGraphEngine getEngine() { - return engine; - } - - protected DBSerializer getSerializer() { - return serializer; - } - - protected Loader getLoader() { - return loader; - } - - protected NotificationHelper getHelper() { - return helper; - } - - protected boolean isHasNotifications() { - return hasNotifications; - } - - } - -} diff --git a/aai-resources/src/main/java/org/onap/aai/migration/v12/ContainmentDeleteOtherVPropertyMigration.java b/aai-resources/src/main/java/org/onap/aai/migration/v12/ContainmentDeleteOtherVPropertyMigration.java deleted file mode 100644 index cc35a3d..0000000 --- a/aai-resources/src/main/java/org/onap/aai/migration/v12/ContainmentDeleteOtherVPropertyMigration.java +++ /dev/null @@ -1,104 +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.migration.v12; - -import java.util.Optional; - -import org.apache.commons.lang.exception.ExceptionUtils; -import org.apache.tinkerpop.gremlin.structure.Edge; -import org.onap.aai.migration.MigrationDangerRating; -import org.onap.aai.migration.Enabled; -import org.onap.aai.migration.MigrationPriority; -import org.onap.aai.migration.Migrator; -import org.onap.aai.migration.Status; -import org.onap.aai.serialization.db.AAIDirection; -import org.onap.aai.serialization.db.EdgeProperty; -import org.onap.aai.serialization.engines.TransactionalGraphEngine; - - - -@Enabled -@MigrationPriority(-100) -@MigrationDangerRating(10) -public class ContainmentDeleteOtherVPropertyMigration extends Migrator { - - private boolean success = true; - - public ContainmentDeleteOtherVPropertyMigration(TransactionalGraphEngine engine) { - super(engine); - } - - //just for testing using test edge rule files - public ContainmentDeleteOtherVPropertyMigration(TransactionalGraphEngine engine, String edgeRulesFile) { - super(engine); - } - - @Override - public void run() { - try { - engine.asAdmin().getTraversalSource().E().sideEffect(t -> { - Edge e = t.get(); - logger.info("out vertex: " + e.outVertex().property("aai-node-type").value() + - " in vertex: " + e.inVertex().property("aai-node-type").value() + - " label : " + e.label()); - if (e.property(EdgeProperty.CONTAINS.toString()).isPresent() && - e.property(EdgeProperty.DELETE_OTHER_V.toString()).isPresent()) { - //in case of orphans - if (!("constrained-element-set".equals(e.inVertex().property("aai-node-type").value()) - && "model-element".equals(e.outVertex().property("aai-node-type").value()))) { - //skip the weird horrible problem child edge - String containment = (String) e.property(EdgeProperty.CONTAINS.toString()).value(); - if (AAIDirection.OUT.toString().equalsIgnoreCase(containment) || - AAIDirection.IN.toString().equalsIgnoreCase(containment) || - AAIDirection.BOTH.toString().equalsIgnoreCase(containment)) { - logger.info("updating delete-other-v property"); - e.property(EdgeProperty.DELETE_OTHER_V.toString(), containment); - } - } - } - }).iterate(); - } catch (Exception e) { - logger.info("error encountered " + e.getClass() + " " + e.getMessage() + " " + ExceptionUtils.getFullStackTrace(e)); - logger.error("error encountered " + e.getClass() + " " + e.getMessage() + " " + ExceptionUtils.getFullStackTrace(e)); - success = false; - } - - } - - @Override - public Status getStatus() { - if (success) { - return Status.SUCCESS; - } else { - return Status.FAILURE; - } - } - - @Override - public Optional<String[]> getAffectedNodeTypes() { - return Optional.empty(); - } - - @Override - public String getMigrationName() { - return "migrate-containment-delete-other-v"; - } - -} diff --git a/aai-resources/src/main/java/org/onap/aai/migration/v12/EdgeReportForToscaMigration.java b/aai-resources/src/main/java/org/onap/aai/migration/v12/EdgeReportForToscaMigration.java deleted file mode 100644 index 2ff916c..0000000 --- a/aai-resources/src/main/java/org/onap/aai/migration/v12/EdgeReportForToscaMigration.java +++ /dev/null @@ -1,141 +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.migration.v12; - -import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource; -import org.apache.tinkerpop.gremlin.structure.Edge; -import org.apache.tinkerpop.gremlin.structure.Vertex; -import org.onap.aai.migration.*; -import org.onap.aai.serialization.db.EdgeRules; -import org.onap.aai.serialization.engines.TransactionalGraphEngine; - -import java.util.*; - -@Enabled -@MigrationPriority(0) -@MigrationDangerRating(0) -public class EdgeReportForToscaMigration extends Migrator { - - private boolean success = true; - EdgeRules ers = EdgeRules.getInstance(); - - public EdgeReportForToscaMigration(TransactionalGraphEngine graphEngine){ - super(graphEngine); - } - - @Override - public Status getStatus() { - if (success) { - return Status.SUCCESS; - } else { - return Status.FAILURE; - } - } - - @Override - public void run() { - Vertex out = null; - Vertex in = null; - String label = ""; - String outURI = ""; - String inURI = ""; - String parentCousinIndicator = "NONE"; - String oldEdgeString = null; - List<String> edgeMissingParentProperty = new ArrayList<>(); - StringBuilder sb = new StringBuilder(); - Set<String> noURI = new HashSet<>(); - sb.append("----------EDGES----------\n"); - - GraphTraversalSource g = engine.asAdmin().getTraversalSource(); - - try { - Set<Edge> edges = g.E().toSet(); - for (Edge edge : edges) { - out = edge.outVertex(); - in = edge.inVertex(); - label = edge.label(); - outURI = this.getVertexURI(out); - inURI = this.getVertexURI(in); - parentCousinIndicator = "NONE"; - oldEdgeString = this.toStringForPrinting(edge, 1); - - if (!outURI.startsWith("/")) { - noURI.add(outURI); - } - if (!inURI.startsWith("/")) { - noURI.add(inURI); - } - - if (out == null || in == null) { - logger.error(edge.id() + " invalid because one vertex was null: out=" + edge.outVertex() + " in=" + edge.inVertex()); - } else { - - if (edge.property("contains-other-v").isPresent()) { - parentCousinIndicator = edge.property("contains-other-v").value().toString(); - } else if (edge.property("isParent").isPresent()) { - if ((Boolean)edge.property("isParent").value()) { - parentCousinIndicator = "OUT"; - } else if (edge.property("isParent-REV").isPresent() && (Boolean)edge.property("isParent-REV").value()) { - parentCousinIndicator = "IN"; - } - } else { - edgeMissingParentProperty.add(this.toStringForPrinting(edge, 1)); - } - - sb.append(outURI + "|" + label + "|" + inURI + "|" + parentCousinIndicator + "\n"); - } - } - } catch(Exception ex){ - logger.error("exception occurred during migration, failing: out=" + out + " in=" + in + "edge=" + oldEdgeString, ex); - success = false; - } - sb.append("--------EDGES END--------\n"); - - logger.info(sb.toString()); - edgeMissingParentProperty.forEach(s -> logger.warn("Edge Missing Parent Property: " + s)); - logger.info("Edge Missing Parent Property Count: " + edgeMissingParentProperty.size()); - logger.info("Vertex Missing URI Property Count: " + noURI.size()); - - } - - private String getVertexURI(Vertex v) { - if (v.property("aai-uri").isPresent()) { - return v.property("aai-uri").value().toString(); - } else { - return v.id().toString() + "(" + v.property("aai-node-type").value().toString() + ")"; - } - } - - @Override - public Optional<String[]> getAffectedNodeTypes() { - return Optional.empty(); - } - - @Override - public String getMigrationName() { - return "edge-report-for-tosca-migration"; - } - - @Override - public void commit() { - engine.rollback(); - } - -} diff --git a/aai-resources/src/main/java/org/onap/aai/migration/v12/MigrateDataFromASDCToConfiguration.java b/aai-resources/src/main/java/org/onap/aai/migration/v12/MigrateDataFromASDCToConfiguration.java deleted file mode 100644 index 113d441..0000000 --- a/aai-resources/src/main/java/org/onap/aai/migration/v12/MigrateDataFromASDCToConfiguration.java +++ /dev/null @@ -1,128 +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.migration.v12; - -import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversal; -import org.apache.tinkerpop.gremlin.structure.Vertex; -import org.onap.aai.db.props.AAIProperties; -import org.onap.aai.migration.*; -import org.onap.aai.serialization.engines.TransactionalGraphEngine; -import org.onap.aai.util.AAIConstants; - -import java.io.*; -import java.util.Optional; - -@MigrationPriority(20) -@MigrationDangerRating(2) -@Enabled -public class MigrateDataFromASDCToConfiguration extends Migrator { - private final String PARENT_NODE_TYPE = "generic-vnf"; - private boolean success = true; - private String entitlementPoolUuid = ""; - private String VNT = ""; - - - public MigrateDataFromASDCToConfiguration(TransactionalGraphEngine engine) { - super(engine); - } - - - @Override - public void run() { - String csvFile = AAIConstants.AAI_HOME_ETC + "VNT-migration-data" + AAIConstants.AAI_FILESEP + "VNT-migration-input.csv"; - logger.info("Reading Csv file: " + csvFile); - BufferedReader br = null; - String line = ""; - String cvsSplitBy = "\t"; - try { - - br = new BufferedReader(new FileReader(new File(csvFile))); - while ((line = br.readLine()) != null) { - line = line.replaceAll("\"", ""); - String[] temp = line.split(cvsSplitBy); - if ("entitlement-pool-uuid".equals(temp[0]) || "vendor-allowed-max-bandwidth (VNT)".equals(temp[1])) { - continue; - } - entitlementPoolUuid = temp[0]; - VNT = temp[1]; - GraphTraversal<Vertex, Vertex> f = this.engine.asAdmin().getTraversalSource().V().has(AAIProperties.NODE_TYPE, "entitlement").has("group-uuid", entitlementPoolUuid) - .out("org.onap.relationships.inventory.BelongsTo").has(AAIProperties.NODE_TYPE, "generic-vnf") - .has("vnf-type", "vHNF").in("org.onap.relationships.inventory.ComposedOf").has(AAIProperties.NODE_TYPE, "service-instance").out("org.onap.relationships.inventory.Uses").has(AAIProperties.NODE_TYPE, "configuration"); - - modify(f); - } - - } catch (FileNotFoundException e) { - success = false; - logger.error("Found Exception" , e); - } catch (IOException e) { - success = false; - logger.error("Found Exception" , e); - } catch (Exception a) { - success= false; - logger.error("Found Exception" , a); - } finally { - if (br != null){ - try { - br.close(); - } catch (IOException e) { - success = false; - logger.error("Found Exception" , e); - } - } - } - - } - - public void modify(GraphTraversal<Vertex, Vertex> g) { - int count = 0; - while (g.hasNext()) { - Vertex v = g.next(); - logger.info("Found node type " + v.property("aai-node-type").value().toString() + " with configuration id: " + v.property("configuration-id").value().toString()); - v.property("vendor-allowed-max-bandwidth", VNT); - logger.info("VNT val after migration: " + v.property("vendor-allowed-max-bandwidth").value().toString()); - count++; - } - - logger.info("modified " + count + " configuration nodes related to Entitlement UUID: " +entitlementPoolUuid); - - } - - @Override - public Status getStatus() { - if (success) { - return Status.SUCCESS; - } else { - return Status.FAILURE; - } - } - - @Override - public Optional<String[]> getAffectedNodeTypes() { - return Optional.of(new String[]{PARENT_NODE_TYPE}); - } - - @Override - public String getMigrationName() { - return "MigrateDataFromASDCToConfiguration"; - } - - -} diff --git a/aai-resources/src/main/java/org/onap/aai/migration/v12/MigrateServiceInstanceToConfiguration.java b/aai-resources/src/main/java/org/onap/aai/migration/v12/MigrateServiceInstanceToConfiguration.java deleted file mode 100644 index 7f2a809..0000000 --- a/aai-resources/src/main/java/org/onap/aai/migration/v12/MigrateServiceInstanceToConfiguration.java +++ /dev/null @@ -1,190 +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.migration.v12; - -import java.io.UnsupportedEncodingException; -import java.util.Iterator; -import java.util.Optional; -import java.util.UUID; - -import org.apache.tinkerpop.gremlin.process.traversal.P; -import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversal; -import org.apache.tinkerpop.gremlin.structure.Direction; -import org.apache.tinkerpop.gremlin.structure.Vertex; -import org.onap.aai.db.props.AAIProperties; -import org.onap.aai.exceptions.AAIException; -import org.onap.aai.introspection.Introspector; -import org.onap.aai.introspection.exceptions.AAIUnknownObjectException; -import org.onap.aai.migration.Enabled; -import org.onap.aai.migration.MigrationDangerRating; -import org.onap.aai.migration.MigrationPriority; -import org.onap.aai.migration.Migrator; -import org.onap.aai.migration.Status; -import org.onap.aai.serialization.db.EdgeType; -import org.onap.aai.serialization.engines.TransactionalGraphEngine; - -@Enabled -@MigrationPriority(10) -@MigrationDangerRating(10) -public class MigrateServiceInstanceToConfiguration extends Migrator { - - private boolean success = true; - private final String CONFIGURATION_NODE_TYPE = "configuration"; - private final String SERVICE_INSTANCE_NODE_TYPE = "service-instance"; - private Introspector configObj; - - public MigrateServiceInstanceToConfiguration(TransactionalGraphEngine engine) { - super(engine); - try { - this.configObj = this.loader.introspectorFromName(CONFIGURATION_NODE_TYPE); - } catch (AAIUnknownObjectException e) { - this.configObj = null; - } - } - - @Override - public void run() { - Vertex serviceInstance = null; - Vertex configuration = null; - String serviceInstanceId = "", tunnelBandwidth = ""; - String bandwidthTotal, configType, nodeType; - GraphTraversal<Vertex, Vertex> serviceInstanceItr; - Iterator<Vertex> configurationItr; - - try { - serviceInstanceItr = this.engine.asAdmin().getTraversalSource().V() - .has(AAIProperties.NODE_TYPE, P.within(getAffectedNodeTypes().get())) - .where(this.engine.getQueryBuilder() - .createEdgeTraversal(EdgeType.TREE, "service-instance", "service-subscription") - .getVerticesByProperty("service-type", "DHV") - .<GraphTraversal<?, ?>>getQuery()); - - if (serviceInstanceItr == null || !serviceInstanceItr.hasNext()) { - logger.info("No servince-instance nodes found with service-type of DHV"); - return; - } - - // iterate through all service instances of service-type DHV - while (serviceInstanceItr.hasNext()) { - serviceInstance = serviceInstanceItr.next(); - - if (serviceInstance != null && serviceInstance.property("bandwidth-total").isPresent()) { - serviceInstanceId = serviceInstance.value("service-instance-id"); - logger.info("Processing service instance with id=" + serviceInstanceId); - bandwidthTotal = serviceInstance.value("bandwidth-total"); - - if (bandwidthTotal != null && !bandwidthTotal.isEmpty()) { - - // check for existing edges to configuration nodes - configurationItr = serviceInstance.vertices(Direction.OUT, "has"); - - // create new configuration node if service-instance does not have existing ones - if (!configurationItr.hasNext()) { - logger.info(serviceInstanceId + " has no existing configuration nodes, creating new node"); - createConfigurationNode(serviceInstance, bandwidthTotal); - continue; - } - - // in case if configuration nodes exist, but none are DHV - boolean hasDHVConfig = false; - - // service-instance has existing configuration nodes - while (configurationItr.hasNext()) { - configuration = configurationItr.next(); - nodeType = configuration.value("aai-node-type").toString(); - - if (configuration != null && "configuration".equalsIgnoreCase(nodeType)) { - logger.info("Processing configuration node with id=" + configuration.property("configuration-id").value()); - configType = configuration.value("configuration-type"); - logger.info("Configuration type: " + configType); - - // if configuration-type is DHV, update tunnel-bandwidth to bandwidth-total value - if ("DHV".equalsIgnoreCase(configType)) { - if (configuration.property("tunnel-bandwidth").isPresent()) { - tunnelBandwidth = configuration.value("tunnel-bandwidth"); - } else { - tunnelBandwidth = ""; - } - - logger.info("Existing tunnel-bandwidth: " + tunnelBandwidth); - configuration.property("tunnel-bandwidth", bandwidthTotal); - touchVertexProperties(configuration, false); - logger.info("Updated tunnel-bandwidth: " + configuration.value("tunnel-bandwidth")); - hasDHVConfig = true; - } - } - } - - // create new configuration node if none of existing config nodes are of type DHV - if (!hasDHVConfig) { - logger.info(serviceInstanceId + " has existing configuration nodes, but none are DHV, create new node"); - createConfigurationNode(serviceInstance, bandwidthTotal); - } - } - } - } - } catch (AAIException | UnsupportedEncodingException e) { - logger.error("Caught exception while processing service instance with id=" + serviceInstanceId + " | " + e.toString()); - success = false; - } - } - - private void createConfigurationNode(Vertex serviceInstance, String bandwidthTotal) throws UnsupportedEncodingException, AAIException { - // create new vertex - Vertex configurationNode = serializer.createNewVertex(configObj); - - // configuration-id: UUID format - String configurationUUID = UUID.randomUUID().toString(); - configObj.setValue("configuration-id", configurationUUID); - - // configuration-type: DHV - configObj.setValue("configuration-type", "DHV"); - - // migrate the bandwidth-total property from the service-instance to the - // tunnel-bandwidth property of the related configuration object - configObj.setValue("tunnel-bandwidth", bandwidthTotal); - - // create edge between service instance and configuration: cousinEdge(out, in) - createCousinEdge(serviceInstance, configurationNode); - - // serialize edge & vertex, takes care of everything - serializer.serializeSingleVertex(configurationNode, configObj, "migrations"); - logger.info("Created configuration node with uuid=" + configurationUUID + ", tunnel-bandwidth=" + bandwidthTotal); - } - - @Override - public Status getStatus() { - if (success) { - return Status.SUCCESS; - } else { - return Status.FAILURE; - } - } - - @Override - public Optional<String[]> getAffectedNodeTypes() { - return Optional.of(new String[] {SERVICE_INSTANCE_NODE_TYPE}); - } - - @Override - public String getMigrationName() { - return "service-instance-to-configuration"; - } -} diff --git a/aai-resources/src/main/java/org/onap/aai/migration/v12/SDWANSpeedChangeMigration.java b/aai-resources/src/main/java/org/onap/aai/migration/v12/SDWANSpeedChangeMigration.java deleted file mode 100644 index 57e3e5e..0000000 --- a/aai-resources/src/main/java/org/onap/aai/migration/v12/SDWANSpeedChangeMigration.java +++ /dev/null @@ -1,254 +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.migration.v12; - -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.Vertex; -import org.onap.aai.exceptions.AAIException; -import org.onap.aai.migration.*; -import org.onap.aai.serialization.db.EdgeType; -import org.onap.aai.serialization.engines.TransactionalGraphEngine; - -import java.util.*; - -@MigrationPriority(1) -@MigrationDangerRating(1) -@Enabled -public class SDWANSpeedChangeMigration extends Migrator { - - private final String PARENT_NODE_TYPE = "alloted-resource"; - private boolean success = true; - - Vertex allottedRsrcVertex; - - Map<String, String> bandwidthMap = new HashMap<>(); - Set<String> bandWidthSet = new HashSet<>(); - - GraphTraversal<Vertex, Vertex> allottedRsrcTraversal; - GraphTraversal<Vertex, Vertex> tunnelXConnectTraversal; - GraphTraversal<Vertex, Vertex> pinterfaceTraversal; - GraphTraversal<Vertex, Vertex> plinkTraversal; - - public SDWANSpeedChangeMigration(TransactionalGraphEngine engine) { - super(engine); - bandWidthSet.add("bandwidth-up-wan1"); - bandWidthSet.add("bandwidth-down-wan1"); - bandWidthSet.add("bandwidth-up-wan2"); - bandWidthSet.add("bandwidth-down-wan2"); - } - - - @Override - public void run() { - - logger.info("Started the migration "+ getMigrationName()); - - try { - - allottedRsrcTraversal = this.engine.asAdmin().getTraversalSource().V() - .has("aai-node-type", "service-subscription") - .has("service-type", "DHV") - .in("org.onap.relationships.inventory.BelongsTo") - .has("aai-node-type", "service-instance") - .out("org.onap.relationships.inventory.Uses") - .has("aai-node-type", "allotted-resource") - .where( - this.engine.getQueryBuilder() - .createEdgeTraversal(EdgeType.TREE, "allotted-resource", "service-instance") - .createEdgeTraversal(EdgeType.TREE, "service-instance", "service-subscription") - .<GraphTraversal<Vertex, Vertex>>getQuery() - .has("service-type", "VVIG") - ); - - if(!(allottedRsrcTraversal.hasNext())){ - - logger.info("unable to find allotted resource to DHV as cousin and child of VVIG"); - } - - while (allottedRsrcTraversal.hasNext()) { - bandwidthMap.clear(); - - allottedRsrcVertex = allottedRsrcTraversal.next(); - String allottedResourceId = allottedRsrcVertex.property("id").value().toString(); - logger.info("Found an allotted resource with id " + allottedResourceId); - - tunnelXConnectTraversal = this.engine.asAdmin().getTraversalSource() - .V(allottedRsrcVertex) - .in("org.onap.relationships.inventory.BelongsTo") - .has("aai-node-type", "tunnel-xconnect"); - - if (tunnelXConnectTraversal != null && tunnelXConnectTraversal.hasNext()) { - Vertex xConnect = tunnelXConnectTraversal.next(); - String tunnelId = xConnect.property("id").value().toString(); - logger.info("Found an tunnelxconnect object with id " + tunnelId); - extractBandwidthProps(xConnect); - modifyPlink(allottedRsrcVertex); - } else { - logger.info("Unable to find the tunnel connect for the current allotted resource traversal"); - } - - } - } catch (AAIException e) { - e.printStackTrace(); - success = false; - } - - logger.info("Successfully finished the " + getMigrationName()); - } - - public void extractBandwidthProps(Vertex vertex) { - logger.info("Trying to extract bandwith props"); - bandWidthSet.stream().forEach((key) -> { - if (vertex.property(key).isPresent()) { - bandwidthMap.put(key, vertex.property(key).value().toString()); - } - }); - logger.info("Extracted bandwith props for tunnelXConnect " +vertex.value("id")); - } - - public void modifyPlink(Vertex v) { - - try { - pinterfaceTraversal = this.engine.asAdmin().getTraversalSource().V(v) - .in("org.onap.relationships.inventory.Uses").has("aai-node-type", "service-instance") - .where( - __.out("org.onap.relationships.inventory.BelongsTo") - .has("aai-node-type", "service-subscription") - .has("service-type", "DHV") - ) - .out("org.onap.relationships.inventory.ComposedOf").has("aai-node-type", "generic-vnf") - .out("tosca.relationships.HostedOn").has("aai-node-type", "vserver") - .out("tosca.relationships.HostedOn").has("aai-node-type", "pserver") - .in("tosca.relationships.network.BindsTo").has("aai-node-type", "p-interface"); - } catch (Exception e) { - logger.info("error trying to find p interfaces"); - } - - - while (pinterfaceTraversal.hasNext()) { - - Vertex pInterfaceVertex = pinterfaceTraversal.next(); - - String pinterfaceName = pInterfaceVertex.property("interface-name").value().toString(); - logger.info("p-interface "+ pinterfaceName + " found from traversal from allotted-resource " +v.value("id")); - String[] parts = pinterfaceName.split("/"); - - if (parts[parts.length - 1].equals("10")) { - - logger.info("Found the pinterface with the interface name ending with /10"); - - try { - plinkTraversal = this.engine.asAdmin().getTraversalSource() - .V(pInterfaceVertex) - .out("tosca.relationships.network.LinksTo") - .has("aai-node-type", "physical-link"); - } catch (Exception e) { - logger.info("error trying to find the p Link for /10"); - } - if (plinkTraversal != null && plinkTraversal.hasNext()) { - Vertex pLink = plinkTraversal.next(); - - - if ( bandwidthMap.containsKey("bandwidth-up-wan1") - && bandwidthMap.containsKey("bandwidth-down-wan1") - && !(("").equals(bandwidthMap.get("bandwidth-up-wan1").replaceAll("[^0-9]", "").trim())) - && !(("").equals(bandwidthMap.get("bandwidth-down-wan1").replaceAll("[^0-9]", "").trim()))) - { - - pLink.property("service-provider-bandwidth-up-value", Integer.valueOf(bandwidthMap.get("bandwidth-up-wan1").replaceAll("[^0-9]", "").trim())); - pLink.property("service-provider-bandwidth-up-units", "Mbps"); - pLink.property("service-provider-bandwidth-down-value", Integer.valueOf(bandwidthMap.get("bandwidth-down-wan1").replaceAll("[^0-9]", "").trim())); - pLink.property("service-provider-bandwidth-down-units", "Mbps"); - logger.info("Successfully modified the plink with link name ", pLink.property("link-name").value().toString()); - this.touchVertexProperties(pLink, false); - } else { - logger.info("missing up and down vals for the plink with link name ", pLink.property("link-name").value().toString()); - } - - - } else { - logger.info("missing plink for p interface" + pinterfaceName); - } - - } - - if (parts[parts.length - 1].equals("11")) { - - logger.info("Found the pinterface with the interface name ending with /11"); - try { - plinkTraversal = this.engine.asAdmin() - .getTraversalSource() - .V(pInterfaceVertex) - .out("tosca.relationships.network.LinksTo") - .has("aai-node-type", "physical-link"); - } catch (Exception e) { - logger.info("error trying to find the p Link for /11"); - } - - if (plinkTraversal != null && plinkTraversal.hasNext()) { - Vertex pLink = plinkTraversal.next(); - - - if ( bandwidthMap.containsKey("bandwidth-up-wan2") - && bandwidthMap.containsKey("bandwidth-down-wan2") - && !(("").equals(bandwidthMap.get("bandwidth-up-wan2").replaceAll("[^0-9]", "").trim())) - && !(("").equals(bandwidthMap.get("bandwidth-down-wan2").replaceAll("[^0-9]", "").trim()))) - { - pLink.property("service-provider-bandwidth-up-value", Integer.valueOf(bandwidthMap.get("bandwidth-up-wan2").replaceAll("[^0-9]", "").trim())); - pLink.property("service-provider-bandwidth-up-units", "Mbps"); - pLink.property("service-provider-bandwidth-down-value", Integer.valueOf(bandwidthMap.get("bandwidth-down-wan2").replaceAll("[^0-9]", "").trim())); - pLink.property("service-provider-bandwidth-down-units", "Mbps"); - logger.info("Successfully modified the plink with link name ", pLink.property("link-name").value().toString()); - this.touchVertexProperties(pLink, false); - } else { - logger.error("missing up and down vals for the plink with link name ", pLink.property("link-name").value().toString()); - } - - } else { - logger.info("missing plink for p interface" + pinterfaceName); - } - } - } - } - - - @Override - public Status getStatus() { - if (success) { - return Status.SUCCESS; - } else { - return Status.FAILURE; - } - } - - @Override - public Optional<String[]> getAffectedNodeTypes() { - - return Optional.of(new String[]{PARENT_NODE_TYPE}); - } - - @Override - public String getMigrationName() { - return "SDWANSpeedChangeMigration"; - } - - -} diff --git a/aai-resources/src/main/java/org/onap/aai/migration/v12/ToscaMigration.java b/aai-resources/src/main/java/org/onap/aai/migration/v12/ToscaMigration.java deleted file mode 100644 index 91ca4d7..0000000 --- a/aai-resources/src/main/java/org/onap/aai/migration/v12/ToscaMigration.java +++ /dev/null @@ -1,159 +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.migration.v12; - -import java.util.*; - -import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource; -import org.apache.tinkerpop.gremlin.structure.Edge; -import org.apache.tinkerpop.gremlin.structure.Vertex; -import org.onap.aai.db.props.AAIProperties; -import org.onap.aai.migration.Enabled; -import org.onap.aai.migration.MigrationDangerRating; -import org.onap.aai.migration.MigrationPriority; -import org.onap.aai.migration.Migrator; -import org.onap.aai.migration.Status; -import org.onap.aai.serialization.db.*; -import org.onap.aai.serialization.db.exceptions.EdgeMultiplicityException; -import org.onap.aai.serialization.engines.TransactionalGraphEngine; - -@Enabled - -@MigrationPriority(0) -@MigrationDangerRating(1000) -public class ToscaMigration extends Migrator { - - private boolean success = true; - EdgeRules ers = EdgeRules.getInstance(); - - public ToscaMigration(TransactionalGraphEngine graphEngine){ - super(graphEngine); - } - - @Override - public Status getStatus() { - if (success) { - return Status.SUCCESS; - } else { - return Status.FAILURE; - } - } - - @Override - public void run() { - Vertex out = null; - Vertex in = null; - boolean isCousin = false; - String oldEdgeString = null; - Map<String,Integer> edgeMultiplicityExceptionCtr = new HashMap<>(); - List<String> edgeMissingParentProperty = new ArrayList<>(); - - GraphTraversalSource g = engine.asAdmin().getTraversalSource(); - - try { - Set<Edge> edges = g.E().toSet(); - for (Edge edge : edges) { - // skip if this edge was migrated in a previous run - if (edge.label().contains("org.") || edge.label().contains("tosca.")) { - continue; - } - out = edge.outVertex(); - in = edge.inVertex(); - isCousin = false; - - if (out == null || in == null) { - logger.error(edge.id() + " invalid because one vertex was null: out=" + edge.outVertex() + " in=" + edge.inVertex()); - } else { - - if (edge.property("contains-other-v").isPresent()) { - isCousin = "NONE".equals(edge.property("contains-other-v").value()); - } else if (edge.property("isParent").isPresent()) { - isCousin = !(Boolean)edge.property("isParent").value(); - } else { - edgeMissingParentProperty.add(this.toStringForPrinting(edge, 1)); - } - - String inVertexNodeType = in.value(AAIProperties.NODE_TYPE); - String outVertexNodeType = out.value(AAIProperties.NODE_TYPE); - String label = null; - - - Set<String> edgeLabels = ers.getEdgeRules(outVertexNodeType,inVertexNodeType).keySet(); - - if (edgeLabels.isEmpty()) { - logger.error(edge.id() + " did not migrate as no edge rule found for: out=" + outVertexNodeType + " in=" + inVertexNodeType); - continue; - } else if (edgeLabels.size() > 1) { - if (edgeLabels.contains("org.onap.relationships.inventory.Source")) { - if ("sourceLInterface".equals(edge.label())) { - label = "org.onap.relationships.inventory.Source"; - } else if ("targetLInterface".equals(edge.label())) { - label = "org.onap.relationships.inventory.Destination"; - } else { - label = "tosca.relationships.network.LinksTo"; - } - } - } - - try { - if (isCousin) { - ers.addEdgeIfPossible(g, in, out, label); - } else { - ers.addTreeEdge(g, out, in); - } - edge.remove(); - } catch (EdgeMultiplicityException edgeMultiplicityException) { - logger.warn("Edge Multiplicity Exception: " - + "\nInV:\n" + this.toStringForPrinting(in, 1) - + "Edge:\n" + this.toStringForPrinting(edge, 1) - + "OutV:\n" + this.toStringForPrinting(out, 1) - ); - - final String mapKey = "OUT:" + outVertexNodeType + " " + (isCousin ? EdgeType.COUSIN.toString():EdgeType.TREE.toString()) + " " + "IN:" + inVertexNodeType; - if (edgeMultiplicityExceptionCtr.containsKey(mapKey)) { - edgeMultiplicityExceptionCtr.put(mapKey, edgeMultiplicityExceptionCtr.get(mapKey)+1); - } else { - edgeMultiplicityExceptionCtr.put(mapKey, 1); - } - } - } - } - } catch(Exception ex){ - logger.error("exception occurred during migration, failing: out=" + out + " in=" + in + "edge=" + oldEdgeString, ex); - success = false; - } - - logger.info("Edge Missing Parent Property Count: " + edgeMissingParentProperty.size()); - logger.info("Edge Multiplicity Exception Count : " + edgeMultiplicityExceptionCtr.values().stream().mapToInt(Number::intValue).sum()); - logger.info("Edge Multiplicity Exception Breakdown : " + edgeMultiplicityExceptionCtr); - - } - - @Override - public Optional<String[]> getAffectedNodeTypes() { - return Optional.empty(); - } - - @Override - public String getMigrationName() { - return "migrate-all-edges"; - } - -} diff --git a/aai-resources/src/main/java/org/onap/aai/migration/v13/MigrateInstanceGroupSubType.java b/aai-resources/src/main/java/org/onap/aai/migration/v13/MigrateInstanceGroupSubType.java deleted file mode 100644 index feb8a6a..0000000 --- a/aai-resources/src/main/java/org/onap/aai/migration/v13/MigrateInstanceGroupSubType.java +++ /dev/null @@ -1,59 +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.migration.v13; -import java.util.Optional; - -import org.onap.aai.migration.Enabled; -import org.onap.aai.migration.MigrationDangerRating; -import org.onap.aai.migration.MigrationPriority; -import org.onap.aai.migration.PropertyMigrator; -import org.onap.aai.serialization.engines.TransactionalGraphEngine; - -import org.janusgraph.core.Cardinality; - -@MigrationPriority(20) -@MigrationDangerRating(2) -@Enabled -public class MigrateInstanceGroupSubType extends PropertyMigrator{ - - protected static final String SUB_TYPE_PROPERTY = "sub-type"; - protected static final String INSTANCE_GROUP_ROLE_PROPERTY = "instance-group-role"; - protected static final String INSTANCE_GROUP_NODE_TYPE = "instance-group"; - - public MigrateInstanceGroupSubType(TransactionalGraphEngine engine) { - super(engine,SUB_TYPE_PROPERTY , INSTANCE_GROUP_ROLE_PROPERTY, String.class,Cardinality.SINGLE); - } - - @Override - public Optional<String[]> getAffectedNodeTypes() { - return Optional.of(new String[]{INSTANCE_GROUP_NODE_TYPE}); - } - - @Override - public String getMigrationName() { - return "MigrateInstanceGroupSubType"; - } - - @Override - public boolean isIndexed() { - return true; - } - -} diff --git a/aai-resources/src/main/java/org/onap/aai/migration/v13/MigrateInstanceGroupType.java b/aai-resources/src/main/java/org/onap/aai/migration/v13/MigrateInstanceGroupType.java deleted file mode 100644 index dc55b40..0000000 --- a/aai-resources/src/main/java/org/onap/aai/migration/v13/MigrateInstanceGroupType.java +++ /dev/null @@ -1,59 +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.migration.v13; -import java.util.Optional; - -import org.onap.aai.migration.Enabled; -import org.onap.aai.migration.MigrationDangerRating; -import org.onap.aai.migration.MigrationPriority; -import org.onap.aai.migration.PropertyMigrator; -import org.onap.aai.serialization.engines.TransactionalGraphEngine; - -import org.janusgraph.core.Cardinality; - -@MigrationPriority(20) -@MigrationDangerRating(2) -@Enabled -public class MigrateInstanceGroupType extends PropertyMigrator{ - - protected static final String TYPE_PROPERTY = "type"; - protected static final String INSTANCE_GROUP_TYPE_PROPERTY = "instance-group-type"; - protected static final String INSTANCE_GROUP_NODE_TYPE = "instance-group"; - - public MigrateInstanceGroupType(TransactionalGraphEngine engine) { - super(engine,TYPE_PROPERTY , INSTANCE_GROUP_TYPE_PROPERTY, String.class,Cardinality.SINGLE); - } - - @Override - public Optional<String[]> getAffectedNodeTypes() { - return Optional.of(new String[]{INSTANCE_GROUP_NODE_TYPE}); - } - - @Override - public String getMigrationName() { - return "MigrateInstanceGroupType"; - } - - @Override - public boolean isIndexed() { - return true; - } - -} diff --git a/aai-resources/src/main/java/org/onap/aai/rest/BulkAddConsumer.java b/aai-resources/src/main/java/org/onap/aai/rest/BulkAddConsumer.java index 50e7634..0c316bf 100644 --- a/aai-resources/src/main/java/org/onap/aai/rest/BulkAddConsumer.java +++ b/aai-resources/src/main/java/org/onap/aai/rest/BulkAddConsumer.java @@ -23,7 +23,7 @@ import javax.ws.rs.Path; import org.onap.aai.restcore.HttpMethod; -@Path("{version: v[8-9]|v1[01234]}/bulkadd") +@Path("{version: v[1-9][0-9]*|latest}/bulkadd") public class BulkAddConsumer extends BulkConsumer { @Override diff --git a/aai-resources/src/main/java/org/onap/aai/rest/BulkConsumer.java b/aai-resources/src/main/java/org/onap/aai/rest/BulkConsumer.java index 1c40859..d6ec93a 100644 --- a/aai-resources/src/main/java/org/onap/aai/rest/BulkConsumer.java +++ b/aai-resources/src/main/java/org/onap/aai/rest/BulkConsumer.java @@ -43,12 +43,13 @@ import javax.ws.rs.core.UriBuilder; import javax.ws.rs.core.UriInfo; import org.javatuples.Pair; +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.setup.SchemaVersion; import org.onap.aai.introspection.exceptions.AAIUnmarshallingException; import org.onap.aai.logging.ErrorObjectNotFoundException; import org.onap.aai.logging.LoggingContext; @@ -99,8 +100,8 @@ public abstract class BulkConsumer extends RESTAPI { private ModelType introspectorFactoryType = ModelType.MOXY; /** The query style. */ - private QueryStyle queryStyle = QueryStyle.TRAVERSAL; - + private QueryStyle queryStyle = QueryStyle.TRAVERSAL_URI; + /** * Bulk add. * @@ -121,7 +122,7 @@ public abstract class BulkConsumer extends RESTAPI { String sourceOfTruth = headers.getRequestHeaders().getFirst("X-FromAppId"); String realTime = headers.getRequestHeaders().getFirst("Real-Time"); String outputMediaType = getMediaType(headers.getAcceptableMediaTypes()); - Version version = Version.valueOf(versionParam); + SchemaVersion version = new SchemaVersion(versionParam); Response response = null; try { @@ -145,9 +146,10 @@ public abstract class BulkConsumer extends RESTAPI { JsonArray transactions = getTransactions(content, headers); for (int i = 0; i < transactions.size(); i++){ - HttpEntry httpEntry = new HttpEntry(version, introspectorFactoryType, queryStyle, type); - Loader loader = httpEntry.getLoader(); - TransactionalGraphEngine dbEngine = httpEntry.getDbEngine(); + HttpEntry resourceHttpEntry = SpringContextAware.getBean("traversalUriHttpEntry", HttpEntry.class); + resourceHttpEntry.setHttpEntryProperties(version, type); + Loader loader = resourceHttpEntry.getLoader(); + TransactionalGraphEngine dbEngine = resourceHttpEntry.getDbEngine(); URI thisUri = null; List<BulkOperation> bulkOperations = new ArrayList<>(); HttpMethod method = null; @@ -175,7 +177,7 @@ public abstract class BulkConsumer extends RESTAPI { requests.add(request); } - Pair<Boolean, List<Pair<URI, Response>>> results = httpEntry.process(requests, sourceOfTruth, this.enableResourceVersion()); + Pair<Boolean, List<Pair<URI, Response>>> results = resourceHttpEntry.process(requests, sourceOfTruth, this.enableResourceVersion()); List<BulkOperationResponse> responses = BulkOperationResponse.processPairList(method, results.getValue1()); allResponses.add(responses); if (results.getValue0()) { //everything was processed without error @@ -364,7 +366,7 @@ public abstract class BulkConsumer extends RESTAPI { * keep any errors with their corresponding uris for client feedback */ bulkOperation.setUri(uri); - + bulkOperation.addUriInfoQueryParams(uriComponents.getQueryParams()); if (!ValidateEncoding.getInstance().validate(uri)) { diff --git a/aai-resources/src/main/java/org/onap/aai/rest/BulkProcessConsumer.java b/aai-resources/src/main/java/org/onap/aai/rest/BulkProcessConsumer.java index 2cae668..aac2deb 100644 --- a/aai-resources/src/main/java/org/onap/aai/rest/BulkProcessConsumer.java +++ b/aai-resources/src/main/java/org/onap/aai/rest/BulkProcessConsumer.java @@ -23,7 +23,7 @@ import javax.ws.rs.Path; import org.onap.aai.restcore.HttpMethod; -@Path("{version: v[789]|v1[01234]}/bulkprocess") +@Path("{version: v[1-9][0-9]*|latest}/bulkprocess") public class BulkProcessConsumer extends BulkConsumer { @Override diff --git a/aai-resources/src/main/java/org/onap/aai/rest/ExampleConsumer.java b/aai-resources/src/main/java/org/onap/aai/rest/ExampleConsumer.java index d52befd..74884e2 100644 --- a/aai-resources/src/main/java/org/onap/aai/rest/ExampleConsumer.java +++ b/aai-resources/src/main/java/org/onap/aai/rest/ExampleConsumer.java @@ -31,13 +31,14 @@ import javax.ws.rs.core.Response; import javax.ws.rs.core.Response.Status; import javax.ws.rs.core.UriInfo; +import org.onap.aai.config.SpringContextAware; import org.onap.aai.exceptions.AAIException; import org.onap.aai.introspection.Introspector; import org.onap.aai.introspection.Loader; import org.onap.aai.introspection.LoaderFactory; import org.onap.aai.introspection.MarshallerProperties; import org.onap.aai.introspection.ModelType; -import org.onap.aai.introspection.Version; +import org.onap.aai.setup.SchemaVersion; import org.onap.aai.introspection.generator.CreateExample; import org.onap.aai.restcore.HttpMethod; import org.onap.aai.restcore.RESTAPI; @@ -45,7 +46,7 @@ import org.onap.aai.restcore.RESTAPI; /** * The Class ExampleConsumer. */ -@Path("/{version: v[789]|v1[01234]}/examples") +@Path("{version: v[1-9][0-9]*|latest}/examples") public class ExampleConsumer extends RESTAPI { @@ -71,8 +72,8 @@ public class ExampleConsumer extends RESTAPI { String mediaType = getMediaType(headers.getAcceptableMediaTypes()); org.onap.aai.restcore.MediaType outputMediaType = org.onap.aai.restcore.MediaType.getEnum(mediaType); - Version version = Version.valueOf(versionParam); - Loader loader = LoaderFactory.createLoaderForVersion(ModelType.MOXY, version); + SchemaVersion version = new SchemaVersion(versionParam); + Loader loader = SpringContextAware.getBean( LoaderFactory.class).createLoaderForVersion(ModelType.MOXY, version); CreateExample example = new CreateExample(loader, type); diff --git a/aai-resources/src/main/java/org/onap/aai/rest/LegacyMoxyConsumer.java b/aai-resources/src/main/java/org/onap/aai/rest/LegacyMoxyConsumer.java index 61f0d88..3c2754d 100644 --- a/aai-resources/src/main/java/org/onap/aai/rest/LegacyMoxyConsumer.java +++ b/aai-resources/src/main/java/org/onap/aai/rest/LegacyMoxyConsumer.java @@ -25,10 +25,8 @@ import java.util.ArrayList; import java.util.Arrays; import java.util.HashSet; import java.util.List; -import java.util.Map.Entry; import java.util.Set; import java.util.stream.Collectors; -import java.util.concurrent.Callable; import javax.servlet.http.HttpServletRequest; import javax.ws.rs.Consumes; @@ -52,13 +50,13 @@ import javax.ws.rs.core.UriInfo; import io.swagger.jaxrs.PATCH; import org.javatuples.Pair; +import org.onap.aai.concurrent.AaiCallable; +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.logging.LoggingContext; +import org.onap.aai.setup.SchemaVersion; import org.onap.aai.parsers.query.QueryParser; import org.onap.aai.rest.db.DBRequest; import org.onap.aai.rest.db.HttpEntry; @@ -66,50 +64,40 @@ import org.onap.aai.rest.exceptions.AAIInvalidXMLNamespace; import org.onap.aai.rest.util.ValidateEncoding; 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.util.AAIConstants; -import org.onap.aai.workarounds.RemoveDME2QueryParams; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Controller; import com.att.eelf.configuration.EELFLogger; import com.att.eelf.configuration.EELFManager; import com.google.common.base.Joiner; - /** * The Class LegacyMoxyConsumer. */ -@Path("{version: v[789]|v1[01234]}") +@Controller +@Path("{version: v[1-9][0-9]*|latest}") public class LegacyMoxyConsumer extends RESTAPI { - - private static final EELFLogger LOGGER = EELFManager.getInstance().getLogger(LegacyMoxyConsumer.class.getName()); - protected static String authPolicyFunctionName = "REST"; - private ModelType introspectorFactoryType = ModelType.MOXY; - private QueryStyle queryStyle = QueryStyle.TRAVERSAL; - private final static String TARGET_ENTITY = "aai-resources"; - /** - * Update. - * - * @param content the content - * @param versionParam the version param - * @param uri the uri - * @param headers the headers - * @param info the info - * @param req the req - * @return the response - */ + + private static final EELFLogger logger = EELFManager.getInstance().getLogger(LegacyMoxyConsumer.class.getName()); + +// private HttpEntry traversalUriHttpEntry; + +// @Autowired +// public LegacyMoxyConsumer(HttpEntry traversalUriHttpEntry){ +// this.traversalUriHttpEntry = traversalUriHttpEntry; +// } + + public LegacyMoxyConsumer(){ + + } + @PUT @Path("/{uri: .+}") @Consumes({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML }) @Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML }) public Response update (String content, @PathParam("version")String versionParam, @PathParam("uri") @Encoded String uri, @Context HttpHeaders headers, @Context UriInfo info, @Context HttpServletRequest req) { - String serviceName = "PUT " + uri.toString(); - String queryStr = req.getQueryString(); - if ( queryStr != null ) { - serviceName = serviceName + "?" + queryStr; - } - LoggingContext.serviceName(serviceName); - LoggingContext.targetServiceName(serviceName); MediaType mediaType = headers.getMediaType(); return this.handleWrites(mediaType, HttpMethod.PUT, content, versionParam, uri, headers, info); } @@ -140,25 +128,14 @@ public class LegacyMoxyConsumer extends RESTAPI { TransactionalGraphEngine dbEngine = null; boolean success = true; - String serviceName = req.getMethod() + " " + req.getRequestURI().toString(); - String queryStr = req.getQueryString(); - if ( queryStr != null ) { - serviceName = serviceName + "?" + queryStr; - } - LoggingContext.requestId(transId); - LoggingContext.partnerName(sourceOfTruth); - LoggingContext.serviceName(serviceName); - LoggingContext.targetEntity(TARGET_ENTITY); - LoggingContext.targetServiceName(serviceName); - try { validateRequest(info); - Version version = Version.valueOf(versionParam); - version = Version.valueOf(versionParam); + SchemaVersion version = new SchemaVersion(versionParam); DBConnectionType type = this.determineConnectionType(sourceOfTruth, realTime); - HttpEntry httpEntry = new HttpEntry(version, introspectorFactoryType, queryStyle, type); - loader = httpEntry.getLoader(); - dbEngine = httpEntry.getDbEngine(); + HttpEntry traversalUriHttpEntry = SpringContextAware.getBean("traversalUriHttpEntry", HttpEntry.class); + traversalUriHttpEntry.setHttpEntryProperties(version, type); + loader = traversalUriHttpEntry.getLoader(); + dbEngine = traversalUriHttpEntry.getDbEngine(); URI uriObject = UriBuilder.fromPath(uri).build(); this.validateURI(uriObject); @@ -170,7 +147,7 @@ public class LegacyMoxyConsumer extends RESTAPI { DBRequest request = new DBRequest.Builder(HttpMethod.PUT_EDGE, uriObject, uriQuery, wrappedEntity, headers, info, transId).build(); List<DBRequest> requests = new ArrayList<>(); requests.add(request); - Pair<Boolean, List<Pair<URI, Response>>> responsesTuple = httpEntry.process(requests, sourceOfTruth); + Pair<Boolean, List<Pair<URI, Response>>> responsesTuple = traversalUriHttpEntry.process(requests, sourceOfTruth); response = responsesTuple.getValue1().get(0).getValue1(); success = responsesTuple.getValue0(); @@ -214,13 +191,6 @@ public class LegacyMoxyConsumer extends RESTAPI { public Response patch (String content, @PathParam("version")String versionParam, @PathParam("uri") @Encoded String uri, @Context HttpHeaders headers, @Context UriInfo info, @Context HttpServletRequest req) { MediaType mediaType = MediaType.APPLICATION_JSON_TYPE; - String serviceName = "PATCH " + uri.toString(); - String queryStr = req.getQueryString(); - if ( queryStr != null ) { - serviceName = serviceName + "?" + queryStr; - } - LoggingContext.serviceName(serviceName); - LoggingContext.targetServiceName(serviceName); return this.handleWrites(mediaType, HttpMethod.MERGE_PATCH, content, versionParam, uri, headers, info); } @@ -249,9 +219,9 @@ public class LegacyMoxyConsumer extends RESTAPI { headers, info, HttpMethod.GET, - new Callable<Response>() { + new AaiCallable<Response>() { @Override - public Response call() { + public Response process() { return getLegacy(content, versionParam, uri, depthParam, cleanUp, headers, info, req, new HashSet<String>(), resultIndex, resultSize); } } @@ -279,25 +249,15 @@ public class LegacyMoxyConsumer extends RESTAPI { Response response = null; TransactionalGraphEngine dbEngine = null; Loader loader = null; - - String serviceName = req.getMethod() + " " + req.getRequestURI().toString(); - String queryStr = req.getQueryString(); - if ( queryStr != null ) { - serviceName = serviceName + "?" + queryStr; - } - LoggingContext.requestId(transId); - LoggingContext.partnerName(sourceOfTruth); - LoggingContext.serviceName(serviceName); - LoggingContext.targetEntity(TARGET_ENTITY); - LoggingContext.targetServiceName(serviceName); try { validateRequest(info); - Version version = Version.valueOf(versionParam); + SchemaVersion version = new SchemaVersion(versionParam); DBConnectionType type = this.determineConnectionType(sourceOfTruth, realTime); - final HttpEntry httpEntry = new HttpEntry(version, introspectorFactoryType, queryStyle, type); - dbEngine = httpEntry.getDbEngine(); - loader = httpEntry.getLoader(); + final HttpEntry traversalUriHttpEntry = SpringContextAware.getBean("traversalUriHttpEntry", HttpEntry.class); + traversalUriHttpEntry.setHttpEntryProperties(version, type); + dbEngine = traversalUriHttpEntry.getDbEngine(); + loader = traversalUriHttpEntry.getLoader(); MultivaluedMap<String, String> params = info.getQueryParameters(); params = removeNonFilterableParams(params); @@ -319,7 +279,11 @@ public class LegacyMoxyConsumer extends RESTAPI { new DBRequest.Builder(HttpMethod.GET, uriObject, uriQuery, obj, headers, info, transId).build(); List<DBRequest> requests = new ArrayList<>(); requests.add(request); - Pair<Boolean, List<Pair<URI, Response>>> responsesTuple = httpEntry.process(requests, sourceOfTruth); + if (resultIndex != null && resultIndex != "-1" && resultSize != null && resultSize != "-1") { + traversalUriHttpEntry.setPaginationIndex(Integer.parseInt(resultIndex)); + traversalUriHttpEntry.setPaginationBucket(Integer.parseInt(resultSize)); + } + Pair<Boolean, List<Pair<URI, Response>>> responsesTuple = traversalUriHttpEntry.process(requests, sourceOfTruth); response = responsesTuple.getValue1().get(0).getValue1(); @@ -377,16 +341,6 @@ public class LegacyMoxyConsumer extends RESTAPI { String sourceOfTruth = headers.getRequestHeaders().getFirst("X-FromAppId"); String transId = headers.getRequestHeaders().getFirst("X-TransactionId"); String realTime = headers.getRequestHeaders().getFirst("Real-Time"); - String serviceName = req.getMethod() + " " + req.getRequestURI().toString(); - String queryStr = req.getQueryString(); - if ( queryStr != null ) { - serviceName = serviceName + "?" + queryStr; - } - LoggingContext.requestId(transId); - LoggingContext.partnerName(sourceOfTruth); - LoggingContext.serviceName(serviceName); - LoggingContext.targetEntity(TARGET_ENTITY); - LoggingContext.targetServiceName(serviceName); TransactionalGraphEngine dbEngine = null; Response response = Response.status(404) @@ -397,12 +351,12 @@ public class LegacyMoxyConsumer extends RESTAPI { try { validateRequest(info); - 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(); - Loader loader = httpEntry.getLoader(); + HttpEntry traversalUriHttpEntry = SpringContextAware.getBean("traversalUriHttpEntry", HttpEntry.class); + traversalUriHttpEntry.setHttpEntryProperties(version, type); + dbEngine = traversalUriHttpEntry.getDbEngine(); + Loader loader = traversalUriHttpEntry.getLoader(); URI uriObject = UriBuilder.fromPath(uri).build(); @@ -413,7 +367,7 @@ public class LegacyMoxyConsumer extends RESTAPI { DBRequest request = new DBRequest.Builder(HttpMethod.DELETE, uriObject, uriQuery, obj, headers, info, transId).build(); List<DBRequest> requests = new ArrayList<>(); requests.add(request); - Pair<Boolean, List<Pair<URI, Response>>> responsesTuple = httpEntry.process(requests, sourceOfTruth); + Pair<Boolean, List<Pair<URI, Response>>> responsesTuple = traversalUriHttpEntry.process(requests, sourceOfTruth); response = responsesTuple.getValue1().get(0).getValue1(); success = responsesTuple.getValue0(); @@ -462,17 +416,6 @@ public class LegacyMoxyConsumer extends RESTAPI { String transId = headers.getRequestHeaders().getFirst("X-TransactionId"); String realTime = headers.getRequestHeaders().getFirst("Real-Time"); - String serviceName = req.getMethod() + " " + req.getRequestURI().toString(); - String queryStr = req.getQueryString(); - if ( queryStr != null ) { - serviceName = serviceName + "?" + queryStr; - } - LoggingContext.requestId(transId); - LoggingContext.partnerName(sourceOfTruth); - LoggingContext.serviceName(serviceName); - LoggingContext.targetEntity(TARGET_ENTITY); - LoggingContext.targetServiceName(serviceName); - Loader loader = null; TransactionalGraphEngine dbEngine = null; Response response = Response.status(404) @@ -482,11 +425,12 @@ public class LegacyMoxyConsumer extends RESTAPI { try { this.validateRequest(info); - Version version = Version.valueOf(versionParam); + SchemaVersion version = new SchemaVersion(versionParam); DBConnectionType type = this.determineConnectionType(sourceOfTruth, realTime); - HttpEntry httpEntry = new HttpEntry(version, introspectorFactoryType, queryStyle, type); - loader = httpEntry.getLoader(); - dbEngine = httpEntry.getDbEngine(); + HttpEntry traversalUriHttpEntry = SpringContextAware.getBean("traversalUriHttpEntry", HttpEntry.class); + traversalUriHttpEntry.setHttpEntryProperties(version, type); + loader = traversalUriHttpEntry.getLoader(); + dbEngine = traversalUriHttpEntry.getDbEngine(); if (content.equals("")) { throw new AAIException("AAI_3102", "You must supply a relationship"); @@ -501,7 +445,7 @@ public class LegacyMoxyConsumer extends RESTAPI { DBRequest request = new DBRequest.Builder(HttpMethod.DELETE_EDGE, uriObject, uriQuery, wrappedEntity, headers, info, transId).build(); List<DBRequest> requests = new ArrayList<>(); requests.add(request); - Pair<Boolean, List<Pair<URI, Response>>> responsesTuple = httpEntry.process(requests, sourceOfTruth); + Pair<Boolean, List<Pair<URI, Response>>> responsesTuple = traversalUriHttpEntry.process(requests, sourceOfTruth); response = responsesTuple.getValue1().get(0).getValue1(); success = responsesTuple.getValue0(); @@ -581,25 +525,21 @@ public class LegacyMoxyConsumer extends RESTAPI { Response response = null; TransactionalGraphEngine dbEngine = null; Loader loader = null; - Version version = null; + SchemaVersion version = null; String sourceOfTruth = headers.getRequestHeaders().getFirst("X-FromAppId"); String transId = headers.getRequestHeaders().getFirst("X-TransactionId"); String realTime = headers.getRequestHeaders().getFirst("Real-Time"); Boolean success = true; - - //LoggingContext service name and target service name set in calling method - LoggingContext.requestId(transId); - LoggingContext.partnerName(sourceOfTruth); - LoggingContext.targetEntity(TARGET_ENTITY); try { validateRequest(info); - version = Version.valueOf(versionParam); + version = new SchemaVersion(versionParam); DBConnectionType type = this.determineConnectionType(sourceOfTruth, realTime); - HttpEntry httpEntry = new HttpEntry(version, introspectorFactoryType, queryStyle, type); - loader = httpEntry.getLoader(); - dbEngine = httpEntry.getDbEngine(); + HttpEntry traversalUriHttpEntry = SpringContextAware.getBean("traversalUriHttpEntry", HttpEntry.class); + traversalUriHttpEntry.setHttpEntryProperties(version, type); + loader = traversalUriHttpEntry.getLoader(); + dbEngine = traversalUriHttpEntry.getDbEngine(); URI uriObject = UriBuilder.fromPath(uri).build(); this.validateURI(uriObject); QueryParser uriQuery = dbEngine.getQueryBuilder().createQueryFromURI(uriObject); @@ -627,7 +567,7 @@ public class LegacyMoxyConsumer extends RESTAPI { .rawRequestContent(content).build(); List<DBRequest> requests = new ArrayList<>(); requests.add(request); - Pair<Boolean, List<Pair<URI, Response>>> responsesTuple = httpEntry.process(requests, sourceOfTruth); + Pair<Boolean, List<Pair<URI, Response>>> responsesTuple = traversalUriHttpEntry.process(requests, sourceOfTruth); response = responsesTuple.getValue1().get(0).getValue1(); success = responsesTuple.getValue0(); diff --git a/aai-resources/src/main/java/org/onap/aai/rest/URLFromVertexIdConsumer.java b/aai-resources/src/main/java/org/onap/aai/rest/URLFromVertexIdConsumer.java index eb54194..b9e5aa8 100644 --- a/aai-resources/src/main/java/org/onap/aai/rest/URLFromVertexIdConsumer.java +++ b/aai-resources/src/main/java/org/onap/aai/rest/URLFromVertexIdConsumer.java @@ -20,7 +20,6 @@ package org.onap.aai.rest; import java.net.URI; -import java.net.URL; import java.util.Iterator; import javax.servlet.http.HttpServletRequest; @@ -36,11 +35,11 @@ import javax.ws.rs.core.Response.Status; import javax.ws.rs.core.UriInfo; import org.apache.tinkerpop.gremlin.structure.Vertex; - +import org.onap.aai.config.SpringContextAware; 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.setup.SchemaVersion; import org.onap.aai.rest.db.HttpEntry; import org.onap.aai.restcore.HttpMethod; import org.onap.aai.restcore.RESTAPI; @@ -48,15 +47,14 @@ import org.onap.aai.serialization.db.DBSerializer; import org.onap.aai.serialization.engines.QueryStyle; import org.onap.aai.serialization.engines.TransactionalGraphEngine; import org.onap.aai.util.AAIConfig; -import org.onap.aai.workarounds.LegacyURITransformer; /** * The Class URLFromVertexIdConsumer. */ -@Path("{version: v[789]|v1[01234]}/generateurl") +@Path("{version: v[1-9][0-9]*|latest}/generateurl") public class URLFromVertexIdConsumer extends RESTAPI { private ModelType introspectorFactoryType = ModelType.MOXY; - private QueryStyle queryStyle = QueryStyle.TRAVERSAL; + private QueryStyle queryStyle = QueryStyle.TRAVERSAL_URI; private final String ID_ENDPOINT = "/id/{vertexid: \\d+}"; @@ -73,20 +71,21 @@ public class URLFromVertexIdConsumer extends RESTAPI { */ @GET @Path(ID_ENDPOINT) - @Produces({ MediaType.TEXT_PLAIN }) + @Produces({ MediaType.WILDCARD }) public Response generateUrlFromVertexId(String content, @PathParam("version")String versionParam, @PathParam("vertexid")long vertexid, @Context HttpHeaders headers, @Context UriInfo info, @Context HttpServletRequest req) { String sourceOfTruth = headers.getRequestHeaders().getFirst("X-FromAppId"); String realTime = headers.getRequestHeaders().getFirst("Real-Time"); - Version version = Version.valueOf(versionParam); + SchemaVersion version = new SchemaVersion(versionParam); StringBuilder result = new StringBuilder(); Response response = null; TransactionalGraphEngine dbEngine = null; try { DBConnectionType type = this.determineConnectionType(sourceOfTruth, realTime); - HttpEntry httpEntry = new HttpEntry(version, introspectorFactoryType, queryStyle, type); - dbEngine = httpEntry.getDbEngine(); + HttpEntry resourceHttpEntry = SpringContextAware.getBean("traversalUriHttpEntry", HttpEntry.class); + resourceHttpEntry.setHttpEntryProperties(version, type); + dbEngine = resourceHttpEntry.getDbEngine(); DBSerializer serializer = new DBSerializer(version, dbEngine, introspectorFactoryType, sourceOfTruth); @@ -100,14 +99,6 @@ public class URLFromVertexIdConsumer extends RESTAPI { result.append(uri.getRawPath()); result.insert(0, version); result.insert(0, AAIConfig.get("aai.server.url.base")); - LegacyURITransformer urlTransformer = LegacyURITransformer.getInstance(); - URI output = new URI(result.toString()); - /*if (version.compareTo(Version.v2) == 0) { - output = urlTransformer.getLegacyURI(output); - result = new StringBuilder(); - result.append(output.toString()); - }*/ - response = Response.ok().entity(result.toString()).status(Status.OK).type(MediaType.TEXT_PLAIN).build(); } catch (AAIException e) { //TODO check that the details here are sensible diff --git a/aai-resources/src/main/java/org/onap/aai/rest/VertexIdConsumer.java b/aai-resources/src/main/java/org/onap/aai/rest/VertexIdConsumer.java index 94a6a68..3451528 100644 --- a/aai-resources/src/main/java/org/onap/aai/rest/VertexIdConsumer.java +++ b/aai-resources/src/main/java/org/onap/aai/rest/VertexIdConsumer.java @@ -41,7 +41,7 @@ import javax.ws.rs.core.UriInfo; import org.apache.tinkerpop.gremlin.structure.Vertex; import org.javatuples.Pair; - +import org.onap.aai.config.SpringContextAware; import org.onap.aai.db.props.AAIProperties; import org.onap.aai.dbmap.DBConnectionType; import org.onap.aai.exceptions.AAIException; @@ -49,7 +49,6 @@ import org.onap.aai.introspection.Introspector; import org.onap.aai.introspection.Loader; import org.onap.aai.introspection.MarshallerProperties; import org.onap.aai.introspection.ModelType; -import org.onap.aai.introspection.Version; import org.onap.aai.parsers.query.QueryParser; import org.onap.aai.rest.db.DBRequest; import org.onap.aai.rest.db.HttpEntry; @@ -58,18 +57,21 @@ import org.onap.aai.restcore.RESTAPI; import org.onap.aai.serialization.db.DBSerializer; import org.onap.aai.serialization.engines.QueryStyle; import org.onap.aai.serialization.engines.TransactionalGraphEngine; +import org.onap.aai.setup.SchemaVersion; /** * The Class VertexIdConsumer. */ -@Path("{version: v[789]|v1[01234]}/resources") +@Path("{version: v[1-9][0-9]*|latest}/resources") public class VertexIdConsumer extends RESTAPI { - + private ModelType introspectorFactoryType = ModelType.MOXY; - private QueryStyle queryStyle = QueryStyle.TRAVERSAL; + private QueryStyle queryStyle = QueryStyle.TRAVERSAL_URI; private final String ID_ENDPOINT = "/id/{vertexid: \\d+}"; + private HttpEntry resourceHttpEntry; + /** * Gets the by vertex id. * @@ -91,7 +93,7 @@ public class VertexIdConsumer extends RESTAPI { String sourceOfTruth = headers.getRequestHeaders().getFirst("X-FromAppId"); String transId = headers.getRequestHeaders().getFirst("X-TransactionId"); String realTime = headers.getRequestHeaders().getFirst("Real-Time"); - Version version = Version.valueOf(versionParam); + SchemaVersion version = new SchemaVersion(versionParam); Status status = Status.NOT_FOUND; String result = ""; Response response = null; @@ -99,9 +101,10 @@ public class VertexIdConsumer extends RESTAPI { try { int depth = setDepth(depthParam); DBConnectionType type = this.determineConnectionType(sourceOfTruth, realTime); - HttpEntry httpEntry = new HttpEntry(version, introspectorFactoryType, queryStyle, type); - dbEngine = httpEntry.getDbEngine(); - Loader loader = httpEntry.getLoader(); + resourceHttpEntry = SpringContextAware.getBean("traversalUriHttpEntry", HttpEntry.class); + resourceHttpEntry.setHttpEntryProperties(version, type); + dbEngine = resourceHttpEntry.getDbEngine(); + Loader loader = resourceHttpEntry.getLoader(); DBSerializer serializer = new DBSerializer(version, dbEngine, introspectorFactoryType, sourceOfTruth); @@ -127,7 +130,7 @@ public class VertexIdConsumer extends RESTAPI { List<DBRequest> requests = new ArrayList<>(); requests.add(request); - Pair<Boolean, List<Pair<URI, Response>>> responsesTuple = httpEntry.process(requests, sourceOfTruth); + Pair<Boolean, List<Pair<URI, Response>>> responsesTuple = resourceHttpEntry.process(requests, sourceOfTruth); response = responsesTuple.getValue1().get(0).getValue1(); } catch (AAIException e){ response = consumerExceptionResponseGenerator(headers, info, HttpMethod.GET, e); diff --git a/aai-resources/src/main/java/org/onap/aai/rest/bulk/BulkOperation.java b/aai-resources/src/main/java/org/onap/aai/rest/bulk/BulkOperation.java index dfd0f1d..82a706f 100644 --- a/aai-resources/src/main/java/org/onap/aai/rest/bulk/BulkOperation.java +++ b/aai-resources/src/main/java/org/onap/aai/rest/bulk/BulkOperation.java @@ -1,87 +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.rest.bulk;
-
-import java.net.URI;
-import java.util.List;
-import java.util.Map.Entry;
-
-import javax.ws.rs.core.UriInfo;
-
-import org.onap.aai.introspection.Introspector;
-import org.onap.aai.restcore.HttpMethod;
-import org.springframework.util.MultiValueMap;
-
-public class BulkOperation {
-
- private URI uri = null;
- private Introspector introspector = null;
- private HttpMethod httpMethod = null;
- private String rawReq = "";
- private UriInfo uriInfo = new BulkUriInfo();
-
- public UriInfo getUriInfo() {
- return uriInfo;
- }
-
- public String getRawReq() {
- return rawReq;
- }
-
- public void setRawReq(String rawReq) {
- this.rawReq = rawReq;
- }
-
- public URI getUri() {
- return uri;
- }
-
- public void setUri(URI uri) {
- this.uri = uri;
- }
-
- public Introspector getIntrospector() {
- return introspector;
- }
-
- public void setIntrospector(Introspector introspector) {
- this.introspector = introspector;
- }
-
- public HttpMethod getHttpMethod() {
- return httpMethod;
- }
-
- public void setHttpMethod(HttpMethod httpMethod) {
- this.httpMethod = httpMethod;
- }
-
- public void addUriInfoQueryParams(MultiValueMap<String, String> queryParams) {
-
- BulkUriInfo bui = new BulkUriInfo();
-
- for (Entry<String, List<String>> entry : queryParams.entrySet()) {
- bui.addParams(entry.getKey(), entry.getValue());
- }
-
- this.uriInfo = bui;
- }
-
-}
+/** + * ============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.bulk; + +import java.net.URI; +import java.util.List; +import java.util.Map.Entry; + +import javax.ws.rs.core.UriInfo; + +import org.onap.aai.introspection.Introspector; +import org.onap.aai.parsers.query.QueryParser; +import org.onap.aai.restcore.HttpMethod; +import org.springframework.util.MultiValueMap; + +public class BulkOperation { + + private URI uri = null; + private QueryParser uriQuery = null; + private Introspector introspector = null; + private HttpMethod httpMethod = null; + private String rawReq = ""; + private UriInfo uriInfo = new BulkUriInfo(); + + public UriInfo getUriInfo() { + return uriInfo; + } + + public String getRawReq() { + return rawReq; + } + + public void setRawReq(String rawReq) { + this.rawReq = rawReq; + } + + public URI getUri() { + return uri; + } + + public void setUri(URI uri) { + this.uri = uri; + } + + public QueryParser getUriQuery() { + return uriQuery; + } + + public void setUriQuery(QueryParser uriQuery) { + this.uriQuery = uriQuery; + } + + public Introspector getIntrospector() { + return introspector; + } + + public void setIntrospector(Introspector introspector) { + this.introspector = introspector; + } + + public HttpMethod getHttpMethod() { + return httpMethod; + } + + public void setHttpMethod(HttpMethod httpMethod) { + this.httpMethod = httpMethod; + } + + public void addUriInfoQueryParams(MultiValueMap<String, String> queryParams) { + + BulkUriInfo bui = new BulkUriInfo(); + + for (Entry<String, List<String>> entry : queryParams.entrySet()) { + bui.addParams(entry.getKey(), entry.getValue()); + } + + this.uriInfo = bui; + } + + public void addUriInfo(UriInfo uriInfo){ + this.uriInfo = uriInfo; + } + +} diff --git a/aai-resources/src/main/java/org/onap/aai/rest/bulk/BulkOperationResponse.java b/aai-resources/src/main/java/org/onap/aai/rest/bulk/BulkOperationResponse.java index d5c53fd..130ab1c 100644 --- a/aai-resources/src/main/java/org/onap/aai/rest/bulk/BulkOperationResponse.java +++ b/aai-resources/src/main/java/org/onap/aai/rest/bulk/BulkOperationResponse.java @@ -1,89 +1,89 @@ -/**
- * ============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.bulk;
-
-import java.net.URI;
-import java.util.ArrayList;
-import java.util.List;
-
-import javax.ws.rs.core.Response;
-
-import org.javatuples.Pair;
-import org.onap.aai.restcore.HttpMethod;
-
-public class BulkOperationResponse {
-
- private URI uri = null;
- private Response response = null;
- private HttpMethod httpMethod = null;
-
- private BulkOperationResponse() {
-
- }
-
- private BulkOperationResponse(HttpMethod httpMethod, Pair<URI, Response> pair) {
- this.httpMethod = httpMethod;
- this.response = pair.getValue1();
- this.uri = pair.getValue0();
- }
-
- public BulkOperationResponse(HttpMethod httpMethod, URI uri, Response response) {
- this.httpMethod = httpMethod;
- this.response = response;
- this.uri = uri;
- }
-
- public URI getUri() {
- return uri;
- }
-
- public void setUri(URI uri) {
- this.uri = uri;
- }
-
- public Response getResponse() {
- return response;
- }
-
- public void setResponse(Response response) {
- this.response = response;
- }
-
- public HttpMethod getHttpMethod() {
- return httpMethod;
- }
-
- public void setHttpMethod(HttpMethod httpMethod) {
- this.httpMethod = httpMethod;
- }
-
- public static List<BulkOperationResponse> processPairList(HttpMethod httpMethod, List<Pair<URI, Response>> pairList) {
-
- List<BulkOperationResponse> borList = new ArrayList<>();
- BulkOperationResponse bor;
-
- for (Pair<URI, Response> pair: pairList) {
- bor = new BulkOperationResponse(httpMethod, pair);
- borList.add(bor);
- }
-
- return borList;
- }
-}
+/** + * ============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.bulk; + +import java.net.URI; +import java.util.ArrayList; +import java.util.List; + +import javax.ws.rs.core.Response; + +import org.javatuples.Pair; +import org.onap.aai.restcore.HttpMethod; + +public class BulkOperationResponse { + + private URI uri = null; + private Response response = null; + private HttpMethod httpMethod = null; + + private BulkOperationResponse() { + + } + + private BulkOperationResponse(HttpMethod httpMethod, Pair<URI, Response> pair) { + this.httpMethod = httpMethod; + this.response = pair.getValue1(); + this.uri = pair.getValue0(); + } + + public BulkOperationResponse(HttpMethod httpMethod, URI uri, Response response) { + this.httpMethod = httpMethod; + this.response = response; + this.uri = uri; + } + + public URI getUri() { + return uri; + } + + public void setUri(URI uri) { + this.uri = uri; + } + + public Response getResponse() { + return response; + } + + public void setResponse(Response response) { + this.response = response; + } + + public HttpMethod getHttpMethod() { + return httpMethod; + } + + public void setHttpMethod(HttpMethod httpMethod) { + this.httpMethod = httpMethod; + } + + public static List<BulkOperationResponse> processPairList(HttpMethod httpMethod, List<Pair<URI, Response>> pairList) { + + List<BulkOperationResponse> borList = new ArrayList<>(); + BulkOperationResponse bor; + + for (Pair<URI, Response> pair: pairList) { + bor = new BulkOperationResponse(httpMethod, pair); + borList.add(bor); + } + + return borList; + } +} diff --git a/aai-resources/src/main/java/org/onap/aai/rest/bulk/BulkSingleTransactionConsumer.java b/aai-resources/src/main/java/org/onap/aai/rest/bulk/BulkSingleTransactionConsumer.java new file mode 100644 index 0000000..1e6ab0c --- /dev/null +++ b/aai-resources/src/main/java/org/onap/aai/rest/bulk/BulkSingleTransactionConsumer.java @@ -0,0 +1,414 @@ +/** + * ============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.bulk; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import org.javatuples.Pair; +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.logging.ErrorLogHelper; +import org.onap.aai.logging.LoggingContext; +import org.onap.aai.rest.bulk.pojos.Operation; +import org.onap.aai.rest.bulk.pojos.OperationResponse; +import org.onap.aai.rest.bulk.pojos.Transaction; +import org.onap.aai.rest.bulk.pojos.TransactionResponse; +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.MediaType; +import org.onap.aai.restcore.RESTAPI; +import org.onap.aai.serialization.engines.TransactionalGraphEngine; +import org.onap.aai.setup.SchemaVersion; +import org.onap.aai.util.AAIConfig; +import org.onap.aai.util.AAIConstants; +import org.springframework.web.util.UriComponents; +import org.springframework.web.util.UriComponentsBuilder; + +import javax.servlet.http.HttpServletRequest; +import javax.ws.rs.*; +import javax.ws.rs.core.*; +import java.io.UnsupportedEncodingException; +import java.net.URI; +import java.util.*; + +@Path(value = "{version: v[1-9][0-9]*|latest}/bulk/single-transaction") +public class BulkSingleTransactionConsumer extends RESTAPI { + + private static final String TARGET_ENTITY = "aai-resources"; + private static final Set<String> validOperations = Collections.unmodifiableSet(new HashSet<>(Arrays.asList("put", "patch", "delete"))); + private int allowedOperationCount = 30; + private TransactionalGraphEngine dbEngine = null; + + @POST + @Consumes(value = javax.ws.rs.core.MediaType.APPLICATION_JSON) + @Produces(value = javax.ws.rs.core.MediaType.APPLICATION_JSON) + public Response process(String content, @PathParam(value = "version")String versionParam, @Context HttpHeaders headers, @Context UriInfo info, @Context HttpServletRequest req){ + + String transId = headers.getRequestHeaders().getFirst("X-TransactionId"); + String sourceOfTruth = headers.getRequestHeaders().getFirst("X-FromAppId"); + String realTime = headers.getRequestHeaders().getFirst("Real-Time"); + SchemaVersion version = new SchemaVersion(versionParam); + DBConnectionType type; + + initLogging(req, transId, sourceOfTruth); + + try { + type = this.determineConnectionType(sourceOfTruth, realTime); + + // unmarshall the payload. + Gson gson = new Gson(); + Transaction transaction; + try { + transaction = gson.fromJson(content, Transaction.class); + } catch (Exception e) { + throw new AAIException("AAI_6111", "Input payload does not follow bulk/single-transaction interface"); + } + + //set the operation count limit + setOperationCount(headers); + //validate + validate(transaction); + + //generate bulkoperations + List<BulkOperation> bulkOperations = generateBulkOperations(transaction); + + //init http entry + HttpEntry resourceHttpEntry = SpringContextAware.getBean("traversalUriHttpEntry", HttpEntry.class); + resourceHttpEntry.setHttpEntryProperties(version, type); + Loader loader = resourceHttpEntry.getLoader(); + TransactionalGraphEngine dbEngine = resourceHttpEntry.getDbEngine(); + + //populate uri query + populateUriQuery(bulkOperations, dbEngine); + + //populate introspector for operations + populateIntrospectors(bulkOperations, loader); + + //generate db process from bulk operation + List<DBRequest> dbRequests = bulkOperationToDbRequests(headers, transId, bulkOperations); + + //process db requests + Pair<Boolean, List<Pair<URI, Response>>> results = resourceHttpEntry.process(dbRequests, sourceOfTruth, this.enableResourceVersion()); + + //process result of db requests + TransactionResponse transactionResponse = buildTransactionResponse(transaction, results.getValue1()); + + //commit/rollback based on results + if (results.getValue0()) { //everything was processed without error + dbEngine.commit(); + } else { //something failed + dbEngine.rollback(); + } + + return Response + .status(Response.Status.CREATED) + .entity(new GsonBuilder().serializeNulls().create().toJson(transactionResponse)) + .build(); + + } catch (AAIException e) { + return consumerExceptionResponseGenerator(headers, info, javax.ws.rs.HttpMethod.POST, e); + } finally { + if (dbEngine != null) { + dbEngine.rollback(); + } + } + + } + + + /** + * Builds the response + * @param transaction the input transactions + * @param results the response of all of he operations + * @return TansactionResponse obj representing the result of the transaction + * @throws AAIException thrown if there is a failure in the result. Msg contains the details of the first failure. + */ + private TransactionResponse buildTransactionResponse(Transaction transaction, List<Pair<URI, Response>> results) throws AAIException { + TransactionResponse transactionResponse = new TransactionResponse(); + transactionResponse.setOperationResponses(new ArrayList<>(transaction.getOperations().size())); + final String failureInResponse = "Operation %s failed with status code (%s) and msg (%s)"; + for (int i = 0; i < transaction.getOperations().size(); i++) { + if (!Response.Status.Family.familyOf(results.get(i).getValue1().getStatus()) + .equals(Response.Status.Family.SUCCESSFUL)) { + throw new AAIException("AAI_3000", + String.format( + failureInResponse, + i, + results.get(i).getValue1().getStatus(), + results.get(i).getValue1().getEntity())); + } + OperationResponse operationResponse = new OperationResponse(); + operationResponse.setResponseStatusCode(results.get(i).getValue1().getStatus()); + operationResponse.setAction(transaction.getOperations().get(i).getAction()); + operationResponse.setUri(transaction.getOperations().get(i).getUri()); + operationResponse.setBody(results.get(i).getValue1().getEntity()); + transactionResponse.getOperationResponsess().add(i, operationResponse); + } + return transactionResponse; + } + + /** + * Generate one DBRequest per BulkOperation + * @param headers request headers + * @param transId transaction id + * @param bulkOperations operations to convert + * @return One DBRequest per BulkOperation + * @throws AAIException thrown if there are any issues with the transform + */ + private List<DBRequest> bulkOperationToDbRequests(@Context HttpHeaders headers, String transId, List<BulkOperation> bulkOperations) throws AAIException { + List<DBRequest> requests = new ArrayList<>(); + for (int i = 0; i < bulkOperations.size(); i++) { + try { + BulkOperation bulkOperation = bulkOperations.get(i); + DBRequest request = new DBRequest.Builder( + bulkOperation.getHttpMethod(), + bulkOperation.getUri(), + bulkOperation.getUriQuery(), + bulkOperation.getIntrospector(), + headers, + bulkOperation.getUriInfo(), + transId + ).rawRequestContent(bulkOperation.getRawReq()).build(); + requests.add(request); + } catch (Exception e) { + throw new AAIException("AAI_3000", "Error with operation " + i + ": " +e.getMessage()); + } + } + return requests; + } + + /** + * Sets the uriquery for each bulk operation + * @param bulkOperations operations to generate queries for + * @param dbEngine engine for query builder generation + * @throws AAIException thrown for issues with generating uri query + */ + private void populateUriQuery(List<BulkOperation> bulkOperations, TransactionalGraphEngine dbEngine) throws AAIException { + for (int i = 0; i < bulkOperations.size(); i++) { + try { + bulkOperations.get(i).setUriQuery(dbEngine.getQueryBuilder().createQueryFromURI(bulkOperations.get(i).getUri())); + } catch (AAIException e) { + throw new AAIException(e.getCode(), "Error with operation " + i + ": " +e.getMessage()); + } catch (UnsupportedEncodingException e) { + throw new AAIException("AAI_3000", "Error with operation " + i + ": " +e.getMessage()); + } + } + } + + /** + * Sets the introspector for each bulk operation. requires that uriquery is set per operation + * @param bulkOperations operations to generate introspector for + * @param loader Loader for generating introspector + * @throws AAIException thrown for issues with generating introspector + */ + private void populateIntrospectors(List<BulkOperation> bulkOperations, Loader loader) throws AAIException { + + final String objectUnMarshallMsg = "Body of operation %s could not be unmarshalled: %s"; + Introspector obj; + for (int i = 0; i < bulkOperations.size(); i++) { + BulkOperation bulkOperation = bulkOperations.get(i); + try { + if (bulkOperation.getHttpMethod().equals(HttpMethod.PUT_EDGE) + || bulkOperation.getHttpMethod().equals(HttpMethod.DELETE_EDGE)) { + obj = loader.unmarshal("relationship", bulkOperation.getRawReq(), MediaType.APPLICATION_JSON_TYPE); + bulkOperation.setIntrospector(obj); + } else { + String objName = bulkOperation.getUriQuery().getResultType(); + if (bulkOperation.getHttpMethod().equals(HttpMethod.DELETE)) { + obj = loader.introspectorFromName(objName); + } else { + obj = loader.unmarshal(objName, bulkOperation.getRawReq(), MediaType.APPLICATION_JSON_TYPE); + this.validateIntrospector(obj, loader, bulkOperation.getUri(), bulkOperation.getHttpMethod()); + } + bulkOperation.setIntrospector(obj); + } + } catch (UnsupportedEncodingException e) { + throw new AAIException("AAI_3000", String.format(objectUnMarshallMsg, i, bulkOperation.getRawReq())); + } + } + + } + + /** + * Sets the allowedOperationCount to one of the following + * - Integer.MAX_VALUE if override limit is configured + * - Property in aaiconfig + * - 30 by default + * @param headers request header + */ + private void setOperationCount(HttpHeaders headers) { + try { + String overrideLimit = headers.getRequestHeaders().getFirst("X-OverrideLimit"); + boolean isOverride = overrideLimit != null && !AAIConfig.get(AAIConstants.AAI_BULKCONSUMER_OVERRIDE_LIMIT).equals("false") + && overrideLimit.equals(AAIConfig.get(AAIConstants.AAI_BULKCONSUMER_OVERRIDE_LIMIT)); + if (isOverride) { + allowedOperationCount = Integer.MAX_VALUE; + } else { + allowedOperationCount = AAIConfig.getInt(AAIConstants.AAI_BULKCONSUMER_LIMIT); + } + } catch (AAIException e) { + allowedOperationCount = 30; + } + } + + /** + * Converts the request transaction into a list of bulk operations + * @param transaction transaction to extract bulk operations from + * @return list of bulk operations + */ + private List<BulkOperation> generateBulkOperations(Transaction transaction) { + List<BulkOperation> bulkOperations = new ArrayList<>(transaction.getOperations().size()); + + BulkOperation bulkOperation; + for (int i = 0; i < transaction.getOperations().size(); i++) { + final Operation operation = transaction.getOperations().get(i); + bulkOperation = new BulkOperation(); + + UriComponents uriComponents = UriComponentsBuilder.fromUriString(operation.getUri()).build(); + bulkOperation.setUri(UriBuilder.fromPath(uriComponents.getPath()).build()); + bulkOperation.addUriInfoQueryParams(uriComponents.getQueryParams()); + bulkOperation.setHttpMethod(getHttpMethod(operation.getAction(), bulkOperation.getUri())); + bulkOperation.setRawReq(operation.getBody().toString()); + bulkOperations.add(bulkOperation); + } + + return bulkOperations; + } + + /** + * Map action to httpmethod + * @param action action to be mapped + * @param uri uri of the action + * @return HttpMethod thats action/uri maps to + */ + private HttpMethod getHttpMethod(String action, URI uri) { + HttpMethod method = HttpMethod.GET; + switch (action) { + case "put": + method = HttpMethod.PUT; + break; + case "delete": + method = HttpMethod.DELETE; + break; + case "patch": + method = HttpMethod.MERGE_PATCH; + break; + } + if (uri.getPath().endsWith("/relationship-list/relationship")) { + if (method.equals(HttpMethod.PUT)) { + method = HttpMethod.PUT_EDGE; + } else if (method.equals(HttpMethod.DELETE)) { + method = HttpMethod.DELETE_EDGE; + } + } + + return method; + } + + + /** + * For each operation validates: + * - action is provided and correct. + * - uri exists + * - body exists + * @param transaction parsed payload + * @throws AAIException with the violations in the msg + */ + private void validate(Transaction transaction) throws AAIException { + if (transaction == null) { + throw new AAIException("AAI_6111", "input payload does not follow /bulk/single-transaction interface"); + } + + if (transaction.getOperations() == null + || transaction.getOperations().isEmpty()) { + throw new AAIException("AAI_6118", " Payload has no objects to operate on"); + } else if (transaction.getOperations().size() > allowedOperationCount){ + throw new AAIException("AAI_6147", " Allowed limit = " + allowedOperationCount); + } + + final String missingFieldMsgFormat = "Operation %s missing '%s'"; + final String invalidActionMsgFormat = "Operation %s has invalid action '%s'"; + List<String> msgs = new ArrayList<>(); + for (int i = 0; i < transaction.getOperations().size(); i++) { + final Operation operation = transaction.getOperations().get(i); + if (operation.getAction() == null || operation.getAction().isEmpty()) { + msgs.add(String.format(missingFieldMsgFormat, i, "action")); + } else if (!validOperations.contains(operation.getAction())) { + msgs.add(String.format(invalidActionMsgFormat, i, operation.getAction())); + } + if (operation.getUri() == null || operation.getUri().isEmpty()) { + msgs.add(String.format(missingFieldMsgFormat, i, "uri")); + } + if (operation.getBody() == null) { + msgs.add(String.format(missingFieldMsgFormat, i, "body")); + } + } + if (!msgs.isEmpty()) { + throw new AAIException("AAI_6111", "input payload missing required properties. [" + String.join(", ", msgs) + "]"); + } + + } + + /** + * Initialize logging context + * @param req requestContext + * @param transId transaction id + * @param sourceOfTruth application source + */ + private void initLogging(@Context HttpServletRequest req, String transId, String sourceOfTruth) { + String serviceName = req.getMethod() + " " + req.getRequestURI().toString(); + LoggingContext.requestId(transId); + LoggingContext.partnerName(sourceOfTruth); + LoggingContext.serviceName(serviceName); + LoggingContext.targetEntity(TARGET_ENTITY); + LoggingContext.targetServiceName(serviceName); + } + + protected boolean enableResourceVersion() { + return true; + } + + + /** + * Consumer exception response generator. + * + * @param headers the headers + * @param info the info + * @param action type of request + * @param e the e + * @return the response + */ + protected Response consumerExceptionResponseGenerator(HttpHeaders headers, UriInfo info, String action, AAIException e) { + ArrayList<String> templateVars = new ArrayList<>(); + templateVars.add(action); //GET, PUT, etc + templateVars.add(info.getPath()); + templateVars.addAll(e.getTemplateVars()); + + ErrorLogHelper.logException(e); + return Response + .status(e.getErrorObject().getHTTPResponseCode()) + .entity(ErrorLogHelper.getRESTAPIErrorResponseWithLogging(headers.getAcceptableMediaTypes(), e, templateVars)) + .build(); + } +} diff --git a/aai-resources/src/main/java/org/onap/aai/rest/bulk/BulkUriInfo.java b/aai-resources/src/main/java/org/onap/aai/rest/bulk/BulkUriInfo.java index 41cdd85..50b218f 100644 --- a/aai-resources/src/main/java/org/onap/aai/rest/bulk/BulkUriInfo.java +++ b/aai-resources/src/main/java/org/onap/aai/rest/bulk/BulkUriInfo.java @@ -1,130 +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.bulk;
-
-import java.net.URI;
-import java.util.List;
-
-import javax.ws.rs.core.*;
-
-
-public class BulkUriInfo implements UriInfo {
-
- private MultivaluedMap<String, String> queryParams= new MultivaluedHashMap<>();
-
- @Override
- public String getPath() {
- return null;
- }
-
- @Override
- public String getPath(boolean decode) {
- return null;
- }
-
- @Override
- public List<PathSegment> getPathSegments() {
- return null;
- }
-
- @Override
- public List<PathSegment> getPathSegments(boolean decode) {
- return null;
- }
-
- @Override
- public URI getRequestUri() {
- return null;
- }
-
- @Override
- public UriBuilder getRequestUriBuilder() {
- return null;
- }
-
- @Override
- public URI getAbsolutePath() {
- return null;
- }
-
- @Override
- public UriBuilder getAbsolutePathBuilder() {
- return null;
- }
-
- @Override
- public URI getBaseUri() {
- return null;
- }
-
- @Override
- public UriBuilder getBaseUriBuilder() {
- return null;
- }
-
- @Override
- public MultivaluedMap<String, String> getPathParameters() {
- return null;
- }
-
- @Override
- public MultivaluedMap<String, String> getPathParameters(boolean decode) {
- return null;
- }
-
- @Override
- public MultivaluedMap<String, String> getQueryParameters() {
- return this.queryParams;
- }
-
- @Override
- public MultivaluedMap<String, String> getQueryParameters(boolean decode) {
- return this.queryParams;
- }
-
- @Override
- public List<String> getMatchedURIs() {
- return null;
- }
-
- @Override
- public List<String> getMatchedURIs(boolean decode) {
- return null;
- }
-
- @Override
- public List<Object> getMatchedResources() {
- return null;
- }
-
- @Override
- public URI resolve(URI uri) {
- return null;
- }
-
- @Override
- public URI relativize(URI uri) {
- return null;
- }
-
- public void addParams(String key, List<String> list) {
- this.queryParams.put(key, list);
- }
-}
+/** + * ============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.bulk; + +import java.net.URI; +import java.util.List; + +import javax.ws.rs.core.*; + + +public class BulkUriInfo implements UriInfo { + + private MultivaluedMap<String, String> queryParams= new MultivaluedHashMap<>(); + + @Override + public String getPath() { + return null; + } + + @Override + public String getPath(boolean decode) { + return null; + } + + @Override + public List<PathSegment> getPathSegments() { + return null; + } + + @Override + public List<PathSegment> getPathSegments(boolean decode) { + return null; + } + + @Override + public URI getRequestUri() { + return null; + } + + @Override + public UriBuilder getRequestUriBuilder() { + return null; + } + + @Override + public URI getAbsolutePath() { + return null; + } + + @Override + public UriBuilder getAbsolutePathBuilder() { + return null; + } + + @Override + public URI getBaseUri() { + return null; + } + + @Override + public UriBuilder getBaseUriBuilder() { + return null; + } + + @Override + public MultivaluedMap<String, String> getPathParameters() { + return null; + } + + @Override + public MultivaluedMap<String, String> getPathParameters(boolean decode) { + return null; + } + + @Override + public MultivaluedMap<String, String> getQueryParameters() { + return this.queryParams; + } + + @Override + public MultivaluedMap<String, String> getQueryParameters(boolean decode) { + return this.queryParams; + } + + @Override + public List<String> getMatchedURIs() { + return null; + } + + @Override + public List<String> getMatchedURIs(boolean decode) { + return null; + } + + @Override + public List<Object> getMatchedResources() { + return null; + } + + @Override + public URI resolve(URI uri) { + return null; + } + + @Override + public URI relativize(URI uri) { + return null; + } + + public void addParams(String key, List<String> list) { + this.queryParams.put(key, list); + } +} diff --git a/aai-resources/src/test/java/org/onap/aai/util/DbTestFileWatcher.java b/aai-resources/src/main/java/org/onap/aai/rest/bulk/pojos/Operation.java index 60b9039..183f0ad 100644 --- a/aai-resources/src/test/java/org/onap/aai/util/DbTestFileWatcher.java +++ b/aai-resources/src/main/java/org/onap/aai/rest/bulk/pojos/Operation.java @@ -17,47 +17,48 @@ * limitations under the License. * ============LICENSE_END========================================================= */ -package org.onap.aai.util; - -import java.io.File; -import java.util.TimerTask; - -public abstract class DbTestFileWatcher extends TimerTask { - private long timeStamp; - private File file; - - /** - * Instantiates a new db test file watcher. - * - * @param file the file - */ - public DbTestFileWatcher( File file ) { - this.file = file; - this.timeStamp = file.lastModified(); - } - - /** - * {@inheritDoc} - */ - public final void run() { - long timeStamp = file.lastModified(); - - if( (timeStamp - this.timeStamp) > 500 ) { - this.timeStamp = timeStamp; - onChange(file); +package org.onap.aai.rest.bulk.pojos; + +import com.google.gson.*; +import com.google.gson.annotations.SerializedName; + +public class Operation { + + @SerializedName("action") + private String action; + @SerializedName("uri") + private String uri; + @SerializedName("body") + private JsonObject body; + + public Operation(String action, String uri, JsonObject body) { + this.action = action; + this.uri = uri; + this.body = body; } - try { - Thread.sleep(1000); - } catch (InterruptedException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } - } - - /** - * On change. - * - * @param file the file - */ - protected abstract void onChange( File file ); + + public String getAction() { + return action; + } + + public void setAction(String action) { + this.action = action; + } + + public JsonObject getBody() { + return body; + } + + public void setBody(JsonObject body) { + this.body = body; + } + + public String getUri() { + return uri; + } + + public void setUri(String uri) { + this.uri = uri; + } + } diff --git a/aai-resources/src/main/java/org/onap/aai/rest/bulk/pojos/OperationResponse.java b/aai-resources/src/main/java/org/onap/aai/rest/bulk/pojos/OperationResponse.java new file mode 100644 index 0000000..007e434 --- /dev/null +++ b/aai-resources/src/main/java/org/onap/aai/rest/bulk/pojos/OperationResponse.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.bulk.pojos; + +import com.google.gson.JsonObject; +import com.google.gson.JsonParser; +import com.google.gson.annotations.SerializedName; + +public class OperationResponse { + + @SerializedName("action") + private String action; + @SerializedName("uri") + private String uri; + @SerializedName("response-status-code") + private int responseStatusCode; + @SerializedName("response-body") + private JsonObject body; + + public String getAction() { + return action; + } + + public void setAction(String action) { + this.action = action; + } + + public JsonObject getBody() { + return body; + } + + public void setBody(JsonObject body) { + this.body = body; + } + + public String getUri() { + return uri; + } + + public void setUri(String uri) { + this.uri = uri; + } + + public int getResponseStatusCode() { + return responseStatusCode; + } + + public void setResponseStatusCode(int responseStatusCode) { + this.responseStatusCode = responseStatusCode; + } + + public void setBody(Object s) { + if (s == null) { + this.body = null; + } else { + this.body = new JsonParser().parse(s.toString()).getAsJsonObject(); + } + } +} diff --git a/aai-resources/src/main/java/org/onap/aai/transforms/LowerCamelToLowerHyphenConverter.java b/aai-resources/src/main/java/org/onap/aai/rest/bulk/pojos/Transaction.java index aae42b5..20329d7 100644 --- a/aai-resources/src/main/java/org/onap/aai/transforms/LowerCamelToLowerHyphenConverter.java +++ b/aai-resources/src/main/java/org/onap/aai/rest/bulk/pojos/Transaction.java @@ -17,17 +17,23 @@ * limitations under the License. * ============LICENSE_END========================================================= */ -package org.onap.aai.transforms; +package org.onap.aai.rest.bulk.pojos; -import com.google.common.base.CaseFormat; +import com.google.gson.annotations.SerializedName; -public class LowerCamelToLowerHyphenConverter implements Converter { +import java.util.List; - @Override - public String convert(String input) { - if(input == null){ - return null; - } - return CaseFormat.LOWER_CAMEL.to(CaseFormat.LOWER_HYPHEN, input); +public class Transaction { + + @SerializedName("operations") + private List<Operation> operations; + + public List<Operation> getOperations() { + return operations; } + + public void setOperations(List<Operation> operations) { + this.operations = operations; + } + } diff --git a/aai-resources/src/test/java/org/onap/aai/rest/retired/V7V8NamedQueriesTest.java b/aai-resources/src/main/java/org/onap/aai/rest/bulk/pojos/TransactionResponse.java index 88ae287..ce5462c 100644 --- a/aai-resources/src/test/java/org/onap/aai/rest/retired/V7V8NamedQueriesTest.java +++ b/aai-resources/src/main/java/org/onap/aai/rest/bulk/pojos/TransactionResponse.java @@ -17,12 +17,23 @@ * limitations under the License. * ============LICENSE_END========================================================= */ -package org.onap.aai.rest.retired; +package org.onap.aai.rest.bulk.pojos; -public class V7V8NamedQueriesTest extends RetiredConsumerTest { +import com.google.gson.annotations.SerializedName; - @Override - public RetiredConsumer getRetiredConsumer() { - return new V7V8NamedQueries(); +import java.util.List; + +public class TransactionResponse { + + @SerializedName("operation-responses") + private List<OperationResponse> operationResponses; + + public List<OperationResponse> getOperationResponsess() { + return operationResponses; } + + public void setOperationResponses(List<OperationResponse> operationResponses) { + this.operationResponses = operationResponses; + } + } diff --git a/aai-resources/src/main/java/org/onap/aai/rest/retired/RetiredConsumer.java b/aai-resources/src/main/java/org/onap/aai/rest/retired/RetiredConsumer.java deleted file mode 100644 index 808b8bc..0000000 --- a/aai-resources/src/main/java/org/onap/aai/rest/retired/RetiredConsumer.java +++ /dev/null @@ -1,141 +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", "")); - } - - Response response = Response - .status(e.getErrorObject().getHTTPResponseCode()) - .entity(ErrorLogHelper.getRESTAPIErrorResponse(headers.getAcceptableMediaTypes(), e, - templateVars)).build(); - - return response; - } -} diff --git a/aai-resources/src/main/java/org/onap/aai/rest/retired/V3ThroughV7Consumer.java b/aai-resources/src/main/java/org/onap/aai/rest/retired/V3ThroughV7Consumer.java deleted file mode 100644 index 1a590bb..0000000 --- a/aai-resources/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-6]}") //TODO re-add v7 when we fix our env issues AAI-8567 -public class V3ThroughV7Consumer extends RetiredConsumer { - -} diff --git a/aai-resources/src/main/java/org/onap/aai/rest/retired/V7V8Models.java b/aai-resources/src/main/java/org/onap/aai/rest/retired/V7V8Models.java deleted file mode 100644 index b023827..0000000 --- a/aai-resources/src/main/java/org/onap/aai/rest/retired/V7V8Models.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/models") -public class V7V8Models extends RetiredConsumer { - -} diff --git a/aai-resources/src/main/java/org/onap/aai/rest/retired/V7V8NamedQueries.java b/aai-resources/src/main/java/org/onap/aai/rest/retired/V7V8NamedQueries.java deleted file mode 100644 index 9a9c183..0000000 --- a/aai-resources/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-resources/src/main/java/org/onap/aai/rest/tools/ModelVersionTransformer.java b/aai-resources/src/main/java/org/onap/aai/rest/tools/ModelVersionTransformer.java deleted file mode 100644 index 15596d0..0000000 --- a/aai-resources/src/main/java/org/onap/aai/rest/tools/ModelVersionTransformer.java +++ /dev/null @@ -1,410 +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.tools; - -import java.io.UnsupportedEncodingException; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.NoSuchElementException; -import java.util.Set; - -import javax.servlet.http.HttpServletRequest; -import javax.ws.rs.Consumes; -import javax.ws.rs.Encoded; -import javax.ws.rs.POST; -import javax.ws.rs.Path; -import javax.ws.rs.PathParam; -import javax.ws.rs.Produces; -import javax.ws.rs.core.Context; -import javax.ws.rs.core.HttpHeaders; -import javax.ws.rs.core.MediaType; -import javax.ws.rs.core.MultivaluedMap; -import javax.ws.rs.core.Response; -import javax.ws.rs.core.Response.Status; -import javax.ws.rs.core.UriInfo; - -import org.apache.tinkerpop.gremlin.structure.Vertex; -import org.onap.aai.db.props.AAIProperties; -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.MarshallerProperties; -import org.onap.aai.introspection.ModelType; -import org.onap.aai.introspection.Version; -import org.onap.aai.introspection.exceptions.AAIUnknownObjectException; -import org.onap.aai.logging.ErrorLogHelper; -import org.onap.aai.logging.LogFormatTools; -import org.onap.aai.rest.db.HttpEntry; -import org.onap.aai.rest.exceptions.AAIInvalidXMLNamespace; -import org.onap.aai.rest.util.ValidateEncoding; -import org.onap.aai.restcore.RESTAPI; -import org.onap.aai.serialization.db.EdgeType; -import org.onap.aai.serialization.db.exceptions.NoEdgeRuleFoundException; -import org.onap.aai.serialization.engines.QueryStyle; -import org.onap.aai.serialization.engines.TransactionalGraphEngine; - -import com.att.eelf.configuration.EELFLogger; -import com.att.eelf.configuration.EELFManager; -import com.google.common.base.Joiner; - - -/** - * The Class ModelVersionTransformer. - */ -@Path("tools") -public class ModelVersionTransformer extends RESTAPI { - - private static final EELFLogger LOGGER = EELFManager.getInstance().getLogger(ModelVersionTransformer.class.getName()); - protected static String authPolicyFunctionName = "REST"; - private ModelType introspectorFactoryType = ModelType.MOXY; - private QueryStyle queryStyle = QueryStyle.TRAVERSAL; - protected static String MODEL_ELEMENTS = "model-elements"; - private static final String RELATIONSHIP="relationship"; - - - /** - * POST for model transformation. - * - * @param content the content - * @param uri the uri - * @param headers the headers - * @param info the info - * @param req the req - * @return the transformed model - * @Path("/{uri: modeltransform}") - * @throws UnsupportedEncodingException - */ - @POST - @Path("/{uri: modeltransform}") - @Consumes({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML }) - @Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML }) - public Response modelTransform (String content, @PathParam("uri") @Encoded String uri, @Context HttpHeaders headers, @Context UriInfo info, @Context HttpServletRequest req) throws UnsupportedEncodingException { - Response response = null; - TransactionalGraphEngine dbEngine = null; - Loader loader = null; - MediaType mediaType = headers.getMediaType(); - String sourceOfTruth = headers.getRequestHeaders().getFirst("X-FromAppId"); - String transId = headers.getRequestHeaders().getFirst("X-TransactionId"); - String realTime = headers.getRequestHeaders().getFirst("Real-Time"); - Boolean success = true; - AAIException ex; - - try { - validateRequest(info); - - DBConnectionType type = this.determineConnectionType(sourceOfTruth, realTime); - HttpEntry httpEntry = new HttpEntry(Version.v8, introspectorFactoryType, queryStyle, type); - loader = httpEntry.getLoader(); - dbEngine = httpEntry.getDbEngine(); - if (content.length() == 0) { - if (mediaType.toString().contains(MediaType.APPLICATION_JSON)) { - content = "{}"; - } else { - content = "<empty/>"; - } - } - - //Unmarshall the received model and store properties and values in a map. - Introspector obj = loader.unmarshal("Model", content, org.onap.aai.restcore.MediaType.getEnum(this.getInputMediaType(mediaType))); - if (obj == null) { - throw new AAIException("AAI_3000", "object could not be unmarshalled:" + content); - } - - if (mediaType.toString().contains(MediaType.APPLICATION_XML) && !content.equals("<empty/>") && isEmptyObject(obj)) { - throw new AAIInvalidXMLNamespace(content); - } - - Set<String> properties = obj.getProperties(); - java.util.Iterator<String> propItr = properties.iterator(); - - Map<String, Object> v8PropMap = new HashMap<String, Object>(); - while (propItr.hasNext()){ - String property = propItr.next(); - Object propertyValue = obj.getValue(property); - if (propertyValue != null) { - v8PropMap.put(propItr.next(), propertyValue); - } - } - // Get the current models and create a map of model-ver to model keys, this allows us - // to easily figure out and construct the relationships on the supplied v8 model - Map<String,String> modelVersionIdToModelInvariantIdMap = getCurrentModelsFromGraph(headers, transId, info); - - // Build the v10 - TODO - HttpEntry newHttpEntry = new HttpEntry(Version.v10, introspectorFactoryType, queryStyle, type); - Loader newLoader = newHttpEntry.getLoader(); - Introspector newModelObj = newLoader.introspectorFromName("Model"); - - // pull the attributes we need to apply to the model + model-ver objects - // model specific attrs - String oldModelInvariantId = obj.getValue("model-id"); - String oldModelType = obj.getValue("model-type"); - // model-ver specific - String oldModelName = obj.getValue("model-name"); - String oldModelVersionId = obj.getValue("model-name-version-id"); - String oldModelVersion = obj.getValue("model-version"); - - // copy attributes from the v8 model object to the v10 model object - newModelObj.setValue("model-invariant-id", oldModelInvariantId); - newModelObj.setValue("model-type", oldModelType); - - Introspector modelVersObj = newModelObj.newIntrospectorInstanceOfProperty("model-vers"); - - newModelObj.setValue("model-vers", modelVersObj.getUnderlyingObject()); - - List<Object> modelVerList = (List<Object>)modelVersObj.getValue("model-ver"); - - //create a model-ver object - Introspector modelVerObj = newLoader.introspectorFromName("ModelVer"); - // load attributes from the v8 model object into the v10 model-ver object - modelVerObj.setValue("model-version-id", oldModelVersionId); - modelVerObj.setValue("model-name", oldModelName); - modelVerObj.setValue("model-version", oldModelVersion); - - - if (obj.hasProperty(MODEL_ELEMENTS)) { - Introspector oldModelElements = obj.getWrappedValue(MODEL_ELEMENTS); - if (oldModelElements != null) { - Introspector newModelElements = modelVerObj.newIntrospectorInstanceOfProperty(MODEL_ELEMENTS); - modelVerObj.setValue(MODEL_ELEMENTS, newModelElements.getUnderlyingObject()); - repackModelElements(oldModelElements, newModelElements, modelVersionIdToModelInvariantIdMap); - } - } - - modelVerList.add(modelVerObj.getUnderlyingObject()); - - String outputMediaType = getMediaType(headers.getAcceptableMediaTypes()); - MarshallerProperties marshallerProperties = - new MarshallerProperties.Builder(org.onap.aai.restcore.MediaType.getEnum(outputMediaType)).build(); - - String result = newModelObj.marshal(marshallerProperties); - response = Response.ok(result).build(); - - } catch (AAIException e) { - - ArrayList<String> templateVars = new ArrayList<String>(2); - templateVars.add("POST modeltransform"); - templateVars.add("model-ver.model-version-id"); - response = Response - .status(e.getErrorObject().getHTTPResponseCode()) - .entity(ErrorLogHelper.getRESTAPIErrorResponse( - headers.getAcceptableMediaTypes(), e, - templateVars)).build(); - success = false; - } catch (Exception e) { - ArrayList<String> templateVars = new ArrayList<String>(2); - templateVars.add("POST modeltransform"); - templateVars.add("model-ver.model-version-id"); - ex = new AAIException("AAI_4000", e); - response = Response - .status(Status.INTERNAL_SERVER_ERROR) - .entity(ErrorLogHelper.getRESTAPIErrorResponse(headers.getAcceptableMediaTypes(), ex, templateVars)) - .build(); - LOGGER.error("Internal server error", e); - success = false; - } finally { - if (dbEngine != null) { - if (success) { - dbEngine.commit(); - } else { - dbEngine.rollback(); - } - } - } - return response; - } - - - private void repackModelElements(Introspector oldModelElements, Introspector newModelElements, Map<String, String> modelVersionIdToModelInvariantIdMap) - throws AAIUnknownObjectException, AAIException { - - List<Introspector> oldModelElementList = oldModelElements.getWrappedListValue("model-element"); - List<Object> newModelElementList = (List<Object>)newModelElements.getValue("model-element"); - - for (Introspector oldModelElement : oldModelElementList) { - Introspector newModelElement = newModelElements.getLoader().introspectorFromName("model-element"); - - ArrayList<String> attrs = new ArrayList<String>(); - - attrs.add("model-element-uuid"); - attrs.add("new-data-del-flag"); - attrs.add("cardinality"); - attrs.add("linkage-points"); - - for (String attr : attrs) { - if (oldModelElement.hasProperty(attr)) { - newModelElement.setValue(attr, oldModelElement.getValue(attr)); - } - } - - if (oldModelElement.hasProperty("relationship-list")) { - - Introspector oldRelationshipList = oldModelElement.getWrappedValue("relationship-list"); - Introspector newRelationshipList = newModelElements.getLoader().introspectorFromName("relationship-list"); - newModelElement.setValue("relationship-list", newRelationshipList.getUnderlyingObject()); - - List<Introspector> oldRelationshipListList = oldRelationshipList.getWrappedListValue(RELATIONSHIP); - List<Object> newRelationshipListList = (List<Object>)newRelationshipList.getValue(RELATIONSHIP); - - for (Introspector oldRelationship : oldRelationshipListList) { - - Introspector newRelationship = newModelElements.getLoader().introspectorFromName(RELATIONSHIP); - newRelationshipListList.add(newRelationship.getUnderlyingObject()); - - List<Introspector> oldRelationshipData = oldRelationship.getWrappedListValue("relationship-data"); - List<Object> newRelationshipData = (List<Object>)newRelationship.getValue("relationship-data"); - - newRelationship.setValue("related-to", "model-ver"); - - for (Introspector oldRelationshipDatum : oldRelationshipData) { - - String oldProp = null; - String oldVal = null; - - if (oldRelationshipDatum.hasProperty("relationship-key")) { - oldProp = oldRelationshipDatum.getValue("relationship-key"); - } - if (oldRelationshipDatum.hasProperty("relationship-value")) { - oldVal = oldRelationshipDatum.getValue("relationship-value"); - } - - if ("model.model-name-version-id".equals(oldProp)) { - // make two new relationshipDatum for use w/ the new style model - - // you should have the model in the list of models we collected earlier - if (modelVersionIdToModelInvariantIdMap.containsKey(oldVal)) { - Introspector newRelationshipDatum1 = newModelElements.getLoader().introspectorFromName("relationship-data"); - Introspector newRelationshipDatum2 = newModelElements.getLoader().introspectorFromName("relationship-data"); - - String modelId = modelVersionIdToModelInvariantIdMap.get(oldVal); - - // the first one points at the model-invariant-id of found model - newRelationshipDatum1.setValue("relationship-key", "model.model-invariant-id"); - newRelationshipDatum1.setValue("relationship-value", modelId); - - // the second one points at the model-version-id which corresponds to the old model-name-version-id - newRelationshipDatum2.setValue("relationship-key", "model-ver.model-version-id"); - newRelationshipDatum2.setValue("relationship-value", oldVal); - - newRelationshipData.add(newRelationshipDatum1.getUnderlyingObject()); - newRelationshipData.add(newRelationshipDatum2.getUnderlyingObject()); - } else { - throw new AAIException("AAI_6114", "No model-ver found using model-ver.model-version-id=" + oldVal); - } - } - } - - } - } - - if (oldModelElement.hasProperty(MODEL_ELEMENTS)) { - Introspector nextOldModelElements = oldModelElement.getWrappedValue(MODEL_ELEMENTS); - if (nextOldModelElements != null) { - Introspector nextNewModelElements = newModelElement.newIntrospectorInstanceOfProperty(MODEL_ELEMENTS); - newModelElement.setValue(MODEL_ELEMENTS, nextNewModelElements.getUnderlyingObject()); - repackModelElements(nextOldModelElements, nextNewModelElements, modelVersionIdToModelInvariantIdMap); - } - } - newModelElementList.add(newModelElement.getUnderlyingObject()); - } - return; - - } - - private Map<String, String> getCurrentModelsFromGraph(HttpHeaders headers, String transactionId, UriInfo info) throws NoEdgeRuleFoundException, AAIException { - - TransactionalGraphEngine dbEngine = null; - Map<String, String> modelVerModelMap = new HashMap<String,String>() ; - try { - - Version version = AAIProperties.LATEST; - DBConnectionType type = DBConnectionType.REALTIME; - - final HttpEntry httpEntry = new HttpEntry(version, introspectorFactoryType, queryStyle, type); - dbEngine = httpEntry.getDbEngine(); - - List<Vertex> modelVertices = dbEngine.asAdmin().getTraversalSource().V().has(AAIProperties.NODE_TYPE,"model").toList(); - for (Vertex modelVtx : modelVertices) { - - List<Vertex> modelVerVerts = dbEngine.getQueryBuilder(modelVtx).createEdgeTraversal(EdgeType.TREE, "model", "model-ver").toList(); - for (Vertex v : modelVerVerts) { - modelVerModelMap.put(v.value("model-version-id"), modelVtx.value("model-invariant-id")); - } - } - } catch (NoSuchElementException e) { - throw new NoSuchElementException(); - } catch (Exception e1) { - LOGGER.error("Exception while getting current models from graph"+ LogFormatTools.getStackTop(e1)); - } - return modelVerModelMap; - - } - - /** - * Validate request. - * - * @param uri the uri - * @param headers the headers - * @param req the req - * @param action the action - * @param info the info - * @throws AAIException the AAI exception - * @throws UnsupportedEncodingException the unsupported encoding exception - */ - private void validateRequest(UriInfo info) throws AAIException, UnsupportedEncodingException { - - if (!ValidateEncoding.getInstance().validate(info)) { - throw new AAIException("AAI_3008", "uri=" + getPath(info)); - } - } - - /** - * Gets the path. - * - * @param info the info - * @return the path - */ - private String getPath(UriInfo info) { - String path = info.getPath(false); - MultivaluedMap<String, String> map = info.getQueryParameters(false); - String params = "?"; - List<String> parmList = new ArrayList<>(); - for (String key : map.keySet()) { - for (String value : map.get(key)) { - parmList.add(key + "=" + value); - } - } - String queryParams = Joiner.on("&").join(parmList); - if (map.keySet().isEmpty()) { - path += params + queryParams; - } - - return path; - - } - - protected boolean isEmptyObject(Introspector obj) { - return "{}".equals(obj.marshal(false)); - } - - -} diff --git a/aai-resources/src/main/java/org/onap/aai/migration/Enabled.java b/aai-resources/src/main/java/org/onap/aai/rest/util/LogFormatTools.java index 8a2ef68..931ab0b 100644 --- a/aai-resources/src/main/java/org/onap/aai/migration/Enabled.java +++ b/aai-resources/src/main/java/org/onap/aai/rest/util/LogFormatTools.java @@ -17,19 +17,19 @@ * limitations under the License. * ============LICENSE_END========================================================= */ -package org.onap.aai.migration; +package org.onap.aai.rest.util; -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; +import java.time.ZoneOffset; +import java.time.ZonedDateTime; +import java.time.format.DateTimeFormatter; +public class LogFormatTools { -/** - * Used to enable a migration to be picked up by the {@link com.openecomp.aai.migration.MigrationControllerInternal MigrationController} - */ -@Target(ElementType.TYPE) -@Retention(value = RetentionPolicy.RUNTIME) -public @interface Enabled { - + private static final String DATE_FORMAT = "yyyy-MM-dd'T'HH:mm:ss.SSSZ"; + private static final DateTimeFormatter DTF = DateTimeFormatter.ofPattern(DATE_FORMAT) + .withZone(ZoneOffset.UTC); + + public static String getCurrentDateTime() { + return DTF.format(ZonedDateTime.now()); + } } diff --git a/aai-resources/src/main/java/org/onap/aai/rest/util/ValidateEncoding.java b/aai-resources/src/main/java/org/onap/aai/rest/util/ValidateEncoding.java index 3b4ea73..7d04bf7 100644 --- a/aai-resources/src/main/java/org/onap/aai/rest/util/ValidateEncoding.java +++ b/aai-resources/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-resources/src/main/java/org/onap/aai/service/AuthorizationService.java b/aai-resources/src/main/java/org/onap/aai/service/AuthorizationService.java index 616bb9c..d2597d0 100644 --- a/aai-resources/src/main/java/org/onap/aai/service/AuthorizationService.java +++ b/aai-resources/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; @@ -35,6 +37,7 @@ import java.util.HashMap; import java.util.Map; import java.util.stream.Stream; +@Profile(Profiles.ONE_WAY_SSL) @Service public class AuthorizationService { diff --git a/aai-resources/src/main/java/org/onap/aai/service/RetiredService.java b/aai-resources/src/main/java/org/onap/aai/service/RetiredService.java new file mode 100644 index 0000000..5989e31 --- /dev/null +++ b/aai-resources/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-resources/src/main/java/org/onap/aai/transforms/Converter.java b/aai-resources/src/main/java/org/onap/aai/transforms/Converter.java deleted file mode 100644 index 676c910..0000000 --- a/aai-resources/src/main/java/org/onap/aai/transforms/Converter.java +++ /dev/null @@ -1,24 +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.transforms; - -public interface Converter { - String convert(String input); -} diff --git a/aai-resources/src/main/java/org/onap/aai/transforms/LowerHyphenToLowerCamelConverter.java b/aai-resources/src/main/java/org/onap/aai/transforms/LowerHyphenToLowerCamelConverter.java deleted file mode 100644 index b4baa0c..0000000 --- a/aai-resources/src/main/java/org/onap/aai/transforms/LowerHyphenToLowerCamelConverter.java +++ /dev/null @@ -1,80 +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.transforms; - -/** - * <b>LowerHyphenToLowerCamelConverter</b> is the converter to use - * for converting from the lower hyphen to lower camel case - * <p> - * Examples: - * lower-test => lowerTest - * lower-Test => lowerTest - * lowerTest => lowerTest - * lower-test-val => lowerTestVal - * <p> - * - */ -public class LowerHyphenToLowerCamelConverter implements Converter { - - /** - * Converts the dash formatted string into a camel case string - * Ensure that the capitalization is not lost during this conversion - * <p> - * Loops through each character in the string - * checks if the current character is '-' and if it is then sets the - * boolean isPreviousCharDash to true and continues to the next iteration - * If the character is not '-', then checks if the previous character is dash - * If it is, then it will upper case the current character and appends to the builder - * Otherwise, it will just append the current character without any modification - * - * @param input the input string to convert to camel case - * @return a string that is converted to camel case - * if the input is null, then it returns null - */ - @Override - public String convert(String input) { - if(input == null){ - return null; - } - - int size = input.length(); - StringBuilder builder = new StringBuilder(size); - - boolean isPreviousCharDash = false; - - for(int index = 0; index < size; ++index){ - char ch = input.charAt(index); - - if(ch == '-'){ - isPreviousCharDash = true; - continue; - } - if(isPreviousCharDash){ - builder.append(Character.toUpperCase(ch)); - isPreviousCharDash = false; - } else{ - builder.append(ch); - } - } - - return builder.toString(); - } - -} diff --git a/aai-resources/src/main/java/org/onap/aai/transforms/MapTraverser.java b/aai-resources/src/main/java/org/onap/aai/transforms/MapTraverser.java deleted file mode 100644 index 9091998..0000000 --- a/aai-resources/src/main/java/org/onap/aai/transforms/MapTraverser.java +++ /dev/null @@ -1,86 +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.transforms; - - -import joptsimple.internal.Objects; - -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -public class MapTraverser { - - private Converter converter; - - public MapTraverser(Converter converter){ - this.converter = converter; - } - - public Map<String, Object> convertKeys(Map<String, Object> map){ - - Objects.ensureNotNull(map); - - Map<String, Object> modifiedMap = new HashMap<String, Object>(); - convertKeys(map, modifiedMap); - - return modifiedMap; - } - - private Map<String, Object> convertKeys(Map<String, Object> original, Map<String, Object> modified){ - - for(Map.Entry<String, Object> entry : original.entrySet()){ - String key = entry.getKey(); - key = converter.convert(key); - Object value = entry.getValue(); - if(value instanceof Map){ - modified.put(key, convertKeys((Map<String, Object>)value, new HashMap<String, Object>())); - } else if(value instanceof List){ - modified.put(key, convertKeys((List<Object>) value)); - } else { - modified.put(key, value); - } - } - - return modified; - } - - public List<Object> convertKeys(List<Object> list){ - - List<Object> modifiedList = new ArrayList<Object>(); - if(list != null && list.size() > 0){ - - for(Object o : list){ - if(o instanceof Map){ - Map<String, Object> map = (Map<String, Object>) o; - modifiedList.add(convertKeys(map)); - } else if(o instanceof List){ - List<Object> l = (List<Object>) o; - modifiedList.add(convertKeys(l)); - } else { - modifiedList.add(o); - } - } - } - - return modifiedList; - } -} diff --git a/aai-resources/src/main/java/org/onap/aai/util/DataConversionHelper.java b/aai-resources/src/main/java/org/onap/aai/util/DataConversionHelper.java deleted file mode 100644 index 0fc9779..0000000 --- a/aai-resources/src/main/java/org/onap/aai/util/DataConversionHelper.java +++ /dev/null @@ -1,62 +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; - - -/** - * Utility to convert data from one form to another - * - */ -public class DataConversionHelper { - - public static final String IPVERSION_IPV4 = "ipv4"; - public static final String IPVERSION_IPV6 = "ipv6"; - public static final String IPVERSION_UNKNOWN = "unknown"; - - /** - * Instantiates a new data conversion helper. - */ - public DataConversionHelper() { } - - /** - * Convert from 4 or 6 to ipv4 or ipv6. Returns unknown if 4 or 6 not passed. - * @param numVal expects good input but won't error if that's not what's passed - * @return IPVERSION constant, . - * @see org.onap.aai.domain.yang.IpVersion - */ - public static String convertIPVersionNumToString(String numVal) { - if ("4".equals(numVal)) return IPVERSION_IPV4; - else if ("6".equals(numVal))return IPVERSION_IPV6; - else return IPVERSION_UNKNOWN; - } - - /** - * Convert from ipv4 or ipv6 to 4 or 6. Returns 0 on bad input. - * @param stringVal expects good input but won't error if that's not what's passed - * @return 4 or 6, or 0 if a bad string is sent. - * @see org.onap.aai.domain.yang.IpVersion - */ - public static String convertIPVersionStringToNum(String stringVal) { - if (IPVERSION_IPV4.equals(stringVal)) return "4"; - else if (IPVERSION_IPV6.equals(stringVal)) return "6"; - else return "0"; - } - -} diff --git a/aai-resources/src/main/java/org/onap/aai/util/JettyObfuscationConversionCommandLineUtil.java b/aai-resources/src/main/java/org/onap/aai/util/JettyObfuscationConversionCommandLineUtil.java deleted file mode 100644 index 8e1de14..0000000 --- a/aai-resources/src/main/java/org/onap/aai/util/JettyObfuscationConversionCommandLineUtil.java +++ /dev/null @@ -1,98 +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 org.apache.commons.cli.BasicParser; -import org.apache.commons.cli.CommandLine; -import org.apache.commons.cli.CommandLineParser; -import org.apache.commons.cli.Options; -import org.apache.commons.cli.ParseException; -import org.eclipse.jetty.util.security.Password; - -import org.onap.aai.exceptions.AAIException; - -/* - * The purpose of this class is to be a tool for - * manually applying jetty obfuscation/deobfuscation - * so that one can obfuscate the various passwords/secrets - * in aaiconfig.properties. - * - * Originally, they were being encrypted by a similar - * command line utility, however the encryption key - * was being hardcoded in the src package - * which is a security violation. - * Since this ultimately just moved the problem of how - * to hide secrets to a different secret in a different file, - * and since that encryption was really just being done to - * obfuscate those values in case someone needed to look at - * properties with others looking at their screen, - * we decided that jetty obfuscation would be adequate - * for that task as well as - * removing the "turtles all the way down" secret-to-hide- - * the-secret-to-hide-the-secret problem. - */ -public class JettyObfuscationConversionCommandLineUtil { - - /** - * The main method. - * - * @param args the arguments - */ - public static void main(String[] args){ - Options options = new Options(); - options.addOption("e", true, "obfuscate the given string"); - options.addOption("d", true, "deobfuscate the given string"); - - CommandLineParser parser = new BasicParser(); - - try { - CommandLine cmd = parser.parse(options, args); - String toProcess = null; - - if (cmd.hasOption("e")){ - toProcess = cmd.getOptionValue("e"); - String encoded = Password.obfuscate(toProcess); - System.out.println(encoded); - } else if (cmd.hasOption("d")) { - toProcess = cmd.getOptionValue("d"); - String decoded_str = Password.deobfuscate(toProcess); - System.out.println(decoded_str); - } else { - usage(); - } - } catch (ParseException e) { - System.out.println("failed to parse input"); - System.out.println(e.toString()); - usage(); - } catch (Exception e) { - System.out.println("exception:" + e.toString()); - } - } - - /** - * Usage. - */ - private static void usage(){ - System.out.println("usage:");; - System.out.println("-e [string] to obfuscate"); - System.out.println("-d [string] to deobfuscate"); - System.out.println("-h help"); - } -} diff --git a/aai-resources/src/test/java/org/onap/aai/util/HbaseSaltPrefixerTest.java b/aai-resources/src/main/java/org/onap/aai/util/PositiveNumValidator.java index 6379240..ee58f55 100644 --- a/aai-resources/src/test/java/org/onap/aai/util/HbaseSaltPrefixerTest.java +++ b/aai-resources/src/main/java/org/onap/aai/util/PositiveNumValidator.java @@ -19,20 +19,17 @@ */ package org.onap.aai.util; -import org.junit.Test; +import com.beust.jcommander.IParameterValidator; +import com.beust.jcommander.ParameterException; -import static org.junit.Assert.assertTrue; +public class PositiveNumValidator implements IParameterValidator { -public class HbaseSaltPrefixerTest { + @Override + public void validate(String name, String value) throws ParameterException { + int num = Integer.parseInt(value); - /** - * Test. - */ - @Test - public void test() { - String key = "imakey"; - String saltedKey = HbaseSaltPrefixer.getInstance().prependSalt(key); - assertTrue(saltedKey.equals("0-imakey")); + if(num < 0) { + throw new ParameterException("Parameter " + name + " should be >= 0"); + } } - -} +}
\ No newline at end of file diff --git a/aai-resources/src/main/java/org/onap/aai/web/JerseyConfiguration.java b/aai-resources/src/main/java/org/onap/aai/web/JerseyConfiguration.java index 320c9c4..4cd09bf 100644 --- a/aai-resources/src/main/java/org/onap/aai/web/JerseyConfiguration.java +++ b/aai-resources/src/main/java/org/onap/aai/web/JerseyConfiguration.java @@ -21,11 +21,8 @@ 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.*; -import org.onap.aai.rest.retired.V7V8Models; -import org.onap.aai.rest.retired.V7V8NamedQueries; -import org.onap.aai.rest.tools.ModelVersionTransformer; +import org.onap.aai.rest.bulk.BulkSingleTransactionConsumer; import org.onap.aai.rest.util.EchoResponse; import org.reflections.Reflections; import org.springframework.beans.factory.annotation.Autowired; @@ -34,7 +31,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 +39,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()); @@ -60,19 +55,15 @@ public class JerseyConfiguration extends ResourceConfig { register(ExampleConsumer.class); register(BulkAddConsumer.class); register(BulkProcessConsumer.class); + register(BulkSingleTransactionConsumer.class); register(LegacyMoxyConsumer.class); register(URLFromVertexIdConsumer.class); - register(V7V8Models.class); - register(V7V8NamedQueries.class); - register(ModelVersionTransformer.class); //Request Filters registerFiltersForRequests(); // Response Filters registerFiltersForResponses(); - property(ServletProperties.FILTER_FORWARD_ON_404, true); - // Following registers the request headers and response headers // If the LoggingFilter second argument is set to true, it will print response value as well if ("true".equalsIgnoreCase(env.getProperty("aai.request.logging.enabled"))) { diff --git a/aai-resources/src/main/java/org/onap/aai/web/LocalHostAccessLog.java b/aai-resources/src/main/java/org/onap/aai/web/LocalHostAccessLog.java index 9d0aa9a..4bc3300 100644 --- a/aai-resources/src/main/java/org/onap/aai/web/LocalHostAccessLog.java +++ b/aai-resources/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-resources/src/main/java/org/onap/aai/web/WebConfiguration.java b/aai-resources/src/main/java/org/onap/aai/web/WebConfiguration.java index 5984734..5300611 100644 --- a/aai-resources/src/main/java/org/onap/aai/web/WebConfiguration.java +++ b/aai-resources/src/main/java/org/onap/aai/web/WebConfiguration.java @@ -19,28 +19,28 @@ */ package org.onap.aai.web; -//import org.springframework.context.annotation.Bean; -//import org.springframework.context.annotation.Configuration; -//import org.springframework.web.servlet.config.annotation.ViewControllerRegistry; -//import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter; -// -//@Configuration -//public class WebConfiguration { -// -// @Bean -// public WebMvcConfigurerAdapter forwardToIndex() { -// return new WebMvcConfigurerAdapter() { -// @Override -// public void addViewControllers(ViewControllerRegistry registry) { -// registry.addViewController("/swagger").setViewName( -// "redirect:/swagger/index.html"); -// registry.addViewController("/swagger/").setViewName( -// "redirect:/swagger/index.html"); -// registry.addViewController("/docs").setViewName( -// "redirect:/docs/html/index.html"); -// registry.addViewController("/docs/").setViewName( -// "redirect:/docs/html/index.html"); -// } -// }; -// } -//} +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.web.servlet.config.annotation.ViewControllerRegistry; +import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter; + +@Configuration +public class WebConfiguration { + + @Bean + public WebMvcConfigurerAdapter forwardToIndex() { + return new WebMvcConfigurerAdapter() { + @Override + public void addViewControllers(ViewControllerRegistry registry) { + registry.addViewController("/swagger").setViewName( + "redirect:/swagger/index.html"); + registry.addViewController("/swagger/").setViewName( + "redirect:/swagger/index.html"); + registry.addViewController("/docs").setViewName( + "redirect:/docs/html/index.html"); + registry.addViewController("/docs/").setViewName( + "redirect:/docs/html/index.html"); + } + }; + } +}
\ No newline at end of file diff --git a/aai-resources/src/main/jenkins/Jenkinsfile b/aai-resources/src/main/jenkins/Jenkinsfile deleted file mode 100644 index c74d439..0000000 --- a/aai-resources/src/main/jenkins/Jenkinsfile +++ /dev/null @@ -1,31 +0,0 @@ -node ("${BUILD_SLAVE}") { - // get the jenkinsfile root directory - def rootDir = pwd() - - def JAVA_HOME = tool 'jdk180' - env.PATH = "${JAVA_HOME}/bin:${env.PATH}" - sh 'which java' - sh 'java -version' - - env.DOCKER_HOST="tcp://localhost:4243" - - // load external groovy scripts - def build - def checkout - def deploy - dir('tmp') { - git url: "${GIT_URL}", branch: "${GIT_BRANCH}" - checkout = load 'src/main/jenkins/checkout.groovy' - build = load 'src/main/jenkins/build.groovy' - deploy = load 'src/main/jenkins/deploy.groovy' - } - - // check out code from git - checkout.gitCheckout() - - // build the git project - build.buildProject() - - deploy.deployService() - -}
\ No newline at end of file diff --git a/aai-resources/src/main/jenkins/build.groovy b/aai-resources/src/main/jenkins/build.groovy deleted file mode 100644 index 3170510..0000000 --- a/aai-resources/src/main/jenkins/build.groovy +++ /dev/null @@ -1,14 +0,0 @@ - - -def buildProject() { - stage 'Build Git Project' - wrap([$class: 'ConfigFileBuildWrapper', managedFiles: [[fileId: 'eb0c7cc1-e851-4bc2-9401-2680c225f88c', targetLocation: '', variable: 'MAVEN_SETTINGS']]]) { - mvn '-s $MAVEN_SETTINGS -f pom.xml' -} -} - -def mvn(args) { - sh "${tool 'maven3'}/bin/mvn ${args} ${MAVEN_GOALS}" -} - -return this
\ No newline at end of file diff --git a/aai-resources/src/main/jenkins/checkout.groovy b/aai-resources/src/main/jenkins/checkout.groovy deleted file mode 100644 index ed439ec..0000000 --- a/aai-resources/src/main/jenkins/checkout.groovy +++ /dev/null @@ -1,14 +0,0 @@ - -def gitCheckout() { - stage 'Checkout GIT' - //different ways to checkout - //checkout from master - //git "url: ${GIT_URL}, branch: ${GIT_BRANCH}" - //checkout from branch hardcoding" - //git branch: 'jenkins_deploy_test', credentialsId: 'b9bbafe5-53ce-4d2c-8b84-09137f75c592', url: 'https://codecloud.web.att.com/scm/st_ocnp/sdk-java-starter.git' - //checkout from branch parameters with credentials - //git branch: "${GIT_BRANCH}", credentialsId: 'b9bbafe5-53ce-4d2c-8b84-09137f75c592', url: "${GIT_URL}" - //checkout from branch parameters with no credentials - git branch: "${GIT_BRANCH}", url: "${GIT_URL}" -} -return this
\ No newline at end of file diff --git a/aai-resources/src/main/jenkins/deploy.groovy b/aai-resources/src/main/jenkins/deploy.groovy deleted file mode 100644 index 1a000e3..0000000 --- a/aai-resources/src/main/jenkins/deploy.groovy +++ /dev/null @@ -1,15 +0,0 @@ -def deployService(){ - stage 'Deploying Service' - - // get the jenkinsfile root directory - def ROOT_DIR = pwd() - ROOT_DIR = "${ROOT_DIR}"+'/src/main/kubernetes' - echo "ROOTDIR : ${ROOT_DIR}" - sh "/opt/app/kubernetes/v1.3.4/bin/kubectl --kubeconfig=${ROOT_DIR}/kubectl.conf replace --force --cascade -f ${ROOT_DIR}/${artifactId}-svc.yaml" - sh "/opt/app/kubernetes/v1.3.4/bin/kubectl --kubeconfig=${ROOT_DIR}/kubectl.conf replace --force --cascade -f ${ROOT_DIR}/${artifactId}-rc.yaml" -} -return this - - - - diff --git a/aai-resources/src/main/kubernetes/ajsc6configdemo-rc.yaml b/aai-resources/src/main/kubernetes/ajsc6configdemo-rc.yaml deleted file mode 100644 index 274ea47..0000000 --- a/aai-resources/src/main/kubernetes/ajsc6configdemo-rc.yaml +++ /dev/null @@ -1,28 +0,0 @@ -apiVersion: v1 -kind: ReplicationController -metadata: - name: ajsc6configdemo - namespace: org-onap-aai -spec: - replicas: 5 - selector: - app: ajsc6configdemo - template: - metadata: - labels: - app: ajsc6configdemo - spec: - serviceAccount: ajsc-svc-account - containers: - - name: ajsc6configdemo - volumeMounts: - - name: myservice-properties-volume - mountPath: /etc/config/dynamic - image: ajsc6configdemo:latest - imagePullPolicy: Always - ports: - - containerPort: 8080 - volumes: - - name: myservice-properties-volume - configMap: - name: ajsc6configdemo-dynamic-properties
\ No newline at end of file diff --git a/aai-resources/src/main/kubernetes/ajsc6configdemo-svc.yaml b/aai-resources/src/main/kubernetes/ajsc6configdemo-svc.yaml deleted file mode 100644 index eb81d38..0000000 --- a/aai-resources/src/main/kubernetes/ajsc6configdemo-svc.yaml +++ /dev/null @@ -1,13 +0,0 @@ -apiVersion: v1 -kind: Service -metadata: - name: ajsc6configdemo - namespace: org-onap-aai -spec: - selector: - app: ajsc6configdemo - ports: - port: 80 - protocol: TCP - targetPort: 8080 - type: NodePort diff --git a/aai-resources/src/main/kubernetes/ajsc6configdemo.yaml b/aai-resources/src/main/kubernetes/ajsc6configdemo.yaml deleted file mode 100644 index 545d7f6..0000000 --- a/aai-resources/src/main/kubernetes/ajsc6configdemo.yaml +++ /dev/null @@ -1,8 +0,0 @@ -apiVersion: v1 -data: - dynamic.properties: | - my.property.name=prod -kind: ConfigMap -metadata: - name: ajsc6configdemo-dynamic-properties - namespace: org-onap-aai
\ No newline at end of file diff --git a/aai-resources/src/main/kubernetes/kubectl.conf b/aai-resources/src/main/kubernetes/kubectl.conf deleted file mode 100644 index 09e7abb..0000000 --- a/aai-resources/src/main/kubernetes/kubectl.conf +++ /dev/null @@ -1,22 +0,0 @@ -current-context: baremetal-ajsc-01 -apiVersion: v1 -clusters: -- cluster: - api-version: v1 - server: https://aai.org - insecure-skip-tls-verify: true - name: baremetal-ajsc-01 -contexts: -- context: - cluster: baremetal-ajsc-01 - namespace: org-onap-aai - user: user@example.com - name: baremetal-ajsc-01 -kind: Config -preferences: - colors: true -users: -- name: aai@example.com - user: - username: kube - password: asdjofja diff --git a/aai-resources/src/main/resources/application.properties b/aai-resources/src/main/resources/application.properties index 05611c2..b869262 100644 --- a/aai-resources/src/main/resources/application.properties +++ b/aai-resources/src/main/resources/application.properties @@ -8,25 +8,20 @@ spring.application.name=aai-resources spring.jersey.type=filter server.contextPath=/ -spring.autoconfigure.exclude=org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration,org.springframework.boot.autoconfigure.orm.jpa.HibernateJpaAutoConfiguration +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 +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-resources/src/main/resources/ @@ -43,28 +38,32 @@ server.ssl.key-store-type=JKS # JMS bind address host port jms.bind.address=tcp://localhost:61647 -dmaap.ribbon.eureka.enabled=false + 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 +# Schema related attributes for the oxm and edges +# Any additional schema related attributes should start with prefix schema +schema.configuration.location=N/A +schema.source.name=onap +schema.nodes.location=${server.local.startpath}/schema/${schema.source.name}/oxm/ +schema.edges.location=${server.local.startpath}/schema/${schema.source.name}/dbedgerules/ + +schema.ingest.file=${server.local.startpath}/application.properties -# 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 Version Related Attributes -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.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-resources/src/main/resources/bootstrap.properties b/aai-resources/src/main/resources/bootstrap.properties deleted file mode 100644 index 65a28ac..0000000 --- a/aai-resources/src/main/resources/bootstrap.properties +++ /dev/null @@ -1,16 +0,0 @@ -# Activate Spring Cloud Config Server functionality, these should remain false while using the file based implementation to prevent conflicts with properties pulled from a remote server. -spring.cloud.config.discovery.enabled=false -spring.cloud.config.enabled=false - -# Allow Spring Cloud properties configuration to override properties set from System Properties and ENV Properties -spring.cloud.config.overrideSystemProperties=true - -# Path to the file containing the dynamic properties -com.att.ajsc.dynamic.properties.path=/etc/config/dynamic/dynamic.properties - - -# Path to the file containing the dynamic logger levels -com.att.ajsc.dynamic.logging.path=/etc/config/logging/logging.properties - -# File watcher polling frequency in milliseconds -com.att.ajsc.dynamic.watcher.delay=5000
\ No newline at end of file diff --git a/aai-resources/src/main/resources/edgeLabelMigration.csv b/aai-resources/src/main/resources/edgeLabelMigration.csv deleted file mode 100644 index 53639e5..0000000 --- a/aai-resources/src/main/resources/edgeLabelMigration.csv +++ /dev/null @@ -1,212 +0,0 @@ -from,to,label,direction,multiplicity,contains-other-v,delete-other-v,SVC-INFRA,prevent-delete,new from,new to,new label,new direction,new multiplicity,new contains-other-v,new delete-other-v,new SVC-INFRA,new prevent-delete,new default -allotted-resource,allotted-resource,bindsTo,OUT,ONE2ONE,NONE,NONE,NONE,NONE,allotted-resource,allotted-resource,tosca.relationships.network.BindsTo,OUT,ONE2ONE,NONE,NONE,NONE,NONE,T -allotted-resource,generic-vnf,isPartOf,OUT,MANY2MANY,NONE,NONE,NONE,NONE,allotted-resource,generic-vnf,org.onap.relationships.inventory.PartOf,OUT,MANY2MANY,NONE,NONE,NONE,NONE,T -allotted-resource,instance-group,isMemberOf,OUT,MANY2MANY,NONE,NONE,NONE,NONE,allotted-resource,instance-group,org.onap.relationships.inventory.MemberOf,OUT,MANY2MANY,NONE,NONE,NONE,NONE,T -allotted-resource,l3-network,isPartOf,OUT,MANY2MANY,NONE,NONE,NONE,NONE,allotted-resource,l3-network,org.onap.relationships.inventory.PartOf,OUT,MANY2MANY,NONE,NONE,NONE,NONE,T -allotted-resource,l-interface,uses,OUT,ONE2MANY,NONE,NONE,NONE,NONE,allotted-resource,l-interface,org.onap.relationships.inventory.Uses,OUT,ONE2MANY,NONE,NONE,NONE,NONE,T -allotted-resource,network-policy,uses,OUT,ONE2ONE,NONE,NONE,NONE,NONE,allotted-resource,network-policy,org.onap.relationships.inventory.Uses,OUT,ONE2ONE,NONE,NONE,NONE,NONE,T -allotted-resource,vlan,isPartOf,OUT,MANY2MANY,NONE,NONE,NONE,NONE,allotted-resource,vlan,org.onap.relationships.inventory.PartOf,OUT,MANY2MANY,NONE,NONE,NONE,NONE,T -allotted-resource,vpn-binding,belongsTo,OUT,MANY2MANY,NONE,NONE,NONE,!${direction},allotted-resource,vpn-binding,org.onap.relationships.inventory.BelongsTo,OUT,MANY2MANY,NONE,NONE,NONE,!${direction},T -allotted-resource,tunnel-xconnect,has,OUT,ONE2ONE,${direction},${direction},NONE,NONE,tunnel-xconnect,allotted-resource,org.onap.relationships.inventory.BelongsTo,OUT,ONE2ONE,!${direction},!${direction},NONE,NONE,T -availability-zone,complex,groupsResourcesIn,OUT,MANY2MANY,NONE,NONE,NONE,!${direction},availability-zone,complex,org.onap.relationships.inventory.LocatedIn,OUT,MANY2ONE,NONE,NONE,NONE,!${direction},T -availability-zone,service-capability,supportsServiceCapability,OUT,MANY2MANY,NONE,NONE,NONE,!${direction},availability-zone,service-capability,org.onap.relationships.inventory.AppliesTo,OUT,MANY2MANY,NONE,NONE,NONE,!${direction},T -cloud-region,availability-zone,has,OUT,ONE2MANY,${direction},${direction},NONE,${direction},availability-zone,cloud-region,org.onap.relationships.inventory.BelongsTo,OUT,MANY2ONE,!${direction},!${direction},NONE,NONE,T -cloud-region,complex,locatedIn,OUT,MANY2ONE,NONE,NONE,NONE,!${direction},cloud-region,complex,org.onap.relationships.inventory.LocatedIn,OUT,MANY2ONE,NONE,NONE,NONE,!${direction},T -cloud-region,l3-network,uses,OUT,MANY2MANY,NONE,NONE,NONE,NONE,cloud-region,l3-network,org.onap.relationships.inventory.Uses,OUT,MANY2MANY,NONE,NONE,NONE,NONE,T -cloud-region,zone,isMemberOf,OUT,MANY2ONE,NONE,NONE,NONE,NONE,cloud-region,zone,org.onap.relationships.inventory.LocatedIn,OUT,MANY2ONE,NONE,NONE,NONE,NONE,T -cloud-region,dvs-switch,has,OUT,ONE2MANY,${direction},${direction},NONE,${direction},dvs-switch,cloud-region,org.onap.relationships.inventory.BelongsTo,OUT,MANY2ONE,!${direction},NONE,NONE,!${direction},T -cloud-region,flavor,has,OUT,ONE2MANY,${direction},${direction},NONE,${direction},flavor,cloud-region,org.onap.relationships.inventory.BelongsTo,OUT,MANY2ONE,!${direction},NONE,NONE,!${direction},T -cloud-region,group-assignment,has,OUT,ONE2MANY,${direction},${direction},NONE,${direction},group-assignment,cloud-region,org.onap.relationships.inventory.BelongsTo,OUT,MANY2ONE,!${direction},NONE,NONE,!${direction},T -cloud-region,image,has,OUT,ONE2MANY,${direction},${direction},NONE,${direction},image,cloud-region,org.onap.relationships.inventory.BelongsTo,OUT,MANY2ONE,!${direction},NONE,NONE,!${direction},T -cloud-region,oam-network,has,OUT,ONE2MANY,${direction},${direction},NONE,${direction},oam-network,cloud-region,org.onap.relationships.inventory.BelongsTo,OUT,MANY2ONE,!${direction},NONE,NONE,!${direction},T -cloud-region,snapshot,has,OUT,ONE2MANY,${direction},${direction},NONE,${direction},snapshot,cloud-region,org.onap.relationships.inventory.BelongsTo,OUT,MANY2ONE,!${direction},NONE,NONE,!${direction},T -cloud-region,tenant,has,OUT,ONE2MANY,${direction},${direction},!${direction},${direction},tenant,cloud-region,org.onap.relationships.inventory.BelongsTo,OUT,MANY2ONE,!${direction},NONE,${direction},!${direction},T -cloud-region,vip-ipv4-address-list,hasIpAddress,OUT,ONE2MANY,${direction},${direction},${direction},NONE,vip-ipv4-address-list,cloud-region,org.onap.relationships.inventory.BelongsTo,OUT,MANY2ONE,!${direction},NONE,NONE,!${direction},T -cloud-region,vip-ipv6-address-list,hasIpAddress,OUT,ONE2MANY,${direction},${direction},${direction},NONE,vip-ipv6-address-list,cloud-region,org.onap.relationships.inventory.BelongsTo,OUT,MANY2ONE,!${direction},NONE,NONE,!${direction},T -cloud-region,volume-group,has,OUT,ONE2MANY,${direction},${direction},NONE,${direction},volume-group,cloud-region,org.onap.relationships.inventory.BelongsTo,OUT,MANY2ONE,!${direction},NONE,NONE,!${direction},T -complex,l3-network,usesL3Network,OUT,MANY2MANY,NONE,NONE,${direction},NONE,complex,l3-network,org.onap.relationships.inventory.Uses,OUT,MANY2MANY,NONE,NONE,${direction},NONE,T -complex,ctag-pool,hasCtagPool,OUT,MANY2MANY,${direction},${direction},NONE,NONE,ctag-pool,complex,org.onap.relationships.inventory.BelongsTo,OUT,MANY2ONE,!${direction},!${direction},NONE,NONE,T -configuration,allotted-resource,uses,OUT,ONE2ONE,NONE,${direction},NONE,NONE,configuration,allotted-resource,org.onap.relationships.inventory.Uses,OUT,ONE2ONE,NONE,${direction},NONE,NONE,T -configuration,logical-link,has,OUT,ONE2MANY,NONE,${direction},NONE,NONE,configuration,logical-link,org.onap.relationships.inventory.Uses,OUT,ONE2MANY,NONE,${direction},NONE,NONE,T -configuration,metadatum,owns,OUT,ONE2MANY,${direction},${direction},NONE,NONE,metadatum,configuration,org.onap.relationships.inventory.BelongsTo,OUT,MANY2ONE,!${direction},!${direction},NONE,NONE,T -connector,virtual-data-center,contains,OUT,MANY2MANY,NONE,NONE,NONE,NONE,connector,virtual-data-center,org.onap.relationships.inventory.LocatedIn,OUT,MANY2MANY,NONE,NONE,NONE,NONE,T -connector,metadatum,hasMetaData,OUT,MANY2MANY,${direction},${direction},NONE,NONE,metadatum,connector,org.onap.relationships.inventory.BelongsTo,OUT,MANY2ONE,!${direction},!${direction},NONE,NONE,T -constrained-element-set,element-choice-set,uses,OUT,ONE2MANY,${direction},${direction},NONE,NONE,element-choice-set,constrained-element-set,org.onap.relationships.inventory.BelongsTo,OUT,MANY2ONE,!${direction},!${direction},NONE,NONE,T -ctag-pool,availability-zone,supportsAvailabilityZone,OUT,MANY2MANY,NONE,NONE,NONE,!${direction},ctag-pool,availability-zone,org.onap.relationships.inventory.AppliesTo,OUT,MANY2MANY,NONE,NONE,NONE,!${direction},T -customer,service-subscription,subscribesTo,OUT,MANY2MANY,${direction},${direction},!${direction},NONE,service-subscription,customer,org.onap.relationships.inventory.BelongsTo,OUT,MANY2ONE,!${direction},!${direction},${direction},NONE,T -dvs-switch,availability-zone,existsIn,OUT,MANY2MANY,NONE,NONE,NONE,!${direction},dvs-switch,availability-zone,org.onap.relationships.inventory.AppliesTo,OUT,MANY2MANY,NONE,NONE,NONE,!${direction},T -element-choice-set,model-element,has,OUT,ONE2MANY,${direction},${direction},NONE,NONE,model-element,element-choice-set,org.onap.relationships.inventory.BelongsTo,OUT,MANY2ONE,!${direction},!${direction},NONE,NONE,T -generic-vnf,entitlement,has,OUT,ONE2MANY,${direction},${direction},NONE,NONE,entitlement,generic-vnf,org.onap.relationships.inventory.BelongsTo,OUT,MANY2ONE,!${direction},!${direction},NONE,NONE,T -generic-vnf,availability-zone,hasAvailabilityZone,OUT,MANY2MANY,NONE,NONE,${direction},!${direction},generic-vnf,availability-zone,org.onap.relationships.inventory.Uses,OUT,MANY2MANY,NONE,NONE,${direction},!${direction},T -generic-vnf,complex,locatedIn,OUT,MANY2MANY,NONE,NONE,NONE,!${direction},generic-vnf,complex,org.onap.relationships.inventory.LocatedIn,OUT,MANY2MANY,NONE,NONE,NONE,!${direction},T -generic-vnf,configuration,uses,OUT,ONE2MANY,NONE,${direction},NONE,NONE,generic-vnf,configuration,org.onap.relationships.inventory.Uses,OUT,ONE2MANY,NONE,${direction},NONE,NONE,T -generic-vnf,ctag-pool,usesCtagPool,OUT,MANY2MANY,NONE,NONE,NONE,NONE,generic-vnf,ctag-pool,org.onap.relationships.inventory.Uses,OUT,MANY2MANY,NONE,NONE,NONE,NONE,T -generic-vnf,instance-group,isMemberOf,OUT,MANY2MANY,NONE,NONE,NONE,NONE,generic-vnf,instance-group,org.onap.relationships.inventory.MemberOf,OUT,MANY2MANY,NONE,NONE,NONE,NONE,T -generic-vnf,ipsec-configuration,uses,OUT,MANY2ONE,NONE,NONE,NONE,NONE,generic-vnf,ipsec-configuration,org.onap.relationships.inventory.Uses,OUT,MANY2ONE,NONE,NONE,NONE,NONE,T -generic-vnf,l3-network,usesL3Network,OUT,MANY2MANY,NONE,NONE,${direction},NONE,generic-vnf,l3-network,org.onap.relationships.inventory.Uses,OUT,MANY2MANY,NONE,NONE,${direction},NONE,T -generic-vnf,license-key-resource,uses,OUT,MANY2MANY,NONE,NONE,NONE,!${direction},generic-vnf,license-key-resource,org.onap.relationships.inventory.Uses,OUT,MANY2MANY,NONE,NONE,NONE,!${direction},T -generic-vnf,pnf,hostedOn,OUT,MANY2MANY,NONE,NONE,NONE,NONE,generic-vnf,pnf,tosca.relationships.HostedOn,OUT,MANY2MANY,NONE,NONE,NONE,NONE,T -generic-vnf,pserver,runsOnPserver,OUT,MANY2MANY,NONE,NONE,${direction},!${direction},generic-vnf,pserver,tosca.relationships.HostedOn,OUT,MANY2MANY,NONE,NONE,${direction},!${direction},T -generic-vnf,vnfc,uses,OUT,ONE2MANY,NONE,${direction},${direction},NONE,vnfc,generic-vnf,org.onap.relationships.inventory.BelongsTo,OUT,MANY2ONE,NONE,!${direction},!${direction},NONE,T -generic-vnf,vnf-image,usesVnfImage,OUT,MANY2ONE,NONE,NONE,${direction},!${direction},generic-vnf,vnf-image,org.onap.relationships.inventory.Uses,OUT,MANY2ONE,NONE,NONE,${direction},!${direction},T -generic-vnf,volume-group,uses,OUT,ONE2MANY,NONE,NONE,${direction},NONE,generic-vnf,volume-group,org.onap.relationships.inventory.DependsOn,OUT,ONE2MANY,NONE,NONE,${direction},NONE,T -generic-vnf,vserver,runsOnVserver,OUT,ONE2MANY,NONE,NONE,${direction},NONE,generic-vnf,vserver,tosca.relationships.HostedOn,OUT,ONE2MANY,NONE,NONE,${direction},NONE,T -generic-vnf,lag-interface,hasLAGInterface,OUT,MANY2MANY,${direction},${direction},${direction},NONE,lag-interface,generic-vnf,org.onap.relationships.inventory.BelongsTo,OUT,MANY2ONE,!${direction},!${direction},!${direction},NONE,T -generic-vnf,license,has,OUT,ONE2MANY,${direction},${direction},NONE,NONE,license,generic-vnf,org.onap.relationships.inventory.BelongsTo,OUT,MANY2ONE,!${direction},!${direction},NONE,NONE,T -generic-vnf,l-interface,hasLInterface,OUT,MANY2MANY,${direction},${direction},${direction},NONE,l-interface,generic-vnf,org.onap.relationships.inventory.BelongsTo,OUT,MANY2ONE,!${direction},!${direction},!${direction},NONE,T -generic-vnf,network-profile,hasNetworkProfile,OUT,MANY2MANY,NONE,NONE,NONE,NONE,network-profile,generic-vnf,org.onap.relationships.inventory.AppliesTo,OUT,MANY2MANY,NONE,NONE,NONE,NONE,T -generic-vnf,service-instance,hasInstance,OUT,MANY2MANY,NONE,NONE,${direction},NONE,service-instance,generic-vnf,org.onap.relationships.inventory.ComposedOf,OUT,ONE2MANY,NONE,NONE,!${direction},NONE,T -generic-vnf,site-pair-set,hasSitePairSet,OUT,MANY2MANY,NONE,NONE,NONE,NONE,site-pair-set,generic-vnf,org.onap.relationships.inventory.AppliesTo,OUT,MANY2MANY,NONE,NONE,NONE,NONE,T -generic-vnf,vf-module,has,OUT,ONE2MANY,${direction},${direction},${direction},NONE,vf-module,generic-vnf,org.onap.relationships.inventory.BelongsTo,OUT,MANY2ONE,!${direction},!${direction},!${direction},NONE,T -group-assignment,pserver,has,OUT,ONE2MANY,NONE,NONE,NONE,!${direction},pserver,group-assignment,org.onap.relationships.inventory.MemberOf,OUT,MANY2ONE,NONE,NONE,NONE,${direction},T -group-assignment,tenant,has,OUT,MANY2MANY,NONE,NONE,NONE,NONE,tenant,group-assignment,org.onap.relationships.inventory.MemberOf,OUT,MANY2MANY,NONE,NONE,NONE,NONE,T -image,metadatum,hasMetaDatum,OUT,MANY2MANY,${direction},${direction},NONE,NONE,metadatum,image,org.onap.relationships.inventory.BelongsTo,OUT,MANY2ONE,!${direction},!${direction},NONE,NONE,T -instance-group,model,targets,OUT,MANY2MANY,NONE,NONE,NONE,!${direction},instance-group,model,org.onap.relationships.inventory.Targets,OUT,MANY2MANY,NONE,NONE,NONE,!${direction},T -ipsec-configuration,vig-server,hasVigServer,OUT,ONE2MANY,${direction},${direction},NONE,NONE,vig-server,ipsec-configuration,org.onap.relationships.inventory.BelongsTo,OUT,MANY2ONE,!${direction},!${direction},NONE,NONE,T -l3-interface-ipv4-address-list,instance-group,isMemberOf,OUT,MANY2MANY,NONE,NONE,NONE,NONE,l3-interface-ipv4-address-list,instance-group,org.onap.relationships.inventory.network.MemberOf,OUT,MANY2MANY,NONE,NONE,NONE,NONE,T -l3-interface-ipv4-address-list,l3-network,isMemberOf,OUT,MANY2MANY,NONE,NONE,${direction},NONE,l3-interface-ipv4-address-list,l3-network,org.onap.relationships.inventory.network.MemberOf,OUT,MANY2MANY,NONE,NONE,${direction},NONE,T -l3-interface-ipv4-address-list,subnet,isMemberOf,OUT,MANY2MANY,NONE,NONE,${direction},!${direction},l3-interface-ipv4-address-list,subnet,org.onap.relationships.inventory.network.MemberOf,OUT,MANY2MANY,NONE,NONE,${direction},!${direction},T -l3-interface-ipv6-address-list,instance-group,isMemberOf,OUT,MANY2MANY,NONE,NONE,NONE,NONE,l3-interface-ipv6-address-list,instance-group,org.onap.relationships.inventory.network.MemberOf,OUT,MANY2MANY,NONE,NONE,NONE,NONE,T -l3-interface-ipv6-address-list,l3-network,isMemberOf,OUT,MANY2MANY,NONE,NONE,${direction},NONE,l3-interface-ipv6-address-list,l3-network,org.onap.relationships.inventory.network.MemberOf,OUT,MANY2MANY,NONE,NONE,${direction},NONE,T -l3-interface-ipv6-address-list,subnet,isMemberOf,OUT,MANY2MANY,NONE,NONE,${direction},!${direction},l3-interface-ipv6-address-list,subnet,org.onap.relationships.inventory.network.MemberOf,OUT,MANY2MANY,NONE,NONE,${direction},!${direction},T -l3-network,ctag-assignment,hasCtagAssignment,OUT,MANY2MANY,${direction},${direction},${direction},NONE,ctag-assignment,l3-network,org.onap.relationships.inventory.BelongsTo,OUT,MANY2ONE,!${direction},!${direction},!${direction},NONE,T -l3-network,instance-group,memberOf,OUT,MANY2MANY,NONE,NONE,NONE,NONE,l3-network,instance-group,org.onap.relationships.inventory.MemberOf,OUT,MANY2MANY,NONE,NONE,NONE,NONE,T -l3-network,network-policy,uses,OUT,MANY2MANY,NONE,NONE,${direction},NONE,l3-network,network-policy,org.onap.relationships.inventory.Uses,OUT,MANY2MANY,NONE,NONE,${direction},NONE,T -l3-network,route-table-reference,uses,OUT,MANY2MANY,NONE,NONE,NONE,NONE,l3-network,route-table-reference,org.onap.relationships.inventory.Uses,OUT,MANY2MANY,NONE,NONE,NONE,NONE,T -l3-network,vpn-binding,usesVpnBinding,OUT,MANY2MANY,NONE,NONE,NONE,!${direction},l3-network,vpn-binding,org.onap.relationships.inventory.Uses,OUT,MANY2MANY,NONE,NONE,NONE,!${direction},T -l3-network,segmentation-assignment,has,OUT,ONE2MANY,${direction},${direction},NONE,NONE,segmentation-assignment,l3-network,org.onap.relationships.inventory.BelongsTo,OUT,MANY2ONE,!${direction},!${direction},NONE,NONE,T -l3-network,service-instance,hasInstance,OUT,MANY2MANY,NONE,NONE,!${direction},NONE,service-instance,l3-network,org.onap.relationships.inventory.ComposedOf,OUT,ONE2MANY,NONE,NONE,${direction},NONE,T -l3-network,subnet,hasSubnet,OUT,MANY2MANY,${direction},${direction},!${direction},NONE,subnet,l3-network,org.onap.relationships.inventory.BelongsTo,OUT,MANY2ONE,!${direction},!${direction},${direction},NONE,T -lag-interface,lag-link,usesLAGLink,OUT,MANY2MANY,NONE,${direction},${direction},NONE,lag-interface,lag-link,tosca.relationships.network.LinksTo,OUT,MANY2MANY,NONE,${direction},${direction},NONE,T -lag-interface,logical-link,uses,OUT,MANY2MANY,NONE,${direction},${direction},NONE,lag-interface,logical-link,org.onap.relationships.inventory.Uses,OUT,MANY2MANY,NONE,${direction},${direction},NONE,T -lag-interface,p-interface,usesPInterface,OUT,MANY2MANY,NONE,NONE,${direction},NONE,lag-interface,p-interface,org.onap.relationships.inventory.Uses,OUT,MANY2MANY,NONE,NONE,${direction},NONE,T -lag-interface,l-interface,hasLInterface,OUT,MANY2MANY,${direction},${direction},${direction},NONE,l-interface,lag-interface,org.onap.relationships.inventory.BelongsTo,OUT,MANY2ONE,!${direction},!${direction},!${direction},NONE,T -line-of-business,generic-vnf,realizedBy,OUT,MANY2MANY,NONE,NONE,NONE,NONE,line-of-business,generic-vnf,org.onap.relationships.inventory.Uses,OUT,MANY2MANY,NONE,NONE,NONE,NONE,T -l-interface,l3-interface-ipv4-address-list,hasIpAddress,OUT,MANY2MANY,${direction},${direction},${direction},NONE,l3-interface-ipv4-address-list,l-interface,org.onap.relationships.inventory.BelongsTo,OUT,MANY2ONE,!${direction},!${direction},!${direction},NONE,T -l-interface,l3-interface-ipv6-address-list,hasIpAddress,OUT,MANY2MANY,${direction},${direction},${direction},NONE,l3-interface-ipv6-address-list,l-interface,org.onap.relationships.inventory.BelongsTo,OUT,MANY2ONE,!${direction},!${direction},!${direction},NONE,T -l-interface,instance-group,isMemberOf,OUT,MANY2MANY,NONE,NONE,NONE,NONE,l-interface,instance-group,org.onap.relationships.inventory.MemberOf,OUT,MANY2MANY,NONE,NONE,NONE,NONE,T -l-interface,l-interface,has,OUT,ONE2MANY,${direction},${direction},${direction},NONE,l-interface,l-interface,org.onap.relationships.inventory.BelongsTo,OUT,MANY2ONE,!${direction},!${direction},!${direction},NONE,T -l-interface,logical-link,usesLogicalLink,OUT,MANY2MANY,NONE,${direction},${direction},NONE,l-interface,logical-link,tosca.relationships.network.LinksTo,OUT,MANY2ONE,NONE,${direction},${direction},NONE,T -l-interface,logical-link,sourceLInterface,OUT,MANY2MANY,NONE,${direction},${direction},NONE,logical-link,l-interface,org.onap.relationships.inventory.Source,OUT,ONE2MANY,NONE,!${direction},!${direction},NONE,F -l-interface,logical-link,targetLInterface,OUT,MANY2MANY,NONE,${direction},${direction},NONE,logical-link,l-interface,org.onap.relationships.inventory.Destination,OUT,ONE2MANY,NONE,!${direction},!${direction},NONE,F -l-interface,sriov-vf,has,OUT,ONE2ONE,${direction},${direction},NONE,NONE,sriov-vf,l-interface,org.onap.relationships.inventory.BelongsTo,OUT,ONE2ONE,!${direction},!${direction},NONE,NONE,T -l-interface,vlan,hasVlan,OUT,MANY2MANY,${direction},${direction},NONE,NONE,vlan,l-interface,tosca.relationships.network.LinksTo,OUT,MANY2ONE,!${direction},!${direction},NONE,NONE,T -logical-link,cloud-region,existsIn,OUT,MANY2MANY,NONE,NONE,NONE,NONE,logical-link,cloud-region,org.onap.relationships.inventory.LocatedIn,OUT,MANY2MANY,NONE,NONE,NONE,NONE,T -logical-link,generic-vnf,bridgedTo,OUT,MANY2MANY,NONE,NONE,NONE,NONE,logical-link,generic-vnf,org.onap.relationships.inventory.BridgedTo,OUT,MANY2MANY,NONE,NONE,NONE,NONE,T -logical-link,lag-link,usesLAGLink,OUT,MANY2MANY,NONE,NONE,${direction},NONE,logical-link,lag-link,org.onap.relationships.inventory.Uses,OUT,MANY2MANY,NONE,NONE,${direction},NONE,T -logical-link,logical-link,uses,OUT,ONE2MANY,NONE,NONE,${direction},NONE,logical-link,logical-link,org.onap.relationships.inventory.Uses,OUT,ONE2MANY,NONE,NONE,${direction},NONE,T -logical-link,pnf,bridgedTo,OUT,MANY2MANY,NONE,NONE,NONE,NONE,logical-link,pnf,org.onap.relationships.inventory.BridgedTo,OUT,MANY2MANY,NONE,NONE,NONE,NONE,T -logical-link,pserver,bridgedTo,OUT,MANY2MANY,NONE,NONE,NONE,!${direction},logical-link,pserver,org.onap.relationships.inventory.BridgedTo,OUT,MANY2MANY,NONE,NONE,NONE,!${direction},T -logical-link,vpn-binding,uses,OUT,MANY2MANY,NONE,NONE,NONE,!${direction},logical-link,vpn-binding,org.onap.relationships.inventory.Uses,OUT,MANY2MANY,NONE,NONE,NONE,!${direction},T -model,model-ver,has,OUT,ONE2MANY,${direction},${direction},NONE,NONE,model-ver,model,org.onap.relationships.inventory.BelongsTo,OUT,MANY2ONE,!${direction},!${direction},NONE,NONE,T -model-constraint,constrained-element-set,uses,OUT,ONE2MANY,${direction},${direction},NONE,NONE,constrained-element-set,model-constraint,org.onap.relationships.inventory.BelongsTo,OUT,MANY2ONE,!${direction},!${direction},NONE,NONE,T -model-element,constrained-element-set,connectsTo,OUT,ONE2MANY,${direction},${direction},NONE,NONE,constrained-element-set,model-element,org.onap.relationships.inventory.BelongsTo,OUT,MANY2ONE,!${direction},!${direction},NONE,NONE,T -model-element,model-constraint,uses,OUT,ONE2MANY,${direction},${direction},NONE,NONE,model-constraint,model-element,org.onap.relationships.inventory.BelongsTo,OUT,MANY2ONE,!${direction},!${direction},NONE,NONE,T -model-element,model-element,connectsTo,OUT,ONE2MANY,${direction},${direction},NONE,NONE,model-element,model-element,org.onap.relationships.inventory.BelongsTo,OUT,MANY2ONE,!${direction},!${direction},NONE,NONE,T -model-element,model-ver,isA,OUT,MANY2ONE,NONE,NONE,NONE,!${direction},model-element,model-ver,org.onap.relationships.inventory.IsA,OUT,MANY2ONE,NONE,NONE,NONE,!${direction},T -model-ver,metadatum,hasMetaDatum,OUT,ONE2MANY,${direction},${direction},NONE,NONE,metadatum,model-ver,org.onap.relationships.inventory.BelongsTo,OUT,MANY2ONE,!${direction},!${direction},NONE,NONE,T -model-ver,model-element,startsWith,OUT,ONE2MANY,${direction},${direction},NONE,NONE,model-element,model-ver,org.onap.relationships.inventory.BelongsTo,OUT,MANY2ONE,!${direction},!${direction},NONE,NONE,T -named-query,model,relatedTo,OUT,ONE2MANY,NONE,NONE,NONE,!${direction},named-query,model,org.onap.relationships.inventory.AppliesTo,OUT,ONE2MANY,NONE,NONE,NONE,!${direction},T -named-query,named-query-element,startsWith,OUT,ONE2ONE,${direction},${direction},NONE,NONE,named-query-element,named-query,org.onap.relationships.inventory.BelongsTo,OUT,ONE2ONE,!${direction},!${direction},NONE,NONE,T -named-query-element,model,isA,OUT,MANY2ONE,NONE,NONE,NONE,!${direction},named-query-element,model,org.onap.relationships.inventory.IsA,OUT,MANY2ONE,NONE,NONE,NONE,!${direction},T -named-query-element,named-query-element,connectsTo,OUT,MANY2MANY,${direction},${direction},NONE,NONE,named-query-element,named-query-element,org.onap.relationships.inventory.BelongsTo,OUT,MANY2ONE,!${direction},!${direction},NONE,NONE,T -named-query-element,property-constraint,uses,OUT,ONE2MANY,${direction},${direction},NONE,NONE,property-constraint,named-query-element,org.onap.relationships.inventory.BelongsTo,OUT,MANY2ONE,!${direction},!${direction},NONE,NONE,T -named-query-element,related-lookup,uses,OUT,ONE2MANY,${direction},${direction},NONE,NONE,related-lookup,named-query-element,org.onap.relationships.inventory.BelongsTo,OUT,MANY2ONE,!${direction},!${direction},NONE,NONE,T -newvce,l-interface,hasLInterface,OUT,MANY2MANY,${direction},${direction},NONE,NONE,l-interface,newvce,org.onap.relationships.inventory.BelongsTo,OUT,MANY2ONE,!${direction},!${direction},NONE,NONE,T -oam-network,complex,definedFor,OUT,MANY2MANY,NONE,NONE,NONE,!${direction},oam-network,complex,org.onap.relationships.inventory.AppliesTo,OUT,MANY2MANY,NONE,NONE,NONE,!${direction},T -oam-network,service-capability,supportsServiceCapability,OUT,MANY2MANY,NONE,NONE,NONE,!${direction},oam-network,service-capability,org.onap.relationships.inventory.AppliesTo,OUT,MANY2MANY,NONE,NONE,NONE,!${direction},T -operational-environment,operational-environment,managedBy,OUT,ONE2ONE,NONE,NONE,NONE,NONE,operational-environment,operational-environment,org.onap.relationships.inventory.Uses,OUT,ONE2ONE,NONE,NONE,NONE,NONE,T -owning-entity,service-instance,owns,OUT,ONE2MANY,NONE,NONE,NONE,NONE,service-instance,owning-entity,org.onap.relationships.inventory.BelongsTo,OUT,MANY2ONE,NONE,NONE,NONE,NONE,T -p-interface,l-interface,hasLInterface,OUT,MANY2MANY,${direction},${direction},${direction},NONE,l-interface,p-interface,tosca.relationships.network.BindsTo,OUT,MANY2ONE,!${direction},!${direction},!${direction},NONE,T -p-interface,logical-link,usesLogicalLink,OUT,MANY2ONE,NONE,NONE,${direction},NONE,p-interface,logical-link,tosca.relationships.network.LinksTo,OUT,MANY2ONE,NONE,NONE,${direction},NONE,T -p-interface,physical-link,usesPhysicalLink,OUT,MANY2MANY,NONE,${direction},NONE,NONE,p-interface,physical-link,tosca.relationships.network.LinksTo,OUT,MANY2ONE,NONE,${direction},NONE,NONE,T -p-interface,sriov-pf,has,OUT,ONE2ONE,${direction},${direction},NONE,NONE,sriov-pf,p-interface,org.onap.relationships.inventory.BelongsTo,OUT,ONE2ONE,!${direction},!${direction},NONE,NONE,T -platform,generic-vnf,uses,OUT,MANY2MANY,NONE,NONE,NONE,NONE,platform,generic-vnf,org.onap.relationships.inventory.Uses,OUT,MANY2MANY,NONE,NONE,NONE,NONE,T -pnf,lag-interface,has,OUT,ONE2MANY,${direction},${direction},${direction},NONE,lag-interface,pnf,tosca.relationships.network.BindsTo,OUT,MANY2ONE,!${direction},!${direction},!${direction},NONE,T -pnf,p-interface,hasPinterface,OUT,MANY2MANY,${direction},${direction},${direction},NONE,p-interface,pnf,tosca.relationships.network.BindsTo,OUT,MANY2ONE,!${direction},!${direction},!${direction},NONE,T -pnf,complex,locatedIn,OUT,MANY2ONE,NONE,NONE,NONE,!${direction},pnf,complex,org.onap.relationships.inventory.LocatedIn,OUT,MANY2ONE,NONE,NONE,NONE,!${direction},T -pnf,instance-group,isMemberOf,OUT,MANY2MANY,NONE,NONE,NONE,NONE,pnf,instance-group,org.onap.relationships.inventory.MemberOf,OUT,MANY2MANY,NONE,NONE,NONE,NONE,T -pnf,zone,isMemberOf,OUT,MANY2ONE,NONE,NONE,NONE,NONE,pnf,zone,org.onap.relationships.inventory.LocatedIn,OUT,MANY2ONE,NONE,NONE,NONE,NONE,T -port-group,cvlan-tag,hasCTag,OUT,MANY2MANY,${direction},${direction},${direction},NONE,cvlan-tag,port-group,org.onap.relationships.inventory.BelongsTo,OUT,MANY2ONE,!${direction},!${direction},!${direction},NONE,T -project,service-instance,created,OUT,ONE2MANY,NONE,NONE,NONE,NONE,project,service-instance,org.onap.relationships.inventory.Uses,OUT,ONE2MANY,NONE,NONE,NONE,NONE,T -pserver,lag-interface,hasLAGInterface,OUT,MANY2MANY,${direction},${direction},${direction},NONE,lag-interface,pserver,tosca.relationships.network.BindsTo,OUT,MANY2ONE,!${direction},!${direction},!${direction},NONE,T -pserver,p-interface,hasPinterface,OUT,MANY2MANY,${direction},${direction},${direction},NONE,p-interface,pserver,tosca.relationships.network.BindsTo,OUT,MANY2ONE,!${direction},!${direction},!${direction},NONE,T -pserver,availability-zone,existsIn,OUT,MANY2ONE,NONE,NONE,${direction},!${direction},pserver,availability-zone,org.onap.relationships.inventory.MemberOf,OUT,MANY2ONE,NONE,NONE,${direction},!${direction},T -pserver,cloud-region,locatedIn,OUT,MANY2ONE,NONE,NONE,${direction},NONE,pserver,cloud-region,org.onap.relationships.inventory.LocatedIn,OUT,MANY2ONE,NONE,NONE,${direction},NONE,T -pserver,complex,locatedIn,OUT,MANY2ONE,NONE,NONE,${direction},!${direction},pserver,complex,org.onap.relationships.inventory.LocatedIn,OUT,MANY2ONE,NONE,NONE,${direction},!${direction},T -pserver,zone,isMemberOf,OUT,MANY2ONE,NONE,NONE,NONE,NONE,pserver,zone,org.onap.relationships.inventory.LocatedIn,OUT,MANY2ONE,NONE,NONE,NONE,NONE,T -routing-instance,site-pair,hasSitePair,OUT,MANY2MANY,${direction},${direction},NONE,NONE,site-pair,routing-instance,org.onap.relationships.inventory.BelongsTo,OUT,MANY2ONE,!${direction},!${direction},NONE,NONE,T -service-instance,allotted-resource,has,OUT,MANY2MANY,${direction},${direction},NONE,NONE,allotted-resource,service-instance,org.onap.relationships.inventory.BelongsTo,OUT,MANY2ONE,!${direction},!${direction},NONE,NONE,T -service-instance,metadatum,hasMetaData,OUT,MANY2MANY,${direction},${direction},NONE,NONE,metadatum,service-instance,org.onap.relationships.inventory.BelongsTo,OUT,MANY2ONE,!${direction},!${direction},NONE,NONE,T -service-instance,allotted-resource,uses,OUT,MANY2MANY,NONE,NONE,NONE,NONE,service-instance,allotted-resource,org.onap.relationships.inventory.Uses,OUT,MANY2MANY,NONE,NONE,NONE,NONE,T -service-instance,configuration,has,OUT,ONE2MANY,NONE,NONE,NONE,NONE,service-instance,configuration,org.onap.relationships.inventory.Uses,OUT,ONE2MANY,NONE,NONE,NONE,NONE,T -service-instance,connector,uses,OUT,MANY2MANY,NONE,NONE,NONE,NONE,service-instance,connector,org.onap.relationships.inventory.Uses,OUT,MANY2MANY,NONE,NONE,NONE,NONE,T -service-instance,ctag-assignment,uses,OUT,ONE2MANY,NONE,NONE,NONE,NONE,service-instance,ctag-assignment,org.onap.relationships.inventory.Uses,OUT,ONE2MANY,NONE,NONE,NONE,NONE,T -service-instance,cvlan-tag,hasIPAGFacingVLAN,OUT,MANY2MANY,NONE,NONE,NONE,NONE,service-instance,cvlan-tag,org.onap.relationships.inventory.ComposedOf,OUT,MANY2MANY,NONE,NONE,NONE,NONE,T -service-instance,instance-group,isMemberOf,OUT,MANY2MANY,NONE,NONE,NONE,NONE,service-instance,instance-group,org.onap.relationships.inventory.MemberOf,OUT,MANY2MANY,NONE,NONE,NONE,NONE,T -service-instance,logical-link,uses,OUT,MANY2MANY,NONE,${direction},NONE,NONE,service-instance,logical-link,org.onap.relationships.inventory.Uses,OUT,ONE2MANY,NONE,${direction},NONE,NONE,T -service-instance,pnf,uses,OUT,ONE2MANY,NONE,NONE,NONE,NONE,service-instance,pnf,org.onap.relationships.inventory.ComposedOf,OUT,ONE2MANY,NONE,NONE,NONE,NONE,T -service-instance,service-instance,dependsOn,OUT,ONE2MANY,NONE,NONE,NONE,NONE,service-instance,service-instance,org.onap.relationships.inventory.ComposedOf,OUT,ONE2MANY,NONE,NONE,NONE,NONE,T -service-instance,vlan,dependsOn,OUT,ONE2MANY,NONE,NONE,NONE,NONE,service-instance,vlan,org.onap.relationships.inventory.ComposedOf,OUT,ONE2MANY,NONE,NONE,NONE,NONE,T -service-instance,zone,locatedIn,OUT,MANY2ONE,NONE,NONE,${direction},NONE,service-instance,zone,org.onap.relationships.inventory.LocatedIn,OUT,MANY2ONE,NONE,NONE,${direction},NONE,T -service-subscription,service-instance,hasInstance,OUT,MANY2MANY,${direction},${direction},!${direction},NONE,service-instance,service-subscription,org.onap.relationships.inventory.BelongsTo,OUT,MANY2ONE,!${direction},!${direction},${direction},NONE,T -site-pair,class-of-service,hasClassOfService,OUT,MANY2MANY,${direction},${direction},NONE,NONE,class-of-service,site-pair,org.onap.relationships.inventory.BelongsTo,OUT,MANY2ONE,!${direction},!${direction},NONE,NONE,T -site-pair-set,routing-instance,hasRoutingInstance,OUT,MANY2MANY,${direction},${direction},NONE,NONE,routing-instance,site-pair-set,org.onap.relationships.inventory.BelongsTo,OUT,MANY2ONE,!${direction},!${direction},NONE,NONE,T -sriov-vf,sriov-pf,uses,OUT,MANY2ONE,NONE,NONE,NONE,NONE,sriov-vf,sriov-pf,org.onap.relationships.inventory.Uses,OUT,MANY2ONE,NONE,NONE,NONE,NONE,T -subnet,host-route,has,OUT,ONE2MANY,${direction},${direction},NONE,NONE,host-route,subnet,org.onap.relationships.inventory.BelongsTo,OUT,MANY2ONE,!${direction},!${direction},NONE,NONE,T -tenant,service-subscription,relatedTo,OUT,MANY2MANY,NONE,NONE,NONE,NONE,service-subscription,tenant,org.onap.relationships.inventory.Uses,OUT,MANY2MANY,NONE,NONE,NONE,NONE,T -tenant,l3-network,usesL3Network,OUT,MANY2MANY,NONE,NONE,NONE,NONE,tenant,l3-network,org.onap.relationships.inventory.Uses,OUT,MANY2MANY,NONE,NONE,NONE,NONE,T -tenant,vserver,owns,OUT,ONE2MANY,${direction},${direction},!${direction},${direction},vserver,tenant,org.onap.relationships.inventory.BelongsTo,OUT,MANY2ONE,!${direction},NONE,${direction},!${direction},T -vce,entitlement,has,OUT,ONE2MANY,${direction},${direction},NONE,NONE,entitlement,vce,org.onap.relationships.inventory.BelongsTo,OUT,MANY2ONE,!${direction},!${direction},NONE,NONE,T -vce,license,has,OUT,ONE2MANY,${direction},${direction},NONE,NONE,license,vce,org.onap.relationships.inventory.BelongsTo,OUT,MANY2ONE,!${direction},!${direction},NONE,NONE,T -vce,port-group,hasPortGroup,OUT,MANY2MANY,${direction},${direction},${direction},NONE,port-group,vce,org.onap.relationships.inventory.BelongsTo,OUT,MANY2ONE,!${direction},!${direction},!${direction},NONE,T -vce,service-instance,hasServiceInstance,OUT,MANY2MANY,NONE,NONE,!${direction},NONE,service-instance,vce,org.onap.relationships.inventory.ComposedOf,OUT,ONE2MANY,NONE,NONE,${direction},NONE,T -vce,availability-zone,hasAvailabilityZone,OUT,MANY2MANY,NONE,NONE,NONE,!${direction},vce,availability-zone,org.onap.relationships.inventory.Uses,OUT,MANY2MANY,NONE,NONE,NONE,!${direction},T -vce,complex,locatedIn,OUT,MANY2MANY,NONE,NONE,${direction},!${direction},vce,complex,org.onap.relationships.inventory.LocatedIn,OUT,MANY2MANY,NONE,NONE,${direction},!${direction},T -vce,vserver,runsOnVserver,OUT,MANY2MANY,NONE,NONE,${direction},NONE,vce,vserver,tosca.relationships.HostedOn,OUT,ONE2MANY,NONE,NONE,${direction},NONE,T -vf-module,l3-network,uses,OUT,MANY2MANY,NONE,NONE,${direction},NONE,vf-module,l3-network,org.onap.relationships.inventory.DependsOn,OUT,MANY2MANY,NONE,NONE,${direction},NONE,T -vf-module,vnfc,uses,OUT,ONE2MANY,NONE,${direction},${direction},${direction},vf-module,vnfc,org.onap.relationships.inventory.Uses,OUT,ONE2MANY,NONE,NONE,${direction},${direction},T -vf-module,volume-group,uses,OUT,ONE2ONE,NONE,NONE,${direction},NONE,vf-module,volume-group,org.onap.relationships.inventory.Uses,OUT,ONE2ONE,NONE,NONE,${direction},NONE,T -vip-ipv4-address-list,instance-group,isMemberOf,OUT,MANY2MANY,NONE,NONE,NONE,NONE,vip-ipv4-address-list,instance-group,org.onap.relationships.inventory.MemberOf,OUT,MANY2MANY,NONE,NONE,NONE,NONE,T -vip-ipv4-address-list,subnet,isMemberOf,OUT,MANY2MANY,NONE,NONE,${direction},!${direction},vip-ipv4-address-list,subnet,org.onap.relationships.inventory.MemberOf,OUT,MANY2MANY,NONE,NONE,NONE,!${direction},T -vip-ipv6-address-list,instance-group,isMemberOf,OUT,MANY2MANY,NONE,NONE,NONE,NONE,vip-ipv6-address-list,instance-group,org.onap.relationships.inventory.MemberOf,OUT,MANY2MANY,NONE,NONE,NONE,NONE,T -vip-ipv6-address-list,subnet,isMemberOf,OUT,MANY2MANY,NONE,NONE,${direction},!${direction},vip-ipv6-address-list,subnet,org.onap.relationships.inventory.MemberOf,OUT,MANY2MANY,NONE,NONE,NONE,!${direction},T -virtual-data-center,generic-vnf,hasVNF,OUT,MANY2MANY,NONE,NONE,!${direction},NONE,generic-vnf,virtual-data-center,org.onap.relationships.inventory.LocatedIn,OUT,MANY2MANY,NONE,NONE,${direction},NONE,T -virtual-data-center,logical-link,contains,OUT,MANY2MANY,NONE,NONE,NONE,NONE,logical-link,virtual-data-center,org.onap.relationships.inventory.LocatedIn,OUT,MANY2MANY,NONE,NONE,NONE,NONE,T -vlan,l3-interface-ipv4-address-list,hasIpAddress,OUT,MANY2MANY,${direction},${direction},${direction},NONE,l3-interface-ipv4-address-list,vlan,org.onap.relationships.inventory.BelongsTo,OUT,MANY2ONE,!${direction},!${direction},!${direction},NONE,T -vlan,l3-interface-ipv6-address-list,hasIpAddress,OUT,MANY2MANY,${direction},${direction},${direction},NONE,l3-interface-ipv6-address-list,vlan,org.onap.relationships.inventory.BelongsTo,OUT,MANY2ONE,!${direction},!${direction},!${direction},NONE,T -vlan,logical-link,usesLogicalLink,OUT,MANY2MANY,NONE,${direction},${direction},NONE,vlan,logical-link,org.onap.relationships.inventory.Uses,OUT,MANY2MANY,NONE,${direction},${direction},NONE,T -vlan,multicast-configuration,uses,OUT,MANY2MANY,NONE,NONE,NONE,NONE,vlan,multicast-configuration,org.onap.relationships.inventory.Uses,OUT,MANY2MANY,NONE,NONE,NONE,NONE,T -vnfc,l3-interface-ipv4-address-list,hasIpAddress,OUT,ONE2MANY,${direction},${direction},NONE,NONE,l3-interface-ipv4-address-list,vnfc,org.onap.relationships.inventory.BelongsTo,OUT,MANY2ONE,!${direction},!${direction},NONE,NONE,T -vnfc,l3-interface-ipv6-address-list,hasIpAddress,OUT,ONE2MANY,${direction},${direction},NONE,NONE,l3-interface-ipv6-address-list,vnfc,org.onap.relationships.inventory.BelongsTo,OUT,MANY2ONE,!${direction},!${direction},NONE,NONE,T -vnfc,instance-group,isMemberOf,OUT,MANY2MANY,NONE,NONE,NONE,NONE,vnfc,instance-group,org.onap.relationships.inventory.MemberOf,OUT,MANY2MANY,NONE,NONE,NONE,NONE,T -vnfc,vip-ipv4-address-list,uses,OUT,MANY2MANY,NONE,NONE,NONE,NONE,vnfc,vip-ipv4-address-list,org.onap.relationships.inventory.Uses,OUT,MANY2MANY,NONE,NONE,NONE,NONE,T -vnfc,vip-ipv6-address-list,uses,OUT,MANY2MANY,NONE,NONE,NONE,NONE,vnfc,vip-ipv6-address-list,org.onap.relationships.inventory.Uses,OUT,MANY2MANY,NONE,NONE,NONE,NONE,T -volume-group,tenant,belongsTo,OUT,MANY2MANY,NONE,NONE,${direction},NONE,tenant,volume-group,org.onap.relationships.inventory.DependsOn,OUT,ONE2MANY,NONE,NONE,!${direction},NONE,T -volume-group,complex,existsIn,OUT,MANY2MANY,NONE,NONE,${direction},!${direction},volume-group,complex,org.onap.relationships.inventory.LocatedIn,OUT,MANY2ONE,NONE,NONE,${direction},!${direction},T -vpls-pe,lag-interface,hasLAGinterface,OUT,MANY2MANY,${direction},${direction},NONE,NONE,lag-interface,vpls-pe,tosca.relationships.network.BindsTo,OUT,MANY2ONE,!${direction},!${direction},NONE,NONE,T -vpls-pe,p-interface,hasPinterface,OUT,MANY2MANY,${direction},${direction},NONE,NONE,p-interface,vpls-pe,tosca.relationships.network.BindsTo,OUT,MANY2ONE,!${direction},!${direction},NONE,NONE,T -vpls-pe,complex,locatedIn,OUT,MANY2MANY,NONE,NONE,NONE,!${direction},vpls-pe,complex,org.onap.relationships.inventory.LocatedIn,OUT,MANY2ONE,NONE,NONE,NONE,!${direction},T -vpls-pe,ctag-pool,usesCtagPool,OUT,MANY2MANY,NONE,NONE,NONE,NONE,vpls-pe,ctag-pool,org.onap.relationships.inventory.Uses,OUT,MANY2MANY,NONE,NONE,NONE,NONE,T -vpn-binding,route-target,has,OUT,ONE2MANY,${direction},${direction},NONE,NONE,route-target,vpn-binding,org.onap.relationships.inventory.BelongsTo,OUT,MANY2ONE,!${direction},!${direction},NONE,NONE,T -vserver,l-interface,hasLInterface,OUT,MANY2MANY,${direction},${direction},${direction},NONE,l-interface,vserver,tosca.relationships.network.BindsTo,OUT,MANY2ONE,!${direction},!${direction},!${direction},NONE,T -vserver,vf-module,isPartOf,OUT,MANY2ONE,NONE,NONE,${direction},NONE,vf-module,vserver,org.onap.relationships.inventory.Uses,OUT,ONE2MANY,NONE,NONE,!${direction},NONE,T -vserver,vnfc,hosts,OUT,MANY2MANY,NONE,NONE,${direction},NONE,vnfc,vserver,tosca.relationships.HostedOn,OUT,ONE2MANY,NONE,NONE,!${direction},NONE,T -vserver,flavor,hasFlavor,OUT,MANY2ONE,NONE,NONE,${direction},!${direction},vserver,flavor,org.onap.relationships.inventory.Uses,OUT,MANY2ONE,NONE,NONE,${direction},!${direction},T -vserver,image,hasImage,OUT,MANY2ONE,NONE,NONE,${direction},!${direction},vserver,image,org.onap.relationships.inventory.Uses,OUT,MANY2ONE,NONE,NONE,${direction},!${direction},T -vserver,pserver,runsOnPserver,OUT,MANY2ONE,NONE,NONE,${direction},!${direction},vserver,pserver,tosca.relationships.HostedOn,OUT,MANY2ONE,NONE,NONE,${direction},!${direction},T -vserver,snapshot,uses,OUT,ONE2ONE,NONE,NONE,${direction},NONE,vserver,snapshot,org.onap.relationships.inventory.Uses,OUT,ONE2ONE,NONE,NONE,${direction},NONE,T -vserver,volume,hasVolume,OUT,MANY2MANY,${direction},${direction},${direction},NONE,vserver,volume,tosca.relationships.AttachesTo,OUT,ONE2MANY,${direction},${direction},${direction},NONE,T -zone,complex,existsIn,OUT,MANY2ONE,NONE,NONE,NONE,!${direction},zone,complex,org.onap.relationships.inventory.LocatedIn,OUT,MANY2ONE,NONE,NONE,NONE,!${direction},T -,,,,,,,,,allotted-resource,model-ver,org.onap.relationships.inventory.IsA,OUT,Many2One,NONE,NONE,NONE,NONE,T -,,,,,,,,,generic-vnf,model-ver,org.onap.relationships.inventory.IsA,OUT,Many2One,NONE,NONE,NONE,NONE,T -,,,,,,,,,l3-network,model-ver,org.onap.relationships.inventory.IsA,OUT,Many2One,NONE,NONE,NONE,NONE,T -,,,,,,,,,logical-link,model-ver,org.onap.relationships.inventory.IsA,OUT,Many2One,NONE,NONE,NONE,NONE,T -,,,,,,,,,service-instance,model-ver,org.onap.relationships.inventory.IsA,OUT,Many2One,NONE,NONE,NONE,NONE,T -,,,,,,,,,vf-module,model-ver,org.onap.relationships.inventory.IsA,OUT,Many2One,NONE,NONE,NONE,NONE,T -configuration,l-interface,has,OUT,ONE2MANY,NONE,NONE,NONE,NONE,configuration,l-interface,org.onap.relationships.inventory.AppliesTo,OUT,ONE2MANY,NONE,NONE,NONE,NONE,T -configuration,pnf,has,OUT,ONE2MANY,NONE,NONE,NONE,NONE,configuration,pnf,org.onap.relationships.inventory.AppliesTo,OUT,ONE2MANY,NONE,NONE,NONE,NONE,T -forwarder,forwarding-path,belongsTo,OUT,MANY2ONE,!${direction},!${direction},NONE,NONE,forwarder,forwarding-path,org.onap.relationships.inventory.BelongsTo,OUT,MANY2ONE,!${direction},!${direction},NONE,NONE,T -forwarding-path,service-instance,implements,OUT,MANY2ONE,NONE,!${direction},NONE,NONE,forwarding-path,service-instance,org.onap.relationships.inventory.AppliesTo,OUT,MANY2ONE,NONE,!${direction},NONE,NONE,T -forwarder,l-interface,forwardsTo,OUT,ONE2ONE,NONE,NONE,NONE,NONE,forwarder,l-interface,org.onap.relationships.inventory.ForwardsTo,OUT,ONE2ONE,NONE,NONE,NONE,NONE,T -forwarder,p-interface,forwardsTo,OUT,ONE2ONE,NONE,NONE,NONE,NONE,forwarder,p-interface,org.onap.relationships.inventory.ForwardsTo,OUT,ONE2ONE,NONE,NONE,NONE,NONE,T diff --git a/aai-resources/src/main/resources/etc/VNT-migration-data/VNT-migration-input.csv b/aai-resources/src/main/resources/etc/VNT-migration-data/VNT-migration-input.csv deleted file mode 100644 index 916dced..0000000 --- a/aai-resources/src/main/resources/etc/VNT-migration-data/VNT-migration-input.csv +++ /dev/null @@ -1,2 +0,0 @@ -"entitlement-pool-uuid vendor-allowed-max-bandwidth (VNT)" -"some-uuid 1000" diff --git a/aai-resources/src/main/resources/etc/appprops/Introscope.properties b/aai-resources/src/main/resources/etc/appprops/Introscope.properties deleted file mode 100644 index 319381e..0000000 --- a/aai-resources/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-resources/src/main/resources/etc/appprops/PostProcessorInterceptors.properties b/aai-resources/src/main/resources/etc/appprops/PostProcessorInterceptors.properties deleted file mode 100644 index ca31a26..0000000 --- a/aai-resources/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-resources/src/main/resources/etc/appprops/PreProcessorInterceptors.properties b/aai-resources/src/main/resources/etc/appprops/PreProcessorInterceptors.properties deleted file mode 100644 index 1620bea..0000000 --- a/aai-resources/src/main/resources/etc/appprops/PreProcessorInterceptors.properties +++ /dev/null @@ -1,3 +0,0 @@ -#This properties file is for defining any PreProcessorInterceptors that have been created for your AJSC service. - -/**=com.att.ajsc.csi.restmethodmap.RestMethodMapInterceptor,org.onap.aai.interceptors.PreAaiAjscInterceptor diff --git a/aai-resources/src/main/resources/etc/appprops/aaiconfig.properties b/aai-resources/src/main/resources/etc/appprops/aaiconfig.properties index 0d7bc4e..b11d8f8 100644 --- a/aai-resources/src/main/resources/etc/appprops/aaiconfig.properties +++ b/aai-resources/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. @@ -16,9 +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. -# #################################################################### # REMEMBER TO THINK ABOUT ENVIRONMENTAL DIFFERENCES AND CHANGE THE @@ -47,58 +44,15 @@ aai.tools.enableBasicAuth=true aai.tools.username=AAI aai.tools.password=AAI -ecm.openstack.tenantid=b0a529aba48440a39e0caf1aea9b27e3 - -aai.avpn.interim.laginterface=ae0 - 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 - -# pin up a skeleton if it's not found - -aai.precheck.cloudinfrastructure.complex.defaults.physicalLocationType=AAIDefault -aai.precheck.cloudinfrastructure.complex.defaults.street1=AAIDefault -aai.precheck.cloudinfrastructure.complex.defaults.city=AAIDefault -aai.precheck.cloudinfrastructure.complex.defaults.state=NJ -aai.precheck.cloudinfrastructure.complex.defaults.postalCode=07748 -aai.precheck.cloudinfrastructure.complex.defaults.country=USA -aai.precheck.cloudinfrastructure.complex.defaults.region=US - -# single primary server -aai.primary.filetransfer.serverlist=ONAPserverTBD -aai.primary.filetransfer.primarycheck=echo:8443/aai/util/echo -aai.primary.filetransfer.pingtimeout=5000 -aai.primary.filetransfer.pingcount=5 - -#rsync properties -aai.rsync.command=rsync -aai.rsync.options.list=-v|-t -aai.rsync.remote.user=aaiadmin -aai.rsync.enabled=y - -#Service Specific Data Values -aai.servicedescription.hostedcomm=HOSTED COMMUNICATIONS -aai.servicedescription.mobility=MOBILITY -aai.servicedescription.vusp=VIRTUAL USP -aai.servicedescription.vvig=vVIGaaS -aai.servicedescription.lrsi=LRSI-OSPF - aai.notification.current.version=v14 aai.notificationEvent.default.status=UNPROCESSED aai.notificationEvent.default.eventType=AAI-EVENT @@ -133,20 +87,9 @@ aai.forceDel.protected.nt.list=cloud-region aai.forceDel.protected.edge.count=10 aai.forceDel.protected.descendant.count=10 -# Used for CTAG-Pool generation -aai.ctagPool.rangeString.vplsPe1=2001-2500 -aai.ctagPool.rangeString.vplsPe2=2501-3000 -aai.ctagPool.rangeString.vpe=3001-3500 - aai.dmaap.workload.enableEventProcessing=true aai.realtime.clients=RO,SDNC,MSO,SO - -aai.server.rebind=g - -# This is a fake one just for test so please ignore -ecm.auth.password.x=OBF:1igd1i9a1jnb1yte1vv11vu91yt81jk71i6o1idt -aai.run.migrations=false aai.jms.enable=false #timeout for crud enabled flag @@ -157,9 +100,12 @@ aai.crud.timeout.appspecific=JUNITTESTAPP1,1|JUNITTESTAPP2,-1|DCAE-CCS,-1|DCAES, #default timeout limit added for crud if not overridden (in ms) aai.crud.timeoutlimit=100000 + #limit set for bulk consumer APIS aai.bulkconsumer.payloadlimit=30 #uncomment and use header X-OverrideLimit with the value to override the bulk api limit #aai.bulkconsumer.payloadoverride=E6F04B93462CB5B0EDF41C05A9DDF5C3FE59748F aai.bulkconsumer.payloadoverride=false + +aai.rest.getall.depthparam=asofijaosjf-oijfadao-43jj-a508-8539cd36ecda diff --git a/aai-resources/src/main/resources/etc/appprops/app-intercepts.properties b/aai-resources/src/main/resources/etc/appprops/app-intercepts.properties deleted file mode 100644 index 3230921..0000000 --- a/aai-resources/src/main/resources/etc/appprops/app-intercepts.properties +++ /dev/null @@ -1,6 +0,0 @@ -#This is where all your application intercept strategies must be configured. AJSC reads this property file and adds -#the list of intercepts specified here to the camel context. This can be useful for accessing every exchange object transferred from/to -#each endpoint in the request/response flow and can allow for more precise debugging and/or processing of the exchange. - -#e.g. -#intercepts=org.openecomp.aai.ajsc_aai.JaxrsEchoService,packagename.class1name,packagename.class2name diff --git a/aai-resources/src/main/resources/etc/appprops/caet.properties b/aai-resources/src/main/resources/etc/appprops/caet.properties deleted file mode 100644 index ac4960c..0000000 --- a/aai-resources/src/main/resources/etc/appprops/caet.properties +++ /dev/null @@ -1,4 +0,0 @@ -#caet_service=http://DME2RESOLVE/service=com.att.csid.CAET/version=3/envContext=TEST/routeOffer=TEST_CAET -#caet_service=http://DME2RESOLVE/service=com.att.csid.CAET/version=3/envContext=TEST/routeOffer=D3A_CAET -#caet_service=dme2://DME2RESOLVE/service=com.att.csid.CAET/version=4.0/envContext=TEST/routeOffer=TEST_CAET -caet_service=http://DME2RESOLVE/service=com.att.csid.CAET/version=4.0/envContext=TEST/routeOffer=TEST_CAET
\ No newline at end of file diff --git a/aai-resources/src/main/resources/etc/appprops/createDBSchema-logback.xml b/aai-resources/src/main/resources/etc/appprops/createDBSchema-logback.xml deleted file mode 100644 index ef93d9c..0000000 --- a/aai-resources/src/main/resources/etc/appprops/createDBSchema-logback.xml +++ /dev/null @@ -1,131 +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> - <property name="logDirectory" value="${AJSC_HOME}/logs" /> - <property name="eelfLogPattern" value="%ecompStartTime|%date{yyyy-MM-dd'T'HH:mm:ss.SSSZ, UTC}|%X{requestId}|%X{serviceInstanceId}|%-10t|%X{serverName}|%X{serviceName}|%X{partnerName}|%X{statusCode}|%X{responseCode}|%replace(%replace(%X{responseDescription}){'\\|', '!'}){'\r|\n', '^'}|%X{instanceUUID}|%level|%X{severity}|%X{serverIpAddress}|%ecompElapsedTime|%X{server}|%X{clientIpAddress}|%eelfClassOfCaller|%X{unused}|%X{processKey}|%X{customField1}|%X{customField2}|%X{customField3}|%X{customField4}|co=%X{component}:%replace(%replace(%m){'\\|', '!'}){'\r|\n', '^'}%n"/> - <property name="eelfMetricLogPattern" value="%ecompStartTime|%date{yyyy-MM-dd'T'HH:mm:ss.SSSZ, UTC}|%X{requestId}|%X{serviceInstanceId}|%-10t|%X{serverName}|%X{serviceName}|%X{partnerName}|%X{targetEntity}|%X{targetServiceName}|%X{statusCode}|%X{responseCode}|%replace(%replace(%X{responseDescription}){'\\|', '!'}){'\r|\n', '^'}|%X{instanceUUID}|%level|%X{severity}|%X{serverIpAddress}|%ecompElapsedTime|%X{server}|%X{clientIpAddress}|%eelfClassOfCaller|%X{unused}|%X{processKey}|%X{targetVirtualEntity}|%X{customField1}|%X{customField2}|%X{customField3}|%X{customField4}|co=%X{component}:%replace(%replace(%m){'\\|', '!'}){'\r|\n', '^'}%n"/> - - <appender name="createDBSchema" class="ch.qos.logback.core.rolling.RollingFileAppender"> - <filter class="ch.qos.logback.classic.filter.ThresholdFilter"> - <level>WARN</level> - </filter> - <File>${logDirectory}/createDBSchema/error.log</File> - <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy"> - <fileNamePattern>${logDirectory}/createDBSchema/error.log.%d{yyyy-MM-dd}</fileNamePattern> - </rollingPolicy> - <encoder class="org.onap.aai.logging.EcompEncoder"> - <pattern>${eelfLogPattern}</pattern> - </encoder> - </appender> - - <appender name="createDBSchemadebug" class="ch.qos.logback.core.rolling.RollingFileAppender"> - <filter class="ch.qos.logback.classic.filter.LevelFilter"> - <level>DEBUG</level> - <onMatch>ACCEPT</onMatch> - <onMismatch>DENY</onMismatch> - </filter> - <File>${logDirectory}/createDBSchema/debug.log</File> - <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy"> - <fileNamePattern>${logDirectory}/createDBSchema/debug.log.%d{yyyy-MM-dd}</fileNamePattern> - </rollingPolicy> - <encoder class="org.onap.aai.logging.EcompEncoder"> - <pattern>${eelfLogPattern}</pattern> - </encoder> - </appender> - - <appender name="createDBSchemametric" class="ch.qos.logback.core.rolling.RollingFileAppender"> - <filter class="ch.qos.logback.classic.filter.LevelFilter"> - <level>INFO</level> - <onMatch>ACCEPT</onMatch> - <onMismatch>DENY</onMismatch> - </filter> - <File>${logDirectory}/createDBSchema/metrics.log</File> - <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy"> - <fileNamePattern>${logDirectory}/createDBSchema/metrics.log.%d{yyyy-MM-dd}</fileNamePattern> - </rollingPolicy> - <encoder class="org.onap.aai.logging.EcompEncoder"> - <pattern>${eelfMetricLogPattern}</pattern> - </encoder> - </appender> - - <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender"> - <encoder>%-4relative [%thread] %-5level %logger{35} - %msg %n</encoder> - </appender> - - <logger name="org.reflections" level="WARN" additivity="false"> - <appender-ref ref="createDBSchema"/> - <appender-ref ref="createDBSchemadebug"/> - <appender-ref ref="createDBSchemametric"/> - <appender-ref ref="STDOUT"/> - </logger> - <logger name="org.apache.zookeeper" level="WARN" additivity="false"> - <appender-ref ref="createDBSchema"/> - <appender-ref ref="createDBSchemadebug"/> - <appender-ref ref="createDBSchemametric"/> - <appender-ref ref="STDOUT"/> - </logger> - <logger name="org.apache.hadoop" level="WARN" additivity="false"> - <appender-ref ref="createDBSchema"/> - <appender-ref ref="createDBSchemadebug"/> - <appender-ref ref="createDBSchemametric"/> - <appender-ref ref="STDOUT"/> - </logger> - <logger name="org.janusgraph" level="WARN" additivity="false"> - <appender-ref ref="createDBSchema"/> - <appender-ref ref="createDBSchemadebug"/> - <appender-ref ref="createDBSchemametric"/> - <appender-ref ref="STDOUT"/> - </logger> - <logger name="ch.qos.logback.classic" level="WARN" additivity="false"> - <appender-ref ref="createDBSchema"/> - <appender-ref ref="createDBSchemadebug"/> - <appender-ref ref="createDBSchemametric"/> - <appender-ref ref="STDOUT"/> - </logger> - <logger name="ch.qos.logback.core" level="WARN" additivity="false"> - <appender-ref ref="createDBSchema"/> - <appender-ref ref="createDBSchemadebug"/> - <appender-ref ref="createDBSchemametric"/> - <appender-ref ref="STDOUT"/> - </logger> - <logger name="com.att.eelf" level="WARN" additivity="false"> - <appender-ref ref="createDBSchema"/> - <appender-ref ref="createDBSchemadebug"/> - <appender-ref ref="createDBSchemametric"/> - <appender-ref ref="STDOUT"/> - </logger> - <logger name="org.onap.aai" level="DEBUG" additivity="false"> - <appender-ref ref="createDBSchema"/> - <appender-ref ref="createDBSchemadebug"/> - <appender-ref ref="createDBSchemametric"/> - <appender-ref ref="STDOUT"/> - </logger> - - <root level="DEBUG"> - <appender-ref ref="createDBSchema"/> - <appender-ref ref="createDBSchemadebug"/> - <appender-ref ref="createDBSchemametric"/> - <appender-ref ref="STDOUT"/> - </root> -</configuration> diff --git a/aai-resources/src/main/resources/etc/appprops/dataGrooming-logback.xml b/aai-resources/src/main/resources/etc/appprops/dataGrooming-logback.xml deleted file mode 100644 index 73d72d4..0000000 --- a/aai-resources/src/main/resources/etc/appprops/dataGrooming-logback.xml +++ /dev/null @@ -1,138 +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> - <property name="logDirectory" value="${AJSC_HOME}/logs" /> - <property name="eelfLogPattern" value="%ecompStartTime|%date{yyyy-MM-dd'T'HH:mm:ss.SSSZ, UTC}|%X{requestId}|%X{serviceInstanceId}|%-10t|%X{serverName}|%X{serviceName}|%X{partnerName}|%X{statusCode}|%X{responseCode}|%replace(%replace(%X{responseDescription}){'\\|', '!'}){'\r|\n', '^'}|%X{instanceUUID}|%level|%X{severity}|%X{serverIpAddress}|%ecompElapsedTime|%X{server}|%X{clientIpAddress}|%eelfClassOfCaller|%X{unused}|%X{processKey}|%X{customField1}|%X{customField2}|%X{customField3}|%X{customField4}|co=%X{component}:%replace(%replace(%m){'\\|', '!'}){'\r|\n', '^'}%n"/> - <property name="eelfMetricLogPattern" value="%ecompStartTime|%date{yyyy-MM-dd'T'HH:mm:ss.SSSZ, UTC}|%X{requestId}|%X{serviceInstanceId}|%-10t|%X{serverName}|%X{serviceName}|%X{partnerName}|%X{targetEntity}|%X{targetServiceName}|%X{statusCode}|%X{responseCode}|%replace(%replace(%X{responseDescription}){'\\|', '!'}){'\r|\n', '^'}|%X{instanceUUID}|%level|%X{severity}|%X{serverIpAddress}|%ecompElapsedTime|%X{server}|%X{clientIpAddress}|%eelfClassOfCaller|%X{unused}|%X{processKey}|%X{targetVirtualEntity}|%X{customField1}|%X{customField2}|%X{customField3}|%X{customField4}|co=%X{component}:%replace(%replace(%m){'\\|', '!'}){'\r|\n', '^'}%n"/> - - <appender name="dataGrooming" class="ch.qos.logback.core.rolling.RollingFileAppender"> - <filter class="ch.qos.logback.classic.filter.ThresholdFilter"> - <level>WARN</level> - </filter> - <File>${logDirectory}/dataGrooming/error.log</File> - <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy"> - <fileNamePattern>${logDirectory}/dataGrooming/error.log.%d{yyyy-MM-dd}</fileNamePattern> - </rollingPolicy> - <encoder class="org.onap.aai.logging.EcompEncoder"> - <pattern>${eelfLogPattern}</pattern> - </encoder> - </appender> - - <appender name="dataGroomingdebug" class="ch.qos.logback.core.rolling.RollingFileAppender"> - <filter class="ch.qos.logback.classic.filter.LevelFilter"> - <level>DEBUG</level> - <onMatch>ACCEPT</onMatch> - <onMismatch>DENY</onMismatch> - </filter> - <File>${logDirectory}/dataGrooming/debug.log</File> - <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy"> - <fileNamePattern>${logDirectory}/dataGrooming/debug.log.%d{yyyy-MM-dd}</fileNamePattern> - </rollingPolicy> - <encoder class="org.onap.aai.logging.EcompEncoder"> - <pattern>${eelfLogPattern}</pattern> - </encoder> - </appender> - - <appender name="dataGroomingmetric" class="ch.qos.logback.core.rolling.RollingFileAppender"> - <filter class="ch.qos.logback.classic.filter.LevelFilter"> - <level>INFO</level> - <onMatch>ACCEPT</onMatch> - <onMismatch>DENY</onMismatch> - </filter> - <File>${logDirectory}/dataGrooming/metrics.log</File> - <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy"> - <fileNamePattern>${logDirectory}/dataGrooming/metrics.log.%d{yyyy-MM-dd}</fileNamePattern> - </rollingPolicy> - <encoder class="org.onap.aai.logging.EcompEncoder"> - <pattern>${eelfMetricLogPattern}</pattern> - </encoder> - </appender> - - <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender"> - <encoder>%-4relative [%thread] %-5level %logger{35} - %msg %n</encoder> - </appender> - - <logger name="org.reflections" level="WARN" additivity="false"> - <appender-ref ref="dataGrooming"/> - <appender-ref ref="dataGroomingdebug"/> - <appender-ref ref="dataGroomingmetric"/> - </logger> - <logger name="org.apache.zookeeper" level="WARN" additivity="false"> - <appender-ref ref="dataGrooming"/> - <appender-ref ref="dataGroomingdebug"/> - <appender-ref ref="dataGroomingmetric"/> - </logger> - <logger name="org.apache.hadoop" level="WARN" additivity="false"> - <appender-ref ref="dataGrooming"/> - <appender-ref ref="dataGroomingdebug"/> - <appender-ref ref="dataGroomingmetric"/> - </logger> - <logger name="org.janusgraph" level="WARN" additivity="false"> - <appender-ref ref="dataGrooming"/> - <appender-ref ref="dataGroomingdebug"/> - <appender-ref ref="dataGroomingmetric"/> - </logger> - <logger name="ch.qos.logback.classic" level="WARN" additivity="false"> - <appender-ref ref="dataGrooming"/> - <appender-ref ref="dataGroomingdebug"/> - <appender-ref ref="dataGroomingmetric"/> - </logger> - <logger name="ch.qos.logback.core" level="WARN" additivity="false"> - <appender-ref ref="dataGrooming"/> - <appender-ref ref="dataGroomingdebug"/> - <appender-ref ref="dataGroomingmetric"/> - </logger> - <logger name="com.att.eelf" level="WARN" additivity="false"> - <appender-ref ref="dataGrooming"/> - <appender-ref ref="dataGroomingdebug"/> - <appender-ref ref="dataGroomingmetric"/> - </logger> - <logger name="org.onap.aai" level="INFO" additivity="false"> - <appender-ref ref="dataGrooming"/> - <appender-ref ref="dataGroomingdebug"/> - <appender-ref ref="dataGroomingmetric"/> - </logger> - <logger name="com.sun.jersey.api.client" level="WARN" additivity="false"> - <appender-ref ref="dataGrooming"/> - <appender-ref ref="dataGroomingdebug"/> - <appender-ref ref="dataGroomingmetric"/> - </logger> - <logger name="org.eclipse.jetty.util.log" level="WARN" additivity="false"> - <appender-ref ref="dataGrooming"/> - <appender-ref ref="dataGroomingdebug"/> - <appender-ref ref="dataGroomingmetric"/> - </logger> - <logger name="java.net" level="WARN" additivity="false"> - <appender-ref ref="dataGrooming"/> - <appender-ref ref="dataGroomingdebug"/> - <appender-ref ref="dataGroomingmetric"/> - </logger> - - <root level="INFO"> - <appender-ref ref="dataGrooming"/> - <appender-ref ref="dataGroomingdebug"/> - <appender-ref ref="dataGroomingmetric"/> - <appender-ref ref="STDOUT"/> - </root> -</configuration> diff --git a/aai-resources/src/main/resources/etc/appprops/dataSnapshot-logback.xml b/aai-resources/src/main/resources/etc/appprops/dataSnapshot-logback.xml deleted file mode 100644 index 0985f39..0000000 --- a/aai-resources/src/main/resources/etc/appprops/dataSnapshot-logback.xml +++ /dev/null @@ -1,139 +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> - <property name="logDirectory" value="${AJSC_HOME}/logs" /> - <property name="eelfLogPattern" value="%ecompStartTime|%date{yyyy-MM-dd'T'HH:mm:ss.SSSZ, UTC}|%X{requestId}|%X{serviceInstanceId}|%-10t|%X{serverName}|%X{serviceName}|%X{partnerName}|%X{statusCode}|%X{responseCode}|%replace(%replace(%X{responseDescription}){'\\|', '!'}){'\r|\n', '^'}|%X{instanceUUID}|%level|%X{severity}|%X{serverIpAddress}|%ecompElapsedTime|%X{server}|%X{clientIpAddress}|%eelfClassOfCaller|%X{unused}|%X{processKey}|%X{customField1}|%X{customField2}|%X{customField3}|%X{customField4}|co=%X{component}:%replace(%replace(%m){'\\|', '!'}){'\r|\n', '^'}%n"/> - <property name="eelfMetricLogPattern" value="%ecompStartTime|%date{yyyy-MM-dd'T'HH:mm:ss.SSSZ, UTC}|%X{requestId}|%X{serviceInstanceId}|%-10t|%X{serverName}|%X{serviceName}|%X{partnerName}|%X{targetEntity}|%X{targetServiceName}|%X{statusCode}|%X{responseCode}|%replace(%replace(%X{responseDescription}){'\\|', '!'}){'\r|\n', '^'}|%X{instanceUUID}|%level|%X{severity}|%X{serverIpAddress}|%ecompElapsedTime|%X{server}|%X{clientIpAddress}|%eelfClassOfCaller|%X{unused}|%X{processKey}|%X{targetVirtualEntity}|%X{customField1}|%X{customField2}|%X{customField3}|%X{customField4}|co=%X{component}:%replace(%replace(%m){'\\|', '!'}){'\r|\n', '^'}%n"/> - - <appender name="dataSnapshot" class="ch.qos.logback.core.rolling.RollingFileAppender"> - <filter class="ch.qos.logback.classic.filter.ThresholdFilter"> - <level>WARN</level> - </filter> - <File>${logDirectory}/dataSnapshot/error.log</File> - <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy"> - <fileNamePattern>${logDirectory}/dataSnapshot/error.log.%d{yyyy-MM-dd}</fileNamePattern> - </rollingPolicy> - <encoder class="org.onap.aai.logging.EcompEncoder"> - <pattern>${eelfLogPattern}</pattern> - </encoder> - </appender> - - <appender name="dataSnapshotdebug" class="ch.qos.logback.core.rolling.RollingFileAppender"> - <filter class="ch.qos.logback.classic.filter.LevelFilter"> - <level>DEBUG</level> - <onMatch>ACCEPT</onMatch> - <onMismatch>DENY</onMismatch> - </filter> - <File>${logDirectory}/dataSnapshot/debug.log</File> - <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy"> - <fileNamePattern>${logDirectory}/dataSnapshot/debug.log.%d{yyyy-MM-dd}</fileNamePattern> - </rollingPolicy> - <encoder class="org.onap.aai.logging.EcompEncoder"> - <pattern>${eelfLogPattern}</pattern> - </encoder> - </appender> - - <appender name="dataSnapshotmetric" class="ch.qos.logback.core.rolling.RollingFileAppender"> - <filter class="ch.qos.logback.classic.filter.LevelFilter"> - <level>INFO</level> - <onMatch>ACCEPT</onMatch> - <onMismatch>DENY</onMismatch> - </filter> - <File>${logDirectory}/dataSnapshot/metrics.log</File> - <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy"> - <fileNamePattern>${logDirectory}/dataSnapshot/metrics.log.%d{yyyy-MM-dd}</fileNamePattern> - </rollingPolicy> - <encoder class="org.onap.aai.logging.EcompEncoder"> - <pattern>${eelfMetricLogPattern}</pattern> - </encoder> - </appender> - - <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender"> - <encoder>%-4relative [%thread] %-5level %logger{35} - %msg %n</encoder> - </appender> - - <logger name="org.reflections" level="WARN" additivity="false"> - <appender-ref ref="dataSnapshot"/> - <appender-ref ref="dataSnapshotdebug"/> - <appender-ref ref="dataSnapshotmetric"/> - </logger> - <logger name="org.apache.zookeeper" level="WARN" additivity="false"> - <appender-ref ref="dataSnapshot"/> - <appender-ref ref="dataSnapshotdebug"/> - <appender-ref ref="dataSnapshotmetric"/> - </logger> - <logger name="org.apache.hadoop" level="WARN" additivity="false"> - <appender-ref ref="dataSnapshot"/> - <appender-ref ref="dataSnapshotdebug"/> - <appender-ref ref="dataSnapshotmetric"/> - <appender-ref ref="STDOUT"/> - </logger> - <logger name="org.janusgraph" level="WARN" additivity="false"> - <appender-ref ref="dataSnapshot"/> - <appender-ref ref="dataSnapshotdebug"/> - <appender-ref ref="dataSnapshotmetric"/> - </logger> - <logger name="ch.qos.logback.classic" level="WARN" additivity="false"> - <appender-ref ref="dataSnapshot"/> - <appender-ref ref="dataSnapshotdebug"/> - <appender-ref ref="dataSnapshotmetric"/> - </logger> - <logger name="ch.qos.logback.core" level="WARN" additivity="false"> - <appender-ref ref="dataSnapshot"/> - <appender-ref ref="dataSnapshotdebug"/> - <appender-ref ref="dataSnapshotmetric"/> - </logger> - <logger name="com.att.eelf" level="WARN" additivity="false"> - <appender-ref ref="dataSnapshot"/> - <appender-ref ref="dataSnapshotdebug"/> - <appender-ref ref="dataSnapshotmetric"/> - </logger> - <logger name="org.onap.aai" level="INFO" additivity="false"> - <appender-ref ref="dataSnapshot"/> - <appender-ref ref="dataSnapshotdebug"/> - <appender-ref ref="dataSnapshotmetric"/> - </logger> - <logger name="com.sun.jersey.api.client" level="WARN" additivity="false"> - <appender-ref ref="dataSnapshot"/> - <appender-ref ref="dataSnapshotdebug"/> - <appender-ref ref="dataSnapshotmetric"/> - </logger> - <logger name="org.eclipse.jetty.util.log" level="WARN" additivity="false"> - <appender-ref ref="dataSnapshot"/> - <appender-ref ref="dataSnapshotdebug"/> - <appender-ref ref="dataSnapshotmetric"/> - </logger> - <logger name="java.net" level="WARN" additivity="false"> - <appender-ref ref="dataSnapshot"/> - <appender-ref ref="dataSnapshotdebug"/> - <appender-ref ref="dataSnapshotmetric"/> - </logger> - - <root level="INFO"> - <appender-ref ref="dataSnapshot"/> - <appender-ref ref="dataSnapshotdebug"/> - <appender-ref ref="dataSnapshotmetric"/> - <appender-ref ref="STDOUT"/> - </root> -</configuration> diff --git a/aai-resources/src/main/resources/etc/appprops/default-logback.xml b/aai-resources/src/main/resources/etc/appprops/default-logback.xml deleted file mode 100644 index 0b1178c..0000000 --- a/aai-resources/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="org.janusgraph" 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-resources/src/main/resources/etc/appprops/dupeTool-logback.xml b/aai-resources/src/main/resources/etc/appprops/dupeTool-logback.xml deleted file mode 100644 index ae2c7d3..0000000 --- a/aai-resources/src/main/resources/etc/appprops/dupeTool-logback.xml +++ /dev/null @@ -1,62 +0,0 @@ -<configuration> - <property name="logDirectory" value="${AJSC_HOME}/logs" /> - - <appender name="dupeToollog" class="ch.qos.logback.classic.sift.SiftingAppender"> - <filter class="ch.qos.logback.classic.filter.LevelFilter"> - <level>INFO</level> - <onMatch>ACCEPT</onMatch> - <onMismatch>DENY</onMismatch> - </filter> - <!-- This is MDC value --> - <!-- We will assign a value to 'logFilenameAppender' via Java code --> - <discriminator> - <key>logFilenameAppender</key> - <defaultValue>undefined</defaultValue> - </discriminator> - <sift> - <!-- A standard RollingFileAppender, the log file is based on 'logFileName' - at runtime --> - <appender name="FILE-${logFilenameAppender}" - class="ch.qos.logback.core.rolling.RollingFileAppender"> - <file>${logDirectory}/dupeTool/${logFilenameAppender}.log</file> - <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy"> - <fileNamePattern>${logDirectory}/dupeTool/${logFilenameAppender}.log.%d{yyyy-MM-dd} - </fileNamePattern> - </rollingPolicy> - <encoder> - <pattern>%d{yyyy-MM-dd'T'HH:mm:ss.SSSXXX}|%m%n</pattern> - </encoder> - </appender> - </sift> - </appender> - - <logger name="org.reflections" level="ERROR" additivity="false"> - <appender-ref ref="dupeToollog" /> - </logger> - <logger name="org.apache.zookeeper" level="ERROR" additivity="false"> - <appender-ref ref="dupeToollog" /> - </logger> - <logger name="org.apache.hadoop" level="ERROR" additivity="false"> - <appender-ref ref="dupeToollog" /> - </logger> - <logger name="org.janusgraph" level="ERROR" additivity="false"> - <appender-ref ref="dupeToollog" /> - </logger> - <logger name="ch.qos.logback.classic" level="ERROR" additivity="false"> - <appender-ref ref="dupeToollog" /> - </logger> - <logger name="ch.qos.logback.core" level="ERROR" additivity="false"> - <appender-ref ref="dupeToollog" /> - </logger> - <logger name="com.att.eelf" level="ERROR" additivity="false"> - <appender-ref ref="dupeToollog" /> - </logger> - <logger name="org.onap.aai" level="ERROR" additivity="false"> - <appender-ref ref="dupeToollog" /> - </logger> - - - <root level="INFO"> - <appender-ref ref="dupeToollog" /> - </root> -</configuration>
\ No newline at end of file diff --git a/aai-resources/src/main/resources/etc/appprops/dynamic.properties b/aai-resources/src/main/resources/etc/appprops/dynamic.properties index e8f9a90..ae5b390 100644 --- a/aai-resources/src/main/resources/etc/appprops/dynamic.properties +++ b/aai-resources/src/main/resources/etc/appprops/dynamic.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,17 +16,11 @@ # 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 # the following parameters are not reloaded automatically and require a manual bounce storage.backend=inmemory -#Kept the below if we need to change from in-memory to dynamic instance -#storage.hostname=mtanjv9aads01.nvp.cip.att.com,mtanjv9aads02.nvp.cip.att.com,mtanjv9aads03.nvp.cip.att.com -#storage.hbase.table=tenant-isol-temp - #caching on cache.db-cache = true cache.db-cache-clean-wait = 20 diff --git a/aai-resources/src/main/resources/etc/appprops/dynamicPayloadGenerator-logback.xml b/aai-resources/src/main/resources/etc/appprops/dynamicPayloadGenerator-logback.xml deleted file mode 100644 index 3942af0..0000000 --- a/aai-resources/src/main/resources/etc/appprops/dynamicPayloadGenerator-logback.xml +++ /dev/null @@ -1,85 +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> - <property name="logDirectory" value="${AJSC_HOME}/logs" /> - - <appender name="dynamicPayloadGeneratorlog" class="ch.qos.logback.classic.sift.SiftingAppender"> - <filter class="ch.qos.logback.classic.filter.LevelFilter"> - <level>INFO</level> - <onMatch>ACCEPT</onMatch> - <onMismatch>DENY</onMismatch> - </filter> - <!-- This is MDC value --> - <!-- We will assign a value to 'logFilenameAppender' via Java code --> - <discriminator> - <key>logFilenameAppender</key> - <defaultValue>undefined</defaultValue> - </discriminator> - <sift> - <!-- A standard RollingFileAppender, the log file is based on 'logFileName' - at runtime --> - <appender name="FILE-${logFilenameAppender}" - class="ch.qos.logback.core.rolling.RollingFileAppender"> - <file>${logDirectory}/dynamicPayloadGeneratorlog/${logFilenameAppender}.log</file> - <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy"> - <fileNamePattern>${logDirectory}/dynamicPayloadGeneratorlog/${logFilenameAppender}.log.%d{yyyy-MM-dd} - </fileNamePattern> - </rollingPolicy> - <encoder> - <pattern>%d{yyyy-MM-dd'T'HH:mm:ss.SSSXXX}|%m%n</pattern> - </encoder> - </appender> - </sift> - </appender> - - <logger name="org.reflections" level="ERROR" additivity="false"> - <appender-ref ref="dynamicPayloadGeneratorlog" /> - </logger> - <logger name="org.apache.zookeeper" level="ERROR" additivity="false"> - <appender-ref ref="dynamicPayloadGeneratorlog" /> - </logger> - <logger name="org.apache.hadoop" level="ERROR" additivity="false"> - <appender-ref ref="dynamicPayloadGeneratorlog" /> - </logger> - <logger name="org.janusgraph" level="ERROR" additivity="false"> - <appender-ref ref="dynamicPayloadGeneratorlog" /> - </logger> - <logger name="ch.qos.logback.classic" level="ERROR" additivity="false"> - <appender-ref ref="dynamicPayloadGeneratorlog" /> - </logger> - <logger name="ch.qos.logback.core" level="ERROR" additivity="false"> - <appender-ref ref="dynamicPayloadGeneratorlog" /> - </logger> - <logger name="com.att.eelf" level="ERROR" additivity="false"> - <appender-ref ref="dynamicPayloadGeneratorlog" /> - </logger> - <logger name="org.onap.aai" level="INFO" additivity="false"> - <appender-ref ref="dynamicPayloadGeneratorlog" /> - </logger> - - - <root level="INFO"> - <appender-ref ref="dynamicPayloadGeneratorlog" /> - </root> -</configuration> diff --git a/aai-resources/src/main/resources/etc/appprops/error.properties b/aai-resources/src/main/resources/etc/appprops/error.properties index 745f4fb..99306d4 100644 --- a/aai-resources/src/main/resources/etc/appprops/error.properties +++ b/aai-resources/src/main/resources/etc/appprops/error.properties @@ -32,6 +32,10 @@ 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_3015=5:6:INFO:3015:410:3015:The %1 capability is retired, please contact the A&AI SE team to identify a replacement query +AAI_3016=5:6:INFO:3007:400:3016:Request uri is not valid, please check the version %1 +AAI_3017=5:6:INFO:3007:400:3016:Request uri is not valid, please check the uri %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 @@ -136,9 +140,6 @@ 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 @@ -171,3 +172,7 @@ AAI_9108=5:0:WARN:9107:403:3300:Basic auth credentials is not provided in the re #--- 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-resources/src/main/resources/etc/appprops/forceDelete-logback.xml b/aai-resources/src/main/resources/etc/appprops/forceDelete-logback.xml deleted file mode 100644 index 41d33c1..0000000 --- a/aai-resources/src/main/resources/etc/appprops/forceDelete-logback.xml +++ /dev/null @@ -1,85 +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> - <property name="logDirectory" value="${AJSC_HOME}/logs" /> - - <appender name="forceDeletelog" class="ch.qos.logback.classic.sift.SiftingAppender"> - <filter class="ch.qos.logback.classic.filter.LevelFilter"> - <level>INFO</level> - <onMatch>ACCEPT</onMatch> - <onMismatch>DENY</onMismatch> - </filter> - <!-- This is MDC value --> - <!-- We will assign a value to 'logFilenameAppender' via Java code --> - <discriminator> - <key>logFilenameAppender</key> - <defaultValue>undefined</defaultValue> - </discriminator> - <sift> - <!-- A standard RollingFileAppender, the log file is based on 'logFileName' - at runtime --> - <appender name="FILE-${logFilenameAppender}" - class="ch.qos.logback.core.rolling.RollingFileAppender"> - <file>${logDirectory}/forceDelete/${logFilenameAppender}.log</file> - <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy"> - <fileNamePattern>${logDirectory}/forceDelete/${logFilenameAppender}.log.%d{yyyy-MM-dd} - </fileNamePattern> - </rollingPolicy> - <encoder> - <pattern>%d{yyyy-MM-dd'T'HH:mm:ss.SSSXXX}|%m%n</pattern> - </encoder> - </appender> - </sift> - </appender> - - <logger name="org.reflections" level="ERROR" additivity="false"> - <appender-ref ref="forceDeletelog" /> - </logger> - <logger name="org.apache.zookeeper" level="ERROR" additivity="false"> - <appender-ref ref="forceDeletelog" /> - </logger> - <logger name="org.apache.hadoop" level="ERROR" additivity="false"> - <appender-ref ref="forceDeletelog" /> - </logger> - <logger name="org.janusgraph" level="ERROR" additivity="false"> - <appender-ref ref="forceDeletelog" /> - </logger> - <logger name="ch.qos.logback.classic" level="ERROR" additivity="false"> - <appender-ref ref="forceDeletelog" /> - </logger> - <logger name="ch.qos.logback.core" level="ERROR" additivity="false"> - <appender-ref ref="forceDeletelog" /> - </logger> - <logger name="com.att.eelf" level="ERROR" additivity="false"> - <appender-ref ref="forceDeletelog" /> - </logger> - <logger name="org.onap.aai" level="ERROR" additivity="false"> - <appender-ref ref="forceDeletelog" /> - </logger> - - - <root level="INFO"> - <appender-ref ref="forceDeletelog" /> - </root> -</configuration>
\ No newline at end of file diff --git a/aai-resources/src/main/resources/etc/appprops/getres-logback.xml b/aai-resources/src/main/resources/etc/appprops/getres-logback.xml deleted file mode 100644 index 441f807..0000000 --- a/aai-resources/src/main/resources/etc/appprops/getres-logback.xml +++ /dev/null @@ -1,123 +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> - <property name="logDirectory" value="${AJSC_HOME}/logs" /> - <property name="eelfLogPattern" value="%ecompStartTime|%date{yyyy-MM-dd'T'HH:mm:ss.SSSZ, UTC}|%X{requestId}|%X{serviceInstanceId}|%-10t|%X{serverName}|%X{serviceName}|%X{partnerName}|%X{statusCode}|%X{responseCode}|%replace(%replace(%X{responseDescription}){'\\|', '!'}){'\r|\n', '^'}|%X{instanceUUID}|%level|%X{severity}|%X{serverIpAddress}|%ecompElapsedTime|%X{server}|%X{clientIpAddress}|%eelfClassOfCaller|%X{unused}|%X{processKey}|%X{customField1}|%X{customField2}|%X{customField3}|%X{customField4}|co=%X{component}:%replace(%replace(%m){'\\|', '!'}){'\r|\n', '^'}%n"/> - <property name="eelfMetricLogPattern" value="%ecompStartTime|%date{yyyy-MM-dd'T'HH:mm:ss.SSSZ, UTC}|%X{requestId}|%X{serviceInstanceId}|%-10t|%X{serverName}|%X{serviceName}|%X{partnerName}|%X{targetEntity}|%X{targetServiceName}|%X{statusCode}|%X{responseCode}|%replace(%replace(%X{responseDescription}){'\\|', '!'}){'\r|\n', '^'}|%X{instanceUUID}|%level|%X{severity}|%X{serverIpAddress}|%ecompElapsedTime|%X{server}|%X{clientIpAddress}|%eelfClassOfCaller|%X{unused}|%X{processKey}|%X{targetVirtualEntity}|%X{customField1}|%X{customField2}|%X{customField3}|%X{customField4}|co=%X{component}:%replace(%replace(%m){'\\|', '!'}){'\r|\n', '^'}%n"/> - - <appender name="getTool" class="ch.qos.logback.core.rolling.RollingFileAppender"> - <filter class="ch.qos.logback.classic.filter.ThresholdFilter"> - <level>WARN</level> - </filter> - <File>${logDirectory}/getTool/error.log</File> - <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy"> - <fileNamePattern>${logDirectory}/getTool/error.log.%d{yyyy-MM-dd}</fileNamePattern> - </rollingPolicy> - <encoder class="org.onap.aai.logging.EcompEncoder"> - <pattern>${eelfLogPattern}</pattern> - </encoder> - </appender> - - <appender name="getTooldebug" class="ch.qos.logback.core.rolling.RollingFileAppender"> - <filter class="ch.qos.logback.classic.filter.LevelFilter"> - <level>DEBUG</level> - <onMatch>ACCEPT</onMatch> - <onMismatch>DENY</onMismatch> - </filter> - <File>${logDirectory}/getTool/debug.log</File> - <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy"> - <fileNamePattern>${logDirectory}/getTool/debug.log.%d{yyyy-MM-dd}</fileNamePattern> - </rollingPolicy> - <encoder class="org.onap.aai.logging.EcompEncoder"> - <pattern>${eelfLogPattern}</pattern> - </encoder> - </appender> - - <appender name="getToolmetric" class="ch.qos.logback.core.rolling.RollingFileAppender"> - <filter class="ch.qos.logback.classic.filter.LevelFilter"> - <level>INFO</level> - <onMatch>ACCEPT</onMatch> - <onMismatch>DENY</onMismatch> - </filter> - <File>${logDirectory}/getTool/metrics.log</File> - <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy"> - <fileNamePattern>${logDirectory}/getTool/metrics.log.%d{yyyy-MM-dd}</fileNamePattern> - </rollingPolicy> - <encoder class="org.onap.aai.logging.EcompEncoder"> - <pattern>${eelfMetricLogPattern}</pattern> - </encoder> - </appender> - - <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender"> - <encoder>%-4relative [%thread] %-5level %logger{35} - %msg %n</encoder> - </appender> - - <logger name="org.reflections" level="WARN" additivity="false"> - <appender-ref ref="getTool"/> - <appender-ref ref="getTooldebug"/> - <appender-ref ref="getToolmetric"/> - </logger> - <logger name="org.apache.zookeeper" level="WARN" additivity="false"> - <appender-ref ref="getTool"/> - <appender-ref ref="getTooldebug"/> - <appender-ref ref="getToolmetric"/> - </logger> - <logger name="org.apache.hadoop" level="WARN" additivity="false"> - <appender-ref ref="getTool"/> - <appender-ref ref="getTooldebug"/> - <appender-ref ref="getToolmetric"/> - </logger> - <logger name="org.janusgraph" level="WARN" additivity="false"> - <appender-ref ref="getTool"/> - <appender-ref ref="getTooldebug"/> - <appender-ref ref="getToolmetric"/> - </logger> - <logger name="ch.qos.logback.classic" level="WARN" additivity="false"> - <appender-ref ref="getTool"/> - <appender-ref ref="getTooldebug"/> - <appender-ref ref="getToolmetric"/> - </logger> - <logger name="ch.qos.logback.core" level="WARN" additivity="false"> - <appender-ref ref="getTool"/> - <appender-ref ref="getTooldebug"/> - <appender-ref ref="getToolmetric"/> - </logger> - <logger name="com.att.eelf" level="WARN" additivity="false"> - <appender-ref ref="getTool"/> - <appender-ref ref="getTooldebug"/> - <appender-ref ref="getToolmetric"/> - </logger> - <logger name="org.onap.aai" level="INFO" additivity="false"> - <appender-ref ref="getTool"/> - <appender-ref ref="getTooldebug"/> - <appender-ref ref="getToolmetric"/> - </logger> - - <root level="INFO"> - <appender-ref ref="getTool"/> - <appender-ref ref="getTooldebug"/> - <appender-ref ref="getToolmetric"/> - <appender-ref ref="STDOUT"/> - </root> -</configuration> diff --git a/aai-resources/src/main/resources/etc/appprops/janusgraph-cached.properties b/aai-resources/src/main/resources/etc/appprops/janusgraph-cached.properties index ecd4dbf..c90816d 100644 --- a/aai-resources/src/main/resources/etc/appprops/janusgraph-cached.properties +++ b/aai-resources/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,21 +16,16 @@ # 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.hostname=localhost -#graph.titan-version=1.0.0 #schema.default=none storage.lock.wait-time=300 storage.hbase.table=aaigraph-dev1.dev -storage.hbase.ext.zookeeper.znode.parent=/hbase +storage.hbase.ext.zookeeper.znode.parent=/hbase-unsecure #caching on cache.db-cache = true cache.db-cache-clean-wait = 20 @@ -38,4 +33,4 @@ cache.db-cache-time = 180000 cache.db-cache-size = 0.3 #load graphson file on startup -load.snapshot.file=false +load.snapshot.file=false
\ No newline at end of file diff --git a/aai-resources/src/main/resources/etc/appprops/janusgraph-realtime.properties b/aai-resources/src/main/resources/etc/appprops/janusgraph-realtime.properties index cfe8312..36256c9 100644 --- a/aai-resources/src/main/resources/etc/appprops/janusgraph-realtime.properties +++ b/aai-resources/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,24 +16,18 @@ # 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.hostname=localhost -#graph.titan-version=1.0.0 - #schema.default=none storage.lock.wait-time=300 storage.hbase.table=aaigraph-dev1.dev -storage.hbase.ext.zookeeper.znode.parent=/hbase +storage.hbase.ext.zookeeper.znode.parent=/hbase-unsecure # Setting db-cache to false ensure the fastest propagation of changes across servers cache.db-cache = false #load graphson file on startup -load.snapshot.file=false +load.snapshot.file=false
\ No newline at end of file diff --git a/aai-resources/src/main/resources/etc/appprops/loadDataForDHV-logback.xml b/aai-resources/src/main/resources/etc/appprops/loadDataForDHV-logback.xml deleted file mode 100644 index e42128b..0000000 --- a/aai-resources/src/main/resources/etc/appprops/loadDataForDHV-logback.xml +++ /dev/null @@ -1,116 +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> - <property name="logDirectory" value="${AJSC_HOME}/logs" /> - - <appender name="loadDataForDHV" class="ch.qos.logback.core.rolling.RollingFileAppender"> - <filter class="ch.qos.logback.classic.filter.ThresholdFilter"> - <level>WARN</level> - </filter> - <File>${logDirectory}/loadDataForDHV/error.log</File> - <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy"> - <fileNamePattern>${logDirectory}/loadDataForDHV/error.log.%d{yyyy-MM-dd}</fileNamePattern> - </rollingPolicy> - <encoder> - <pattern>%m%n</pattern> - </encoder> - </appender> - - <appender name="loadDataForDHVdebug" class="ch.qos.logback.core.rolling.RollingFileAppender"> - <filter class="ch.qos.logback.classic.filter.LevelFilter"> - <level>DEBUG</level> - <onMatch>ACCEPT</onMatch> - <onMismatch>DENY</onMismatch> - </filter> - <File>${logDirectory}/loadDataForDHV/debug.log</File> - <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy"> - <fileNamePattern>${logDirectory}/loadDataForDHV/debug.log.%d{yyyy-MM-dd}</fileNamePattern> - </rollingPolicy> - <encoder> - <pattern>%m%n</pattern> - </encoder> - </appender> - - <appender name="loadDataForDHVmetric" class="ch.qos.logback.core.rolling.RollingFileAppender"> - <filter class="ch.qos.logback.classic.filter.LevelFilter"> - <level>INFO</level> - <onMatch>ACCEPT</onMatch> - <onMismatch>DENY</onMismatch> - </filter> - <File>${logDirectory}/loadDataForDHV/metrics.log</File> - <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy"> - <fileNamePattern>${logDirectory}/loadDataForDHV/metrics.log.%d{yyyy-MM-dd}</fileNamePattern> - </rollingPolicy> - <encoder> - <pattern>%m%n</pattern> - </encoder> - </appender> - - <logger name="org.reflections" level="WARN" additivity="false"> - <appender-ref ref="loadDataForDHV"/> - <appender-ref ref="loadDataForDHVdebug"/> - <appender-ref ref="loadDataForDHVmetric"/> - </logger> - <logger name="org.apache.zookeeper" level="WARN" additivity="false"> - <appender-ref ref="loadDataForDHV"/> - <appender-ref ref="loadDataForDHVdebug"/> - <appender-ref ref="loadDataForDHVmetric"/> - </logger> - <logger name="org.apache.hadoop" level="WARN" additivity="false"> - <appender-ref ref="loadDataForDHV"/> - <appender-ref ref="loadDataForDHVdebug"/> - <appender-ref ref="loadDataForDHVmetric"/> - </logger> - <logger name="org.janusgraph" level="WARN" additivity="false"> - <appender-ref ref="loadDataForDHV"/> - <appender-ref ref="loadDataForDHVdebug"/> - <appender-ref ref="loadDataForDHVmetric"/> - </logger> - <logger name="ch.qos.logback.classic" level="WARN" additivity="false"> - <appender-ref ref="loadDataForDHV"/> - <appender-ref ref="loadDataForDHVdebug"/> - <appender-ref ref="loadDataForDHVmetric"/> - </logger> - <logger name="ch.qos.logback.core" level="WARN" additivity="false"> - <appender-ref ref="loadDataForDHV"/> - <appender-ref ref="loadDataForDHVdebug"/> - <appender-ref ref="loadDataForDHVmetric"/> - </logger> - <logger name="com.att.eelf" level="WARN" additivity="false"> - <appender-ref ref="loadDataForDHV"/> - <appender-ref ref="loadDataForDHVdebug"/> - <appender-ref ref="loadDataForDHVmetric"/> - </logger> - <logger name="org.onap.aai" level="INFO" additivity="false"> - <appender-ref ref="loadDataForDHV"/> - <appender-ref ref="loadDataForDHVdebug"/> - <appender-ref ref="loadDataForDHVmetric"/> - </logger> - - <root level="INFO"> - <appender-ref ref="loadDataForDHV"/> - <appender-ref ref="loadDataForDHVdebug"/> - <appender-ref ref="loadDataForDHVmetric"/> - </root> -</configuration> diff --git a/aai-resources/src/main/resources/etc/appprops/logging.properties b/aai-resources/src/main/resources/etc/appprops/logging.properties deleted file mode 100644 index e029cc4..0000000 --- a/aai-resources/src/main/resources/etc/appprops/logging.properties +++ /dev/null @@ -1,128 +0,0 @@ -# Licensed to the Apache Software Foundation (ASF) under one or more -# contributor license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright ownership. -# The ASF licenses this file to You under the Apache License, Version 2.0 -# (the "License"); you may not use this file except in compliance with -# the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -handlers = 1catalina.org.apache.juli.FileHandler, 2localhost.org.apache.juli.FileHandler, 3manager.org.apache.juli.FileHandler, 4host-manager.org.apache.juli.FileHandler, java.util.logging.ConsoleHandler - -.handlers = 1catalina.org.apache.juli.FileHandler, java.util.logging.ConsoleHandler - -############################################################ -# Handler specific properties. -# Describes specific configuration info for Handlers. -############################################################ - -# this is where we will limit logging on components -org.apache.hadoop.level=WARNING -org.apache.zookeeper.level=WARNING -org.reflections.level=WARNING -com.thinkaurelius.level=WARNING - -1catalina.org.apache.juli.FileHandler.level = FINE -1catalina.org.apache.juli.FileHandler.directory = ${catalina.base}/logs -1catalina.org.apache.juli.FileHandler.prefix = catalina. - -2localhost.org.apache.juli.FileHandler.level = FINE -2localhost.org.apache.juli.FileHandler.directory = ${catalina.base}/logs -2localhost.org.apache.juli.FileHandler.prefix = localhost. - -3manager.org.apache.juli.FileHandler.level = FINE -3manager.org.apache.juli.FileHandler.directory = ${catalina.base}/logs -3manager.org.apache.juli.FileHandler.prefix = manager. - -4host-manager.org.apache.juli.FileHandler.level = FINE -4host-manager.org.apache.juli.FileHandler.directory = ${catalina.base}/logs -4host-manager.org.apache.juli.FileHandler.prefix = host-manager. - -java.util.logging.ConsoleHandler.level = INFO -java.util.logging.ConsoleHandler.formatter = java.util.logging.SimpleFormatter - - - -############################################################ -# Facility specific properties. -# Provides extra control for each logger. -############################################################ - -org.apache.catalina.core.ContainerBase.[Catalina].[localhost].level = INFO -org.apache.catalina.core.ContainerBase.[Catalina].[localhost].handlers = 2localhost.org.apache.juli.FileHandler - -org.apache.catalina.core.ContainerBase.[Catalina].[localhost].[/manager].level = INFO -org.apache.catalina.core.ContainerBase.[Catalina].[localhost].[/manager].handlers = 3manager.org.apache.juli.FileHandler - -org.apache.catalina.core.ContainerBase.[Catalina].[localhost].[/host-manager].level = INFO -org.apache.catalina.core.ContainerBase.[Catalina].[localhost].[/host-manager].handlers = 4host-manager.org.apache.juli.FileHandler - -# For example, set the org.apache.catalina.util.LifecycleBase logger to log -# each component that extends LifecycleBase changing state: -#org.apache.catalina.util.LifecycleBase.level = FINE - -# To see debug messages in TldLocationsCache, uncomment the following line: -#org.apache.jasper.compiler.TldLocationsCache.level = FINE - - -################################ -# OpenEJB/TomEE specific loggers -################################ -# -# ACTIVATE LEVEL/HANDLERS YOU WANT -# IF YOU ACTIVATE 5tomee.org.apache.juli.FileHandler -# ADD IT TO handlers LINE LIKE: -# -# handlers = 1catalina.org.apache.juli.FileHandler, 2localhost.org.apache.juli.FileHandler, 3manager.org.apache.juli.FileHandler, 4host-manager.org.apache.juli.FileHandler, 5tomee.org.apache.juli.FileHandler, java.util.logging.ConsoleHandler -# -# LEVELS: -# ======= -# -# OpenEJB.level = WARNING -# OpenEJB.options.level = INFO -# OpenEJB.server.level = INFO -# OpenEJB.startup.level = INFO -# OpenEJB.startup.service.level = WARNING -# OpenEJB.startup.config.level = INFO -# OpenEJB.hsql.level = INFO -# CORBA-Adapter.level = WARNING -# Transaction.level = WARNING -# org.apache.activemq.level = SEVERE -# org.apache.geronimo.level = SEVERE -# openjpa.level = WARNING -# OpenEJB.cdi.level = INFO -# org.apache.webbeans.level = INFO -# org.apache.openejb.level = FINE -# -# HANDLERS: -# ========= -# -# OpenEJB.handlers = 5tomee.org.apache.juli.FileHandler, java.util.logging.ConsoleHandler -# OpenEJB.options.handlers = 5tomee.org.apache.juli.FileHandler, java.util.logging.ConsoleHandler -# OpenEJB.server.handlers = 5tomee.org.apache.juli.FileHandler, java.util.logging.ConsoleHandler -# OpenEJB.startup.handlers = 5tomee.org.apache.juli.FileHandler, java.util.logging.ConsoleHandler -# OpenEJB.startup.service.handlers = 5tomee.org.apache.juli.FileHandler, java.util.logging.ConsoleHandler -# OpenEJB.startup.config.handlers = 5tomee.org.apache.juli.FileHandler, java.util.logging.ConsoleHandler -# OpenEJB.hsql.handlers = 5tomee.org.apache.juli.FileHandler, java.util.logging.ConsoleHandler -# CORBA-Adapter.handlers = 5tomee.org.apache.juli.FileHandler, java.util.logging.ConsoleHandler -# Transaction.handlers = 5tomee.org.apache.juli.FileHandler, java.util.logging.ConsoleHandler -# org.apache.activemq.handlers = 5tomee.org.apache.juli.FileHandler, java.util.logging.ConsoleHandler -# org.apache.geronimo.handlers = 5tomee.org.apache.juli.FileHandler, java.util.logging.ConsoleHandler -# openjpa.handlers = 5tomee.org.apache.juli.FileHandler, java.util.logging.ConsoleHandler -# OpenEJB.cdi.handlers = 5tomee.org.apache.juli.FileHandler, java.util.logging.ConsoleHandler -# org.apache.webbeans.handlers = 5tomee.org.apache.juli.FileHandler, java.util.logging.ConsoleHandler -# org.apache.openejb.handlers = 5tomee.org.apache.juli.FileHandler, java.util.logging.ConsoleHandler -# -# TOMEE HANDLER SAMPLE: -# ===================== -# -# 5tomee.org.apache.juli.FileHandler.level = FINEST -# 5tomee.org.apache.juli.FileHandler.directory = ${catalina.base}/logs -# 5tomee.org.apache.juli.FileHandler.prefix = tomee. - diff --git a/aai-resources/src/main/resources/etc/appprops/methodMapper.properties b/aai-resources/src/main/resources/etc/appprops/methodMapper.properties deleted file mode 100644 index bcacfa6..0000000 --- a/aai-resources/src/main/resources/etc/appprops/methodMapper.properties +++ /dev/null @@ -1,24 +0,0 @@ -{ - "ActiveAndAvailableInventory-CloudNetwork" : [{ - "logicalName" : "getAAIResource", - "method" : "get", - "url" : "/aai/*" - }, { - "logicalName" : "putAAIResource", - "method" : "put", - "url" : "/aai/*" - }, { - "logicalName" : "deleteAAIResource", - "method" : "delete", - "url" : "/aai/*" - }, { - "logicalName" : "postAAIResource", - "method" : "post", - "url" : "/aai/*" - }, { - "logicalName" : "patchAAIResource", - "method" : "patch", - "url" : "/aai/*" - } - ] -} diff --git a/aai-resources/src/main/resources/etc/appprops/migration-logback.xml b/aai-resources/src/main/resources/etc/appprops/migration-logback.xml deleted file mode 100644 index a6dbc1e..0000000 --- a/aai-resources/src/main/resources/etc/appprops/migration-logback.xml +++ /dev/null @@ -1,85 +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> - <property name="logDirectory" value="${AJSC_HOME}/logs" /> - - <appender name="migrationlog" class="ch.qos.logback.classic.sift.SiftingAppender"> - <filter class="ch.qos.logback.classic.filter.LevelFilter"> - <level>INFO</level> - <onMatch>ACCEPT</onMatch> - <onMismatch>DENY</onMismatch> - </filter> - <!-- This is MDC value --> - <!-- We will assign a value to 'logFilenameAppender' via Java code --> - <discriminator> - <key>logFilenameAppender</key> - <defaultValue>undefined</defaultValue> - </discriminator> - <sift> - <!-- A standard RollingFileAppender, the log file is based on 'logFileName' - at runtime --> - <appender name="FILE-${logFilenameAppender}" - class="ch.qos.logback.core.rolling.RollingFileAppender"> - <file>${logDirectory}/migration/${logFilenameAppender}.log</file> - <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy"> - <fileNamePattern>${logDirectory}/migration/${logFilenameAppender}.log.%d{yyyy-MM-dd} - </fileNamePattern> - </rollingPolicy> - <encoder> - <pattern>%d{yyyy-MM-dd'T'HH:mm:ss.SSSXXX}|%m%n</pattern> - </encoder> - </appender> - </sift> - </appender> - - <logger name="org.reflections" level="ERROR" additivity="false"> - <appender-ref ref="migrationlog" /> - </logger> - <logger name="org.apache.zookeeper" level="ERROR" additivity="false"> - <appender-ref ref="migrationlog" /> - </logger> - <logger name="org.apache.hadoop" level="ERROR" additivity="false"> - <appender-ref ref="migrationlog" /> - </logger> - <logger name="org.janusgraph" level="ERROR" additivity="false"> - <appender-ref ref="migrationlog" /> - </logger> - <logger name="ch.qos.logback.classic" level="ERROR" additivity="false"> - <appender-ref ref="migrationlog" /> - </logger> - <logger name="ch.qos.logback.core" level="ERROR" additivity="false"> - <appender-ref ref="migrationlog" /> - </logger> - <logger name="com.att.eelf" level="ERROR" additivity="false"> - <appender-ref ref="migrationlog" /> - </logger> - <logger name="org.onap.aai" level="ERROR" additivity="false"> - <appender-ref ref="migrationlog" /> - </logger> - - - <root level="INFO"> - <appender-ref ref="migrationlog" /> - </root> -</configuration> diff --git a/aai-resources/src/main/resources/etc/appprops/preferredRoute.txt b/aai-resources/src/main/resources/etc/appprops/preferredRoute.txt deleted file mode 100644 index 662b0aa..0000000 --- a/aai-resources/src/main/resources/etc/appprops/preferredRoute.txt +++ /dev/null @@ -1 +0,0 @@ -preferredRouteKey=MR1
\ No newline at end of file diff --git a/aai-resources/src/main/resources/etc/appprops/pullInvData-logback.xml b/aai-resources/src/main/resources/etc/appprops/pullInvData-logback.xml deleted file mode 100644 index 72c60b8..0000000 --- a/aai-resources/src/main/resources/etc/appprops/pullInvData-logback.xml +++ /dev/null @@ -1,128 +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> - <property name="logDirectory" value="${AJSC_HOME}/logs" /> - <property name="eelfLogPattern" value="%ecompStartTime|%date{yyyy-MM-dd'T'HH:mm:ss.SSSZ, UTC}|%X{requestId}|%X{serviceInstanceId}|%-10t|%X{serverName}|%X{serviceName}|%X{partnerName}|%X{statusCode}|%X{responseCode}|%replace(%replace(%X{responseDescription}){'\\|', '!'}){'\r|\n', '^'}|%X{instanceUUID}|%level|%X{severity}|%X{serverIpAddress}|%ecompElapsedTime|%X{server}|%X{clientIpAddress}|%eelfClassOfCaller|%X{unused}|%X{processKey}|%X{customField1}|%X{customField2}|%X{customField3}|%X{customField4}|co=%X{component}:%replace(%replace(%m){'\\|', '!'}){'\r|\n', '^'}%n"/> - <property name="eelfMetricLogPattern" value="%ecompStartTime|%date{yyyy-MM-dd'T'HH:mm:ss.SSSZ, UTC}|%X{requestId}|%X{serviceInstanceId}|%-10t|%X{serverName}|%X{serviceName}|%X{partnerName}|%X{targetEntity}|%X{targetServiceName}|%X{statusCode}|%X{responseCode}|%replace(%replace(%X{responseDescription}){'\\|', '!'}){'\r|\n', '^'}|%X{instanceUUID}|%level|%X{severity}|%X{serverIpAddress}|%ecompElapsedTime|%X{server}|%X{clientIpAddress}|%eelfClassOfCaller|%X{unused}|%X{processKey}|%X{targetVirtualEntity}|%X{customField1}|%X{customField2}|%X{customField3}|%X{customField4}|co=%X{component}:%replace(%replace(%m){'\\|', '!'}){'\r|\n', '^'}%n"/> - - <appender name="pullInvData" class="ch.qos.logback.core.rolling.RollingFileAppender"> - <filter class="ch.qos.logback.classic.filter.ThresholdFilter"> - <level>WARN</level> - </filter> - <File>${logDirectory}/pullInvData/error.log</File> - <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy"> - <fileNamePattern>${logDirectory}/pullInvData/error.log.%d{yyyy-MM-dd}</fileNamePattern> - </rollingPolicy> - <encoder class="org.onap.aai.logging.EcompEncoder"> - <pattern>${eelfLogPattern}</pattern> - </encoder> - </appender> - - <appender name="pullInvDatadebug" class="ch.qos.logback.core.rolling.RollingFileAppender"> - <filter class="ch.qos.logback.classic.filter.LevelFilter"> - <level>DEBUG</level> - <onMatch>ACCEPT</onMatch> - <onMismatch>DENY</onMismatch> - </filter> - <File>${logDirectory}/pullInvData/debug.log</File> - <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy"> - <fileNamePattern>${logDirectory}/pullInvData/debug.log.%d{yyyy-MM-dd}</fileNamePattern> - </rollingPolicy> - <encoder class="org.onap.aai.logging.EcompEncoder"> - <pattern>${eelfLogPattern}</pattern> - </encoder> - </appender> - - <appender name="pullInvDatametric" class="ch.qos.logback.core.rolling.RollingFileAppender"> - <filter class="ch.qos.logback.classic.filter.LevelFilter"> - <level>INFO</level> - <onMatch>ACCEPT</onMatch> - <onMismatch>DENY</onMismatch> - </filter> - <File>${logDirectory}/pullInvData/metrics.log</File> - <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy"> - <fileNamePattern>${logDirectory}/pullInvData/metrics.log.%d{yyyy-MM-dd}</fileNamePattern> - </rollingPolicy> - <encoder class="org.onap.aai.logging.EcompEncoder"> - <pattern>${eelfMetricLogPattern}</pattern> - </encoder> - </appender> - - <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender"> - <encoder>%-4relative [%thread] %-5level %logger{35} - %msg %n</encoder> - </appender> - - <logger name="org.reflections" level="WARN" additivity="false"> - <appender-ref ref="pullInvData"/> - <appender-ref ref="pullInvDatadebug"/> - <appender-ref ref="pullInvDatametric"/> - </logger> - <logger name="org.apache.zookeeper" level="WARN" additivity="false"> - <appender-ref ref="pullInvData"/> - <appender-ref ref="pullInvDatadebug"/> - <appender-ref ref="pullInvDatametric"/> - </logger> - <logger name="org.apache.hadoop" level="WARN" additivity="false"> - <appender-ref ref="pullInvData"/> - <appender-ref ref="pullInvDatadebug"/> - <appender-ref ref="pullInvDatametric"/> - </logger> - <logger name="org.janusgraph" level="WARN" additivity="false"> - <appender-ref ref="pullInvData"/> - <appender-ref ref="pullInvDatadebug"/> - <appender-ref ref="pullInvDatametric"/> - </logger> - <logger name="ch.qos.logback.classic" level="WARN" additivity="false"> - <appender-ref ref="pullInvData"/> - <appender-ref ref="pullInvDatadebug"/> - <appender-ref ref="pullInvDatametric"/> - </logger> - <logger name="ch.qos.logback.core" level="WARN" additivity="false"> - <appender-ref ref="pullInvData"/> - <appender-ref ref="pullInvDatadebug"/> - <appender-ref ref="pullInvDatametric"/> - </logger> - <logger name="java.net" level="WARN" additivity="false"> - <appender-ref ref="pullInvData"/> - <appender-ref ref="pullInvDatadebug"/> - <appender-ref ref="pullInvDatametric"/> - </logger> - <logger name="com.att.eelf" level="WARN" additivity="false"> - <appender-ref ref="pullInvData"/> - <appender-ref ref="pullInvDatadebug"/> - <appender-ref ref="pullInvDatametric"/> - </logger> - <logger name="org.onap.aai" level="INFO" additivity="false"> - <appender-ref ref="pullInvData"/> - <appender-ref ref="pullInvDatadebug"/> - <appender-ref ref="pullInvDatametric"/> - </logger> - - <root level="INFO"> - <appender-ref ref="pullInvData"/> - <appender-ref ref="pullInvDatadebug"/> - <appender-ref ref="pullInvDatametric"/> - <appender-ref ref="STDOUT"/> - </root> -</configuration> diff --git a/aai-resources/src/main/resources/etc/appprops/schemaMod-logback.xml b/aai-resources/src/main/resources/etc/appprops/schemaMod-logback.xml deleted file mode 100644 index 5a0316f..0000000 --- a/aai-resources/src/main/resources/etc/appprops/schemaMod-logback.xml +++ /dev/null @@ -1,85 +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> - <property name="logDirectory" value="${AJSC_HOME}/logs" /> - - <appender name="schemaModlog" class="ch.qos.logback.classic.sift.SiftingAppender"> - <filter class="ch.qos.logback.classic.filter.LevelFilter"> - <level>INFO</level> - <onMatch>ACCEPT</onMatch> - <onMismatch>DENY</onMismatch> - </filter> - <!-- This is MDC value --> - <!-- We will assign a value to 'logFilenameAppender' via Java code --> - <discriminator> - <key>logFilenameAppender</key> - <defaultValue>undefined</defaultValue> - </discriminator> - <sift> - <!-- A standard RollingFileAppender, the log file is based on 'logFileName' - at runtime --> - <appender name="FILE-${logFilenameAppender}" - class="ch.qos.logback.core.rolling.RollingFileAppender"> - <file>${logDirectory}/schemaMod/${logFilenameAppender}.log</file> - <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy"> - <fileNamePattern>${logDirectory}/schemaMod/${logFilenameAppender}.log.%d{yyyy-MM-dd} - </fileNamePattern> - </rollingPolicy> - <encoder> - <pattern>%d{yyyy-MM-dd'T'HH:mm:ss.SSSXXX}|%m%n</pattern> - </encoder> - </appender> - </sift> - </appender> - - <logger name="org.reflections" level="WARN" additivity="false"> - <appender-ref ref="schemaModlog" /> - </logger> - <logger name="org.apache.zookeeper" level="ERROR" additivity="false"> - <appender-ref ref="schemaModlog" /> - </logger> - <logger name="org.apache.hadoop" level="ERROR" additivity="false"> - <appender-ref ref="schemaModlog" /> - </logger> - <logger name="org.janusgraph" level="WARN" additivity="false"> - <appender-ref ref="schemaModlog" /> - </logger> - <logger name="ch.qos.logback.classic" level="WARN" additivity="false"> - <appender-ref ref="schemaModlog" /> - </logger> - <logger name="ch.qos.logback.core" level="WARN" additivity="false"> - <appender-ref ref="schemaModlog" /> - </logger> - <logger name="com.att.eelf" level="WARN" additivity="false"> - <appender-ref ref="schemaModlog" /> - </logger> - <logger name="org.onap.aai" level="INFO" additivity="false"> - <appender-ref ref="schemaModlog" /> - </logger> - - - <root level="INFO"> - <appender-ref ref="schemaModlog" /> - </root> -</configuration> diff --git a/aai-resources/src/main/resources/etc/appprops/uniquePropertyCheck-logback.xml b/aai-resources/src/main/resources/etc/appprops/uniquePropertyCheck-logback.xml deleted file mode 100644 index 5b91003..0000000 --- a/aai-resources/src/main/resources/etc/appprops/uniquePropertyCheck-logback.xml +++ /dev/null @@ -1,85 +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> - <property name="logDirectory" value="${AJSC_HOME}/logs" /> - - <appender name="uniquePropertyChecklog" class="ch.qos.logback.classic.sift.SiftingAppender"> - <filter class="ch.qos.logback.classic.filter.LevelFilter"> - <level>INFO</level> - <onMatch>ACCEPT</onMatch> - <onMismatch>DENY</onMismatch> - </filter> - <!-- This is MDC value --> - <!-- We will assign a value to 'logFilenameAppender' via Java code --> - <discriminator> - <key>logFilenameAppender</key> - <defaultValue>undefined</defaultValue> - </discriminator> - <sift> - <!-- A standard RollingFileAppender, the log file is based on 'logFileName' - at runtime --> - <appender name="FILE-${logFilenameAppender}" - class="ch.qos.logback.core.rolling.RollingFileAppender"> - <file>${logDirectory}/uniquePropertyCheck/${logFilenameAppender}.log</file> - <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy"> - <fileNamePattern>${logDirectory}/uniquePropertyCheck/${logFilenameAppender}.log.%d{yyyy-MM-dd} - </fileNamePattern> - </rollingPolicy> - <encoder> - <pattern>%d{yyyy-MM-dd'T'HH:mm:ss.SSSXXX}|%m%n</pattern> - </encoder> - </appender> - </sift> - </appender> - - <logger name="org.reflections" level="WARN" additivity="false"> - <appender-ref ref="uniquePropertyChecklog" /> - </logger> - <logger name="org.apache.zookeeper" level="ERROR" additivity="false"> - <appender-ref ref="uniquePropertyChecklog" /> - </logger> - <logger name="org.apache.hadoop" level="ERROR" additivity="false"> - <appender-ref ref="uniquePropertyChecklog" /> - </logger> - <logger name="org.janusgraph" level="WARN" additivity="false"> - <appender-ref ref="uniquePropertyChecklog" /> - </logger> - <logger name="ch.qos.logback.classic" level="WARN" additivity="false"> - <appender-ref ref="uniquePropertyChecklog" /> - </logger> - <logger name="ch.qos.logback.core" level="WARN" additivity="false"> - <appender-ref ref="uniquePropertyChecklog" /> - </logger> - <logger name="com.att.eelf" level="WARN" additivity="false"> - <appender-ref ref="uniquePropertyChecklog" /> - </logger> - <logger name="org.onap.aai" level="INFO" additivity="false"> - <appender-ref ref="uniquePropertyChecklog" /> - </logger> - - - <root level="INFO"> - <appender-ref ref="uniquePropertyChecklog" /> - </root> -</configuration> diff --git a/aai-resources/src/main/resources/etc/scriptdata/tenant_isolation/nodes.json b/aai-resources/src/main/resources/etc/scriptdata/tenant_isolation/nodes.json deleted file mode 100644 index 5c28c8b..0000000 --- a/aai-resources/src/main/resources/etc/scriptdata/tenant_isolation/nodes.json +++ /dev/null @@ -1,14 +0,0 @@ -{ - "pserver" : { - "cousins" : ["zone", "complex", "availability-zone", "cloud-region"], - "parents":[] - }, - "complex" : { - "cousins":[], - "parents":[] - }, - "zone" : { - "cousins":["complex"], - "parents":[] - } -} diff --git a/aai-resources/src/main/resources/etc/scriptdata/tenant_isolation/nodesAZCloud.json b/aai-resources/src/main/resources/etc/scriptdata/tenant_isolation/nodesAZCloud.json deleted file mode 100644 index b955757..0000000 --- a/aai-resources/src/main/resources/etc/scriptdata/tenant_isolation/nodesAZCloud.json +++ /dev/null @@ -1,22 +0,0 @@ -{ - "cloud-region": { - "cousins" : [], - "parents":[] - }, - "availability-zone": { - "cousins" : [], - "parents":["cloud-region"] - }, - "pserver" : { - "cousins" : ["zone", "complex", "availability-zone"], - "parents":[] - }, - "complex" : { - "cousins":[], - "parents":[] - }, - "zone" : { - "cousins":["complex"], - "parents":[] - } -} diff --git a/aai-resources/src/main/resources/etc/scriptdata/tenant_isolation/nodesNoAZ.json b/aai-resources/src/main/resources/etc/scriptdata/tenant_isolation/nodesNoAZ.json deleted file mode 100644 index a0dfae5..0000000 --- a/aai-resources/src/main/resources/etc/scriptdata/tenant_isolation/nodesNoAZ.json +++ /dev/null @@ -1,14 +0,0 @@ -{ - "pserver" : { - "cousins" : ["zone", "complex"], - "parents":[] - }, - "complex" : { - "cousins":[], - "parents":[] - }, - "zone" : { - "cousins":["complex"], - "parents":[] - } -} diff --git a/aai-resources/src/main/resources/etc/tmp-config/hbase-site.xml b/aai-resources/src/main/resources/etc/tmp-config/hbase-site.xml deleted file mode 100644 index a2fcca6..0000000 --- a/aai-resources/src/main/resources/etc/tmp-config/hbase-site.xml +++ /dev/null @@ -1,52 +0,0 @@ -<?xml version="1.0"?> -<?xml-stylesheet type="text/xsl" href="configuration.xsl"?> -<!-- -/** - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ ---> - -<!-- -OVERVIEW - -The important configs. are listed near the top. You should change -at least the setting for hbase.tmp.dir. Other settings will change -dependent on whether you are running hbase in standalone mode or -distributed. See the hbase reference guide for requirements and -guidance making configuration. - -This file does not contain all possible configurations. The file would be -much larger if it carried everything. The absent configurations will only be -found through source code reading. The idea is that such configurations are -exotic and only those who would go to the trouble of reading a particular -section in the code would be knowledgeable or invested enough in ever wanting -to alter such configurations, so we do not list them here. Listing all -possible configurations would overwhelm and obscure the important. ---> - -<configuration> - <property> - <name>hbase.client.scanner.timeout.period</name> - <value>600000</value> - <description>Client scanner lease period in milliseconds.</description> - </property> - <property> - <name>hbase.rpc.timeout</name> - <value>6000000</value> - <description>hbase rpc timeout</description> - </property> -</configuration> diff --git a/aai-resources/src/main/resources/etc/tosca-migration-data/edgeLabelMigration.csv b/aai-resources/src/main/resources/etc/tosca-migration-data/edgeLabelMigration.csv deleted file mode 100644 index 53639e5..0000000 --- a/aai-resources/src/main/resources/etc/tosca-migration-data/edgeLabelMigration.csv +++ /dev/null @@ -1,212 +0,0 @@ -from,to,label,direction,multiplicity,contains-other-v,delete-other-v,SVC-INFRA,prevent-delete,new from,new to,new label,new direction,new multiplicity,new contains-other-v,new delete-other-v,new SVC-INFRA,new prevent-delete,new default -allotted-resource,allotted-resource,bindsTo,OUT,ONE2ONE,NONE,NONE,NONE,NONE,allotted-resource,allotted-resource,tosca.relationships.network.BindsTo,OUT,ONE2ONE,NONE,NONE,NONE,NONE,T -allotted-resource,generic-vnf,isPartOf,OUT,MANY2MANY,NONE,NONE,NONE,NONE,allotted-resource,generic-vnf,org.onap.relationships.inventory.PartOf,OUT,MANY2MANY,NONE,NONE,NONE,NONE,T -allotted-resource,instance-group,isMemberOf,OUT,MANY2MANY,NONE,NONE,NONE,NONE,allotted-resource,instance-group,org.onap.relationships.inventory.MemberOf,OUT,MANY2MANY,NONE,NONE,NONE,NONE,T -allotted-resource,l3-network,isPartOf,OUT,MANY2MANY,NONE,NONE,NONE,NONE,allotted-resource,l3-network,org.onap.relationships.inventory.PartOf,OUT,MANY2MANY,NONE,NONE,NONE,NONE,T -allotted-resource,l-interface,uses,OUT,ONE2MANY,NONE,NONE,NONE,NONE,allotted-resource,l-interface,org.onap.relationships.inventory.Uses,OUT,ONE2MANY,NONE,NONE,NONE,NONE,T -allotted-resource,network-policy,uses,OUT,ONE2ONE,NONE,NONE,NONE,NONE,allotted-resource,network-policy,org.onap.relationships.inventory.Uses,OUT,ONE2ONE,NONE,NONE,NONE,NONE,T -allotted-resource,vlan,isPartOf,OUT,MANY2MANY,NONE,NONE,NONE,NONE,allotted-resource,vlan,org.onap.relationships.inventory.PartOf,OUT,MANY2MANY,NONE,NONE,NONE,NONE,T -allotted-resource,vpn-binding,belongsTo,OUT,MANY2MANY,NONE,NONE,NONE,!${direction},allotted-resource,vpn-binding,org.onap.relationships.inventory.BelongsTo,OUT,MANY2MANY,NONE,NONE,NONE,!${direction},T -allotted-resource,tunnel-xconnect,has,OUT,ONE2ONE,${direction},${direction},NONE,NONE,tunnel-xconnect,allotted-resource,org.onap.relationships.inventory.BelongsTo,OUT,ONE2ONE,!${direction},!${direction},NONE,NONE,T -availability-zone,complex,groupsResourcesIn,OUT,MANY2MANY,NONE,NONE,NONE,!${direction},availability-zone,complex,org.onap.relationships.inventory.LocatedIn,OUT,MANY2ONE,NONE,NONE,NONE,!${direction},T -availability-zone,service-capability,supportsServiceCapability,OUT,MANY2MANY,NONE,NONE,NONE,!${direction},availability-zone,service-capability,org.onap.relationships.inventory.AppliesTo,OUT,MANY2MANY,NONE,NONE,NONE,!${direction},T -cloud-region,availability-zone,has,OUT,ONE2MANY,${direction},${direction},NONE,${direction},availability-zone,cloud-region,org.onap.relationships.inventory.BelongsTo,OUT,MANY2ONE,!${direction},!${direction},NONE,NONE,T -cloud-region,complex,locatedIn,OUT,MANY2ONE,NONE,NONE,NONE,!${direction},cloud-region,complex,org.onap.relationships.inventory.LocatedIn,OUT,MANY2ONE,NONE,NONE,NONE,!${direction},T -cloud-region,l3-network,uses,OUT,MANY2MANY,NONE,NONE,NONE,NONE,cloud-region,l3-network,org.onap.relationships.inventory.Uses,OUT,MANY2MANY,NONE,NONE,NONE,NONE,T -cloud-region,zone,isMemberOf,OUT,MANY2ONE,NONE,NONE,NONE,NONE,cloud-region,zone,org.onap.relationships.inventory.LocatedIn,OUT,MANY2ONE,NONE,NONE,NONE,NONE,T -cloud-region,dvs-switch,has,OUT,ONE2MANY,${direction},${direction},NONE,${direction},dvs-switch,cloud-region,org.onap.relationships.inventory.BelongsTo,OUT,MANY2ONE,!${direction},NONE,NONE,!${direction},T -cloud-region,flavor,has,OUT,ONE2MANY,${direction},${direction},NONE,${direction},flavor,cloud-region,org.onap.relationships.inventory.BelongsTo,OUT,MANY2ONE,!${direction},NONE,NONE,!${direction},T -cloud-region,group-assignment,has,OUT,ONE2MANY,${direction},${direction},NONE,${direction},group-assignment,cloud-region,org.onap.relationships.inventory.BelongsTo,OUT,MANY2ONE,!${direction},NONE,NONE,!${direction},T -cloud-region,image,has,OUT,ONE2MANY,${direction},${direction},NONE,${direction},image,cloud-region,org.onap.relationships.inventory.BelongsTo,OUT,MANY2ONE,!${direction},NONE,NONE,!${direction},T -cloud-region,oam-network,has,OUT,ONE2MANY,${direction},${direction},NONE,${direction},oam-network,cloud-region,org.onap.relationships.inventory.BelongsTo,OUT,MANY2ONE,!${direction},NONE,NONE,!${direction},T -cloud-region,snapshot,has,OUT,ONE2MANY,${direction},${direction},NONE,${direction},snapshot,cloud-region,org.onap.relationships.inventory.BelongsTo,OUT,MANY2ONE,!${direction},NONE,NONE,!${direction},T -cloud-region,tenant,has,OUT,ONE2MANY,${direction},${direction},!${direction},${direction},tenant,cloud-region,org.onap.relationships.inventory.BelongsTo,OUT,MANY2ONE,!${direction},NONE,${direction},!${direction},T -cloud-region,vip-ipv4-address-list,hasIpAddress,OUT,ONE2MANY,${direction},${direction},${direction},NONE,vip-ipv4-address-list,cloud-region,org.onap.relationships.inventory.BelongsTo,OUT,MANY2ONE,!${direction},NONE,NONE,!${direction},T -cloud-region,vip-ipv6-address-list,hasIpAddress,OUT,ONE2MANY,${direction},${direction},${direction},NONE,vip-ipv6-address-list,cloud-region,org.onap.relationships.inventory.BelongsTo,OUT,MANY2ONE,!${direction},NONE,NONE,!${direction},T -cloud-region,volume-group,has,OUT,ONE2MANY,${direction},${direction},NONE,${direction},volume-group,cloud-region,org.onap.relationships.inventory.BelongsTo,OUT,MANY2ONE,!${direction},NONE,NONE,!${direction},T -complex,l3-network,usesL3Network,OUT,MANY2MANY,NONE,NONE,${direction},NONE,complex,l3-network,org.onap.relationships.inventory.Uses,OUT,MANY2MANY,NONE,NONE,${direction},NONE,T -complex,ctag-pool,hasCtagPool,OUT,MANY2MANY,${direction},${direction},NONE,NONE,ctag-pool,complex,org.onap.relationships.inventory.BelongsTo,OUT,MANY2ONE,!${direction},!${direction},NONE,NONE,T -configuration,allotted-resource,uses,OUT,ONE2ONE,NONE,${direction},NONE,NONE,configuration,allotted-resource,org.onap.relationships.inventory.Uses,OUT,ONE2ONE,NONE,${direction},NONE,NONE,T -configuration,logical-link,has,OUT,ONE2MANY,NONE,${direction},NONE,NONE,configuration,logical-link,org.onap.relationships.inventory.Uses,OUT,ONE2MANY,NONE,${direction},NONE,NONE,T -configuration,metadatum,owns,OUT,ONE2MANY,${direction},${direction},NONE,NONE,metadatum,configuration,org.onap.relationships.inventory.BelongsTo,OUT,MANY2ONE,!${direction},!${direction},NONE,NONE,T -connector,virtual-data-center,contains,OUT,MANY2MANY,NONE,NONE,NONE,NONE,connector,virtual-data-center,org.onap.relationships.inventory.LocatedIn,OUT,MANY2MANY,NONE,NONE,NONE,NONE,T -connector,metadatum,hasMetaData,OUT,MANY2MANY,${direction},${direction},NONE,NONE,metadatum,connector,org.onap.relationships.inventory.BelongsTo,OUT,MANY2ONE,!${direction},!${direction},NONE,NONE,T -constrained-element-set,element-choice-set,uses,OUT,ONE2MANY,${direction},${direction},NONE,NONE,element-choice-set,constrained-element-set,org.onap.relationships.inventory.BelongsTo,OUT,MANY2ONE,!${direction},!${direction},NONE,NONE,T -ctag-pool,availability-zone,supportsAvailabilityZone,OUT,MANY2MANY,NONE,NONE,NONE,!${direction},ctag-pool,availability-zone,org.onap.relationships.inventory.AppliesTo,OUT,MANY2MANY,NONE,NONE,NONE,!${direction},T -customer,service-subscription,subscribesTo,OUT,MANY2MANY,${direction},${direction},!${direction},NONE,service-subscription,customer,org.onap.relationships.inventory.BelongsTo,OUT,MANY2ONE,!${direction},!${direction},${direction},NONE,T -dvs-switch,availability-zone,existsIn,OUT,MANY2MANY,NONE,NONE,NONE,!${direction},dvs-switch,availability-zone,org.onap.relationships.inventory.AppliesTo,OUT,MANY2MANY,NONE,NONE,NONE,!${direction},T -element-choice-set,model-element,has,OUT,ONE2MANY,${direction},${direction},NONE,NONE,model-element,element-choice-set,org.onap.relationships.inventory.BelongsTo,OUT,MANY2ONE,!${direction},!${direction},NONE,NONE,T -generic-vnf,entitlement,has,OUT,ONE2MANY,${direction},${direction},NONE,NONE,entitlement,generic-vnf,org.onap.relationships.inventory.BelongsTo,OUT,MANY2ONE,!${direction},!${direction},NONE,NONE,T -generic-vnf,availability-zone,hasAvailabilityZone,OUT,MANY2MANY,NONE,NONE,${direction},!${direction},generic-vnf,availability-zone,org.onap.relationships.inventory.Uses,OUT,MANY2MANY,NONE,NONE,${direction},!${direction},T -generic-vnf,complex,locatedIn,OUT,MANY2MANY,NONE,NONE,NONE,!${direction},generic-vnf,complex,org.onap.relationships.inventory.LocatedIn,OUT,MANY2MANY,NONE,NONE,NONE,!${direction},T -generic-vnf,configuration,uses,OUT,ONE2MANY,NONE,${direction},NONE,NONE,generic-vnf,configuration,org.onap.relationships.inventory.Uses,OUT,ONE2MANY,NONE,${direction},NONE,NONE,T -generic-vnf,ctag-pool,usesCtagPool,OUT,MANY2MANY,NONE,NONE,NONE,NONE,generic-vnf,ctag-pool,org.onap.relationships.inventory.Uses,OUT,MANY2MANY,NONE,NONE,NONE,NONE,T -generic-vnf,instance-group,isMemberOf,OUT,MANY2MANY,NONE,NONE,NONE,NONE,generic-vnf,instance-group,org.onap.relationships.inventory.MemberOf,OUT,MANY2MANY,NONE,NONE,NONE,NONE,T -generic-vnf,ipsec-configuration,uses,OUT,MANY2ONE,NONE,NONE,NONE,NONE,generic-vnf,ipsec-configuration,org.onap.relationships.inventory.Uses,OUT,MANY2ONE,NONE,NONE,NONE,NONE,T -generic-vnf,l3-network,usesL3Network,OUT,MANY2MANY,NONE,NONE,${direction},NONE,generic-vnf,l3-network,org.onap.relationships.inventory.Uses,OUT,MANY2MANY,NONE,NONE,${direction},NONE,T -generic-vnf,license-key-resource,uses,OUT,MANY2MANY,NONE,NONE,NONE,!${direction},generic-vnf,license-key-resource,org.onap.relationships.inventory.Uses,OUT,MANY2MANY,NONE,NONE,NONE,!${direction},T -generic-vnf,pnf,hostedOn,OUT,MANY2MANY,NONE,NONE,NONE,NONE,generic-vnf,pnf,tosca.relationships.HostedOn,OUT,MANY2MANY,NONE,NONE,NONE,NONE,T -generic-vnf,pserver,runsOnPserver,OUT,MANY2MANY,NONE,NONE,${direction},!${direction},generic-vnf,pserver,tosca.relationships.HostedOn,OUT,MANY2MANY,NONE,NONE,${direction},!${direction},T -generic-vnf,vnfc,uses,OUT,ONE2MANY,NONE,${direction},${direction},NONE,vnfc,generic-vnf,org.onap.relationships.inventory.BelongsTo,OUT,MANY2ONE,NONE,!${direction},!${direction},NONE,T -generic-vnf,vnf-image,usesVnfImage,OUT,MANY2ONE,NONE,NONE,${direction},!${direction},generic-vnf,vnf-image,org.onap.relationships.inventory.Uses,OUT,MANY2ONE,NONE,NONE,${direction},!${direction},T -generic-vnf,volume-group,uses,OUT,ONE2MANY,NONE,NONE,${direction},NONE,generic-vnf,volume-group,org.onap.relationships.inventory.DependsOn,OUT,ONE2MANY,NONE,NONE,${direction},NONE,T -generic-vnf,vserver,runsOnVserver,OUT,ONE2MANY,NONE,NONE,${direction},NONE,generic-vnf,vserver,tosca.relationships.HostedOn,OUT,ONE2MANY,NONE,NONE,${direction},NONE,T -generic-vnf,lag-interface,hasLAGInterface,OUT,MANY2MANY,${direction},${direction},${direction},NONE,lag-interface,generic-vnf,org.onap.relationships.inventory.BelongsTo,OUT,MANY2ONE,!${direction},!${direction},!${direction},NONE,T -generic-vnf,license,has,OUT,ONE2MANY,${direction},${direction},NONE,NONE,license,generic-vnf,org.onap.relationships.inventory.BelongsTo,OUT,MANY2ONE,!${direction},!${direction},NONE,NONE,T -generic-vnf,l-interface,hasLInterface,OUT,MANY2MANY,${direction},${direction},${direction},NONE,l-interface,generic-vnf,org.onap.relationships.inventory.BelongsTo,OUT,MANY2ONE,!${direction},!${direction},!${direction},NONE,T -generic-vnf,network-profile,hasNetworkProfile,OUT,MANY2MANY,NONE,NONE,NONE,NONE,network-profile,generic-vnf,org.onap.relationships.inventory.AppliesTo,OUT,MANY2MANY,NONE,NONE,NONE,NONE,T -generic-vnf,service-instance,hasInstance,OUT,MANY2MANY,NONE,NONE,${direction},NONE,service-instance,generic-vnf,org.onap.relationships.inventory.ComposedOf,OUT,ONE2MANY,NONE,NONE,!${direction},NONE,T -generic-vnf,site-pair-set,hasSitePairSet,OUT,MANY2MANY,NONE,NONE,NONE,NONE,site-pair-set,generic-vnf,org.onap.relationships.inventory.AppliesTo,OUT,MANY2MANY,NONE,NONE,NONE,NONE,T -generic-vnf,vf-module,has,OUT,ONE2MANY,${direction},${direction},${direction},NONE,vf-module,generic-vnf,org.onap.relationships.inventory.BelongsTo,OUT,MANY2ONE,!${direction},!${direction},!${direction},NONE,T -group-assignment,pserver,has,OUT,ONE2MANY,NONE,NONE,NONE,!${direction},pserver,group-assignment,org.onap.relationships.inventory.MemberOf,OUT,MANY2ONE,NONE,NONE,NONE,${direction},T -group-assignment,tenant,has,OUT,MANY2MANY,NONE,NONE,NONE,NONE,tenant,group-assignment,org.onap.relationships.inventory.MemberOf,OUT,MANY2MANY,NONE,NONE,NONE,NONE,T -image,metadatum,hasMetaDatum,OUT,MANY2MANY,${direction},${direction},NONE,NONE,metadatum,image,org.onap.relationships.inventory.BelongsTo,OUT,MANY2ONE,!${direction},!${direction},NONE,NONE,T -instance-group,model,targets,OUT,MANY2MANY,NONE,NONE,NONE,!${direction},instance-group,model,org.onap.relationships.inventory.Targets,OUT,MANY2MANY,NONE,NONE,NONE,!${direction},T -ipsec-configuration,vig-server,hasVigServer,OUT,ONE2MANY,${direction},${direction},NONE,NONE,vig-server,ipsec-configuration,org.onap.relationships.inventory.BelongsTo,OUT,MANY2ONE,!${direction},!${direction},NONE,NONE,T -l3-interface-ipv4-address-list,instance-group,isMemberOf,OUT,MANY2MANY,NONE,NONE,NONE,NONE,l3-interface-ipv4-address-list,instance-group,org.onap.relationships.inventory.network.MemberOf,OUT,MANY2MANY,NONE,NONE,NONE,NONE,T -l3-interface-ipv4-address-list,l3-network,isMemberOf,OUT,MANY2MANY,NONE,NONE,${direction},NONE,l3-interface-ipv4-address-list,l3-network,org.onap.relationships.inventory.network.MemberOf,OUT,MANY2MANY,NONE,NONE,${direction},NONE,T -l3-interface-ipv4-address-list,subnet,isMemberOf,OUT,MANY2MANY,NONE,NONE,${direction},!${direction},l3-interface-ipv4-address-list,subnet,org.onap.relationships.inventory.network.MemberOf,OUT,MANY2MANY,NONE,NONE,${direction},!${direction},T -l3-interface-ipv6-address-list,instance-group,isMemberOf,OUT,MANY2MANY,NONE,NONE,NONE,NONE,l3-interface-ipv6-address-list,instance-group,org.onap.relationships.inventory.network.MemberOf,OUT,MANY2MANY,NONE,NONE,NONE,NONE,T -l3-interface-ipv6-address-list,l3-network,isMemberOf,OUT,MANY2MANY,NONE,NONE,${direction},NONE,l3-interface-ipv6-address-list,l3-network,org.onap.relationships.inventory.network.MemberOf,OUT,MANY2MANY,NONE,NONE,${direction},NONE,T -l3-interface-ipv6-address-list,subnet,isMemberOf,OUT,MANY2MANY,NONE,NONE,${direction},!${direction},l3-interface-ipv6-address-list,subnet,org.onap.relationships.inventory.network.MemberOf,OUT,MANY2MANY,NONE,NONE,${direction},!${direction},T -l3-network,ctag-assignment,hasCtagAssignment,OUT,MANY2MANY,${direction},${direction},${direction},NONE,ctag-assignment,l3-network,org.onap.relationships.inventory.BelongsTo,OUT,MANY2ONE,!${direction},!${direction},!${direction},NONE,T -l3-network,instance-group,memberOf,OUT,MANY2MANY,NONE,NONE,NONE,NONE,l3-network,instance-group,org.onap.relationships.inventory.MemberOf,OUT,MANY2MANY,NONE,NONE,NONE,NONE,T -l3-network,network-policy,uses,OUT,MANY2MANY,NONE,NONE,${direction},NONE,l3-network,network-policy,org.onap.relationships.inventory.Uses,OUT,MANY2MANY,NONE,NONE,${direction},NONE,T -l3-network,route-table-reference,uses,OUT,MANY2MANY,NONE,NONE,NONE,NONE,l3-network,route-table-reference,org.onap.relationships.inventory.Uses,OUT,MANY2MANY,NONE,NONE,NONE,NONE,T -l3-network,vpn-binding,usesVpnBinding,OUT,MANY2MANY,NONE,NONE,NONE,!${direction},l3-network,vpn-binding,org.onap.relationships.inventory.Uses,OUT,MANY2MANY,NONE,NONE,NONE,!${direction},T -l3-network,segmentation-assignment,has,OUT,ONE2MANY,${direction},${direction},NONE,NONE,segmentation-assignment,l3-network,org.onap.relationships.inventory.BelongsTo,OUT,MANY2ONE,!${direction},!${direction},NONE,NONE,T -l3-network,service-instance,hasInstance,OUT,MANY2MANY,NONE,NONE,!${direction},NONE,service-instance,l3-network,org.onap.relationships.inventory.ComposedOf,OUT,ONE2MANY,NONE,NONE,${direction},NONE,T -l3-network,subnet,hasSubnet,OUT,MANY2MANY,${direction},${direction},!${direction},NONE,subnet,l3-network,org.onap.relationships.inventory.BelongsTo,OUT,MANY2ONE,!${direction},!${direction},${direction},NONE,T -lag-interface,lag-link,usesLAGLink,OUT,MANY2MANY,NONE,${direction},${direction},NONE,lag-interface,lag-link,tosca.relationships.network.LinksTo,OUT,MANY2MANY,NONE,${direction},${direction},NONE,T -lag-interface,logical-link,uses,OUT,MANY2MANY,NONE,${direction},${direction},NONE,lag-interface,logical-link,org.onap.relationships.inventory.Uses,OUT,MANY2MANY,NONE,${direction},${direction},NONE,T -lag-interface,p-interface,usesPInterface,OUT,MANY2MANY,NONE,NONE,${direction},NONE,lag-interface,p-interface,org.onap.relationships.inventory.Uses,OUT,MANY2MANY,NONE,NONE,${direction},NONE,T -lag-interface,l-interface,hasLInterface,OUT,MANY2MANY,${direction},${direction},${direction},NONE,l-interface,lag-interface,org.onap.relationships.inventory.BelongsTo,OUT,MANY2ONE,!${direction},!${direction},!${direction},NONE,T -line-of-business,generic-vnf,realizedBy,OUT,MANY2MANY,NONE,NONE,NONE,NONE,line-of-business,generic-vnf,org.onap.relationships.inventory.Uses,OUT,MANY2MANY,NONE,NONE,NONE,NONE,T -l-interface,l3-interface-ipv4-address-list,hasIpAddress,OUT,MANY2MANY,${direction},${direction},${direction},NONE,l3-interface-ipv4-address-list,l-interface,org.onap.relationships.inventory.BelongsTo,OUT,MANY2ONE,!${direction},!${direction},!${direction},NONE,T -l-interface,l3-interface-ipv6-address-list,hasIpAddress,OUT,MANY2MANY,${direction},${direction},${direction},NONE,l3-interface-ipv6-address-list,l-interface,org.onap.relationships.inventory.BelongsTo,OUT,MANY2ONE,!${direction},!${direction},!${direction},NONE,T -l-interface,instance-group,isMemberOf,OUT,MANY2MANY,NONE,NONE,NONE,NONE,l-interface,instance-group,org.onap.relationships.inventory.MemberOf,OUT,MANY2MANY,NONE,NONE,NONE,NONE,T -l-interface,l-interface,has,OUT,ONE2MANY,${direction},${direction},${direction},NONE,l-interface,l-interface,org.onap.relationships.inventory.BelongsTo,OUT,MANY2ONE,!${direction},!${direction},!${direction},NONE,T -l-interface,logical-link,usesLogicalLink,OUT,MANY2MANY,NONE,${direction},${direction},NONE,l-interface,logical-link,tosca.relationships.network.LinksTo,OUT,MANY2ONE,NONE,${direction},${direction},NONE,T -l-interface,logical-link,sourceLInterface,OUT,MANY2MANY,NONE,${direction},${direction},NONE,logical-link,l-interface,org.onap.relationships.inventory.Source,OUT,ONE2MANY,NONE,!${direction},!${direction},NONE,F -l-interface,logical-link,targetLInterface,OUT,MANY2MANY,NONE,${direction},${direction},NONE,logical-link,l-interface,org.onap.relationships.inventory.Destination,OUT,ONE2MANY,NONE,!${direction},!${direction},NONE,F -l-interface,sriov-vf,has,OUT,ONE2ONE,${direction},${direction},NONE,NONE,sriov-vf,l-interface,org.onap.relationships.inventory.BelongsTo,OUT,ONE2ONE,!${direction},!${direction},NONE,NONE,T -l-interface,vlan,hasVlan,OUT,MANY2MANY,${direction},${direction},NONE,NONE,vlan,l-interface,tosca.relationships.network.LinksTo,OUT,MANY2ONE,!${direction},!${direction},NONE,NONE,T -logical-link,cloud-region,existsIn,OUT,MANY2MANY,NONE,NONE,NONE,NONE,logical-link,cloud-region,org.onap.relationships.inventory.LocatedIn,OUT,MANY2MANY,NONE,NONE,NONE,NONE,T -logical-link,generic-vnf,bridgedTo,OUT,MANY2MANY,NONE,NONE,NONE,NONE,logical-link,generic-vnf,org.onap.relationships.inventory.BridgedTo,OUT,MANY2MANY,NONE,NONE,NONE,NONE,T -logical-link,lag-link,usesLAGLink,OUT,MANY2MANY,NONE,NONE,${direction},NONE,logical-link,lag-link,org.onap.relationships.inventory.Uses,OUT,MANY2MANY,NONE,NONE,${direction},NONE,T -logical-link,logical-link,uses,OUT,ONE2MANY,NONE,NONE,${direction},NONE,logical-link,logical-link,org.onap.relationships.inventory.Uses,OUT,ONE2MANY,NONE,NONE,${direction},NONE,T -logical-link,pnf,bridgedTo,OUT,MANY2MANY,NONE,NONE,NONE,NONE,logical-link,pnf,org.onap.relationships.inventory.BridgedTo,OUT,MANY2MANY,NONE,NONE,NONE,NONE,T -logical-link,pserver,bridgedTo,OUT,MANY2MANY,NONE,NONE,NONE,!${direction},logical-link,pserver,org.onap.relationships.inventory.BridgedTo,OUT,MANY2MANY,NONE,NONE,NONE,!${direction},T -logical-link,vpn-binding,uses,OUT,MANY2MANY,NONE,NONE,NONE,!${direction},logical-link,vpn-binding,org.onap.relationships.inventory.Uses,OUT,MANY2MANY,NONE,NONE,NONE,!${direction},T -model,model-ver,has,OUT,ONE2MANY,${direction},${direction},NONE,NONE,model-ver,model,org.onap.relationships.inventory.BelongsTo,OUT,MANY2ONE,!${direction},!${direction},NONE,NONE,T -model-constraint,constrained-element-set,uses,OUT,ONE2MANY,${direction},${direction},NONE,NONE,constrained-element-set,model-constraint,org.onap.relationships.inventory.BelongsTo,OUT,MANY2ONE,!${direction},!${direction},NONE,NONE,T -model-element,constrained-element-set,connectsTo,OUT,ONE2MANY,${direction},${direction},NONE,NONE,constrained-element-set,model-element,org.onap.relationships.inventory.BelongsTo,OUT,MANY2ONE,!${direction},!${direction},NONE,NONE,T -model-element,model-constraint,uses,OUT,ONE2MANY,${direction},${direction},NONE,NONE,model-constraint,model-element,org.onap.relationships.inventory.BelongsTo,OUT,MANY2ONE,!${direction},!${direction},NONE,NONE,T -model-element,model-element,connectsTo,OUT,ONE2MANY,${direction},${direction},NONE,NONE,model-element,model-element,org.onap.relationships.inventory.BelongsTo,OUT,MANY2ONE,!${direction},!${direction},NONE,NONE,T -model-element,model-ver,isA,OUT,MANY2ONE,NONE,NONE,NONE,!${direction},model-element,model-ver,org.onap.relationships.inventory.IsA,OUT,MANY2ONE,NONE,NONE,NONE,!${direction},T -model-ver,metadatum,hasMetaDatum,OUT,ONE2MANY,${direction},${direction},NONE,NONE,metadatum,model-ver,org.onap.relationships.inventory.BelongsTo,OUT,MANY2ONE,!${direction},!${direction},NONE,NONE,T -model-ver,model-element,startsWith,OUT,ONE2MANY,${direction},${direction},NONE,NONE,model-element,model-ver,org.onap.relationships.inventory.BelongsTo,OUT,MANY2ONE,!${direction},!${direction},NONE,NONE,T -named-query,model,relatedTo,OUT,ONE2MANY,NONE,NONE,NONE,!${direction},named-query,model,org.onap.relationships.inventory.AppliesTo,OUT,ONE2MANY,NONE,NONE,NONE,!${direction},T -named-query,named-query-element,startsWith,OUT,ONE2ONE,${direction},${direction},NONE,NONE,named-query-element,named-query,org.onap.relationships.inventory.BelongsTo,OUT,ONE2ONE,!${direction},!${direction},NONE,NONE,T -named-query-element,model,isA,OUT,MANY2ONE,NONE,NONE,NONE,!${direction},named-query-element,model,org.onap.relationships.inventory.IsA,OUT,MANY2ONE,NONE,NONE,NONE,!${direction},T -named-query-element,named-query-element,connectsTo,OUT,MANY2MANY,${direction},${direction},NONE,NONE,named-query-element,named-query-element,org.onap.relationships.inventory.BelongsTo,OUT,MANY2ONE,!${direction},!${direction},NONE,NONE,T -named-query-element,property-constraint,uses,OUT,ONE2MANY,${direction},${direction},NONE,NONE,property-constraint,named-query-element,org.onap.relationships.inventory.BelongsTo,OUT,MANY2ONE,!${direction},!${direction},NONE,NONE,T -named-query-element,related-lookup,uses,OUT,ONE2MANY,${direction},${direction},NONE,NONE,related-lookup,named-query-element,org.onap.relationships.inventory.BelongsTo,OUT,MANY2ONE,!${direction},!${direction},NONE,NONE,T -newvce,l-interface,hasLInterface,OUT,MANY2MANY,${direction},${direction},NONE,NONE,l-interface,newvce,org.onap.relationships.inventory.BelongsTo,OUT,MANY2ONE,!${direction},!${direction},NONE,NONE,T -oam-network,complex,definedFor,OUT,MANY2MANY,NONE,NONE,NONE,!${direction},oam-network,complex,org.onap.relationships.inventory.AppliesTo,OUT,MANY2MANY,NONE,NONE,NONE,!${direction},T -oam-network,service-capability,supportsServiceCapability,OUT,MANY2MANY,NONE,NONE,NONE,!${direction},oam-network,service-capability,org.onap.relationships.inventory.AppliesTo,OUT,MANY2MANY,NONE,NONE,NONE,!${direction},T -operational-environment,operational-environment,managedBy,OUT,ONE2ONE,NONE,NONE,NONE,NONE,operational-environment,operational-environment,org.onap.relationships.inventory.Uses,OUT,ONE2ONE,NONE,NONE,NONE,NONE,T -owning-entity,service-instance,owns,OUT,ONE2MANY,NONE,NONE,NONE,NONE,service-instance,owning-entity,org.onap.relationships.inventory.BelongsTo,OUT,MANY2ONE,NONE,NONE,NONE,NONE,T -p-interface,l-interface,hasLInterface,OUT,MANY2MANY,${direction},${direction},${direction},NONE,l-interface,p-interface,tosca.relationships.network.BindsTo,OUT,MANY2ONE,!${direction},!${direction},!${direction},NONE,T -p-interface,logical-link,usesLogicalLink,OUT,MANY2ONE,NONE,NONE,${direction},NONE,p-interface,logical-link,tosca.relationships.network.LinksTo,OUT,MANY2ONE,NONE,NONE,${direction},NONE,T -p-interface,physical-link,usesPhysicalLink,OUT,MANY2MANY,NONE,${direction},NONE,NONE,p-interface,physical-link,tosca.relationships.network.LinksTo,OUT,MANY2ONE,NONE,${direction},NONE,NONE,T -p-interface,sriov-pf,has,OUT,ONE2ONE,${direction},${direction},NONE,NONE,sriov-pf,p-interface,org.onap.relationships.inventory.BelongsTo,OUT,ONE2ONE,!${direction},!${direction},NONE,NONE,T -platform,generic-vnf,uses,OUT,MANY2MANY,NONE,NONE,NONE,NONE,platform,generic-vnf,org.onap.relationships.inventory.Uses,OUT,MANY2MANY,NONE,NONE,NONE,NONE,T -pnf,lag-interface,has,OUT,ONE2MANY,${direction},${direction},${direction},NONE,lag-interface,pnf,tosca.relationships.network.BindsTo,OUT,MANY2ONE,!${direction},!${direction},!${direction},NONE,T -pnf,p-interface,hasPinterface,OUT,MANY2MANY,${direction},${direction},${direction},NONE,p-interface,pnf,tosca.relationships.network.BindsTo,OUT,MANY2ONE,!${direction},!${direction},!${direction},NONE,T -pnf,complex,locatedIn,OUT,MANY2ONE,NONE,NONE,NONE,!${direction},pnf,complex,org.onap.relationships.inventory.LocatedIn,OUT,MANY2ONE,NONE,NONE,NONE,!${direction},T -pnf,instance-group,isMemberOf,OUT,MANY2MANY,NONE,NONE,NONE,NONE,pnf,instance-group,org.onap.relationships.inventory.MemberOf,OUT,MANY2MANY,NONE,NONE,NONE,NONE,T -pnf,zone,isMemberOf,OUT,MANY2ONE,NONE,NONE,NONE,NONE,pnf,zone,org.onap.relationships.inventory.LocatedIn,OUT,MANY2ONE,NONE,NONE,NONE,NONE,T -port-group,cvlan-tag,hasCTag,OUT,MANY2MANY,${direction},${direction},${direction},NONE,cvlan-tag,port-group,org.onap.relationships.inventory.BelongsTo,OUT,MANY2ONE,!${direction},!${direction},!${direction},NONE,T -project,service-instance,created,OUT,ONE2MANY,NONE,NONE,NONE,NONE,project,service-instance,org.onap.relationships.inventory.Uses,OUT,ONE2MANY,NONE,NONE,NONE,NONE,T -pserver,lag-interface,hasLAGInterface,OUT,MANY2MANY,${direction},${direction},${direction},NONE,lag-interface,pserver,tosca.relationships.network.BindsTo,OUT,MANY2ONE,!${direction},!${direction},!${direction},NONE,T -pserver,p-interface,hasPinterface,OUT,MANY2MANY,${direction},${direction},${direction},NONE,p-interface,pserver,tosca.relationships.network.BindsTo,OUT,MANY2ONE,!${direction},!${direction},!${direction},NONE,T -pserver,availability-zone,existsIn,OUT,MANY2ONE,NONE,NONE,${direction},!${direction},pserver,availability-zone,org.onap.relationships.inventory.MemberOf,OUT,MANY2ONE,NONE,NONE,${direction},!${direction},T -pserver,cloud-region,locatedIn,OUT,MANY2ONE,NONE,NONE,${direction},NONE,pserver,cloud-region,org.onap.relationships.inventory.LocatedIn,OUT,MANY2ONE,NONE,NONE,${direction},NONE,T -pserver,complex,locatedIn,OUT,MANY2ONE,NONE,NONE,${direction},!${direction},pserver,complex,org.onap.relationships.inventory.LocatedIn,OUT,MANY2ONE,NONE,NONE,${direction},!${direction},T -pserver,zone,isMemberOf,OUT,MANY2ONE,NONE,NONE,NONE,NONE,pserver,zone,org.onap.relationships.inventory.LocatedIn,OUT,MANY2ONE,NONE,NONE,NONE,NONE,T -routing-instance,site-pair,hasSitePair,OUT,MANY2MANY,${direction},${direction},NONE,NONE,site-pair,routing-instance,org.onap.relationships.inventory.BelongsTo,OUT,MANY2ONE,!${direction},!${direction},NONE,NONE,T -service-instance,allotted-resource,has,OUT,MANY2MANY,${direction},${direction},NONE,NONE,allotted-resource,service-instance,org.onap.relationships.inventory.BelongsTo,OUT,MANY2ONE,!${direction},!${direction},NONE,NONE,T -service-instance,metadatum,hasMetaData,OUT,MANY2MANY,${direction},${direction},NONE,NONE,metadatum,service-instance,org.onap.relationships.inventory.BelongsTo,OUT,MANY2ONE,!${direction},!${direction},NONE,NONE,T -service-instance,allotted-resource,uses,OUT,MANY2MANY,NONE,NONE,NONE,NONE,service-instance,allotted-resource,org.onap.relationships.inventory.Uses,OUT,MANY2MANY,NONE,NONE,NONE,NONE,T -service-instance,configuration,has,OUT,ONE2MANY,NONE,NONE,NONE,NONE,service-instance,configuration,org.onap.relationships.inventory.Uses,OUT,ONE2MANY,NONE,NONE,NONE,NONE,T -service-instance,connector,uses,OUT,MANY2MANY,NONE,NONE,NONE,NONE,service-instance,connector,org.onap.relationships.inventory.Uses,OUT,MANY2MANY,NONE,NONE,NONE,NONE,T -service-instance,ctag-assignment,uses,OUT,ONE2MANY,NONE,NONE,NONE,NONE,service-instance,ctag-assignment,org.onap.relationships.inventory.Uses,OUT,ONE2MANY,NONE,NONE,NONE,NONE,T -service-instance,cvlan-tag,hasIPAGFacingVLAN,OUT,MANY2MANY,NONE,NONE,NONE,NONE,service-instance,cvlan-tag,org.onap.relationships.inventory.ComposedOf,OUT,MANY2MANY,NONE,NONE,NONE,NONE,T -service-instance,instance-group,isMemberOf,OUT,MANY2MANY,NONE,NONE,NONE,NONE,service-instance,instance-group,org.onap.relationships.inventory.MemberOf,OUT,MANY2MANY,NONE,NONE,NONE,NONE,T -service-instance,logical-link,uses,OUT,MANY2MANY,NONE,${direction},NONE,NONE,service-instance,logical-link,org.onap.relationships.inventory.Uses,OUT,ONE2MANY,NONE,${direction},NONE,NONE,T -service-instance,pnf,uses,OUT,ONE2MANY,NONE,NONE,NONE,NONE,service-instance,pnf,org.onap.relationships.inventory.ComposedOf,OUT,ONE2MANY,NONE,NONE,NONE,NONE,T -service-instance,service-instance,dependsOn,OUT,ONE2MANY,NONE,NONE,NONE,NONE,service-instance,service-instance,org.onap.relationships.inventory.ComposedOf,OUT,ONE2MANY,NONE,NONE,NONE,NONE,T -service-instance,vlan,dependsOn,OUT,ONE2MANY,NONE,NONE,NONE,NONE,service-instance,vlan,org.onap.relationships.inventory.ComposedOf,OUT,ONE2MANY,NONE,NONE,NONE,NONE,T -service-instance,zone,locatedIn,OUT,MANY2ONE,NONE,NONE,${direction},NONE,service-instance,zone,org.onap.relationships.inventory.LocatedIn,OUT,MANY2ONE,NONE,NONE,${direction},NONE,T -service-subscription,service-instance,hasInstance,OUT,MANY2MANY,${direction},${direction},!${direction},NONE,service-instance,service-subscription,org.onap.relationships.inventory.BelongsTo,OUT,MANY2ONE,!${direction},!${direction},${direction},NONE,T -site-pair,class-of-service,hasClassOfService,OUT,MANY2MANY,${direction},${direction},NONE,NONE,class-of-service,site-pair,org.onap.relationships.inventory.BelongsTo,OUT,MANY2ONE,!${direction},!${direction},NONE,NONE,T -site-pair-set,routing-instance,hasRoutingInstance,OUT,MANY2MANY,${direction},${direction},NONE,NONE,routing-instance,site-pair-set,org.onap.relationships.inventory.BelongsTo,OUT,MANY2ONE,!${direction},!${direction},NONE,NONE,T -sriov-vf,sriov-pf,uses,OUT,MANY2ONE,NONE,NONE,NONE,NONE,sriov-vf,sriov-pf,org.onap.relationships.inventory.Uses,OUT,MANY2ONE,NONE,NONE,NONE,NONE,T -subnet,host-route,has,OUT,ONE2MANY,${direction},${direction},NONE,NONE,host-route,subnet,org.onap.relationships.inventory.BelongsTo,OUT,MANY2ONE,!${direction},!${direction},NONE,NONE,T -tenant,service-subscription,relatedTo,OUT,MANY2MANY,NONE,NONE,NONE,NONE,service-subscription,tenant,org.onap.relationships.inventory.Uses,OUT,MANY2MANY,NONE,NONE,NONE,NONE,T -tenant,l3-network,usesL3Network,OUT,MANY2MANY,NONE,NONE,NONE,NONE,tenant,l3-network,org.onap.relationships.inventory.Uses,OUT,MANY2MANY,NONE,NONE,NONE,NONE,T -tenant,vserver,owns,OUT,ONE2MANY,${direction},${direction},!${direction},${direction},vserver,tenant,org.onap.relationships.inventory.BelongsTo,OUT,MANY2ONE,!${direction},NONE,${direction},!${direction},T -vce,entitlement,has,OUT,ONE2MANY,${direction},${direction},NONE,NONE,entitlement,vce,org.onap.relationships.inventory.BelongsTo,OUT,MANY2ONE,!${direction},!${direction},NONE,NONE,T -vce,license,has,OUT,ONE2MANY,${direction},${direction},NONE,NONE,license,vce,org.onap.relationships.inventory.BelongsTo,OUT,MANY2ONE,!${direction},!${direction},NONE,NONE,T -vce,port-group,hasPortGroup,OUT,MANY2MANY,${direction},${direction},${direction},NONE,port-group,vce,org.onap.relationships.inventory.BelongsTo,OUT,MANY2ONE,!${direction},!${direction},!${direction},NONE,T -vce,service-instance,hasServiceInstance,OUT,MANY2MANY,NONE,NONE,!${direction},NONE,service-instance,vce,org.onap.relationships.inventory.ComposedOf,OUT,ONE2MANY,NONE,NONE,${direction},NONE,T -vce,availability-zone,hasAvailabilityZone,OUT,MANY2MANY,NONE,NONE,NONE,!${direction},vce,availability-zone,org.onap.relationships.inventory.Uses,OUT,MANY2MANY,NONE,NONE,NONE,!${direction},T -vce,complex,locatedIn,OUT,MANY2MANY,NONE,NONE,${direction},!${direction},vce,complex,org.onap.relationships.inventory.LocatedIn,OUT,MANY2MANY,NONE,NONE,${direction},!${direction},T -vce,vserver,runsOnVserver,OUT,MANY2MANY,NONE,NONE,${direction},NONE,vce,vserver,tosca.relationships.HostedOn,OUT,ONE2MANY,NONE,NONE,${direction},NONE,T -vf-module,l3-network,uses,OUT,MANY2MANY,NONE,NONE,${direction},NONE,vf-module,l3-network,org.onap.relationships.inventory.DependsOn,OUT,MANY2MANY,NONE,NONE,${direction},NONE,T -vf-module,vnfc,uses,OUT,ONE2MANY,NONE,${direction},${direction},${direction},vf-module,vnfc,org.onap.relationships.inventory.Uses,OUT,ONE2MANY,NONE,NONE,${direction},${direction},T -vf-module,volume-group,uses,OUT,ONE2ONE,NONE,NONE,${direction},NONE,vf-module,volume-group,org.onap.relationships.inventory.Uses,OUT,ONE2ONE,NONE,NONE,${direction},NONE,T -vip-ipv4-address-list,instance-group,isMemberOf,OUT,MANY2MANY,NONE,NONE,NONE,NONE,vip-ipv4-address-list,instance-group,org.onap.relationships.inventory.MemberOf,OUT,MANY2MANY,NONE,NONE,NONE,NONE,T -vip-ipv4-address-list,subnet,isMemberOf,OUT,MANY2MANY,NONE,NONE,${direction},!${direction},vip-ipv4-address-list,subnet,org.onap.relationships.inventory.MemberOf,OUT,MANY2MANY,NONE,NONE,NONE,!${direction},T -vip-ipv6-address-list,instance-group,isMemberOf,OUT,MANY2MANY,NONE,NONE,NONE,NONE,vip-ipv6-address-list,instance-group,org.onap.relationships.inventory.MemberOf,OUT,MANY2MANY,NONE,NONE,NONE,NONE,T -vip-ipv6-address-list,subnet,isMemberOf,OUT,MANY2MANY,NONE,NONE,${direction},!${direction},vip-ipv6-address-list,subnet,org.onap.relationships.inventory.MemberOf,OUT,MANY2MANY,NONE,NONE,NONE,!${direction},T -virtual-data-center,generic-vnf,hasVNF,OUT,MANY2MANY,NONE,NONE,!${direction},NONE,generic-vnf,virtual-data-center,org.onap.relationships.inventory.LocatedIn,OUT,MANY2MANY,NONE,NONE,${direction},NONE,T -virtual-data-center,logical-link,contains,OUT,MANY2MANY,NONE,NONE,NONE,NONE,logical-link,virtual-data-center,org.onap.relationships.inventory.LocatedIn,OUT,MANY2MANY,NONE,NONE,NONE,NONE,T -vlan,l3-interface-ipv4-address-list,hasIpAddress,OUT,MANY2MANY,${direction},${direction},${direction},NONE,l3-interface-ipv4-address-list,vlan,org.onap.relationships.inventory.BelongsTo,OUT,MANY2ONE,!${direction},!${direction},!${direction},NONE,T -vlan,l3-interface-ipv6-address-list,hasIpAddress,OUT,MANY2MANY,${direction},${direction},${direction},NONE,l3-interface-ipv6-address-list,vlan,org.onap.relationships.inventory.BelongsTo,OUT,MANY2ONE,!${direction},!${direction},!${direction},NONE,T -vlan,logical-link,usesLogicalLink,OUT,MANY2MANY,NONE,${direction},${direction},NONE,vlan,logical-link,org.onap.relationships.inventory.Uses,OUT,MANY2MANY,NONE,${direction},${direction},NONE,T -vlan,multicast-configuration,uses,OUT,MANY2MANY,NONE,NONE,NONE,NONE,vlan,multicast-configuration,org.onap.relationships.inventory.Uses,OUT,MANY2MANY,NONE,NONE,NONE,NONE,T -vnfc,l3-interface-ipv4-address-list,hasIpAddress,OUT,ONE2MANY,${direction},${direction},NONE,NONE,l3-interface-ipv4-address-list,vnfc,org.onap.relationships.inventory.BelongsTo,OUT,MANY2ONE,!${direction},!${direction},NONE,NONE,T -vnfc,l3-interface-ipv6-address-list,hasIpAddress,OUT,ONE2MANY,${direction},${direction},NONE,NONE,l3-interface-ipv6-address-list,vnfc,org.onap.relationships.inventory.BelongsTo,OUT,MANY2ONE,!${direction},!${direction},NONE,NONE,T -vnfc,instance-group,isMemberOf,OUT,MANY2MANY,NONE,NONE,NONE,NONE,vnfc,instance-group,org.onap.relationships.inventory.MemberOf,OUT,MANY2MANY,NONE,NONE,NONE,NONE,T -vnfc,vip-ipv4-address-list,uses,OUT,MANY2MANY,NONE,NONE,NONE,NONE,vnfc,vip-ipv4-address-list,org.onap.relationships.inventory.Uses,OUT,MANY2MANY,NONE,NONE,NONE,NONE,T -vnfc,vip-ipv6-address-list,uses,OUT,MANY2MANY,NONE,NONE,NONE,NONE,vnfc,vip-ipv6-address-list,org.onap.relationships.inventory.Uses,OUT,MANY2MANY,NONE,NONE,NONE,NONE,T -volume-group,tenant,belongsTo,OUT,MANY2MANY,NONE,NONE,${direction},NONE,tenant,volume-group,org.onap.relationships.inventory.DependsOn,OUT,ONE2MANY,NONE,NONE,!${direction},NONE,T -volume-group,complex,existsIn,OUT,MANY2MANY,NONE,NONE,${direction},!${direction},volume-group,complex,org.onap.relationships.inventory.LocatedIn,OUT,MANY2ONE,NONE,NONE,${direction},!${direction},T -vpls-pe,lag-interface,hasLAGinterface,OUT,MANY2MANY,${direction},${direction},NONE,NONE,lag-interface,vpls-pe,tosca.relationships.network.BindsTo,OUT,MANY2ONE,!${direction},!${direction},NONE,NONE,T -vpls-pe,p-interface,hasPinterface,OUT,MANY2MANY,${direction},${direction},NONE,NONE,p-interface,vpls-pe,tosca.relationships.network.BindsTo,OUT,MANY2ONE,!${direction},!${direction},NONE,NONE,T -vpls-pe,complex,locatedIn,OUT,MANY2MANY,NONE,NONE,NONE,!${direction},vpls-pe,complex,org.onap.relationships.inventory.LocatedIn,OUT,MANY2ONE,NONE,NONE,NONE,!${direction},T -vpls-pe,ctag-pool,usesCtagPool,OUT,MANY2MANY,NONE,NONE,NONE,NONE,vpls-pe,ctag-pool,org.onap.relationships.inventory.Uses,OUT,MANY2MANY,NONE,NONE,NONE,NONE,T -vpn-binding,route-target,has,OUT,ONE2MANY,${direction},${direction},NONE,NONE,route-target,vpn-binding,org.onap.relationships.inventory.BelongsTo,OUT,MANY2ONE,!${direction},!${direction},NONE,NONE,T -vserver,l-interface,hasLInterface,OUT,MANY2MANY,${direction},${direction},${direction},NONE,l-interface,vserver,tosca.relationships.network.BindsTo,OUT,MANY2ONE,!${direction},!${direction},!${direction},NONE,T -vserver,vf-module,isPartOf,OUT,MANY2ONE,NONE,NONE,${direction},NONE,vf-module,vserver,org.onap.relationships.inventory.Uses,OUT,ONE2MANY,NONE,NONE,!${direction},NONE,T -vserver,vnfc,hosts,OUT,MANY2MANY,NONE,NONE,${direction},NONE,vnfc,vserver,tosca.relationships.HostedOn,OUT,ONE2MANY,NONE,NONE,!${direction},NONE,T -vserver,flavor,hasFlavor,OUT,MANY2ONE,NONE,NONE,${direction},!${direction},vserver,flavor,org.onap.relationships.inventory.Uses,OUT,MANY2ONE,NONE,NONE,${direction},!${direction},T -vserver,image,hasImage,OUT,MANY2ONE,NONE,NONE,${direction},!${direction},vserver,image,org.onap.relationships.inventory.Uses,OUT,MANY2ONE,NONE,NONE,${direction},!${direction},T -vserver,pserver,runsOnPserver,OUT,MANY2ONE,NONE,NONE,${direction},!${direction},vserver,pserver,tosca.relationships.HostedOn,OUT,MANY2ONE,NONE,NONE,${direction},!${direction},T -vserver,snapshot,uses,OUT,ONE2ONE,NONE,NONE,${direction},NONE,vserver,snapshot,org.onap.relationships.inventory.Uses,OUT,ONE2ONE,NONE,NONE,${direction},NONE,T -vserver,volume,hasVolume,OUT,MANY2MANY,${direction},${direction},${direction},NONE,vserver,volume,tosca.relationships.AttachesTo,OUT,ONE2MANY,${direction},${direction},${direction},NONE,T -zone,complex,existsIn,OUT,MANY2ONE,NONE,NONE,NONE,!${direction},zone,complex,org.onap.relationships.inventory.LocatedIn,OUT,MANY2ONE,NONE,NONE,NONE,!${direction},T -,,,,,,,,,allotted-resource,model-ver,org.onap.relationships.inventory.IsA,OUT,Many2One,NONE,NONE,NONE,NONE,T -,,,,,,,,,generic-vnf,model-ver,org.onap.relationships.inventory.IsA,OUT,Many2One,NONE,NONE,NONE,NONE,T -,,,,,,,,,l3-network,model-ver,org.onap.relationships.inventory.IsA,OUT,Many2One,NONE,NONE,NONE,NONE,T -,,,,,,,,,logical-link,model-ver,org.onap.relationships.inventory.IsA,OUT,Many2One,NONE,NONE,NONE,NONE,T -,,,,,,,,,service-instance,model-ver,org.onap.relationships.inventory.IsA,OUT,Many2One,NONE,NONE,NONE,NONE,T -,,,,,,,,,vf-module,model-ver,org.onap.relationships.inventory.IsA,OUT,Many2One,NONE,NONE,NONE,NONE,T -configuration,l-interface,has,OUT,ONE2MANY,NONE,NONE,NONE,NONE,configuration,l-interface,org.onap.relationships.inventory.AppliesTo,OUT,ONE2MANY,NONE,NONE,NONE,NONE,T -configuration,pnf,has,OUT,ONE2MANY,NONE,NONE,NONE,NONE,configuration,pnf,org.onap.relationships.inventory.AppliesTo,OUT,ONE2MANY,NONE,NONE,NONE,NONE,T -forwarder,forwarding-path,belongsTo,OUT,MANY2ONE,!${direction},!${direction},NONE,NONE,forwarder,forwarding-path,org.onap.relationships.inventory.BelongsTo,OUT,MANY2ONE,!${direction},!${direction},NONE,NONE,T -forwarding-path,service-instance,implements,OUT,MANY2ONE,NONE,!${direction},NONE,NONE,forwarding-path,service-instance,org.onap.relationships.inventory.AppliesTo,OUT,MANY2ONE,NONE,!${direction},NONE,NONE,T -forwarder,l-interface,forwardsTo,OUT,ONE2ONE,NONE,NONE,NONE,NONE,forwarder,l-interface,org.onap.relationships.inventory.ForwardsTo,OUT,ONE2ONE,NONE,NONE,NONE,NONE,T -forwarder,p-interface,forwardsTo,OUT,ONE2ONE,NONE,NONE,NONE,NONE,forwarder,p-interface,org.onap.relationships.inventory.ForwardsTo,OUT,ONE2ONE,NONE,NONE,NONE,NONE,T diff --git a/aai-resources/src/main/resources/logback.xml b/aai-resources/src/main/resources/logback.xml index e727228..b580353 100644 --- a/aai-resources/src/main/resources/logback.xml +++ b/aai-resources/src/main/resources/logback.xml @@ -31,12 +31,12 @@ <property name="AJSC_HOME" value="${AJSC_HOME:-.}" /> <jmxConfigurator /> <property name="logDirectory" value="${AJSC_HOME}/logs" /> - <property name="eelfLogPattern" value="%ecompStartTime|%date{yyyy-MM-dd'T'HH:mm:ss.SSSZ, UTC}|%X{requestId}|%X{serviceInstanceId}|%-10t|%X{serverName}|%X{serviceName}|%X{partnerName}|%X{statusCode}|%X{responseCode}|%replace(%replace(%X{responseDescription}){'\\|', '!'}){'\r|\n', '^'}|%X{instanceUUID}|%level|%X{severity}|%X{serverIpAddress}|%ecompElapsedTime|%X{server}|%X{clientIpAddress}|%eelfClassOfCaller|%X{unused}|%X{processKey}|%X{customField1}|%X{customField2}|%X{customField3}|%X{customField4}|co=%X{component}:%replace(%replace(%m){'\\|', '!'}){'\r|\n', '^'}%n"/> - <property name="eelfAuditLogPattern" value="%ecompStartTime|%date{yyyy-MM-dd'T'HH:mm:ss.SSSZ, UTC}|%X{requestId}|%X{serviceInstanceId}|%-10t|%X{serverName}|%X{serviceName}|%X{partnerName}|%X{statusCode}|%X{responseCode}|%replace(%replace(%X{responseDescription}){'\\|', '!'}){'\r|\n|\r\n', '^'}|%X{instanceUUID}|%level|%X{severity}|%X{serverIpAddress}|%ecompElapsedTime|%X{server}|%X{clientIpAddress}|%eelfClassOfCaller|%X{unused}|%X{processKey}|%X{customField1}|%X{customField2}|%X{customField3}|%X{customField4}|co=%X{component}:%replace(%replace(%m){'\\|', '!'}){'\r|\n', '^'}%n"/> - <property name="eelfMetricLogPattern" value="%ecompStartTime|%date{yyyy-MM-dd'T'HH:mm:ss.SSSZ, UTC}|%X{requestId}|%X{serviceInstanceId}|%-10t|%X{serverName}|%X{serviceName}|%X{partnerName}|%X{targetEntity}|%X{targetServiceName}|%X{statusCode}|%X{responseCode}|%replace(%replace(%X{responseDescription}){'\\|', '!'}){'\r|\n', '^'}|%X{instanceUUID}|%level|%X{severity}|%X{serverIpAddress}|%ecompElapsedTime|%X{server}|%X{clientIpAddress}|%eelfClassOfCaller|%X{unused}|%X{processKey}|%X{targetVirtualEntity}|%X{customField1}|%X{customField2}|%X{customField3}|%X{customField4}|co=%X{component}:%replace(%replace(%m){'\\|', '!'}){'\r|\n', '^'}%n"/> - <!-- <property name="eelfErrorLogPattern" value="%ecompStartTime|%X{requestId}|%-10t|%X{serviceName}|%X{partnerName}|%X{targetEntity}|%X{targetServiceName}|%ecompErrorCategory|%X{responseCode}|%replace(%replace(%X{responseDescription}){'\\|', '!'}){'\r|\n|\r\n', '^'}|co=%X{component}:%replace(%replace(%m){'\\|', '!'}){'\r|\n', '^'}%n"/> --> - <property name="eelfErrorLogPattern" value="%ecompStartTime|%X{requestId}|%-10t|%X{serviceName}|%X{partnerName}|%X{targetEntity}|%X{targetServiceName}|%ecompErrorCategory|%ecompResponseCode|%ecompResponseDescription|co=%X{component}:%replace(%replace(%m){'\\|', '!'}){'\r|\n', '^'}%n"/> - <property name="eelfTransLogPattern" value="%ecompStartTime|%date{yyyy-MM-dd'T'HH:mm:ss.SSSZ, UTC}|%X{requestId}|%X{serviceInstanceId}|%-10t|%X{serverName}|%X{serviceName}|%X{partnerName}|%X{statusCode}|%X{responseCode}|%replace(%replace(%X{responseDescription}){'\\|', '!'}){'\r|\n', '^'}|%X{instanceUUID}|%level|%X{severity}|%X{serverIpAddress}|%ecompElapsedTime|%X{server}|%X{clientIpAddress}|%eelfClassOfCaller|%X{unused}|%X{processKey}|%X{customField1}|%X{customField2}|%X{customField3}|%X{customField4}|co=%X{partnerName}:%m%n"/> + <property name="eelfLogPattern" value="%ecompStartTime|%date{yyyy-MM-dd'T'HH:mm:ss.SSSZ, UTC}|%X{requestId}|%X{serviceInstanceId}|%-10t|%X{serverName}|%ecompServiceName|%X{partnerName}|%ecompStatusCode|%X{responseCode}|%replace(%replace(%X{responseDescription}){'\\|', '!'}){'\r|\n', '^'}|%X{instanceUUID}|%level|%X{severity}|%X{serverIpAddress}|%ecompElapsedTime|%X{server}|%X{clientIpAddress}|%eelfClassOfCaller|%X{unused}|%X{processKey}|%X{customField1}|%X{customField2}|%X{customField3}|%X{customField4}|co=%X{component}:%replace(%replace(%m){'\\|', '!'}){'\r|\n', '^'}%n"/> + <property name="eelfAuditLogPattern" value="%ecompStartTime|%date{yyyy-MM-dd'T'HH:mm:ss.SSSZ, UTC}|%X{requestId}|%X{serviceInstanceId}|%-10t|%X{serverName}|%ecompServiceName|%X{partnerName}|%ecompStatusCode|%X{responseCode}|%replace(%replace(%X{responseDescription}){'\\|', '!'}){'\r|\n|\r\n', '^'}|%X{instanceUUID}|%level|%X{severity}|%X{serverIpAddress}|%ecompElapsedTime|%X{server}|%X{clientIpAddress}|%eelfClassOfCaller|%X{unused}|%X{processKey}|%X{customField1}|%X{customField2}|%X{customField3}|%X{customField4}|co=%X{component}:%replace(%replace(%m){'\\|', '!'}){'\r|\n', '^'}%n"/> + <property name="eelfMetricLogPattern" value="%ecompStartTime|%date{yyyy-MM-dd'T'HH:mm:ss.SSSZ, UTC}|%X{requestId}|%X{serviceInstanceId}|%-10t|%X{serverName}|%ecompServiceName|%X{partnerName}|%X{targetEntity}|%X{targetServiceName}|%ecompStatusCode|%X{responseCode}|%replace(%replace(%X{responseDescription}){'\\|', '!'}){'\r|\n', '^'}|%X{instanceUUID}|%level|%X{severity}|%X{serverIpAddress}|%ecompElapsedTime|%X{server}|%X{clientIpAddress}|%eelfClassOfCaller|%X{unused}|%X{processKey}|%X{targetVirtualEntity}|%X{customField1}|%X{customField2}|%X{customField3}|%X{customField4}|co=%X{component}:%replace(%replace(%m){'\\|', '!'}){'\r|\n', '^'}%n"/> + <!-- <property name="eelfErrorLogPattern" value="%ecompStartTime|%X{requestId}|%-10t|%ecompServiceName|%X{partnerName}|%X{targetEntity}|%X{targetServiceName}|%ecompErrorCategory|%X{responseCode}|%replace(%replace(%X{responseDescription}){'\\|', '!'}){'\r|\n|\r\n', '^'}|co=%X{component}:%replace(%replace(%m){'\\|', '!'}){'\r|\n', '^'}%n"/> --> + <property name="eelfErrorLogPattern" value="%ecompStartTime|%X{requestId}|%-10t|%ecompServiceName|%X{partnerName}|%X{targetEntity}|%X{targetServiceName}|%ecompErrorCategory|%ecompResponseCode|%ecompResponseDescription|co=%X{component}:%replace(%replace(%m){'\\|', '!'}){'\r|\n', '^'}%n"/> + <property name="eelfTransLogPattern" value="%ecompStartTime|%date{yyyy-MM-dd'T'HH:mm:ss.SSSZ, UTC}|%X{requestId}|%X{serviceInstanceId}|%-10t|%X{serverName}|%ecompServiceName|%X{partnerName}|%ecompStatusCode|%X{responseCode}|%replace(%replace(%X{responseDescription}){'\\|', '!'}){'\r|\n', '^'}|%X{instanceUUID}|%level|%X{severity}|%X{serverIpAddress}|%ecompElapsedTime|%X{server}|%X{clientIpAddress}|%eelfClassOfCaller|%X{unused}|%X{processKey}|%X{customField1}|%X{customField2}|%X{customField3}|%X{customField4}|co=%X{partnerName}:%m%n"/> <conversionRule conversionWord="clr" converterClass="org.springframework.boot.logging.logback.ColorConverter" /> <conversionRule conversionWord="wex" converterClass="org.springframework.boot.logging.logback.WhitespaceThrowableProxyConverter" /> @@ -184,7 +184,7 @@ </fileNamePattern> </rollingPolicy> <encoder class="org.onap.aai.logging.EcompEncoder"> - <pattern>${eelfLogPattern}</pattern> + <pattern>${eelfErrorLogPattern}</pattern> </encoder> </appender> diff --git a/aai-resources/src/main/resources/logmessages.properties b/aai-resources/src/main/resources/logmessages.properties deleted file mode 100644 index 59684e4..0000000 --- a/aai-resources/src/main/resources/logmessages.properties +++ /dev/null @@ -1,6 +0,0 @@ -RESTSERVICE_HELLO=SERVICE0001I|Get a quick hello|No resolution needed|No action is required -RESTSERVICE_HELLO_NAME=SERVICE0002I|Get a quick hello for {0}|No resolution needed|No action is required -SPRINSERVICE_HELLO=SERVICE0003I|Say a quick hello|No resolution needed|No action is required -SPRINSERVICE_HELLO_NAME=SERVICE0004I|Say a quick hello for {0}|No resolution needed|No action is required -SPRINSERVICE_HELLO_MESSAGE=SERVICE0005I|Say hello message: {0}|No resolution needed|No action is required -SPRINSERVICE_HELLO_MESSAGE_NAME=SERVICE0006I|Say hello message object:{0}|No resolution needed|No action is required diff --git a/aai-resources/src/main/resources/retired.properties b/aai-resources/src/main/resources/retired.properties new file mode 100644 index 0000000..b4c0ca4 --- /dev/null +++ b/aai-resources/src/main/resources/retired.properties @@ -0,0 +1,9 @@ +# Retired properties +retired.api.pattern.list=\ + ^/aai/servers/v2/.*$,\ + ^/aai/v[78]/service-design-and-creation/models.*$,\ + ^/aai/v[78]/service-design-and-creation/named-queries.*$,\ + ^/aai/v[2-6]+/.*$\ + +retired.api.all.versions=^/aai/v[0-9]+/search/edge-tag-query.*$,\ + ^/aai/v[0-9]+/search/sdn-zone-query.*$
\ No newline at end of file diff --git a/aai-resources/src/main/resources/schema/UebEventLogEntry.xsd b/aai-resources/src/main/resources/schema/UebEventLogEntry.xsd deleted file mode 100644 index edc8924..0000000 --- a/aai-resources/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-resources/src/main/scripts/PropertyChangeName.sh b/aai-resources/src/main/scripts/PropertyChangeName.sh deleted file mode 100644 index 8168928..0000000 --- a/aai-resources/src/main/scripts/PropertyChangeName.sh +++ /dev/null @@ -1,66 +0,0 @@ -#!/bin/ksh -# -# ============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========================================================= -# - -# -# This script is used to add a target property name with the same value in the database schema -# to a vertex which has an existing property. The existing property is not removed. -# -# Note also - This script just makes changes to the schema that is currently live. -# If you were to create a new schema in a brandy-new environment, it would look like -# whatever the oxm (as of July 2016) told it to look like. So, part of making a -# change to the db schema should Always first be to make the change in the oxm so that -# future environments will have the change. This script is just to change existing -# instances of the schema since schemaGenerator (as of July 2015) does not update things - it -# just does the initial creation. -# -# To use this script, you need to pass four parameters: -# propertyName -- the name of the property that has the value to be used in the targetProperty -# targetPropertyName -- the name of the targetProperty -# targetNodeType -- NA if all propertyName instances in the DB are impacted, otherwise limit the change to this nodeType -# skipCommit -- true or false. For testing, skips the commit when set to true. -# -# Ie. propertyNameChange service-id persona-model-id service-instance true -# - -echo "RETIRED: Reach out to delivery team if this needs to be execued." -#COMMON_ENV_PATH=$( cd "$(dirname "$0")" ; pwd -P ) -#. ${COMMON_ENV_PATH}/common_functions.sh -#start_date; -#check_user; - - -#if [ "$#" -ne 4 ]; then -# echo "Illegal number of parameters" -# echo "usage: $0 propertyName targetPropertyName targetNodeType skipCommit" -# exit 1 -#fi - -#source_profile; -#execute_spring_jar org.onap.aai.dbgen.PropertyNameChange ${PROJECT_HOME}/resources/etc/appprops/schemaMod-logback.xml "$1 $2 $3 $4" -#if [ "$?" -ne "0" ]; then -# echo "Problem executing propertyNameChange " -# end_date; -# exit 1 -#fi - - -#end_date; -#exit 0 diff --git a/aai-resources/src/main/scripts/audit_schema.sh b/aai-resources/src/main/scripts/audit_schema.sh index 70aa535..ea66092 100644 --- a/aai-resources/src/main/scripts/audit_schema.sh +++ b/aai-resources/src/main/scripts/audit_schema.sh @@ -1,4 +1,4 @@ -#!/bin/sh +#!/bin/bash # # ============LICENSE_START======================================================= # org.onap.aai diff --git a/aai-resources/src/main/scripts/changePropertyCardinality.sh b/aai-resources/src/main/scripts/changePropertyCardinality.sh deleted file mode 100644 index 3be0178..0000000 --- a/aai-resources/src/main/scripts/changePropertyCardinality.sh +++ /dev/null @@ -1,70 +0,0 @@ -#!/bin/ksh - -### -# ============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========================================================= -### - -# -# This script is used to change the cardinality of an existing database property. -# It currently just allows you to change TO a SET cardinality with dataType = String. -# It does not currently let you preserve the data (since we're just doing this for one -# field which nobody uses yet). -# -# Note also - This script just makes changes to the schema that is currently live. -# If you were to create a new schema in a brandy-new environment, it would look like -# whatever ex5.json (as of Jan 2016) told it to look like. So, part of making a -# change to the db schema should Always first be to make the change in ex5.json so that -# future environments will have the change. This script is just to change existing -# instances of the schema since schemaGenerator (as of Jan 2016) does not update things - it -# just does the initial creation. -# -# Boy, this is getting to be a big comment section... -# -# To use this script, you need to pass four parameters: -# propertyName -- the name of the property that you need to change Cardinality on. -# targetDataType -- whether it's changing or not, you need to give it: For now -- we only allow "String" -# targetCardinality -- For now -- only accepts "SET". In the future we should support ("SET", "LIST" or "SINGLE") -# preserveDataFlag -- true or false. For now -- only supports "false" -# -# Ie. changePropertyCardinality.sh supplier-release-list String SET false -# - -COMMON_ENV_PATH=$( cd "$(dirname "$0")" ; pwd -P ) -. ${COMMON_ENV_PATH}/common_functions.sh - -start_date; -check_user; - -if [ "$#" -ne 4 ]; then - echo "Illegal number of parameters" - echo "usage: $0 propertyName targetDataType targetCardinality preserveDataFlag" - exit 1 -fi - -source_profile; - -execute_spring_jar org.onap.aai.dbgen.ChangePropertyCardinality ${PROJECT_HOME}/resources/etc/appprops/schemaMod-logback.xml "$1 $2 $3 $4" -if [ "$?" -ne "0" ]; then - echo "Problem executing ChangePropertyCardinality " - end_date; - exit 1 -fi - -end_date; -exit 0 diff --git a/aai-resources/src/main/scripts/common_functions.sh b/aai-resources/src/main/scripts/common_functions.sh index 768a911..9c8e275 100644 --- a/aai-resources/src/main/scripts/common_functions.sh +++ b/aai-resources/src/main/scripts/common_functions.sh @@ -1,4 +1,4 @@ -#!/bin/ksh +#!/bin/bash # # ============LICENSE_START======================================================= # org.onap.aai @@ -49,15 +49,24 @@ execute_spring_jar(){ shift 2; - EXECUTABLE_JAR=$(ls ${PROJECT_HOME}/lib/aai-resources-*.jar); + EXECUTABLE_JAR=$(ls ${PROJECT_HOME}/lib/*.jar); - JAVA_OPTS="${JAVA_PRE_OPTS}"; - JAVA_OPTS="-DAJSC_HOME=$PROJECT_HOME"; + JAVA_OPTS="${JAVA_PRE_OPTS} -DAJSC_HOME=$PROJECT_HOME"; JAVA_OPTS="$JAVA_OPTS -DBUNDLECONFIG_DIR=resources"; JAVA_OPTS="$JAVA_OPTS -Daai.home=$PROJECT_HOME "; JAVA_OPTS="$JAVA_OPTS -Dhttps.protocols=TLSv1.1,TLSv1.2"; JAVA_OPTS="$JAVA_OPTS -Dloader.main=${className}"; + JAVA_OPTS="$JAVA_OPTS -Dloader.path=${PROJECT_HOME}/resources"; JAVA_OPTS="$JAVA_OPTS -Dlogback.configurationFile=${logbackFile}"; + + 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_OPTS="${JAVA_OPTS} ${JAVA_POST_OPTS}"; ${JAVA_HOME}/bin/java ${JVM_OPTS} ${JAVA_OPTS} -jar ${EXECUTABLE_JAR} "$@" diff --git a/aai-resources/src/main/scripts/createDBSchema.sh b/aai-resources/src/main/scripts/createDBSchema.sh deleted file mode 100644 index 00f49ca..0000000 --- a/aai-resources/src/main/scripts/createDBSchema.sh +++ /dev/null @@ -1,40 +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. -# - -# -# The script invokes GenTester java class to create the DB schema -# -# NOTE: you can pass an option GEN_DB_WITH_NO_SCHEMA if you want it to create an instance of -# the graph - but with no schema (this is useful when using the Hbase copyTable to -# copy our database to different environments). -# Ie. createDbSchema.sh GEN_DB_WITH_NO_SCHEMA -# - -COMMON_ENV_PATH=$( cd "$(dirname "$0")" ; pwd -P ) -. ${COMMON_ENV_PATH}/common_functions.sh -start_date; -check_user; -source_profile; -execute_spring_jar org.onap.aai.dbgen.GenTester ${PROJECT_HOME}/resources/etc/appprops/createDBSchema-logback.xml "$@" -end_date; -exit 0 diff --git a/aai-resources/src/main/scripts/dataGrooming.sh b/aai-resources/src/main/scripts/dataGrooming.sh deleted file mode 100644 index f1ba4bc..0000000 --- a/aai-resources/src/main/scripts/dataGrooming.sh +++ /dev/null @@ -1,131 +0,0 @@ -#!/bin/ksh -# -# ============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========================================================= -# - -# -# The script invokes the dataGrooming java class to run some tests and generate a report and -# potentially do some auto-deleteing. -# -# Here are the allowed Parameters. Note - they are all optional and can be mixed and matched. -# -# -f oldFileName (see note below) -# -autoFix -# -sleepMinutes nn -# -edgesOnly -# -skipEdges -# -timeWindowMinutes nn -# -dontFixOrphans -# -maxFix -# -skipHostCheck -# -singleCommits -# -dupeCheckOff -# -dupeFixOn -# -ghost2CheckOff -# -ghost2FixOn -# -# NOTES: -# -f The name of a previous report can optionally be passed in with the "-f" option. -# Just the filename -- ie. "dataGrooming.sh -f dataGrooming.201504272106.out" -# The file will be assumed to be in the directory that it was created in. -# If a filename is passed, then the "deleteCandidate" vertex-id's and bad edges -# listed inside that report file will be deleted on this run if they are encountered as -# bad nodes/edges again. -# -# -autoFix If you don't use the "-f" option, you could choose to use "-autofix" which will -# automatically run the script twice: once to look for problems, then after -# sleeping for a few minutes, it will re-run with the inital-run's output as -# an input file. -# -# -maxFix When using autoFix, you might want to limit how many 'bad' records get fixed. -# This is a safeguard against accidently deleting too many records automatically. -# It has a default value set in AAIConstants: AAI_GROOMING_DEFAULT_MAX_FIX = 15; -# If there are more than maxFix candidates found -- then none will be deleted (ie. -# someone needs to look into it) -# -# -sleepMinutes When using autoFix, this defines how many minutes we sleep before the second run. -# It has a default value set in AAIConstants: AAI_GROOMING_DEFAULT_SLEEP_MINUTES = 7; -# The reason we sleep at all between runs is that our DB is "eventually consistant", so -# we want to give it time to resolve itself if possible. -# -# -edgesOnly Can be used any time you want to limit this tool so it only looks at edges. -# Note - as of 1710, we have not been seeing many purely bad edges, -# (ie. not associated with a phantom node) so this option is not used often. -# -# -skipEdgeChecks Use it to bypass checks for bad Edges (which are pretty rare). -# -# -timeWindowMinutes Use it to limit the nodes looked at to ones whose update-timestamp tells us that it was last updated less than this many minutes ago. Note this is usually used along with the skipEdgeChecks option. -# -# -dontFixOrphans Since there can sometimes be a lot of orphan nodes, and they don't -# harm processing as much as phantom-nodes or bad-edges, it is useful to be -# able to ignore them when fixing things. -# -# -skipHostCheck By default, the grooming tool will check to see that it is running -# on the host that is the first one in the list found in: -# aaiconfig.properties aai.primary.filetransfer.serverlist -# This is so that when run from the cron, it only runs on one machine. -# This option lets you turn that checking off. -# -# -singleCommits By default, the grooming tool will do all of its processing and then do -# a commit of all the changes at once. This option (maybe could have been named better) -# is letting the user override the default behavior and do a commit for each -# individual 'remove" one by one as they are encountered by the grooming logic. -# NOTE - this only applies when using either the "-f" or "-autoFix" options since -# those are the only two that make changes to the database. -# -# -dupeCheckOff By default, we will check all of our nodes for duplicates. This parameter lets -# us turn this check off if we don't want to do it for some reason. -# -# -dupeFixOn When we're fixing data, by default we will NOT fix duplicates This parameter lets us turn -# that fixing ON when we are comfortable that it can pick the correct duplicate to preserve. -# -# -ghost2CheckOff By default, we will check for the "new" kind of ghost that we saw on -# Production in early February 2016. This parameter lets us turn this check off if we -# don't want to do it for some reason. -# -# -ghost2FixOn When we're fixing data, by default we will NOT try to fix the "new" ghost nodes. -# This parameter lets us turn that fixing ON if we want to try to fix them. -# - -COMMON_ENV_PATH=$( cd "$(dirname "$0")" ; pwd -P ) -. ${COMMON_ENV_PATH}/common_functions.sh - -start_date; -check_user; - -# Make sure that it's not already running -processStat=`ps -ef|grep aaiadmin|grep -E "org.onap.aai.dbgen.DataGrooming"|grep -v grep` -if [ "$processStat" != "" ] - then - echo "Found dataGrooming is already running: " $processStat - exit 1 -fi - -# Make sure that it's not already running -processStat=`ps -ef|grep aaiadmin|grep -E "org.onap.aai.dbgen.DataGrooming"|grep -v grep` -if [ "$processStat" != "" ] - then - echo "Found dataGrooming is already running: " $processStat - exit 1 -fi - -source_profile; -execute_spring_jar org.onap.aai.dbgen.DataGrooming ${PROJECT_HOME}/resources/etc/appprops/dataGrooming-logback.xml "$@" -end_date; -exit 0 diff --git a/aai-resources/src/main/scripts/dataRestoreFromSnapshot.sh b/aai-resources/src/main/scripts/dataRestoreFromSnapshot.sh deleted file mode 100644 index 042dd15..0000000 --- a/aai-resources/src/main/scripts/dataRestoreFromSnapshot.sh +++ /dev/null @@ -1,70 +0,0 @@ -#!/bin/ksh -# -# ============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========================================================= -# - -# -# This script uses the dataSnapshot and SchemaGenerator (via GenTester) java classes to restore -# data to a database by doing three things: -# 1) clear out whatever data and schema are currently in the db -# 2) rebuild the schema (using the SchemaGenerator) -# 3) reload data from the passed-in datafile (which must found in the dataSnapShots directory and -# contain an xml view of the db data). -# - -COMMON_ENV_PATH=$( cd "$(dirname "$0")" ; pwd -P ) -. ${COMMON_ENV_PATH}/common_functions.sh - -start_date; -check_user; - -if [ "$#" -lt 1 ]; then - echo "Illegal number of parameters" - echo "usage: $0 previous_snapshot_filename" - exit 1 -fi - -source_profile; -export PRE_JAVA_OPTS=${PRE_JAVA_OPTS:--Xms6g -Xmx8g}; - -#### Step 1) clear out the database -execute_spring_jar org.onap.aai.dbgen.DataSnapshot ${PROJECT_HOME}/resources/etc/appprops/dataSnapshot-logback.xml "CLEAR_ENTIRE_DATABASE" "$1" "$2" -if [ "$?" -ne "0" ]; then - echo "Problem clearing out database." - exit 1 -fi - -#### Step 2) rebuild the db-schema -execute_spring_jar org.onap.aai.dbgen.GenTester ${PROJECT_HOME}/resources/etc/appprops/createDBSchema-logback.xml "GEN_DB_WITH_NO_DEFAULT_CR" -if [ "$?" -ne "0" ]; then - echo "Problem rebuilding the schema (SchemaGenerator)." - exit 1 -fi - -#### Step 3) reload the data from a snapshot file - -execute_spring_jar org.onap.aai.dbgen.DataSnapshot ${PROJECT_HOME}/resources/etc/appprops/dataSnapshot-logback.xml "RELOAD_DATA" "$1" -if [ "$?" -ne "0" ]; then - echo "Problem reloading data into the database." - end_date; - exit 1 -fi - -end_date; -exit 0 diff --git a/aai-resources/src/main/scripts/deleteTool.sh b/aai-resources/src/main/scripts/deleteTool.sh index 3d7f923..6cb27c8 100644 --- a/aai-resources/src/main/scripts/deleteTool.sh +++ b/aai-resources/src/main/scripts/deleteTool.sh @@ -1,4 +1,4 @@ -#!/bin/ksh +#!/bin/bash ### # ============LICENSE_START======================================================= diff --git a/aai-resources/src/main/scripts/deobfuscatePW.sh b/aai-resources/src/main/scripts/deobfuscatePW.sh deleted file mode 100644 index 6732b04..0000000 --- a/aai-resources/src/main/scripts/deobfuscatePW.sh +++ /dev/null @@ -1,39 +0,0 @@ -#!/bin/sh -# -# ============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========================================================= -# - -# -# The script invokes the utils.JettyObfuscationConversionCommandLineUtil class to -# deobfuscate an obfuscated name from aaiconfig property file -# e.g. -# ./deobfuscatePW.sh odl.auth.password -# will return: -# admin -# - -COMMON_ENV_PATH=$( cd "$(dirname "$0")" ; pwd -P ) -. ${COMMON_ENV_PATH}/common_functions.sh - -start_date; -check_user; - -source_profile; -execute_spring_jar org.onap.aai.util.AAIConfigCommandLinePropGetter ${PROJECT_HOME}/resources/etc/appprops/default-logback.xml "$1" -end_date;
\ No newline at end of file diff --git a/aai-resources/src/main/scripts/dupeTool.sh b/aai-resources/src/main/scripts/dupeTool.sh deleted file mode 100644 index f088d5b..0000000 --- a/aai-resources/src/main/scripts/dupeTool.sh +++ /dev/null @@ -1,73 +0,0 @@ -#!/bin/ksh - -### -# ============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========================================================= -### - -# -# dupeTool.sh -- This tool is used to look at or fix duplicate nodes for one nodeType -# at a time and can be used to limit what it's looking at to just nodes created -# within a recent time window. -# It is made to deal with situations (like we have in 1610/1702) where one type -# of node keeps needing to have duplicates cleaned up (tenant nodes). -# It is needed because DataGrooming cannot be run often and cannot be focused just -# on duplicates or just on one nodeType. -# -# Parameters: -# -# -userId (required) must be followed by a userid -# -nodeType (required) must be followed by a valid nodeType -# -timeWindowMinutes (optional) by default we would look at all nodes of the -# given nodeType, but if a window is given, then we will only look at -# nodes created that many (or fewer) minutes ago. -# -autoFix (optional) use this if you want duplicates fixed automatically (if we -# can figure out which to delete) -# -maxFix (optional) like with dataGrooming lets you override the default maximum -# number of dupes that can be processed at one time -# -skipHostCheck (optional) By default, the dupe tool will check to see that it is running -# on the host that is the first one in the list found in: -# aaiconfig.properties aai.primary.filetransfer.serverlist -# This is so that when run from the cron, it only runs on one machine. -# This option lets you turn that checking off. -# -sleepMinutes (optional) like with DataGrooming, you can override the -# sleep time done when doing autoFix between first and second checks of the data. -# -params4Collect (optional) followed by a string to tell what properties/values to use -# to limit the nodes being looked at. Must be in the format -# of “propertName|propValue” use commas to separate if there -# are more than one name/value being passed. -# -specialTenantRule (optional) turns on logic which will use extra logic to figure -# out which tenant node can be deleted in a common scenario. -# -# -# For example (there are many valid ways to use it): -# -# dupeTool.sh -userId am8383 -nodeType tenant -timeWindowMinutes 60 -autoFix -# or -# dupeTool.sh -userId am8383 -nodeType tenant -specialTenantRule -autoFix -maxFix 100 -# - -COMMON_ENV_PATH=$( cd "$(dirname "$0")" ; pwd -P ) -. ${COMMON_ENV_PATH}/common_functions.sh - -start_date; -check_user; -source_profile; -execute_spring_jar org.onap.aai.dbgen.DupeTool ${PROJECT_HOME}/resources/etc/appprops/dupeTool-logback.xml "$@" -end_date; -exit 0 diff --git a/aai-resources/src/main/scripts/dynamicPayloadArchive.sh b/aai-resources/src/main/scripts/dynamicPayloadArchive.sh deleted file mode 100644 index 75d75d4..0000000 --- a/aai-resources/src/main/scripts/dynamicPayloadArchive.sh +++ /dev/null @@ -1,66 +0,0 @@ -#!/bin/ksh - -### -# ============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========================================================= -### - -# -# The script is called to tar and gzip the files under /opt/app/aai-resources/resources/etc/scriptdata/addmanualdata/tenant_isolation which are the payload files created by the dynamicPayloadGenerator.sh tool. -# -# - -COMMON_ENV_PATH=$( cd "$(dirname "$0")" ; pwd -P ) -. ${COMMON_ENV_PATH}/common_functions.sh - -. /etc/profile.d/aai.sh -PROJECT_HOME=/opt/app/aai-resources - -PROGNAME=$(basename $0) - -TS=$(date "+%Y_%m_%d_%H_%M_%S") - -CHECK_USER="aaiadmin" -userid=$( id | cut -f2 -d"(" | cut -f1 -d")" ) -if [ "${userid}" != $CHECK_USER ]; then - echo "You must be $CHECK_USER to run $0. The id used $userid." - exit 1 -fi -DIRECTORY=${PROJECT_HOME}/resources/etc/scriptdata/addmanualdata/tenant_isolation -if [ ! -d ${DIRECTORY} ] -then - echo " ${DIRECTORY} doesn't exist" - exit 1 -fi - -tar c ${DIRECTORY}/* -f /var/tmp/dynamicPayloadArchive_${TS}.tar -if [ $? -ne 0 ] -then - echo " Unable to tar ${DIRECTORY}" - exit 1 -fi - -cd /var/tmp -gzip /var/tmp/dynamicPayloadArchive_${TS}.tar -if [ $? -ne 0 ] -then - echo " Unable to gzip /var/tmp/dynamicPayloadArchive_${TS}.tar" - exit 1 -fi -echo "Completed successfully: /var/tmp/dynamicPayloadArchive_${TS}.tar.gz" -exit 0 diff --git a/aai-resources/src/main/scripts/dynamicPayloadGenerator.sh b/aai-resources/src/main/scripts/dynamicPayloadGenerator.sh deleted file mode 100644 index 6d46546..0000000 --- a/aai-resources/src/main/scripts/dynamicPayloadGenerator.sh +++ /dev/null @@ -1,87 +0,0 @@ -#!/bin/ksh - -### -# ============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========================================================= -### - -# -# dynamicPayloadGenerator.sh -- This tool is used for Tenant-Isolation project -# It is used to load a snapshot into memory and generate payloads for any input nodes -# -# -# Parameters: -# -# -d (required) name of the fully qualified Datasnapshot file that you need to load -# -s (optional) true or false to enable or disable schema, By default it is true for production, -# you can change to false if the snapshot has duplicates -# -c (optional) config file to use for loading snapshot into memory. -# -o (required) output file to store the data files -# -f (optional) PAYLOAD or DMAAP-MR -# -n (optional) input file for the script -# -# -# For example (there are many valid ways to use it): -# -# dynamicPayloadGenerator.sh -d '/opt/app/snapshots/snaphot.graphSON' -o '/opt/app/aai-resources/resources/etc/scriptdata/addmanualdata/tenant_isolation/' -# -# or -# dynamicPayloadGenerator.sh -d '/opt/app/snapshots/snaphot.graphSON' -s false -c '/opt/app/aai-resources/resources/etc/appprops/dynamic.properties' -# -o '/opt/app/aai-resources/resources/etc/scriptdata/addmanualdata/tenant_isolation/' -f PAYLOAD -n '/opt/app/aai-resources/resources/etc/scriptdata/nodes.json' -# - - -echo -echo `date` " Starting $0" - -display_usage() { - cat <<EOF - Usage: $0 [options] - - 1. Usage: dynamicPayloadGenerator -d <graphsonPath> -o <output-path> - 2. This script has 2 arguments that are required. - a. -d (required) Name of the fully qualified Datasnapshot file that you need to load - b. -o (required) output file to store the data files - 3. Optional Parameters: - a. -s (optional) true or false to enable or disable schema, By default it is true for production, - b. -c (optional) config file to use for loading snapshot into memory. - c. -f (optional) PAYLOAD or DMAAP-MR - d. -n (optional) input file for the script - 4. For example (there are many valid ways to use it): - dynamicPayloadGenerator.sh -d '/opt/app/snapshots/snaphot.graphSON' -o '/opt/app/aai-resources/resources/etc/scriptdata/addmanualdata/tenant_isolation/' - - dynamicPayloadGenerator.sh -d '/opt/app/snapshots/snaphot.graphSON' -s false -c '/opt/app/aai-resources/resources/etc/appprops/dynamic.properties' - -o '/opt/app/aai-resources/resources/etc/scriptdata/addmanualdata/tenant_isolation/' -f PAYLOAD -n '/opt/app/aai-resources/resources/etc/scriptdata/nodes.json' - -EOF -} -if [ $# -eq 0 ]; then - display_usage - exit 1 -fi - -COMMON_ENV_PATH=$( cd "$(dirname "$0")" ; pwd -P ) -. ${COMMON_ENV_PATH}/common_functions.sh - -start_date; -check_user; -source_profile; -export JVM_OPTS="-Xmx9000m -Xms9000m" -execute_spring_jar org.onap.aai.dbgen.DynamicPayloadGenerator ${PROJECT_HOME}/resources/etc/appprops/dynamicPayloadGenerator-logback.xml "$@" -end_date; -exit 0 diff --git a/aai-resources/src/main/scripts/edgeTagger.sh b/aai-resources/src/main/scripts/edgeTagger.sh deleted file mode 100644 index abb3428..0000000 --- a/aai-resources/src/main/scripts/edgeTagger.sh +++ /dev/null @@ -1,86 +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. -# - -# -# This script is used to synch-up the data in the database with the "edge-tags" definitions found in the DbEdgeRules.java file. -# It is not needed during normal operation, but if a new tag (really a property) is defined for an edge or if an -# existing tag is changed, then this script should be run to migrate existing data so that it matches the new -# definition. Note: it is only dealing with the "tags" defined after position 2. For example, for our existing -# rules, we have have "isParent" defined in position 2, and then other tags in positions 3, 4 and 5 as -# mapped in DbEdgeRules.EdgeInfoMap: -# -# public static final Map<Integer, String> EdgeInfoMap; -# static { -# EdgeInfoMap = new HashMap<Integer, String>(); -# EdgeInfoMap.put(0, "edgeLabel"); -# EdgeInfoMap.put(1, "direction"); -# EdgeInfoMap.put(2, "isParent" ); -# EdgeInfoMap.put(3, "usesResource" ); -# EdgeInfoMap.put(4, "hasDelTarget" ); -# EdgeInfoMap.put(5, "SVC-INFRA" ); -# } -# -# -- The map above is used to interpret the data in the DbEdgeRules.EdgeRules map: -# -# public static final Multimap<String, String> EdgeRules = -# new ImmutableSetMultimap.Builder<String, String>() -# .putAll("availability-zone|complex","groupsResourcesIn,OUT,false,false,false,reverse") -# .putAll("availability-zone|service-capability","supportsServiceCapability,OUT,false,false,false,false") -# .putAll("complex|ctag-pool","hasCtagPool,OUT,true,false,false,false") -# .putAll("complex|l3-network","usesL3Network,OUT,false,false,false,true") -# etc... -# -# -- Valid values for the "tags" can be "true", "false" or "reverse". Read the T-space -# write-up for a detailed explanation of this... -# -# -# To use this script, You can either pass the parameter, "all" to update all the edge rules, or -# you can pass the KEY to a single edge rule that you would like to update. NOTE - the -# key is that first part of each edge rule that looks like, "nodeTypeA|nodeTypeB". -# -# Ie. ./edgeTagger.sh "all" -# or ./edgeTagger.sh "complex|ctag-pool" -# - -COMMON_ENV_PATH=$( cd "$(dirname "$0")" ; pwd -P ) -. ${COMMON_ENV_PATH}/common_functions.sh - -start_date; - -echo " NOTE - if you are deleting data, please run the dataSnapshot.sh script first or " -echo " at least make a note the details of the node that you are deleting. " - -check_user; -source_profile; - -execute_spring_jar org.onap.aai.dbgen.UpdateEdgeTags "" "$@" - -PROCESS_STATUS=$?; - -if [ ${PROCESS_STATUS} -ne 0 ]; then - echo "Problem executing UpdateEdgeTags"; - exit 1; -fi; - -end_date; -exit 0 diff --git a/aai-resources/src/main/scripts/forceDeleteTool.sh b/aai-resources/src/main/scripts/forceDeleteTool.sh deleted file mode 100644 index cb87b38..0000000 --- a/aai-resources/src/main/scripts/forceDeleteTool.sh +++ /dev/null @@ -1,84 +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. -# - -# -# forceDeleteTool.sh -- This tool is used to delete nodes that cannot be deleted using -# the normal REST API because of internal DB problems. For example, Phantom nodes -# and duplicate nodes cause errors to happen in "normal" REST API codes and must -# be deleted using this tool. -# Since it is not using the "normal" REST logic, it is also not invoking the "normal" -# edge rules that we use to cascade deletes to "child" nodes. So - this tool can be dangerous. -# Ie. if you accidently delete a parent node (like a cloud-region) that has many dependent -# child nodes, there will be no way to get to any of those child-nodes after the cloud-region -# has been deleted. -# There are several environment variables defined in aaiconfig.properties to help minimize errors like that. -# aai.forceDel.protected.nt.list=cloud-region -# aai.forceDel.protected.edge.count=10 -# aai.forceDel.protected.descendant.count=10 -# -# Parameters: -# -# -action (required) valid values: COLLECT_DATA or DELETE_NODE or DELETE_EDGE -# -userId (required) must be followed by a userid -# -params4Collect (followed by a string to tell what properties/values to use -# as part of a COLLECT_DATA request. Must be in the format -# of ?propertName|propValue? use commas to separate if there -# are more than one name/value being passed. -# -vertexId - required for a DELETE_NODE request -# -edgeId - required for a DELETE_EDGE request -# -overRideProtection --- WARNING ? This over-rides the protections we introduced! -# It will let you override a protected vertex or vertex that has more -# than the allowed number of edges or descendants. -# -DISPLAY_ALL_VIDS (optional) - in the rare case when you want to see the -# vertex-ids (vids) of all the CONNECTED vertices, you can use this. By -# default, we do not show them. -# -# -# For example: -# -# forceDeleteTool.sh -action COLLECT_DATA -userId am8383 -params4Collect "tenant-id|junk tenant01 ID 0224" -# -# forceDeleteTool.sh -action COLLECT_DATA -userId am8383 -params4Collect "cloud-owner|junkTesterCloudOwner 0224,cloud-region-id|junkTesterCloud REgion ID 0224" -# -# forceDeleteTool.sh -action DELETE_NODE -userId am8383 -vertexId 1234567 -# -# forceDeleteTool.sh -action DELETE_EDGE -userId am8383 -edgeId 9876543 -# -# - -COMMON_ENV_PATH=$( cd "$(dirname "$0")" ; pwd -P ) -. ${COMMON_ENV_PATH}/common_functions.sh - -start_date; - -echo " NOTE - if you are deleting data, please run the dataSnapshot.sh script first or " -echo " at least make a note the details of the node that you are deleting. " - -check_user; -source_profile; - -execute_spring_jar org.onap.aai.dbgen.ForceDeleteTool ${PROJECT_HOME}/resources/etc/appprops/forceDelete-logback.xml "$@" - -end_date; - -exit 0 diff --git a/aai-resources/src/main/scripts/getTool.sh b/aai-resources/src/main/scripts/getTool.sh index 3f61ab1..b513d0b 100644 --- a/aai-resources/src/main/scripts/getTool.sh +++ b/aai-resources/src/main/scripts/getTool.sh @@ -1,4 +1,4 @@ -#!/bin/ksh +#!/bin/bash ### # ============LICENSE_START======================================================= @@ -95,7 +95,7 @@ if [ $MISSING_PROP = false ]; then else AUTHSTRING="-u $CURLUSER:$CURLPASSWORD" fi - curl --request GET -sL -k $AUTHSTRING -H "X-FromAppId: $XFROMAPPID" -H "X-TransactionId: $XTRANSID" -H "Accept: application/json" $RESTURL$RESOURCE | jq '.' + curl --request GET -sL -k $AUTHSTRING -H "X-FromAppId: $XFROMAPPID" -H "X-TransactionId: $XTRANSID" -H "Accept: application/json" $RESTURL$RESOURCE | jq -M '.' | sed 's/\r//g' RC=$?; else echo "usage: $0 resource" diff --git a/aai-resources/src/main/scripts/dataSnapshot.sh b/aai-resources/src/main/scripts/increaseNodes.sh index 0e54a46..ce84ad6 100644 --- a/aai-resources/src/main/scripts/dataSnapshot.sh +++ b/aai-resources/src/main/scripts/increaseNodes.sh @@ -1,15 +1,16 @@ -#!/bin/ksh -# +#!/bin/bash + +### # ============LICENSE_START======================================================= # org.onap.aai # ================================================================================ -# Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved. +# Copyright (C) 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 +# http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, @@ -17,21 +18,17 @@ # See the License for the specific language governing permissions and # limitations under the License. # ============LICENSE_END========================================================= -# - -# -# This script invokes the dataSnapshot java class passing an option to tell it to take -# a snapshot of the database and store it as a single-line XML file. -# +### COMMON_ENV_PATH=$( cd "$(dirname "$0")" ; pwd -P ) . ${COMMON_ENV_PATH}/common_functions.sh +# TODO: There is a better way where you can pass in the function +# and then let the common functions check if the function exist and invoke it +# So this all can be templated out start_date; check_user; - source_profile; -execute_spring_jar org.onap.aai.dbgen.DataSnapshot ${PROJECT_HOME}/resources/etc/appprops/dataSnapshot-logback.xml "JUST_TAKE_SNAPSHOT" - +execute_spring_jar org.onap.aai.IncreaseNodesTool ${PROJECT_HOME}/resources/logback.xml "$@" end_date; exit 0 diff --git a/aai-resources/src/main/scripts/install/addManualData.sh b/aai-resources/src/main/scripts/install/addManualData.sh index 9a5bb59..016c5c3 100644 --- a/aai-resources/src/main/scripts/install/addManualData.sh +++ b/aai-resources/src/main/scripts/install/addManualData.sh @@ -1,4 +1,4 @@ -#!/bin/ksh +#!/bin/bash ### # ============LICENSE_START======================================================= @@ -75,19 +75,8 @@ error_exit () { rel="/"$1"/" k=0 -if [ "$1" = "tenant_isolation" ] -then - CR_TEXT_PATH=`find $PROJECT_HOME/resources/etc/scriptdata/addmanualdata/tenant_isolation/cloud-region -name "*.txt" -print | sort -f` - AZ_TEXT_PATH=`find $PROJECT_HOME/resources/etc/scriptdata/addmanualdata/tenant_isolation/availability-zone -name "*.txt" -print | sort -f` - COMPLEX_TEXT_PATH=`find $PROJECT_HOME/resources/etc/scriptdata/addmanualdata/tenant_isolation/complex -name "*.txt" -print | sort -f` - ZONE_TEXT_PATH=`find $PROJECT_HOME/resources/etc/scriptdata/addmanualdata/tenant_isolation/zone -name "*.txt" -print | sort -f` - PSERVER_TEXT_PATH=`find $PROJECT_HOME/resources/etc/scriptdata/addmanualdata/tenant_isolation/pserver -name "*.txt" -print | sort -f` - TEXT_PATH="${CR_TEXT_PATH} ${AZ_TEXT_PATH} ${COMPLEX_TEXT_PATH} ${ZONE_TEXT_PATH} ${PSERVER_TEXT_PATH}" - COMMAND=${TEXT_PATH} -else - TEXT_PATH=$PROJECT_HOME/resources/etc/scriptdata/addmanualdata/*/*.txt - COMMAND=`ls ${TEXT_PATH} | sort -f` -fi +TEXT_PATH=$PROJECT_HOME/resources/etc/scriptdata/addmanualdata/*/*.txt +COMMAND=`ls ${TEXT_PATH} | sort -f` ls ${TEXT_PATH} >/dev/null 2>&1 if [ $? -ne 0 ] @@ -107,7 +96,8 @@ while IFS=\n read -r i do echo "##### Begin putTool for $i ##### from file $filepath" | tee -a $OUTFILE resource=`echo $i | tr -d '\r'` -$PROJECT_HOME/scripts/putTool.sh $resource $jsonfile 1 0 na 1 >> $OUTFILE 2>&1 || error_exit "$resource" $j $filepath +errorcode=412 +$PROJECT_HOME/scripts/putTool.sh $resource $jsonfile $errorcode 1 0 na 1 >> $OUTFILE 2>&1 || error_exit "$resource" $j $filepath echo "##### End putTool for $resource #####" | tee -a $OUTFILE echo "Begin getTool for $resource" | tee -a $OUTFILE $PROJECT_HOME/scripts/getTool.sh $resource >> $OUTFILE 2>&1 || error_exit "$i" $j $filepath diff --git a/aai-resources/src/main/scripts/install/updateQueryData.sh b/aai-resources/src/main/scripts/install/updateQueryData.sh deleted file mode 100644 index 27fa24b..0000000 --- a/aai-resources/src/main/scripts/install/updateQueryData.sh +++ /dev/null @@ -1,106 +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. -# - -PROGNAME=$(basename $0) -OUTFILE=$PROJECT_HOME/logs/misc/${PROGNAME}.log.$(date +\%Y-\%m-\%d) -#OUTFILE=/c/temp/${PROGNAME}.log.$(date +\%Y-\%m-\%d) - -TS=$(date "+%Y-%m-%d %H:%M:%S") - -CHECK_USER="aaiadmin" -userid=$( id | cut -f2 -d"(" | cut -f1 -d")" ) -if [ "${userid}" != $CHECK_USER ]; then - echo "You must be $CHECK_USER to run $0. The id used $userid." - exit 1 -fi - -error_exit () { - echo "${PROGNAME}: failed for ${1:-"Unknown error"} on cmd $2" 1>&2 - echo "${PROGNAME}: failed for ${1:-"Unknown error"} on cmd $2" >> $OUTFILE -# exit ${2:-"1"} -} - -j=0 -for filepath in `ls $PROJECT_HOME/bundleconfig/etc/scriptdata/widget-model-json/*.json|sort -f` -#for filepath in `ls /c/sources/aai/aaigitnew/bundleconfig-local/etc/scriptdata/widget-model-json/*.json|sort -f` -do -j=$(expr "$j" + 1) -filename=$(basename $filepath) -echo "Begin putTool for widget $filename" | tee -a $OUTFILE -vers=`grep model-invariant-id $filepath|cut -d':' -f2|cut -d'"' -f2` -# last parameter will skip put if it exists -resource=service-design-and-creation/models/model/$vers -$PROJECT_HOME/scripts/putTool.sh $resource $filepath 1 0 na 1 >> $OUTFILE 2>&1 || error_exit "$resource $filepath" $j -#/c/sources/aai/aaigitnew/src/main/scripts/putTool.sh $resource $filepath 1 0 na 1 >> $OUTFILE 2>&1 || error_exit "$resource $filepath" $j -echo "End putTool for widget $filename" | tee -a $OUTFILE -done - -j=0 -for filepath in `ls $PROJECT_HOME/bundleconfig/etc/scriptdata/named-query-json/*.json|sort -f` -#for filepath in `ls /c/sources/aai/aaigitnew/bundleconfig-local/etc/scriptdata/named-query-json/*.json|sort -f` -do -j=$(expr "$j" + 1) -filename=$(basename $filepath) -echo "Begin putTool for named-query $filename" | tee -a $OUTFILE -vers=`grep named-query-uuid $filepath|cut -d':' -f2|cut -d'"' -f2` -# last parameter will skip put if it exists -resource=service-design-and-creation/named-queries/named-query/$vers -$PROJECT_HOME/scripts/putTool.sh $resource $filepath 1 0 na 1 >> $OUTFILE 2>&1 || error_exit "$resource $filepath" $j -#/c/sources/aai/aaigitnew/src/main/scripts/putTool.sh $resource $filepath 1 0 na 1 >> $OUTFILE 2>&1 || error_exit "$resource $filepath" $j -echo "End putTool for named-query $filename" | tee -a $OUTFILE -done - -j=0 -for filepath in `ls $PROJECT_HOME/bundleconfig/etc/scriptdata/resource-model-json/*.json|sort -f` -#for filepath in `ls /c/sources/aai/aaigitnew/bundleconfig-local/etc/scriptdata/resource-model-json/*.json|sort -f` -do -j=$(expr "$j" + 1) -filename=$(basename $filepath) -echo "Begin putTool for resource model $filename" | tee -a $OUTFILE -vers=`grep model-invariant-id $filepath|cut -d':' -f2|cut -d'"' -f2` -# last parameter will skip put if it exists -resource=service-design-and-creation/models/model/$vers -$PROJECT_HOME/scripts/putTool.sh $resource $filepath 1 0 na 1 >> $OUTFILE 2>&1 || error_exit "$resource $filepath" $j -#/c/sources/aai/aaigitnew/src/main/scripts/putTool.sh $resource $filepath 1 0 na 1 >> $OUTFILE 2>&1 || error_exit "$resource $filepath" $j -echo "End putTool for resource model $filename" | tee -a $OUTFILE -done - -j=0 -for filepath in `ls $PROJECT_HOME/bundleconfig/etc/scriptdata/service-model-json/*.json|sort -f` -#for filepath in `ls /c/sources/aai/aaigitnew/bundleconfig-local/etc/scriptdata/service-model-json/*.json|sort -f` -do -j=$(expr "$j" + 1) -filename=$(basename $filepath) -echo "Begin putTool for service model $filename" | tee -a $OUTFILE -vers=`grep model-invariant-id $filepath|cut -d':' -f2|cut -d'"' -f2` -# last parameter will skip put if it exists -resource=service-design-and-creation/models/model/$vers -$PROJECT_HOME/scripts/putTool.sh $resource $filepath 1 0 na 1 >> $OUTFILE 2>&1 || error_exit "$resource $filepath" $j -#/c/sources/aai/aaigitnew/src/main/scripts/putTool.sh $resource $filepath 1 0 na 1 >> $OUTFILE 2>&1 || error_exit "$resource $filepath" $j -echo "End putTool for service model $filename" | tee -a $OUTFILE -done - -echo "$PROGNAME completed ${TS}" | tee -a $OUTFILE -echo "See output and error file: $OUTFILE" - -exit 0 diff --git a/aai-resources/src/main/scripts/putTool.sh b/aai-resources/src/main/scripts/putTool.sh index 46696b2..cb28413 100644 --- a/aai-resources/src/main/scripts/putTool.sh +++ b/aai-resources/src/main/scripts/putTool.sh @@ -1,4 +1,4 @@ -#!/bin/ksh +#!/bin/bash ### # ============LICENSE_START======================================================= @@ -119,6 +119,14 @@ 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" @@ -126,10 +134,10 @@ if [ $MISSING_PROP = false ]; then AUTHSTRING="-u $CURLUSER:$CURLPASSWORD" fi if [ $RETURNRESPONSE = true ]; then - curl --request PUT -sL -k $AUTHSTRING -H "X-FromAppId: $XFROMAPPID" -H "X-TransactionId: $XTRANSID" -H "Accept: application/json" -T /tmp/$(basename $JSONFILE) $RESTURL$RESOURCE | jq '.' + curl --request PUT -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 "X-FromAppId: $XFROMAPPID" -H "X-TransactionId: $XTRANSID" -H "Accept: application/json" -T /tmp/$(basename $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 diff --git a/aai-resources/src/main/scripts/rshipTool.sh b/aai-resources/src/main/scripts/rshipTool.sh index 3952d44..049ef2e 100644 --- a/aai-resources/src/main/scripts/rshipTool.sh +++ b/aai-resources/src/main/scripts/rshipTool.sh @@ -1,4 +1,4 @@ -#!/bin/ksh +#!/bin/bash ### # ============LICENSE_START======================================================= diff --git a/aai-resources/src/main/scripts/run_Migrations.sh b/aai-resources/src/main/scripts/run_Migrations.sh deleted file mode 100644 index 19dda2d..0000000 --- a/aai-resources/src/main/scripts/run_Migrations.sh +++ /dev/null @@ -1,47 +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========================================================= -### - -COMMON_ENV_PATH=$( cd "$(dirname "$0")" ; pwd -P ) -. ${COMMON_ENV_PATH}/common_functions.sh - -# TODO: There is a better way where you can pass in the function -# and then let the common functions check if the function exist and invoke it -# So this all can be templated out -start_date; -check_user; -source_profile; - -ARGS="-c ${PROJECT_HOME}/resources/etc/appprops/janusgraph-realtime.properties"; - -if [ -f "$PROJECT_HOME/resources/application.properties" ]; then - # Get the application properties file and look for all lines - # starting with either jms dmaap or niws - # Turn them into system properties and export JAVA_PRE_OPTS so - # execute spring jar will get those values - # This is only needed since dmaap is used by run_migrations - JAVA_PRE_OPTS=$(egrep '^(dmaap|jms|niws)' $PROJECT_HOME/resources/application.properties | sed 's/^\(.*\)$/-D\1/g' | tr '\n' ' '); - export JAVA_PRE_OPTS; -fi; - -execute_spring_jar org.onap.aai.migration.MigrationController ${PROJECT_HOME}/resources/etc/appprops/migration-logback.xml ${ARGS} "$@" -end_date; -exit 0 diff --git a/aai-resources/src/main/scripts/schemaMod.sh b/aai-resources/src/main/scripts/schemaMod.sh deleted file mode 100644 index c2d0c83..0000000 --- a/aai-resources/src/main/scripts/schemaMod.sh +++ /dev/null @@ -1,70 +0,0 @@ -#!/bin/ksh -# -# ============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========================================================= -# - -# -# This script is used to correct mistakes made in the database schema. -# It currently just allows you to change either the dataType and/or indexType on properties used by nodes. -# -# NOTE - Titan is not elegant in 0.5.3 about making changes to the schema. Bad properties never -# actually leave the database, they just get renamed and stop getting used. So it is -# really worthwhile to get indexes and dataTypes correct the first time around. -# Note also - This script just makes changes to the schema that is currently live. -# If you were to create a new schema in a brandy-new environment, it would look like -# whatever ex5.json (as of June 2015) told it to look like. So, part of making a -# change to the db schema should Always first be to make the change in ex5.json so that -# future environments will have the change. This script is just to change existing -# instances of the schema since schemaGenerator (as of June 2015) does not update things - it -# just does the initial creation. -# -# Boy, this is getting to be a big comment section... -# -# To use this script, you need to pass four parameters: -# propertyName -- the name of the property that you need to change either the index or dataType on -# targetDataType -- whether it's changing or not, you need to give it: String, Integer, Boolean or Long -# targetIndexInfo -- whether it's changing or not, you need to give it: index, noIndex or uniqueIndex -# preserveDataFlag -- true or false. The only reason I can think of why you'd ever want to -# set this to false would be maybe if you were changing to an incompatible dataType so didn't -# want it to try to use the old data (and fail). But 99% of the time this will just be 'true'. -# -# Ie. schemaMod flavor-id String index true -# - -COMMON_ENV_PATH=$( cd "$(dirname "$0")" ; pwd -P ) -. ${COMMON_ENV_PATH}/common_functions.sh -start_date; -check_user; - -if [ "$#" -ne 4 ]; then - echo "Illegal number of parameters" - echo "usage: $0 propertyName targetDataType targetIndexInfo preserveDataFlag" - exit 1 -fi - -source_profile; -execute_spring_jar org.onap.aai.dbgen.SchemaMod ${PROJECT_HOME}/resources/etc/appprops/schemaMod-logback.xml "$1 $2 $3 $4" -if [ "$?" -ne "0" ]; then - echo "Problem executing schemaMod " - end_date; - exit 1 -fi - -end_date; -exit 0 diff --git a/aai-resources/src/main/scripts/uniquePropertyCheck.sh b/aai-resources/src/main/scripts/uniquePropertyCheck.sh deleted file mode 100644 index 87f7aad..0000000 --- a/aai-resources/src/main/scripts/uniquePropertyCheck.sh +++ /dev/null @@ -1,44 +0,0 @@ -#!/bin/ksh -# -# ============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========================================================= -# - -# -# The script invokes UniqueProperty java class to see if the passed property is unique in the db and if -# not, to display where duplicate values are found. -# -# For example: uniquePropertyCheck.sh subscriber-name -# - -COMMON_ENV_PATH=$( cd "$(dirname "$0")" ; pwd -P ) -. ${COMMON_ENV_PATH}/common_functions.sh -start_date; -check_user; -source_profile; - -#execute_spring_jar org.onap.aai.util.UniquePropertyCheck ${PROJECT_HOME}/resources/etc/appprops/uniquePropertyCheck-logback.xml "$@" -execute_spring_jar org.onap.aai.util.UniquePropertyCheck ${PROJECT_HOME}/resources/uniquePropertyCheck-logback.xml "$@" -ret_code=$? -if [ $ret_code != 0 ]; then - end_date; - exit $ret_code -fi - -end_date; -exit 0
\ No newline at end of file diff --git a/aai-resources/src/main/scripts/run_DbTestProcessBuilder.sh b/aai-resources/src/main/scripts/updatePem.sh index 6e6ac6f..cb4ca8d 100644 --- a/aai-resources/src/main/scripts/run_DbTestProcessBuilder.sh +++ b/aai-resources/src/main/scripts/updatePem.sh @@ -1,4 +1,4 @@ -#!/bin/ksh +#!/bin/bash ### # ============LICENSE_START======================================================= diff --git a/aai-resources/src/main/scripts/updateTool.sh b/aai-resources/src/main/scripts/updateTool.sh index 05377d6..c2b788d 100644 --- a/aai-resources/src/main/scripts/updateTool.sh +++ b/aai-resources/src/main/scripts/updateTool.sh @@ -1,4 +1,4 @@ -#!/bin/ksh +#!/bin/bash # # ============LICENSE_START======================================================= # org.onap.aai @@ -47,15 +47,18 @@ contains() { display_usage() { cat <<EOF +Use the execTool starting 1806 for running the updateTool.sh in the format shown below: +/opt/app/aai-resources/execTool.sh --debug ./updateTool.sh <node type> <update nodeURI> /tmp/updatepayload.json + Usage 1: updateTool.sh <node type> <update node URI> <property name>:<property value> [,<property name>:<property value]* | where update node uri is the URI path for that node for ex1: ./updateTool.sh pserver cloud-infrastructure/pservers/pserver/XXX prov-status:NEWSTATUS ex2:./updateTool.sh pserver cloud-infrastructure/pservers/pserver/XXX 'prov-status:NEWSTATUS with space' ex3:./updateTool.sh pserver cloud-infrastructure/pservers/pserver/XXX 'prov-status:NEWSTATUS,attribute2:value' -Usage 2. using .json file for update: ./updateTool.sh <node type> <update node URI> /tmp/updatepayload.json +Usage 2. using .json file for update: ./updateTool.sh <node type> <update nodeURI> /tmp/updatepayload.json Ex: ./updateTool.sh pserver cloud-infrastructure/pservers/pserver/XXX /tmp/testpayload.json - +testpayload.json should be only under /tmp EOF } @@ -93,7 +96,7 @@ fi . /etc/profile.d/aai.sh PROJECT_HOME=/opt/app/aai-resources -prop_file=$PROJECT_HOME/bundleconfig/etc/appprops/aaiconfig.properties +prop_file=$PROJECT_HOME/resources/etc/appprops/aaiconfig.properties log_dir=$PROJECT_HOME/logs/misc today=$(date +\%Y-\%m-\%d) @@ -168,7 +171,7 @@ EOF if [ $MISSING_PROP = false ]; then if [ $USEBASICAUTH = false ]; then - AUTHSTRING="--cert $PROJECT_HOME/bundleconfig/etc/auth/aaiClientPublicCert.pem --key $PROJECT_HOME/bundleconfig/etc/auth/aaiClientPrivateKey.pem" + AUTHSTRING="--cert $PROJECT_HOME/resources/etc/auth/aaiClientPublicCert.pem --key $PROJECT_HOME/resources/etc/auth/aaiClientPrivateKey.pem" else AUTHSTRING="-u $CURLUSER:$CURLPASSWORD" fi diff --git a/aai-resources/src/main/swm/package/nix/dist_files/opt/app/aai-resources/docker-compose.template.yaml b/aai-resources/src/main/swm/package/nix/dist_files/opt/app/aai-resources/docker-compose.template.yaml deleted file mode 100644 index f7c46c8..0000000 --- a/aai-resources/src/main/swm/package/nix/dist_files/opt/app/aai-resources/docker-compose.template.yaml +++ /dev/null @@ -1,50 +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-resources: - image: __REGISTRY__/__NAMESPACE__/aai-resources:__IMAGE_VERSION__ - network_mode: host - environment: - - LOCAL_USER_ID=__LOCAL_USER_ID__ - - LOCAL_GROUP_ID=__LOCAL_GROUP_ID__ - volumes: - - /opt/aai/logroot/AAI-RES:/opt/aai/logroot/AAI-RES - - /opt/app/aai-resources/appconfig/aai-client-cert.p12:/opt/app/aai-resources/resources/etc/auth/aai-client-cert.p12 - - /opt/app/aai-resources/appconfig/aai_keystore:/opt/app/aai-resources/resources/etc/auth/aai_keystore - - /opt/app/aai-resources/appconfig/aaiconfig.properties:/opt/app/aai-resources/resources/etc/appprops/aaiconfig.properties - - /opt/app/aai-resources/appconfig/application.properties:/opt/app/aai-resources/resources/application.properties - - /opt/app/aai-resources/appconfig/dme2.properties:/opt/app/aai-resources/resources/dme2.properties - - /opt/app/aai-resources/appconfig/localhost-access-logback.xml:/opt/app/aai-resources/resources/localhost-access-logback.xml - - /opt/app/aai-resources/appconfig/logback.xml:/opt/app/aai-resources/resources/logback.xml - - /opt/app/aai-resources/appconfig/janusgraph-cached.properties:/opt/app/aai-resources/resources/etc/appprops/janusgraph-cached.properties - - /opt/app/aai-resources/appconfig/janusgraph-realtime.properties:/opt/app/aai-resources/resources/etc/appprops/janusgraph-realtime.properties - logging: - driver: "json-file" - options: - max-size: "30m" - max-file: "5" diff --git a/aai-resources/src/main/swm/package/nix/dist_files/opt/app/aai-resources/execTool.sh b/aai-resources/src/main/swm/package/nix/dist_files/opt/app/aai-resources/execTool.sh deleted file mode 100644 index da52a66..0000000 --- a/aai-resources/src/main/swm/package/nix/dist_files/opt/app/aai-resources/execTool.sh +++ /dev/null @@ -1,38 +0,0 @@ -#!/bin/bash -# -# ============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========================================================= -# - - - -export WORKING_DIR="$( cd "$(dirname "$0")" ; pwd -P )/" - -CONTAINER_NAME=$(docker ps | grep 'aai-resources' | awk '{ print $7; }'); - -SCRIPT_NAME=$1; - -shift; - -docker exec -u aaiadmin ${CONTAINER_NAME} ls /opt/app/aai-resources/scripts/${SCRIPT_NAME} && { - docker exec -u aaiadmin ${CONTAINER_NAME} /opt/app/aai-resources/scripts/${SCRIPT_NAME} "$@" - exit 0; -} || { - echo "Unable to find the tool in the /opt/app/aai-resources/scripts"; - exit 1; -} diff --git a/aai-resources/src/main/swm/package/nix/dist_files/opt/app/aai-resources/kill_resources.sh b/aai-resources/src/main/swm/package/nix/dist_files/opt/app/aai-resources/kill_resources.sh deleted file mode 100755 index a278739..0000000 --- a/aai-resources/src/main/swm/package/nix/dist_files/opt/app/aai-resources/kill_resources.sh +++ /dev/null @@ -1,27 +0,0 @@ -#!/bin/bash -# -# ============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========================================================= -# - - -. /etc/profile.d/aai.sh -PROJECT_HOME=/opt/app/aai-resources - -docker-compose -f ${PROJECT_HOME}/docker-compose.yaml stop && \ - docker-compose -f ${PROJECT_HOME}/docker-compose.yaml rm -f diff --git a/aai-resources/src/main/swm/package/nix/dist_files/opt/app/aai-resources/start_resources.sh b/aai-resources/src/main/swm/package/nix/dist_files/opt/app/aai-resources/start_resources.sh deleted file mode 100755 index 13f7568..0000000 --- a/aai-resources/src/main/swm/package/nix/dist_files/opt/app/aai-resources/start_resources.sh +++ /dev/null @@ -1,26 +0,0 @@ -#!/bin/bash -# -# ============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========================================================= -# - - -. /etc/profile.d/aai.sh -PROJECT_HOME=/opt/app/aai-resources - -docker-compose -f ${PROJECT_HOME}/docker-compose.yaml up -d || exit 200 diff --git a/aai-resources/src/main/swm/package/nix/dist_files/opt/app/aai-resources/stop_resources.sh b/aai-resources/src/main/swm/package/nix/dist_files/opt/app/aai-resources/stop_resources.sh deleted file mode 100755 index 24c03a3..0000000 --- a/aai-resources/src/main/swm/package/nix/dist_files/opt/app/aai-resources/stop_resources.sh +++ /dev/null @@ -1,26 +0,0 @@ -#!/bin/bash -# -# ============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========================================================= -# - - -. /etc/profile.d/aai.sh -PROJECT_HOME=/opt/app/aai-resources - -docker-compose -f ${PROJECT_HOME}/docker-compose.yaml stop || exit 200 diff --git a/aai-resources/src/main/swm/package/nix/install/postproc/post_proc b/aai-resources/src/main/swm/package/nix/install/postproc/post_proc deleted file mode 100644 index d017750..0000000 --- a/aai-resources/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-resources/src/main/swm/package/nix/install/preproc/pre_proc b/aai-resources/src/main/swm/package/nix/install/preproc/pre_proc deleted file mode 100644 index 3f1b26f..0000000 --- a/aai-resources/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-resources/src/main/xjb/bindings.xjb b/aai-resources/src/main/xjb/bindings.xjb deleted file mode 100644 index 4ced5e0..0000000 --- a/aai-resources/src/main/xjb/bindings.xjb +++ /dev/null @@ -1,46 +0,0 @@ -<?xml version="1.0" encoding="UTF-8" standalone="yes"?> -<jaxb:bindings - version="2.1" - xmlns:jaxb="http://java.sun.com/xml/ns/jaxb" - xmlns:xs="http://www.w3.org/2001/XMLSchema"> - <jaxb:bindings scd="x-schema::a" xmlns:a="http://org.openecomp.aai.inventory"> - <jaxb:schemaBindings> - <jaxb:package name="org.openecomp.aai.domain.yang.v2"/> - </jaxb:schemaBindings> - </jaxb:bindings> - <jaxb:bindings scd="x-schema::a" xmlns:a="http://org.openecomp.aai.inventory/v3"> - <jaxb:schemaBindings> - <jaxb:package name="org.openecomp.aai.domain.yang.v3"/> - </jaxb:schemaBindings> - </jaxb:bindings> - <jaxb:bindings scd="x-schema::a" xmlns:a="http://org.openecomp.aai.inventory/v4"> - <jaxb:schemaBindings> - <jaxb:package name="org.openecomp.aai.domain.yang.v4"/> - </jaxb:schemaBindings> - </jaxb:bindings> - <jaxb:bindings scd="x-schema::a" xmlns:a="http://org.openecomp.aai.inventory/v5"> - <jaxb:schemaBindings> - <jaxb:package name="org.openecomp.aai.domain.yang.v5"/> - </jaxb:schemaBindings> - </jaxb:bindings> - <jaxb:bindings scd="x-schema::a" xmlns:a="http://org.openecomp.aai.inventory/v6"> - <jaxb:schemaBindings> - <jaxb:package name="org.openecomp.aai.domain.yang.v6"/> - </jaxb:schemaBindings> - </jaxb:bindings> - <jaxb:bindings scd="x-schema::a" xmlns:a="http://org.openecomp.aai.inventory/v7"> - <jaxb:schemaBindings> - <jaxb:package name="org.openecomp.aai.domain.yang.v7"/> - </jaxb:schemaBindings> - </jaxb:bindings> - <jaxb:bindings scd="x-schema::a" xmlns:a="http://org.openecomp.aai.inventory/v8"> - <jaxb:schemaBindings> - <jaxb:package name="org.openecomp.aai.domain.yang.v8"/> - </jaxb:schemaBindings> - </jaxb:bindings> - <jaxb:bindings scd="x-schema::a" xmlns:a="http://org.openecomp.aai.inventory/v9"> - <jaxb:schemaBindings> - <jaxb:package name="org.openecomp.aai.domain.yang"/> - </jaxb:schemaBindings> - </jaxb:bindings> -</jaxb:bindings>
\ No newline at end of file diff --git a/aai-resources/src/test/java/org/onap/aai/AAISetup.java b/aai-resources/src/test/java/org/onap/aai/AAISetup.java index 1ae7f51..a93127b 100644 --- a/aai-resources/src/test/java/org/onap/aai/AAISetup.java +++ b/aai-resources/src/test/java/org/onap/aai/AAISetup.java @@ -23,21 +23,81 @@ 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.serialization.queryformats.QueryFormatTestHelper; -import org.onap.aai.util.AAIConstants; +import org.onap.aai.config.SpringContextAware; +import org.onap.aai.config.IntrospectionConfig; +import org.onap.aai.introspection.LoaderFactory; +import org.onap.aai.logging.LoggingContext; +import org.onap.aai.nodes.NodeIngestor; +import org.onap.aai.config.RestBeanConfig; +import org.onap.aai.rest.db.HttpEntry; +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.onap.aai.introspection.MoxyLoader; +import org.junit.ClassRule; +import org.junit.Rule; +import org.onap.aai.edges.EdgeIngestor; +import org.onap.aai.setup.AAIConfigTranslator; +import org.onap.aai.serialization.db.EdgeSerializer; +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, + NodeIngestor.class, + EdgeIngestor.class, + EdgeSerializer.class, + SpringContextAware.class, + IntrospectionConfig.class, + RestBeanConfig.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 SchemaVersions schemaVersions; + + @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/"); -// QueryFormatTestHelper.setFinalStatic(AAIConstants.class.getField("AAI_HOME_ETC_OXM"), "bundleconfig-local/etc/oxm/"); + LoggingContext.init(); } - + public String getPayload(String filename) throws IOException { InputStream inputStream = getClass() diff --git a/aai-resources/src/test/java/org/onap/aai/HttpTestUtil.java b/aai-resources/src/test/java/org/onap/aai/HttpTestUtil.java new file mode 100644 index 0000000..6b49b78 --- /dev/null +++ b/aai-resources/src/test/java/org/onap/aai/HttpTestUtil.java @@ -0,0 +1,377 @@ +/** + * ============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.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.setup.SchemaVersion; +import org.onap.aai.setup.SchemaVersions; +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.TransactionalGraphEngine; + +import javax.ws.rs.core.*; +import java.io.UnsupportedEncodingException; +import java.net.URI; +import java.util.ArrayList; +import java.util.List; +import java.util.UUID; + +import static org.mockito.Matchers.anyObject; +import static org.mockito.Mockito.doReturn; +import static org.mockito.Mockito.when; + +public class HttpTestUtil extends RESTAPI { + + private static final EELFLogger logger = EELFManager.getInstance().getLogger(HttpTestUtil.class); + + protected static final MediaType APPLICATION_JSON = MediaType.valueOf("application/json"); + + private static final String EMPTY = ""; + + protected HttpHeaders httpHeaders; + protected UriInfo uriInfo; + + protected MultivaluedMap<String, String> headersMultiMap; + protected MultivaluedMap<String, String> queryParameters; + + protected List<String> aaiRequestContextList; + protected List<MediaType> outputMediaTypes; + protected SchemaVersions schemaVersions; + + public void init(){ + + 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.getRequestHeaders()).thenReturn(headersMultiMap); + when(httpHeaders.getAcceptableMediaTypes()).thenReturn(outputMediaTypes); + + when(httpHeaders.getRequestHeader("aai-request-context")).thenReturn(aaiRequestContextList); + + when(uriInfo.getQueryParameters()).thenReturn(queryParameters); + when(uriInfo.getQueryParameters(false)).thenReturn(queryParameters); + + doReturn(null).when(queryParameters).remove(anyObject()); + when(httpHeaders.getMediaType()).thenReturn(APPLICATION_JSON); + schemaVersions = SpringContextAware.getBean(SchemaVersions.class); + } + + public Response doPut(String uri, String payload) throws AAIException { + + this.init(); + Response response = null; + boolean success = true; + TransactionalGraphEngine dbEngine = null; + + try { + + uri = uri.replaceAll("/aai/", ""); + logger.info("Starting the put request for the uri {} with payload {}", uri, payload); + + String [] arr = uri.split("/"); + + SchemaVersion version = null; + + if(arr != null && arr.length > 1){ + if(arr[0].matches("^v\\d+")){ + version = new SchemaVersion(arr[0]); + uri = uri.replaceAll("^v\\d+", ""); + } + } + + if(version == null){ + version = schemaVersions.getDefaultVersion(); + } + Mockito.when(uriInfo.getPath()).thenReturn(uri); + + DBConnectionType type = DBConnectionType.REALTIME; + //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); + + String objType = uriToObject.getEntityName(); + QueryParser uriQuery = dbEngine.getQueryBuilder().createQueryFromURI(uriObject); + + + logger.info("Unmarshalling the payload to this {}", objType); + + Introspector obj; + HttpMethod httpMethod; + if(uri.contains("/relationship-list/relationship")){ + obj = loader.unmarshal("relationship", payload, org.onap.aai.restcore.MediaType.getEnum("application/json")); + httpMethod = HttpMethod.PUT_EDGE; + } else { + obj = loader.unmarshal(objType, payload, org.onap.aai.restcore.MediaType.getEnum("application/json")); + httpMethod = HttpMethod.PUT; + this.validateIntrospector(obj, loader, uriObject, httpMethod); + } + + + DBRequest dbRequest = + new DBRequest.Builder(httpMethod, uriObject, uriQuery, obj, httpHeaders, uriInfo, "JUNIT-TRANSACTION") + .rawRequestContent(payload).build(); + + List<DBRequest> dbRequestList = new ArrayList<>(); + dbRequestList.add(dbRequest); + + Pair<Boolean, List<Pair<URI, Response>>> responsesTuple = resourceHttpEntry.process(dbRequestList, "JUNIT"); + response = responsesTuple.getValue1().get(0).getValue1(); + + } catch (AAIException e) { + response = this.consumerExceptionResponseGenerator(httpHeaders, uriInfo, HttpMethod.PUT, e); + success = false; + } catch(Exception e){ + AAIException ex = new AAIException("AAI_4000", e); + response = this.consumerExceptionResponseGenerator(httpHeaders, uriInfo, HttpMethod.PUT, ex); + success = false; + } finally { + if(success){ + if(response != null){ + if((response.getStatus() / 100) == 2){ + logger.info("Successfully completed the PUT request with status {} and committing it to DB", response.getStatus()); + } else { + logFailure(HttpMethod.PUT, response); + } + } + dbEngine.commit(); + } else { + if(response != null) { + logFailure(HttpMethod.PUT, response); + } + dbEngine.rollback(); + } + } + + return response; + } + + public Response doGet(String uri) throws UnsupportedEncodingException, AAIException { + + this.init(); + Response response = null; + boolean success = true; + TransactionalGraphEngine dbEngine = null; + + try { + + uri = uri.replaceAll("/aai/", ""); + logger.info("Starting the GET request for the uri {} with depth {}", uri, "all"); + + String [] arr = uri.split("/"); + + SchemaVersion version = null; + + if(arr != null && arr.length > 1){ + if(arr[0].matches("^v\\d+")){ + version = new SchemaVersion(arr[0]); + uri = uri.replaceAll("^v\\d+", ""); + } + } + + if(version == null){ + version = schemaVersions.getDefaultVersion(); + } + + DBConnectionType type = DBConnectionType.REALTIME; + // 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); + + String objType = uriToObject.getEntityName(); + queryParameters.add("depth", "all"); + QueryParser uriQuery = dbEngine.getQueryBuilder().createQueryFromURI(uriObject, queryParameters); + + Mockito.when(uriInfo.getPath()).thenReturn(uri); + + logger.info("Unmarshalling the payload to this {}", objType); + + Introspector obj = loader.introspectorFromName(objType); + + DBRequest dbRequest = + new DBRequest.Builder(HttpMethod.GET, uriObject, uriQuery, obj, httpHeaders, uriInfo, "JUNIT-TRANSACTION") + .build(); + + List<DBRequest> dbRequestList = new ArrayList<>(); + dbRequestList.add(dbRequest); + + Pair<Boolean, List<Pair<URI, Response>>> responsesTuple = resourceHttpEntry.process(dbRequestList, "JUNIT"); + response = responsesTuple.getValue1().get(0).getValue1(); + + } catch (AAIException e) { + response = this.consumerExceptionResponseGenerator(httpHeaders, uriInfo, HttpMethod.PUT, e); + success = false; + } catch(Exception e){ + AAIException ex = new AAIException("AAI_4000", e); + response = this.consumerExceptionResponseGenerator(httpHeaders, uriInfo, HttpMethod.PUT, ex); + success = false; + } finally { + if(success){ + if(response != null){ + if((response.getStatus() / 100) == 2){ + logger.info("Successfully completed the GET request with status {} and committing it to DB", response.getStatus()); + } else { + logFailure(HttpMethod.GET, response); + } + } + dbEngine.commit(); + } else { + logFailure(HttpMethod.GET, response); + dbEngine.rollback(); + } + } + + return response; + } + + public Response doDelete(String uri, String resourceVersion) throws UnsupportedEncodingException, AAIException { + + this.init(); + Response response = null; + boolean success = true; + TransactionalGraphEngine dbEngine = null; + + try { + + uri = uri.replaceAll("/aai/", ""); + logger.info("Starting the delete request for the uri {} with resource version {}", uri, resourceVersion); + + String [] arr = uri.split("/"); + + SchemaVersion version = null; + + if(arr != null && arr.length > 1){ + if(arr[0].matches("^v\\d+")){ + version = new SchemaVersion(arr[0]); + if(!uri.contains("relationship-list/relationship")){ + uri = uri.replaceAll("^v\\d+", ""); + } + } + } + + if(version == null){ + version = schemaVersions.getDefaultVersion(); + } + + Mockito.when(uriInfo.getPath()).thenReturn(uri); + DBConnectionType type = DBConnectionType.REALTIME; + // 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); + + String objType = uriToObject.getEntityName(); + queryParameters.add("resource-version", resourceVersion); + QueryParser uriQuery = dbEngine.getQueryBuilder().createQueryFromURI(uriObject, queryParameters); + + logger.info("Unmarshalling the payload to this {}", objType); + + Introspector obj; + HttpMethod httpMethod; + if(uri.contains("/relationship-list/relationship")){ + obj = loader.introspectorFromName("relationship"); + httpMethod = HttpMethod.DELETE_EDGE; + } else { + obj = loader.introspectorFromName(objType); + httpMethod = HttpMethod.DELETE; + } + + DBRequest dbRequest = + new DBRequest.Builder(httpMethod, uriObject, uriQuery, obj, httpHeaders, uriInfo, "JUNIT-TRANSACTION") + .build(); + + List<DBRequest> dbRequestList = new ArrayList<>(); + dbRequestList.add(dbRequest); + + Pair<Boolean, List<Pair<URI, Response>>> responsesTuple = resourceHttpEntry.process(dbRequestList, "JUNIT"); + response = responsesTuple.getValue1().get(0).getValue1(); + + } catch (AAIException e) { + response = this.consumerExceptionResponseGenerator(httpHeaders, uriInfo, HttpMethod.PUT, e); + success = false; + } catch(Exception e){ + AAIException ex = new AAIException("AAI_4000", e); + response = this.consumerExceptionResponseGenerator(httpHeaders, uriInfo, HttpMethod.PUT, ex); + success = false; + } finally { + if(success){ + if(response != null){ + if((response.getStatus() / 100) == 2){ + logger.info("Successfully completed the DELETE request with status {} and committing it to DB", response.getStatus()); + } else { + logFailure(HttpMethod.DELETE, response); + } + } + dbEngine.commit(); + } else { + logFailure(HttpMethod.DELETE, response); + dbEngine.rollback(); + } + } + + return response; + } + + public static void logFailure(HttpMethod httpMethod, Response response){ + logger.info("Unable to complete the {} request with status {} and rolling back", httpMethod.toString(), response.getStatus()); + logger.info("Response body of failed request {}", response.getEntity()); + + } +} diff --git a/aai-resources/src/test/java/org/onap/aai/IncreaseNodesToolTest.java b/aai-resources/src/test/java/org/onap/aai/IncreaseNodesToolTest.java new file mode 100644 index 0000000..5d91fb3 --- /dev/null +++ b/aai-resources/src/test/java/org/onap/aai/IncreaseNodesToolTest.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; + +import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversal; +import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource; +import org.janusgraph.core.JanusGraph; +import org.janusgraph.core.JanusGraphTransaction; + +import org.junit.Before; +import org.junit.Test; +import org.mockito.Mock; +import org.mockito.Mockito; +import org.apache.tinkerpop.gremlin.structure.Vertex; + +import static org.mockito.Mockito.*; + +public class IncreaseNodesToolTest extends AAISetup { + + @Mock + JanusGraphTransaction janusGraphtransaction; + + @Mock + JanusGraph janusGraph; + + @Mock + GraphTraversalSource graphTraversalSource; + + @Mock + Vertex mockVertex; + + @Mock + GraphTraversal<org.apache.tinkerpop.gremlin.structure.Vertex, org.apache.tinkerpop.gremlin.structure.Vertex> graphTraversalVertex; + + private IncreaseNodesTool increaseNodesTool; + + + String [] args = {"-numberOfNodes", "5" ,"-nodeType", "pserver", "-uri", "/cloud-infrastructure/pservers/pserver/"}; + + @Before + public void setup(){ + increaseNodesTool = new IncreaseNodesTool(loaderFactory, schemaVersions); + } + + @Test + public void addVertex() throws Exception { + + when(janusGraph.newTransaction()).thenReturn(janusGraphtransaction); + when(janusGraphtransaction.traversal()).thenReturn(graphTraversalSource); + when(graphTraversalSource.addV()).thenReturn(graphTraversalVertex); + when(graphTraversalVertex.next()).thenReturn(mockVertex); + increaseNodesTool.run(janusGraph,args); + + Mockito.verify(janusGraph).newTransaction(); + + Mockito.verify(graphTraversalSource,times(5)).addV(); + } + + @Test + public void addVertexfFail() throws Exception { + + when(janusGraph.newTransaction()).thenReturn(janusGraphtransaction); + when(janusGraphtransaction.traversal()).thenThrow(new RuntimeException()); + + increaseNodesTool.run(janusGraph,args); + + Mockito.verify(janusGraphtransaction).rollback(); + } + +} + diff --git a/aai-resources/src/test/java/org/onap/aai/PayloadUtil.java b/aai-resources/src/test/java/org/onap/aai/PayloadUtil.java new file mode 100644 index 0000000..9c99163 --- /dev/null +++ b/aai-resources/src/test/java/org/onap/aai/PayloadUtil.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; + +import org.apache.commons.io.IOUtils; + +import java.io.IOException; +import java.io.InputStream; +import java.util.HashMap; +import java.util.Map; +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +import static org.junit.Assert.assertNotNull; + +public class PayloadUtil { + + private static final Map<String, String> cache = new HashMap<>(); + private static final Pattern TEMPLATE_PATTERN = Pattern.compile("\\$\\{[^}]+\\}"); + + public static String getResourcePayload(String fileName) throws IOException { + + InputStream inputStream = PayloadUtil.class.getClassLoader().getResourceAsStream("payloads/resource/" + fileName); + + String message = String.format("Unable to find the %s in src/test/resources", fileName); + assertNotNull(message, inputStream); + + String resource = IOUtils.toString(inputStream); + + inputStream.close(); + return resource; + } + + public static String getTemplatePayload(String fileName, Map<String, String> templateValueMap) throws Exception { + + InputStream inputStream = PayloadUtil.class.getClassLoader().getResourceAsStream("payloads/templates/" + fileName); + + String message = String.format("Unable to find the %s in src/test/resources", fileName); + assertNotNull(message, inputStream); + + String resource; + + if(cache.containsKey(fileName)){ + resource = cache.get(fileName); + } else { + resource = IOUtils.toString(inputStream); + cache.put(fileName, resource); + } + + Matcher matcher = TEMPLATE_PATTERN.matcher(resource); + + String resourceWithTemplateValues = resource; + + while(matcher.find()){ + int start = matcher.start() + 2; + int end = matcher.end() - 1; + String key = resource.substring(start, end); + if(templateValueMap.containsKey(key)){ + resourceWithTemplateValues = resourceWithTemplateValues.replaceAll("\\$\\{" + key +"\\}", templateValueMap.get(key)); + } else { + throw new RuntimeException("Unable to find the key value pair in map for the template processing for key " + key); + } + } + + inputStream.close(); + return resourceWithTemplateValues; + } + + public static String getPayload(String fileName) throws IOException { + + InputStream inputStream = PayloadUtil.class.getClassLoader().getResourceAsStream("payloads/" + fileName); + + String message = String.format("Unable to find the %s in src/test/resources/payloads/", fileName); + assertNotNull(message, inputStream); + + String resource = IOUtils.toString(inputStream); + + inputStream.close(); + return resource; + } +} diff --git a/aai-resources/src/test/java/org/onap/aai/dbgen/DupeToolTest.java b/aai-resources/src/test/java/org/onap/aai/dbgen/DupeToolTest.java deleted file mode 100644 index e9e95eb..0000000 --- a/aai-resources/src/test/java/org/onap/aai/dbgen/DupeToolTest.java +++ /dev/null @@ -1,148 +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.dbgen; - -import com.att.eelf.configuration.EELFLogger; -import com.att.eelf.configuration.EELFManager; -import org.janusgraph.core.JanusGraphTransaction; -import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource; -import org.apache.tinkerpop.gremlin.structure.Vertex; -import org.junit.After; -import org.junit.Before; -import org.junit.Test; -import org.onap.aai.AAISetup; -import org.onap.aai.dbmap.AAIGraph; -import org.onap.aai.serialization.db.EdgeRules; - -import static org.junit.Assert.*; - - -public class DupeToolTest extends AAISetup { - - private static final EELFLogger logger = EELFManager.getInstance().getLogger(DupeToolTest.class); - - private DupeTool dupeTool; - - @Before - public void setup(){ - dupeTool = new DupeTool(); - dupeTool.SHOULD_EXIT_VM = false; - createGraph(); - } - - private void createGraph() { - JanusGraphTransaction transaction = AAIGraph.getInstance().getGraph().newTransaction(); - - EdgeRules edgeRules = EdgeRules.getInstance(); - - boolean success = true; - - try { - - GraphTraversalSource g = transaction.traversal(); - - Vertex cloudRegionVertex = g.addV() - .property("aai-node-type", "cloud-region") - .property("cloud-owner", "test-owner") - .property("cloud-region-id", "test-region") - .property("source-of-truth", "JUNIT") - .next(); - - Vertex tenantVertex = g.addV() - .property("aai-node-type", "tenant") - .property("tenant-id", "test-tenant") - .property("source-of-truth", "JUNIT") - .next(); - - Vertex pserverVertex = g.addV() - .property("aai-node-type", "pserver") - .property("hostname", "test-pserver") - .property("in-maint", false) - .property("source-of-truth", "JUNIT") - .next(); - - for(int i = 0; i < 100; ++i){ - g.addV() - .property("aai-node-type", "pserver") - .property("hostname", "test-pserver") - .property("in-maint", false) - .property("source-of-truth", "JUNIT") - .next(); - } - - edgeRules.addTreeEdge(g, cloudRegionVertex, tenantVertex); - edgeRules.addEdge(g, cloudRegionVertex, pserverVertex); - - } catch(Exception ex){ - success = false; - logger.error("Unable to create the vertexes", ex); - } finally { - if(success){ - transaction.commit(); - } else { - transaction.rollback(); - fail("Unable to setup the graph"); - } - } - } - - @Test - public void testDupeTool(){ - - String[] args = { - "-userId", "testuser", - "-nodeType", "pserver", - "-timeWindowMinutes", "30", - "-autoFix", - "-maxFix", "30", - "-sleepMinutes", "0" - }; - - dupeTool.main(args); - } - - @After - public void tearDown(){ - - JanusGraphTransaction transaction = AAIGraph.getInstance().getGraph().newTransaction(); - boolean success = true; - - try { - - GraphTraversalSource g = transaction.traversal(); - - g.V().has("source-of-truth", "JUNIT") - .toList() - .forEach(v -> v.remove()); - - } catch(Exception ex){ - success = false; - logger.error("Unable to remove the vertexes", ex); - } finally { - if(success){ - transaction.commit(); - } else { - transaction.rollback(); - fail("Unable to teardown the graph"); - } - } - - } -} diff --git a/aai-resources/src/test/java/org/onap/aai/dbgen/ForceDeleteToolTest.java b/aai-resources/src/test/java/org/onap/aai/dbgen/ForceDeleteToolTest.java deleted file mode 100644 index f5b1da4..0000000 --- a/aai-resources/src/test/java/org/onap/aai/dbgen/ForceDeleteToolTest.java +++ /dev/null @@ -1,208 +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.dbgen; - -import com.att.eelf.configuration.EELFLogger; -import com.att.eelf.configuration.EELFManager; -import org.janusgraph.core.JanusGraphTransaction; -import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource; -import org.apache.tinkerpop.gremlin.structure.Edge; -import org.apache.tinkerpop.gremlin.structure.Vertex; -import org.junit.After; -import org.junit.Before; -import org.junit.FixMethodOrder; -import org.junit.Test; -import org.junit.runners.MethodSorters; -import org.onap.aai.AAISetup; -import org.onap.aai.dbmap.AAIGraph; -import org.onap.aai.serialization.db.EdgeRules; - -import java.io.ByteArrayInputStream; -import java.io.InputStream; -import java.util.List; - -import static org.junit.Assert.fail; - -@FixMethodOrder(MethodSorters.NAME_ASCENDING) -public class ForceDeleteToolTest extends AAISetup { - - private static final EELFLogger logger = EELFManager.getInstance().getLogger(ForceDeleteToolTest.class); - - private ForceDeleteTool deleteTool; - - private Vertex cloudRegionVertex; - @Before - public void setup(){ - deleteTool = new ForceDeleteTool(); - deleteTool.SHOULD_EXIT_VM = false; - JanusGraphTransaction transaction = AAIGraph.getInstance().getGraph().newTransaction(); - - EdgeRules edgeRules = EdgeRules.getInstance(); - - boolean success = true; - - try { - - GraphTraversalSource g = transaction.traversal(); - - cloudRegionVertex = g.addV() - .property("aai-node-type", "cloud-region") - .property("cloud-owner", "test-owner") - .property("cloud-region-id", "test-region") - .property("source-of-truth", "JUNIT") - .next(); - - Vertex tenantVertex = g.addV() - .property("aai-node-type", "tenant") - .property("tenant-id", "test-tenant") - .property("source-of-truth", "JUNIT") - .next(); - - Vertex pserverVertex = g.addV() - .property("aai-node-type", "pserver") - .property("hostname", "test-pserver") - .property("in-maint", false) - .property("source-of-truth", "JUNIT") - .next(); - - edgeRules.addTreeEdge(g, cloudRegionVertex, tenantVertex); - edgeRules.addEdge(g, cloudRegionVertex, pserverVertex); - - } catch(Exception ex){ - success = false; - logger.error("Unable to create the vertexes", ex); - } finally { - if(success){ - transaction.commit(); - } else { - transaction.rollback(); - fail("Unable to setup the graph"); - } - } - - - } - - @Test - public void testCollectDataForVertex(){ - - String [] args = { - - "-action", - "COLLECT_DATA", - "-userId", - "someuser", - "-params4Collect", - "cloud-owner|test-owner" - }; - - deleteTool.main(args); - } - - @Test - public void testDeleteNode(){ - - String id = cloudRegionVertex.id().toString(); - - String [] args = { - - "-action", - "DELETE_NODE", - "-userId", - "someuser", - "-vertexId", - id - }; - - deleteTool.main(args); - } - - @Test - public void testCollectDataForEdge(){ - - JanusGraphTransaction transaction = AAIGraph.getInstance().getGraph().newTransaction(); - GraphTraversalSource g = transaction.traversal(); - List<Edge> edges = g.E().toList(); - String cloudRegionToPserverId = edges.get(0).id().toString(); - - String [] args = { - - "-action", - "COLLECT_DATA", - "-userId", - "someuser", - "-edgeId", - cloudRegionToPserverId - }; - - deleteTool.main(args); - } - - @Test - public void testDeleteForEdge(){ - - InputStream systemInputStream = System.in; - ByteArrayInputStream in = new ByteArrayInputStream("y".getBytes()); - System.setIn(in); - JanusGraphTransaction transaction = AAIGraph.getInstance().getGraph().newTransaction(); - GraphTraversalSource g = transaction.traversal(); - List<Edge> edges = g.E().toList(); - String cloudRegionToPserverId = edges.get(0).id().toString(); - - String [] args = { - - "-action", - "DELETE_EDGE", - "-userId", - "someuser", - "-edgeId", - cloudRegionToPserverId - }; - - deleteTool.main(args); - System.setIn(systemInputStream); - } - @After - public void tearDown(){ - - JanusGraphTransaction transaction = AAIGraph.getInstance().getGraph().newTransaction(); - boolean success = true; - - try { - - GraphTraversalSource g = transaction.traversal(); - - g.V().has("source-of-truth", "JUNIT") - .toList() - .forEach(v -> v.remove()); - - } catch(Exception ex){ - success = false; - logger.error("Unable to remove the vertexes", ex); - } finally { - if(success){ - transaction.commit(); - } else { - transaction.rollback(); - fail("Unable to teardown the graph"); - } - } - } -} diff --git a/aai-resources/src/test/java/org/onap/aai/dbgen/tags/UpdateEdgeTagsTest.java b/aai-resources/src/test/java/org/onap/aai/dbgen/tags/UpdateEdgeTagsTest.java deleted file mode 100644 index 89c4955..0000000 --- a/aai-resources/src/test/java/org/onap/aai/dbgen/tags/UpdateEdgeTagsTest.java +++ /dev/null @@ -1,228 +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.dbgen.tags; - -import org.janusgraph.core.JanusGraphFactory; -import org.janusgraph.core.JanusGraph; -import org.janusgraph.core.schema.JanusGraphManagement; -import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource; -import org.apache.tinkerpop.gremlin.structure.Direction; -import org.apache.tinkerpop.gremlin.structure.Edge; -import org.apache.tinkerpop.gremlin.structure.Graph; -import org.apache.tinkerpop.gremlin.structure.Vertex; -import org.junit.After; -import org.junit.AfterClass; -import org.junit.Before; -import org.junit.BeforeClass; -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.ExpectedException; -import org.mockito.Mockito; -import org.onap.aai.AAISetup; -import org.onap.aai.db.props.AAIProperties; -import org.onap.aai.dbmap.AAIGraph; -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.AAIDirection; -import org.onap.aai.serialization.db.EdgeProperty; -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.exceptions.AAIException; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; -import static org.mockito.Mockito.spy; -import static org.mockito.Mockito.when; - -import java.util.Iterator; - -public class UpdateEdgeTagsTest extends AAISetup { - - private final static Version version = Version.v12; - private final static ModelType introspectorFactoryType = ModelType.MOXY; - private final static QueryStyle queryStyle = QueryStyle.TRAVERSAL; - private final static DBConnectionType type = DBConnectionType.REALTIME; - private Loader loader; - private TransactionalGraphEngine dbEngine; - private JanusGraph graph; - private JanusGraph passedGraph; - private UpdateEdgeTagsCmd edgeOp; - private GraphTraversalSource g; - private Graph tx; - @Rule - public ExpectedException thrown = ExpectedException.none(); - - @Before - public void setUp() throws Exception { - graph = JanusGraphFactory.build().set("storage.backend","inmemory").open(); - JanusGraphManagement janusgraphManagement = graph.openManagement(); - tx = graph.newTransaction(); - g = tx.traversal(); - loader = LoaderFactory.createLoaderForVersion(introspectorFactoryType, version); - dbEngine = new JanusGraphDBEngine( - queryStyle, - type, - loader); - - Vertex gvnf = g.addV().property(AAIProperties.NODE_TYPE, "generic-vnf") - .property("vnf-id", "test-vnf") - .next(); - - Vertex lInterface = g.addV().property(AAIProperties.NODE_TYPE, "l-interface") - .property("interface-name", "toscaMigration-test-lint") - .next(); - - Vertex logicalLink = g.addV().property(AAIProperties.NODE_TYPE, "logical-link") - .property("link-name", "toscaMigration-logical-link") - .next(); - - - - gvnf.addEdge("hasLInterface", lInterface, EdgeProperty.CONTAINS.toString(), AAIDirection.OUT.toString(), - EdgeProperty.DELETE_OTHER_V.toString(), AAIDirection.NONE.toString()); - - lInterface.addEdge("usesLogicalLink", logicalLink, EdgeProperty.CONTAINS.toString(), AAIDirection.NONE.toString(), - EdgeProperty.DELETE_OTHER_V.toString(), AAIDirection.NONE.toString()); - lInterface.addEdge("sourceLInterface", logicalLink, EdgeProperty.CONTAINS.toString(), AAIDirection.NONE.toString(), - EdgeProperty.DELETE_OTHER_V.toString(), AAIDirection.NONE.toString()); - - Vertex pserver = g.addV("aai-node-type","pserver","hostname","a-name").next(); - Vertex vnfc = g.addV("aai-node-type","vnfc","vnfc-name","a-name").next(); - pserver.addEdge("tosca.relationships.HostedOn", vnfc, EdgeProperty.CONTAINS.toString(), AAIDirection.NONE.toString(), - EdgeProperty.DELETE_OTHER_V.toString(), AAIDirection.NONE.toString()); - GraphTraversalSource traversal = g; - - passedGraph = spy(graph); - when(passedGraph.traversal()).thenReturn(traversal); - - Iterator<Edge> edgeItr = traversal.E(); - while( edgeItr != null && edgeItr.hasNext() ){ - Edge tEdge = edgeItr.next(); - String edLab = tEdge.label().toString(); - System.out.println("key = " + tEdge.inVertex().<String>property("aai-node-type").orElse(null)+"|"+ tEdge.outVertex().<String>property("aai-node-type").orElse(null)+ ", label = " + tEdge.label() - + ", for id = " + tEdge.id().toString() + ", set: "+tEdge.keys()+":"+tEdge.values()); - System.out.println("DEBUG - label = " + edLab); - } - - } - - @After - public void cleanUp() { - tx.tx().rollback(); - graph.close(); - } - - @Test - public void verifyDirectionWasReversed_OriginalGraph() { - - edgeOp = new UpdateEdgeTagsCmd("all", "/updateEdgeTestRules.json"); - edgeOp.setGraph(passedGraph); - try { - edgeOp.execute(); - } catch (AAIException e) { - e.printStackTrace(); - } - Iterator<Edge> edgeItr = g.E(); - while( edgeItr != null && edgeItr.hasNext() ){ - Edge tmpEd = edgeItr.next(); - System.out.println("Edge = " + tmpEd.inVertex().property("aai-node-type") + ", label = " + tmpEd.label() - + ", for id = " + tmpEd.id().toString() +","+tmpEd.keys()+tmpEd.value("contains-other-v")); - try { - System.out.println("Edge prevent-delete = " +tmpEd.value("prevent-delete")); - System.out.println("Edge description = " +tmpEd.value("description")); - } catch (Exception e) {;} finally {;} - } - assertEquals("Graph should have four(4) Edges with contains-other-v=OUT" - , Long.valueOf(4) - , g.E().has("contains-other-v",AAIDirection.IN.toString()).count().next()); - assertEquals("Graph should have zero(0) Edges with contains-other-v=NONE" - , Long.valueOf(0) - , g.E().has("contains-other-v",AAIDirection.NONE.toString()).count().next()); - } - - @Test - public void verifyDirectionWasReversed_withFilter() { - - edgeOp = new UpdateEdgeTagsCmd("vnfc|pserver", "/updateEdgeTestRules.json"); - edgeOp.setGraph(passedGraph); - try { - edgeOp.execute(); - } catch (AAIException e) { - e.printStackTrace(); - } - Iterator<Edge> edgeItr = g.E(); - while( edgeItr != null && edgeItr.hasNext() ){ - Edge tmpEd = edgeItr.next(); - System.out.println("Edge = " + tmpEd.inVertex().property("aai-node-type") + ", label = " + tmpEd.label() - + ", for id = " + tmpEd.id().toString() +","+tmpEd.keys()+tmpEd.value("contains-other-v")); - } - assertEquals("Graph should have one(1) Edges with contains-other-v=OUT" - , Long.valueOf(1) - , g.E().has("contains-other-v",AAIDirection.OUT.toString()).count().next()); - assertEquals("Graph should have one(1) Edges with contains-other-v=IN" - , Long.valueOf(1) - , g.E().has("contains-other-v",AAIDirection.IN.toString()).count().next()); - assertEquals("Graph should have two(2) Edges with contains-other-v=NONE" - , Long.valueOf(2) - , g.E().has("contains-other-v",AAIDirection.NONE.toString()).count().next()); - } - - @Test - public void verifyFaultyRuleFile_MissingEdgeSpec() throws AAIException { - - thrown.expect(AAIException.class); - thrown.expectMessage("No EdgeRule found for nodeTypes: pserver|vnfc|blah"); - - Vertex pserver = g.V().has(AAIProperties.NODE_TYPE, "pserver").has("hostname", "a-name").next(); - Vertex vnfc = g.V().has(AAIProperties.NODE_TYPE,"vnfc").has("vnfc-name","a-name").next(); - pserver.addEdge("blah", vnfc, EdgeProperty.CONTAINS.toString(), AAIDirection.NONE.toString(), - EdgeProperty.DELETE_OTHER_V.toString(), AAIDirection.NONE.toString()); - //Edge "blah" is not found in updateEdgeTestRules.json - edgeOp = new UpdateEdgeTagsCmd("all", "/updateEdgeTestRules.json"); - edgeOp.setGraph(passedGraph); - edgeOp.execute(); - } - - @Test - public void verifyNewPropertyWasNOTAdded() { - //Edge rules in updateEdgeTestRules.json have "description" and "newProperty" - // but they don't transfer - edgeOp = new UpdateEdgeTagsCmd("all", "/updateEdgeTestRules.json"); - edgeOp.setGraph(passedGraph); - try { - edgeOp.execute(); - } catch (AAIException e) { - e.printStackTrace(); - } - assertEquals("Graph could have zero(4) Edges with newProperty=newValue" - , Long.valueOf(0) - , g.E().has("newProperty","newValue").count().next()); - assertEquals("Graph should have one(1) Edge with description=A l-interface/logical-link(1) edge description" - , Long.valueOf(0) - , g.E().has("description","A l-interface/logical-link(0) edge description").count().next()); - } -} - -
\ No newline at end of file diff --git a/aai-resources/src/test/java/org/onap/aai/migration/EdgeSwingMigratorTest.java b/aai-resources/src/test/java/org/onap/aai/migration/EdgeSwingMigratorTest.java deleted file mode 100644 index 89da7fa..0000000 --- a/aai-resources/src/test/java/org/onap/aai/migration/EdgeSwingMigratorTest.java +++ /dev/null @@ -1,258 +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.migration; - -import static org.junit.Assert.*; -import static org.mockito.Mockito.spy; -import static org.mockito.Mockito.when; - -import java.util.ArrayList; -import java.util.HashMap; -import java.util.Iterator; -import java.util.List; -import java.util.Optional; - -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.Direction; -import org.apache.tinkerpop.gremlin.structure.Vertex; -import org.apache.tinkerpop.gremlin.structure.Edge; -import org.apache.tinkerpop.gremlin.structure.Property; -import org.javatuples.Pair; -import org.junit.After; -import org.junit.Before; -import org.junit.Test; -import org.mockito.Mockito; -import org.onap.aai.AAISetup; -import org.onap.aai.db.props.AAIProperties; -import org.onap.aai.dbmap.AAIGraph; -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.EdgeRules; -import org.onap.aai.serialization.engines.QueryStyle; -import org.onap.aai.serialization.engines.JanusGraphDBEngine; -import org.onap.aai.serialization.engines.TransactionalGraphEngine; - -import org.janusgraph.core.JanusGraphFactory; -import org.janusgraph.core.JanusGraph; -import org.janusgraph.core.JanusGraphTransaction; -import org.janusgraph.core.schema.JanusGraphManagement; - -public class EdgeSwingMigratorTest extends AAISetup { - - 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; - private Loader loader; - private TransactionalGraphEngine dbEngine; - private JanusGraph graph; - private GraphTraversalSource g; - private JanusGraphTransaction tx; - private MockEdgeSwingMigrator migration; - private EdgeRules rules; - private Vertex modelVer1 = null; - private Vertex modelVer3 = null; - - - @Before - public void setUp() throws Exception { - graph = JanusGraphFactory.build().set("storage.backend","inmemory").open(); - JanusGraphManagement janusgraphManagement = graph.openManagement(); - tx = graph.newTransaction(); - g = graph.traversal(); - loader = LoaderFactory.createLoaderForVersion(introspectorFactoryType, version); - dbEngine = new JanusGraphDBEngine( - queryStyle, - type, - loader); - rules = EdgeRules.getInstance(); - createFirstVertexAndRelatedVertexes(); - TransactionalGraphEngine spy = spy(dbEngine); - TransactionalGraphEngine.Admin adminSpy = spy(dbEngine.asAdmin()); - GraphTraversalSource traversal = g; - when(spy.asAdmin()).thenReturn(adminSpy); - when(adminSpy.getTraversalSource()).thenReturn(traversal); - Mockito.doReturn(janusgraphManagement).when(adminSpy).getManagementSystem(); - - - migration = new MockEdgeSwingMigrator(spy); - migration.run(); - } - - private void createFirstVertexAndRelatedVertexes() throws AAIException { - Vertex model1 = g.addV().property("aai-node-type", "model") - .property("model-invariant-id", "model-invariant-id-1") - .property("model-type", "widget") - .next(); - modelVer1 = g.addV().property("aai-node-type", "model-ver") - .property("model-version-id", "model-version-id-1") - .property("model-name", "connector") - .property("model-version", "v1.0") - .next(); - rules.addTreeEdge(g, model1, modelVer1); - - //Create the cousin vertex - modelElement2 which will point to modelVer1 - Vertex model2 = g.addV().property("aai-node-type", "model") - .property("model-invariant-id", "model-invariant-id-2") - .property("model-type", "resource") - .next(); - Vertex modelVer2 = g.addV().property("aai-node-type", "model-ver") - .property("model-version-id", "model-version-id-2") - .property("model-name", "resourceModTestVer") - .property("model-version", "v1.0") - .next(); - rules.addTreeEdge(g, model2, modelVer2); - Vertex modelElement2 = g.addV().property("aai-node-type", "model-element") - .property("model-element-uuid", "model-element-uuid-2") - .property("new-data-del-flag", "T") - .property("cardinality", "unbounded") - .next(); - rules.addTreeEdge(g, modelVer2, modelElement2); - rules.addEdge(g, modelVer1, modelElement2); - - Vertex model3 = g.addV().property("aai-node-type", "model") - .property("model-invariant-id", "model-invariant-id-3") - .property("model-type", "widget") - .next(); - modelVer3 = g.addV().property("aai-node-type", "model-ver") - .property("model-version-id", "model-version-id-3") - .property("model-name", "connector") - .property("model-version", "v1.0") - .next(); - rules.addTreeEdge(g, model3, modelVer3); - } - - class MockEdgeSwingMigrator extends EdgeSwingMigrator { - - public MockEdgeSwingMigrator(TransactionalGraphEngine engine) { - super(engine); - } - - @Override - public List<Pair<Vertex, Vertex>> getAffectedNodePairs() { - List<Pair<Vertex, Vertex>> fromToVertPairList = new ArrayList<Pair<Vertex, Vertex>>(); - Vertex fromVert = modelVer1; - Vertex toVert = modelVer3; - fromToVertPairList.add(new Pair<>(fromVert, toVert)); - return fromToVertPairList; - } - - public String getNodeTypeRestriction(){ - return "model-element"; - } - - public String getEdgeLabelRestriction(){ - return "org.onap.relationships.inventory.IsA"; - } - - public String getEdgeDirRestriction(){ - return "IN"; - } - - @Override - public void cleanupAsAppropriate(List<Pair<Vertex, Vertex>> nodePairL) { - // For the scenario we're testing, we would define this to remove the model-ver that - // we moved off of, and also remove its parent model since it was a widget model and - // these are currently one-to-one (model-ver to model). - // - // But what gets cleaned up (if anything) after a node's edges are migrated will vary depending - // on what the edgeSwingMigration is being used for. - - - } - - @Override - public Optional<String[]> getAffectedNodeTypes() { - return Optional.of(new String[]{"model", "model-element", "model-ver"}); - } - - @Override - public String getMigrationName() { - return "MockEdgeSwingMigrator"; - } - } - - @After - public void cleanUp() { - tx.rollback(); - graph.close(); - } - - - - @Test - public void testBelongsToEdgesStillThere() { - assertEquals(true, g.V().has("aai-node-type", "model-ver").has("model-version-id", "model-version-id-1") - .out("org.onap.relationships.inventory.BelongsTo").has("model-invariant-id", "model-invariant-id-1").hasNext()); - assertEquals(true, g.V().has("aai-node-type", "model-ver").has("model-version-id", "model-version-id-3") - .out("org.onap.relationships.inventory.BelongsTo").has("model-invariant-id", "model-invariant-id-3").hasNext()); - assertEquals(true, g.V().has("aai-node-type", "model-element").has("model-element-uuid", "model-element-uuid-2") - .out("org.onap.relationships.inventory.BelongsTo").has("model-version-id", "model-version-id-2").hasNext()); - } - - @Test - public void testThatNewEdgeAdded() { - assertEquals(true, g.V().has("aai-node-type", "model-ver").has("model-version-id", "model-version-id-3") - .in("org.onap.relationships.inventory.IsA").has("model-element-uuid", "model-element-uuid-2").hasNext()); - } - - @Test - public void testThatNewEdgeHasAaiUuidAndDelProperties() { - boolean haveUuidProp = false; - boolean haveDelOtherVProp = false; - GraphTraversal<Vertex, Vertex> modVerTrav = g.V().has("aai-node-type", "model-ver").has("model-version-id", "model-version-id-3"); - while (modVerTrav.hasNext()) { - Vertex modVerVtx = modVerTrav.next(); - Iterator <Edge> edgeIter = modVerVtx.edges(Direction.IN, "org.onap.relationships.inventory.IsA"); - while( edgeIter.hasNext() ){ - Edge oldOutE = edgeIter.next(); - - Iterator <Property<Object>> propsIter2 = oldOutE.properties(); - HashMap<String, String> propMap2 = new HashMap<String,String>(); - while( propsIter2.hasNext() ){ - Property <Object> ep2 = propsIter2.next(); - if( ep2.key().equals("aai-uuid") ){ - haveUuidProp = true; - } - else if( ep2.key().equals("delete-other-v") ){ - haveDelOtherVProp = true; - } - } - } - } - - assertTrue("New IsA edge has aai-uuid property ", haveUuidProp ); - assertTrue("New IsA edge has delete-other-v property ", haveDelOtherVProp ); - } - - - @Test - public void testThatOldEdgeGone() { - assertEquals(false, g.V().has("aai-node-type", "model-ver").has("model-version-id", "model-version-id-1") - .in("org.onap.relationships.inventory.IsA").has("model-element-uuid", "model-element-uuid-2").hasNext()); - } - - -}
\ No newline at end of file diff --git a/aai-resources/src/test/java/org/onap/aai/migration/MigrationControllerInternalTest.java b/aai-resources/src/test/java/org/onap/aai/migration/MigrationControllerInternalTest.java deleted file mode 100644 index 4ba200a..0000000 --- a/aai-resources/src/test/java/org/onap/aai/migration/MigrationControllerInternalTest.java +++ /dev/null @@ -1,281 +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.migration; - -import com.att.eelf.configuration.EELFLogger; -import com.att.eelf.configuration.EELFManager; -import org.janusgraph.core.JanusGraphTransaction; -import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource; -import org.apache.tinkerpop.gremlin.structure.Vertex; -import org.junit.After; -import org.junit.Before; -import org.junit.Test; -import org.onap.aai.AAISetup; -import org.onap.aai.dbmap.AAIGraph; -import org.onap.aai.exceptions.AAIException; -import org.onap.aai.serialization.db.EdgeRules; - -import java.io.ByteArrayOutputStream; -import java.io.PrintStream; - -import static org.hamcrest.MatcherAssert.assertThat; -import static org.hamcrest.core.StringContains.containsString; - -public class MigrationControllerInternalTest extends AAISetup { - - private static final EELFLogger logger = EELFManager.getInstance().getLogger(MigrationControllerInternalTest.class); - - private MigrationControllerInternal migrationControllerInternal; - - @Before - public void setup() throws AAIException { - migrationControllerInternal = new MigrationControllerInternal(); - clearGraph(); - createGraph(); - } - - private void createGraph(){ - - JanusGraphTransaction transaction = AAIGraph.getInstance().getGraph().newTransaction(); - boolean success = true; - - try { - GraphTraversalSource g = transaction.traversal(); - - Vertex servSub1 = g.addV().property("aai-node-type", "service-subscription") - .property("service-type", "DHV") - .property("source-of-truth", "JUNIT") - .next(); - Vertex servinst1 = g.addV().property( "aai-node-type", "service-instance") - .property("service-type", "DHV") - .property("source-of-truth", "JUNIT") - .next(); - Vertex allotedRsrc1 = g.addV().property( "aai-node-type", "allotted-resource") - .property("id","rsrc1") - .property("source-of-truth", "JUNIT") - .next(); - Vertex servinst2 = g.addV().property( "aai-node-type", "service-instance") - .property("service-type", "VVIG") - .property("source-of-truth", "JUNIT") - .next(); - Vertex servSub2 = g.addV().property("aai-node-type", "service-subscription") - .property("service-type", "VVIG") - .property("source-of-truth", "JUNIT") - .next(); - - Vertex genericvnf1 = g.addV().property("aai-node-type", "generic-vnf") - .property("vnf-id", "vnfId1") - .property("source-of-truth", "JUNIT") - .next(); - Vertex vServer1 = g.addV().property("aai-node-type", "vserver") - .property("source-of-truth", "JUNIT") - .next(); - Vertex pServer1 = g.addV().property("aai-node-type", "pserver") - .property("source-of-truth", "JUNIT") - .next(); - Vertex pInterfaceWan1 = g.addV().property("aai-node-type", "p-interface") - .property("interface-name","ge-0/0/10") - .property("source-of-truth", "JUNIT") - .next(); - Vertex tunnelXConnectAll_Wan1 = g.addV().property( "aai-node-type", "tunnel-xconnect") - .property("id", "tunnelXConnectWan1") - .property("bandwidth-up-wan1", "300") - .property("bandwidth-down-wan1", "400") - .property("bandwidth-up-wan2", "500") - .property("bandwidth-down-wan2", "600") - .property("source-of-truth", "JUNIT") - .next(); - - Vertex pLinkWan1 = g.addV().property("aai-node-type", "physical-link") - .property("link-name", "pLinkWan1") - .property("service-provider-bandwidth-up-units", "empty") - .property("service-provider-bandwidth-down-units", "empty") - .property("source-of-truth", "JUNIT") - .next(); - Vertex servSub3 = g.addV().property("aai-node-type", "service-subscription") - .property("service-type", "DHV") - .property("source-of-truth", "JUNIT") - .next(); - Vertex servinst3 = g.addV().property( "aai-node-type", "service-instance") - .property("service-type", "DHV") - .property("source-of-truth", "JUNIT") - .next(); - Vertex allotedRsrc3 = g.addV().property( "aai-node-type", "allotted-resource") - .property("id","rsrc3") - .property("source-of-truth", "JUNIT") - .next(); - Vertex servinst4 = g.addV().property( "aai-node-type", "service-instance") - .property("service-type", "VVIG") - .property("source-of-truth", "JUNIT") - .next(); - Vertex servSub4 = g.addV().property("aai-node-type", "service-subscription") - .property("service-type", "VVIG") - .property("source-of-truth", "JUNIT") - .next(); - - Vertex genericvnf3 = g.addV().property("aai-node-type", "generic-vnf") - .property("vnf-id", "vnfId3") - .property("source-of-truth", "JUNIT") - .next(); - Vertex vServer3 = g.addV().property("aai-node-type", "vserver") - .property("source-of-truth", "JUNIT") - .next(); - Vertex pServer3 = g.addV().property("aai-node-type", "pserver") - .property("source-of-truth", "JUNIT") - .next(); - Vertex pInterfaceWan3 = g.addV().property("aai-node-type", "p-interface") - .property("interface-name","ge-0/0/11") - .property("source-of-truth", "JUNIT") - .next(); - Vertex tunnelXConnectAll_Wan3 = g.addV().property( "aai-node-type", "tunnel-xconnect") - .property("id", "tunnelXConnectWan3") - .property("bandwidth-up-wan1", "300") - .property("bandwidth-down-wan1", "400") - .property("bandwidth-up-wan2", "500") - .property("bandwidth-down-wan2", "600") - .property("source-of-truth", "JUNIT") - .next(); - - Vertex pLinkWan3 = g.addV().property("aai-node-type", "physical-link") - .property("link-name", "pLinkWan3") - .property("service-provider-bandwidth-up-units", "empty") - .property("service-provider-bandwidth-down-units", "empty") - .property("source-of-truth", "JUNIT") - .next(); - - EdgeRules rules = EdgeRules.getInstance(); - - rules.addTreeEdge(g,servSub1,servinst1); - rules.addEdge(g,servinst1,allotedRsrc1); - rules.addTreeEdge(g,servinst2,servSub2); - rules.addTreeEdge(g,allotedRsrc1,servinst2); - - rules.addTreeEdge(g,allotedRsrc1,tunnelXConnectAll_Wan1); - - - rules.addEdge(g,servinst1,genericvnf1); - rules.addEdge(g,genericvnf1,vServer1); - rules.addEdge(g,vServer1,pServer1); - rules.addTreeEdge(g,pServer1,pInterfaceWan1); - rules.addEdge(g,pInterfaceWan1,pLinkWan1); - - rules.addTreeEdge(g,servSub3,servinst3); - rules.addEdge(g,servinst3,allotedRsrc3); - rules.addTreeEdge(g,servinst4,servSub4); - rules.addTreeEdge(g,allotedRsrc3,servinst4); - - rules.addTreeEdge(g,allotedRsrc3,tunnelXConnectAll_Wan3); - - - rules.addEdge(g,servinst3,genericvnf3); - rules.addEdge(g,genericvnf3,vServer3); - rules.addEdge(g,vServer3,pServer3); - rules.addTreeEdge(g,pServer3,pInterfaceWan3); - rules.addEdge(g,pInterfaceWan3,pLinkWan3); - - } catch(Exception ex){ - success = false; - logger.error("Unable to create the graph {}", ex); - } finally { - if(success){ - transaction.commit(); - } else { - transaction.rollback(); - } - - } - } - - @Test - public void testListAllOfMigrations() throws Exception { - PrintStream oldOutputStream = System.out; - final ByteArrayOutputStream myOut = new ByteArrayOutputStream(); - System.setOut(new PrintStream(myOut)); - - String [] args = { - "-c", "./bundleconfig-local/etc/appprops/janusgraph-realtime.properties", - "-l" - }; - - migrationControllerInternal.run(args); - - String content = myOut.toString(); - assertThat(content, containsString("List of all migrations")); - System.setOut(oldOutputStream); - } - - @Test - public void testRunSpecificMigration() throws Exception { - String [] args = "-c ./bundleconfig-local/etc/appprops/janusgraph-realtime.properties -m SDWANSpeedChangeMigration".split(" "); - migrationControllerInternal.run(args); - } - - @Test - public void testRunSpecificMigrationAndCommit() throws Exception { - String [] args = { - "-c", "./bundleconfig-local/etc/appprops/janusgraph-realtime.properties", - "-m", "SDWANSpeedChangeMigration", - "--commit" - }; - migrationControllerInternal.run(args); - } - - @Test - public void testRunSpecificMigrationFromLoadingSnapshotAndCommit() throws Exception{ - clearGraph(); - String [] args = { - "-d", "./snapshots/sdwan_test_migration.graphson", - "-c", "./bundleconfig-local/etc/appprops/janusgraph-realtime.properties", - "-m", "SDWANSpeedChangeMigration" - }; - migrationControllerInternal.run(args); - } - - @After - public void tearDown(){ - clearGraph(); - } - - public void clearGraph(){ - - JanusGraphTransaction janusgraphTransaction = AAIGraph.getInstance().getGraph().newTransaction(); - - boolean success = true; - - try { - GraphTraversalSource g = janusgraphTransaction.traversal(); - - g.V().has("source-of-truth", "JUNIT") - .toList() - .forEach((v) -> v.remove()); - - } catch(Exception ex) { - success = false; - logger.error("Unable to remove all of the vertexes", ex); - } finally { - if(success){ - janusgraphTransaction.commit(); - } else { - janusgraphTransaction.rollback(); - } - } - - } -}
\ No newline at end of file diff --git a/aai-resources/src/test/java/org/onap/aai/migration/PropertyMigratorTest.java b/aai-resources/src/test/java/org/onap/aai/migration/PropertyMigratorTest.java deleted file mode 100644 index 2b7d58d..0000000 --- a/aai-resources/src/test/java/org/onap/aai/migration/PropertyMigratorTest.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.migration; - -import com.att.eelf.configuration.EELFLogger; -import com.att.eelf.configuration.EELFManager; -import org.janusgraph.core.Cardinality; -import org.janusgraph.core.JanusGraphTransaction; -import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource; -import org.apache.tinkerpop.gremlin.structure.Vertex; -import org.junit.Before; -import org.junit.Test; -import org.onap.aai.AAISetup; -import org.onap.aai.dbmap.AAIGraph; -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.engines.QueryStyle; -import org.onap.aai.serialization.engines.JanusGraphDBEngine; -import org.onap.aai.serialization.engines.TransactionalGraphEngine; - -import java.util.List; -import java.util.Optional; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; - -public class PropertyMigratorTest extends AAISetup { - - private static final EELFLogger logger = EELFManager.getInstance().getLogger(PropertyMigratorTest.class); - - public static class PserverPropMigrator extends PropertyMigrator { - - public PserverPropMigrator(TransactionalGraphEngine engine, String oldName, String newName, Class<?> type, Cardinality cardinality) { - super(engine, oldName, newName, type, cardinality); - } - - @Override - public boolean isIndexed() { - return true; - } - - @Override - public Optional<String[]> getAffectedNodeTypes() { - return Optional.of(new String[]{ "pserver" }); - } - - @Override - public String getMigrationName() { - return "PserverPropMigrator"; - } - } - - @Before - public void setup(){ - AAIGraph.getInstance(); - JanusGraphTransaction janusgraphTransaction = AAIGraph.getInstance().getGraph().newTransaction(); - boolean success = true; - - try { - GraphTraversalSource g = janusgraphTransaction.traversal(); - g.addV() - .property("aai-node-type", "pserver") - .property("hostname", "fake-hostname") - .property("inv-status", "some status") - .property("source-of-truth", "JUNIT") - .next(); - } catch(Exception ex){ - success = false; - logger.error("Unable to commit the transaction {}", ex); - - } finally { - if(success){ - janusgraphTransaction.commit(); - } else { - janusgraphTransaction.rollback(); - } - - } - } - - @Test - public void testAfterPropertyMigration(){ - - String oldPropName = "inv-status"; - String newPropName = "inventory-status"; - - Loader loader = LoaderFactory.createLoaderForVersion(ModelType.MOXY, Version.v11); - JanusGraphDBEngine dbEngine = new JanusGraphDBEngine(QueryStyle.TRAVERSAL, DBConnectionType.REALTIME, loader); - dbEngine.startTransaction(); - - PropertyMigrator propertyMigrator = new PserverPropMigrator(dbEngine, oldPropName, newPropName, String.class, Cardinality.SINGLE); - propertyMigrator.run(); - assertEquals("Expecting the property to be success", Status.SUCCESS, propertyMigrator.getStatus()); - dbEngine.commit(); - - JanusGraphTransaction janusgraphTransaction = AAIGraph.getInstance().getGraph().newTransaction(); - GraphTraversalSource g = janusgraphTransaction.traversal(); - - List<Vertex> oldVList = g.V().has("aai-node-type", "pserver").has(oldPropName).toList(); - List<Vertex> newVList = g.V().has("aai-node-type", "pserver").has(newPropName).toList(); - - assertEquals("Expecting the vertex list with old property to be zero", 0, oldVList.size()); - assertEquals("Expecting the vertex list with new property to be 1", 1, newVList.size()); - assertEquals("Expecting the equipment type to be some equipment", "some status", newVList.get(0).property(newPropName).value()); - } -}
\ No newline at end of file diff --git a/aai-resources/src/test/java/org/onap/aai/migration/ValueMigratorTest.java b/aai-resources/src/test/java/org/onap/aai/migration/ValueMigratorTest.java deleted file mode 100644 index 7850fd2..0000000 --- a/aai-resources/src/test/java/org/onap/aai/migration/ValueMigratorTest.java +++ /dev/null @@ -1,154 +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.migration; - -import com.att.eelf.configuration.EELFLogger; -import com.att.eelf.configuration.EELFManager; -import org.janusgraph.core.JanusGraphFactory; -import org.janusgraph.core.JanusGraph; -import org.janusgraph.core.JanusGraphTransaction; -import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource; -import org.junit.Before; -import org.junit.Test; -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.EdgeRules; -import org.onap.aai.serialization.engines.QueryStyle; -import org.onap.aai.serialization.engines.JanusGraphDBEngine; -import org.onap.aai.serialization.engines.TransactionalGraphEngine; - -import static org.mockito.Mockito.spy; -import static org.mockito.Mockito.when; - -import java.util.HashMap; -import java.util.Map; -import java.util.Optional; - -import static org.junit.Assert.assertTrue; -import static org.junit.Assert.assertEquals; - -public class ValueMigratorTest extends AAISetup{ - - public static class SampleValueMigrator extends ValueMigrator { - public SampleValueMigrator(TransactionalGraphEngine engine, Map map, Boolean updateExistingValues){ - super(engine, map, updateExistingValues); - } - @Override - public Status getStatus() { - return Status.SUCCESS; - } - @Override - public Optional<String[]> getAffectedNodeTypes() { - return null; - } - @Override - public String getMigrationName() { - return "SampleValueMigrator"; - } - } - - private final static Version version = Version.v10; - private final static ModelType introspectorFactoryType = ModelType.MOXY; - private final static QueryStyle queryStyle = QueryStyle.TRAVERSAL; - private final static DBConnectionType type = DBConnectionType.REALTIME; - private Loader loader; - private TransactionalGraphEngine dbEngine; - private JanusGraph graph; - private SampleValueMigrator migration; - private EdgeRules rules; - private GraphTraversalSource g; - private JanusGraphTransaction tx; - private SampleValueMigrator existingValuesMigration; - - @Before - public void setup() throws Exception{ - graph = JanusGraphFactory.build().set("storage.backend", "inmemory").open(); - tx = graph.newTransaction(); - g = tx.traversal(); - loader = LoaderFactory.createLoaderForVersion(introspectorFactoryType, version); - dbEngine = new JanusGraphDBEngine( - queryStyle, - type, - loader); - rules = EdgeRules.getInstance(); - Map<String, Map> map = new HashMap<>(); - Map<String, Boolean> pair = new HashMap<>(); - pair.put("in-maint", true); - map.put("pserver", pair); - map.put("pnf", pair); - g.addV().property("aai-node-type", "pserver") - .property("pserver-id", "pserver0") - .next(); - g.addV().property("aai-node-type", "pserver") - .property("pserver-id", "pserver1") - .property("in-maint", "") - .next(); - g.addV().property("aai-node-type", "pserver") - .property("pserver-id", "pserver2") - .property("in-maint", false) - .next(); - g.addV().property("aai-node-type", "pnf") - .property("pnf-name","pnf1" ) - .property("in-maint", false) - .next(); - TransactionalGraphEngine spy = spy(dbEngine); - TransactionalGraphEngine.Admin adminSpy = spy(dbEngine.asAdmin()); - GraphTraversalSource traversal = g; - when(spy.asAdmin()).thenReturn(adminSpy); - when(adminSpy.getTraversalSource()).thenReturn(traversal); - migration = new SampleValueMigrator(spy, map, false); - migration.run(); - - map = new HashMap<>(); - pair = new HashMap<>(); - pair.put("in-maint", true); - map.put("pnf", pair); - existingValuesMigration = new SampleValueMigrator(spy, map, true); - existingValuesMigration.run(); - } - - @Test - public void testMissingProperty(){ - assertTrue("Value of pnf should be updated since the property doesn't exist", - g.V().has("aai-node-type", "pserver").has("pserver-id", "pserver0").has("in-maint", true).hasNext()); - } - - @Test - public void testExistingValue() { - assertTrue("Value of pserver shouldn't be updated since it already exists", - g.V().has("aai-node-type", "pserver").has("pserver-id", "pserver2").has("in-maint", false).hasNext()); - } - - @Test - public void testEmptyValue() { - assertTrue("Value of pserver should be updated since the value is an empty string", - g.V().has("aai-node-type", "pserver").has("pserver-id", "pserver1").has("in-maint", true).hasNext()); - } - - @Test - public void testUpdateExistingValues() { - assertTrue("Value of pnf should be updated even though it already exists", - g.V().has("aai-node-type", "pnf").has("pnf-name", "pnf1").has("in-maint", true).hasNext()); - } -} diff --git a/aai-resources/src/test/java/org/onap/aai/migration/VertexMergeTest.java b/aai-resources/src/test/java/org/onap/aai/migration/VertexMergeTest.java deleted file mode 100644 index 90cd921..0000000 --- a/aai-resources/src/test/java/org/onap/aai/migration/VertexMergeTest.java +++ /dev/null @@ -1,179 +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.migration; - -import org.janusgraph.core.Cardinality; -import org.janusgraph.core.JanusGraphFactory; -import org.janusgraph.core.JanusGraph; -import org.janusgraph.core.schema.JanusGraphManagement; -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.*; -import org.onap.aai.AAISetup; -import org.onap.aai.db.props.AAIProperties; -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.db.EdgeRules; -import org.onap.aai.serialization.engines.QueryStyle; -import org.onap.aai.serialization.engines.JanusGraphDBEngine; -import org.onap.aai.serialization.engines.TransactionalGraphEngine; - -import java.io.UnsupportedEncodingException; -import java.util.*; - -import static org.hamcrest.collection.IsIterableContainingInAnyOrder.containsInAnyOrder; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertThat; -import static org.mockito.Mockito.spy; -import static org.mockito.Mockito.when; - -@Ignore -public class VertexMergeTest extends AAISetup { - - - private final static Version version = Version.v10; - private final static ModelType introspectorFactoryType = ModelType.MOXY; - private final static QueryStyle queryStyle = QueryStyle.TRAVERSAL; - private final static DBConnectionType type = DBConnectionType.REALTIME; - private Loader loader; - private TransactionalGraphEngine dbEngine; - private JanusGraph graph; - private EdgeRules rules; - private GraphTraversalSource g; - private Graph tx; - - @Before - public void setUp() throws Exception { - graph = JanusGraphFactory.build().set("storage.backend","inmemory").open(); - tx = graph.newTransaction(); - g = tx.traversal(); - loader = LoaderFactory.createLoaderForVersion(introspectorFactoryType, version); - dbEngine = new JanusGraphDBEngine( - queryStyle, - type, - loader); - rules = EdgeRules.getInstance(); - - JanusGraphManagement mgmt = graph.openManagement(); - mgmt.makePropertyKey("test-list").dataType(String.class).cardinality(Cardinality.SET).make(); - mgmt.commit(); - Vertex pserverSkeleton = g.addV().property("aai-node-type", "pserver").property("hostname", "TEST1") - .property("source-of-truth", "AAI-EXTENSIONS").property("fqdn", "test1.com").property("test-list", "value1").next(); - - Vertex pInterface1 = g.addV().property("aai-node-type", "p-interface").property("interface-name", "p-interface1") - .property(AAIProperties.AAI_URI, "/cloud-infrastructure/pservers/pserver/TEST1/p-interfaces/p-interface/p-interface1").next(); - - Vertex pInterface2 = g.addV().property("aai-node-type", "p-interface").property("interface-name", "p-interface2") - .property(AAIProperties.AAI_URI, "/cloud-infrastructure/pservers/pserver/TEST1/p-interfaces/p-interface/p-interface2").next(); - - Vertex pInterface2Secondary = g.addV().property("aai-node-type", "p-interface").property("interface-name", "p-interface2").property("special-prop", "value") - .property(AAIProperties.AAI_URI, "/cloud-infrastructure/pservers/pserver/TEST1/p-interfaces/p-interface/p-interface2").next(); - - Vertex lInterface1 = g.addV().property("aai-node-type", "l-interface").property("interface-name", "l-interface1").property("special-prop", "value") - .property(AAIProperties.AAI_URI, "/cloud-infrastructure/pservers/pserver/TEST1/p-interfaces/p-interface/p-interface2/l-interfaces/l-interface/l-interface1").next(); - - Vertex lInterface1Canopi = g.addV().property("aai-node-type", "l-interface").property("interface-name", "l-interface1") - .property(AAIProperties.AAI_URI, "/cloud-infrastructure/pservers/pserver/TEST1/p-interfaces/p-interface/p-interface2/l-interfaces/l-interface/l-interface1").next(); - - Vertex logicalLink = g.addV().property("aai-node-type", "logical-link").property("link-name", "logical-link1") - .property(AAIProperties.AAI_URI, "/network/logical-links/logical-link/logical-link1").next(); - Vertex pserverCanopi = g.addV().property("aai-node-type", "pserver").property("hostname", "TEST1") - .property("source-of-truth", "CANOPI-WS").property("fqdn", "test2.com").property("test-list", "value2").next(); - - Vertex complex1 = g.addV().property("aai-node-type", "complex").property("physical-location-id", "complex1") - .property("source-of-truth", "RO").next(); - - Vertex complex2 = g.addV().property("aai-node-type", "complex").property("physical-location-id", "complex2") - .property("source-of-truth", "RCT").next(); - - Vertex vserver1 = g.addV().property("aai-node-type", "vserver").property("vserver-id", "vserver1") - .property("source-of-truth", "RO").next(); - - Vertex vserver2 = g.addV().property("aai-node-type", "vserver").property("vserver-id", "vserver2") - .property("source-of-truth", "RCT").next(); - Vertex vserver3 = g.addV().property("aai-node-type", "vserver").property("vserver-id", "vserver3") - .property("source-of-truth", "RCT").next(); - Vertex vserver4 = g.addV().property("aai-node-type", "vserver").property("vserver-id", "vserver4") - .property("source-of-truth", "RCT").next(); - Vertex vserver5 = g.addV().property("aai-node-type", "vserver").property("vserver-id", "vserver5") - .property("source-of-truth", "RCT").next(); - - - rules.addEdge(g, pserverSkeleton, complex1); - rules.addEdge(g, pserverSkeleton, vserver1); - rules.addEdge(g, pserverSkeleton, vserver2); - rules.addTreeEdge(g, pserverSkeleton, pInterface1); - rules.addTreeEdge(g, pserverSkeleton, pInterface2Secondary); - rules.addTreeEdge(g, pInterface2Secondary, lInterface1); - rules.addEdge(g, lInterface1, logicalLink); - rules.addEdge(g, pserverCanopi, complex2); - rules.addEdge(g, pserverCanopi, vserver3); - rules.addEdge(g, pserverCanopi, vserver4); - rules.addEdge(g, pserverCanopi, vserver5); - rules.addTreeEdge(g, pserverCanopi, pInterface2); - rules.addTreeEdge(g, pInterface2, lInterface1Canopi); - - Map<String, Set<String>> forceCopy = new HashMap<>(); - Set<String> forceSet = new HashSet<>(); - forceSet.add("fqdn"); - forceCopy.put("pserver", forceSet); - - TransactionalGraphEngine spy = spy(dbEngine); - TransactionalGraphEngine.Admin adminSpy = spy(dbEngine.asAdmin()); - GraphTraversalSource traversal = g; - GraphTraversalSource readOnly = g; - when(spy.asAdmin()).thenReturn(adminSpy); - when(adminSpy.getTraversalSource()).thenReturn(traversal); - when(adminSpy.getReadOnlyTraversalSource()).thenReturn(readOnly); - DBSerializer serializer = new DBSerializer(version, spy, introspectorFactoryType, "Merge test"); - - VertexMerge merge = new VertexMerge.Builder(loader, spy, serializer).build(); - merge.performMerge(pserverCanopi, pserverSkeleton, forceCopy); - } - - @After - public void cleanUp() { - tx.tx().rollback(); - graph.close(); - } - - @Test - public void run() throws UnsupportedEncodingException { - - assertEquals("pserver merged", false, g.V().has("hostname", "TEST1").has("source-of-truth", "AAI-EXTENSIONS").hasNext()); - assertThat("pserver list merge", Arrays.asList("value1", "value2"), containsInAnyOrder(g.V().has("hostname", "TEST1").values("test-list").toList().toArray())); - assertEquals("canopi pserver has one edge to vserver2", 1, g.V().has("hostname", "TEST1").both().has("vserver-id", "vserver2").toList().size()); - assertEquals("canopi pserver has one edge to vserver1", 1, g.V().has("hostname", "TEST1").both().has("vserver-id", "vserver1").toList().size()); - assertEquals("canopi pserver retained edge to complex2", true, g.V().has("hostname", "TEST1").both().has("physical-location-id", "complex2").hasNext()); - assertEquals("canopi pserver received forced prop", "test1.com", g.V().has("hostname", "TEST1").values("fqdn").next()); - assertEquals("pserver skeleton child copied", true, g.V().has("hostname", "TEST1").both().has("interface-name", "p-interface1").hasNext()); - assertEquals("pserver skeleton child merged", true, g.V().has("hostname", "TEST1").both().has("interface-name", "p-interface2").has("special-prop", "value").hasNext()); - assertEquals("l-interface child merged", true, g.V().has("hostname", "TEST1").both().has("interface-name", "p-interface2").both().has("interface-name", "l-interface1").has("special-prop", "value").hasNext()); - assertEquals("l-interface child cousin edge merged", true, g.V().has("hostname", "TEST1").both().has("interface-name", "p-interface2").both().has("interface-name", "l-interface1").both().has("link-name", "logical-link1").hasNext()); - assertEquals("one l-interface1 found", new Long(1), g.V().has("interface-name", "l-interface1").count().next()); - assertEquals("one p-interface2 found", new Long(1), g.V().has("interface-name", "p-interface2").count().next()); - - } -} diff --git a/aai-resources/src/test/java/org/onap/aai/migration/v12/ContainmentDeleteOtherVPropertyMigrationTest.java b/aai-resources/src/test/java/org/onap/aai/migration/v12/ContainmentDeleteOtherVPropertyMigrationTest.java deleted file mode 100644 index f80229c..0000000 --- a/aai-resources/src/test/java/org/onap/aai/migration/v12/ContainmentDeleteOtherVPropertyMigrationTest.java +++ /dev/null @@ -1,112 +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.migration.v12; - -import org.janusgraph.core.JanusGraphFactory; -import org.janusgraph.core.JanusGraph; -import org.janusgraph.core.schema.JanusGraphManagement; -import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource; -import org.apache.tinkerpop.gremlin.structure.Edge; -import org.apache.tinkerpop.gremlin.structure.Graph; -import org.apache.tinkerpop.gremlin.structure.Vertex; -import org.junit.After; -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.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.AAIDirection; -import org.onap.aai.serialization.db.EdgeProperty; -import org.onap.aai.serialization.engines.QueryStyle; -import org.onap.aai.serialization.engines.JanusGraphDBEngine; -import org.onap.aai.serialization.engines.TransactionalGraphEngine; - -import static org.junit.Assert.assertEquals; -import static org.mockito.Mockito.spy; -import static org.mockito.Mockito.when; - -public class ContainmentDeleteOtherVPropertyMigrationTest extends AAISetup { - - private final static Version version = Version.v12; - private final static ModelType introspectorFactoryType = ModelType.MOXY; - private final static QueryStyle queryStyle = QueryStyle.TRAVERSAL; - private final static DBConnectionType type = DBConnectionType.REALTIME; - private Loader loader; - private TransactionalGraphEngine dbEngine; - private JanusGraph graph; - private ContainmentDeleteOtherVPropertyMigration migration; - private GraphTraversalSource g; - private Graph tx; - - @Before - public void setUp() throws Exception { - graph = JanusGraphFactory.build().set("storage.backend","inmemory").open(); - JanusGraphManagement janusgraphManagement = graph.openManagement(); - tx = graph.newTransaction(); - g = tx.traversal(); - loader = LoaderFactory.createLoaderForVersion(introspectorFactoryType, version); - dbEngine = new JanusGraphDBEngine( - queryStyle, - type, - loader); - Vertex v = g.addV().property("aai-node-type", "generic-vnf") - .property("vnf-id", "delcontains-test-vnf") - .next(); - Vertex v2 = g.addV().property("aai-node-type", "l-interface") - .property("interface-name", "delcontains-test-lint") - .next(); - Edge e = v.addEdge("hasLInterface", v2, EdgeProperty.CONTAINS.toString(), AAIDirection.OUT.toString(), - EdgeProperty.DELETE_OTHER_V.toString(), AAIDirection.NONE.toString()); - - Vertex v3 = g.addV().property("aai-node-type", "allotted-resource").next(); - - Edge e2 = v2.addEdge("uses", v3, EdgeProperty.CONTAINS.toString(), AAIDirection.NONE.toString(), - EdgeProperty.DELETE_OTHER_V.toString(), AAIDirection.NONE.toString()); - TransactionalGraphEngine spy = spy(dbEngine); - TransactionalGraphEngine.Admin adminSpy = spy(dbEngine.asAdmin()); - GraphTraversalSource traversal = g; - when(spy.asAdmin()).thenReturn(adminSpy); - when(adminSpy.getTraversalSource()).thenReturn(traversal); - Mockito.doReturn(janusgraphManagement).when(adminSpy).getManagementSystem(); - migration = new ContainmentDeleteOtherVPropertyMigration(spy, "/edgeMigrationTestRules.json"); - migration.run(); - } - - @After - public void cleanUp() { - tx.tx().rollback(); - graph.close(); - } - - @Test - public void run() { - assertEquals("del other now OUT", true, - g.E().hasLabel("hasLInterface").has(EdgeProperty.DELETE_OTHER_V.toString(), AAIDirection.OUT.toString()).hasNext()); - assertEquals("contains val still same", true, - g.E().hasLabel("hasLInterface").has(EdgeProperty.CONTAINS.toString(), AAIDirection.OUT.toString()).hasNext()); - assertEquals("non-containment unchanged", true, - g.E().hasLabel("uses").has(EdgeProperty.DELETE_OTHER_V.toString(), AAIDirection.NONE.toString()).hasNext()); - } - -} diff --git a/aai-resources/src/test/java/org/onap/aai/migration/v12/MigrateDataFromASDCToConfigurationTest.java b/aai-resources/src/test/java/org/onap/aai/migration/v12/MigrateDataFromASDCToConfigurationTest.java deleted file mode 100644 index 4fbed4c..0000000 --- a/aai-resources/src/test/java/org/onap/aai/migration/v12/MigrateDataFromASDCToConfigurationTest.java +++ /dev/null @@ -1,172 +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.migration.v12; - -import org.janusgraph.core.JanusGraphFactory; -import org.janusgraph.core.JanusGraph; -import org.janusgraph.core.JanusGraphTransaction; -import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource; -import org.apache.tinkerpop.gremlin.structure.Vertex; -import org.junit.After; -import org.junit.Before; -import org.junit.Test; -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.EdgeRules; -import org.onap.aai.serialization.engines.QueryStyle; -import org.onap.aai.serialization.engines.JanusGraphDBEngine; -import org.onap.aai.serialization.engines.TransactionalGraphEngine; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotEquals; -import static org.mockito.Mockito.spy; -import static org.mockito.Mockito.when; - -public class MigrateDataFromASDCToConfigurationTest extends AAISetup { - - private final static Version version = Version.v12; - private final static ModelType introspectorFactoryType = ModelType.MOXY; - private final static QueryStyle queryStyle = QueryStyle.TRAVERSAL; - private final static DBConnectionType type = DBConnectionType.REALTIME; - private Loader loader; - private TransactionalGraphEngine dbEngine; - private JanusGraph graph; - private MigrateDataFromASDCToConfiguration migration; - private EdgeRules rules; - private GraphTraversalSource g; - private JanusGraphTransaction tx; - Vertex configuration; - Vertex configuration2; - Vertex configuration3; - Vertex configuration4; - - private boolean success = true; - private String entitlementPoolUuid = ""; - private final String PARENT_NODE_TYPE = "generic-vnf"; - private String VNT = ""; - - @Before - public void setUp() throws Exception { - graph = JanusGraphFactory.build().set("storage.backend","inmemory").open(); - tx = graph.newTransaction(); - g = tx.traversal(); - loader = LoaderFactory.createLoaderForVersion(introspectorFactoryType, version); - dbEngine = new JanusGraphDBEngine( - queryStyle, - type, - loader); - rules = EdgeRules.getInstance(); - Vertex genericvnf1 = g.addV().property("aai-node-type", "generic-vnf") - .property("vnf-id", "vnfId1") - .property("vnf-type","vHNF") - .next(); - - Vertex genericvnf2 = g.addV().property("aai-node-type", "generic-vnf") - .property("vnf-id", "vnfId2") - .property("vnf-type","vHNF") - .next(); - - Vertex entitlement1 = g.addV().property("aai-node-type", "entitlement") - .property("group-uuid", "some-uuid") - .next(); - - Vertex serviceInstance1 = g.addV().property("aai-node-type", "service-instance") - .property("service-instance-id", "servinstanceTestId1") - .next(); - - configuration = g.addV().property("aai-node-type", "configuration") - .property("configuration-id", "configurationIdGraph") - .property("vendor-allowed-max-bandwidth", "20") - .next(); - configuration3 = g.addV().property("aai-node-type", "configuration") - .property("configuration-id", "configurationIdGraph3") - .property("vendor-allowed-max-bandwidth", "15") - .next(); - configuration2 = g.addV().property("aai-node-type", "configuration") - .property("configuration-id", "configurationIdGraph2") - .property("vendor-allowed-max-bandwidth", "25") - .next(); - configuration4 = g.addV().property("aai-node-type", "configuration") - .property("configuration-id", "configurationIdGraph4") - .property("vendor-allowed-max-bandwidth", "50") - .next(); - - rules.addTreeEdge(g, genericvnf1, entitlement1); - rules.addEdge(g, genericvnf1, serviceInstance1); - rules.addEdge(g, serviceInstance1, configuration); - rules.addEdge(g, serviceInstance1, configuration3); - - - rules.addEdge(g, genericvnf2, configuration2); - - - TransactionalGraphEngine spy = spy(dbEngine); - TransactionalGraphEngine.Admin adminSpy = spy(dbEngine.asAdmin()); - GraphTraversalSource traversal = g; - when(spy.asAdmin()).thenReturn(adminSpy); - when(adminSpy.getTraversalSource()).thenReturn(traversal); - migration = new MigrateDataFromASDCToConfiguration(spy); - migration.run(); - } - - - @After - public void cleanUp() { - tx.rollback(); - graph.close(); - } - - - /*** - * checks if the VNt value was updated and if theres a second configuration object it is also to be modified - */ - - @Test - public void confirmVNtValueChanged() { - - assertEquals("1000",configuration.property("vendor-allowed-max-bandwidth").value()); - assertEquals("1000",configuration3.property("vendor-allowed-max-bandwidth").value()); - - } - - /*** - * checks to see if the entitlement object is missing the configuration objects should not be modified at all - */ - @Test - public void missingEntitlementObject() { - assertEquals("25",configuration2.property("vendor-allowed-max-bandwidth").value()); - } - /*** - * checks to see if there's a configuration object not connected to anything it should not be modified at all - */ - - @Test - public void confirmConfiguration4notchanged() { - assertEquals("50",configuration4.property("vendor-allowed-max-bandwidth").value()); - } - - - - -} diff --git a/aai-resources/src/test/java/org/onap/aai/migration/v12/MigrateServiceInstanceToConfigurationTest.java b/aai-resources/src/test/java/org/onap/aai/migration/v12/MigrateServiceInstanceToConfigurationTest.java deleted file mode 100644 index b07c728..0000000 --- a/aai-resources/src/test/java/org/onap/aai/migration/v12/MigrateServiceInstanceToConfigurationTest.java +++ /dev/null @@ -1,410 +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.migration.v12; - -import static org.junit.Assert.assertArrayEquals; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; -import static org.mockito.Mockito.spy; -import static org.mockito.Mockito.when; - -import java.util.Optional; - -import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource; -import org.apache.tinkerpop.gremlin.process.traversal.strategy.verification.ReadOnlyStrategy; -import org.apache.tinkerpop.gremlin.structure.Vertex; -import org.junit.AfterClass; -import org.junit.BeforeClass; -import org.junit.Test; -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.EdgeRules; -import org.onap.aai.serialization.engines.QueryStyle; -import org.onap.aai.serialization.engines.JanusGraphDBEngine; -import org.onap.aai.serialization.engines.TransactionalGraphEngine; - -import org.janusgraph.core.JanusGraphFactory; -import org.janusgraph.core.JanusGraph; -import org.janusgraph.core.JanusGraphTransaction; - -public class MigrateServiceInstanceToConfigurationTest extends AAISetup { - - private final static Version version = Version.v12; - private final static ModelType introspectorFactoryType = ModelType.MOXY; - private final static QueryStyle queryStyle = QueryStyle.TRAVERSAL; - private final static DBConnectionType type = DBConnectionType.REALTIME; - - private static Loader loader; - private static TransactionalGraphEngine dbEngine; - private static JanusGraph graph; - private static MigrateServiceInstanceToConfiguration migration; - private static JanusGraphTransaction tx; - private static GraphTraversalSource g; - private static EdgeRules rules; - - @BeforeClass - public static void setUp() throws Exception { - graph = JanusGraphFactory.build().set("storage.backend","inmemory").open(); - tx = graph.newTransaction(); - g = tx.traversal(); - loader = LoaderFactory.createLoaderForVersion(introspectorFactoryType, version); - dbEngine = new JanusGraphDBEngine( - queryStyle, - type, - loader); - rules = EdgeRules.getInstance(); - - Vertex customer1 = g.addV() - .property("aai-node-type", "customer") - .property("global-customer-id", "customer-id-1") - .property("subscriber-type", "CUST") - .next(); - - Vertex customer2 = g.addV() - .property("aai-node-type", "customer") - .property("global-customer-id", "customer-id-2") - .property("subscriber-type", "CUST") - .next(); - - Vertex customer3 = g.addV() - .property("aai-node-type", "customer") - .property("global-customer-id", "customer-id-3") - .property("subscriber-type", "CUST") - .next(); - - Vertex customer4 = g.addV() - .property("aai-node-type", "customer") - .property("global-customer-id", "customer-id-4") - .property("subscriber-type", "CUST") - .next(); - - Vertex servSub1 = g.addV() - .property("aai-node-type", "service-subscription") - .property("service-type", "DHV") - .next(); - - Vertex servSub2 = g.addV() - .property("aai-node-type", "service-subscription") - .property("service-type", "OTHER") - .next(); - - Vertex servSub3 = g.addV() - .property("aai-node-type", "service-subscription") - .property("service-type", "DHV") - .next(); - - Vertex servSub4 = g.addV() - .property("aai-node-type", "service-subscription") - .property("service-type", "DHV") - .next(); - - Vertex servSub5 = g.addV() - .property("aai-node-type", "service-subscription") - .property("service-type", "DHV") - .next(); - - Vertex servInstance1 = g.addV() - .property("aai-node-type", "service-instance") - .property("service-instance-id", "service-inst-1") - .property("operational-status", "activated") - .property("bandwidth-total", "5") - .next(); - - Vertex servInstance2 = g.addV() - .property("aai-node-type", "service-instance") - .property("service-instance-id", "service-inst-2") - .property("operational-status", "activated") - .property("bandwidth-total", "8") - .next(); - - Vertex servInstance3 = g.addV() - .property("aai-node-type", "service-instance") - .property("service-instance-id", "service-inst-3") - .property("operational-status", "activated") - .property("bandwidth-total", "10") - .next(); - - Vertex servInstance4 = g.addV() - .property("aai-node-type", "service-instance") - .property("service-instance-id", "service-inst-4") - .property("operational-status", "activated") - .property("bandwidth-total", "15") - .next(); - - Vertex config1 = g.addV() - .property("aai-node-type", "configuration") - .property("configuration-id", "configuration-1") - .property("configuration-type", "DHV") - .property("tunnel-bandwidth", "7") - .next(); - - Vertex config2 = g.addV() - .property("aai-node-type", "configuration") - .property("configuration-id", "configuration-2") - .property("configuration-type", "OTHER") - .property("tunnel-bandwidth", "3") - .next(); - - Vertex config3 = g.addV() - .property("aai-node-type", "configuration") - .property("configuration-id", "configuration-3") - .property("configuration-type", "OTHER") - .property("tunnel-bandwidth", "2") - .next(); - - Vertex config4 = g.addV() - .property("aai-node-type", "configuration") - .property("configuration-id", "configuration-4") - .property("configuration-type", "OTHER") - .property("tunnel-bandwidth", "4") - .next(); - - // graph 1 - rules.addTreeEdge(g, customer1, servSub1); - rules.addTreeEdge(g, customer1, servSub2); - rules.addTreeEdge(g, servSub1, servInstance1); - rules.addTreeEdge(g, servSub2, servInstance2); - - // graph 2 - rules.addTreeEdge(g, customer2, servSub3); - - // graph 3 - rules.addTreeEdge(g, customer3, servSub4); - rules.addTreeEdge(g, servSub4, servInstance3); - rules.addEdge(g, servInstance3, config1); - rules.addEdge(g, servInstance3, config2); - - // graph 4 - rules.addTreeEdge(g, customer4, servSub5); - rules.addTreeEdge(g, servSub5, servInstance4); - rules.addEdge(g, servInstance4, config3); - rules.addEdge(g, servInstance4, config4); - - TransactionalGraphEngine spy = spy(dbEngine); - TransactionalGraphEngine.Admin adminSpy = spy(dbEngine.asAdmin()); - - GraphTraversalSource traversal = g; - GraphTraversalSource readOnly = tx.traversal(GraphTraversalSource.build().with(ReadOnlyStrategy.instance())); - when (spy.tx()).thenReturn(tx); - when(spy.asAdmin()).thenReturn(adminSpy); - when(adminSpy.getTraversalSource()).thenReturn(traversal); - when(adminSpy.getReadOnlyTraversalSource()).thenReturn(readOnly); - - migration = new MigrateServiceInstanceToConfiguration(spy); - migration.run(); - } - - @AfterClass - public static void cleanUp() { - tx.tx().rollback(); - graph.close(); - } - - @Test - public void testRun_createConfigNode() throws Exception { - // check if graph nodes exist - assertEquals("customer node exists", true, - g.V().has("global-customer-id", "customer-id-1") - .hasNext()); - - assertEquals("service subscription node, service-type=DHV", true, - g.V().has("global-customer-id", "customer-id-1") - .in("org.onap.relationships.inventory.BelongsTo").has("service-type", "DHV") - .hasNext()); - - assertEquals("service instance node, bandwidth-total=5", true, - g.V().has("global-customer-id", "customer-id-1") - .in("org.onap.relationships.inventory.BelongsTo").has("service-type", "DHV") - .in("org.onap.relationships.inventory.BelongsTo").has("service-instance-id", "service-inst-1").has("bandwidth-total", "5") - .hasNext()); - - // check if configuration node gets created - assertEquals("configuration node exists", true, - g.V().has("global-customer-id", "customer-id-1") - .in("org.onap.relationships.inventory.BelongsTo").has("service-type", "DHV") - .in("org.onap.relationships.inventory.BelongsTo").has("service-instance-id", "service-inst-1") - .out("org.onap.relationships.inventory.Uses").has("aai-node-type", "configuration") - .hasNext()); - - // check configuration type - assertEquals("configuration node, configuration-type=DHV", true, - g.V().has("global-customer-id", "customer-id-1") - .in("org.onap.relationships.inventory.BelongsTo").has("service-type", "DHV") - .in("org.onap.relationships.inventory.BelongsTo").has("service-instance-id", "service-inst-1") - .out("org.onap.relationships.inventory.Uses").has("aai-node-type", "configuration").has("configuration-type", "DHV") - .hasNext()); - - // check configuration tunnel-bandwidth - assertEquals("configuration node, tunnel-bandwidth=5", true, - g.V().has("global-customer-id", "customer-id-1") - .in("org.onap.relationships.inventory.BelongsTo").has("service-type", "DHV") - .in("org.onap.relationships.inventory.BelongsTo").has("service-instance-id", "service-inst-1") - .out("org.onap.relationships.inventory.Uses").has("aai-node-type", "configuration").has("tunnel-bandwidth", "5") - .hasNext()); - } - - @Test - public void testRun_configNodeNotCreated() throws Exception { - // check if graph nodes exist - assertEquals("customer node exists", true, - g.V().has("global-customer-id", "customer-id-1") - .hasNext()); - - assertEquals("service subscription node, service-type=OTHER", true, - g.V().has("global-customer-id", "customer-id-1") - .in("org.onap.relationships.inventory.BelongsTo").has("service-type", "OTHER") - .hasNext()); - - assertEquals("service instance node, bandwidth-total=8", true, - g.V().has("global-customer-id", "customer-id-1") - .in("org.onap.relationships.inventory.BelongsTo").has("service-type", "OTHER") - .in("org.onap.relationships.inventory.BelongsTo").has("service-instance-id", "service-inst-2").has("bandwidth-total", "8") - .hasNext()); - - // configuration node should not be created - assertEquals("configuration node does not exist", false, - g.V().has("global-customer-id", "customer-id-1") - .in("org.onap.relationships.inventory.BelongsTo").has("service-type", "OTHER") - .in("org.onap.relationships.inventory.BelongsTo").has("service-instance-id", "service-inst-2") - .out("org.onap.relationships.inventory.Uses").has("aai-node-type", "configuration") - .hasNext()); - - // edge between service instance and configuration should not be created - assertEquals("configuration node does not exist", false, - g.V().has("global-customer-id", "customer-id-1") - .in("org.onap.relationships.inventory.BelongsTo").has("service-type", "OTHER") - .in("org.onap.relationships.inventory.BelongsTo").has("service-instance-id", "service-inst-2") - .out("org.onap.relationships.inventory.Uses").hasNext()); - } - - @Test - public void testRun_noServiceInstance() throws Exception { - // check if graph nodes exist - assertEquals("customer node exists", true, - g.V().has("global-customer-id", "customer-id-2") - .hasNext()); - - assertEquals("service subscription node, service-type=DHV", true, - g.V().has("global-customer-id", "customer-id-2") - .in("org.onap.relationships.inventory.BelongsTo").has("service-type", "DHV") - .hasNext()); - - // no service instance nodes - assertEquals("no service instance nodes", false, - g.V().has("global-customer-id", "customer-id-2") - .in("org.onap.relationships.inventory.BelongsTo").has("service-type", "DHV") - .in("org.onap.relationships.inventory.BelongsTo").has("aai-node-type", "service-instance") - .hasNext()); - } - - @Test - public void testRun_existingConfig() throws Exception { - // check if graph nodes exist - assertEquals("customer node exists", true, - g.V().has("global-customer-id", "customer-id-3") - .hasNext()); - - assertEquals("service subscription node, service-type=DHV", true, - g.V().has("global-customer-id", "customer-id-3") - .in("org.onap.relationships.inventory.BelongsTo").has("service-type", "DHV") - .hasNext()); - - assertEquals("service instance node, bandwidth-total=10", true, - g.V().has("global-customer-id", "customer-id-3") - .in("org.onap.relationships.inventory.BelongsTo").has("service-type", "DHV") - .in("org.onap.relationships.inventory.BelongsTo").has("service-instance-id", "service-inst-3").has("bandwidth-total", "10") - .hasNext()); - - assertEquals("configuration node with type DHV, tunnel-bandwidth changed to 10", true, - g.V().has("global-customer-id", "customer-id-3") - .in("org.onap.relationships.inventory.BelongsTo").has("service-type", "DHV") - .in("org.onap.relationships.inventory.BelongsTo").has("service-instance-id", "service-inst-3") - .out("org.onap.relationships.inventory.Uses").has("aai-node-type", "configuration").has("tunnel-bandwidth", "10") - .hasNext()); - - assertEquals("configuration node with type OTHER, tunnel-bandwidth remains same", true, - g.V().has("global-customer-id", "customer-id-3") - .in("org.onap.relationships.inventory.BelongsTo").has("service-type", "DHV") - .in("org.onap.relationships.inventory.BelongsTo").has("service-instance-id", "service-inst-3") - .out("org.onap.relationships.inventory.Uses").has("aai-node-type", "configuration").has("tunnel-bandwidth", "3") - .hasNext()); - } - - @Test - public void testRun_existingConfigNotDHV() throws Exception { - // check if graph nodes exist - assertEquals("customer node exists", true, - g.V().has("global-customer-id", "customer-id-4") - .hasNext()); - - assertEquals("service subscription node, service-type=DHV", true, - g.V().has("global-customer-id", "customer-id-4") - .in("org.onap.relationships.inventory.BelongsTo").has("service-type", "DHV") - .hasNext()); - - assertEquals("service instance node, bandwidth-total=15", true, - g.V().has("global-customer-id", "customer-id-4") - .in("org.onap.relationships.inventory.BelongsTo").has("service-type", "DHV") - .in("org.onap.relationships.inventory.BelongsTo").has("service-instance-id", "service-inst-4").has("bandwidth-total", "15") - .hasNext()); - - assertEquals("first configuration node with type OTHER, tunnel-bandwidth remains same", true, - g.V().has("global-customer-id", "customer-id-4") - .in("org.onap.relationships.inventory.BelongsTo").has("service-type", "DHV") - .in("org.onap.relationships.inventory.BelongsTo").has("service-instance-id", "service-inst-4") - .out("org.onap.relationships.inventory.Uses").has("aai-node-type", "configuration").has("tunnel-bandwidth", "2") - .hasNext()); - - assertEquals("second configuration node with type OTHER, tunnel-bandwidth remains same", true, - g.V().has("global-customer-id", "customer-id-4") - .in("org.onap.relationships.inventory.BelongsTo").has("service-type", "DHV") - .in("org.onap.relationships.inventory.BelongsTo").has("service-instance-id", "service-inst-4") - .out("org.onap.relationships.inventory.Uses").has("aai-node-type", "configuration").has("tunnel-bandwidth", "4") - .hasNext()); - - assertEquals("new configuration node created with type DHV, tunnel-bandwidth=15", true, - g.V().has("global-customer-id", "customer-id-4") - .in("org.onap.relationships.inventory.BelongsTo").has("service-type", "DHV") - .in("org.onap.relationships.inventory.BelongsTo").has("service-instance-id", "service-inst-4") - .out("org.onap.relationships.inventory.Uses").has("aai-node-type", "configuration").has("tunnel-bandwidth", "15") - .hasNext()); - } - - @Test - public void testGetAffectedNodeTypes() { - Optional<String[]> types = migration.getAffectedNodeTypes(); - Optional<String[]> expected = Optional.of(new String[]{"service-instance"}); - - assertNotNull(types); - assertArrayEquals(expected.get(), types.get()); - } - - @Test - public void testGetMigrationName() { - String migrationName = migration.getMigrationName(); - - assertNotNull(migrationName); - assertEquals("service-instance-to-configuration", migrationName); - } -} diff --git a/aai-resources/src/test/java/org/onap/aai/migration/v12/MigrateServiceInstanceToConfigurationTestPreMigrationMock.java b/aai-resources/src/test/java/org/onap/aai/migration/v12/MigrateServiceInstanceToConfigurationTestPreMigrationMock.java deleted file mode 100644 index 498fd0c..0000000 --- a/aai-resources/src/test/java/org/onap/aai/migration/v12/MigrateServiceInstanceToConfigurationTestPreMigrationMock.java +++ /dev/null @@ -1,304 +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.migration.v12; - -import static org.junit.Assert.assertArrayEquals; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; -import static org.mockito.Mockito.spy; -import static org.mockito.Mockito.when; - -import java.util.Optional; - -import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource; -import org.apache.tinkerpop.gremlin.process.traversal.strategy.verification.ReadOnlyStrategy; -import org.apache.tinkerpop.gremlin.structure.Vertex; -import org.junit.AfterClass; -import org.junit.BeforeClass; -import org.junit.Test; -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.EdgeRules; -import org.onap.aai.serialization.engines.QueryStyle; -import org.onap.aai.serialization.engines.JanusGraphDBEngine; -import org.onap.aai.serialization.engines.TransactionalGraphEngine; - -import org.janusgraph.core.JanusGraphFactory; -import org.janusgraph.core.JanusGraph; -import org.janusgraph.core.JanusGraphTransaction; - -public class MigrateServiceInstanceToConfigurationTestPreMigrationMock extends AAISetup { - - private final static Version version = Version.v12; - private final static ModelType introspectorFactoryType = ModelType.MOXY; - private final static QueryStyle queryStyle = QueryStyle.TRAVERSAL; - private final static DBConnectionType type = DBConnectionType.REALTIME; - - private static Loader loader; - private static TransactionalGraphEngine dbEngine; - private static JanusGraph graph; - private static MigrateServiceInstanceToConfiguration migration; - private static JanusGraphTransaction tx; - private static GraphTraversalSource g; - private static EdgeRules rules; - - @BeforeClass - public static void setUp() throws Exception { - graph = JanusGraphFactory.build().set("storage.backend","inmemory").open(); - tx = graph.newTransaction(); - g = tx.traversal(); - loader = LoaderFactory.createLoaderForVersion(introspectorFactoryType, version); - dbEngine = new JanusGraphDBEngine( - queryStyle, - type, - loader); - rules = EdgeRules.getInstance(); - - Vertex customer = g.addV() - .property("aai-node-type", "customer") - .property("global-customer-id", "customer-9972-BandwidthMigration") - .property("subscriber-type", "CUST") - .next(); - - Vertex servSubSDNEI = g.addV() - .property("aai-node-type", "service-subscription") - .property("service-type", "SDN-ETHERNET-INTERNET") - .next(); - - Vertex servInstance22 = g.addV() - .property("aai-node-type", "service-instance") - .property("service-instance-id", "servInstance-9972-22-BandwidthMigration") - .property("operational-status", "activated") - .property("bandwidth-total", "bandwidth-total-22-BandwidthMigration") - .next(); - - Vertex servInstance11 = g.addV() - .property("aai-node-type", "service-instance") - .property("service-instance-id", "servInstance-9972-11-BandwidthMigration") - .property("operational-status", "activated") - .property("bandwidth-total", "bandwidth-total-11-BandwidthMigration") - .next(); - - Vertex servSubDHV = g.addV() - .property("aai-node-type", "service-subscription") - .property("service-type", "DHV") - .next(); - - Vertex servInstance4 = g.addV() - .property("aai-node-type", "service-instance") - .property("service-instance-id", "servInstance-9972-4-BandwidthMigration") - .property("operational-status", "activated") - .property("bandwidth-total", "bandwidth-total-4-BandwidthMigration") - .next(); - - Vertex servInstance1 = g.addV() - .property("aai-node-type", "service-instance") - .property("service-instance-id", "ServInstance-9972-1-BandwidthMigration") - .property("operational-status", "activated") - .property("bandwidth-total", "2380") - .next(); - - Vertex servInstance3 = g.addV() - .property("aai-node-type", "service-instance") - .property("service-instance-id", "servInstance-9972-3-BandwidthMigration") - .property("operational-status", "activated") - .property("bandwidth-total", "bandwidth-total-3-BandwidthMigration") - .next(); - - Vertex servInstance2 = g.addV() - .property("aai-node-type", "service-instance") - .property("service-instance-id", "servInstance-9972-2-BandwidthMigration") - .property("operational-status", "activated") - .property("bandwidth-total", "bandwidth-total-2-BandwidthMigration") - .next(); - - Vertex config1 = g.addV() - .property("aai-node-type", "configuration") - .property("configuration-id", "9972-config-LB1113") - .property("configuration-type", "DHV") - .property("tunnel-bandwidth", "12") - .next(); - - Vertex config2 = g.addV() - .property("aai-node-type", "configuration") - .property("configuration-id", "9972-1config-LB1113") - .property("configuration-type", "configuration-type1-9972") - .next(); - - Vertex allottedResource = g.addV() - .property("aai-node-type", "allotted-resource") - .property("id", "allResource-9972-BandwidthMigration") - .next(); - - rules.addTreeEdge(g, customer, servSubSDNEI); - rules.addTreeEdge(g, customer, servSubDHV); - rules.addTreeEdge(g, servSubSDNEI, servInstance22); - rules.addTreeEdge(g, servSubSDNEI, servInstance11); - rules.addTreeEdge(g, servSubDHV, servInstance4); - rules.addTreeEdge(g, servSubDHV, servInstance1); - rules.addTreeEdge(g, servSubDHV, servInstance3); - rules.addTreeEdge(g, servSubDHV, servInstance2); - rules.addEdge(g, servInstance1, allottedResource); - rules.addEdge(g, servInstance1, config1); - rules.addEdge(g, servInstance2, config2); - - TransactionalGraphEngine spy = spy(dbEngine); - TransactionalGraphEngine.Admin adminSpy = spy(dbEngine.asAdmin()); - - GraphTraversalSource traversal = g; - GraphTraversalSource readOnly = tx.traversal(GraphTraversalSource.build().with(ReadOnlyStrategy.instance())); - when (spy.tx()).thenReturn(tx); - when(spy.asAdmin()).thenReturn(adminSpy); - when(adminSpy.getTraversalSource()).thenReturn(traversal); - when(adminSpy.getReadOnlyTraversalSource()).thenReturn(readOnly); - - migration = new MigrateServiceInstanceToConfiguration(spy); - migration.run(); - } - - @AfterClass - public static void cleanUp() { - tx.tx().rollback(); - graph.close(); - } - - @Test - public void testRun() throws Exception { - // check if graph nodes exist - assertEquals("customer node exists", true, - g.V().has("global-customer-id", "customer-9972-BandwidthMigration") - .hasNext()); - - assertEquals("service subscription node, service-type=SDN-ETHERNET-INTERNET", true, - g.V().has("global-customer-id", "customer-9972-BandwidthMigration") - .in("org.onap.relationships.inventory.BelongsTo").has("service-type", "SDN-ETHERNET-INTERNET") - .hasNext()); - - assertEquals("service instance node, bandwidth-total=bandwidth-total-22-BandwidthMigration", true, - g.V().has("global-customer-id", "customer-9972-BandwidthMigration") - .in("org.onap.relationships.inventory.BelongsTo").has("service-type", "SDN-ETHERNET-INTERNET") - .in("org.onap.relationships.inventory.BelongsTo").has("service-instance-id", "servInstance-9972-22-BandwidthMigration") - .has("bandwidth-total", "bandwidth-total-22-BandwidthMigration") - .hasNext()); - - assertEquals("service instance node, bandwidth-total=bandwidth-total-11-BandwidthMigration", true, - g.V().has("global-customer-id", "customer-9972-BandwidthMigration") - .in("org.onap.relationships.inventory.BelongsTo").has("service-type", "SDN-ETHERNET-INTERNET") - .in("org.onap.relationships.inventory.BelongsTo").has("service-instance-id", "servInstance-9972-11-BandwidthMigration") - .has("bandwidth-total", "bandwidth-total-11-BandwidthMigration") - .hasNext()); - - assertEquals("service subscription node, service-type=DHV", true, - g.V().has("global-customer-id", "customer-9972-BandwidthMigration") - .in("org.onap.relationships.inventory.BelongsTo").has("service-type", "DHV") - .hasNext()); - - assertEquals("service instance node, bandwidth-total=servInstance-9972-4-BandwidthMigration", true, - g.V().has("global-customer-id", "customer-9972-BandwidthMigration") - .in("org.onap.relationships.inventory.BelongsTo").has("service-type", "DHV") - .in("org.onap.relationships.inventory.BelongsTo").has("service-instance-id", "servInstance-9972-4-BandwidthMigration") - .has("bandwidth-total", "bandwidth-total-4-BandwidthMigration") - .hasNext()); - - assertEquals("service instance node, bandwidth-total=ServInstance-9972-1-BandwidthMigration", true, - g.V().has("global-customer-id", "customer-9972-BandwidthMigration") - .in("org.onap.relationships.inventory.BelongsTo").has("service-type", "DHV") - .in("org.onap.relationships.inventory.BelongsTo").has("service-instance-id", "ServInstance-9972-1-BandwidthMigration") - .has("bandwidth-total", "2380") - .hasNext()); - - assertEquals("service instance node, bandwidth-total=servInstance-9972-3-BandwidthMigration", true, - g.V().has("global-customer-id", "customer-9972-BandwidthMigration") - .in("org.onap.relationships.inventory.BelongsTo").has("service-type", "DHV") - .in("org.onap.relationships.inventory.BelongsTo").has("service-instance-id", "servInstance-9972-3-BandwidthMigration") - .has("bandwidth-total", "bandwidth-total-3-BandwidthMigration") - .hasNext()); - - assertEquals("service instance node, bandwidth-total=servInstance-9972-2-BandwidthMigration", true, - g.V().has("global-customer-id", "customer-9972-BandwidthMigration") - .in("org.onap.relationships.inventory.BelongsTo").has("service-type", "DHV") - .in("org.onap.relationships.inventory.BelongsTo").has("service-instance-id", "servInstance-9972-2-BandwidthMigration") - .has("bandwidth-total", "bandwidth-total-2-BandwidthMigration") - .hasNext()); - - assertEquals("configuration node with type=configuration-type1-9972, tunnel-bandwidth does not exist", true, - g.V().has("global-customer-id", "customer-9972-BandwidthMigration") - .in("org.onap.relationships.inventory.BelongsTo").has("service-type", "DHV") - .in("org.onap.relationships.inventory.BelongsTo").has("service-instance-id", "servInstance-9972-2-BandwidthMigration") - .out("org.onap.relationships.inventory.Uses").has("aai-node-type", "configuration") - .has("configuration-type", "configuration-type1-9972") - .hasNext()); - - // check if configuration node gets created for 2, 3, 4 - assertEquals("configuration node created with type=DHV, tunnel-bandwidth=servInstance-9972-4-BandwidthMigration", true, - g.V().has("global-customer-id", "customer-9972-BandwidthMigration") - .in("org.onap.relationships.inventory.BelongsTo").has("service-type", "DHV") - .in("org.onap.relationships.inventory.BelongsTo").has("service-instance-id", "servInstance-9972-4-BandwidthMigration") - .out("org.onap.relationships.inventory.Uses").has("aai-node-type", "configuration") - .has("configuration-type", "DHV").has("tunnel-bandwidth", "bandwidth-total-4-BandwidthMigration") - .hasNext()); - - assertEquals("configuration node created with type=DHV, tunnel-bandwidth=servInstance-9972-3-BandwidthMigration", true, - g.V().has("global-customer-id", "customer-9972-BandwidthMigration") - .in("org.onap.relationships.inventory.BelongsTo").has("service-type", "DHV") - .in("org.onap.relationships.inventory.BelongsTo").has("service-instance-id", "servInstance-9972-3-BandwidthMigration") - .out("org.onap.relationships.inventory.Uses").has("aai-node-type", "configuration") - .has("configuration-type", "DHV").has("tunnel-bandwidth", "bandwidth-total-3-BandwidthMigration") - .hasNext()); - - assertEquals("configuration node created with type=DHV, tunnel-bandwidth=servInstance-9972-2-BandwidthMigration", true, - g.V().has("global-customer-id", "customer-9972-BandwidthMigration") - .in("org.onap.relationships.inventory.BelongsTo").has("service-type", "DHV") - .in("org.onap.relationships.inventory.BelongsTo").has("service-instance-id", "servInstance-9972-2-BandwidthMigration") - .out("org.onap.relationships.inventory.Uses").has("aai-node-type", "configuration") - .has("configuration-type", "DHV").has("tunnel-bandwidth", "bandwidth-total-2-BandwidthMigration") - .hasNext()); - - // configuration modified for ServInstance-9972-1-BandwidthMigration - assertEquals("configuration node modified for ServInstance-9972-1-BandwidthMigration, tunnel-bandwidth=2380", true, - g.V().has("global-customer-id", "customer-9972-BandwidthMigration") - .in("org.onap.relationships.inventory.BelongsTo").has("service-type", "DHV") - .in("org.onap.relationships.inventory.BelongsTo").has("service-instance-id", "ServInstance-9972-1-BandwidthMigration") - .out("org.onap.relationships.inventory.Uses").has("aai-node-type", "configuration") - .has("configuration-type", "DHV").has("tunnel-bandwidth", "2380") - .hasNext()); - } - - @Test - public void testGetAffectedNodeTypes() { - Optional<String[]> types = migration.getAffectedNodeTypes(); - Optional<String[]> expected = Optional.of(new String[]{"service-instance"}); - - assertNotNull(types); - assertArrayEquals(expected.get(), types.get()); - } - - @Test - public void testGetMigrationName() { - String migrationName = migration.getMigrationName(); - - assertNotNull(migrationName); - assertEquals("service-instance-to-configuration", migrationName); - } -} diff --git a/aai-resources/src/test/java/org/onap/aai/migration/v12/SDWANSpeedChangeMigrationTest.java b/aai-resources/src/test/java/org/onap/aai/migration/v12/SDWANSpeedChangeMigrationTest.java deleted file mode 100644 index 677050a..0000000 --- a/aai-resources/src/test/java/org/onap/aai/migration/v12/SDWANSpeedChangeMigrationTest.java +++ /dev/null @@ -1,379 +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.migration.v12; - -import org.janusgraph.core.JanusGraphFactory; -import org.janusgraph.core.JanusGraph; -import org.janusgraph.core.JanusGraphTransaction; -import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource; -import org.apache.tinkerpop.gremlin.structure.Vertex; -import org.junit.After; -import org.junit.Before; -import org.junit.Test; -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.EdgeRules; -import org.onap.aai.serialization.engines.QueryStyle; -import org.onap.aai.serialization.engines.JanusGraphDBEngine; -import org.onap.aai.serialization.engines.TransactionalGraphEngine; - -import static org.junit.Assert.assertEquals; -import static org.mockito.Mockito.spy; -import static org.mockito.Mockito.when; - -public class SDWANSpeedChangeMigrationTest extends AAISetup { - - private final static Version version = Version.v12; - private final static ModelType introspectorFactoryType = ModelType.MOXY; - private final static QueryStyle queryStyle = QueryStyle.TRAVERSAL; - private final static DBConnectionType type = DBConnectionType.REALTIME; - private Loader loader; - private TransactionalGraphEngine dbEngine; - private JanusGraph graph; - private SDWANSpeedChangeMigration migration; - private EdgeRules rules; - private GraphTraversalSource g; - private JanusGraphTransaction tx; - Vertex pLinkWan1; - Vertex pLinkWan3; - Vertex pLinkWan5; - Vertex pLinkWan7; - - - - @Before - public void setUp() throws Exception { - graph = JanusGraphFactory.build().set("storage.backend", "inmemory").open(); - tx = graph.newTransaction(); - g = tx.traversal(); - loader = LoaderFactory.createLoaderForVersion(introspectorFactoryType, version); - dbEngine = new JanusGraphDBEngine( - queryStyle, - type, - loader); - rules = EdgeRules.getInstance(); - - Vertex servSub1 = g.addV().property("aai-node-type", "service-subscription") - .property("service-type", "DHV") - .next(); - Vertex servinst1 = g.addV().property("aai-node-type", "service-instance") - .property("service-type", "DHV") - .next(); - Vertex allotedRsrc1 = g.addV().property("aai-node-type", "allotted-resource") - .property("id", "rsrc1") - .next(); - Vertex servinst2 = g.addV().property("aai-node-type", "service-instance") - .property("service-type", "VVIG") - .next(); - Vertex servSub2 = g.addV().property("aai-node-type", "service-subscription") - .property("service-type", "VVIG") - .next(); - - Vertex genericvnf1 = g.addV().property("aai-node-type", "generic-vnf") - .property("vnf-id", "vnfId1") - .next(); - Vertex vServer1 = g.addV().property("aai-node-type", "vserver") - .next(); - Vertex pServer1 = g.addV().property("aai-node-type", "pserver") - .next(); - Vertex pInterfaceWan1 = g.addV().property("aai-node-type", "p-interface") - .property("interface-name", "ge-0/0/10") - .next(); - Vertex tunnelXConnectAll_Wan1 = g.addV().property("aai-node-type", "tunnel-xconnect") - .property("id", "txc1") - .property("bandwidth-up-wan1", "300 Mbps") - .property("bandwidth-down-wan1", "400 Mbps") - .property("bandwidth-up-wan2", "500 Mbps") - .property("bandwidth-down-wan2", "600 Mbps") - .next(); - - pLinkWan1 = g.addV().property("aai-node-type", "physical-link") - .property("link-name", "pLinkWan1") - .property("service-provider-bandwidth-up-value", "empty") - .property("service-provider-bandwidth-up-units", "empty") - .property("service-provider-bandwidth-down-value", "empty") - .property("service-provider-bandwidth-down-units", "empty") - .next(); - Vertex servSub3 = g.addV().property("aai-node-type", "service-subscription") - .property("service-type", "DHV") - .next(); - Vertex servinst3 = g.addV().property("aai-node-type", "service-instance") - .property("service-type", "DHV") - .next(); - Vertex allotedRsrc3 = g.addV().property("aai-node-type", "allotted-resource") - .property("id", "rsrc1") - .next(); - Vertex servinst4 = g.addV().property("aai-node-type", "service-instance") - .property("service-type", "VVIG") - .next(); - Vertex servSub4 = g.addV().property("aai-node-type", "service-subscription") - .property("service-type", "VVIG") - .next(); - - Vertex genericvnf3 = g.addV().property("aai-node-type", "generic-vnf") - .property("vnf-id", "vnfId1") - .next(); - Vertex vServer3 = g.addV().property("aai-node-type", "vserver") - .next(); - Vertex pServer3 = g.addV().property("aai-node-type", "pserver") - .next(); - Vertex pInterfaceWan3 = g.addV().property("aai-node-type", "p-interface") - .property("interface-name", "ge-0/0/11") - .next(); - Vertex tunnelXConnectAll_Wan3 = g.addV().property("aai-node-type", "tunnel-xconnect") - .property("id", "txc3") - .property("bandwidth-up-wan1", "300 Mbps") - .property("bandwidth-down-wan1", "400 Mbps") - .property("bandwidth-up-wan2", "500 Mbps") - .property("bandwidth-down-wan2", "600 Mbps") - .next(); - - pLinkWan3 = g.addV().property("aai-node-type", "physical-link") - .property("link-name", "pLinkWan3") - .property("service-provider-bandwidth-up-value", "empty") - .property("service-provider-bandwidth-up-units", "empty") - .property("service-provider-bandwidth-down-value", "empty") - .property("service-provider-bandwidth-down-units", "empty") - .next(); - - - Vertex servSub5 = g.addV().property("aai-node-type", "service-subscription") - .property("service-type", "DHV") - .next(); - Vertex servinst5 = g.addV().property("aai-node-type", "service-instance") - .property("service-type", "DHV") - .next(); - Vertex allotedRsrc5 = g.addV().property("aai-node-type", "allotted-resource") - .property("id", "rsrc1") - .next(); - Vertex servinst6 = g.addV().property("aai-node-type", "service-instance") - .property("service-type", "VVIG") - .next(); - Vertex servSub6 = g.addV().property("aai-node-type", "service-subscription") - .property("service-type", "VVIG") - .next(); - - Vertex genericvnf5 = g.addV().property("aai-node-type", "generic-vnf") - .property("vnf-id", "vnfId1") - .next(); - Vertex vServer5 = g.addV().property("aai-node-type", "vserver") - .next(); - Vertex pServer5 = g.addV().property("aai-node-type", "pserver") - .next(); - Vertex pInterfaceWan5 = g.addV().property("aai-node-type", "p-interface") - .property("interface-name", "ge-0/0/10") - .next(); - Vertex tunnelXConnectAll_Wan5 = g.addV().property("aai-node-type", "tunnel-xconnect") - .property("id", "txc5") - .property("bandwidth-up-wan1", "") - .property("bandwidth-down-wan1", "") - .property("bandwidth-up-wan2", "500 Mbps") - .property("bandwidth-down-wan2", "600 Mbps") - .next(); - - pLinkWan5 = g.addV().property("aai-node-type", "physical-link") - .property("link-name", "pLinkWan5") - .property("service-provider-bandwidth-up-value", "") - .property("service-provider-bandwidth-up-units", "") - .property("service-provider-bandwidth-down-value", "") - .property("service-provider-bandwidth-down-units", "") - .next(); - - - Vertex servSub7 = g.addV().property("aai-node-type", "service-subscription") - .property("service-type", "DHV") - .next(); - Vertex servinst7 = g.addV().property("aai-node-type", "service-instance") - .property("service-type", "DHV") - .next(); - Vertex allotedRsrc7 = g.addV().property("aai-node-type", "allotted-resource") - .property("id", "rsrc1") - .next(); - Vertex servinst9 = g.addV().property("aai-node-type", "service-instance") - .property("service-type", "VVIG") - .next(); - Vertex servSub9 = g.addV().property("aai-node-type", "service-subscription") - .property("service-type", "VVIG") - .next(); - - Vertex genericvnf7 = g.addV().property("aai-node-type", "generic-vnf") - .property("vnf-id", "vnfId1") - .next(); - Vertex vServer7 = g.addV().property("aai-node-type", "vserver") - .next(); - Vertex pServer7 = g.addV().property("aai-node-type", "pserver") - .next(); - Vertex pInterfaceWan7 = g.addV().property("aai-node-type", "p-interface") - .property("interface-name", "ge-0/0/11") - .next(); - Vertex tunnelXConnectAll_Wan7 = g.addV().property("aai-node-type", "tunnel-xconnect") - .property("id", "txc7") - .property("bandwidth-up-wan1", "300 Mbps") - .property("bandwidth-down-wan1", "400 Mbps") - .property("bandwidth-up-wan2", "") - .property("bandwidth-down-wan2", "") - .next(); - - pLinkWan7 = g.addV().property("aai-node-type", "physical-link") - .property("link-name", "pLinkWan5") - .property("service-provider-bandwidth-up-value", "") - .property("service-provider-bandwidth-up-units", "") - .property("service-provider-bandwidth-down-value", "") - .property("service-provider-bandwidth-down-units", "") - .next(); - - - - rules.addTreeEdge(g, servSub1, servinst1); - rules.addEdge(g, servinst1, allotedRsrc1); - rules.addTreeEdge(g, servinst2, servSub2); - rules.addTreeEdge(g, allotedRsrc1, servinst2); - - rules.addTreeEdge(g, allotedRsrc1, tunnelXConnectAll_Wan1); - - - rules.addEdge(g, servinst1, genericvnf1); - rules.addEdge(g, genericvnf1, vServer1); - rules.addEdge(g, vServer1, pServer1); - rules.addTreeEdge(g, pServer1, pInterfaceWan1); - rules.addEdge(g, pInterfaceWan1, pLinkWan1); - - rules.addTreeEdge(g, servSub3, servinst3); - rules.addEdge(g, servinst3, allotedRsrc3); - rules.addTreeEdge(g, servinst4, servSub4); - rules.addTreeEdge(g, allotedRsrc3, servinst4); - - rules.addTreeEdge(g, allotedRsrc3, tunnelXConnectAll_Wan3); - - - rules.addEdge(g, servinst3, genericvnf3); - rules.addEdge(g, genericvnf3, vServer3); - rules.addEdge(g, vServer3, pServer3); - rules.addTreeEdge(g, pServer3, pInterfaceWan3); - rules.addEdge(g, pInterfaceWan3, pLinkWan3); - - - rules.addTreeEdge(g, servSub5, servinst5); - rules.addEdge(g, servinst5, allotedRsrc5); - rules.addTreeEdge(g, servinst6, servSub6); - rules.addTreeEdge(g, allotedRsrc5, servinst6); - - rules.addTreeEdge(g, allotedRsrc5, tunnelXConnectAll_Wan5); - - - rules.addEdge(g, servinst5, genericvnf5); - rules.addEdge(g, genericvnf5, vServer5); - rules.addEdge(g, vServer5, pServer5); - rules.addTreeEdge(g, pServer5, pInterfaceWan5); - rules.addEdge(g, pInterfaceWan5, pLinkWan5); - - rules.addTreeEdge(g, servSub7, servinst7); - rules.addEdge(g, servinst7, allotedRsrc7); - rules.addTreeEdge(g, servinst9, servSub9); - rules.addTreeEdge(g, allotedRsrc7, servinst9); - - rules.addTreeEdge(g, allotedRsrc7, tunnelXConnectAll_Wan7); - - - rules.addEdge(g, servinst7, genericvnf7); - rules.addEdge(g, genericvnf7, vServer7); - rules.addEdge(g, vServer7, pServer7); - rules.addTreeEdge(g, pServer7, pInterfaceWan7); - rules.addEdge(g, pInterfaceWan7, pLinkWan7); - - - TransactionalGraphEngine spy = spy(dbEngine); - TransactionalGraphEngine.Admin adminSpy = spy(dbEngine.asAdmin()); - GraphTraversalSource traversal = g; - when(spy.asAdmin()).thenReturn(adminSpy); - when(adminSpy.getTraversalSource()).thenReturn(traversal); - migration = new SDWANSpeedChangeMigration(spy); - migration.run(); - } - - - @After - public void cleanUp() { - tx.rollback(); - graph.close(); - } - - - /*** - * Checks to see if the Wan1 properties were updated in the physical link - */ - - @Test - public void ConfirmWan1Changes() { - - assertEquals("300", pLinkWan1.property("service-provider-bandwidth-up-value").value().toString()); - assertEquals("Mbps", pLinkWan1.property("service-provider-bandwidth-up-units").value().toString()); - assertEquals("400", pLinkWan1.property("service-provider-bandwidth-down-value").value().toString()); - assertEquals("Mbps", pLinkWan1.property("service-provider-bandwidth-down-units").value().toString()); - - } - - /*** - * Checks to see if the Wan2 properties were updated in the physical link - */ - @Test - public void ConfirmWan2Changes() { - - assertEquals("500", pLinkWan3.property("service-provider-bandwidth-up-value").value().toString()); - assertEquals("Mbps", pLinkWan3.property("service-provider-bandwidth-up-units").value().toString()); - assertEquals("600", pLinkWan3.property("service-provider-bandwidth-down-value").value().toString()); - assertEquals("Mbps", pLinkWan3.property("service-provider-bandwidth-down-units").value().toString()); - - } - - /*** - * if tunnel xconncets missing bandwidth up 1 value the plink should not be updated - */ - - @Test - public void Wan1EmptyNoChanges() { - - assertEquals("", pLinkWan5.property("service-provider-bandwidth-up-value").value().toString()); - assertEquals("", pLinkWan5.property("service-provider-bandwidth-up-units").value().toString()); - assertEquals("", pLinkWan5.property("service-provider-bandwidth-down-value").value().toString()); - assertEquals("", pLinkWan5.property("service-provider-bandwidth-down-units").value().toString()); - - } - - /*** - * if tunnel xconncets missing bandwidth up 2 value the plink should not be updated - */ - - @Test - public void Wan2EmptyNoChanges() { - - assertEquals("", pLinkWan7.property("service-provider-bandwidth-up-value").value().toString()); - assertEquals("", pLinkWan7.property("service-provider-bandwidth-up-units").value().toString()); - assertEquals("", pLinkWan7.property("service-provider-bandwidth-down-value").value().toString()); - assertEquals("", pLinkWan7.property("service-provider-bandwidth-down-units").value().toString()); - - } - - -} diff --git a/aai-resources/src/test/java/org/onap/aai/migration/v12/ToscaMigrationTest.java b/aai-resources/src/test/java/org/onap/aai/migration/v12/ToscaMigrationTest.java deleted file mode 100644 index 9e21947..0000000 --- a/aai-resources/src/test/java/org/onap/aai/migration/v12/ToscaMigrationTest.java +++ /dev/null @@ -1,181 +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.migration.v12; - -import org.janusgraph.core.JanusGraphFactory; -import org.janusgraph.core.JanusGraph; -import org.janusgraph.core.schema.JanusGraphManagement; -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.After; -import org.junit.Before; -import org.junit.Test; -import org.mockito.Mockito; -import org.onap.aai.AAISetup; -import org.onap.aai.db.props.AAIProperties; -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.AAIDirection; -import org.onap.aai.serialization.db.EdgeProperty; -import org.onap.aai.serialization.engines.QueryStyle; -import org.onap.aai.serialization.engines.JanusGraphDBEngine; -import org.onap.aai.serialization.engines.TransactionalGraphEngine; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; -import static org.mockito.Mockito.spy; -import static org.mockito.Mockito.when; - -public class ToscaMigrationTest extends AAISetup { - - private final static Version version = Version.v12; - private final static ModelType introspectorFactoryType = ModelType.MOXY; - private final static QueryStyle queryStyle = QueryStyle.TRAVERSAL; - private final static DBConnectionType type = DBConnectionType.REALTIME; - private Loader loader; - private TransactionalGraphEngine dbEngine; - private JanusGraph graph; - private ToscaMigration migration; - private GraphTraversalSource g; - private Graph tx; - - @Before - public void setUp() throws Exception { - graph = JanusGraphFactory.build().set("storage.backend","inmemory").open(); - JanusGraphManagement janusgraphManagement = graph.openManagement(); - tx = graph.newTransaction(); - g = tx.traversal(); - loader = LoaderFactory.createLoaderForVersion(introspectorFactoryType, version); - dbEngine = new JanusGraphDBEngine( - queryStyle, - type, - loader); - - Vertex gvnf = g.addV().property(AAIProperties.NODE_TYPE, "generic-vnf") - .property("vnf-id", "toscaMigration-test-vnf") - .next(); - - Vertex lInterface = g.addV().property(AAIProperties.NODE_TYPE, "l-interface") - .property("interface-name", "toscaMigration-test-lint") - .next(); - - Vertex logicalLink = g.addV().property(AAIProperties.NODE_TYPE, "logical-link") - .property("link-name", "toscaMigration-logical-link") - .next(); - - - - gvnf.addEdge("hasLInterface", lInterface, EdgeProperty.CONTAINS.toString(), AAIDirection.OUT.toString(), - EdgeProperty.DELETE_OTHER_V.toString(), AAIDirection.NONE.toString()); - - lInterface.addEdge("usesLogicalLink", logicalLink, EdgeProperty.CONTAINS.toString(), AAIDirection.NONE.toString(), - EdgeProperty.DELETE_OTHER_V.toString(), AAIDirection.NONE.toString()); - lInterface.addEdge("sourceLInterface", logicalLink, EdgeProperty.CONTAINS.toString(), AAIDirection.NONE.toString(), - EdgeProperty.DELETE_OTHER_V.toString(), AAIDirection.NONE.toString()); - - Vertex pserver = g.addV("aai-node-type","pserver","hostname","a-name").next(); - Vertex vnfc = g.addV("aai-node-type","vnfc","vnfc-name","a-name").next(); - pserver.addEdge("blah", vnfc, EdgeProperty.CONTAINS.toString(), AAIDirection.NONE.toString(), - EdgeProperty.DELETE_OTHER_V.toString(), AAIDirection.NONE.toString()); - - TransactionalGraphEngine spy = spy(dbEngine); - TransactionalGraphEngine.Admin adminSpy = spy(dbEngine.asAdmin()); - GraphTraversalSource traversal = g; - when(spy.asAdmin()).thenReturn(adminSpy); - when(adminSpy.getTraversalSource()).thenReturn(traversal); - Mockito.doReturn(janusgraphManagement).when(adminSpy).getManagementSystem(); - migration = new ToscaMigration(spy); - migration.run(); - - - } - - @After - public void cleanUp() { - tx.tx().rollback(); - graph.close(); - } - - @Test - public void verifyVnfHasOnlyNewEdgeTest() { - - // We want to check that this edge has the expected new label and reversed direction from - // what it was created with. NOTE - if the csv file changes what the new label is supposed - // to be, then this test will need to be updated. - - assertEquals("edge direction and label were migrated", true, - g.V().has(AAIProperties.NODE_TYPE, "generic-vnf").has("vnf-id", "toscaMigration-test-vnf").inE() - .hasLabel("org.onap.relationships.inventory.BelongsTo").hasNext()); - - - assertEquals("if we look for old edge, it should be gone", false, - g.V().has(AAIProperties.NODE_TYPE, "generic-vnf").has("vnf-id", "toscaMigration-test-vnf").outE() - .hasLabel("hasLInterface").hasNext()); - } - - @Test - public void verifyGraphHasNoOldEdgeLabelsTest() { - assertEquals("Graph should have none of the old edge label" - , Long.valueOf(0) - , g.E().hasLabel("hasLInterface","usesLogicalLink").count().next()); - assertEquals("Graph should have none of the old edge label" - , Long.valueOf(2) - , g.E().hasLabel("org.onap.relationships.inventory.BelongsTo","tosca.relationships.network.LinksTo") - .count().next()); - } - - @Test - public void verifyGenericVnfHas1EdgeTest() { - assertEquals("Generic vnf should have 1 edge" - , Long.valueOf(1) - , g.V().has(AAIProperties.NODE_TYPE, "generic-vnf") - .both() - .count().next()); - - } - - @Test - public void verifyLogicalLinkHas2EdgesTest() { - assertEquals("Logical Link should have 2 edges" - , Long.valueOf(2) - , g.V().has(AAIProperties.NODE_TYPE, "logical-link") - .both() - .count().next()); - - assertTrue("Logical Link has source edge" - , g.V().has(AAIProperties.NODE_TYPE, "logical-link").bothE("org.onap.relationships.inventory.Source").hasNext()); - - assertTrue("Logical Link has default edge" - , g.V().has(AAIProperties.NODE_TYPE, "logical-link").bothE("tosca.relationships.network.LinksTo").hasNext()); - - } - - @Test - public void checkThatEdgeWithNoRulesDoesNotGetMigratedTest() { - assertTrue("Edge with no rule did not get migrated ", g.E().hasLabel("blah").hasNext()); - } - -} - -
\ No newline at end of file diff --git a/aai-resources/src/test/java/org/onap/aai/migration/v13/MigrateInstanceGroupSubTypeTest.java b/aai-resources/src/test/java/org/onap/aai/migration/v13/MigrateInstanceGroupSubTypeTest.java deleted file mode 100644 index a29fb6b..0000000 --- a/aai-resources/src/test/java/org/onap/aai/migration/v13/MigrateInstanceGroupSubTypeTest.java +++ /dev/null @@ -1,112 +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.migration.v13; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.mockito.Mockito.spy; -import static org.mockito.Mockito.when; - -import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource; -import org.apache.tinkerpop.gremlin.structure.Vertex; -import org.junit.After; -import org.junit.Before; -import org.junit.Test; -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.engines.QueryStyle; -import org.onap.aai.serialization.engines.JanusGraphDBEngine; -import org.onap.aai.serialization.engines.TransactionalGraphEngine; - -import org.janusgraph.core.JanusGraphFactory; -import org.janusgraph.core.JanusGraph; -import org.janusgraph.core.JanusGraphTransaction; - - -public class MigrateInstanceGroupSubTypeTest extends AAISetup{ - - private static final String SUB_TYPE_VALUE = "SubTypeValue"; - private final static Version version = Version.v13; - private final static ModelType introspectorFactoryType = ModelType.MOXY; - private final static QueryStyle queryStyle = QueryStyle.TRAVERSAL; - private final static DBConnectionType type = DBConnectionType.REALTIME; - private Loader loader; - private TransactionalGraphEngine dbEngine; - private JanusGraph graph; - private MigrateInstanceGroupSubType migration; - private GraphTraversalSource g; - private JanusGraphTransaction tx; - Vertex instanceGroup; - Vertex instanceGroupWithoutTSubType; - - - @Before - public void setUp() throws Exception { - graph = JanusGraphFactory.build().set("storage.backend", "inmemory").open(); - tx = graph.newTransaction(); - g = tx.traversal(); - loader = LoaderFactory.createLoaderForVersion(introspectorFactoryType, version); - dbEngine = new JanusGraphDBEngine( - queryStyle, - type, - loader); - instanceGroup = g.addV().property("aai-node-type", MigrateInstanceGroupSubType.INSTANCE_GROUP_NODE_TYPE) - .property( MigrateInstanceGroupSubType.SUB_TYPE_PROPERTY, SUB_TYPE_VALUE) - .next(); - - instanceGroupWithoutTSubType = g.addV().property("aai-node-type", MigrateInstanceGroupSubType.INSTANCE_GROUP_NODE_TYPE) - .next(); - - TransactionalGraphEngine spy = spy(dbEngine); - TransactionalGraphEngine.Admin adminSpy = spy(dbEngine.asAdmin()); - GraphTraversalSource traversal = g; - when(spy.asAdmin()).thenReturn(adminSpy); - when(adminSpy.getTraversalSource()).thenReturn(traversal); - migration = new MigrateInstanceGroupSubType(spy); - } - - @After - public void cleanUp() { - tx.rollback(); - graph.close(); - } - - - /*** - * checks if the type/subtype property were renamed - */ - - @Test - public void confirmTypeAndSubTypeWereRenamed() { - migration.run(); - - //instance group with sub-type - assertEquals(SUB_TYPE_VALUE, instanceGroup.property(MigrateInstanceGroupSubType.INSTANCE_GROUP_ROLE_PROPERTY).value()); - assertFalse(instanceGroup.property(MigrateInstanceGroupSubType.SUB_TYPE_PROPERTY).isPresent()); - - //instance group without subtype - assertFalse(instanceGroupWithoutTSubType.property(MigrateInstanceGroupSubType.INSTANCE_GROUP_ROLE_PROPERTY).isPresent()); - assertFalse(instanceGroupWithoutTSubType.property(MigrateInstanceGroupSubType.SUB_TYPE_PROPERTY).isPresent()); - } -}
\ No newline at end of file diff --git a/aai-resources/src/test/java/org/onap/aai/migration/v13/MigrateInstanceGroupTypeTest.java b/aai-resources/src/test/java/org/onap/aai/migration/v13/MigrateInstanceGroupTypeTest.java deleted file mode 100644 index 11e5157..0000000 --- a/aai-resources/src/test/java/org/onap/aai/migration/v13/MigrateInstanceGroupTypeTest.java +++ /dev/null @@ -1,112 +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.migration.v13; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.mockito.Mockito.spy; -import static org.mockito.Mockito.when; - -import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource; -import org.apache.tinkerpop.gremlin.structure.Vertex; -import org.junit.After; -import org.junit.Before; -import org.junit.Test; -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.engines.QueryStyle; -import org.onap.aai.serialization.engines.JanusGraphDBEngine; -import org.onap.aai.serialization.engines.TransactionalGraphEngine; - -import org.janusgraph.core.JanusGraphFactory; -import org.janusgraph.core.JanusGraph; -import org.janusgraph.core.JanusGraphTransaction; - - -public class MigrateInstanceGroupTypeTest extends AAISetup{ - - private static final String TYPE_VALUE = "TypeValue"; - private final static Version version = Version.v13; - private final static ModelType introspectorFactoryType = ModelType.MOXY; - private final static QueryStyle queryStyle = QueryStyle.TRAVERSAL; - private final static DBConnectionType type = DBConnectionType.REALTIME; - private Loader loader; - private TransactionalGraphEngine dbEngine; - private JanusGraph graph; - private MigrateInstanceGroupType migration; - private GraphTraversalSource g; - private JanusGraphTransaction tx; - Vertex instanceGroup; - Vertex instanceGroupWithoutType; - - - @Before - public void setUp() throws Exception { - graph = JanusGraphFactory.build().set("storage.backend", "inmemory").open(); - tx = graph.newTransaction(); - g = tx.traversal(); - loader = LoaderFactory.createLoaderForVersion(introspectorFactoryType, version); - dbEngine = new JanusGraphDBEngine( - queryStyle, - type, - loader); - instanceGroup = g.addV().property("aai-node-type", MigrateInstanceGroupType.INSTANCE_GROUP_NODE_TYPE) - .property( MigrateInstanceGroupType.TYPE_PROPERTY, TYPE_VALUE) - .next(); - - instanceGroupWithoutType = g.addV().property("aai-node-type", MigrateInstanceGroupType.INSTANCE_GROUP_NODE_TYPE) - .next(); - - TransactionalGraphEngine spy = spy(dbEngine); - TransactionalGraphEngine.Admin adminSpy = spy(dbEngine.asAdmin()); - GraphTraversalSource traversal = g; - when(spy.asAdmin()).thenReturn(adminSpy); - when(adminSpy.getTraversalSource()).thenReturn(traversal); - migration = new MigrateInstanceGroupType(spy); - } - - @After - public void cleanUp() { - tx.rollback(); - graph.close(); - } - - - /*** - * checks if the type/subtype property were renamed - */ - - @Test - public void confirmTypeAndSubTypeWereRenamed() { - migration.run(); - - //instance group with type - assertEquals(TYPE_VALUE, instanceGroup.property(MigrateInstanceGroupType.INSTANCE_GROUP_TYPE_PROPERTY).value()); - assertFalse(instanceGroup.property(MigrateInstanceGroupType.TYPE_PROPERTY).isPresent()); - - //instance group without type - assertFalse(instanceGroupWithoutType.property(MigrateInstanceGroupType.INSTANCE_GROUP_TYPE_PROPERTY).isPresent()); - assertFalse(instanceGroupWithoutType.property(MigrateInstanceGroupType.TYPE_PROPERTY).isPresent()); - } -}
\ No newline at end of file diff --git a/aai-resources/src/test/java/org/onap/aai/rest/AbstractSpringRestTest.java b/aai-resources/src/test/java/org/onap/aai/rest/AbstractSpringRestTest.java new file mode 100644 index 0000000..ab9fdd1 --- /dev/null +++ b/aai-resources/src/test/java/org/onap/aai/rest/AbstractSpringRestTest.java @@ -0,0 +1,128 @@ +/** + * ============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.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.ResourcesApp; +import org.onap.aai.ResourcesTestConfiguration; +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 = ResourcesApp.class) +@TestPropertySource(locations = "classpath:application-test.properties") +@ContextConfiguration(initializers = PropertyPasswordConfiguration.class) +@Import(ResourcesTestConfiguration.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(); + + headers = new HttpHeaders(); + + String authorization = Base64.getEncoder().encodeToString("AAI:AAI".getBytes("UTF-8")); + + 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"); + + headers.add("Authorization", "Basic " + authorization); + httpEntity = new HttpEntity(headers); + baseUrl = "https://localhost:" + randomPort; + } + + @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-resources/src/test/java/org/onap/aai/rest/BulkAddConsumerTest.java b/aai-resources/src/test/java/org/onap/aai/rest/BulkAddConsumerTest.java index 350a011..6e98a39 100644 --- a/aai-resources/src/test/java/org/onap/aai/rest/BulkAddConsumerTest.java +++ b/aai-resources/src/test/java/org/onap/aai/rest/BulkAddConsumerTest.java @@ -28,11 +28,9 @@ import javax.ws.rs.core.Response; import org.apache.commons.lang3.StringUtils; import org.junit.Test; -import org.onap.aai.introspection.Version; import com.att.eelf.configuration.EELFLogger; import com.att.eelf.configuration.EELFManager; - public class BulkAddConsumerTest extends BulkProcessorTestAbstraction { private static final EELFLogger logger = EELFManager.getInstance().getLogger(BulkAddConsumerTest.class.getName()); @@ -137,6 +135,6 @@ public class BulkAddConsumerTest extends BulkProcessorTestAbstraction { @Override protected String getUri() { - return "/aai/" + Version.getLatest().toString() + "/bulkadd"; + return "/aai/" + schemaVersions.getDefaultVersion().toString() + "/bulkadd"; } } diff --git a/aai-resources/src/test/java/org/onap/aai/rest/BulkProcessConsumerTest.java b/aai-resources/src/test/java/org/onap/aai/rest/BulkProcessConsumerTest.java index b6ec0ae..1d8702a 100644 --- a/aai-resources/src/test/java/org/onap/aai/rest/BulkProcessConsumerTest.java +++ b/aai-resources/src/test/java/org/onap/aai/rest/BulkProcessConsumerTest.java @@ -1,285 +1,298 @@ -/**
- * ============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 static org.mockito.Mockito.when;
-
-import java.io.IOException;
-
-import javax.ws.rs.core.Response;
-
-import org.apache.commons.lang3.StringUtils;
-import org.json.JSONException;
-import org.junit.Test;
-import org.onap.aai.introspection.Version;
-import org.skyscreamer.jsonassert.JSONAssert;
-
-import com.att.eelf.configuration.EELFLogger;
-import com.att.eelf.configuration.EELFManager;
-import org.springframework.mock.web.MockHttpServletRequest;
-
-public class BulkProcessConsumerTest extends BulkProcessorTestAbstraction {
-
- private static final EELFLogger logger = EELFManager.getInstance().getLogger(BulkProcessConsumerTest.class.getName());
- private LegacyMoxyConsumer legacyMoxyConsumer;
-
- @Test
- public void bulkAddPayloadInBulkProcessTest() throws IOException {
-
- when(uriInfo.getPath()).thenReturn(uri);
- when(uriInfo.getPath(false)).thenReturn(uri);
-
- String payload = getBulkPayload("pserver-transactions");
- Response response = executeRequest(payload);
-
- assertEquals("Valid Response Code", Response.Status.CREATED.getStatusCode(), response.getStatus());
- assertEquals("Contains 3 {\"201\":null}", 3, StringUtils.countMatches(response.getEntity().toString(), "{\"201\":null}"));
- }
-
- @Test
- public void bulkProcessPayloadTest() throws IOException {
-
- when(uriInfo.getPath()).thenReturn(uri);
- when(uriInfo.getPath(false)).thenReturn(uri);
-
- String payload = getBulkPayload("pserver-bulk-process-transactions");
- Response response = executeRequest(payload);
-
- assertEquals("Valid Response Code", Response.Status.CREATED.getStatusCode(), response.getStatus());
- assertEquals("Contains 1 {\"201\":null}", 1, StringUtils.countMatches(response.getEntity().toString(), "{\"201\":null}"));
- assertEquals("Contains 1 {\"404\":\"{", 1, StringUtils.countMatches(response.getEntity().toString(), "{\"404\":\"{"));
- assertEquals("Contains 1 ERR.5.4.6114", 1, StringUtils.countMatches(response.getEntity().toString(), "ERR.5.4.6114"));
- }
-
- @Test
- public void bulkProcessComplexDeletePayloadTest() throws IOException {
-
- when(uriInfo.getPath()).thenReturn(uri);
- when(uriInfo.getPath(false)).thenReturn(uri);
-
- String payload = getBulkPayload("complex-bulk-process-transactions");
- Response response = executeRequest(payload);
-
- System.out.println(response.getEntity().toString());
- assertEquals("Valid Response Code", Response.Status.CREATED.getStatusCode(), response.getStatus());
- assertEquals("Contains 0 {\"201\":null}", 0, StringUtils.countMatches(response.getEntity().toString(), "{\"201\":null}"));
- assertEquals("Contains 1 {\"404\":\"{", 1, StringUtils.countMatches(response.getEntity().toString(), "{\"404\":\"{"));
- assertEquals("Contains 1 ERR.5.4.6114", 1, StringUtils.countMatches(response.getEntity().toString(), "ERR.5.4.6114"));
- }
-
- @Test
- public void testBulkDeletePserverAndComplexRelationship() throws IOException, JSONException {
-
- legacyMoxyConsumer = new LegacyMoxyConsumer();
-
- String pserverData = getPayload("payloads/relationship/pserver-bugfix.json");
- String complexData = getPayload("payloads/relationship/complex-bugfix.json");
-
- String hostname = "pserver-9876543210-77-jenkins";
- String physicalLocationId ="complex-987654321-77-jenkins";
-
- String pserverUri = String.format("cloud-infrastructure/pservers/pserver/%s", hostname);
- String complexUri = String.format("cloud-infrastructure/complexes/complex/%s", physicalLocationId);
-
- doSetupResource(pserverUri, pserverData);
- doSetupResource(complexUri, complexData);
-
- String complexToPserverRelationshipData = getPayload("payloads/relationship/pserver-complex-relationship-for-bulk.json");
- String complexToPserverRelationshipUri = String.format(
- "cloud-infrastructure/pservers/pserver/%s/relationship-list/relationship", hostname);
-
- Response response = legacyMoxyConsumer.updateRelationship(
- complexToPserverRelationshipData,
- Version.getLatest().toString(),
- complexToPserverRelationshipUri,
- httpHeaders,
- uriInfo,
- new MockHttpServletRequest("DELETE", "http://www.test.com")
- );
-
- assertNotNull("Response from the legacy moxy consumer returned null", response);
- int code = response.getStatus();
- if(!VALID_HTTP_STATUS_CODES.contains(code)){
- System.out.println("Response Code: " + code + "\tEntity: " + response.getEntity());
- }
-
- assertEquals("Expected to return status created from the response",
- Response.Status.OK.getStatusCode(), response.getStatus());
- logger.info("Response Code: " + code + "\tEntity: " + response.getEntity());
-
- // TODO - Need to actually verify the relationship between pserver and cloud-region
-
- String payload = getBulkPayload("complex-bulk-process-delete-transactions");
- Response responseBulkDelete = executeRequest(payload);
-
- System.out.println(responseBulkDelete.getEntity().toString());
-
- code = responseBulkDelete.getStatus();
-
- if(!VALID_HTTP_STATUS_CODES.contains(code)){
- System.out.println("Response Code: " + code + "\tEntity: " + responseBulkDelete.getEntity());
- System.out.println("Response Code: " + code + "\tEntity: " + responseBulkDelete.getEntity());
- }
- assertEquals("Expected to return status created from the response",
- Response.Status.CREATED.getStatusCode(), responseBulkDelete.getStatus());
- assertEquals("Contains 0 {\"204\":null}", 1, StringUtils.countMatches(responseBulkDelete.getEntity().toString(), "{\"204\":null}"));
-
- }
-
- protected void doSetupResource(String uri, String payload) throws JSONException {
-
- when(uriInfo.getPath()).thenReturn(uri);
- when(uriInfo.getPath(false)).thenReturn(uri);
-
- Response response = legacyMoxyConsumer.getLegacy(
- "",
- "-1",
- "-1",
- Version.getLatest().toString(),
- uri,
- "all",
- "false",
- httpHeaders,
- uriInfo,
- new MockHttpServletRequest("GET", "http://www.test.com")
- );
-
- assertNotNull("Response from the legacy moxy consumer returned null", response);
- assertEquals("Expected to not have the data already in memory",
- Response.Status.NOT_FOUND.getStatusCode(), response.getStatus());
-
- response = legacyMoxyConsumer.update(
- payload,
- Version.getLatest().toString(),
- uri,
- httpHeaders,
- uriInfo,
- new MockHttpServletRequest("PUT", "http://www.test.com")
- );
-
- assertNotNull("Response from the legacy moxy consumer returned null", response);
- int code = response.getStatus();
- if(!VALID_HTTP_STATUS_CODES.contains(code)){
- System.out.println("Response Code: " + code + "\tEntity: " + response.getEntity());
- }
- assertEquals("Expected to return status created from the response",
- Response.Status.CREATED.getStatusCode(), response.getStatus());
-
- queryParameters.add("depth", "10000");
- response = legacyMoxyConsumer.getLegacy(
- "",
- "-1",
- "-1",
- Version.getLatest().toString(),
- uri,
- "all",
- "false",
- httpHeaders,
- uriInfo,
- new MockHttpServletRequest("GET", "http://www.test.com")
- );
-
- assertNotNull("Response from the legacy moxy consumer returned null", response);
- assertEquals("Expected to return the pserver data that was just put in memory",
- Response.Status.OK.getStatusCode(), response.getStatus());
-
- if("".equalsIgnoreCase(payload)){
- payload = "{}";
- }
-
- JSONAssert.assertEquals(payload, response.getEntity().toString(), false);
- }
-
-
- @Test
- public void bulkAddInvalidMethodTest() throws IOException {
-
- when(uriInfo.getPath()).thenReturn(uri);
- when(uriInfo.getPath(false)).thenReturn(uri);
-
- String payload = getBulkPayload("pserver-transactions-invalid-method");
- Response response = executeRequest(payload);
-
- assertEquals("Valid Response Code", Response.Status.CREATED.getStatusCode(), response.getStatus());
- assertEquals("Contains 1 {\"400\":\"{", 1, StringUtils.countMatches(response.getEntity().toString(), "{\"400\":\"{"));
- assertEquals("Contains 1 ERR.5.4.6118", 1, StringUtils.countMatches(response.getEntity().toString(), "ERR.5.4.6118"));
- }
-
- @Test
- public void bulkAddThrowExceptionWhenPayloadContainsNoTransactionsTest(){
-
- when(uriInfo.getPath()).thenReturn(uri);
- when(uriInfo.getPath(false)).thenReturn(uri);
-
- String payload = "{\"transactions\":[]}";
- Response response = executeRequest(payload);
-
- assertEquals("Bad Request", Response.Status.BAD_REQUEST.getStatusCode(), response.getStatus());
- assertEquals("Contains error code", true, response.getEntity().toString().contains("ERR.5.4.6118"));
- }
-
- @Test
- public void bulkAddThrowExceptionWhenInvalidJsonTest() throws IOException {
-
- when(uriInfo.getPath()).thenReturn(uri);
- when(uriInfo.getPath(false)).thenReturn(uri);
-
- String payload = "{";
- Response response = executeRequest(payload);
-
- assertEquals("Bad Request", Response.Status.BAD_REQUEST.getStatusCode(), response.getStatus());
- assertEquals("Contains error code", true, response.getEntity().toString().contains("ERR.5.4.6111"));
- }
- @Test
- public void bulkProcessCheckMeetsLimit() throws IOException{
- when(uriInfo.getPath()).thenReturn(uri);
- when(uriInfo.getPath(false)).thenReturn(uri);
-
- String payload = getBulkPayload("pserver-bulk-limit-meet");
- Response response = executeRequest(payload);
-
- assertEquals("Created", Response.Status.CREATED.getStatusCode(), response.getStatus());
- assertEquals("Contains 30 {\"201\":null}", 30, StringUtils.countMatches(response.getEntity().toString(), "{\"201\":null}"));
- }
-
- @Test
- public void bulkProcessCheckExceedsLimit() throws IOException{
- when(uriInfo.getPath()).thenReturn(uri);
- when(uriInfo.getPath(false)).thenReturn(uri);
-
- String payload = getBulkPayload("pserver-bulk-limit-exceed");
- Response response = executeRequest(payload);
-
- assertEquals("Bad Request", Response.Status.BAD_REQUEST.getStatusCode(), response.getStatus());
- assertEquals("Contains error code", true, response.getEntity().toString().contains("ERR.5.4.6147"));
- }
-
- @Override
- protected BulkConsumer getConsumer(){
- return new BulkProcessConsumer();
- }
-
- @Override
- protected String getUri() {
- return "/aai/" + Version.getLatest().toString() + "/bulkprocess";
- }
-}
+/** + * ============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 static org.mockito.Mockito.when; + +import java.io.IOException; + +import javax.ws.rs.core.Response; + +import org.apache.commons.lang3.StringUtils; +import org.json.JSONException; +import org.junit.Test; +import org.onap.aai.dbmap.AAIGraph; +import org.skyscreamer.jsonassert.JSONAssert; + +import com.att.eelf.configuration.EELFLogger; +import com.att.eelf.configuration.EELFManager; +import org.springframework.mock.web.MockHttpServletRequest; + +public class BulkProcessConsumerTest extends BulkProcessorTestAbstraction { + + private static final EELFLogger logger = EELFManager.getInstance().getLogger(BulkProcessConsumerTest.class.getName()); + private LegacyMoxyConsumer legacyMoxyConsumer; + + @Test + public void bulkAddPayloadInBulkProcessTest() throws IOException { + + when(uriInfo.getPath()).thenReturn(uri); + when(uriInfo.getPath(false)).thenReturn(uri); + + String payload = getBulkPayload("pserver-transactions"); + Response response = executeRequest(payload); + + assertEquals("Valid Response Code", Response.Status.CREATED.getStatusCode(), response.getStatus()); + assertEquals("Contains 3 {\"201\":null}", 3, StringUtils.countMatches(response.getEntity().toString(), "{\"201\":null}")); + } + + @Test + public void bulkProcessPayloadTest() throws IOException { + + when(uriInfo.getPath()).thenReturn(uri); + when(uriInfo.getPath(false)).thenReturn(uri); + + String payload = getBulkPayload("pserver-bulk-process-transactions"); + Response response = executeRequest(payload); + + assertEquals("Valid Response Code", Response.Status.CREATED.getStatusCode(), response.getStatus()); + assertEquals("Contains 1 {\"201\":null}", 1, StringUtils.countMatches(response.getEntity().toString(), "{\"201\":null}")); + assertEquals("Contains 1 {\"404\":\"{", 1, StringUtils.countMatches(response.getEntity().toString(), "{\"404\":\"{")); + assertEquals("Contains 1 ERR.5.4.6114", 1, StringUtils.countMatches(response.getEntity().toString(), "ERR.5.4.6114")); + } + + @Test + public void bulkProcessPayloadWithPatchTest() throws IOException { + + when(uriInfo.getPath()).thenReturn(uri); + when(uriInfo.getPath(false)).thenReturn(uri); + + String payload = getBulkPayload("pserver-bulk-process-transactions-with-patch"); + Response response = executeRequest(payload); + System.out.println(response.getEntity()); + System.out.println(AAIGraph.getInstance().getGraph().newTransaction().traversal().V().has("fqdn", "NEW").count().next()); + assertEquals("Valid Response Code", Response.Status.CREATED.getStatusCode(), response.getStatus()); + } + + @Test + public void bulkProcessComplexDeletePayloadTest() throws IOException { + + when(uriInfo.getPath()).thenReturn(uri); + when(uriInfo.getPath(false)).thenReturn(uri); + + String payload = getBulkPayload("complex-bulk-process-transactions"); + Response response = executeRequest(payload); + + System.out.println(response.getEntity().toString()); + assertEquals("Valid Response Code", Response.Status.CREATED.getStatusCode(), response.getStatus()); + assertEquals("Contains 0 {\"201\":null}", 0, StringUtils.countMatches(response.getEntity().toString(), "{\"201\":null}")); + assertEquals("Contains 1 {\"404\":\"{", 1, StringUtils.countMatches(response.getEntity().toString(), "{\"404\":\"{")); + assertEquals("Contains 1 ERR.5.4.6114", 1, StringUtils.countMatches(response.getEntity().toString(), "ERR.5.4.6114")); + } + + @Test + public void testBulkDeletePserverAndComplexRelationship() throws IOException, JSONException { + + legacyMoxyConsumer = new LegacyMoxyConsumer(); + + String pserverData = getPayload("payloads/relationship/pserver-bugfix.json"); + String complexData = getPayload("payloads/relationship/complex-bugfix.json"); + + String hostname = "pserver-9876543210-77-jenkins"; + String physicalLocationId ="complex-987654321-77-jenkins"; + + String pserverUri = String.format("cloud-infrastructure/pservers/pserver/%s", hostname); + String complexUri = String.format("cloud-infrastructure/complexes/complex/%s", physicalLocationId); + + doSetupResource(pserverUri, pserverData); + doSetupResource(complexUri, complexData); + + String complexToPserverRelationshipData = getPayload("payloads/relationship/pserver-complex-relationship-for-bulk.json"); + String complexToPserverRelationshipUri = String.format( + "cloud-infrastructure/pservers/pserver/%s/relationship-list/relationship", hostname); + + Response response = legacyMoxyConsumer.updateRelationship( + complexToPserverRelationshipData, + schemaVersions.getDefaultVersion().toString(), + complexToPserverRelationshipUri, + httpHeaders, + uriInfo, + new MockHttpServletRequest("DELETE", "http://www.test.com") + ); + + assertNotNull("Response from the legacy moxy consumer returned null", response); + int code = response.getStatus(); + if(!VALID_HTTP_STATUS_CODES.contains(code)){ + System.out.println("Response Code: " + code + "\tEntity: " + response.getEntity()); + } + + assertEquals("Expected to return status created from the response", + Response.Status.OK.getStatusCode(), response.getStatus()); + logger.info("Response Code: " + code + "\tEntity: " + response.getEntity()); + + // TODO - Need to actually verify the relationship between pserver and cloud-region + + String payload = getBulkPayload("complex-bulk-process-delete-transactions"); + Response responseBulkDelete = executeRequest(payload); + + System.out.println(responseBulkDelete.getEntity().toString()); + + code = responseBulkDelete.getStatus(); + + if(!VALID_HTTP_STATUS_CODES.contains(code)){ + System.out.println("Response Code: " + code + "\tEntity: " + responseBulkDelete.getEntity()); + System.out.println("Response Code: " + code + "\tEntity: " + responseBulkDelete.getEntity()); + } + assertEquals("Expected to return status created from the response", + Response.Status.CREATED.getStatusCode(), responseBulkDelete.getStatus()); + assertEquals("Contains 0 {\"204\":null}", 1, StringUtils.countMatches(responseBulkDelete.getEntity().toString(), "{\"204\":null}")); + + } + + protected void doSetupResource(String uri, String payload) throws JSONException { + + when(uriInfo.getPath()).thenReturn(uri); + when(uriInfo.getPath(false)).thenReturn(uri); + + Response response = legacyMoxyConsumer.getLegacy( + "", + "-1", + "-1", + schemaVersions.getDefaultVersion().toString(), + uri, + "all", + "false", + httpHeaders, + uriInfo, + new MockHttpServletRequest("GET", "http://www.test.com") + ); + + assertNotNull("Response from the legacy moxy consumer returned null", response); + assertEquals("Expected to not have the data already in memory", + Response.Status.NOT_FOUND.getStatusCode(), response.getStatus()); + + response = legacyMoxyConsumer.update( + payload, + schemaVersions.getDefaultVersion().toString(), + uri, + httpHeaders, + uriInfo, + new MockHttpServletRequest("PUT", "http://www.test.com") + ); + + assertNotNull("Response from the legacy moxy consumer returned null", response); + int code = response.getStatus(); + if(!VALID_HTTP_STATUS_CODES.contains(code)){ + System.out.println("Response Code: " + code + "\tEntity: " + response.getEntity()); + } + assertEquals("Expected to return status created from the response", + Response.Status.CREATED.getStatusCode(), response.getStatus()); + + queryParameters.add("depth", "10000"); + response = legacyMoxyConsumer.getLegacy( + "", + "-1", + "-1", + schemaVersions.getDefaultVersion().toString(), + uri, + "all", + "false", + httpHeaders, + uriInfo, + new MockHttpServletRequest("GET", "http://www.test.com") + ); + + assertNotNull("Response from the legacy moxy consumer returned null", response); + assertEquals("Expected to return the pserver data that was just put in memory", + Response.Status.OK.getStatusCode(), response.getStatus()); + + if("".equalsIgnoreCase(payload)){ + payload = "{}"; + } + + JSONAssert.assertEquals(payload, response.getEntity().toString(), false); + } + + + @Test + public void bulkAddInvalidMethodTest() throws IOException { + + when(uriInfo.getPath()).thenReturn(uri); + when(uriInfo.getPath(false)).thenReturn(uri); + + String payload = getBulkPayload("pserver-transactions-invalid-method"); + Response response = executeRequest(payload); + + assertEquals("Valid Response Code", Response.Status.CREATED.getStatusCode(), response.getStatus()); + assertEquals("Contains 1 {\"400\":\"{", 1, StringUtils.countMatches(response.getEntity().toString(), "{\"400\":\"{")); + assertEquals("Contains 1 ERR.5.4.6118", 1, StringUtils.countMatches(response.getEntity().toString(), "ERR.5.4.6118")); + } + + @Test + public void bulkAddThrowExceptionWhenPayloadContainsNoTransactionsTest(){ + + when(uriInfo.getPath()).thenReturn(uri); + when(uriInfo.getPath(false)).thenReturn(uri); + + String payload = "{\"transactions\":[]}"; + Response response = executeRequest(payload); + + assertEquals("Bad Request", Response.Status.BAD_REQUEST.getStatusCode(), response.getStatus()); + assertEquals("Contains error code", true, response.getEntity().toString().contains("ERR.5.4.6118")); + } + + @Test + public void bulkAddThrowExceptionWhenInvalidJsonTest() throws IOException { + + when(uriInfo.getPath()).thenReturn(uri); + when(uriInfo.getPath(false)).thenReturn(uri); + + String payload = "{"; + Response response = executeRequest(payload); + + assertEquals("Bad Request", Response.Status.BAD_REQUEST.getStatusCode(), response.getStatus()); + assertEquals("Contains error code", true, response.getEntity().toString().contains("ERR.5.4.6111")); + } + @Test + public void bulkProcessCheckMeetsLimit() throws IOException{ + when(uriInfo.getPath()).thenReturn(uri); + when(uriInfo.getPath(false)).thenReturn(uri); + + String payload = getBulkPayload("pserver-bulk-limit-meet"); + Response response = executeRequest(payload); + + assertEquals("Created", Response.Status.CREATED.getStatusCode(), response.getStatus()); + assertEquals("Contains 30 {\"201\":null}", 30, StringUtils.countMatches(response.getEntity().toString(), "{\"201\":null}")); + } + + @Test + public void bulkProcessCheckExceedsLimit() throws IOException{ + when(uriInfo.getPath()).thenReturn(uri); + when(uriInfo.getPath(false)).thenReturn(uri); + + String payload = getBulkPayload("pserver-bulk-limit-exceed"); + Response response = executeRequest(payload); + + assertEquals("Bad Request", Response.Status.BAD_REQUEST.getStatusCode(), response.getStatus()); + assertEquals("Contains error code", true, response.getEntity().toString().contains("ERR.5.4.6147")); + } + + @Override + protected BulkConsumer getConsumer(){ + return new BulkProcessConsumer(); + } + + @Override + protected String getUri() { + return "/aai/" + schemaVersions.getDefaultVersion().toString() + "/bulkprocess"; + } +} diff --git a/aai-resources/src/test/java/org/onap/aai/rest/BulkProcessorTestAbstraction.java b/aai-resources/src/test/java/org/onap/aai/rest/BulkProcessorTestAbstraction.java index 40e8f05..e735041 100644 --- a/aai-resources/src/test/java/org/onap/aai/rest/BulkProcessorTestAbstraction.java +++ b/aai-resources/src/test/java/org/onap/aai/rest/BulkProcessorTestAbstraction.java @@ -41,8 +41,6 @@ import org.junit.BeforeClass; import org.mockito.Mockito; import org.onap.aai.AAISetup; import org.onap.aai.dbmap.AAIGraph; -import org.onap.aai.introspection.ModelInjestor; -import org.onap.aai.introspection.Version; import com.att.eelf.configuration.EELFLogger; import com.att.eelf.configuration.EELFManager; @@ -74,16 +72,21 @@ public abstract class BulkProcessorTestAbstraction extends AAISetup { protected String uri; + private boolean initialized = false; private static final EELFLogger logger = EELFManager.getInstance().getLogger(BulkProcessorTestAbstraction.class.getName()); @BeforeClass public static void setupRest(){ - AAIGraph.getInstance(); - ModelInjestor.getInstance(); + // AAIGraph.getInstance(); + } @Before public void setup(){ + if(!initialized){ + initialized = true; + AAIGraph.getInstance(); + } logger.info("Starting the setup for the integration tests of Rest Endpoints"); bulkConsumer = getConsumer(); @@ -126,7 +129,7 @@ public abstract class BulkProcessorTestAbstraction extends AAISetup { return bulkConsumer.bulkProcessor( payload.replaceAll("<UUID>", UUID.randomUUID().toString()), - Version.getLatest().toString(), + schemaVersions.getDefaultVersion().toString(), httpHeaders, uriInfo, mockReq diff --git a/aai-resources/src/test/java/org/onap/aai/rest/ConfigurationTest.java b/aai-resources/src/test/java/org/onap/aai/rest/ConfigurationTest.java index b6d8872..f030f20 100644 --- a/aai-resources/src/test/java/org/onap/aai/rest/ConfigurationTest.java +++ b/aai-resources/src/test/java/org/onap/aai/rest/ConfigurationTest.java @@ -22,10 +22,10 @@ package org.onap.aai.rest; import com.jayway.jsonpath.JsonPath; import org.junit.Before; import org.junit.Test; -import org.junit.runner.RunWith; import org.onap.aai.ResourcesApp; import org.onap.aai.ResourcesTestConfiguration; import org.onap.aai.config.PropertyPasswordConfiguration; +import org.onap.aai.config.SpringContextAware; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.context.embedded.LocalServerPort; import org.springframework.boot.test.context.SpringBootTest; @@ -33,7 +33,6 @@ 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.io.UnsupportedEncodingException; @@ -47,13 +46,12 @@ import static org.junit.Assert.assertEquals; /** * Test REST requests against configuration resource */ -@RunWith(SpringRunner.class) -@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT, classes = ResourcesApp.class) + @TestPropertySource(locations = "classpath:application-test.properties") -@ContextConfiguration(initializers = PropertyPasswordConfiguration.class) +@ContextConfiguration(initializers = PropertyPasswordConfiguration.class, classes = {SpringContextAware.class}) @Import(ResourcesTestConfiguration.class) -public class ConfigurationTest { - +@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT, classes = {SpringContextAware.class, ResourcesApp.class}) +public class ConfigurationTest extends AbstractSpringRestTest { @Autowired RestTemplate restTemplate; @@ -85,18 +83,23 @@ public class ConfigurationTest { @Test public void testGetPutPatchConfiguration() { - String hostname = "pservertest" + UUID.randomUUID().toString(); - String endpoint = "/aai/v13/cloud-infrastructure/pservers/pserver/" + hostname; + String cid = "configtest" + UUID.randomUUID().toString(); + String endpoint = "/aai/v12/network/configurations/configuration/" + cid; ResponseEntity responseEntity = null; responseEntity = restTemplate.exchange(baseUrl + endpoint, HttpMethod.GET, httpEntity, String.class); assertEquals(HttpStatus.NOT_FOUND, responseEntity.getStatusCode()); + //String putBody = " configuration-id, configuration-type configuration-sub-type"; String putBody = "{" + - "\"hostname\": \"" + hostname + "\"," + - "\"ptnii-equip-name\": \"type1\"," + - "\"equip-type\": \"subtype1\" " + + "\"configuration-id\": \"" + cid + "\"," + + "\"configuration-type\": \"type1\"," + + "\"configuration-sub-type\": \"subtype1\", " + + "\"operational-status\": \"example1\", " + + "\"orchestration-status\": \"example1\", " + + "\"configuration-selflink\": \"example1\", " + + "\"model-customization-id\": \"example1\" " + "}"; httpEntityPut = new HttpEntity<String>(putBody, headers); responseEntity = restTemplate.exchange(baseUrl + endpoint, HttpMethod.PUT, httpEntityPut, String.class); @@ -110,9 +113,13 @@ public class ConfigurationTest { assertEquals(HttpStatus.OK, responseEntity.getStatusCode()); String patchBody = "{" + - "\"hostname\": \"" + hostname + "\"," + - "\"ptnii-equip-name\": \"type2\"," + - "\"equip-type\": \"subtype2\" " + + "\"configuration-id\": \"" + cid + "\"," + + "\"configuration-type\": \"type2\"," + + "\"configuration-sub-type\": \"subtype2\", " + + "\"operational-status\": \"example1\", " + + "\"orchestration-status\": \"example1\", " + + "\"configuration-selflink\": \"example1\", " + + "\"model-customization-id\": \"example1\" " + "}"; headers.put("Content-Type", Arrays.asList("application/merge-patch+json")); headers.add("X-HTTP-Method-Override", "PATCH"); @@ -126,14 +133,14 @@ public class ConfigurationTest { assertEquals(HttpStatus.OK, responseEntity.getStatusCode()); String body = responseEntity.getBody().toString(); - String ptniiEquipName = JsonPath.read(body, "$.ptnii-equip-name"); + String configurationType = JsonPath.read(body, "$.configuration-type"); - assertEquals("type2", ptniiEquipName); + assertEquals("type2", configurationType); patchBody = "{" + - "\"hostname\": \"" + hostname + "\"," + - "\"ptnii-equip-name\": \"type3\"," + - "\"equip-type\": \"subtype3\" " + + "\"configuration-id\": \"" + cid + "\"," + + "\"configuration-type\": \"type3\"," + + "\"configuration-sub-type\": \"subtype3\" " + "}"; httpEntityPatch = new HttpEntity<String>(patchBody, headers); @@ -144,9 +151,9 @@ public class ConfigurationTest { assertEquals(HttpStatus.OK, responseEntity.getStatusCode()); body = responseEntity.getBody().toString(); - ptniiEquipName = JsonPath.read(body, "$.ptnii-equip-name"); + configurationType = JsonPath.read(body, "$.configuration-type"); - assertEquals("type3", ptniiEquipName); + assertEquals("type3", configurationType); } diff --git a/aai-resources/src/test/java/org/onap/aai/rest/CustomerFilterSearchTest.java b/aai-resources/src/test/java/org/onap/aai/rest/CustomerFilterSearchTest.java new file mode 100644 index 0000000..f22c915 --- /dev/null +++ b/aai-resources/src/test/java/org/onap/aai/rest/CustomerFilterSearchTest.java @@ -0,0 +1,66 @@ +/** + * ============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.Test; +import org.onap.aai.PayloadUtil; +import org.springframework.http.*; + +import java.util.Base64; +import java.util.Collections; + +import static org.hamcrest.CoreMatchers.containsString; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertThat; + +public class CustomerFilterSearchTest extends AbstractSpringRestTest { + + @Test + public void testWhenContentTypeMissingItWillFunctionalAndCreateObjectWithPayloadInJson() throws Exception { + + String id = "customer-987654321-91"; + String endpoint = "/aai/v11/business/customers/customer/"+ id; + HttpHeaders headers = new HttpHeaders(); + + headers.setAccept(Collections.singletonList(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); + String body = PayloadUtil.getResourcePayload("customer.json"); + + httpEntity = new HttpEntity(body, headers); + baseUrl = "https://localhost:" + randomPort; + + ResponseEntity responseEntity; + responseEntity = restTemplate.exchange(baseUrl + endpoint, HttpMethod.PUT, httpEntity, String.class); + + assertEquals(HttpStatus.CREATED, responseEntity.getStatusCode()); + + String searchUrl = baseUrl + "/aai/v11/business/customers?subscriber-name=subscriber-name-987654321-91&depth=0"; + httpEntity = new HttpEntity(headers); + responseEntity = restTemplate.exchange(searchUrl, HttpMethod.GET, httpEntity, String.class); + assertEquals(HttpStatus.OK, responseEntity.getStatusCode()); + assertThat(responseEntity.getBody().toString(), containsString("global-customer-id")); + } + +} diff --git a/aai-resources/src/test/java/org/onap/aai/rest/DepthTest.java b/aai-resources/src/test/java/org/onap/aai/rest/DepthTest.java new file mode 100644 index 0000000..c664c22 --- /dev/null +++ b/aai-resources/src/test/java/org/onap/aai/rest/DepthTest.java @@ -0,0 +1,64 @@ +/** + * ============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.hamcrest.MatcherAssert; +import org.junit.Test; +import org.onap.aai.PayloadUtil; +import org.springframework.http.HttpEntity; +import org.springframework.http.HttpMethod; +import org.springframework.http.HttpStatus; +import org.springframework.http.ResponseEntity; + +import java.io.IOException; + +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.containsString; +import static org.hamcrest.Matchers.is; +import static org.hamcrest.Matchers.not; + +public class DepthTest extends AbstractSpringRestTest { + + @Test + public void testOldVersionReturnAllChildrenAndNewVersionReturnDepthZero() throws IOException { + + String id = "customer-987654321-91"; + String endpoint = "/aai/v9/business/customers/customer/"+ id; + + String body = PayloadUtil.getResourcePayload("customer.json"); + + httpEntity = new HttpEntity(body, headers); + + ResponseEntity responseEntity; + responseEntity = restTemplate.exchange(baseUrl + endpoint, HttpMethod.PUT, httpEntity, String.class); + assertThat(responseEntity.getStatusCode(), is(HttpStatus.CREATED)); + + responseEntity = restTemplate.exchange(baseUrl + endpoint, HttpMethod.GET, httpEntity, String.class); + assertThat(responseEntity.getStatusCode(), is(HttpStatus.OK)); + String responseBody = responseEntity.getBody().toString(); + assertThat(responseBody, not(containsString("service-instance-id"))); + endpoint = "/aai/v8/business/customers/customer/"+ id; + + responseEntity = restTemplate.exchange(baseUrl + endpoint, HttpMethod.GET, httpEntity, String.class); + assertThat(responseEntity.getStatusCode(), is(HttpStatus.OK)); + responseBody = responseEntity.getBody().toString(); + assertThat(responseBody, containsString("service-instance-id")); + } +} diff --git a/aai-resources/src/test/java/org/onap/aai/rest/ExampleConsumerTest.java b/aai-resources/src/test/java/org/onap/aai/rest/ExampleConsumerTest.java index 22980ad..3f50ba3 100644 --- a/aai-resources/src/test/java/org/onap/aai/rest/ExampleConsumerTest.java +++ b/aai-resources/src/test/java/org/onap/aai/rest/ExampleConsumerTest.java @@ -27,8 +27,6 @@ import org.junit.Test; import org.mockito.Mockito; import org.onap.aai.AAISetup; import org.onap.aai.dbmap.AAIGraph; -import org.onap.aai.introspection.ModelInjestor; -import org.onap.aai.introspection.Version; import javax.ws.rs.core.*; @@ -69,7 +67,7 @@ public class ExampleConsumerTest extends AAISetup { @BeforeClass public static void setupRest(){ AAIGraph.getInstance(); - ModelInjestor.getInstance(); + } @Before @@ -114,7 +112,7 @@ public class ExampleConsumerTest extends AAISetup { public void testGetExampleRespondsWithOkStatusForValidObject(){ Response response = exampleConsumer.getExample( - Version.getLatest().toString(), + schemaVersions.getDefaultVersion().toString(), "pserver", httpHeaders, uriInfo, @@ -134,7 +132,7 @@ public class ExampleConsumerTest extends AAISetup { when(uriInfo.getPath(false)).thenReturn("examples/fakeObject"); Response response = exampleConsumer.getExample( - Version.getLatest().toString(), + schemaVersions.getDefaultVersion().toString(), "testRandomCrazyObject", httpHeaders, uriInfo, diff --git a/aai-resources/src/test/java/org/onap/aai/rest/InvalidURITest.java b/aai-resources/src/test/java/org/onap/aai/rest/InvalidURITest.java new file mode 100644 index 0000000..ea41872 --- /dev/null +++ b/aai-resources/src/test/java/org/onap/aai/rest/InvalidURITest.java @@ -0,0 +1,47 @@ +/** + * ============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.Test; +import org.springframework.http.HttpMethod; +import org.springframework.http.HttpStatus; +import org.springframework.http.ResponseEntity; + +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.containsString; +import static org.junit.Assert.assertEquals; + +public class InvalidURITest extends AbstractSpringRestTest { + + @Test + public void testWhenUriNotStartsWithAAIItReturnsProperNotFound(){ + + String endpoint = "/aai1/v11/cloud-infrastructure/pservers/pserver/test"; + + ResponseEntity responseEntity; + responseEntity = restTemplate.exchange(baseUrl + endpoint, HttpMethod.GET, httpEntity, String.class); + + String body = responseEntity.getBody().toString(); + System.out.println(body); + + assertEquals(HttpStatus.BAD_REQUEST, responseEntity.getStatusCode()); + assertThat(body, containsString("Unrecognized AAI function ")); + } +} diff --git a/aai-resources/src/test/java/org/onap/aai/rest/LegacyMoxyConsumerTest.java b/aai-resources/src/test/java/org/onap/aai/rest/LegacyMoxyConsumerTest.java index 660d663..3845fb0 100644 --- a/aai-resources/src/test/java/org/onap/aai/rest/LegacyMoxyConsumerTest.java +++ b/aai-resources/src/test/java/org/onap/aai/rest/LegacyMoxyConsumerTest.java @@ -31,13 +31,12 @@ import org.mockito.Mockito; import org.onap.aai.AAISetup; import org.onap.aai.dbmap.AAIGraph; import org.onap.aai.exceptions.AAIException; -import org.onap.aai.introspection.ModelInjestor; -import org.onap.aai.introspection.Version; import org.onap.aai.util.AAIConfig; import org.onap.aai.util.AAIConstants; import org.skyscreamer.jsonassert.JSONAssert; import org.springframework.mock.web.MockHttpServletRequest; +import org.springframework.test.annotation.DirtiesContext; import javax.ws.rs.core.*; import java.io.IOException; @@ -72,17 +71,22 @@ public class LegacyMoxyConsumerTest extends AAISetup { private List<String> aaiRequestContextList; private List<MediaType> outputMediaTypes; + private boolean initialized = false; + private static final EELFLogger logger = EELFManager.getInstance().getLogger(LegacyMoxyConsumerTest.class.getName()); @BeforeClass public static void setupRest(){ - AAIGraph.getInstance(); - ModelInjestor.getInstance(); + // AAIGraph.getInstance(); } @Before public void setup(){ + if(!initialized){ + initialized = true; + AAIGraph.getInstance(); + } logger.info("Starting the setup for the integration tests of Rest Endpoints"); legacyMoxyConsumer = new LegacyMoxyConsumer(); @@ -138,9 +142,9 @@ public class LegacyMoxyConsumerTest extends AAISetup { MockHttpServletRequest mockReqGet = new MockHttpServletRequest("GET", uri); Response response = legacyMoxyConsumer.getLegacy( "", - "-1", - "-1", - Version.getLatest().toString(), + null, + null, + schemaVersions.getDefaultVersion().toString(), uri, "all", "false", @@ -154,7 +158,7 @@ public class LegacyMoxyConsumerTest extends AAISetup { MockHttpServletRequest mockReq = new MockHttpServletRequest("PUT", uri); response = legacyMoxyConsumer.update( payload, - Version.getLatest().toString(), + schemaVersions.getDefaultVersion().toString(), uri, httpHeaders, uriInfo, @@ -172,9 +176,9 @@ public class LegacyMoxyConsumerTest extends AAISetup { response = legacyMoxyConsumer.getLegacy( "", - "-1", - "-1", - Version.getLatest().toString(), + null, + null, + schemaVersions.getDefaultVersion().toString(), uri, "10000", "false", @@ -201,7 +205,7 @@ public class LegacyMoxyConsumerTest extends AAISetup { mockReq = new MockHttpServletRequest("DELETE", uri); response = legacyMoxyConsumer.delete( - Version.getLatest().toString(), + schemaVersions.getDefaultVersion().toString(), uri, httpHeaders, uriInfo, @@ -218,9 +222,9 @@ public class LegacyMoxyConsumerTest extends AAISetup { response = legacyMoxyConsumer.getLegacy( "", - "-1", - "-1", - Version.getLatest().toString(), + null, + null, + schemaVersions.getDefaultVersion().toString(), uri, "all", "false", @@ -233,6 +237,34 @@ public class LegacyMoxyConsumerTest extends AAISetup { } @Test + public void testResponseGetOnResourcePaginated() throws JSONException, IOException, AAIException { + + String uri = getGetAllPserversURI(); + + if(uri.length() != 0 && uri.charAt(0) == '/'){ + uri = uri.substring(1); + } + + when(uriInfo.getPath()).thenReturn(uri); + when(uriInfo.getPath(false)).thenReturn(uri); + + MockHttpServletRequest mockReqGet = new MockHttpServletRequest("GET", uri); + Response response = legacyMoxyConsumer.getLegacy( + "", + "1", + "10", + schemaVersions.getDefaultVersion().toString(), + uri, + "all", + "false", + httpHeaders, + uriInfo, + mockReqGet + ); + assertEquals(Response.Status.OK.getStatusCode(), response.getStatus()); + } + + @Test public void testPutPserverAndCloudRegionRelationship() throws IOException, JSONException { String pserverData = getRelationshipPayload("pserver"); @@ -253,7 +285,7 @@ public class LegacyMoxyConsumerTest extends AAISetup { MockHttpServletRequest mockReq = new MockHttpServletRequest("PUT", cloudToPserverRelationshipUri); Response response = legacyMoxyConsumer.updateRelationship( cloudToPserverRelationshipData, - Version.getLatest().toString(), + schemaVersions.getDefaultVersion().toString(), cloudToPserverRelationshipUri, httpHeaders, uriInfo, @@ -274,7 +306,7 @@ public class LegacyMoxyConsumerTest extends AAISetup { mockReq = new MockHttpServletRequest("DELETE", cloudToPserverRelationshipUri); response = legacyMoxyConsumer.deleteRelationship( cloudToPserverRelationshipData, - Version.getLatest().toString(), + schemaVersions.getDefaultVersion().toString(), cloudToPserverRelationshipUri, httpHeaders, uriInfo, @@ -314,7 +346,7 @@ public class LegacyMoxyConsumerTest extends AAISetup { MockHttpServletRequest mockReq = new MockHttpServletRequest("PUT", uri); Response response = legacyMoxyConsumer.update( payload, - Version.getLatest().toString(), + schemaVersions.getDefaultVersion().toString(), uri, httpHeaders, uriInfo, @@ -337,7 +369,7 @@ public class LegacyMoxyConsumerTest extends AAISetup { MockHttpServletRequest mockReq = new MockHttpServletRequest("PUT", uri); Response response = legacyMoxyConsumer.update( payload, - Version.getLatest().toString(), + schemaVersions.getDefaultVersion().toString(), uri, httpHeaders, uriInfo, @@ -351,7 +383,7 @@ public class LegacyMoxyConsumerTest extends AAISetup { response = legacyMoxyConsumer.updateRelationship( payload, - Version.getLatest().toString(), + schemaVersions.getDefaultVersion().toString(), uri, httpHeaders, uriInfo, @@ -365,9 +397,9 @@ public class LegacyMoxyConsumerTest extends AAISetup { mockReq = new MockHttpServletRequest("GET", uri); response = legacyMoxyConsumer.getLegacy( "", - "-1", - "-1", - Version.getLatest().toString(), + null, + null, + schemaVersions.getDefaultVersion().toString(), uri, "all", "false", @@ -380,7 +412,7 @@ public class LegacyMoxyConsumerTest extends AAISetup { assertEquals(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(), code); mockReq = new MockHttpServletRequest("DELETE", uri); response = legacyMoxyConsumer.delete( - Version.getLatest().toString(), + schemaVersions.getDefaultVersion().toString(), uri, httpHeaders, uriInfo, @@ -393,7 +425,7 @@ public class LegacyMoxyConsumerTest extends AAISetup { response = legacyMoxyConsumer.deleteRelationship( payload, - Version.getLatest().toString(), + schemaVersions.getDefaultVersion().toString(), uri, httpHeaders, uriInfo, @@ -414,7 +446,7 @@ public class LegacyMoxyConsumerTest extends AAISetup { MockHttpServletRequest mockReq = new MockHttpServletRequest("PUT", uri); Response response = legacyMoxyConsumer.update( payload, - Version.getLatest().toString(), + schemaVersions.getDefaultVersion().toString(), uri, httpHeaders, uriInfo, @@ -427,7 +459,7 @@ public class LegacyMoxyConsumerTest extends AAISetup { response = legacyMoxyConsumer.updateRelationship( payload, - Version.getLatest().toString(), + schemaVersions.getDefaultVersion().toString(), uri, httpHeaders, uriInfo, @@ -441,9 +473,9 @@ public class LegacyMoxyConsumerTest extends AAISetup { mockReq = new MockHttpServletRequest("GET", uri); response = legacyMoxyConsumer.getLegacy( "", - "-1", - "-1", - Version.getLatest().toString(), + null, + null, + schemaVersions.getDefaultVersion().toString(), uri, "all", "false", @@ -458,7 +490,7 @@ public class LegacyMoxyConsumerTest extends AAISetup { mockReq = new MockHttpServletRequest("DELETE", uri); queryParameters.add("resource-version", "3434394839483"); response = legacyMoxyConsumer.delete( - Version.getLatest().toString(), + schemaVersions.getDefaultVersion().toString(), uri, httpHeaders, uriInfo, @@ -472,7 +504,7 @@ public class LegacyMoxyConsumerTest extends AAISetup { response = legacyMoxyConsumer.deleteRelationship( payload, - Version.getLatest().toString(), + schemaVersions.getDefaultVersion().toString(), uri, httpHeaders, uriInfo, @@ -499,9 +531,9 @@ public class LegacyMoxyConsumerTest extends AAISetup { MockHttpServletRequest mockReq = new MockHttpServletRequest("GET", uri); Response response = legacyMoxyConsumer.getLegacy( "", - "-1", - "-1", - Version.getLatest().toString(), + null, + null, + schemaVersions.getDefaultVersion().toString(), uri, "all", "false", @@ -514,7 +546,7 @@ public class LegacyMoxyConsumerTest extends AAISetup { mockReq = new MockHttpServletRequest("PUT", uri); response = legacyMoxyConsumer.update( payload, - Version.getLatest().toString(), + schemaVersions.getDefaultVersion().toString(), uri, httpHeaders, uriInfo, @@ -538,7 +570,7 @@ public class LegacyMoxyConsumerTest extends AAISetup { mockReq = new MockHttpServletRequest("PATCH", uri); response = legacyMoxyConsumer.patch( patchData, - Version.getLatest().toString(), + schemaVersions.getDefaultVersion().toString(), uri, httpHeaders, uriInfo, @@ -560,9 +592,9 @@ public class LegacyMoxyConsumerTest extends AAISetup { MockHttpServletRequest mockReqGet = new MockHttpServletRequest("GET", uri); Response response = legacyMoxyConsumer.getLegacy( "", - "-1", - "-1", - Version.getLatest().toString(), + null, + null, + schemaVersions.getDefaultVersion().toString(), uri, "all", "false", @@ -578,7 +610,7 @@ public class LegacyMoxyConsumerTest extends AAISetup { MockHttpServletRequest mockReq = new MockHttpServletRequest("PUT", uri); response = legacyMoxyConsumer.update( payload, - Version.getLatest().toString(), + schemaVersions.getDefaultVersion().toString(), uri, httpHeaders, uriInfo, @@ -596,9 +628,9 @@ public class LegacyMoxyConsumerTest extends AAISetup { queryParameters.add("depth", "10000"); response = legacyMoxyConsumer.getLegacy( "", - "-1", - "-1", - Version.getLatest().toString(), + null, + null, + schemaVersions.getDefaultVersion().toString(), uri, "all", "false", @@ -631,7 +663,7 @@ public class LegacyMoxyConsumerTest extends AAISetup { MockHttpServletRequest mockReq = new MockHttpServletRequest("DELETE", uri); Response response = legacyMoxyConsumer.deleteRelationship( payload, - Version.getLatest().toString(), + schemaVersions.getDefaultVersion().toString(), uri, httpHeaders, uriInfo, @@ -659,6 +691,10 @@ public class LegacyMoxyConsumerTest extends AAISetup { public String getUri(String hostname){ return String.format("cloud-infrastructure/pservers/pserver/%s", hostname); } + public String getGetAllPserversURI(){ + return "cloud-infrastructure/pservers"; + } + public String getUri(){ return getUri("pserver-hostname-test"); @@ -711,9 +747,9 @@ public class LegacyMoxyConsumerTest extends AAISetup { MockHttpServletRequest mockReqGet = new MockHttpServletRequest("GET", uri); Response response = legacyMoxyConsumer.getLegacy( "", - "-1", - "-1", - Version.getLatest().toString(), + null, + null, + schemaVersions.getDefaultVersion().toString(), uri, "all", "false", @@ -740,9 +776,9 @@ public class LegacyMoxyConsumerTest extends AAISetup { MockHttpServletRequest mockReqGet = new MockHttpServletRequest("GET", uri); Response response = legacyMoxyConsumer.getLegacy( "", - "-1", - "-1", - Version.getLatest().toString(), + null, + null, + schemaVersions.getDefaultVersion().toString(), uri, "all", "false", diff --git a/aai-resources/src/test/java/org/onap/aai/rest/PserverGenerateUrlTest.java b/aai-resources/src/test/java/org/onap/aai/rest/PserverGenerateUrlTest.java new file mode 100644 index 0000000..7c27477 --- /dev/null +++ b/aai-resources/src/test/java/org/onap/aai/rest/PserverGenerateUrlTest.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; + +import com.jayway.jsonpath.JsonPath; +import org.junit.Test; +import org.springframework.http.*; + +import java.io.UnsupportedEncodingException; +import java.util.Base64; +import java.util.Collections; +import java.util.UUID; + +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.containsString; +import static org.junit.Assert.assertEquals; +public class PserverGenerateUrlTest extends AbstractSpringRestTest { + + @Test + public void testPutPserverExtractVertexGenerateUrlAndDeleteIt() throws UnsupportedEncodingException { + + String endpoint = "/aai/v11/cloud-infrastructure/pservers/pserver/test" + UUID.randomUUID().toString(); + + ResponseEntity responseEntity = null; + + responseEntity = restTemplate.exchange(baseUrl + endpoint, HttpMethod.GET, httpEntity, String.class); + assertEquals(HttpStatus.NOT_FOUND, responseEntity.getStatusCode()); + + responseEntity = restTemplate.exchange(baseUrl + endpoint, HttpMethod.PUT, httpEntity, String.class); + assertEquals(HttpStatus.CREATED, responseEntity.getStatusCode()); + + String vertexId = responseEntity.getHeaders().getFirst("vertex-id"); + responseEntity = restTemplate.exchange(baseUrl + "/aai/v11/generateurl/id/" + vertexId, HttpMethod.GET, plainHttpEntity(), String.class); + assertEquals(HttpStatus.OK, responseEntity.getStatusCode()); + assertThat(responseEntity.getBody().toString(), containsString(endpoint)); + + responseEntity = restTemplate.exchange(baseUrl + endpoint, HttpMethod.GET, httpEntity, String.class); + assertEquals(HttpStatus.OK, responseEntity.getStatusCode()); + + String body = responseEntity.getBody().toString(); + String resourceVersion = JsonPath.read(body, "$.resource-version"); + + responseEntity = restTemplate.exchange(baseUrl + endpoint+ "?resource-version=" + resourceVersion, HttpMethod.DELETE, httpEntity, String.class); + assertEquals(HttpStatus.NO_CONTENT, responseEntity.getStatusCode()); + } + + private HttpEntity plainHttpEntity() throws UnsupportedEncodingException { + + HttpHeaders headers = new HttpHeaders(); + + headers.setAccept(Collections.singletonList(MediaType.TEXT_PLAIN)); + 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); + return new HttpEntity(headers); + } +} diff --git a/aai-resources/src/test/java/org/onap/aai/rest/PserverMissingTest.java b/aai-resources/src/test/java/org/onap/aai/rest/PserverMissingTest.java new file mode 100644 index 0000000..da982a9 --- /dev/null +++ b/aai-resources/src/test/java/org/onap/aai/rest/PserverMissingTest.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.rest; + +import org.junit.Test; +import org.onap.aai.PayloadUtil; +import org.springframework.http.*; + +import java.util.*; + +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.core.StringContains.containsString; +import static org.junit.Assert.assertEquals; +public class PserverMissingTest extends AbstractSpringRestTest { + + @Test + public void testWhenContentTypeMissingItWillFunctionalAndCreateObjectWithPayloadInJson() throws Exception { + + String id = "test-" + UUID.randomUUID().toString(); + String endpoint = "/aai/v11/cloud-infrastructure/pservers/pserver/"+ id; + HttpHeaders headers = new HttpHeaders(); + + headers.setAccept(Collections.singletonList(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); + + Map<String, String> templateMap = new HashMap<>(); + + templateMap.put("hostname", id); + String body = PayloadUtil.getTemplatePayload("pserver.json", templateMap); + + httpEntity = new HttpEntity(body, headers); + baseUrl = "https://localhost:" + randomPort; + + ResponseEntity responseEntity; + responseEntity = restTemplate.exchange(baseUrl + endpoint, HttpMethod.PUT, httpEntity, String.class); + + assertEquals(HttpStatus.CREATED, responseEntity.getStatusCode()); + } + + @Test + public void testWhenAcceptMissingItWillReturnThePayloadInXml() throws Exception { + + String id = "test-" + UUID.randomUUID().toString(); + String endpoint = "/aai/v11/cloud-infrastructure/pservers/pserver/"+ id; + HttpHeaders headers = new HttpHeaders(); + + 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; + + ResponseEntity responseEntity; + responseEntity = restTemplate.exchange(baseUrl + endpoint, HttpMethod.GET, httpEntity, String.class); + + String body = responseEntity.getBody().toString(); + + assertEquals(HttpStatus.NOT_FOUND, responseEntity.getStatusCode()); + assertThat(body, containsString("<Fault>")); + assertThat(body, containsString("Resource not found for")); + assertThat(body, containsString("Node Not Found")); + } +} diff --git a/aai-resources/src/test/java/org/onap/aai/rest/PserverRelationshipTest.java b/aai-resources/src/test/java/org/onap/aai/rest/PserverRelationshipTest.java new file mode 100644 index 0000000..017844e --- /dev/null +++ b/aai-resources/src/test/java/org/onap/aai/rest/PserverRelationshipTest.java @@ -0,0 +1,97 @@ +/** + * ============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.Test; +import org.onap.aai.PayloadUtil; +import org.onap.aai.util.MapperUtil; +import org.springframework.http.HttpEntity; +import org.springframework.http.HttpMethod; +import org.springframework.http.HttpStatus; +import org.springframework.http.ResponseEntity; + +import java.util.HashMap; +import java.util.HashSet; +import java.util.Map; +import java.util.Set; + +import static org.hamcrest.CoreMatchers.not; +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.containsInAnyOrder; +import static org.hamcrest.Matchers.containsString; +import static org.junit.Assert.assertEquals; + +public class PserverRelationshipTest extends AbstractSpringRestTest { + + @Test + public void testGetRelationshipThrowUnrecognizedAAIObjectException() { + + String endpoint = "/aai/v12/cloud-infrastructure/pservers/pserver/test/relationship-list/relationship"; + + ResponseEntity responseEntity = null; + + responseEntity = restTemplate.exchange(baseUrl + endpoint, HttpMethod.GET, httpEntity, String.class); + String body = responseEntity.getBody().toString(); + + Set<HttpMethod> httpMethodSet = new HashSet<>(); + + httpMethodSet.add(HttpMethod.PUT); + httpMethodSet.add(HttpMethod.DELETE); + httpMethodSet.add(HttpMethod.OPTIONS); + + + assertEquals(HttpStatus.BAD_REQUEST, responseEntity.getStatusCode()); + assertThat(body, containsString("Unrecognized AAI function")); + assertThat(responseEntity.getHeaders().getAllow(), containsInAnyOrder(httpMethodSet.toArray())); + } + + @Test + public void testPutPserverAndCloudRegionAndReturnEdgesWithLabel() throws Exception { + + String hostname = "test-pserver1"; + String endpoint = "/aai/v12/cloud-infrastructure/pservers/pserver/" + hostname; + + ResponseEntity responseEntity = null; + + restTemplate.exchange(baseUrl + endpoint, HttpMethod.PUT, httpEntity, String.class); + + String cloudRegionId = "test-region-1"; + String cloudOwnerId = "test-owner-1"; + endpoint = "/aai/v12/cloud-infrastructure/cloud-regions/cloud-region/" + cloudOwnerId + "/" + cloudRegionId; + + Map<String, String> map = new HashMap<>(); + map.put("hostname", hostname); + map.put("cloud-region-id", cloudRegionId); + map.put("cloud-owner", cloudOwnerId); + + String payload = PayloadUtil.getTemplatePayload("pserver-to-cloud-region.json", map); + httpEntity = new HttpEntity(payload, headers); + restTemplate.exchange(baseUrl + endpoint, HttpMethod.PUT, httpEntity, String.class); + + httpEntity = new HttpEntity(headers); + responseEntity = restTemplate.exchange(baseUrl + endpoint, HttpMethod.GET, httpEntity, String.class); + assertThat(responseEntity.getBody().toString(), containsString("relationship-label")); + + endpoint = "/aai/v11/cloud-infrastructure/cloud-regions/cloud-region/" + cloudOwnerId + "/" + cloudRegionId; + + responseEntity = restTemplate.exchange(baseUrl + endpoint, HttpMethod.GET, httpEntity, String.class); + assertThat(responseEntity.getBody().toString(), not(containsString("relationship-label"))); + } +} diff --git a/aai-resources/src/test/java/org/onap/aai/rest/PserverTest.java b/aai-resources/src/test/java/org/onap/aai/rest/PserverTest.java index 2acc3c4..7f48ff8 100644 --- a/aai-resources/src/test/java/org/onap/aai/rest/PserverTest.java +++ b/aai-resources/src/test/java/org/onap/aai/rest/PserverTest.java @@ -20,25 +20,11 @@ package org.onap.aai.rest; import com.jayway.jsonpath.JsonPath; -import org.junit.Before; import org.junit.Test; -import org.junit.runner.RunWith; -import org.onap.aai.ResourcesApp; -import org.onap.aai.ResourcesTestConfiguration; -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 org.springframework.http.HttpMethod; +import org.springframework.http.HttpStatus; +import org.springframework.http.ResponseEntity; -import java.io.UnsupportedEncodingException; -import java.util.Base64; -import java.util.Collections; import java.util.UUID; import static org.junit.Assert.assertEquals; @@ -54,40 +40,7 @@ import static org.junit.Assert.assertEquals; * 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 = ResourcesApp.class) -@TestPropertySource(locations = "classpath:application-test.properties") -@ContextConfiguration(initializers = PropertyPasswordConfiguration.class) -@Import(ResourcesTestConfiguration.class) -public class PserverTest { - - @Autowired - RestTemplate restTemplate; - - @LocalServerPort - int randomPort; - - private HttpEntity httpEntity; - - private String baseUrl; - - @Before - public void setup() throws UnsupportedEncodingException { - - HttpHeaders 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; - } +public class PserverTest extends AbstractSpringRestTest { @Test public void testPutPserverExtractVertexAndThenDoGetByVertexIdAndThenDeleteIt() { diff --git a/aai-resources/src/test/java/org/onap/aai/rest/PserverWrongHeaderTest.java b/aai-resources/src/test/java/org/onap/aai/rest/PserverWrongHeaderTest.java new file mode 100644 index 0000000..4d75a2e --- /dev/null +++ b/aai-resources/src/test/java/org/onap/aai/rest/PserverWrongHeaderTest.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.rest; + +import org.junit.Test; +import org.springframework.http.*; + +import java.util.UUID; + +import static org.hamcrest.Matchers.containsString; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertThat; +public class PserverWrongHeaderTest extends AbstractSpringRestTest{ + + @Test + public void testWhenNoHeadersItFailsWithBadRequestAndReturnsXml(){ + + HttpHeaders httpHeaders = new HttpHeaders(); + + httpEntity = new HttpEntity(httpHeaders); + + String endpoint = "/aai/v11/cloud-infrastructure/pservers/pserver/test" + UUID.randomUUID().toString(); + + ResponseEntity responseEntity; + responseEntity = restTemplate.exchange(baseUrl + endpoint, HttpMethod.GET, httpEntity, String.class); + + String body = responseEntity.getBody().toString(); + + assertEquals(HttpStatus.BAD_REQUEST, responseEntity.getStatusCode()); + assertThat(body, containsString("<Fault>")); + assertThat(body, containsString("Invalid X-FromAppId in header")); + } +} diff --git a/aai-resources/src/test/java/org/onap/aai/rest/URLFromVertexIdConsumerTest.java b/aai-resources/src/test/java/org/onap/aai/rest/URLFromVertexIdConsumerTest.java index c49d10b..2edec7b 100644 --- a/aai-resources/src/test/java/org/onap/aai/rest/URLFromVertexIdConsumerTest.java +++ b/aai-resources/src/test/java/org/onap/aai/rest/URLFromVertexIdConsumerTest.java @@ -29,8 +29,6 @@ import org.mockito.Mockito; import org.onap.aai.AAISetup; import org.onap.aai.dbmap.AAIGraph; import org.onap.aai.exceptions.AAIException; -import org.onap.aai.introspection.ModelInjestor; -import org.onap.aai.introspection.Version; import javax.ws.rs.core.*; import java.io.IOException; @@ -68,15 +66,18 @@ public class URLFromVertexIdConsumerTest extends AAISetup { private List<MediaType> outputMediaTypes; private static final EELFLogger logger = EELFManager.getInstance().getLogger(LegacyMoxyConsumerTest.class.getName()); - + private boolean initialized = false; @BeforeClass public static void setupRest(){ - AAIGraph.getInstance(); - ModelInjestor.getInstance(); + // AAIGraph.getInstance(); } @Before public void setup(){ + if(!initialized){ + initialized = true; + AAIGraph.getInstance(); + } logger.info("Starting the setup for the integration tests of Rest Endpoints"); urlFromVertexIdConsumer = new URLFromVertexIdConsumer(); @@ -129,7 +130,7 @@ public class URLFromVertexIdConsumerTest extends AAISetup { "", "-1", "-1", - Version.getLatest().toString(), + schemaVersions.getDefaultVersion().toString(), uri, "all", "false", @@ -142,7 +143,7 @@ public class URLFromVertexIdConsumerTest extends AAISetup { MockHttpServletRequest mockReq = new MockHttpServletRequest("PUT", uri); response = legacyMoxyConsumer.update( payload, - Version.getLatest().toString(), + schemaVersions.getDefaultVersion().toString(), uri, httpHeaders, uriInfo, @@ -164,7 +165,7 @@ public class URLFromVertexIdConsumerTest extends AAISetup { String vertexId = responseHeaders.get("vertex-id").get(0).toString(); response = urlFromVertexIdConsumer.generateUrlFromVertexId( "", - Version.getLatest().toString(), + schemaVersions.getDefaultVersion().toString(), Long.valueOf(vertexId).longValue(), httpHeaders, uriInfo, @@ -187,7 +188,7 @@ public class URLFromVertexIdConsumerTest extends AAISetup { MockHttpServletRequest mockReqGet = new MockHttpServletRequest("GET", uri); Response response = urlFromVertexIdConsumer.generateUrlFromVertexId( "", - Version.getLatest().toString(), + schemaVersions.getDefaultVersion().toString(), Long.valueOf(vertexId).longValue(), httpHeaders, uriInfo, diff --git a/aai-resources/src/test/java/org/onap/aai/rest/VertexIdConsumerTest.java b/aai-resources/src/test/java/org/onap/aai/rest/VertexIdConsumerTest.java index 41214db..8d3f5a8 100644 --- a/aai-resources/src/test/java/org/onap/aai/rest/VertexIdConsumerTest.java +++ b/aai-resources/src/test/java/org/onap/aai/rest/VertexIdConsumerTest.java @@ -29,8 +29,6 @@ import org.mockito.Mockito; import org.onap.aai.AAISetup; import org.onap.aai.dbmap.AAIGraph; import org.onap.aai.exceptions.AAIException; -import org.onap.aai.introspection.ModelInjestor; -import org.onap.aai.introspection.Version; import javax.ws.rs.core.*; import java.io.IOException; @@ -40,7 +38,6 @@ import static org.junit.Assert.*; import static org.mockito.Matchers.anyObject; import static org.mockito.Mockito.when; import org.springframework.mock.web.MockHttpServletRequest; - public class VertexIdConsumerTest extends AAISetup { protected static final MediaType APPLICATION_JSON = MediaType.valueOf("application/json"); @@ -68,15 +65,19 @@ public class VertexIdConsumerTest extends AAISetup { private List<MediaType> outputMediaTypes; private static final EELFLogger logger = EELFManager.getInstance().getLogger(LegacyMoxyConsumerTest.class.getName()); - + private boolean initialized = false; + @BeforeClass public static void setupRest(){ - AAIGraph.getInstance(); - ModelInjestor.getInstance(); + //AAIGraph.getInstance(); } @Before public void setup(){ + if(!initialized){ + initialized = true; + AAIGraph.getInstance(); + } logger.info("Starting the setup for the integration tests of Rest Endpoints"); vertexIdConsumer = new VertexIdConsumer(); @@ -129,7 +130,7 @@ public class VertexIdConsumerTest extends AAISetup { "", "-1", "-1", - Version.getLatest().toString(), + schemaVersions.getDefaultVersion().toString(), uri, "all", "false", @@ -143,7 +144,7 @@ public class VertexIdConsumerTest extends AAISetup { response = legacyMoxyConsumer.update( payload, - Version.getLatest().toString(), + schemaVersions.getDefaultVersion().toString(), uri, httpHeaders, uriInfo, @@ -166,7 +167,7 @@ public class VertexIdConsumerTest extends AAISetup { response = vertexIdConsumer.getByVertexId( "", - Version.getLatest().toString(), + schemaVersions.getDefaultVersion().toString(), Long.valueOf(vertexId).longValue(), "10000", httpHeaders, diff --git a/aai-resources/src/test/java/org/onap/aai/rest/bulk/BulkSingleTransactionConsumerTest.java b/aai-resources/src/test/java/org/onap/aai/rest/bulk/BulkSingleTransactionConsumerTest.java new file mode 100644 index 0000000..e317297 --- /dev/null +++ b/aai-resources/src/test/java/org/onap/aai/rest/bulk/BulkSingleTransactionConsumerTest.java @@ -0,0 +1,369 @@ +/** + * ============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.bulk; + +import org.apache.tinkerpop.gremlin.structure.Property; +import org.apache.tinkerpop.gremlin.structure.Vertex; +import org.apache.tinkerpop.gremlin.structure.VertexProperty; +import org.json.JSONException; +import org.json.JSONObject; +import org.junit.Before; +import org.junit.Rule; +import org.junit.Test; +import org.junit.rules.TestName; +import org.onap.aai.db.props.AAIProperties; +import org.onap.aai.dbmap.AAIGraph; +import org.onap.aai.rest.BulkConsumer; +import org.onap.aai.rest.BulkProcessorTestAbstraction; +import org.springframework.mock.web.MockHttpServletRequest; + +import javax.ws.rs.HttpMethod; +import javax.ws.rs.core.Response; +import java.io.IOException; +import java.util.Iterator; + +import static org.hamcrest.CoreMatchers.containsString; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertThat; +import static org.mockito.Mockito.when; + +public class BulkSingleTransactionConsumerTest extends BulkProcessorTestAbstraction { + + private BulkSingleTransactionConsumer bulkSingleTransactionConsumer = new BulkSingleTransactionConsumer(); + + @Rule + public TestName name = new TestName(); + + private String sot = "Junit"; + + @Before + public void before() { + sot = "JUNIT-" + name.getMethodName(); + when(uriInfo.getPath()).thenReturn(uri); + when(uriInfo.getPath(false)).thenReturn(uri); + headersMultiMap.addFirst("X-FromAppId", sot); + + } + + @Test + public void addPserverPatchSamePserverTest() throws IOException { + + String payload = getBulkPayload("single-transaction/put-patch-same-pserver").replaceAll("<methodName>", name.getMethodName()); + Response response = executeRequest(payload); + + assertEquals("Request success", + Response.Status.CREATED.getStatusCode(), + response.getStatus()); + assertEquals("1 vertex from this test in graph", + Long.valueOf(1L), + AAIGraph.getInstance().getGraph().newTransaction().traversal(). + V().has(AAIProperties.SOURCE_OF_TRUTH, sot).count().next()); + assertEquals("1 vertex from this test with fqdn = patched-fqdn", + Long.valueOf(1L), + AAIGraph.getInstance().getGraph().newTransaction().traversal(). + V().has(AAIProperties.SOURCE_OF_TRUTH, sot) + .has("fqdn", "patched-fqdn").count().next()); + + + } + + @Test + public void putPserverComplexRelBetween() throws IOException { + + String payload = getBulkPayload("single-transaction/put-pserver-complex-rel-between").replaceAll("<methodName>", name.getMethodName()); + Response response = executeRequest(payload); + + assertEquals("Request success", + Response.Status.CREATED.getStatusCode(), + response.getStatus()); + assertEquals("2 vertex from this test in graph", + Long.valueOf(2L), + AAIGraph.getInstance().getGraph().newTransaction().traversal(). + V().has(AAIProperties.SOURCE_OF_TRUTH, sot).count().next()); + assertEquals("1 complex vertex", + Long.valueOf(1L), + AAIGraph.getInstance().getGraph().newTransaction().traversal(). + V().has(AAIProperties.SOURCE_OF_TRUTH, sot) + .has(AAIProperties.NODE_TYPE, "complex").count().next()); + assertEquals("1 pserver vertex", + Long.valueOf(1L), + AAIGraph.getInstance().getGraph().newTransaction().traversal(). + V().has(AAIProperties.SOURCE_OF_TRUTH, sot) + .has(AAIProperties.NODE_TYPE, "pserver").count().next()); + assertEquals("pserver has edge to complex", + Long.valueOf(1L), + AAIGraph.getInstance().getGraph().newTransaction().traversal(). + V().has(AAIProperties.SOURCE_OF_TRUTH, sot) + .has(AAIProperties.NODE_TYPE, "pserver") + .bothE() + .otherV() + .has(AAIProperties.NODE_TYPE, "complex") + .has(AAIProperties.SOURCE_OF_TRUTH, sot).count().next()); + + + } + + @Test + public void putPatchSamePserverPutAnotherPserver() throws IOException { + String payload = getBulkPayload("single-transaction/put-patch-same-pserver-put-another-pserver") + .replaceAll("<methodName>", name.getMethodName()); + Response response = executeRequest(payload); + + assertEquals("Request success", + Response.Status.CREATED.getStatusCode(), + response.getStatus()); + assertEquals("2 vertex from this test in graph", + Long.valueOf(2L), + AAIGraph.getInstance().getGraph().newTransaction().traversal(). + V().has(AAIProperties.SOURCE_OF_TRUTH, sot).count().next()); + assertEquals("pserver 1 has hostname pserver-1-" + name.getMethodName() + " fqdn = patched-fqdn", + Long.valueOf(1L), + AAIGraph.getInstance().getGraph().newTransaction().traversal(). + V().has(AAIProperties.SOURCE_OF_TRUTH, sot) + .has("hostname", "pserver-1-" + name.getMethodName()) + .has("fqdn", "patched-fqdn").count().next()); + assertEquals("pserver 2 has hostname pserver-2-" + name.getMethodName(), + Long.valueOf(1L), + AAIGraph.getInstance().getGraph().newTransaction().traversal(). + V().has(AAIProperties.SOURCE_OF_TRUTH, sot) + .has("hostname", "pserver-2-" + name.getMethodName()).count().next()); + } + + + protected String asString(Vertex v) { + final JSONObject result = new JSONObject(); + Iterator<VertexProperty<Object>> properties = v.properties(); + Property<Object> pk = null; + try { + while (properties.hasNext()) { + pk = properties.next(); + result.put(pk.key(), pk.value()); + } + } catch (JSONException e) { + e.printStackTrace(); + } + + return result.toString(); + } + + @Test + public void putPserverComplexRelBetweenDelExistingGvnf() throws IOException { + + AAIGraph.getInstance().getGraph().traversal().addV() + .property(AAIProperties.NODE_TYPE, "generic-vnf") + .property(AAIProperties.SOURCE_OF_TRUTH, sot) + .property(AAIProperties.AAI_URI, "/network/generic-vnfs/generic-vnf/gvnf-putPserverComplexRelBetweenDelExistingGvnf") + .property(AAIProperties.RESOURCE_VERSION, "0") + .property("vnf-id", "gvnf-" + name.getMethodName()) + .next(); + AAIGraph.getInstance().getGraph().tx().commit(); + + assertEquals("1 generic-vnf vertex exists before payload", + Long.valueOf(1L), + AAIGraph.getInstance().getGraph().newTransaction().traversal(). + V().has(AAIProperties.SOURCE_OF_TRUTH, sot) + .has(AAIProperties.NODE_TYPE, "generic-vnf").count().next()); + + String payload = getBulkPayload("single-transaction/put-pserver-complex-rel-between-del-existing-gvnf") + .replaceAll("<methodName>", name.getMethodName()); + Response response = executeRequest(payload); + + assertEquals("Request success", + Response.Status.CREATED.getStatusCode(), + response.getStatus()); + assertEquals("2 vertex from this test in graph", + Long.valueOf(2L), + AAIGraph.getInstance().getGraph().newTransaction().traversal(). + V().has(AAIProperties.SOURCE_OF_TRUTH, sot).count().next()); + assertEquals("1 complex vertex", + Long.valueOf(1L), + AAIGraph.getInstance().getGraph().newTransaction().traversal(). + V().has(AAIProperties.SOURCE_OF_TRUTH, sot) + .has(AAIProperties.NODE_TYPE, "complex").count().next()); + assertEquals("1 pserver vertex", + Long.valueOf(1L), + AAIGraph.getInstance().getGraph().newTransaction().traversal(). + V().has(AAIProperties.SOURCE_OF_TRUTH, sot) + .has(AAIProperties.NODE_TYPE, "pserver").count().next()); + assertEquals("pserver has edge to complex", + Long.valueOf(1L), + AAIGraph.getInstance().getGraph().newTransaction().traversal(). + V().has(AAIProperties.SOURCE_OF_TRUTH, sot) + .has(AAIProperties.NODE_TYPE, "pserver") + .bothE() + .otherV() + .has(AAIProperties.NODE_TYPE, "complex") + .has(AAIProperties.SOURCE_OF_TRUTH, sot).count().next()); + assertEquals("0 generic-vnf vertex exists after payload", + Long.valueOf(0L), + AAIGraph.getInstance().getGraph().newTransaction().traversal(). + V().has(AAIProperties.SOURCE_OF_TRUTH, sot) + .has(AAIProperties.NODE_TYPE, "generic-vnf").count().next()); + + assertThat("Response contains 204 status.", + response.getEntity().toString(), + containsString("\"response-status-code\":204")); + } + + @Test + public void putPserverComplexRelBetweenDelExistingGvnfFail() throws IOException { + + AAIGraph.getInstance().getGraph().traversal().addV() + .property(AAIProperties.NODE_TYPE, "generic-vnf") + .property(AAIProperties.SOURCE_OF_TRUTH, sot) + .property(AAIProperties.AAI_URI, "/network/generic-vnfs/generic-vnf/gvnf-putPserverComplexRelBetweenDelExistingGvnfFail") + .property(AAIProperties.RESOURCE_VERSION, "0") + .property("vnf-id", "gvnf-" + name.getMethodName()) + .next(); + AAIGraph.getInstance().getGraph().tx().commit(); + + assertEquals("1 generic-vnf vertex exists before payload", + Long.valueOf(1L), + AAIGraph.getInstance().getGraph().newTransaction().traversal(). + V().has(AAIProperties.SOURCE_OF_TRUTH, sot) + .has(AAIProperties.NODE_TYPE, "generic-vnf").count().next()); + + String payload = getBulkPayload("single-transaction/put-pserver-complex-rel-between-del-existing-gvnf-fail") + .replaceAll("<methodName>", name.getMethodName()); + Response response = executeRequest(payload); + + assertEquals("Request failed", + Response.Status.BAD_REQUEST.getStatusCode(), + response.getStatus()); + + assertEquals("1 vertex exists after payload due to failure", + Long.valueOf(1L), + AAIGraph.getInstance().getGraph().newTransaction().traversal(). + V().has(AAIProperties.SOURCE_OF_TRUTH, sot).count().next()); + + assertThat("Response contains correct index of failed operation.", + response.getEntity().toString(), + containsString("Operation 3 failed with status code (412) and msg")); + + assertThat("Response contains resource version msg for failed transaction.", + response.getEntity().toString(), + containsString("Precondition Failed:resource-version MISMATCH for delete of generic-vnf")); + + } + + @Test + public void checkExceedsLimit() throws IOException{ + + String payload = getBulkPayload("single-transaction/pserver-bulk-limit-exceed"); + Response response = executeRequest(payload); + + assertEquals("Request fails with 400", + Response.Status.BAD_REQUEST.getStatusCode(), + response.getStatus()); + assertThat("Response contains payload limit msg.", + response.getEntity().toString(), + containsString("Payload Limit Reached, reduce payload: Allowed limit = ")); + } + + @Test + public void invalidJson() { + + String payload = "{]}";//malformed json + Response response = executeRequest(payload); + + assertEquals("Request fails with 400", + Response.Status.BAD_REQUEST.getStatusCode(), + response.getStatus()); + assertThat("Response contains invalid payload msg.", + response.getEntity().toString(), + containsString("JSON processing error:Input payload does not follow bulk/single-transaction interface")); + } + + + @Test + public void noOperations() { + + String payload = "{'operations':[]}"; + Response response = executeRequest(payload); + + assertEquals("Request fails with 400", + Response.Status.BAD_REQUEST.getStatusCode(), + response.getStatus()); + assertThat("Response contains invalid payload msg.", + response.getEntity().toString(), + containsString("Required Field not passed.: Payload has no objects to operate on")); + } + + @Test + public void invalidAction() throws IOException { + + String payload = getBulkPayload("single-transaction/invalid-action"); + Response response = executeRequest(payload); + + assertEquals("Request fails with 400", + Response.Status.BAD_REQUEST.getStatusCode(), + response.getStatus()); + assertThat("Response contains invalid payload msg.", + response.getEntity().toString(), + containsString("JSON processing error:input payload missing required properties")); + assertThat("Response contains invalid payload details.", + response.getEntity().toString(), + containsString("[Operation 0 has invalid action 'create', Operation 1 has invalid action 'destroy']")); + + } + + @Test + public void missingFields() throws IOException { + + String payload = getBulkPayload("single-transaction/missing-fields"); + Response response = executeRequest(payload); + + assertEquals("Request fails with 400", + Response.Status.BAD_REQUEST.getStatusCode(), + response.getStatus()); + assertThat("Response contains invalid payload msg.", + response.getEntity().toString(), + containsString("JSON processing error:input payload missing required properties")); + assertThat("Response contains invalid payload details.", + response.getEntity().toString(), + containsString("[Operation 0 missing 'body', Operation 1 missing 'action', Operation 2 missing 'uri']")); + + } + + + + + protected Response executeRequest(String finalPayload) { + MockHttpServletRequest mockReq = new MockHttpServletRequest(HttpMethod.POST, "http://www.test.com"); + + return bulkSingleTransactionConsumer.process( + finalPayload, + schemaVersions.getDefaultVersion().toString(), + httpHeaders, + uriInfo, + mockReq + ); + } + + @Override + protected BulkConsumer getConsumer() { + return null; + } + + @Override + protected String getUri() { + return "/aai/" + schemaVersions.getDefaultVersion().toString() + "/bulk-single-transaction-multi-operation"; + } +}
\ No newline at end of file diff --git a/aai-resources/src/test/java/org/onap/aai/rest/retired/RetiredConsumerSpringTest.java b/aai-resources/src/test/java/org/onap/aai/rest/retired/RetiredConsumerSpringTest.java new file mode 100644 index 0000000..1fae4a7 --- /dev/null +++ b/aai-resources/src/test/java/org/onap/aai/rest/retired/RetiredConsumerSpringTest.java @@ -0,0 +1,143 @@ +/** + * ============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(); + } + + @Test + public void testOldModelsRetired(){ + setupModelsRetired(); + executeRestCalls(); + } + + @Test + public void testOldNamedQueriesRetired(){ + setupNamedQueriesRetired(); + executeRestCalls(); + } + + @Test + public void testEdgeTagQueryRetired(){ + setupEdgeTagQueriesRetired(); + executeRestCalls(); + } + + @Test + public void testSDNZoneQueryRetired(){ + setupSDNZoneQueryRetired(); + executeRestCalls(); + } + + private void setupSDNZoneQueryRetired() { + httpStatusMap = new HashMap<>(); + + httpStatusMap.put("/aai/v2/search/sdn-zone-query", HttpStatus.GONE); + httpStatusMap.put("/aai/v3/search/sdn-zone-query", HttpStatus.GONE); + httpStatusMap.put("/aai/v4/search/sdn-zone-query", HttpStatus.GONE); + httpStatusMap.put("/aai/v5/search/sdn-zone-query", HttpStatus.GONE); + httpStatusMap.put("/aai/v6/search/sdn-zone-query", HttpStatus.GONE); + httpStatusMap.put("/aai/v7/search/sdn-zone-query", HttpStatus.GONE); + httpStatusMap.put("/aai/v8/search/sdn-zone-query", HttpStatus.GONE); + httpStatusMap.put("/aai/v9/search/sdn-zone-query", HttpStatus.GONE); + httpStatusMap.put("/aai/v10/search/sdn-zone-query", HttpStatus.GONE); + httpStatusMap.put("/aai/v11/search/sdn-zone-query", HttpStatus.GONE); + httpStatusMap.put("/aai/v12/search/sdn-zone-query", HttpStatus.GONE); + httpStatusMap.put("/aai/v12/search/sdn-zone-query/fjaisdofjasdjf", HttpStatus.GONE); + } + + private void setupEdgeTagQueriesRetired() { + + httpStatusMap = new HashMap<>(); + + httpStatusMap.put("/aai/v2/search/edge-tag-query", HttpStatus.GONE); + httpStatusMap.put("/aai/v2/search/edge-tag-query/", HttpStatus.GONE); + httpStatusMap.put("/aai/v2/search/edge-tag-query/something", HttpStatus.GONE); + httpStatusMap.put("/aai/v3/search/edge-tag-query/aifjsodifjiasjdfioadjsiofjaiosdj", HttpStatus.GONE); + httpStatusMap.put("/aai/v4/search/edge-tag-query/aifjsodifjiasjdfioadjsiofjaiosdj", HttpStatus.GONE); + httpStatusMap.put("/aai/v5/search/edge-tag-query/aifjsodifjiasjdfioadjsiofjaiosdj", HttpStatus.GONE); + httpStatusMap.put("/aai/v6/search/edge-tag-query/aifjsodifjiasjdfioadjsiofjaiosdj", HttpStatus.GONE); + httpStatusMap.put("/aai/v7/search/edge-tag-query/aifjsodifjiasjdfioadjsiofjaiosdj", HttpStatus.GONE); + httpStatusMap.put("/aai/v8/search/edge-tag-query/aifjsodifjiasjdfioadjsiofjaiosdj", HttpStatus.GONE); + httpStatusMap.put("/aai/v9/search/edge-tag-query/aifjsodifjiasjdfioadjsiofjaiosdj", HttpStatus.GONE); + httpStatusMap.put("/aai/v10/search/edge-tag-query/aifjsodifjiasjdfioadjsiofjaiosdj", HttpStatus.GONE); + httpStatusMap.put("/aai/v11/search/edge-tag-query/aifjsodifjiasjdfioadjsiofjaiosdj", HttpStatus.GONE); + httpStatusMap.put("/aai/v12/search/edge-tag-query/aifjsodifjiasjdfioadjsiofjaiosdj", HttpStatus.GONE); + httpStatusMap.put("/aai/v13/search/edge-tag-query/aifjsodifjiasjdfioadjsiofjaiosdj", HttpStatus.GONE); + httpStatusMap.put("/aai/v13/search/edge-tag-query", HttpStatus.GONE); + } + + private void setupNamedQueriesRetired() { + httpStatusMap = new HashMap<>(); + + httpStatusMap.put("/aai/v8/cloud-infrastructure/pservers/pserver/samomaisdjfajsfoas", HttpStatus.NOT_FOUND); + + httpStatusMap.put("/aai/v8/service-design-and-creation/named-queries/named-query/samomaisdjfajsfoas", HttpStatus.GONE); + } + + 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/cloud-infrastructure/pservers/pserver/test-pserver1", HttpStatus.GONE); + httpStatusMap.put("/aai/v3/cloud-infrastructure/pservers/pserver/test-pserver1", HttpStatus.GONE); + httpStatusMap.put("/aai/v4/cloud-infrastructure/pservers/pserver/test-pserver1", HttpStatus.GONE); + httpStatusMap.put("/aai/v5/cloud-infrastructure/pservers/pserver/test-pserver1", HttpStatus.GONE); + httpStatusMap.put("/aai/v6/cloud-infrastructure/pservers/pserver/test-pserver1", HttpStatus.GONE); + } + + private void setupModelsRetired() { + + httpStatusMap = new HashMap<>(); + + httpStatusMap.put("/aai/v8/cloud-infrastructure/pservers/pserver/samomaisdjfajsfoas", HttpStatus.NOT_FOUND); + + httpStatusMap.put("/aai/v8/service-design-and-creation/models/model/samomaisdjfajsfoas", HttpStatus.GONE); + } +} diff --git a/aai-resources/src/test/java/org/onap/aai/rest/retired/RetiredConsumerTest.java b/aai-resources/src/test/java/org/onap/aai/rest/retired/RetiredConsumerTest.java deleted file mode 100644 index 3c2897c..0000000 --- a/aai-resources/src/test/java/org/onap/aai/rest/retired/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.rest.retired; - -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.AAISetup; -import org.onap.aai.introspection.Version; - -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 extends AAISetup { - - 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-resources/src/test/java/org/onap/aai/rest/retired/V3ThroughV7ConsumerTest.java b/aai-resources/src/test/java/org/onap/aai/rest/retired/V3ThroughV7ConsumerTest.java deleted file mode 100644 index fef695a..0000000 --- a/aai-resources/src/test/java/org/onap/aai/rest/retired/V3ThroughV7ConsumerTest.java +++ /dev/null @@ -1,28 +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; - -public class V3ThroughV7ConsumerTest extends RetiredConsumerTest { - - @Override - public RetiredConsumer getRetiredConsumer() { - return new V3ThroughV7Consumer(); - } -} diff --git a/aai-resources/src/test/java/org/onap/aai/rest/tools/ModelVersionTransformerTest.java b/aai-resources/src/test/java/org/onap/aai/rest/tools/ModelVersionTransformerTest.java deleted file mode 100644 index 1fb048a..0000000 --- a/aai-resources/src/test/java/org/onap/aai/rest/tools/ModelVersionTransformerTest.java +++ /dev/null @@ -1,135 +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.tools; - -import com.att.eelf.configuration.EELFLogger; -import com.att.eelf.configuration.EELFManager; -import org.junit.Before; -import org.junit.BeforeClass; -import org.junit.Test; -import org.mockito.Mockito; -import org.onap.aai.AAISetup; -import org.onap.aai.dbmap.AAIGraph; -import org.onap.aai.introspection.ModelInjestor; -import org.skyscreamer.jsonassert.JSONAssert; - -import javax.ws.rs.core.*; -import java.util.*; - -import static org.junit.Assert.assertNotNull; -import static org.mockito.Matchers.anyObject; -import static org.mockito.Mockito.when; - -public class ModelVersionTransformerTest extends AAISetup { - - - 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); - } - - private ModelVersionTransformer modelVersionTransformer; - - 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 static final EELFLogger logger = EELFManager.getInstance().getLogger(ModelVersionTransformerTest.class.getName()); - - @BeforeClass - public static void setupRest(){ - AAIGraph.getInstance(); - ModelInjestor.getInstance(); - } - - @Before - public void setup(){ - logger.info("Starting the setup for the integration tests of Rest Endpoints"); - - modelVersionTransformer = new ModelVersionTransformer(); - 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("Content-Type", "application/xml"); - 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 modelTransform() throws Exception { - - String modelXmlPayload = getPayload("payloads/modeltransforms/model.xml"); - String modelJsonPayload = getPayload("payloads/modeltransforms/model.json"); - - String uri = "modeltransform"; - - when(uriInfo.getPath()).thenReturn(uri); - // Comment the following line for the null pointer exception - when(uriInfo.getPath(false)).thenReturn(uri); - - outputMediaTypes = new ArrayList<>(); - outputMediaTypes.add(MediaType.valueOf("application/xml")); - - when(httpHeaders.getAcceptableMediaTypes()).thenReturn(outputMediaTypes); - when(httpHeaders.getRequestHeaders()).thenReturn(headersMultiMap); - when(httpHeaders.getMediaType()).thenReturn(MediaType.valueOf("application/xml")); - - Response response = modelVersionTransformer.modelTransform(modelXmlPayload,uri, httpHeaders, uriInfo, null); - - assertNotNull(response); - } -} diff --git a/aai-resources/src/test/java/org/onap/aai/rest/retired/V7V8ModelsTest.java b/aai-resources/src/test/java/org/onap/aai/rest/util/LogFormatToolsTest.java index 76b38af..f17257b 100644 --- a/aai-resources/src/test/java/org/onap/aai/rest/retired/V7V8ModelsTest.java +++ b/aai-resources/src/test/java/org/onap/aai/rest/util/LogFormatToolsTest.java @@ -17,12 +17,18 @@ * limitations under the License. * ============LICENSE_END========================================================= */ -package org.onap.aai.rest.retired; +package org.onap.aai.rest.util; -public class V7V8ModelsTest extends RetiredConsumerTest { +import org.junit.Test; - @Override - public RetiredConsumer getRetiredConsumer() { - return new V7V8Models(); +import static org.junit.Assert.assertNotNull; + +public class LogFormatToolsTest { + + @Test + public void testLogFormatTools(){ + + String dateTime = new LogFormatTools().getCurrentDateTime(); + assertNotNull(dateTime); } } diff --git a/aai-resources/src/test/java/org/onap/aai/rest/util/ValidateEncodingTest.java b/aai-resources/src/test/java/org/onap/aai/rest/util/ValidateEncodingTest.java index 483d254..136b64e 100644 --- a/aai-resources/src/test/java/org/onap/aai/rest/util/ValidateEncodingTest.java +++ b/aai-resources/src/test/java/org/onap/aai/rest/util/ValidateEncodingTest.java @@ -75,6 +75,7 @@ public class ValidateEncodingTest { assertEquals(false, validator.validate(mockUriInfo)); } + @Test public void goodQueryParams() throws UnsupportedEncodingException { MultivaluedHashMap<String, String> map = new MultivaluedHashMap<String, String>(); @@ -87,6 +88,18 @@ 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); diff --git a/aai-resources/src/test/java/org/onap/aai/schema/db/ManageSchemaTest.java b/aai-resources/src/test/java/org/onap/aai/schema/db/ManageSchemaTest.java deleted file mode 100644 index de5eba1..0000000 --- a/aai-resources/src/test/java/org/onap/aai/schema/db/ManageSchemaTest.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.schema.db; - -import org.janusgraph.core.JanusGraphFactory; -import org.janusgraph.core.JanusGraph; -import org.janusgraph.core.schema.JanusGraphManagement; -import org.codehaus.jackson.JsonParseException; -import org.codehaus.jackson.map.JsonMappingException; -import org.codehaus.jackson.map.ObjectMapper; -import org.junit.Before; -import org.junit.Ignore; -import org.junit.Test; -import org.onap.aai.AAISetup; -import org.onap.aai.db.schema.DBIndex; -import org.onap.aai.db.schema.ManageJanusGraphSchema; - -import java.io.IOException; -import java.util.Set; - -@Ignore("not ready yet") -public class ManageSchemaTest extends AAISetup { - - private JanusGraph graph = null; - - @Before - public void beforeTest() { - graph = JanusGraphFactory.open("bundleconfig-local/etc/appprops/aaiconfig.properties"); - } - - /* - @Test - public void populateEmptyGraph() { - ManageJanusGraphSchema schema = new ManageJanusGraphSchema(graph); - schema.buildSchema(); - } - - @Test - public void modifyIndex() { - ManageJanusGraphSchema schema = new ManageJanusGraphSchema(graph); - schema.buildSchema(); - Vertex v = graph.addVertex(); - v.setProperty("aai-node-type", "pserver"); - v.setProperty("hostname", "test1"); - v.setProperty("internet-topology", "test2"); - graph.commit(); - DBIndex index = new DBIndex(); - index.setName("internet-topology"); - index.setUnique(false); - schema.updateIndex(index); - - } - */ - @Test - public void closeRunningInstances() { - - JanusGraphManagement mgmt = graph.openManagement(); - Set<String> instances = mgmt.getOpenInstances(); - - for (String instance : instances) { - - if (!instance.contains("(current)")) { - mgmt.forceCloseInstance(instance); - } - } - mgmt.commit(); - - graph.close(); - - } - @Test - public void addNewIndex() throws JsonParseException, JsonMappingException, IOException { - ObjectMapper mapper = new ObjectMapper(); - String content = " {\r\n" + - " \"name\" : \"equipment-name\",\r\n" + - " \"unique\" : false,\r\n" + - " \"properties\" : [ {\r\n" + - " \"name\" : \"equipment-name\",\r\n" + - " \"cardinality\" : \"SINGLE\",\r\n" + - " \"typeClass\" : \"java.lang.String\"\r\n" + - " } ]\r\n" + - " }"; - DBIndex index = mapper.readValue(content, DBIndex.class); - ManageJanusGraphSchema schema = new ManageJanusGraphSchema(graph); - JanusGraphManagement mgmt = graph.openManagement(); - Set<String> instances = mgmt.getOpenInstances(); - System.out.println(instances); - schema.updateIndex(index); - - graph.close(); - - } - -} diff --git a/aai-resources/src/test/java/org/onap/aai/serialization/queryformats/QueryFormatTestHelper.java b/aai-resources/src/test/java/org/onap/aai/serialization/queryformats/QueryFormatTestHelper.java deleted file mode 100644 index 609de5f..0000000 --- a/aai-resources/src/test/java/org/onap/aai/serialization/queryformats/QueryFormatTestHelper.java +++ /dev/null @@ -1,74 +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.serialization.queryformats; - -import org.apache.tinkerpop.gremlin.structure.Graph; -import org.apache.tinkerpop.gremlin.structure.Vertex; -import org.apache.tinkerpop.gremlin.structure.io.IoCore; -import org.apache.tinkerpop.gremlin.tinkergraph.structure.TinkerGraph; -import org.mockito.invocation.InvocationOnMock; -import org.mockito.stubbing.Answer; -import org.onap.aai.db.props.AAIProperties; -import org.onap.aai.serialization.queryformats.exceptions.AAIFormatVertexException; -import org.onap.aai.serialization.queryformats.utils.UrlBuilder; - -import java.io.IOException; -import java.lang.reflect.Field; -import java.lang.reflect.Modifier; - -import static org.mockito.Matchers.isA; -import static org.mockito.Mockito.when; - -public class QueryFormatTestHelper { - - - public static final String testResources = "src/test/resources/org.onap.aai/serialization/queryformats/"; - public static final String graphsonResources = "src/test/resources/org.onap.aai/serialization/queryformats/graphson/"; - - - public static void mockPathed(UrlBuilder mock) throws AAIFormatVertexException { - Answer<String> answer = new Answer<String>() { - public String answer(InvocationOnMock invocation) throws Throwable { - Vertex v = invocation.getArgumentAt(0, Vertex.class); - - return v.<String>property(AAIProperties.AAI_URI).orElse("urimissing"); - } - }; - when(mock.pathed(isA(Vertex.class))).thenAnswer(answer); - - } - - public static Graph loadGraphson(String fileName) throws IOException { - final Graph graph = TinkerGraph.open(); - graph.io(IoCore.graphson()).readGraph(QueryFormatTestHelper.graphsonResources + fileName); - - return graph; - } - - public static void setFinalStatic(Field field, Object newValue) throws Exception { - field.setAccessible(true); - // remove final modifier from field - Field modifiersField = Field.class.getDeclaredField("modifiers"); - modifiersField.setAccessible(true); - modifiersField.setInt(field, field.getModifiers() & ~Modifier.FINAL); - field.set(null, newValue); - } - -} diff --git a/aai-resources/src/test/java/org/onap/aai/serialization/queryformats/ResourceFormatSpec.java b/aai-resources/src/test/java/org/onap/aai/serialization/queryformats/ResourceFormatSpec.java deleted file mode 100644 index 19a2ffd..0000000 --- a/aai-resources/src/test/java/org/onap/aai/serialization/queryformats/ResourceFormatSpec.java +++ /dev/null @@ -1,59 +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.serialization.queryformats; - -import com.bazaarvoice.jolt.JsonUtils; -import com.google.gson.Gson; -import com.google.gson.JsonObject; -import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.__; -import org.apache.tinkerpop.gremlin.structure.Graph; -import org.onap.aai.transforms.JoltTestUtil; - -import java.io.IOException; -import java.util.List; - -public class ResourceFormatSpec { - - - private final Graph graph; - public ResourceFormatSpec() throws IOException { - - this.graph = QueryFormatTestHelper.loadGraphson("resource.graphson"); - } - - - public void verifyFormat(Formatter formatter, String fileName) throws IOException { - List<Object> vertices = graph.traversal().V().not(__.has("aai-node-type", "cloud-region")).map(x -> (Object)x.get()).toList(); - - JsonObject obj = formatter.output(vertices); - String jsonStr = new Gson().toJson(obj); - Object actual = JsonUtils.jsonToObject(jsonStr); - - Object expected = JsonUtils.filepathToObject(QueryFormatTestHelper.testResources + fileName); - - JoltTestUtil.runArrayOrderObliviousDiffy("Failed case ", expected, actual); - } - - public void mockToJson(String result) { - - - - } -} diff --git a/aai-resources/src/test/java/org/onap/aai/serialization/queryformats/ResourceFormatTest.java b/aai-resources/src/test/java/org/onap/aai/serialization/queryformats/ResourceFormatTest.java deleted file mode 100644 index 5379676..0000000 --- a/aai-resources/src/test/java/org/onap/aai/serialization/queryformats/ResourceFormatTest.java +++ /dev/null @@ -1,77 +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.serialization.queryformats; - -import com.google.gson.JsonObject; -import org.apache.tinkerpop.gremlin.structure.Vertex; -import org.junit.Before; -import org.junit.Ignore; -import org.junit.Test; -import org.mockito.Mock; -import org.mockito.MockitoAnnotations; -import org.onap.aai.introspection.Loader; -import org.onap.aai.serialization.db.DBSerializer; -import org.onap.aai.serialization.queryformats.exceptions.AAIFormatVertexException; -import org.onap.aai.serialization.queryformats.utils.UrlBuilder; - -import java.io.IOException; - -import static org.mockito.Matchers.isA; -import static org.mockito.Mockito.doReturn; -import static org.mockito.Mockito.spy; - -@Ignore -public class ResourceFormatTest { - - @Mock - private UrlBuilder urlBuilder; - @Mock - private DBSerializer serializer; - @Mock - private Loader loader; - - private ResourceFormatSpec spec; - - @Before - public void setup() throws Exception { - spec = new ResourceFormatSpec(); - MockitoAnnotations.initMocks(this); - } - - @Test - public void resourceAndUrl() throws Exception { - QueryFormatTestHelper.mockPathed(urlBuilder); - Resource resource = new Resource.Builder(loader, serializer, urlBuilder).includeUrl().build(); - Resource spy = spy(resource); - doReturn(new JsonObject()).when(spy).vertexToJsonObject(isA(Vertex.class)); - Formatter formatter = new Formatter(spy); - spec.verifyFormat(formatter, "resource_and_url-format.json"); - } - - @Test - public void resource() throws IOException, AAIFormatVertexException { - QueryFormatTestHelper.mockPathed(urlBuilder); - Resource resource = new Resource.Builder(loader, serializer, urlBuilder).build(); - Resource spy = spy(resource); - doReturn(new JsonObject()).when(spy).vertexToJsonObject(isA(Vertex.class)); - Formatter formatter = new Formatter(spy); - spec.verifyFormat(formatter, "resource-format.json"); - } -} diff --git a/aai-resources/src/test/java/org/onap/aai/transforms/JoltTestUtil.java b/aai-resources/src/test/java/org/onap/aai/transforms/JoltTestUtil.java deleted file mode 100644 index 07832a8..0000000 --- a/aai-resources/src/test/java/org/onap/aai/transforms/JoltTestUtil.java +++ /dev/null @@ -1,59 +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.transforms; - - -import com.bazaarvoice.jolt.ArrayOrderObliviousDiffy; -import com.bazaarvoice.jolt.Diffy; -import com.bazaarvoice.jolt.JsonUtils; -import org.junit.Assert; - -import java.io.IOException; - -public class JoltTestUtil { - - private static final Diffy diffy = new Diffy(); - private static final Diffy arrayOrderObliviousDiffy = new ArrayOrderObliviousDiffy(); - - public static void runDiffy( String failureMessage, Object expected, Object actual ) throws IOException { - runDiffy( diffy, failureMessage, expected, actual ); - } - - public static void runDiffy( Object expected, Object actual ) throws IOException { - runDiffy( diffy, "Failed", expected, actual ); - } - - public static void runArrayOrderObliviousDiffy( String failureMessage, Object expected, Object actual ) throws IOException { - runDiffy( arrayOrderObliviousDiffy, failureMessage, expected, actual ); - } - - public static void runArrayOrderObliviousDiffy( Object expected, Object actual ) throws IOException { - runDiffy( arrayOrderObliviousDiffy, "Failed", expected, actual ); - } - - - private static void runDiffy( Diffy diffy, String failureMessage, Object expected, Object actual ) { - String actualObject = JsonUtils.toPrettyJsonString( actual ); - Diffy.Result result = diffy.diff( expected, actual ); - if (!result.isEmpty()) { - Assert.fail( "\nActual object\n" + actualObject + "\n" + failureMessage + "\nDiffy output\n" + result.toString()); - } - } -} diff --git a/aai-resources/src/test/java/org/onap/aai/transforms/LowerHyphenToLowerCamelConverterTest.java b/aai-resources/src/test/java/org/onap/aai/transforms/LowerHyphenToLowerCamelConverterTest.java deleted file mode 100644 index c88e005..0000000 --- a/aai-resources/src/test/java/org/onap/aai/transforms/LowerHyphenToLowerCamelConverterTest.java +++ /dev/null @@ -1,72 +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.transforms; - -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; -import org.junit.runners.Parameterized.Parameters; - -import java.util.Arrays; -import java.util.Collection; - -import static org.junit.Assert.assertEquals; - -@RunWith(Parameterized.class) -public class LowerHyphenToLowerCamelConverterTest { - - private Converter converter = new LowerHyphenToLowerCamelConverter(); - - private String input; - private String expected; - - public LowerHyphenToLowerCamelConverterTest(String input, String expected){ - this.input = input; - this.expected = expected; - } - - /** - * Data Provider for the Lower Hyphen to Camel Converter Tests - * Make sure the capitalization is not lost during the conversion - * @return - */ - @Parameters - public static Collection<Object[]> data(){ - - return Arrays.asList(new Object[][]{ - {null, null}, - {"test-name", "testName"}, - {"test---name", "testName"}, // Case multiple - {"testName", "testName"}, // Case where upper case word shouldn't be lowercased - {"test-name-cool", "testNameCool"}, - {"test-name-Cool", "testNameCool"}, - {"test-name-Cool-Name-wow----Rest", "testNameCoolNameWowRest"}, - {"test-name#fast#", "testName#fast#"}, - {"test-name---", "testName"}, - {"----test-name", "TestName"}, - }); - } - - @Test - public void testIfInputSuccessfullyModified(){ - String actual = converter.convert(input); - assertEquals(expected, actual); - } -} diff --git a/aai-resources/src/test/java/org/onap/aai/transforms/MapTraverserTest.java b/aai-resources/src/test/java/org/onap/aai/transforms/MapTraverserTest.java deleted file mode 100644 index fef84c2..0000000 --- a/aai-resources/src/test/java/org/onap/aai/transforms/MapTraverserTest.java +++ /dev/null @@ -1,53 +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.transforms; - -import com.bazaarvoice.jolt.JsonUtils; -import org.junit.Test; - -import java.io.IOException; -import java.util.Map; - -public class MapTraverserTest { - - private final String testResources = "src/test/resources/maputils/testcases/"; - - private String[] testCases = { "TestCase1.json", "TestCase2.json" }; - private MapTraverser traverser = new MapTraverser(new LowerCamelToLowerHyphenConverter()); - - @Test(expected = NullPointerException.class) - public void testIfMapIsNullThrowNullPointerException(){ - Map<String, Object> map = null; - traverser.convertKeys(map); - } - - @Test - public void runTestCases() throws IOException { - - for(String testCase : testCases){ - Map<String, Object> values = JsonUtils.filepathToMap(testResources + testCase); - - Object input = values.get("input"); - Object actual = traverser.convertKeys((Map<String, Object>)input); - Object output = values.get("output"); - JoltTestUtil.runArrayOrderObliviousDiffy( "failed case " + testCase, output, actual ); - } - } -} diff --git a/aai-resources/src/test/java/org/onap/aai/util/AAIRSyncUtilityTest.java b/aai-resources/src/test/java/org/onap/aai/util/AAIRSyncUtilityTest.java deleted file mode 100644 index c1aeff9..0000000 --- a/aai-resources/src/test/java/org/onap/aai/util/AAIRSyncUtilityTest.java +++ /dev/null @@ -1,211 +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 org.junit.Before; -import org.junit.Ignore; -import org.junit.Test; -import org.onap.aai.AAISetup; - -import java.io.File; -import java.lang.reflect.Field; -import java.lang.reflect.InvocationTargetException; -import java.lang.reflect.Method; -import java.lang.reflect.Modifier; -import java.net.InetAddress; -import java.net.UnknownHostException; -import java.nio.file.Files; -import java.util.ArrayList; -import java.util.List; -import java.util.StringTokenizer; -import java.util.UUID; - -import static org.junit.Assert.*; - -@Ignore -public class AAIRSyncUtilityTest extends AAISetup { - - AAIRSyncUtility syncUtil; - AAIRSyncUtility syncUtilOmitDoCommand; - AAIConfig aaiConfig; - String hostName; - String transId = UUID.randomUUID().toString(); - - /** - * Initialize. - */ - @Before - public void initialize(){ - syncUtil = new AAIRSyncUtility(); - - syncUtilOmitDoCommand = new AAIRSyncUtility(){ - /** - * {@inheritDoc} - */ - @Override - public int doCommand(List<String> command) throws Exception - { - return 1; - } - }; - - partialSetupForAAIConfig(); - - InetAddress ip = null; - try { - ip = InetAddress.getLocalHost(); - } catch (UnknownHostException e2) { - e2.printStackTrace(); - } - hostName = ip.getHostName(); - } - - - /** - * Test sendRsync. - */ - @Test - public void testSendRsyncCommand(){ - syncUtilOmitDoCommand.sendRsyncCommand(transId, "RandomFileName"); - //TODO write codes to check what is being logged - } - - /** - * Test getHost. - */ - @Test - public void testGetHost(){ - - String returnedHost = null; - Method getHostMethod = makePublic("getHost"); - try { - returnedHost = (String)getHostMethod.invoke(syncUtil, null); - } catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException e) { - e.printStackTrace(); - } - - assertEquals("Host name didn't match", returnedHost, hostName); - } - - /** - * Test getRemoteHostList. - */ - @Test - public void testGetRemoteHostList(){ - String localHost = "host_local"; - String remoteHost1 = "hostR1"; - String remoteHost2 = "hostR2"; - ArrayList<String> remotes = new ArrayList<String>(); - remotes.add(remoteHost1); - remotes.add(remoteHost2); - - StringTokenizer stTokenizer = new StringTokenizer(remoteHost1+"\r"+remoteHost2+"\r"+localHost); - - Method m = makePublic("getRemoteHostList"); - try { - assertEquals("Remote host missing", remotes, m.invoke(syncUtil, stTokenizer, localHost)); - } catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException e) { - e.printStackTrace(); - } - } - - /** - * Test doCommand. - */ - @Test - public void testDoCommand(){ - - assertTrue("Don't have execute permissions", Files.isExecutable(new File(".").toPath())); - - List<String> commands = new ArrayList<String>(); - commands.add("ping"); - commands.add("google.com"); - try { - assertEquals("Failed to execute commands", 1, syncUtilOmitDoCommand.doCommand(commands)); - } catch (Exception e) { - fail("Failed to execute a command"); - e.printStackTrace(); - } - - } - - /** - * Test doCommand with null. - */ - @Test - public void testDoCommand_withNull(){ - assertTrue("Don't have execute permissions", Files.isExecutable(new File(".").toPath())); - try { - assertEquals("This should be unreachable", 1, syncUtil.doCommand(null)); - } catch (Exception e) { - assertTrue("Expecting an NPE from ProcessBuilder", e instanceof NullPointerException); - } - - } - - - /** - * Helper method to covert access type of a method from private to public . - * - * @param privateMethodName Method which is private originally - * @return method object with 'access type = 'public' - */ - public Method makePublic(String privateMethodName){ - Method targetMethod = null; - try { - if (privateMethodName.equals("getHost")) - targetMethod = AAIRSyncUtility.class.getDeclaredMethod(privateMethodName, null); - else if (privateMethodName.equals("getRemoteHostList")) - targetMethod = AAIRSyncUtility.class.getDeclaredMethod(privateMethodName, StringTokenizer.class, String.class); - } catch (NoSuchMethodException | SecurityException e) { - e.printStackTrace(); - } - targetMethod.setAccessible(true); - return targetMethod; - } - - /** - * Helper method to load aai config from test configuration file - * This requires that the 'test_aaiconfig.properties' file is available - */ - static void setFinalStatic(Field field, Object newValue) throws Exception { - field.setAccessible(true); - Field modifiersField = Field.class.getDeclaredField("modifiers"); - modifiersField.setAccessible(true); - modifiersField.setInt(field, field.getModifiers() & ~Modifier.FINAL); - field.set(null, newValue); - } - - /** - * Helper method to setup AAIConfig for test. - */ - public void partialSetupForAAIConfig(){ - try { - setFinalStatic(AAIConfig.class.getDeclaredField("GlobalPropFileName"), "src/test/resources/bundleconfig-local/etc/appprops/aaiconfig.properties"); - } - catch (SecurityException e) {fail();} - catch (NoSuchFieldException e) {fail();} - catch (Exception e) {fail();} - - AAIConfig.reloadConfig(); - } - -} diff --git a/aai-resources/src/test/java/org/onap/aai/util/DataConversionHelperTest.java b/aai-resources/src/test/java/org/onap/aai/util/DataConversionHelperTest.java deleted file mode 100644 index 3acbf03..0000000 --- a/aai-resources/src/test/java/org/onap/aai/util/DataConversionHelperTest.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.util; - -import org.junit.Rule; -import org.junit.Test; -import org.powermock.modules.agent.PowerMockAgent; -import org.powermock.modules.junit4.rule.PowerMockRule; - -import static org.junit.Assert.assertEquals; - -public class DataConversionHelperTest { - - @Rule - public PowerMockRule rule = new PowerMockRule(); - - static { - PowerMockAgent.initializeIfNeeded(); - } - - /** - * Test convertIPVersionNumToString with value "4". - */ - @Test - public void testConvertIPVersionNumToString_withNum4(){ - assertEquals(DataConversionHelper.IPVERSION_IPV4, DataConversionHelper.convertIPVersionNumToString("4")); - } - - /** - * Test convertIPVersionNumToString with value "6". - */ - @Test - public void testConvertIPVersionNumToString_withNum6(){ - assertEquals(DataConversionHelper.IPVERSION_IPV6, DataConversionHelper.convertIPVersionNumToString("6")); - } - - /** - * Test convertIPVersionNumToString with a value other than "4" or "6". - */ - @Test - public void testConvertIPVersionNumToString_withAThirdNumber(){ - assertEquals(DataConversionHelper.IPVERSION_UNKNOWN, DataConversionHelper.convertIPVersionNumToString("-1")); - } - - /** - * Test convertIPVersionStringToNum with "v4". - */ - @Test - public void testConvertIPVersionStringToNum_withV4(){ - assertEquals("4", DataConversionHelper.convertIPVersionStringToNum(DataConversionHelper.IPVERSION_IPV4)); - } - - /** - * Test convertIPVersionStringToNum with "v6". - */ - @Test - public void testConvertIPVersionStringToNum_withV6(){ - assertEquals("6", DataConversionHelper.convertIPVersionStringToNum(DataConversionHelper.IPVERSION_IPV6)); - } - - /** - * Test convertIPVersionStringToNum with an illegal version. - */ - @Test - public void testConvertIPVersionStringToNum_withRandomString(){ - assertEquals("0", DataConversionHelper.convertIPVersionStringToNum("test string")); - } - - -} diff --git a/aai-resources/src/test/java/org/onap/aai/util/DbTestConfig.java b/aai-resources/src/test/java/org/onap/aai/util/DbTestConfig.java deleted file mode 100644 index 09e4cd7..0000000 --- a/aai-resources/src/test/java/org/onap/aai/util/DbTestConfig.java +++ /dev/null @@ -1,294 +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.*; -import java.net.InetAddress; -import java.util.*; - -public class DbTestConfig { - - public static final String AUDIT_FILESEP = (System.getProperty("file.separator") == null) ? "/" : System.getProperty("file.separator"); - public static final String AUDIT_HOME = (System.getProperty("audit.home") == null) ? AUDIT_FILESEP + "opt" + AUDIT_FILESEP + "audit" : System.getProperty("audit.home"); - public static final String AuditPropFilename = "c:\\tmp\\auditConfig.prop"; - public static final String AUDIT_CONFIG_CHECKINGTIME = "audit.config.checktime"; - public static final String AUDIT_NODENAME = "localhost"; - public static final String AUDIT_DEBUG = "audit.config.debug"; - - private static Properties serverProps; - private static boolean propsInitialized = false; - private static boolean timerSet = false; - private static Timer timer = null; - - private static String propFile = null; - - /** - * Inits the. - * - * @param propertyFile the property file - */ - public synchronized static void init(String propertyFile) { - propFile = propertyFile; - init(); - } - - /** - * Inits the. - */ - public synchronized static void init() { - System.out.println("Initializing Config"); - - DbTestConfig.getConfigFile(); - DbTestConfig.reloadConfig(); - - if ( propFile == null) - propFile = AuditPropFilename; - TimerTask task = null; - task = new DbTestFileWatcher ( new File(propFile)) { - protected void onChange( File file ) { - // here we implement the onChange - DbTestConfig.reloadConfig(); - } - }; - - if (!timerSet) { - timerSet = true; - // repeat the check every second - timer = new Timer(); - String fwi = DbTestConfig.get(AUDIT_CONFIG_CHECKINGTIME); - timer.schedule( task , new Date(), Integer.parseInt(fwi) ); - System.out.println("Config Watcher Interval=" + fwi); - - System.out.println("File" + propFile+" Loaded!"); - } - - } - - /** - * Cleanup. - */ - public static void cleanup() { - timer.cancel(); - } - - /** - * Gets the config file. - * - * @return the config file - */ - public static String getConfigFile() { - return propFile; - } - - /** - * Reload config. - */ - public synchronized static void reloadConfig() { - - String propFileName = propFile; - - Properties newServerProps = null; - - System.out.println("Reloading config from "+propFileName); - - try { - InputStream is = new FileInputStream(propFileName); - newServerProps = new Properties(); - newServerProps.load(is); - propsInitialized = true; - - serverProps = newServerProps; - if (get(AUDIT_DEBUG).equals("on")) { - serverProps.list(System.out); - } - newServerProps = null; - - } catch (FileNotFoundException fnfe) { - System.out.println("AuditConfig: " + propFileName + ". FileNotFoundException: "+fnfe.getMessage()); - } catch (IOException e) { - System.out.println("AuditConfig: " + propFileName + ". IOException: "+e.getMessage()); - } - } - - /** - * Gets the. - * - * @param key the key - * @param defaultValue the default value - * @return the string - */ - public static String get(String key, String defaultValue) { - String result = defaultValue; - try { - result = get (key); - } - catch ( Exception a ) { - } - return result; - } - - /** - * Gets the. - * - * @param key the key - * @return the string - */ - public static String get(String key) { - String response = null; - - if (key.equals(AUDIT_NODENAME)) { - // Get this from InetAddress rather than the properties file - String nodeName = getNodeName(); - if (nodeName != null) { - return nodeName; - } - // else get from property file - } - - if (!propsInitialized || (serverProps == null)) { - reloadConfig(); - } - if (!serverProps.containsKey(key)) { - System.out.println( "Property key "+key+" cannot be found"); - } else { - response = serverProps.getProperty(key); - if (response == null || response.isEmpty()) { - System.out.println("Property key "+key+" is null or empty"); - } - } - return response; - } - - /** - * Gets the int. - * - * @param key the key - * @return the int - */ - public static int getInt(String key) { - return Integer.valueOf(DbTestConfig.get(key)); - } - - /** - * Gets the server props. - * - * @return the server props - */ - public static Properties getServerProps() { - return serverProps; - } - - /** - * Gets the node name. - * - * @return the node name - */ - public static String getNodeName() { - try { - InetAddress ip = InetAddress.getLocalHost(); - if (ip != null) { - String hostname = ip.getHostName(); - if (hostname != null) { - return hostname; - } - } - } catch (Exception e) { - return null; - } - return null; - } - - /** - * Extracts a specific property key subset from the known properties. - * The prefix may be removed from the keys in the resulting dictionary, - * or it may be kept. In the latter case, exact matches on the prefix - * will also be copied into the resulting dictionary. - * - * @param prefix is the key prefix to filter the properties by. - * @param keepPrefix if true, the key prefix is kept in the resulting - * dictionary. As side-effect, a key that matches the prefix exactly - * will also be copied. If false, the resulting dictionary's keys are - * shortened by the prefix. An exact prefix match will not be copied, - * as it would result in an empty string key. - * @return a property dictionary matching the filter key. May be - * an empty dictionary, if no prefix matches were found. - * - * @see #getProperty( String ) is used to assemble matches - */ - public static Properties matchingSubset(String prefix, boolean keepPrefix) { - Properties result = new Properties(); - - // sanity check - if (prefix == null || prefix.length() == 0) { - return result; - } - - String prefixMatch; // match prefix strings with this - String prefixSelf; // match self with this - if (prefix.charAt(prefix.length() - 1) != '.') { - // prefix does not end in a dot - prefixSelf = prefix; - prefixMatch = prefix + '.'; - } else { - // prefix does end in one dot, remove for exact matches - prefixSelf = prefix.substring(0, prefix.length() - 1); - prefixMatch = prefix; - } - // POSTCONDITION: prefixMatch and prefixSelf are initialized! - - // now add all matches into the resulting properties. - // Remark 1: #propertyNames() will contain the System properties! - // Remark 2: We need to give priority to System properties. This is done - // automatically by calling this class's getProperty method. - String key; - for (Enumeration e = serverProps.keys(); e.hasMoreElements(); ) { - key = (String) e.nextElement(); - - if (keepPrefix) { - // keep full prefix in result, also copy direct matches - if (key.startsWith(prefixMatch) || key.equals(prefixSelf)) { - result.setProperty(key, serverProps.getProperty(key)); - } - } else { - // remove full prefix in result, dont copy direct matches - if (key.startsWith(prefixMatch)) { - result.setProperty(key.substring(prefixMatch.length()), serverProps.getProperty(key)); - } - } - } - - // done - return result; - } - - - - /** - * The main method. - * - * @param args the arguments - */ - public static void main(String[] args) { - // TODO Auto-generated method stub - DbTestConfig.init( ); - - } - -} diff --git a/aai-resources/src/test/java/org/onap/aai/util/DbTestGetFileTime.java b/aai-resources/src/test/java/org/onap/aai/util/DbTestGetFileTime.java deleted file mode 100644 index fb1f1ee..0000000 --- a/aai-resources/src/test/java/org/onap/aai/util/DbTestGetFileTime.java +++ /dev/null @@ -1,54 +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.File; -import java.io.IOException; -import java.nio.file.Files; -import java.nio.file.Path; -import java.nio.file.Paths; -import java.nio.file.attribute.BasicFileAttributeView; -import java.nio.file.attribute.BasicFileAttributes; -import java.nio.file.attribute.FileTime; - -public class DbTestGetFileTime { - - - /** - * Creates the file return time. - * - * @param path the path - * @return the file time - * @throws IOException Signals that an I/O exception has occurred. - */ - public FileTime createFileReturnTime( String path) throws IOException { - File file = new File(path); - if(!file.exists()) { - file.createNewFile(); - } - Path p = Paths.get(file.getAbsolutePath()); - BasicFileAttributes view - = Files.getFileAttributeView(p, BasicFileAttributeView.class) - .readAttributes(); - FileTime fileTime=view.creationTime(); - // also available view.lastAccessTine and view.lastModifiedTime - return fileTime; - } -} diff --git a/aai-resources/src/test/java/org/onap/aai/util/DbTestProcessBuilder.java b/aai-resources/src/test/java/org/onap/aai/util/DbTestProcessBuilder.java deleted file mode 100644 index 503ec0f..0000000 --- a/aai-resources/src/test/java/org/onap/aai/util/DbTestProcessBuilder.java +++ /dev/null @@ -1,213 +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.*; -import java.nio.file.attribute.FileTime; -import java.text.SimpleDateFormat; -import java.util.Arrays; -import java.util.List; -import java.util.concurrent.Executors; -import java.util.concurrent.ScheduledExecutorService; -import java.util.concurrent.ScheduledFuture; -import java.util.concurrent.TimeUnit; - -public class DbTestProcessBuilder { - ///public static Logger clog = Logger.getLogger("auditConsole"); - //public static Logger alog = Logger.getLogger("auditLog"); - - /** - * Start audit process non blocking. - * - * @param wait the wait - * @param cmds the cmds - * @param dir the dir - */ - public void startAuditProcessNonBlocking(final long wait, final String cmds[], final String dir) { - - final ProcessBuilder pb = new ProcessBuilder(cmds).redirectErrorStream(true).directory(new File(dir)); - - new Thread(new Runnable() { - public void run() { - try { - //System.out.println( "sleeping seconds " + wait + " cmds " + Arrays.toString(cmds)); - Thread.sleep(wait*1000); - //System.out.println( "returned from sleep"); - final Process p = pb.start(); - //System.out.println( "returned from pb.start"); - final InputStream is = p.getInputStream(); - final BufferedReader stdError = new BufferedReader(new InputStreamReader(p.getErrorStream())); - final InputStreamReader isr = new InputStreamReader(is); - final BufferedReader br = new BufferedReader(isr); -//clog.debug("Output of running " + Arrays.toString(cmds) + " is:"); - System.out.println("Output of running is:" ); - String line; - while ((line = br.readLine()) != null ) { - System.out.println(line); - } - System.out.println("stderr of running is:" ); - - while ((line = stdError.readLine()) != null ) { - System.out.println(line); - } - - } catch (IOException ie) { - - } catch (InterruptedException itre) { - Thread.currentThread().interrupt(); - } - } - }).start(); - - } - - - private final ScheduledExecutorService auditProcessScheduler = - Executors.newScheduledThreadPool(10); - - /** - * Run W command every X seconds for Y minutes. - * - * @param w the w - * @param x the x - * @param y the y - * @param runningDir the running dir - */ - public void runWCommandEveryXSecondsForYMinutes(String[] w, int x, int y, final String runningDir) { - final String[] c1 = w; - final Runnable audit = new Runnable() { - public void run() { -//clog.debug("checkpoint "+(new Date()).toString()); - DbTestProcessBuilder a1 = new DbTestProcessBuilder(); - a1.startAuditProcessNonBlocking(1, c1, "/tmp"); - } - }; - - final ScheduledFuture<?> auditHandle = - auditProcessScheduler.scheduleAtFixedRate(audit, 0, x, TimeUnit.SECONDS); - auditProcessScheduler.schedule(new Runnable() { - public void run() { - auditHandle.cancel(true); - } - }, y * 60, TimeUnit.SECONDS); - } - - - /** - * The main method. - * - * @param args the arguments - */ - @SuppressWarnings({ "null", "static-access" }) - public static void main(String args[]) { - String props = "NA"; - if (args.length > 0) { - System.out.println( "DbTestProcessBuilder called with " + args.length + " arguments, " + args[0]); - props = args[0].trim(); - } else { - System.out.print("usage: DbTestProcessBuilder <auditConfig.prop path\n"); - return; - } - DbTestConfig.init(props); - String ail = DbTestConfig.get("audit.list"); - String path = DbTestConfig.get("audit.path"); - final String runningDir = DbTestConfig.get("audit.runningdir"); - try { - DbTestGetFileTime getFileTime = new DbTestGetFileTime(); - FileTime fileTime = getFileTime.createFileReturnTime( path ); - System.out.println(path + " creation time :" - + new SimpleDateFormat("dd/MM/yyyy HH:mm:ss") - .format(fileTime.toMillis()) + " runningDir " + runningDir); - } catch ( IOException io ) { - System.out.println( "IOException getting creation time " + path + " message " + io.getMessage()); - io.printStackTrace(); - } - - List<String> items = Arrays.asList(ail.split("\\s*,\\s*")); - for (String ai: items) { - if (!DbTestConfig.get("audit.task."+ai+".status").startsWith("a")) { - continue; - } -//clog.debug("***audit item = " + ai + " Starting***"); - - String w1 = DbTestConfig.get("audit.task."+ai+".cmd"); - String[] w2 = w1.split("\\s*,\\s*"); - System.out.print( "task items are : " + Arrays.toString(w2)); - // append the audit item name as the prefix of the audit directory name - /*final int N = w2.length; - w2 = Arrays.copyOf(w2, N+1); - w2[N-2] = "\"-Dp=" + DbTestConfig.get("audit.task.odl.output.dir")+ai + "\""; -//clog.debug("***java -D:"+w2[N-2]); - //w2[N] = "\""+DbTestConfig.get("audit.task.odl.output.dir")+ai+"\""; - w2[N] = "\""+DbTestConfig.get("audit.task.odl.output.dir")+ai+"\""; - */ - DbTestProcessBuilder apb = new DbTestProcessBuilder(); - - String ts1 = DbTestConfig.get("audit.task."+ai+".schedule"); - String[] ts2 = ts1.split("\\s*,\\s*"); - // note ts2[0] is the wait-before time, and it is not being used right now. We start with ts2[1] - apb.runWCommandEveryXSecondsForYMinutes(w2,Integer.parseInt(ts2[1]),Integer.parseInt(ts2[2]), runningDir); -//clog.debug("***audit item = " + ai + " started***"); - System.out.println( "started test " + ai); - - /* - int ct = 0; - - while (true) try { - if (DbTestConfig.get("jcl").startsWith("q")) { - System.out.println("***Audit Main Program exiting..."); - System.exit(0); - } - - Thread.currentThread().sleep(1000); - if (ct < 10) { - ct++; - } else { - //clog.debug(AuditConfig.get("jcl").charAt(0)); - ct=0; - } - - } catch (InterruptedException ie) { - - } */ - } - int ct = 0; - - while (true) try { - if (DbTestConfig.get("jcl").startsWith("q")) { - System.out.println("***Audit Main Program exiting..."); - System.exit(0); - } - - Thread.currentThread().sleep(1000); - if (ct < 10) { - ct++; - } else { - //clog.debug(AuditConfig.get("jcl").charAt(0)); - ct=0; - } - - } catch (InterruptedException ie) { - - } - - } - -} diff --git a/aai-resources/src/test/java/org/onap/aai/util/JettyObfuscationConversionCommandLineUtilTest.java b/aai-resources/src/test/java/org/onap/aai/util/JettyObfuscationConversionCommandLineUtilTest.java deleted file mode 100644 index 7c4abc9..0000000 --- a/aai-resources/src/test/java/org/onap/aai/util/JettyObfuscationConversionCommandLineUtilTest.java +++ /dev/null @@ -1,71 +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 org.junit.Ignore; -import org.junit.Test; - -import java.io.ByteArrayOutputStream; -import java.io.PrintStream; -import java.util.regex.Matcher; -import java.util.regex.Pattern; - -import static org.junit.Assert.assertTrue; - -@Ignore -public class JettyObfuscationConversionCommandLineUtilTest { - private final ByteArrayOutputStream testOut = new ByteArrayOutputStream(); - - /** - * Test. - */ - @Test - public void test() { - //setup, this will catch main's print statements for evaluation -// System.setOut(new PrintStream(testOut)); - - /* ------ TEST OBFUSCATION ----*/ - JettyObfuscationConversionCommandLineUtil.main(new String[]{"-e", "hello world"}); - /* - * testOut was also catching any logging statements which interfered with result checking. - * This regex business was the workaround - it tries to find the expected value in - * the results and asserts against that. - */ - String obfResult = testOut.toString(); - String obfExpected = "OBF:1thf1ugo1x151wfw1ylz11tr1ymf1wg21x1h1uh21th7"; - Pattern obfExpectPat = Pattern.compile(obfExpected); - Matcher obfMatch = obfExpectPat.matcher(obfResult); - assertTrue(obfMatch.find()); - - testOut.reset(); //clear out previous result - - /* ------ TEST DEOBFUSCATION ----- */ - JettyObfuscationConversionCommandLineUtil.main(new String[]{"-d", obfExpected}); - String deobfResult = testOut.toString(); - String deobfExpected = "hello world"; - Pattern deobfExpectPat = Pattern.compile(deobfExpected); - Matcher deobfMatch = deobfExpectPat.matcher(deobfResult); - assertTrue(deobfMatch.find()); - - //clean up, resets to stdout -// System.setOut(null); - } - -} diff --git a/aai-resources/src/test/resources/application-test.properties b/aai-resources/src/test/resources/application-test.properties index e6edb6d..ade55fb 100644 --- a/aai-resources/src/test/resources/application-test.properties +++ b/aai-resources/src/test/resources/application-test.properties @@ -8,9 +8,12 @@ spring.application.name=aai-resources spring.jersey.type=filter server.contextPath=/ + +spring.jersey.application-path=${schema.uri.base.path} + spring.autoconfigure.exclude=org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration,org.springframework.boot.autoconfigure.orm.jpa.HibernateJpaAutoConfiguration -spring.profiles.active=production +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,17 +21,6 @@ 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 server.local.startpath=src/main/resources/ server.basic.auth.location=${server.local.startpath}etc/auth/realm.properties @@ -43,28 +35,32 @@ server.ssl.key-store-type=JKS # JMS bind address host port jms.bind.address=tcp://localhost:61647 -dmaap.ribbon.eureka.enabled=false + 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 +# 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 +schema.nodes.location=${server.local.startpath}/schema/${schema.source.name}/oxm/ +schema.edges.location=${server.local.startpath}/schema/${schema.source.name}/dbedgerules/ -# 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.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 +# 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-resources/src/test/resources/bundleconfig-local/etc/appprops/aaiconfig.properties b/aai-resources/src/test/resources/bundleconfig-local/etc/appprops/aaiconfig.properties deleted file mode 100644 index d406c04..0000000 --- a/aai-resources/src/test/resources/bundleconfig-local/etc/appprops/aaiconfig.properties +++ /dev/null @@ -1,148 +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. -# - -#################################################################### -# REMEMBER TO THINK ABOUT ENVIRONMENTAL DIFFERENCES AND CHANGE THE -# TEMPLATE AND *ALL* DATAFILES -#################################################################### - -aai.config.checktime=1000 - -# this could come from siteconfig.pl? -aai.config.nodename=AutomaticallyOverwritten - -aai.logging.hbase.interceptor=true -aai.logging.hbase.enabled=true -aai.logging.hbase.logrequest=true -aai.logging.hbase.logresponse=true - -aai.logging.trace.enabled=true -aai.logging.trace.logrequest=false -aai.logging.trace.logresponse=false - -aai.transaction.logging=true -aai.transaction.logging.get=true -aai.transaction.logging.post=true - - -ecm.openstack.tenantid=b0a529aba48440a39e0caf1aea9b27e3 -# This is a fake one just for test so please ignore -ecm.auth.password.x=OBF:1igd1i9a1jnb1yte1vv11vu91yt81jk71i6o1idt - -aai.avpn.interim.laginterface=ae0 - -aai.server.url.base=https://localhost:8443/aai/ -aai.server.url=https://localhost:8443/aai/v12/ -aai.global.callback.url=https://localhost:8443/aai/ - -aai.auth.cspcookies_on=false -aai.dbmodel.filename=ex5.json -aai.truststore.filename=aai_keystore -aai.truststore.passwd.x= -aai.keystore.filename=aai-client-cert.p12 -aai.keystore.passwd.x= - -# for transaction log -hbase.table.name=aailogging-dev1.dev -hbase.notificationTable.name=aainotification-dev1.dev -hbase.table.timestamp.format=YYYYMMdd-HH:mm:ss:SSS -hbase.zookeeper.quorum=ONAPserverTBD -hbase.zookeeper.property.clientPort=2181 -hbase.zookeeper.znode.parent=/hbase-unsecure - -aai.precheck.cloudinfrastructure.complex.defaults.physicalLocationType=AAIDefault -aai.precheck.cloudinfrastructure.complex.defaults.street1=AAIDefault -aai.precheck.cloudinfrastructure.complex.defaults.city=AAIDefault -aai.precheck.cloudinfrastructure.complex.defaults.state=NJ -aai.precheck.cloudinfrastructure.complex.defaults.postalCode=07748 -aai.precheck.cloudinfrastructure.complex.defaults.country=USA -aai.precheck.cloudinfrastructure.complex.defaults.region=US - -# single primary server -aai.primary.filetransfer.serverlist=ONAPserverTBD -aai.primary.filetransfer.primarycheck=echo:8443/aai/util/echo -aai.primary.filetransfer.pingtimeout=5000 -aai.primary.filetransfer.pingcount=5 - -#rsync properties -aai.rsync.command=rsync -aai.rsync.options.list=-v|-t -aai.rsync.remote.user=aaiadmin -aai.rsync.enabled=y - -#Service Specific Data Values -aai.servicedescription.hostedcomm=HOSTED COMMUNICATIONS -aai.servicedescription.mobility=MOBILITY -aai.servicedescription.vusp=VIRTUAL USP -aai.servicedescription.vvig=vVIGaaS -aai.servicedescription.lrsi=LRSI-OSPF - -aai.notification.current.version=v12 -aai.notificationEvent.default.status=UNPROCESSED -aai.notificationEvent.default.eventType=AAI-EVENT -aai.notificationEvent.default.domain=devINT1 -aai.notificationEvent.default.sourceName=aai -aai.notificationEvent.default.sequenceNumber=0 -aai.notificationEvent.default.severity=NORMAL -aai.notificationEvent.default.version=v12 -# This one lets us enable/disable resource-version checking on updates/deletes -aai.resourceversion.enableflag=true -aai.logging.maxStackTraceEntries=10 -aai.default.api.version=v12 - -# Used by Model-processing code -aai.model.delete.sleep.per.vtx.msec=500 -aai.model.query.resultset.maxcount=50 -aai.model.query.timeout.sec=90 - -# Used by Data Grooming -aai.grooming.default.max.fix=150 -aai.grooming.default.sleep.minutes=7 - -# Used by DupeTool -aai.dupeTool.default.max.fix=25 -aai.dupeTool.default.sleep.minutes=7 - -aai.model.proc.max.levels=50 -aai.edgeTag.proc.max.levels=50 - -# Used by the ForceDelete tool -aai.forceDel.protected.nt.list=cloud-region -aai.forceDel.protected.edge.count=10 -aai.forceDel.protected.descendant.count=10 - -# Used for CTAG-Pool generation -aai.ctagPool.rangeString.vplsPe1=2001-2500 -aai.ctagPool.rangeString.vplsPe2=2501-3000 -aai.ctagPool.rangeString.vpe=3001-3500 - -aai.dmaap.workload.enableEventProcessing=true - -aai.realtime.clients=RO,SDNC,MSO - -aai.server.rebind=g -aai.run.migrations=false -ecm.auth.password.x=OBF:1igd1i9a1jnb1yte1vv11vu91yt81jk71i6o1idt - -aai.jms.enable=false -#limit set for bulk consumer APIS -aai.bulkconsumer.payloadlimit=30 diff --git a/aai-resources/src/test/resources/bundleconfig-local/etc/queryformats/graphson/resource.graphson b/aai-resources/src/test/resources/bundleconfig-local/etc/queryformats/graphson/resource.graphson deleted file mode 100644 index 257916a..0000000 --- a/aai-resources/src/test/resources/bundleconfig-local/etc/queryformats/graphson/resource.graphson +++ /dev/null @@ -1,2 +0,0 @@ -{"id": 386506928,"label": "vertex","properties": {"aai-last-mod-ts": [{"id": "ob632u-6e46nk-5j45","value": 1488308500413}],"aai-uri": [{"id": "ob6712-6e46nk-5lhh","value": "/cloud-infrastructure/cloud-regions/cloud-region/cloud-owner-987654321-9922/cloud-region-id-987654320-9922/tenants/tenant/tenant-987654321-9999/vservers/vserver/vserver-987654321-9999"}],"prov-status": [{"id": "ob651y-6e46nk-1kw5","value": "example-prov-status-val-7367"}],"aai-created-ts": [{"id": "ob62ae-6e46nk-5gqt","value": 1488308500413}],"source-of-truth": [{"id": "ob61w6-6e46nk-5jwl","value": "FitNesse-Test"}],"vserver-selflink": [{"id": "ob65g6-6e46nk-3xfp","value": "example-vserver-selflink-val-7367"}],"aai-node-type": [{"id": "ob61hy-6e46nk-5f5x","value": "vserver"}],"in-maint": [{"id": "ob65ue-6e46nk-20p1","value": false}],"resource-version": [{"id": "ob62om-6e46nk-23ut","value": "1488308500413"}],"vserver-name": [{"id": "ob649i-6e46nk-3u9x","value": "example-vserver-name-val-7367vserver-987654321-9999"}],"vserver-id": [{"id": "ob63va-6e46nk-3sp1","value": "vserver-987654321-9999"}],"last-mod-source-of-truth": [{"id": "ob63h2-6e46nk-5edh","value": "FitNesse-Test"}],"vserver-name2": [{"id": "ob64nq-6e46nk-3vut","value": "example-vserver-name2-val-7367"}],"is-closed-loop-disabled": [{"id": "ob668m-6e46nk-229x","value": false}]}} -{"id": 2461872,"label": "vertex","properties": {"aai-last-mod-ts": [{"id": "21hqu-1grlc-5j45","value": 1467901600}],"in-maint": [{"id": "21i52-1grlc-20p1","value": false}],"resource-version": [{"id": "21ija-1grlc-23ut","value": "1467901600"}],"vserver-name": [{"id": "21ixi-1grlc-3u9x","value": "PerfTest_VServerFix0027TenantPez002701611467901587187Name"}],"aai-created-ts": [{"id": "21jbq-1grlc-5gqt","value": 1467901600}],"vserver-id": [{"id": "21jpy-1grlc-3sp1","value": "PerfTest_VServerFix0027TenantPez002701611467901587187"}],"last-mod-source-of-truth": [{"id": "21k46-1grlc-5edh","value": "MSO"}],"vserver-name2": [{"id": "21kie-1grlc-3vut","value": "PerfTest_VServerFix0027TenantPez002701611467901587187-VM Name2 optional"}],"source-of-truth": [{"id": "21kwm-1grlc-5jwl","value": "MSO"}],"vserver-selflink": [{"id": "21lau-1grlc-3xfp","value": "http://testvserverLink.com/.html?vserv=VserverLink"}],"is-closed-loop-disabled": [{"id": "21lp2-1grlc-229x","value": false}],"aai-node-type": [{"id": "21m3a-1grlc-5f5x","value": "vserver"}],"aai-uri": [{"id": "21m3a-1grlc-5a5x","value": "/vservers/vserver/test1"}]}} diff --git a/aai-resources/src/test/resources/bundleconfig-local/etc/queryformats/resource-format.json b/aai-resources/src/test/resources/bundleconfig-local/etc/queryformats/resource-format.json deleted file mode 100644 index c7e4255..0000000 --- a/aai-resources/src/test/resources/bundleconfig-local/etc/queryformats/resource-format.json +++ /dev/null @@ -1,13 +0,0 @@ -{ - "results": [ - { - "vserver": { - - } - }, - { - "vserver": { - } - } - ] -}
\ No newline at end of file diff --git a/aai-resources/src/test/resources/bundleconfig-local/etc/queryformats/resource_and_url-format.json b/aai-resources/src/test/resources/bundleconfig-local/etc/queryformats/resource_and_url-format.json deleted file mode 100644 index 80d6560..0000000 --- a/aai-resources/src/test/resources/bundleconfig-local/etc/queryformats/resource_and_url-format.json +++ /dev/null @@ -1,16 +0,0 @@ -{ - "results": [ - { - "url" : "/cloud-infrastructure/cloud-regions/cloud-region/cloud-owner-987654321-9922/cloud-region-id-987654321-9922/tenants/tenant/tenant-987654321-9999/vservers/vserver/vserver-987654321-9999", - "vserver": { - - } - }, - { - "url" : "/vservers/vserver/test1", - "vserver": { - - } - } - ] -} diff --git a/aai-resources/src/test/resources/bundleconfig-local/etc/queryformats/simple-format.json b/aai-resources/src/test/resources/bundleconfig-local/etc/queryformats/simple-format.json deleted file mode 100644 index dd34261..0000000 --- a/aai-resources/src/test/resources/bundleconfig-local/etc/queryformats/simple-format.json +++ /dev/null @@ -1,43 +0,0 @@ -{ - "results" : [{ - "id" : "0", - "node-type" : "generic-vnf", - "url" : "urimissing", - "properties" : { - "vnf-name" : "myVnf" - }, - "related-to" : [{ - "node-type" : "vserver", - "id" : "1", - "url" : "urimissing" - }] - } , { - "id" : "1", - "node-type" : "vserver", - "url" : "urimissing", - "properties" : { - "vserver-name" : "myVserver" - }, - "related-to" : [{ - "node-type" : "generic-vnf", - "id" : "0", - "url" : "urimissing" - },{ - "node-type" : "pserver", - "id" : "2", - "url" : "/pservers/pserver/key1" - }] - },{ - "id" : "2", - "node-type" : "pserver", - "url" : "/pservers/pserver/key1", - "properties" : { - "hostname" : "myPserver" - }, - "related-to" : [{ - "node-type" : "vserver", - "id" : "1", - "url" : "urimissing" - }] - }] -}
\ No newline at end of file diff --git a/aai-resources/src/test/resources/edgeLabelMigration.csv b/aai-resources/src/test/resources/edgeLabelMigration.csv deleted file mode 100644 index 53639e5..0000000 --- a/aai-resources/src/test/resources/edgeLabelMigration.csv +++ /dev/null @@ -1,212 +0,0 @@ -from,to,label,direction,multiplicity,contains-other-v,delete-other-v,SVC-INFRA,prevent-delete,new from,new to,new label,new direction,new multiplicity,new contains-other-v,new delete-other-v,new SVC-INFRA,new prevent-delete,new default -allotted-resource,allotted-resource,bindsTo,OUT,ONE2ONE,NONE,NONE,NONE,NONE,allotted-resource,allotted-resource,tosca.relationships.network.BindsTo,OUT,ONE2ONE,NONE,NONE,NONE,NONE,T -allotted-resource,generic-vnf,isPartOf,OUT,MANY2MANY,NONE,NONE,NONE,NONE,allotted-resource,generic-vnf,org.onap.relationships.inventory.PartOf,OUT,MANY2MANY,NONE,NONE,NONE,NONE,T -allotted-resource,instance-group,isMemberOf,OUT,MANY2MANY,NONE,NONE,NONE,NONE,allotted-resource,instance-group,org.onap.relationships.inventory.MemberOf,OUT,MANY2MANY,NONE,NONE,NONE,NONE,T -allotted-resource,l3-network,isPartOf,OUT,MANY2MANY,NONE,NONE,NONE,NONE,allotted-resource,l3-network,org.onap.relationships.inventory.PartOf,OUT,MANY2MANY,NONE,NONE,NONE,NONE,T -allotted-resource,l-interface,uses,OUT,ONE2MANY,NONE,NONE,NONE,NONE,allotted-resource,l-interface,org.onap.relationships.inventory.Uses,OUT,ONE2MANY,NONE,NONE,NONE,NONE,T -allotted-resource,network-policy,uses,OUT,ONE2ONE,NONE,NONE,NONE,NONE,allotted-resource,network-policy,org.onap.relationships.inventory.Uses,OUT,ONE2ONE,NONE,NONE,NONE,NONE,T -allotted-resource,vlan,isPartOf,OUT,MANY2MANY,NONE,NONE,NONE,NONE,allotted-resource,vlan,org.onap.relationships.inventory.PartOf,OUT,MANY2MANY,NONE,NONE,NONE,NONE,T -allotted-resource,vpn-binding,belongsTo,OUT,MANY2MANY,NONE,NONE,NONE,!${direction},allotted-resource,vpn-binding,org.onap.relationships.inventory.BelongsTo,OUT,MANY2MANY,NONE,NONE,NONE,!${direction},T -allotted-resource,tunnel-xconnect,has,OUT,ONE2ONE,${direction},${direction},NONE,NONE,tunnel-xconnect,allotted-resource,org.onap.relationships.inventory.BelongsTo,OUT,ONE2ONE,!${direction},!${direction},NONE,NONE,T -availability-zone,complex,groupsResourcesIn,OUT,MANY2MANY,NONE,NONE,NONE,!${direction},availability-zone,complex,org.onap.relationships.inventory.LocatedIn,OUT,MANY2ONE,NONE,NONE,NONE,!${direction},T -availability-zone,service-capability,supportsServiceCapability,OUT,MANY2MANY,NONE,NONE,NONE,!${direction},availability-zone,service-capability,org.onap.relationships.inventory.AppliesTo,OUT,MANY2MANY,NONE,NONE,NONE,!${direction},T -cloud-region,availability-zone,has,OUT,ONE2MANY,${direction},${direction},NONE,${direction},availability-zone,cloud-region,org.onap.relationships.inventory.BelongsTo,OUT,MANY2ONE,!${direction},!${direction},NONE,NONE,T -cloud-region,complex,locatedIn,OUT,MANY2ONE,NONE,NONE,NONE,!${direction},cloud-region,complex,org.onap.relationships.inventory.LocatedIn,OUT,MANY2ONE,NONE,NONE,NONE,!${direction},T -cloud-region,l3-network,uses,OUT,MANY2MANY,NONE,NONE,NONE,NONE,cloud-region,l3-network,org.onap.relationships.inventory.Uses,OUT,MANY2MANY,NONE,NONE,NONE,NONE,T -cloud-region,zone,isMemberOf,OUT,MANY2ONE,NONE,NONE,NONE,NONE,cloud-region,zone,org.onap.relationships.inventory.LocatedIn,OUT,MANY2ONE,NONE,NONE,NONE,NONE,T -cloud-region,dvs-switch,has,OUT,ONE2MANY,${direction},${direction},NONE,${direction},dvs-switch,cloud-region,org.onap.relationships.inventory.BelongsTo,OUT,MANY2ONE,!${direction},NONE,NONE,!${direction},T -cloud-region,flavor,has,OUT,ONE2MANY,${direction},${direction},NONE,${direction},flavor,cloud-region,org.onap.relationships.inventory.BelongsTo,OUT,MANY2ONE,!${direction},NONE,NONE,!${direction},T -cloud-region,group-assignment,has,OUT,ONE2MANY,${direction},${direction},NONE,${direction},group-assignment,cloud-region,org.onap.relationships.inventory.BelongsTo,OUT,MANY2ONE,!${direction},NONE,NONE,!${direction},T -cloud-region,image,has,OUT,ONE2MANY,${direction},${direction},NONE,${direction},image,cloud-region,org.onap.relationships.inventory.BelongsTo,OUT,MANY2ONE,!${direction},NONE,NONE,!${direction},T -cloud-region,oam-network,has,OUT,ONE2MANY,${direction},${direction},NONE,${direction},oam-network,cloud-region,org.onap.relationships.inventory.BelongsTo,OUT,MANY2ONE,!${direction},NONE,NONE,!${direction},T -cloud-region,snapshot,has,OUT,ONE2MANY,${direction},${direction},NONE,${direction},snapshot,cloud-region,org.onap.relationships.inventory.BelongsTo,OUT,MANY2ONE,!${direction},NONE,NONE,!${direction},T -cloud-region,tenant,has,OUT,ONE2MANY,${direction},${direction},!${direction},${direction},tenant,cloud-region,org.onap.relationships.inventory.BelongsTo,OUT,MANY2ONE,!${direction},NONE,${direction},!${direction},T -cloud-region,vip-ipv4-address-list,hasIpAddress,OUT,ONE2MANY,${direction},${direction},${direction},NONE,vip-ipv4-address-list,cloud-region,org.onap.relationships.inventory.BelongsTo,OUT,MANY2ONE,!${direction},NONE,NONE,!${direction},T -cloud-region,vip-ipv6-address-list,hasIpAddress,OUT,ONE2MANY,${direction},${direction},${direction},NONE,vip-ipv6-address-list,cloud-region,org.onap.relationships.inventory.BelongsTo,OUT,MANY2ONE,!${direction},NONE,NONE,!${direction},T -cloud-region,volume-group,has,OUT,ONE2MANY,${direction},${direction},NONE,${direction},volume-group,cloud-region,org.onap.relationships.inventory.BelongsTo,OUT,MANY2ONE,!${direction},NONE,NONE,!${direction},T -complex,l3-network,usesL3Network,OUT,MANY2MANY,NONE,NONE,${direction},NONE,complex,l3-network,org.onap.relationships.inventory.Uses,OUT,MANY2MANY,NONE,NONE,${direction},NONE,T -complex,ctag-pool,hasCtagPool,OUT,MANY2MANY,${direction},${direction},NONE,NONE,ctag-pool,complex,org.onap.relationships.inventory.BelongsTo,OUT,MANY2ONE,!${direction},!${direction},NONE,NONE,T -configuration,allotted-resource,uses,OUT,ONE2ONE,NONE,${direction},NONE,NONE,configuration,allotted-resource,org.onap.relationships.inventory.Uses,OUT,ONE2ONE,NONE,${direction},NONE,NONE,T -configuration,logical-link,has,OUT,ONE2MANY,NONE,${direction},NONE,NONE,configuration,logical-link,org.onap.relationships.inventory.Uses,OUT,ONE2MANY,NONE,${direction},NONE,NONE,T -configuration,metadatum,owns,OUT,ONE2MANY,${direction},${direction},NONE,NONE,metadatum,configuration,org.onap.relationships.inventory.BelongsTo,OUT,MANY2ONE,!${direction},!${direction},NONE,NONE,T -connector,virtual-data-center,contains,OUT,MANY2MANY,NONE,NONE,NONE,NONE,connector,virtual-data-center,org.onap.relationships.inventory.LocatedIn,OUT,MANY2MANY,NONE,NONE,NONE,NONE,T -connector,metadatum,hasMetaData,OUT,MANY2MANY,${direction},${direction},NONE,NONE,metadatum,connector,org.onap.relationships.inventory.BelongsTo,OUT,MANY2ONE,!${direction},!${direction},NONE,NONE,T -constrained-element-set,element-choice-set,uses,OUT,ONE2MANY,${direction},${direction},NONE,NONE,element-choice-set,constrained-element-set,org.onap.relationships.inventory.BelongsTo,OUT,MANY2ONE,!${direction},!${direction},NONE,NONE,T -ctag-pool,availability-zone,supportsAvailabilityZone,OUT,MANY2MANY,NONE,NONE,NONE,!${direction},ctag-pool,availability-zone,org.onap.relationships.inventory.AppliesTo,OUT,MANY2MANY,NONE,NONE,NONE,!${direction},T -customer,service-subscription,subscribesTo,OUT,MANY2MANY,${direction},${direction},!${direction},NONE,service-subscription,customer,org.onap.relationships.inventory.BelongsTo,OUT,MANY2ONE,!${direction},!${direction},${direction},NONE,T -dvs-switch,availability-zone,existsIn,OUT,MANY2MANY,NONE,NONE,NONE,!${direction},dvs-switch,availability-zone,org.onap.relationships.inventory.AppliesTo,OUT,MANY2MANY,NONE,NONE,NONE,!${direction},T -element-choice-set,model-element,has,OUT,ONE2MANY,${direction},${direction},NONE,NONE,model-element,element-choice-set,org.onap.relationships.inventory.BelongsTo,OUT,MANY2ONE,!${direction},!${direction},NONE,NONE,T -generic-vnf,entitlement,has,OUT,ONE2MANY,${direction},${direction},NONE,NONE,entitlement,generic-vnf,org.onap.relationships.inventory.BelongsTo,OUT,MANY2ONE,!${direction},!${direction},NONE,NONE,T -generic-vnf,availability-zone,hasAvailabilityZone,OUT,MANY2MANY,NONE,NONE,${direction},!${direction},generic-vnf,availability-zone,org.onap.relationships.inventory.Uses,OUT,MANY2MANY,NONE,NONE,${direction},!${direction},T -generic-vnf,complex,locatedIn,OUT,MANY2MANY,NONE,NONE,NONE,!${direction},generic-vnf,complex,org.onap.relationships.inventory.LocatedIn,OUT,MANY2MANY,NONE,NONE,NONE,!${direction},T -generic-vnf,configuration,uses,OUT,ONE2MANY,NONE,${direction},NONE,NONE,generic-vnf,configuration,org.onap.relationships.inventory.Uses,OUT,ONE2MANY,NONE,${direction},NONE,NONE,T -generic-vnf,ctag-pool,usesCtagPool,OUT,MANY2MANY,NONE,NONE,NONE,NONE,generic-vnf,ctag-pool,org.onap.relationships.inventory.Uses,OUT,MANY2MANY,NONE,NONE,NONE,NONE,T -generic-vnf,instance-group,isMemberOf,OUT,MANY2MANY,NONE,NONE,NONE,NONE,generic-vnf,instance-group,org.onap.relationships.inventory.MemberOf,OUT,MANY2MANY,NONE,NONE,NONE,NONE,T -generic-vnf,ipsec-configuration,uses,OUT,MANY2ONE,NONE,NONE,NONE,NONE,generic-vnf,ipsec-configuration,org.onap.relationships.inventory.Uses,OUT,MANY2ONE,NONE,NONE,NONE,NONE,T -generic-vnf,l3-network,usesL3Network,OUT,MANY2MANY,NONE,NONE,${direction},NONE,generic-vnf,l3-network,org.onap.relationships.inventory.Uses,OUT,MANY2MANY,NONE,NONE,${direction},NONE,T -generic-vnf,license-key-resource,uses,OUT,MANY2MANY,NONE,NONE,NONE,!${direction},generic-vnf,license-key-resource,org.onap.relationships.inventory.Uses,OUT,MANY2MANY,NONE,NONE,NONE,!${direction},T -generic-vnf,pnf,hostedOn,OUT,MANY2MANY,NONE,NONE,NONE,NONE,generic-vnf,pnf,tosca.relationships.HostedOn,OUT,MANY2MANY,NONE,NONE,NONE,NONE,T -generic-vnf,pserver,runsOnPserver,OUT,MANY2MANY,NONE,NONE,${direction},!${direction},generic-vnf,pserver,tosca.relationships.HostedOn,OUT,MANY2MANY,NONE,NONE,${direction},!${direction},T -generic-vnf,vnfc,uses,OUT,ONE2MANY,NONE,${direction},${direction},NONE,vnfc,generic-vnf,org.onap.relationships.inventory.BelongsTo,OUT,MANY2ONE,NONE,!${direction},!${direction},NONE,T -generic-vnf,vnf-image,usesVnfImage,OUT,MANY2ONE,NONE,NONE,${direction},!${direction},generic-vnf,vnf-image,org.onap.relationships.inventory.Uses,OUT,MANY2ONE,NONE,NONE,${direction},!${direction},T -generic-vnf,volume-group,uses,OUT,ONE2MANY,NONE,NONE,${direction},NONE,generic-vnf,volume-group,org.onap.relationships.inventory.DependsOn,OUT,ONE2MANY,NONE,NONE,${direction},NONE,T -generic-vnf,vserver,runsOnVserver,OUT,ONE2MANY,NONE,NONE,${direction},NONE,generic-vnf,vserver,tosca.relationships.HostedOn,OUT,ONE2MANY,NONE,NONE,${direction},NONE,T -generic-vnf,lag-interface,hasLAGInterface,OUT,MANY2MANY,${direction},${direction},${direction},NONE,lag-interface,generic-vnf,org.onap.relationships.inventory.BelongsTo,OUT,MANY2ONE,!${direction},!${direction},!${direction},NONE,T -generic-vnf,license,has,OUT,ONE2MANY,${direction},${direction},NONE,NONE,license,generic-vnf,org.onap.relationships.inventory.BelongsTo,OUT,MANY2ONE,!${direction},!${direction},NONE,NONE,T -generic-vnf,l-interface,hasLInterface,OUT,MANY2MANY,${direction},${direction},${direction},NONE,l-interface,generic-vnf,org.onap.relationships.inventory.BelongsTo,OUT,MANY2ONE,!${direction},!${direction},!${direction},NONE,T -generic-vnf,network-profile,hasNetworkProfile,OUT,MANY2MANY,NONE,NONE,NONE,NONE,network-profile,generic-vnf,org.onap.relationships.inventory.AppliesTo,OUT,MANY2MANY,NONE,NONE,NONE,NONE,T -generic-vnf,service-instance,hasInstance,OUT,MANY2MANY,NONE,NONE,${direction},NONE,service-instance,generic-vnf,org.onap.relationships.inventory.ComposedOf,OUT,ONE2MANY,NONE,NONE,!${direction},NONE,T -generic-vnf,site-pair-set,hasSitePairSet,OUT,MANY2MANY,NONE,NONE,NONE,NONE,site-pair-set,generic-vnf,org.onap.relationships.inventory.AppliesTo,OUT,MANY2MANY,NONE,NONE,NONE,NONE,T -generic-vnf,vf-module,has,OUT,ONE2MANY,${direction},${direction},${direction},NONE,vf-module,generic-vnf,org.onap.relationships.inventory.BelongsTo,OUT,MANY2ONE,!${direction},!${direction},!${direction},NONE,T -group-assignment,pserver,has,OUT,ONE2MANY,NONE,NONE,NONE,!${direction},pserver,group-assignment,org.onap.relationships.inventory.MemberOf,OUT,MANY2ONE,NONE,NONE,NONE,${direction},T -group-assignment,tenant,has,OUT,MANY2MANY,NONE,NONE,NONE,NONE,tenant,group-assignment,org.onap.relationships.inventory.MemberOf,OUT,MANY2MANY,NONE,NONE,NONE,NONE,T -image,metadatum,hasMetaDatum,OUT,MANY2MANY,${direction},${direction},NONE,NONE,metadatum,image,org.onap.relationships.inventory.BelongsTo,OUT,MANY2ONE,!${direction},!${direction},NONE,NONE,T -instance-group,model,targets,OUT,MANY2MANY,NONE,NONE,NONE,!${direction},instance-group,model,org.onap.relationships.inventory.Targets,OUT,MANY2MANY,NONE,NONE,NONE,!${direction},T -ipsec-configuration,vig-server,hasVigServer,OUT,ONE2MANY,${direction},${direction},NONE,NONE,vig-server,ipsec-configuration,org.onap.relationships.inventory.BelongsTo,OUT,MANY2ONE,!${direction},!${direction},NONE,NONE,T -l3-interface-ipv4-address-list,instance-group,isMemberOf,OUT,MANY2MANY,NONE,NONE,NONE,NONE,l3-interface-ipv4-address-list,instance-group,org.onap.relationships.inventory.network.MemberOf,OUT,MANY2MANY,NONE,NONE,NONE,NONE,T -l3-interface-ipv4-address-list,l3-network,isMemberOf,OUT,MANY2MANY,NONE,NONE,${direction},NONE,l3-interface-ipv4-address-list,l3-network,org.onap.relationships.inventory.network.MemberOf,OUT,MANY2MANY,NONE,NONE,${direction},NONE,T -l3-interface-ipv4-address-list,subnet,isMemberOf,OUT,MANY2MANY,NONE,NONE,${direction},!${direction},l3-interface-ipv4-address-list,subnet,org.onap.relationships.inventory.network.MemberOf,OUT,MANY2MANY,NONE,NONE,${direction},!${direction},T -l3-interface-ipv6-address-list,instance-group,isMemberOf,OUT,MANY2MANY,NONE,NONE,NONE,NONE,l3-interface-ipv6-address-list,instance-group,org.onap.relationships.inventory.network.MemberOf,OUT,MANY2MANY,NONE,NONE,NONE,NONE,T -l3-interface-ipv6-address-list,l3-network,isMemberOf,OUT,MANY2MANY,NONE,NONE,${direction},NONE,l3-interface-ipv6-address-list,l3-network,org.onap.relationships.inventory.network.MemberOf,OUT,MANY2MANY,NONE,NONE,${direction},NONE,T -l3-interface-ipv6-address-list,subnet,isMemberOf,OUT,MANY2MANY,NONE,NONE,${direction},!${direction},l3-interface-ipv6-address-list,subnet,org.onap.relationships.inventory.network.MemberOf,OUT,MANY2MANY,NONE,NONE,${direction},!${direction},T -l3-network,ctag-assignment,hasCtagAssignment,OUT,MANY2MANY,${direction},${direction},${direction},NONE,ctag-assignment,l3-network,org.onap.relationships.inventory.BelongsTo,OUT,MANY2ONE,!${direction},!${direction},!${direction},NONE,T -l3-network,instance-group,memberOf,OUT,MANY2MANY,NONE,NONE,NONE,NONE,l3-network,instance-group,org.onap.relationships.inventory.MemberOf,OUT,MANY2MANY,NONE,NONE,NONE,NONE,T -l3-network,network-policy,uses,OUT,MANY2MANY,NONE,NONE,${direction},NONE,l3-network,network-policy,org.onap.relationships.inventory.Uses,OUT,MANY2MANY,NONE,NONE,${direction},NONE,T -l3-network,route-table-reference,uses,OUT,MANY2MANY,NONE,NONE,NONE,NONE,l3-network,route-table-reference,org.onap.relationships.inventory.Uses,OUT,MANY2MANY,NONE,NONE,NONE,NONE,T -l3-network,vpn-binding,usesVpnBinding,OUT,MANY2MANY,NONE,NONE,NONE,!${direction},l3-network,vpn-binding,org.onap.relationships.inventory.Uses,OUT,MANY2MANY,NONE,NONE,NONE,!${direction},T -l3-network,segmentation-assignment,has,OUT,ONE2MANY,${direction},${direction},NONE,NONE,segmentation-assignment,l3-network,org.onap.relationships.inventory.BelongsTo,OUT,MANY2ONE,!${direction},!${direction},NONE,NONE,T -l3-network,service-instance,hasInstance,OUT,MANY2MANY,NONE,NONE,!${direction},NONE,service-instance,l3-network,org.onap.relationships.inventory.ComposedOf,OUT,ONE2MANY,NONE,NONE,${direction},NONE,T -l3-network,subnet,hasSubnet,OUT,MANY2MANY,${direction},${direction},!${direction},NONE,subnet,l3-network,org.onap.relationships.inventory.BelongsTo,OUT,MANY2ONE,!${direction},!${direction},${direction},NONE,T -lag-interface,lag-link,usesLAGLink,OUT,MANY2MANY,NONE,${direction},${direction},NONE,lag-interface,lag-link,tosca.relationships.network.LinksTo,OUT,MANY2MANY,NONE,${direction},${direction},NONE,T -lag-interface,logical-link,uses,OUT,MANY2MANY,NONE,${direction},${direction},NONE,lag-interface,logical-link,org.onap.relationships.inventory.Uses,OUT,MANY2MANY,NONE,${direction},${direction},NONE,T -lag-interface,p-interface,usesPInterface,OUT,MANY2MANY,NONE,NONE,${direction},NONE,lag-interface,p-interface,org.onap.relationships.inventory.Uses,OUT,MANY2MANY,NONE,NONE,${direction},NONE,T -lag-interface,l-interface,hasLInterface,OUT,MANY2MANY,${direction},${direction},${direction},NONE,l-interface,lag-interface,org.onap.relationships.inventory.BelongsTo,OUT,MANY2ONE,!${direction},!${direction},!${direction},NONE,T -line-of-business,generic-vnf,realizedBy,OUT,MANY2MANY,NONE,NONE,NONE,NONE,line-of-business,generic-vnf,org.onap.relationships.inventory.Uses,OUT,MANY2MANY,NONE,NONE,NONE,NONE,T -l-interface,l3-interface-ipv4-address-list,hasIpAddress,OUT,MANY2MANY,${direction},${direction},${direction},NONE,l3-interface-ipv4-address-list,l-interface,org.onap.relationships.inventory.BelongsTo,OUT,MANY2ONE,!${direction},!${direction},!${direction},NONE,T -l-interface,l3-interface-ipv6-address-list,hasIpAddress,OUT,MANY2MANY,${direction},${direction},${direction},NONE,l3-interface-ipv6-address-list,l-interface,org.onap.relationships.inventory.BelongsTo,OUT,MANY2ONE,!${direction},!${direction},!${direction},NONE,T -l-interface,instance-group,isMemberOf,OUT,MANY2MANY,NONE,NONE,NONE,NONE,l-interface,instance-group,org.onap.relationships.inventory.MemberOf,OUT,MANY2MANY,NONE,NONE,NONE,NONE,T -l-interface,l-interface,has,OUT,ONE2MANY,${direction},${direction},${direction},NONE,l-interface,l-interface,org.onap.relationships.inventory.BelongsTo,OUT,MANY2ONE,!${direction},!${direction},!${direction},NONE,T -l-interface,logical-link,usesLogicalLink,OUT,MANY2MANY,NONE,${direction},${direction},NONE,l-interface,logical-link,tosca.relationships.network.LinksTo,OUT,MANY2ONE,NONE,${direction},${direction},NONE,T -l-interface,logical-link,sourceLInterface,OUT,MANY2MANY,NONE,${direction},${direction},NONE,logical-link,l-interface,org.onap.relationships.inventory.Source,OUT,ONE2MANY,NONE,!${direction},!${direction},NONE,F -l-interface,logical-link,targetLInterface,OUT,MANY2MANY,NONE,${direction},${direction},NONE,logical-link,l-interface,org.onap.relationships.inventory.Destination,OUT,ONE2MANY,NONE,!${direction},!${direction},NONE,F -l-interface,sriov-vf,has,OUT,ONE2ONE,${direction},${direction},NONE,NONE,sriov-vf,l-interface,org.onap.relationships.inventory.BelongsTo,OUT,ONE2ONE,!${direction},!${direction},NONE,NONE,T -l-interface,vlan,hasVlan,OUT,MANY2MANY,${direction},${direction},NONE,NONE,vlan,l-interface,tosca.relationships.network.LinksTo,OUT,MANY2ONE,!${direction},!${direction},NONE,NONE,T -logical-link,cloud-region,existsIn,OUT,MANY2MANY,NONE,NONE,NONE,NONE,logical-link,cloud-region,org.onap.relationships.inventory.LocatedIn,OUT,MANY2MANY,NONE,NONE,NONE,NONE,T -logical-link,generic-vnf,bridgedTo,OUT,MANY2MANY,NONE,NONE,NONE,NONE,logical-link,generic-vnf,org.onap.relationships.inventory.BridgedTo,OUT,MANY2MANY,NONE,NONE,NONE,NONE,T -logical-link,lag-link,usesLAGLink,OUT,MANY2MANY,NONE,NONE,${direction},NONE,logical-link,lag-link,org.onap.relationships.inventory.Uses,OUT,MANY2MANY,NONE,NONE,${direction},NONE,T -logical-link,logical-link,uses,OUT,ONE2MANY,NONE,NONE,${direction},NONE,logical-link,logical-link,org.onap.relationships.inventory.Uses,OUT,ONE2MANY,NONE,NONE,${direction},NONE,T -logical-link,pnf,bridgedTo,OUT,MANY2MANY,NONE,NONE,NONE,NONE,logical-link,pnf,org.onap.relationships.inventory.BridgedTo,OUT,MANY2MANY,NONE,NONE,NONE,NONE,T -logical-link,pserver,bridgedTo,OUT,MANY2MANY,NONE,NONE,NONE,!${direction},logical-link,pserver,org.onap.relationships.inventory.BridgedTo,OUT,MANY2MANY,NONE,NONE,NONE,!${direction},T -logical-link,vpn-binding,uses,OUT,MANY2MANY,NONE,NONE,NONE,!${direction},logical-link,vpn-binding,org.onap.relationships.inventory.Uses,OUT,MANY2MANY,NONE,NONE,NONE,!${direction},T -model,model-ver,has,OUT,ONE2MANY,${direction},${direction},NONE,NONE,model-ver,model,org.onap.relationships.inventory.BelongsTo,OUT,MANY2ONE,!${direction},!${direction},NONE,NONE,T -model-constraint,constrained-element-set,uses,OUT,ONE2MANY,${direction},${direction},NONE,NONE,constrained-element-set,model-constraint,org.onap.relationships.inventory.BelongsTo,OUT,MANY2ONE,!${direction},!${direction},NONE,NONE,T -model-element,constrained-element-set,connectsTo,OUT,ONE2MANY,${direction},${direction},NONE,NONE,constrained-element-set,model-element,org.onap.relationships.inventory.BelongsTo,OUT,MANY2ONE,!${direction},!${direction},NONE,NONE,T -model-element,model-constraint,uses,OUT,ONE2MANY,${direction},${direction},NONE,NONE,model-constraint,model-element,org.onap.relationships.inventory.BelongsTo,OUT,MANY2ONE,!${direction},!${direction},NONE,NONE,T -model-element,model-element,connectsTo,OUT,ONE2MANY,${direction},${direction},NONE,NONE,model-element,model-element,org.onap.relationships.inventory.BelongsTo,OUT,MANY2ONE,!${direction},!${direction},NONE,NONE,T -model-element,model-ver,isA,OUT,MANY2ONE,NONE,NONE,NONE,!${direction},model-element,model-ver,org.onap.relationships.inventory.IsA,OUT,MANY2ONE,NONE,NONE,NONE,!${direction},T -model-ver,metadatum,hasMetaDatum,OUT,ONE2MANY,${direction},${direction},NONE,NONE,metadatum,model-ver,org.onap.relationships.inventory.BelongsTo,OUT,MANY2ONE,!${direction},!${direction},NONE,NONE,T -model-ver,model-element,startsWith,OUT,ONE2MANY,${direction},${direction},NONE,NONE,model-element,model-ver,org.onap.relationships.inventory.BelongsTo,OUT,MANY2ONE,!${direction},!${direction},NONE,NONE,T -named-query,model,relatedTo,OUT,ONE2MANY,NONE,NONE,NONE,!${direction},named-query,model,org.onap.relationships.inventory.AppliesTo,OUT,ONE2MANY,NONE,NONE,NONE,!${direction},T -named-query,named-query-element,startsWith,OUT,ONE2ONE,${direction},${direction},NONE,NONE,named-query-element,named-query,org.onap.relationships.inventory.BelongsTo,OUT,ONE2ONE,!${direction},!${direction},NONE,NONE,T -named-query-element,model,isA,OUT,MANY2ONE,NONE,NONE,NONE,!${direction},named-query-element,model,org.onap.relationships.inventory.IsA,OUT,MANY2ONE,NONE,NONE,NONE,!${direction},T -named-query-element,named-query-element,connectsTo,OUT,MANY2MANY,${direction},${direction},NONE,NONE,named-query-element,named-query-element,org.onap.relationships.inventory.BelongsTo,OUT,MANY2ONE,!${direction},!${direction},NONE,NONE,T -named-query-element,property-constraint,uses,OUT,ONE2MANY,${direction},${direction},NONE,NONE,property-constraint,named-query-element,org.onap.relationships.inventory.BelongsTo,OUT,MANY2ONE,!${direction},!${direction},NONE,NONE,T -named-query-element,related-lookup,uses,OUT,ONE2MANY,${direction},${direction},NONE,NONE,related-lookup,named-query-element,org.onap.relationships.inventory.BelongsTo,OUT,MANY2ONE,!${direction},!${direction},NONE,NONE,T -newvce,l-interface,hasLInterface,OUT,MANY2MANY,${direction},${direction},NONE,NONE,l-interface,newvce,org.onap.relationships.inventory.BelongsTo,OUT,MANY2ONE,!${direction},!${direction},NONE,NONE,T -oam-network,complex,definedFor,OUT,MANY2MANY,NONE,NONE,NONE,!${direction},oam-network,complex,org.onap.relationships.inventory.AppliesTo,OUT,MANY2MANY,NONE,NONE,NONE,!${direction},T -oam-network,service-capability,supportsServiceCapability,OUT,MANY2MANY,NONE,NONE,NONE,!${direction},oam-network,service-capability,org.onap.relationships.inventory.AppliesTo,OUT,MANY2MANY,NONE,NONE,NONE,!${direction},T -operational-environment,operational-environment,managedBy,OUT,ONE2ONE,NONE,NONE,NONE,NONE,operational-environment,operational-environment,org.onap.relationships.inventory.Uses,OUT,ONE2ONE,NONE,NONE,NONE,NONE,T -owning-entity,service-instance,owns,OUT,ONE2MANY,NONE,NONE,NONE,NONE,service-instance,owning-entity,org.onap.relationships.inventory.BelongsTo,OUT,MANY2ONE,NONE,NONE,NONE,NONE,T -p-interface,l-interface,hasLInterface,OUT,MANY2MANY,${direction},${direction},${direction},NONE,l-interface,p-interface,tosca.relationships.network.BindsTo,OUT,MANY2ONE,!${direction},!${direction},!${direction},NONE,T -p-interface,logical-link,usesLogicalLink,OUT,MANY2ONE,NONE,NONE,${direction},NONE,p-interface,logical-link,tosca.relationships.network.LinksTo,OUT,MANY2ONE,NONE,NONE,${direction},NONE,T -p-interface,physical-link,usesPhysicalLink,OUT,MANY2MANY,NONE,${direction},NONE,NONE,p-interface,physical-link,tosca.relationships.network.LinksTo,OUT,MANY2ONE,NONE,${direction},NONE,NONE,T -p-interface,sriov-pf,has,OUT,ONE2ONE,${direction},${direction},NONE,NONE,sriov-pf,p-interface,org.onap.relationships.inventory.BelongsTo,OUT,ONE2ONE,!${direction},!${direction},NONE,NONE,T -platform,generic-vnf,uses,OUT,MANY2MANY,NONE,NONE,NONE,NONE,platform,generic-vnf,org.onap.relationships.inventory.Uses,OUT,MANY2MANY,NONE,NONE,NONE,NONE,T -pnf,lag-interface,has,OUT,ONE2MANY,${direction},${direction},${direction},NONE,lag-interface,pnf,tosca.relationships.network.BindsTo,OUT,MANY2ONE,!${direction},!${direction},!${direction},NONE,T -pnf,p-interface,hasPinterface,OUT,MANY2MANY,${direction},${direction},${direction},NONE,p-interface,pnf,tosca.relationships.network.BindsTo,OUT,MANY2ONE,!${direction},!${direction},!${direction},NONE,T -pnf,complex,locatedIn,OUT,MANY2ONE,NONE,NONE,NONE,!${direction},pnf,complex,org.onap.relationships.inventory.LocatedIn,OUT,MANY2ONE,NONE,NONE,NONE,!${direction},T -pnf,instance-group,isMemberOf,OUT,MANY2MANY,NONE,NONE,NONE,NONE,pnf,instance-group,org.onap.relationships.inventory.MemberOf,OUT,MANY2MANY,NONE,NONE,NONE,NONE,T -pnf,zone,isMemberOf,OUT,MANY2ONE,NONE,NONE,NONE,NONE,pnf,zone,org.onap.relationships.inventory.LocatedIn,OUT,MANY2ONE,NONE,NONE,NONE,NONE,T -port-group,cvlan-tag,hasCTag,OUT,MANY2MANY,${direction},${direction},${direction},NONE,cvlan-tag,port-group,org.onap.relationships.inventory.BelongsTo,OUT,MANY2ONE,!${direction},!${direction},!${direction},NONE,T -project,service-instance,created,OUT,ONE2MANY,NONE,NONE,NONE,NONE,project,service-instance,org.onap.relationships.inventory.Uses,OUT,ONE2MANY,NONE,NONE,NONE,NONE,T -pserver,lag-interface,hasLAGInterface,OUT,MANY2MANY,${direction},${direction},${direction},NONE,lag-interface,pserver,tosca.relationships.network.BindsTo,OUT,MANY2ONE,!${direction},!${direction},!${direction},NONE,T -pserver,p-interface,hasPinterface,OUT,MANY2MANY,${direction},${direction},${direction},NONE,p-interface,pserver,tosca.relationships.network.BindsTo,OUT,MANY2ONE,!${direction},!${direction},!${direction},NONE,T -pserver,availability-zone,existsIn,OUT,MANY2ONE,NONE,NONE,${direction},!${direction},pserver,availability-zone,org.onap.relationships.inventory.MemberOf,OUT,MANY2ONE,NONE,NONE,${direction},!${direction},T -pserver,cloud-region,locatedIn,OUT,MANY2ONE,NONE,NONE,${direction},NONE,pserver,cloud-region,org.onap.relationships.inventory.LocatedIn,OUT,MANY2ONE,NONE,NONE,${direction},NONE,T -pserver,complex,locatedIn,OUT,MANY2ONE,NONE,NONE,${direction},!${direction},pserver,complex,org.onap.relationships.inventory.LocatedIn,OUT,MANY2ONE,NONE,NONE,${direction},!${direction},T -pserver,zone,isMemberOf,OUT,MANY2ONE,NONE,NONE,NONE,NONE,pserver,zone,org.onap.relationships.inventory.LocatedIn,OUT,MANY2ONE,NONE,NONE,NONE,NONE,T -routing-instance,site-pair,hasSitePair,OUT,MANY2MANY,${direction},${direction},NONE,NONE,site-pair,routing-instance,org.onap.relationships.inventory.BelongsTo,OUT,MANY2ONE,!${direction},!${direction},NONE,NONE,T -service-instance,allotted-resource,has,OUT,MANY2MANY,${direction},${direction},NONE,NONE,allotted-resource,service-instance,org.onap.relationships.inventory.BelongsTo,OUT,MANY2ONE,!${direction},!${direction},NONE,NONE,T -service-instance,metadatum,hasMetaData,OUT,MANY2MANY,${direction},${direction},NONE,NONE,metadatum,service-instance,org.onap.relationships.inventory.BelongsTo,OUT,MANY2ONE,!${direction},!${direction},NONE,NONE,T -service-instance,allotted-resource,uses,OUT,MANY2MANY,NONE,NONE,NONE,NONE,service-instance,allotted-resource,org.onap.relationships.inventory.Uses,OUT,MANY2MANY,NONE,NONE,NONE,NONE,T -service-instance,configuration,has,OUT,ONE2MANY,NONE,NONE,NONE,NONE,service-instance,configuration,org.onap.relationships.inventory.Uses,OUT,ONE2MANY,NONE,NONE,NONE,NONE,T -service-instance,connector,uses,OUT,MANY2MANY,NONE,NONE,NONE,NONE,service-instance,connector,org.onap.relationships.inventory.Uses,OUT,MANY2MANY,NONE,NONE,NONE,NONE,T -service-instance,ctag-assignment,uses,OUT,ONE2MANY,NONE,NONE,NONE,NONE,service-instance,ctag-assignment,org.onap.relationships.inventory.Uses,OUT,ONE2MANY,NONE,NONE,NONE,NONE,T -service-instance,cvlan-tag,hasIPAGFacingVLAN,OUT,MANY2MANY,NONE,NONE,NONE,NONE,service-instance,cvlan-tag,org.onap.relationships.inventory.ComposedOf,OUT,MANY2MANY,NONE,NONE,NONE,NONE,T -service-instance,instance-group,isMemberOf,OUT,MANY2MANY,NONE,NONE,NONE,NONE,service-instance,instance-group,org.onap.relationships.inventory.MemberOf,OUT,MANY2MANY,NONE,NONE,NONE,NONE,T -service-instance,logical-link,uses,OUT,MANY2MANY,NONE,${direction},NONE,NONE,service-instance,logical-link,org.onap.relationships.inventory.Uses,OUT,ONE2MANY,NONE,${direction},NONE,NONE,T -service-instance,pnf,uses,OUT,ONE2MANY,NONE,NONE,NONE,NONE,service-instance,pnf,org.onap.relationships.inventory.ComposedOf,OUT,ONE2MANY,NONE,NONE,NONE,NONE,T -service-instance,service-instance,dependsOn,OUT,ONE2MANY,NONE,NONE,NONE,NONE,service-instance,service-instance,org.onap.relationships.inventory.ComposedOf,OUT,ONE2MANY,NONE,NONE,NONE,NONE,T -service-instance,vlan,dependsOn,OUT,ONE2MANY,NONE,NONE,NONE,NONE,service-instance,vlan,org.onap.relationships.inventory.ComposedOf,OUT,ONE2MANY,NONE,NONE,NONE,NONE,T -service-instance,zone,locatedIn,OUT,MANY2ONE,NONE,NONE,${direction},NONE,service-instance,zone,org.onap.relationships.inventory.LocatedIn,OUT,MANY2ONE,NONE,NONE,${direction},NONE,T -service-subscription,service-instance,hasInstance,OUT,MANY2MANY,${direction},${direction},!${direction},NONE,service-instance,service-subscription,org.onap.relationships.inventory.BelongsTo,OUT,MANY2ONE,!${direction},!${direction},${direction},NONE,T -site-pair,class-of-service,hasClassOfService,OUT,MANY2MANY,${direction},${direction},NONE,NONE,class-of-service,site-pair,org.onap.relationships.inventory.BelongsTo,OUT,MANY2ONE,!${direction},!${direction},NONE,NONE,T -site-pair-set,routing-instance,hasRoutingInstance,OUT,MANY2MANY,${direction},${direction},NONE,NONE,routing-instance,site-pair-set,org.onap.relationships.inventory.BelongsTo,OUT,MANY2ONE,!${direction},!${direction},NONE,NONE,T -sriov-vf,sriov-pf,uses,OUT,MANY2ONE,NONE,NONE,NONE,NONE,sriov-vf,sriov-pf,org.onap.relationships.inventory.Uses,OUT,MANY2ONE,NONE,NONE,NONE,NONE,T -subnet,host-route,has,OUT,ONE2MANY,${direction},${direction},NONE,NONE,host-route,subnet,org.onap.relationships.inventory.BelongsTo,OUT,MANY2ONE,!${direction},!${direction},NONE,NONE,T -tenant,service-subscription,relatedTo,OUT,MANY2MANY,NONE,NONE,NONE,NONE,service-subscription,tenant,org.onap.relationships.inventory.Uses,OUT,MANY2MANY,NONE,NONE,NONE,NONE,T -tenant,l3-network,usesL3Network,OUT,MANY2MANY,NONE,NONE,NONE,NONE,tenant,l3-network,org.onap.relationships.inventory.Uses,OUT,MANY2MANY,NONE,NONE,NONE,NONE,T -tenant,vserver,owns,OUT,ONE2MANY,${direction},${direction},!${direction},${direction},vserver,tenant,org.onap.relationships.inventory.BelongsTo,OUT,MANY2ONE,!${direction},NONE,${direction},!${direction},T -vce,entitlement,has,OUT,ONE2MANY,${direction},${direction},NONE,NONE,entitlement,vce,org.onap.relationships.inventory.BelongsTo,OUT,MANY2ONE,!${direction},!${direction},NONE,NONE,T -vce,license,has,OUT,ONE2MANY,${direction},${direction},NONE,NONE,license,vce,org.onap.relationships.inventory.BelongsTo,OUT,MANY2ONE,!${direction},!${direction},NONE,NONE,T -vce,port-group,hasPortGroup,OUT,MANY2MANY,${direction},${direction},${direction},NONE,port-group,vce,org.onap.relationships.inventory.BelongsTo,OUT,MANY2ONE,!${direction},!${direction},!${direction},NONE,T -vce,service-instance,hasServiceInstance,OUT,MANY2MANY,NONE,NONE,!${direction},NONE,service-instance,vce,org.onap.relationships.inventory.ComposedOf,OUT,ONE2MANY,NONE,NONE,${direction},NONE,T -vce,availability-zone,hasAvailabilityZone,OUT,MANY2MANY,NONE,NONE,NONE,!${direction},vce,availability-zone,org.onap.relationships.inventory.Uses,OUT,MANY2MANY,NONE,NONE,NONE,!${direction},T -vce,complex,locatedIn,OUT,MANY2MANY,NONE,NONE,${direction},!${direction},vce,complex,org.onap.relationships.inventory.LocatedIn,OUT,MANY2MANY,NONE,NONE,${direction},!${direction},T -vce,vserver,runsOnVserver,OUT,MANY2MANY,NONE,NONE,${direction},NONE,vce,vserver,tosca.relationships.HostedOn,OUT,ONE2MANY,NONE,NONE,${direction},NONE,T -vf-module,l3-network,uses,OUT,MANY2MANY,NONE,NONE,${direction},NONE,vf-module,l3-network,org.onap.relationships.inventory.DependsOn,OUT,MANY2MANY,NONE,NONE,${direction},NONE,T -vf-module,vnfc,uses,OUT,ONE2MANY,NONE,${direction},${direction},${direction},vf-module,vnfc,org.onap.relationships.inventory.Uses,OUT,ONE2MANY,NONE,NONE,${direction},${direction},T -vf-module,volume-group,uses,OUT,ONE2ONE,NONE,NONE,${direction},NONE,vf-module,volume-group,org.onap.relationships.inventory.Uses,OUT,ONE2ONE,NONE,NONE,${direction},NONE,T -vip-ipv4-address-list,instance-group,isMemberOf,OUT,MANY2MANY,NONE,NONE,NONE,NONE,vip-ipv4-address-list,instance-group,org.onap.relationships.inventory.MemberOf,OUT,MANY2MANY,NONE,NONE,NONE,NONE,T -vip-ipv4-address-list,subnet,isMemberOf,OUT,MANY2MANY,NONE,NONE,${direction},!${direction},vip-ipv4-address-list,subnet,org.onap.relationships.inventory.MemberOf,OUT,MANY2MANY,NONE,NONE,NONE,!${direction},T -vip-ipv6-address-list,instance-group,isMemberOf,OUT,MANY2MANY,NONE,NONE,NONE,NONE,vip-ipv6-address-list,instance-group,org.onap.relationships.inventory.MemberOf,OUT,MANY2MANY,NONE,NONE,NONE,NONE,T -vip-ipv6-address-list,subnet,isMemberOf,OUT,MANY2MANY,NONE,NONE,${direction},!${direction},vip-ipv6-address-list,subnet,org.onap.relationships.inventory.MemberOf,OUT,MANY2MANY,NONE,NONE,NONE,!${direction},T -virtual-data-center,generic-vnf,hasVNF,OUT,MANY2MANY,NONE,NONE,!${direction},NONE,generic-vnf,virtual-data-center,org.onap.relationships.inventory.LocatedIn,OUT,MANY2MANY,NONE,NONE,${direction},NONE,T -virtual-data-center,logical-link,contains,OUT,MANY2MANY,NONE,NONE,NONE,NONE,logical-link,virtual-data-center,org.onap.relationships.inventory.LocatedIn,OUT,MANY2MANY,NONE,NONE,NONE,NONE,T -vlan,l3-interface-ipv4-address-list,hasIpAddress,OUT,MANY2MANY,${direction},${direction},${direction},NONE,l3-interface-ipv4-address-list,vlan,org.onap.relationships.inventory.BelongsTo,OUT,MANY2ONE,!${direction},!${direction},!${direction},NONE,T -vlan,l3-interface-ipv6-address-list,hasIpAddress,OUT,MANY2MANY,${direction},${direction},${direction},NONE,l3-interface-ipv6-address-list,vlan,org.onap.relationships.inventory.BelongsTo,OUT,MANY2ONE,!${direction},!${direction},!${direction},NONE,T -vlan,logical-link,usesLogicalLink,OUT,MANY2MANY,NONE,${direction},${direction},NONE,vlan,logical-link,org.onap.relationships.inventory.Uses,OUT,MANY2MANY,NONE,${direction},${direction},NONE,T -vlan,multicast-configuration,uses,OUT,MANY2MANY,NONE,NONE,NONE,NONE,vlan,multicast-configuration,org.onap.relationships.inventory.Uses,OUT,MANY2MANY,NONE,NONE,NONE,NONE,T -vnfc,l3-interface-ipv4-address-list,hasIpAddress,OUT,ONE2MANY,${direction},${direction},NONE,NONE,l3-interface-ipv4-address-list,vnfc,org.onap.relationships.inventory.BelongsTo,OUT,MANY2ONE,!${direction},!${direction},NONE,NONE,T -vnfc,l3-interface-ipv6-address-list,hasIpAddress,OUT,ONE2MANY,${direction},${direction},NONE,NONE,l3-interface-ipv6-address-list,vnfc,org.onap.relationships.inventory.BelongsTo,OUT,MANY2ONE,!${direction},!${direction},NONE,NONE,T -vnfc,instance-group,isMemberOf,OUT,MANY2MANY,NONE,NONE,NONE,NONE,vnfc,instance-group,org.onap.relationships.inventory.MemberOf,OUT,MANY2MANY,NONE,NONE,NONE,NONE,T -vnfc,vip-ipv4-address-list,uses,OUT,MANY2MANY,NONE,NONE,NONE,NONE,vnfc,vip-ipv4-address-list,org.onap.relationships.inventory.Uses,OUT,MANY2MANY,NONE,NONE,NONE,NONE,T -vnfc,vip-ipv6-address-list,uses,OUT,MANY2MANY,NONE,NONE,NONE,NONE,vnfc,vip-ipv6-address-list,org.onap.relationships.inventory.Uses,OUT,MANY2MANY,NONE,NONE,NONE,NONE,T -volume-group,tenant,belongsTo,OUT,MANY2MANY,NONE,NONE,${direction},NONE,tenant,volume-group,org.onap.relationships.inventory.DependsOn,OUT,ONE2MANY,NONE,NONE,!${direction},NONE,T -volume-group,complex,existsIn,OUT,MANY2MANY,NONE,NONE,${direction},!${direction},volume-group,complex,org.onap.relationships.inventory.LocatedIn,OUT,MANY2ONE,NONE,NONE,${direction},!${direction},T -vpls-pe,lag-interface,hasLAGinterface,OUT,MANY2MANY,${direction},${direction},NONE,NONE,lag-interface,vpls-pe,tosca.relationships.network.BindsTo,OUT,MANY2ONE,!${direction},!${direction},NONE,NONE,T -vpls-pe,p-interface,hasPinterface,OUT,MANY2MANY,${direction},${direction},NONE,NONE,p-interface,vpls-pe,tosca.relationships.network.BindsTo,OUT,MANY2ONE,!${direction},!${direction},NONE,NONE,T -vpls-pe,complex,locatedIn,OUT,MANY2MANY,NONE,NONE,NONE,!${direction},vpls-pe,complex,org.onap.relationships.inventory.LocatedIn,OUT,MANY2ONE,NONE,NONE,NONE,!${direction},T -vpls-pe,ctag-pool,usesCtagPool,OUT,MANY2MANY,NONE,NONE,NONE,NONE,vpls-pe,ctag-pool,org.onap.relationships.inventory.Uses,OUT,MANY2MANY,NONE,NONE,NONE,NONE,T -vpn-binding,route-target,has,OUT,ONE2MANY,${direction},${direction},NONE,NONE,route-target,vpn-binding,org.onap.relationships.inventory.BelongsTo,OUT,MANY2ONE,!${direction},!${direction},NONE,NONE,T -vserver,l-interface,hasLInterface,OUT,MANY2MANY,${direction},${direction},${direction},NONE,l-interface,vserver,tosca.relationships.network.BindsTo,OUT,MANY2ONE,!${direction},!${direction},!${direction},NONE,T -vserver,vf-module,isPartOf,OUT,MANY2ONE,NONE,NONE,${direction},NONE,vf-module,vserver,org.onap.relationships.inventory.Uses,OUT,ONE2MANY,NONE,NONE,!${direction},NONE,T -vserver,vnfc,hosts,OUT,MANY2MANY,NONE,NONE,${direction},NONE,vnfc,vserver,tosca.relationships.HostedOn,OUT,ONE2MANY,NONE,NONE,!${direction},NONE,T -vserver,flavor,hasFlavor,OUT,MANY2ONE,NONE,NONE,${direction},!${direction},vserver,flavor,org.onap.relationships.inventory.Uses,OUT,MANY2ONE,NONE,NONE,${direction},!${direction},T -vserver,image,hasImage,OUT,MANY2ONE,NONE,NONE,${direction},!${direction},vserver,image,org.onap.relationships.inventory.Uses,OUT,MANY2ONE,NONE,NONE,${direction},!${direction},T -vserver,pserver,runsOnPserver,OUT,MANY2ONE,NONE,NONE,${direction},!${direction},vserver,pserver,tosca.relationships.HostedOn,OUT,MANY2ONE,NONE,NONE,${direction},!${direction},T -vserver,snapshot,uses,OUT,ONE2ONE,NONE,NONE,${direction},NONE,vserver,snapshot,org.onap.relationships.inventory.Uses,OUT,ONE2ONE,NONE,NONE,${direction},NONE,T -vserver,volume,hasVolume,OUT,MANY2MANY,${direction},${direction},${direction},NONE,vserver,volume,tosca.relationships.AttachesTo,OUT,ONE2MANY,${direction},${direction},${direction},NONE,T -zone,complex,existsIn,OUT,MANY2ONE,NONE,NONE,NONE,!${direction},zone,complex,org.onap.relationships.inventory.LocatedIn,OUT,MANY2ONE,NONE,NONE,NONE,!${direction},T -,,,,,,,,,allotted-resource,model-ver,org.onap.relationships.inventory.IsA,OUT,Many2One,NONE,NONE,NONE,NONE,T -,,,,,,,,,generic-vnf,model-ver,org.onap.relationships.inventory.IsA,OUT,Many2One,NONE,NONE,NONE,NONE,T -,,,,,,,,,l3-network,model-ver,org.onap.relationships.inventory.IsA,OUT,Many2One,NONE,NONE,NONE,NONE,T -,,,,,,,,,logical-link,model-ver,org.onap.relationships.inventory.IsA,OUT,Many2One,NONE,NONE,NONE,NONE,T -,,,,,,,,,service-instance,model-ver,org.onap.relationships.inventory.IsA,OUT,Many2One,NONE,NONE,NONE,NONE,T -,,,,,,,,,vf-module,model-ver,org.onap.relationships.inventory.IsA,OUT,Many2One,NONE,NONE,NONE,NONE,T -configuration,l-interface,has,OUT,ONE2MANY,NONE,NONE,NONE,NONE,configuration,l-interface,org.onap.relationships.inventory.AppliesTo,OUT,ONE2MANY,NONE,NONE,NONE,NONE,T -configuration,pnf,has,OUT,ONE2MANY,NONE,NONE,NONE,NONE,configuration,pnf,org.onap.relationships.inventory.AppliesTo,OUT,ONE2MANY,NONE,NONE,NONE,NONE,T -forwarder,forwarding-path,belongsTo,OUT,MANY2ONE,!${direction},!${direction},NONE,NONE,forwarder,forwarding-path,org.onap.relationships.inventory.BelongsTo,OUT,MANY2ONE,!${direction},!${direction},NONE,NONE,T -forwarding-path,service-instance,implements,OUT,MANY2ONE,NONE,!${direction},NONE,NONE,forwarding-path,service-instance,org.onap.relationships.inventory.AppliesTo,OUT,MANY2ONE,NONE,!${direction},NONE,NONE,T -forwarder,l-interface,forwardsTo,OUT,ONE2ONE,NONE,NONE,NONE,NONE,forwarder,l-interface,org.onap.relationships.inventory.ForwardsTo,OUT,ONE2ONE,NONE,NONE,NONE,NONE,T -forwarder,p-interface,forwardsTo,OUT,ONE2ONE,NONE,NONE,NONE,NONE,forwarder,p-interface,org.onap.relationships.inventory.ForwardsTo,OUT,ONE2ONE,NONE,NONE,NONE,NONE,T diff --git a/aai-resources/src/test/resources/edgeMigrationTestRules.json b/aai-resources/src/test/resources/edgeMigrationTestRules.json deleted file mode 100644 index a18b8a9..0000000 --- a/aai-resources/src/test/resources/edgeMigrationTestRules.json +++ /dev/null @@ -1,12 +0,0 @@ -{"rules": -[{ - "from": "generic-vnf", - "to": "l-interface", - "label": "hasLInterface", - "direction": "OUT", - "multiplicity": "MANY2MANY", - "contains-other-v": "${direction}", - "delete-other-v": "${direction}", - "SVC-INFRA": "${direction}", - "prevent-delete": "NONE" -}]}
\ No newline at end of file diff --git a/aai-resources/src/test/resources/etc/appprops/aaiconfig.properties b/aai-resources/src/test/resources/etc/appprops/aaiconfig.properties new file mode 100644 index 0000000..bc8b9b9 --- /dev/null +++ b/aai-resources/src/test/resources/etc/appprops/aaiconfig.properties @@ -0,0 +1,56 @@ +# +# ============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. +# + +#################################################################### +# 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.server.url.base=https://localhost:8443/aai/ +aai.server.url=https://localhost:8443/aai/v14/ +aai.oldserver.url.base=https://localhost:8443/aai/servers/ +aai.oldserver.url=https://localhost:8443/aai/servers/v2/ +aai.global.callback.url=https://localhost:8443/aai/ + +aai.notification.current.version=v14 +aai.notificationEvent.default.status=UNPROCESSED +aai.notificationEvent.default.eventType=AAI-EVENT +aai.notificationEvent.default.domain=devINT1 +aai.notificationEvent.default.sourceName=aai +aai.notificationEvent.default.sequenceNumber=0 +aai.notificationEvent.default.severity=NORMAL +aai.notificationEvent.default.version=v14 +# This one lets us enable/disable resource-version checking on updates/deletes +aai.resourceversion.enableflag=true +aai.logging.maxStackTraceEntries=10 +aai.default.api.version=v14 + +aai.realtime.clients=RO,SDNC,MSO + +aai.run.migrations=false + +aai.jms.enable=false diff --git a/aai-resources/src/test/resources/bundleconfig-local/etc/appprops/error.properties b/aai-resources/src/test/resources/etc/appprops/error.properties index 82e7dcc..828c36c 100644 --- a/aai-resources/src/test/resources/bundleconfig-local/etc/appprops/error.properties +++ b/aai-resources/src/test/resources/etc/appprops/error.properties @@ -131,9 +131,6 @@ 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 diff --git a/aai-resources/src/test/resources/bundleconfig-local/etc/appprops/janusgraph-cached.properties b/aai-resources/src/test/resources/etc/appprops/janusgraph-cached.properties index 5a52d19..6ab12a0 100644 --- a/aai-resources/src/test/resources/bundleconfig-local/etc/appprops/janusgraph-cached.properties +++ b/aai-resources/src/test/resources/etc/appprops/janusgraph-cached.properties @@ -21,13 +21,11 @@ # query.fast-property=true -query.smart-limit=false - # the following parameters are not reloaded automatically and require a manual bounce storage.backend=inmemory storage.hostname=localhost -#graph.titan-version=1.0.0 +graph.titan-version=1.0.0 #schema.default=none storage.lock.wait-time=300 @@ -40,4 +38,4 @@ cache.db-cache-time = 180000 cache.db-cache-size = 0.3 #load graphson file on startup -load.snapshot.file=false +load.snapshot.file=false
\ No newline at end of file diff --git a/aai-resources/src/test/resources/bundleconfig-local/etc/appprops/janusgraph-realtime.properties b/aai-resources/src/test/resources/etc/appprops/janusgraph-realtime.properties index 72ced14..d81f37e 100644 --- a/aai-resources/src/test/resources/bundleconfig-local/etc/appprops/janusgraph-realtime.properties +++ b/aai-resources/src/test/resources/etc/appprops/janusgraph-realtime.properties @@ -21,13 +21,11 @@ # query.fast-property=true -query.smart-limit=false - # the following parameters are not reloaded automatically and require a manual bounce storage.backend=inmemory storage.hostname=localhost -#graph.titan-version=1.0.0 +graph.titan-version=1.0.0 #schema.default=none storage.lock.wait-time=300 diff --git a/aai-resources/src/test/resources/bundleconfig-local/etc/auth/aai_policy.json b/aai-resources/src/test/resources/etc/auth/aai_policy.json index 9706ce9..9706ce9 100644 --- a/aai-resources/src/test/resources/bundleconfig-local/etc/auth/aai_policy.json +++ b/aai-resources/src/test/resources/etc/auth/aai_policy.json diff --git a/aai-resources/src/test/resources/bundleconfig-local/etc/scriptdata/dependencies/vRouterServiceInstanceFile.txt b/aai-resources/src/test/resources/etc/scriptdata/dependencies/vRouterServiceInstanceFile.txt index a5be791..a5be791 100644 --- a/aai-resources/src/test/resources/bundleconfig-local/etc/scriptdata/dependencies/vRouterServiceInstanceFile.txt +++ b/aai-resources/src/test/resources/etc/scriptdata/dependencies/vRouterServiceInstanceFile.txt diff --git a/aai-resources/src/test/resources/inmemory_titan.properties b/aai-resources/src/test/resources/inmemory_titan.properties deleted file mode 100644 index cf4bbfd..0000000 --- a/aai-resources/src/test/resources/inmemory_titan.properties +++ /dev/null @@ -1,23 +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. -# - -storage.backend=inmemory diff --git a/aai-resources/src/test/resources/maputils/testcases/TestCase1.json b/aai-resources/src/test/resources/maputils/testcases/TestCase1.json deleted file mode 100644 index 1f7a794..0000000 --- a/aai-resources/src/test/resources/maputils/testcases/TestCase1.json +++ /dev/null @@ -1,32 +0,0 @@ -{ - "input": { - "myImage": { - "imageId": "test-imageId-1", - "imageName": "test-image-name", - "imageList": [ - { - "imageListName": "testListName", - "imageListId": "testListId", - "imageListNumber": 200, - "imageListBoolean": true, - "imageListNull": null - } - ] - } - }, - "output": { - "my-image": { - "image-id": "test-imageId-1", - "image-name": "test-image-name", - "image-list": [ - { - "image-list-name": "testListName", - "image-list-id": "testListId", - "image-list-number": 200, - "image-list-boolean": true, - "image-list-null": null - } - ] - } - } -}
\ No newline at end of file diff --git a/aai-resources/src/test/resources/maputils/testcases/TestCase2.json b/aai-resources/src/test/resources/maputils/testcases/TestCase2.json deleted file mode 100644 index 9b8a1e3..0000000 --- a/aai-resources/src/test/resources/maputils/testcases/TestCase2.json +++ /dev/null @@ -1,40 +0,0 @@ -{ - "input": { - "myImage": { - "imageId": "test-imageId-1", - "imageName": "test-image-name", - "imageList": [ - { - "imageListName": "testListName", - "imageListId": "testListId", - "imageArray": [ - [ - { - "imageNestedArrayElement": "value" - } - ] - ] - } - ] - } - }, - "output": { - "my-image": { - "image-id": "test-imageId-1", - "image-name": "test-image-name", - "image-list": [ - { - "image-list-name": "testListName", - "image-list-id": "testListId", - "image-array": [ - [ - { - "image-nested-array-element": "value" - } - ] - ] - } - ] - } - } -}
\ No newline at end of file diff --git a/aai-resources/src/test/resources/payloads/bulk/complex-bulk-process-delete-transactions.json b/aai-resources/src/test/resources/payloads/bulk/complex-bulk-process-delete-transactions.json index 96a4228..eae7b35 100644 --- a/aai-resources/src/test/resources/payloads/bulk/complex-bulk-process-delete-transactions.json +++ b/aai-resources/src/test/resources/payloads/bulk/complex-bulk-process-delete-transactions.json @@ -1,20 +1,20 @@ -{
- "transactions": [
- {
- "delete": [
- {
- "uri": "/cloud-infrastructure/pservers/pserver/pserver-9876543210-77-jenkins/relationship-list/relationship",
- "body": {
- "related-to": "complex",
- "relationship-data": [
- {
- "relationship-key": "complex.physical-location-id",
- "relationship-value": "complex-987654321-77-jenkins"
- }
- ]
- }
- }
- ]
- }
- ]
+{ + "transactions": [ + { + "delete": [ + { + "uri": "/cloud-infrastructure/pservers/pserver/pserver-9876543210-77-jenkins/relationship-list/relationship", + "body": { + "related-to": "complex", + "relationship-data": [ + { + "relationship-key": "complex.physical-location-id", + "relationship-value": "complex-987654321-77-jenkins" + } + ] + } + } + ] + } + ] }
\ No newline at end of file diff --git a/aai-resources/src/test/resources/payloads/bulk/pserver-bulk-process-transactions-with-patch.json b/aai-resources/src/test/resources/payloads/bulk/pserver-bulk-process-transactions-with-patch.json new file mode 100644 index 0000000..b030ae4 --- /dev/null +++ b/aai-resources/src/test/resources/payloads/bulk/pserver-bulk-process-transactions-with-patch.json @@ -0,0 +1,25 @@ +{ + "transactions": [ + { + "put": [ + { + "uri": "/cloud-infrastructure/pservers/pserver/pserver-bulk-process-transactions-1-<UUID>", + "body": { + "hostname": "pserver-bulk-process-transactions-1-<UUID>", + "fqdn": "pserver-bulk-process-transactions-1-fqdn" + } + } + ] + }, + { + "patch": [ + { + "uri": "/cloud-infrastructure/pservers/pserver/pserver-bulk-process-transactions-1-<UUID>", + "body": { + "fqdn": "NEW" + } + } + ] + } + ] +} diff --git a/aai-resources/src/test/resources/payloads/bulk/single-transaction/invalid-action.json b/aai-resources/src/test/resources/payloads/bulk/single-transaction/invalid-action.json new file mode 100644 index 0000000..5ed1880 --- /dev/null +++ b/aai-resources/src/test/resources/payloads/bulk/single-transaction/invalid-action.json @@ -0,0 +1,19 @@ +{ + "operations": [ + { + "action": "create", + "uri": "/cloud-infrastructure/pservers/pserver/pserver-<methodName>", + "body": { + "hostname": "pserver-<methodName>", + "fqdn": "pserver-<methodName>-fqdn" + } + }, + { + "action": "destroy", + "uri": "/cloud-infrastructure/pservers/pserver/pserver-<methodName>", + "body": { + "fqdn": "patched-fqdn" + } + } + ] +} diff --git a/aai-resources/src/test/resources/payloads/bulk/single-transaction/missing-fields.json b/aai-resources/src/test/resources/payloads/bulk/single-transaction/missing-fields.json new file mode 100644 index 0000000..e0f5514 --- /dev/null +++ b/aai-resources/src/test/resources/payloads/bulk/single-transaction/missing-fields.json @@ -0,0 +1,20 @@ +{ + "operations": [ + { + "action": "put", + "uri": "/cloud-infrastructure/pservers/pserver/pserver-<methodName>" + }, + { + "uri": "/cloud-infrastructure/pservers/pserver/pserver-<methodName>", + "body": { + "fqdn": "patched-fqdn" + } + }, + { + "action": "patch", + "body": { + "fqdn": "patched-fqdn" + } + } + ] +} diff --git a/aai-resources/src/test/resources/payloads/bulk/single-transaction/pserver-bulk-limit-exceed.json b/aai-resources/src/test/resources/payloads/bulk/single-transaction/pserver-bulk-limit-exceed.json new file mode 100644 index 0000000..b758f67 --- /dev/null +++ b/aai-resources/src/test/resources/payloads/bulk/single-transaction/pserver-bulk-limit-exceed.json @@ -0,0 +1,308 @@ +{ + "operations": [ + { + "action": "put", + "uri": "/cloud-infrastructure/pservers/pserver/pserver-<methodName>", + "body": { + "hostname": "pserver-<methodName>", + "fqdn": "pserver-<methodName>-fqdn" + } + }, + { + "action": "put", + "uri": "/cloud-infrastructure/pservers/pserver/pserver-<methodName>", + "body": { + "hostname": "pserver-<methodName>", + "fqdn": "pserver-<methodName>-fqdn" + } + }, + { + "action": "put", + "uri": "/cloud-infrastructure/pservers/pserver/pserver-<methodName>", + "body": { + "hostname": "pserver-<methodName>", + "fqdn": "pserver-<methodName>-fqdn" + } + }, + { + "action": "put", + "uri": "/cloud-infrastructure/pservers/pserver/pserver-<methodName>", + "body": { + "hostname": "pserver-<methodName>", + "fqdn": "pserver-<methodName>-fqdn" + } + }, + { + "action": "put", + "uri": "/cloud-infrastructure/pservers/pserver/pserver-<methodName>", + "body": { + "hostname": "pserver-<methodName>", + "fqdn": "pserver-<methodName>-fqdn" + } + }, + { + "action": "put", + "uri": "/cloud-infrastructure/pservers/pserver/pserver-<methodName>", + "body": { + "hostname": "pserver-<methodName>", + "fqdn": "pserver-<methodName>-fqdn" + } + }, + { + "action": "put", + "uri": "/cloud-infrastructure/pservers/pserver/pserver-<methodName>", + "body": { + "hostname": "pserver-<methodName>", + "fqdn": "pserver-<methodName>-fqdn" + } + }, + { + "action": "put", + "uri": "/cloud-infrastructure/pservers/pserver/pserver-<methodName>", + "body": { + "hostname": "pserver-<methodName>", + "fqdn": "pserver-<methodName>-fqdn" + } + }, + { + "action": "put", + "uri": "/cloud-infrastructure/pservers/pserver/pserver-<methodName>", + "body": { + "hostname": "pserver-<methodName>", + "fqdn": "pserver-<methodName>-fqdn" + } + }, + { + "action": "put", + "uri": "/cloud-infrastructure/pservers/pserver/pserver-<methodName>", + "body": { + "hostname": "pserver-<methodName>", + "fqdn": "pserver-<methodName>-fqdn" + } + }, + { + "action": "put", + "uri": "/cloud-infrastructure/pservers/pserver/pserver-<methodName>", + "body": { + "hostname": "pserver-<methodName>", + "fqdn": "pserver-<methodName>-fqdn" + } + }, + { + "action": "put", + "uri": "/cloud-infrastructure/pservers/pserver/pserver-<methodName>", + "body": { + "hostname": "pserver-<methodName>", + "fqdn": "pserver-<methodName>-fqdn" + } + }, + { + "action": "put", + "uri": "/cloud-infrastructure/pservers/pserver/pserver-<methodName>", + "body": { + "hostname": "pserver-<methodName>", + "fqdn": "pserver-<methodName>-fqdn" + } + }, + { + "action": "put", + "uri": "/cloud-infrastructure/pservers/pserver/pserver-<methodName>", + "body": { + "hostname": "pserver-<methodName>", + "fqdn": "pserver-<methodName>-fqdn" + } + }, + { + "action": "put", + "uri": "/cloud-infrastructure/pservers/pserver/pserver-<methodName>", + "body": { + "hostname": "pserver-<methodName>", + "fqdn": "pserver-<methodName>-fqdn" + } + }, + { + "action": "put", + "uri": "/cloud-infrastructure/pservers/pserver/pserver-<methodName>", + "body": { + "hostname": "pserver-<methodName>", + "fqdn": "pserver-<methodName>-fqdn" + } + }, + { + "action": "put", + "uri": "/cloud-infrastructure/pservers/pserver/pserver-<methodName>", + "body": { + "hostname": "pserver-<methodName>", + "fqdn": "pserver-<methodName>-fqdn" + } + }, + { + "action": "put", + "uri": "/cloud-infrastructure/pservers/pserver/pserver-<methodName>", + "body": { + "hostname": "pserver-<methodName>", + "fqdn": "pserver-<methodName>-fqdn" + } + }, + { + "action": "put", + "uri": "/cloud-infrastructure/pservers/pserver/pserver-<methodName>", + "body": { + "hostname": "pserver-<methodName>", + "fqdn": "pserver-<methodName>-fqdn" + } + }, + { + "action": "put", + "uri": "/cloud-infrastructure/pservers/pserver/pserver-<methodName>", + "body": { + "hostname": "pserver-<methodName>", + "fqdn": "pserver-<methodName>-fqdn" + } + }, + { + "action": "put", + "uri": "/cloud-infrastructure/pservers/pserver/pserver-<methodName>", + "body": { + "hostname": "pserver-<methodName>", + "fqdn": "pserver-<methodName>-fqdn" + } + }, + { + "action": "put", + "uri": "/cloud-infrastructure/pservers/pserver/pserver-<methodName>", + "body": { + "hostname": "pserver-<methodName>", + "fqdn": "pserver-<methodName>-fqdn" + } + }, + { + "action": "put", + "uri": "/cloud-infrastructure/pservers/pserver/pserver-<methodName>", + "body": { + "hostname": "pserver-<methodName>", + "fqdn": "pserver-<methodName>-fqdn" + } + }, + { + "action": "put", + "uri": "/cloud-infrastructure/pservers/pserver/pserver-<methodName>", + "body": { + "hostname": "pserver-<methodName>", + "fqdn": "pserver-<methodName>-fqdn" + } + }, + { + "action": "put", + "uri": "/cloud-infrastructure/pservers/pserver/pserver-<methodName>", + "body": { + "hostname": "pserver-<methodName>", + "fqdn": "pserver-<methodName>-fqdn" + } + }, + { + "action": "put", + "uri": "/cloud-infrastructure/pservers/pserver/pserver-<methodName>", + "body": { + "hostname": "pserver-<methodName>", + "fqdn": "pserver-<methodName>-fqdn" + } + }, + { + "action": "put", + "uri": "/cloud-infrastructure/pservers/pserver/pserver-<methodName>", + "body": { + "hostname": "pserver-<methodName>", + "fqdn": "pserver-<methodName>-fqdn" + } + }, + { + "action": "put", + "uri": "/cloud-infrastructure/pservers/pserver/pserver-<methodName>", + "body": { + "hostname": "pserver-<methodName>", + "fqdn": "pserver-<methodName>-fqdn" + } + }, + { + "action": "put", + "uri": "/cloud-infrastructure/pservers/pserver/pserver-<methodName>", + "body": { + "hostname": "pserver-<methodName>", + "fqdn": "pserver-<methodName>-fqdn" + } + }, + { + "action": "put", + "uri": "/cloud-infrastructure/pservers/pserver/pserver-<methodName>", + "body": { + "hostname": "pserver-<methodName>", + "fqdn": "pserver-<methodName>-fqdn" + } + }, + { + "action": "put", + "uri": "/cloud-infrastructure/pservers/pserver/pserver-<methodName>", + "body": { + "hostname": "pserver-<methodName>", + "fqdn": "pserver-<methodName>-fqdn" + } + }, + { + "action": "put", + "uri": "/cloud-infrastructure/pservers/pserver/pserver-<methodName>", + "body": { + "hostname": "pserver-<methodName>", + "fqdn": "pserver-<methodName>-fqdn" + } + }, + { + "action": "put", + "uri": "/cloud-infrastructure/pservers/pserver/pserver-<methodName>", + "body": { + "hostname": "pserver-<methodName>", + "fqdn": "pserver-<methodName>-fqdn" + } + }, + { + "action": "put", + "uri": "/cloud-infrastructure/pservers/pserver/pserver-<methodName>", + "body": { + "hostname": "pserver-<methodName>", + "fqdn": "pserver-<methodName>-fqdn" + } + }, + { + "action": "put", + "uri": "/cloud-infrastructure/pservers/pserver/pserver-<methodName>", + "body": { + "hostname": "pserver-<methodName>", + "fqdn": "pserver-<methodName>-fqdn" + } + }, + { + "action": "put", + "uri": "/cloud-infrastructure/pservers/pserver/pserver-<methodName>", + "body": { + "hostname": "pserver-<methodName>", + "fqdn": "pserver-<methodName>-fqdn" + } + }, + { + "action": "put", + "uri": "/cloud-infrastructure/pservers/pserver/pserver-<methodName>", + "body": { + "hostname": "pserver-<methodName>", + "fqdn": "pserver-<methodName>-fqdn" + } + }, + { + "action": "put", + "uri": "/cloud-infrastructure/pservers/pserver/pserver-<methodName>", + "body": { + "hostname": "pserver-<methodName>", + "fqdn": "pserver-<methodName>-fqdn" + } + } + ] +} diff --git a/aai-resources/src/test/resources/payloads/bulk/single-transaction/put-patch-same-pserver-put-another-pserver.json b/aai-resources/src/test/resources/payloads/bulk/single-transaction/put-patch-same-pserver-put-another-pserver.json new file mode 100644 index 0000000..9abc26c --- /dev/null +++ b/aai-resources/src/test/resources/payloads/bulk/single-transaction/put-patch-same-pserver-put-another-pserver.json @@ -0,0 +1,27 @@ +{ + "operations": [ + { + "action": "put", + "uri": "/cloud-infrastructure/pservers/pserver/pserver-1-<methodName>", + "body": { + "hostname": "pserver-1-<methodName>", + "fqdn": "pserver-<methodName>-fqdn" + } + }, + { + "action": "patch", + "uri": "/cloud-infrastructure/pservers/pserver/pserver-1-<methodName>", + "body": { + "fqdn": "patched-fqdn" + } + }, + { + "action": "put", + "uri": "/cloud-infrastructure/pservers/pserver/pserver-2-<methodName>", + "body": { + "hostname": "pserver-2-<methodName>", + "fqdn": "pserver-<methodName>-fqdn" + } + } + ] +} diff --git a/aai-resources/src/test/resources/payloads/bulk/single-transaction/put-patch-same-pserver.json b/aai-resources/src/test/resources/payloads/bulk/single-transaction/put-patch-same-pserver.json new file mode 100644 index 0000000..003cb8c --- /dev/null +++ b/aai-resources/src/test/resources/payloads/bulk/single-transaction/put-patch-same-pserver.json @@ -0,0 +1,19 @@ +{ + "operations": [ + { + "action": "put", + "uri": "/cloud-infrastructure/pservers/pserver/pserver-<methodName>", + "body": { + "hostname": "pserver-<methodName>", + "fqdn": "pserver-<methodName>-fqdn" + } + }, + { + "action": "patch", + "uri": "/cloud-infrastructure/pservers/pserver/pserver-<methodName>", + "body": { + "fqdn": "patched-fqdn" + } + } + ] +} diff --git a/aai-resources/src/test/resources/payloads/bulk/single-transaction/put-pserver-complex-rel-between-del-existing-gvnf-fail.json b/aai-resources/src/test/resources/payloads/bulk/single-transaction/put-pserver-complex-rel-between-del-existing-gvnf-fail.json new file mode 100644 index 0000000..7e923d2 --- /dev/null +++ b/aai-resources/src/test/resources/payloads/bulk/single-transaction/put-pserver-complex-rel-between-del-existing-gvnf-fail.json @@ -0,0 +1,43 @@ +{ + "operations": [ + { + "action": "put", + "uri": "/cloud-infrastructure/pservers/pserver/pserver-<methodName>", + "body": { + "hostname": "pserver-<methodName>", + "fqdn": "pserver-<methodName>-fqdn" + } + }, + { + "action": "put", + "uri": "/cloud-infrastructure/complexes/complex/complex-<methodName>", + "body": { + "physical-location-id": "complex-<methodName>", + "data-center-code": "code", + "identity-url": "N/A", + "physical-location-type": "type", + "street1": "street", + "city": "city", + "state": "state", + "postal-code": "12345", + "country": "NONE", + "region": "Earth" + + } + }, + { + "action": "put", + "uri": "/cloud-infrastructure/complexes/complex/complex-<methodName>/relationship-list/relationship", + "body": { + "related-to": "pserver", + "related-link": "/aai/v13/cloud-infrastructure/pservers/pserver/pserver-<methodName>" + + } + }, + { + "action": "delete", + "uri": "/network/generic-vnfs/generic-vnf/gvnf-<methodName>?resource-version=1", + "body": {} + } + ] +} diff --git a/aai-resources/src/test/resources/payloads/bulk/single-transaction/put-pserver-complex-rel-between-del-existing-gvnf.json b/aai-resources/src/test/resources/payloads/bulk/single-transaction/put-pserver-complex-rel-between-del-existing-gvnf.json new file mode 100644 index 0000000..52c9599 --- /dev/null +++ b/aai-resources/src/test/resources/payloads/bulk/single-transaction/put-pserver-complex-rel-between-del-existing-gvnf.json @@ -0,0 +1,43 @@ +{ + "operations": [ + { + "action": "put", + "uri": "/cloud-infrastructure/pservers/pserver/pserver-<methodName>", + "body": { + "hostname": "pserver-<methodName>", + "fqdn": "pserver-<methodName>-fqdn" + } + }, + { + "action": "put", + "uri": "/cloud-infrastructure/complexes/complex/complex-<methodName>", + "body": { + "physical-location-id": "complex-<methodName>", + "data-center-code": "code", + "identity-url": "N/A", + "physical-location-type": "type", + "street1": "street", + "city": "city", + "state": "state", + "postal-code": "12345", + "country": "NONE", + "region": "Earth" + + } + }, + { + "action": "put", + "uri": "/cloud-infrastructure/complexes/complex/complex-<methodName>/relationship-list/relationship", + "body": { + "related-to": "pserver", + "related-link": "/aai/v13/cloud-infrastructure/pservers/pserver/pserver-<methodName>" + + } + }, + { + "action": "delete", + "uri": "/network/generic-vnfs/generic-vnf/gvnf-<methodName>?resource-version=0", + "body": {} + } + ] +} diff --git a/aai-resources/src/test/resources/payloads/bulk/single-transaction/put-pserver-complex-rel-between.json b/aai-resources/src/test/resources/payloads/bulk/single-transaction/put-pserver-complex-rel-between.json new file mode 100644 index 0000000..a2ac2c5 --- /dev/null +++ b/aai-resources/src/test/resources/payloads/bulk/single-transaction/put-pserver-complex-rel-between.json @@ -0,0 +1,38 @@ +{ + "operations": [ + { + "action": "put", + "uri": "/cloud-infrastructure/pservers/pserver/pserver-<methodName>", + "body": { + "hostname": "pserver-<methodName>", + "fqdn": "pserver-<methodName>-fqdn" + } + }, + { + "action": "put", + "uri": "/cloud-infrastructure/complexes/complex/complex-<methodName>", + "body": { + "physical-location-id": "complex-<methodName>", + "data-center-code": "code", + "identity-url": "N/A", + "physical-location-type": "type", + "street1": "street", + "city": "city", + "state": "state", + "postal-code": "12345", + "country": "NONE", + "region": "Earth" + + } + }, + { + "action": "put", + "uri": "/cloud-infrastructure/complexes/complex/complex-<methodName>/relationship-list/relationship", + "body": { + "related-to": "pserver", + "related-link": "/aai/v13/cloud-infrastructure/pservers/pserver/pserver-<methodName>" + + } + } + ] +} diff --git a/aai-resources/src/test/resources/payloads/relationship/complex-bugfix.json b/aai-resources/src/test/resources/payloads/relationship/complex-bugfix.json index 29fe3d6..9aa41a3 100644 --- a/aai-resources/src/test/resources/payloads/relationship/complex-bugfix.json +++ b/aai-resources/src/test/resources/payloads/relationship/complex-bugfix.json @@ -1,16 +1,16 @@ -{
- "physical-location-id" : "complex-987654321-77-jenkins",
- "physical-location-type" : "uug",
- "street1" : "kDv5Ge6dr",
- "city" : "KpEa5IjqY0u82",
- "postal-code" : "6CRqacfEW2",
- "country" : "P0ho",
- "region" : "Sk2QevPYRBjT",
- "ctag-pools" : {
- "ctag-pool" : [ {
- "target-pe" : "5dbe73c6-cedf-4e68-a7c5-699ba6d90e1d",
- "availability-zone-name" : "819ec2fa-fb9f-49f0-8fd8-5feb941aad1f",
- "ctag-pool-purpose" : "4TMeWI"
- } ]
- }
+{ + "physical-location-id" : "complex-987654321-77-jenkins", + "physical-location-type" : "uug", + "street1" : "kDv5Ge6dr", + "city" : "KpEa5IjqY0u82", + "postal-code" : "6CRqacfEW2", + "country" : "P0ho", + "region" : "Sk2QevPYRBjT", + "ctag-pools" : { + "ctag-pool" : [ { + "target-pe" : "5dbe73c6-cedf-4e68-a7c5-699ba6d90e1d", + "availability-zone-name" : "819ec2fa-fb9f-49f0-8fd8-5feb941aad1f", + "ctag-pool-purpose" : "4TMeWI" + } ] + } }
\ No newline at end of file diff --git a/aai-resources/src/test/resources/payloads/relationship/pserver-bugfix.json b/aai-resources/src/test/resources/payloads/relationship/pserver-bugfix.json index e78bd7a..461b88c 100644 --- a/aai-resources/src/test/resources/payloads/relationship/pserver-bugfix.json +++ b/aai-resources/src/test/resources/payloads/relationship/pserver-bugfix.json @@ -1,4 +1,4 @@ -{
- "hostname" : "pserver-9876543210-77-jenkins",
- "in-maint" : false
+{ + "hostname" : "pserver-9876543210-77-jenkins", + "in-maint" : false }
\ No newline at end of file diff --git a/aai-resources/src/test/resources/payloads/relationship/pserver-complex-relationship-for-bulk.json b/aai-resources/src/test/resources/payloads/relationship/pserver-complex-relationship-for-bulk.json index 72982af..44cecda 100644 --- a/aai-resources/src/test/resources/payloads/relationship/pserver-complex-relationship-for-bulk.json +++ b/aai-resources/src/test/resources/payloads/relationship/pserver-complex-relationship-for-bulk.json @@ -1,8 +1,8 @@ -{
- "related-to" : "complex",
- "related-link" : "/aai/v11/cloud-infrastructure/complexes/complex/complex-987654321-77-jenkins",
- "relationship-data" : [{
- "relationship-key" : "complex.physical-location-id",
- "relationship-value" : "complex-987654321-77-jenkins"
- }]
+{ + "related-to" : "complex", + "related-link" : "/aai/v11/cloud-infrastructure/complexes/complex/complex-987654321-77-jenkins", + "relationship-data" : [{ + "relationship-key" : "complex.physical-location-id", + "relationship-value" : "complex-987654321-77-jenkins" + }] }
\ No newline at end of file diff --git a/aai-resources/src/test/resources/payloads/resource/customer.json b/aai-resources/src/test/resources/payloads/resource/customer.json new file mode 100644 index 0000000..4ee9f5e --- /dev/null +++ b/aai-resources/src/test/resources/payloads/resource/customer.json @@ -0,0 +1,15 @@ +{ + "global-customer-id": "customer-987654321-91", + "subscriber-name": "subscriber-name-987654321-91", + "subscriber-type": "subscriber-type-987654321-91", + "service-subscriptions": { + "service-subscription": { + "service-type": "service-type-987654321-91", + "service-instances": { + "service-instance": { + "service-instance-id": "service-instance-id-987654321-91" + } + } + } + } +}
\ No newline at end of file diff --git a/aai-resources/src/test/resources/payloads/templates/pserver-to-cloud-region.json b/aai-resources/src/test/resources/payloads/templates/pserver-to-cloud-region.json new file mode 100644 index 0000000..d2cbdd3 --- /dev/null +++ b/aai-resources/src/test/resources/payloads/templates/pserver-to-cloud-region.json @@ -0,0 +1,12 @@ +{ + "cloud-region-id": "${cloud-region-id}", + "cloud-owner": "${cloud-owner}", + "relationship-list": { + "relationship": [ + { + "related-to": "pserver", + "related-link": "/cloud-infrastructure/pservers/pserver/${hostname}" + } + ] + } +}
\ No newline at end of file diff --git a/aai-resources/src/test/resources/payloads/templates/pserver-uriencoded.json b/aai-resources/src/test/resources/payloads/templates/pserver-uriencoded.json new file mode 100644 index 0000000..31d4a3b --- /dev/null +++ b/aai-resources/src/test/resources/payloads/templates/pserver-uriencoded.json @@ -0,0 +1,4 @@ +{ + "hostname":"${hostname}", + "ptnii-equip-name": "some equip name" +}
\ No newline at end of file diff --git a/aai-resources/src/test/resources/payloads/templates/pserver-with-data.json b/aai-resources/src/test/resources/payloads/templates/pserver-with-data.json new file mode 100644 index 0000000..2c97b50 --- /dev/null +++ b/aai-resources/src/test/resources/payloads/templates/pserver-with-data.json @@ -0,0 +1,4 @@ +{ + "hostname": "${hostname}", + "pserver-id": "${pserver-id}" +}
\ No newline at end of file diff --git a/aai-resources/src/test/resources/payloads/templates/pserver.json b/aai-resources/src/test/resources/payloads/templates/pserver.json new file mode 100644 index 0000000..3b3ed24 --- /dev/null +++ b/aai-resources/src/test/resources/payloads/templates/pserver.json @@ -0,0 +1,3 @@ +{ + "hostname": "${hostname}" +}
\ No newline at end of file diff --git a/aai-resources/src/test/resources/payloads/templates/pserver.xml b/aai-resources/src/test/resources/payloads/templates/pserver.xml new file mode 100644 index 0000000..2b47e8c --- /dev/null +++ b/aai-resources/src/test/resources/payloads/templates/pserver.xml @@ -0,0 +1,6 @@ +<?xml version="1.0" encoding="UTF-8"?> +<pserver xmlns="http://org.onap.aai.inventory/v11"> + <hostname>${hostname}</hostname> + <ptnii-equip-name>example-ptnii-equip-name-val-35940</ptnii-equip-name> + <number-of-cpus>100</number-of-cpus> +</pserver>
\ No newline at end of file diff --git a/aai-resources/src/test/resources/test_aaiconfig.properties b/aai-resources/src/test/resources/test_aaiconfig.properties deleted file mode 100644 index 224d593..0000000 --- a/aai-resources/src/test/resources/test_aaiconfig.properties +++ /dev/null @@ -1,116 +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. -# - -#################################################################### -# REMEMBER TO THINK ABOUT ENVIRONMENTAL DIFFERENCES AND CHANGE THE -# TEMPLATE AND *ALL* DATAFILES -#################################################################### - -aai.config.checktime=1000 - -# this could come from siteconfig.pl? -aai.config.nodename=AutomaticallyOverwritten - -aai.logging.hbase.interceptor=true -aai.logging.hbase.enabled=true -aai.logging.hbase.logrequest=true -aai.logging.hbase.logresponse=true - -aai.logging.trace.enabled=true -aai.logging.trace.logrequest=false -aai.logging.trace.logresponse=false - -ecm.openstack.tenantid=b0a529aba48440a39e0caf1aea9b27e3 -ecm.serviceid.trinity=UNUSED -ecm.serviceid.vusp=UNUSED - -aai.auth.cspcookies_on=false -aai.dbmodel.filename=ex5.json -aai.server.url.base=https://localhost.com:8443/aai/ -aai.server.url=https://localhost.com:8443/aai/v7/ -aai.oldserver.url.base=https://localhost.com:8443/aai/servers/ -aai.oldserver.url=https://localhost.com:8443/aai/servers/v3/ -aai.truststore.filename=aai_keystore -aai.truststore.passwd.x= -aai.keystore.filename=aai-client-cert.p12 -aai.keystore.passwd.x= - -# the following parameters are not reloaded automatically and require a manual bounce -storage.backend=hbase -storage.hostname=ONAPserverTBD -#schema.default=none -storage.lock.wait-time=300 -storage.hbase.table=aaigraph-dev1.dev -storage.hbase.ext.zookeeper.znode.parent=/hbase-unsecure -# Setting db-cache to false ensure the fastest propagation of changes across servers -cache.db-cache = false -#cache.db-cache-clean-wait = 20 -#cache.db-cache-time = 180000 -#cache.db-cache-size = 0.5 - -# for transaction log -hbase.table.name=aailogging-dev1.dev -hbase.notificationTable.name=aainotification-dev1.dev -hbase.table.timestamp.format=YYYYMMdd-HH:mm:ss:SSS -hbase.zookeeper.quorum=ONAPserverTBD -hbase.zookeeper.property.clientPort=2181 -hbase.zookeeper.znode.parent=/hbase-unsecure - -aai.precheck.cloudinfrastructure.complex.defaults.physicalLocationType=AAIDefault -aai.precheck.cloudinfrastructure.complex.defaults.street1=AAIDefault -aai.precheck.cloudinfrastructure.complex.defaults.city=AAIDefault -aai.precheck.cloudinfrastructure.complex.defaults.state=NJ -aai.precheck.cloudinfrastructure.complex.defaults.postalCode=07748 -aai.precheck.cloudinfrastructure.complex.defaults.country=USA -aai.precheck.cloudinfrastructure.complex.defaults.region=Americas - -# single primary server -aai.primary.filetransfer.serverlist=ONAPserverTBD -aai.primary.filetransfer.primarycheck=echo:8443/aai/util/echo -aai.primary.filetransfer.pingtimeout=5000 -aai.primary.filetransfer.pingcount=5 - -#rsync properties -aai.rsync.command=rsync -aai.rsync.options.list=-v|-t -aai.rsync.remote.user=aaiadmin -aai.rsync.enabled=y - -#Service Specific Data Values -aai.servicedescription.hostedcomm=HOSTED COMMUNICATIONS -aai.servicedescription.mobility=MOBILITY -aai.servicedescription.vusp=VIRTUAL USP - -aai.notification.current.version=v7 -aai.notificationEvent.default.status=UNPROCESSED -aai.notificationEvent.default.eventType=AAI-EVENT -aai.notificationEvent.default.domain=devINT1 -aai.notificationEvent.default.sourceName=aai -aai.notificationEvent.default.sequenceNumber=0 -aai.notificationEvent.default.severity=NORMAL -aai.notificationEvent.default.version=v7 -# This one lets us enable/disable resource-version checking on updates/deletes -aai.resourceversion.enableflag=true -aai.logging.maxStackTraceEntries=10 -aai.default.api.version=v7 - - diff --git a/aai-resources/src/test/resources/updateEdgeTestRules.json b/aai-resources/src/test/resources/updateEdgeTestRules.json deleted file mode 100644 index 4da2b59..0000000 --- a/aai-resources/src/test/resources/updateEdgeTestRules.json +++ /dev/null @@ -1,60 +0,0 @@ -{ - "rules": [ - { - "from": "generic-vnf", - "to": "l-interface", - "label": "hasLInterface", - "direction": "OUT", - "multiplicity": "MANY2MANY", - "contains-other-v": "!${direction}", - "delete-other-v": "!${direction}", - "SVC-INFRA": "${direction}", - "prevent-delete": "NONE", - "description": "An edge comment", - "default": "true", - "newProperty": "newValue" - }, - { - "from": "pserver", - "to": "vnfc", - "label": "tosca.relationships.HostedOn", - "direction": "OUT", - "multiplicity": "MANY2MANY", - "contains-other-v": "!${direction}", - "delete-other-v": "!${direction}", - "SVC-INFRA": "${direction}", - "prevent-delete": "NONE", - "description": "A pserver/vnfc edge description", - "default": "true", - "newProperty": "newValue" - }, - { - "from": "l-interface", - "to": "logical-link", - "label": "usesLogicalLink", - "direction": "OUT", - "multiplicity": "MANY2MANY", - "contains-other-v": "!${direction}", - "delete-other-v": "!${direction}", - "SVC-INFRA": "${direction}", - "prevent-delete": "NONE", - "description": "A l-interface/logical-link(1) edge description", - "default": "true", - "newProperty": "newValue" - }, - { - "from": "l-interface", - "to": "logical-link", - "label": "sourceLInterface", - "direction": "OUT", - "multiplicity": "MANY2MANY", - "contains-other-v": "!${direction}", - "delete-other-v": "!${direction}", - "SVC-INFRA": "${direction}", - "prevent-delete": "NONE", - "description": "A l-interface/logical-link(2) edge description", - "default": "true", - "newProperty": "newValue" - } - ] -}
\ No newline at end of file |