diff options
author | 2017-08-16 10:43:43 -0400 | |
---|---|---|
committer | 2017-08-16 10:58:58 -0400 | |
commit | bb87ed1b5fcfb5393f2ab240fc429d497d6ffb6a (patch) | |
tree | 8671c88f8a42169677f41425b342a8c612ded3e3 /aai-core/src/main/java/org | |
parent | 8336d5e1b0c466ea5f1ca8aa01fc9d01ed91a059 (diff) |
[AAI-178 Amsterdam] Make Edge Properties to be
declared by direction
Change-Id: I8eacd870980c558e8c1f92b72f73c6f86aabc890
Signed-off-by: Maharajh, Robby (rx2202) <rx2202@att.com>
Diffstat (limited to 'aai-core/src/main/java/org')
74 files changed, 710 insertions, 736 deletions
diff --git a/aai-core/src/main/java/org/openecomp/aai/dbgen/DataGrooming.java b/aai-core/src/main/java/org/openecomp/aai/dbgen/DataGrooming.java index 88af8719..fb70f302 100644 --- a/aai-core/src/main/java/org/openecomp/aai/dbgen/DataGrooming.java +++ b/aai-core/src/main/java/org/openecomp/aai/dbgen/DataGrooming.java @@ -20,33 +20,15 @@ package org.openecomp.aai.dbgen; -import java.io.BufferedReader; -import java.io.BufferedWriter; -import java.io.File; -import java.io.FileReader; -import java.io.FileWriter; -import java.io.IOException; -import java.util.ArrayList; -import java.util.Collection; -import java.util.HashMap; -import java.util.Iterator; -import java.util.LinkedHashSet; -import java.util.List; -import java.util.Map; -import java.util.Map.Entry; -import java.util.Properties; -import java.util.Set; -import java.util.UUID; - +import com.att.eelf.configuration.Configuration; +import com.att.eelf.configuration.EELFLogger; +import com.att.eelf.configuration.EELFManager; +import com.thinkaurelius.titan.core.TitanFactory; +import com.thinkaurelius.titan.core.TitanGraph; import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversal; import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource; import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.__; -import org.apache.tinkerpop.gremlin.structure.Direction; -import org.apache.tinkerpop.gremlin.structure.Edge; -import org.apache.tinkerpop.gremlin.structure.Graph; -import org.apache.tinkerpop.gremlin.structure.Property; -import org.apache.tinkerpop.gremlin.structure.Vertex; -import org.apache.tinkerpop.gremlin.structure.VertexProperty; +import org.apache.tinkerpop.gremlin.structure.*; import org.openecomp.aai.db.props.AAIProperties; import org.openecomp.aai.dbmap.AAIGraph; import org.openecomp.aai.exceptions.AAIException; @@ -56,17 +38,15 @@ import org.openecomp.aai.introspection.LoaderFactory; import org.openecomp.aai.introspection.ModelType; import org.openecomp.aai.introspection.exceptions.AAIUnknownObjectException; import org.openecomp.aai.logging.ErrorLogHelper; -import org.openecomp.aai.serialization.db.EdgeProperties; +import org.openecomp.aai.serialization.db.AAIDirection; import org.openecomp.aai.serialization.db.EdgeProperty; import org.openecomp.aai.util.AAIConfig; import org.openecomp.aai.util.AAIConstants; import org.openecomp.aai.util.FormatDate; -import com.att.eelf.configuration.Configuration; -import com.att.eelf.configuration.EELFLogger; -import com.att.eelf.configuration.EELFManager; -import com.thinkaurelius.titan.core.TitanFactory; -import com.thinkaurelius.titan.core.TitanGraph; +import java.io.*; +import java.util.*; +import java.util.Map.Entry; public class DataGrooming { @@ -99,6 +79,11 @@ public class DataGrooming { Boolean ghost2CheckOff = false; Boolean ghost2FixOn = false; Boolean neverUseCache = false; + Boolean skipEdgeCheckFlag = false; + + 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 int maxRecordsToFix = AAIConstants.AAI_GROOMING_DEFAULT_MAX_FIX; int sleepMinutes = AAIConstants.AAI_GROOMING_DEFAULT_SLEEP_MINUTES; @@ -123,8 +108,15 @@ public class DataGrooming { String dteStr = fd.getDateTime(); String groomOutFileName = "dataGrooming." + dteStr + ".out"; + String argString = ""; + for( int x = 0; x < args.length; x++ ) { + argString = argString + " " + args[x]; + } + LOGGER.info(" DataGrooming called with these options: [" + argString + "]"); + if (args.length > 0) { // They passed some arguments in that will affect processing + for (int i = 0; i < args.length; i++) { String thisArg = args[i]; if (thisArg.equals("-edgesOnly")) { @@ -147,6 +139,8 @@ public class DataGrooming { neverUseCache = true; } else if (thisArg.equals("-ghost2FixOn")) { ghost2FixOn = true; + } else if (thisArg.equals("-skipEdgeChecks")) { + skipEdgeCheckFlag = true; } else if (thisArg.equals("-maxFix")) { i++; if (i >= args.length) { @@ -175,6 +169,25 @@ public class DataGrooming { + nextArg + "]"); System.exit(0); } + } else if (thisArg.equals("-timeWindowMinutes")) { + i++; + if (i >= args.length) { + LOGGER.error("No value passed with -timeWindowMinutes option."); + System.exit(0); + } + String nextArg = args[i]; + try { + timeWindowMinutes = Integer.parseInt(nextArg); + } catch (Exception e) { + LOGGER.error("Bad value passed with -timeWindowMinutes option: [" + + nextArg + "]"); + System.exit(0); + } + 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 ); + } } else if (thisArg.equals("-f")) { i++; if (i >= args.length) { @@ -213,7 +226,8 @@ public class DataGrooming { doTheGrooming(prevFileName, edgesOnlyFlag, dontFixOrphansFlag, maxRecordsToFix, groomOutFileName, ver, singleCommits, dupeCheckOff, dupeFixOn, ghost2CheckOff, ghost2FixOn, - finalShutdownFlag, cacheDbOkFlag); + finalShutdownFlag, cacheDbOkFlag, + skipEdgeCheckFlag, windowStartTime); } else if (doAutoFix) { // They want us to run the processing twice -- first to look for // delete candidates, then after @@ -228,7 +242,8 @@ public class DataGrooming { int fixCandCount = doTheGrooming("", edgesOnlyFlag, dontFixOrphansFlag, maxRecordsToFix, groomOutFileName, ver, singleCommits, dupeCheckOff, dupeFixOn, ghost2CheckOff, ghost2FixOn, - finalShutdownFlag, cacheDbOkFlag); + finalShutdownFlag, cacheDbOkFlag, + skipEdgeCheckFlag, windowStartTime); if (fixCandCount == 0) { LOGGER.info(" No fix-Candidates were found by the first pass, so no second/fix-pass is needed. "); } else { @@ -256,7 +271,8 @@ public class DataGrooming { dontFixOrphansFlag, maxRecordsToFix, secondGroomOutFileName, ver, singleCommits, dupeCheckOff, dupeFixOn, ghost2CheckOff, ghost2FixOn, - finalShutdownFlag, cacheDbOkFlag); + finalShutdownFlag, cacheDbOkFlag, + skipEdgeCheckFlag, windowStartTime); } } else { // Do the grooming - plain vanilla (no fix-it-file, no @@ -271,7 +287,8 @@ public class DataGrooming { doTheGrooming("", edgesOnlyFlag, dontFixOrphansFlag, maxRecordsToFix, groomOutFileName, ver, singleCommits, dupeCheckOff, dupeFixOn, ghost2CheckOff, ghost2FixOn, - finalShutdownFlag, cacheDbOkFlag); + finalShutdownFlag, cacheDbOkFlag, + skipEdgeCheckFlag, windowStartTime); } } catch (Exception ex) { LOGGER.error("Exception while grooming data", ex); @@ -306,7 +323,8 @@ public class DataGrooming { Boolean singleCommits, Boolean dupeCheckOff, Boolean dupeFixOn, Boolean ghost2CheckOff, Boolean ghost2FixOn, - Boolean finalShutdownFlag, Boolean cacheDbOkFlag) { + Boolean finalShutdownFlag, Boolean cacheDbOkFlag, + Boolean skipEdgeCheckFlag, long windowStartTime) { LOGGER.debug(" Entering doTheGrooming \n"); @@ -438,6 +456,18 @@ public class DataGrooming { LOGGER.debug("count for " + nType + " so far = " + thisNtCount ); } Vertex thisVtx = iter.next(); + if( windowStartTime > 0 ){ + // We only want nodes that are created after a passed-in timestamp + Object objTimeStamp = thisVtx.property("aai-created-ts").orElse(null); + if( objTimeStamp != null ){ + long thisNodeCreateTime = (long)objTimeStamp; + if( thisNodeCreateTime < windowStartTime ){ + // It is NOT in our window, so we can pass over it + continue; + } + } + } + String thisVid = thisVtx.id().toString(); if (processedVertices.contains(thisVid)) { LOGGER.debug("skipping already processed vertex: " + thisVid); @@ -479,7 +509,7 @@ public class DataGrooming { // This kind of node is dependent on another for uniqueness. // Start at it's parent (the dependent vertex) and make sure we can get it // back using it's key properties and that we only get one. - Iterator <Vertex> vertI2 = source1.V(thisVtx).union(__.inE().has(EdgeProperties.out(EdgeProperty.IS_PARENT), true).outV(), __.outE().has(EdgeProperties.in(EdgeProperty.IS_PARENT)).inV()); + Iterator <Vertex> vertI2 = source1.V(thisVtx).union(__.inE().has(EdgeProperty.CONTAINS.toString(), AAIDirection.OUT.toString()).outV(), __.outE().has(EdgeProperty.CONTAINS.toString(), AAIDirection.IN.toString()).inV()); Vertex parentVtx = null; int pCount = 0; while( vertI2 != null && vertI2.hasNext() ){ @@ -622,6 +652,7 @@ public class DataGrooming { }// end of check to make sure we weren't only supposed to do edges + if( !skipEdgeCheckFlag ){ // -------------------------------------------------------------------------------------- // Now, we're going to look for one-armed-edges. Ie. an edge that // should have @@ -686,6 +717,19 @@ public class DataGrooming { + ", since that guy is a Phantom Node"); continue; } + + if( windowStartTime > 0 ){ + // We only want to look at nodes that are created after a passed-in timestamp + Object objTimeStamp = v.property("aai-created-ts").orElse(null); + if( objTimeStamp != null ){ + long thisNodeCreateTime = (long)objTimeStamp; + if( thisNodeCreateTime < windowStartTime ){ + // It is NOT in our window, so we can pass over it + continue; + } + } + } + if (counter == lastShown + 250) { lastShown = counter; LOGGER.info("... Checking edges for vertex # " @@ -928,7 +972,9 @@ public class DataGrooming { } catch (Exception exx) { LOGGER.warn("WARNING from in the while-verts-loop ", exx); } - }// End of while-vertices-loop + }// End of while-vertices-loop (the edge-checking) + } // end of -- if we're not skipping the edge-checking + deleteCount = deleteCount + dupeGrpsDeleted; if (!singleCommits && deleteCount > 0) { @@ -972,13 +1018,13 @@ public class DataGrooming { + misMatchedHash.size() + "\n"); bw.write("\n ------------- Delete Candidates ---------\n"); - for (Map.Entry<String, Vertex> entry : ghostNodeHash + for (Entry<String, Vertex> entry : ghostNodeHash .entrySet()) { String vid = entry.getKey(); bw.write("DeleteCandidate: Phantom Vid = [" + vid + "]\n"); cleanupCandidateCount++; } - for (Map.Entry<String, Vertex> entry : orphanNodeHash + for (Entry<String, Vertex> entry : orphanNodeHash .entrySet()) { String vid = entry.getKey(); bw.write("DeleteCandidate: OrphanDepNode Vid = [" + vid + "]\n"); @@ -986,12 +1032,12 @@ public class DataGrooming { cleanupCandidateCount++; } } - for (Map.Entry<String, Edge> entry : oneArmedEdgeHash.entrySet()) { + for (Entry<String, Edge> entry : oneArmedEdgeHash.entrySet()) { String eid = entry.getKey(); bw.write("DeleteCandidate: Bad EDGE Edge-id = [" + eid + "]\n"); cleanupCandidateCount++; } - for (Map.Entry<String, Vertex> entry : missingDepNodeHash + for (Entry<String, Vertex> entry : missingDepNodeHash .entrySet()) { String vid = entry.getKey(); bw.write("DeleteCandidate: (maybe) missingDepNode Vid = [" @@ -1001,7 +1047,7 @@ public class DataGrooming { bw.write("\n-- NOTE - To see DeleteCandidates for Duplicates, you need to look in the Duplicates Detail section below.\n"); bw.write("\n ------------- GHOST NODES - detail "); - for (Map.Entry<String, Vertex> entry : ghostNodeHash + for (Entry<String, Vertex> entry : ghostNodeHash .entrySet()) { try { String vid = entry.getKey(); @@ -1023,7 +1069,7 @@ public class DataGrooming { } bw.write("\n ------------- Missing Dependent Edge ORPHAN NODES - detail: "); - for (Map.Entry<String, Vertex> entry : orphanNodeHash + for (Entry<String, Vertex> entry : orphanNodeHash .entrySet()) { try { String vid = entry.getKey(); @@ -1045,7 +1091,7 @@ public class DataGrooming { } bw.write("\n ------------- Missing Dependent Edge (but not orphan) NODES: "); - for (Map.Entry<String, Vertex> entry : missingDepNodeHash + for (Entry<String, Vertex> entry : missingDepNodeHash .entrySet()) { try { String vid = entry.getKey(); @@ -1068,7 +1114,7 @@ public class DataGrooming { } bw.write("\n ------------- EDGES pointing to empty/bad vertices: "); - for (Map.Entry<String, Edge> entry : oneArmedEdgeHash.entrySet()) { + for (Entry<String, Edge> entry : oneArmedEdgeHash.entrySet()) { try { String eid = entry.getKey(); Edge thisE = entry.getValue(); @@ -1168,7 +1214,7 @@ public class DataGrooming { }// while - work on each group of dupes bw.write("\n ------------- Mis-matched Label/aai-node-type Nodes: \n "); - for (Map.Entry<String, String> entry : misMatchedHash.entrySet()) { + for (Entry<String, String> entry : misMatchedHash.entrySet()) { String msg = entry.getValue(); bw.write("MixedMsg = " + msg + "\n"); } @@ -1274,7 +1320,7 @@ public class DataGrooming { while( it.hasNext() ){ String propName = ""; String propVal = ""; - Map.Entry <?,?>propEntry = (Map.Entry<?,?>)it.next(); + Entry <?,?>propEntry = (Entry<?,?>)it.next(); Object propNameObj = propEntry.getKey(); if( propNameObj != null ){ propName = propNameObj.toString(); @@ -1770,7 +1816,7 @@ public class DataGrooming { HashMap<String, ArrayList<Vertex>> vertsGroupedByParentHash = groupVertsByDepNodes( transId, fromAppId, source, version, nType, checkVertList, loader); - for (Map.Entry<String, ArrayList<Vertex>> entry : vertsGroupedByParentHash + for (Entry<String, ArrayList<Vertex>> entry : vertsGroupedByParentHash .entrySet()) { ArrayList<Vertex> thisParentsVertList = entry .getValue(); @@ -2020,7 +2066,7 @@ public class DataGrooming { } int i = -1; - for( Map.Entry<String, Object> entry : keyPropsHash.entrySet() ){ + for( Entry<String, Object> entry : keyPropsHash.entrySet() ){ i++; kName.add(i, entry.getKey()); kVal.add(i, entry.getValue()); @@ -2201,7 +2247,8 @@ public class DataGrooming { Vertex startVtx, String childNType ) throws AAIException{ ArrayList <Vertex> childList = new ArrayList <> (); - Iterator <Vertex> vertI = g.V(startVtx).union(__.outE().has(EdgeProperties.out(EdgeProperty.IS_PARENT), true), __.inE().has(EdgeProperties.in(EdgeProperty.IS_PARENT), true)).bothV(); + Iterator <Vertex> vertI = g.V(startVtx).union(__.outE().has(EdgeProperty.CONTAINS.toString(), AAIDirection.OUT.toString()).inV(), __.inE().has(EdgeProperty.CONTAINS.toString(), AAIDirection.IN.toString()).outV()); + Vertex tmpVtx = null; while( vertI != null && vertI.hasNext() ){ tmpVtx = vertI.next(); @@ -2223,7 +2270,8 @@ public class DataGrooming { Vertex startVtx ) throws AAIException{ Vertex parentVtx = null; - Iterator <Vertex> vertI = g.V(startVtx).union(__.inE().has(EdgeProperties.out(EdgeProperty.IS_PARENT), true), __.outE().has(EdgeProperties.in(EdgeProperty.IS_PARENT), true)).bothV(); + Iterator <Vertex> vertI = g.V(startVtx).union(__.inE().has(EdgeProperty.CONTAINS.toString(), AAIDirection.OUT.toString()).outV(), __.outE().has(EdgeProperty.CONTAINS.toString(), AAIDirection.IN.toString()).inV()); + while( vertI != null && vertI.hasNext() ){ // Note - there better only be one! parentVtx = vertI.next(); @@ -2234,4 +2282,20 @@ public class DataGrooming { }// End of getConnectedParent() + 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 * 60 * 1000; + + long startTimeStamp = unixTimeNow - windowInMillis; + + return startTimeStamp; + } // End of figureWindowStartTime() + + } diff --git a/aai-core/src/main/java/org/openecomp/aai/dbgen/GenTester.java b/aai-core/src/main/java/org/openecomp/aai/dbgen/GenTester.java index 14c58cb5..7847d3d6 100644 --- a/aai-core/src/main/java/org/openecomp/aai/dbgen/GenTester.java +++ b/aai-core/src/main/java/org/openecomp/aai/dbgen/GenTester.java @@ -20,19 +20,17 @@ package org.openecomp.aai.dbgen; -import java.util.Properties; - -import org.openecomp.aai.dbmap.AAIGraph; -import org.openecomp.aai.logging.ErrorLogHelper; -import org.openecomp.aai.util.AAIConfig; -import org.openecomp.aai.util.AAIConstants; import com.att.eelf.configuration.Configuration; import com.att.eelf.configuration.EELFLogger; import com.att.eelf.configuration.EELFManager; import com.thinkaurelius.titan.core.TitanGraph; import com.thinkaurelius.titan.core.schema.TitanManagement; +import org.openecomp.aai.dbmap.AAIGraph; +import org.openecomp.aai.logging.ErrorLogHelper; +import org.openecomp.aai.util.AAIConfig; +import org.openecomp.aai.util.AAIConstants; - +import java.util.Properties; public class GenTester { diff --git a/aai-core/src/main/java/org/openecomp/aai/dbgen/SchemaGenerator.java b/aai-core/src/main/java/org/openecomp/aai/dbgen/SchemaGenerator.java index 9f85d029..165c7029 100644 --- a/aai-core/src/main/java/org/openecomp/aai/dbgen/SchemaGenerator.java +++ b/aai-core/src/main/java/org/openecomp/aai/dbgen/SchemaGenerator.java @@ -21,12 +21,14 @@ package org.openecomp.aai.dbgen; -import java.util.HashMap; -import java.util.HashSet; -import java.util.Map; -import java.util.Optional; -import java.util.Set; - +import com.att.eelf.configuration.EELFLogger; +import com.att.eelf.configuration.EELFManager; +import com.google.common.collect.Multimap; +import com.thinkaurelius.titan.core.Cardinality; +import com.thinkaurelius.titan.core.Multiplicity; +import com.thinkaurelius.titan.core.PropertyKey; +import com.thinkaurelius.titan.core.TitanGraph; +import com.thinkaurelius.titan.core.schema.TitanManagement; import org.apache.tinkerpop.gremlin.structure.Vertex; import org.openecomp.aai.db.props.AAIProperties; import org.openecomp.aai.introspection.Introspector; @@ -38,15 +40,7 @@ import org.openecomp.aai.serialization.db.EdgeRule; import org.openecomp.aai.serialization.db.EdgeRules; import org.openecomp.aai.util.AAIConfig; -import com.att.eelf.configuration.EELFLogger; -import com.att.eelf.configuration.EELFManager; -import com.google.common.collect.Multimap; -import com.thinkaurelius.titan.core.Cardinality; -import com.thinkaurelius.titan.core.Multiplicity; -import com.thinkaurelius.titan.core.PropertyKey; -import com.thinkaurelius.titan.core.TitanGraph; -import com.thinkaurelius.titan.core.schema.TitanManagement; - +import java.util.*; public class SchemaGenerator{ @@ -186,6 +180,28 @@ public class SchemaGenerator{ LOGGER.info(imsg); graphMgmt.commit(); + if (addDefaultCR) { + if (!graph.traversal().V().has("cloud-owner", "att-aic").has("cloud-region-id", "AAIAIC25").hasNext()) { + imsg = "Adding default cloud region to graph..."; + System.out.println(imsg); + LOGGER.info(imsg); + final Vertex cloudRegion = graph.addVertex(); + + final String ts = String.valueOf(System.currentTimeMillis() / 1000L); + + cloudRegion.property("aai-node-type", "cloud-region"); + cloudRegion.property("cloud-owner", "att-aic"); + cloudRegion.property("cloud-region-id", "AAIAIC25"); + cloudRegion.property("cloud-region-version", "2.5"); + cloudRegion.property("complex-name", "AAIAIC25"); + cloudRegion.property("aai-created-ts", ts); + cloudRegion.property("resource-version", ts); + cloudRegion.property("source-of-truth", "aai-schema-loader"); + cloudRegion.property("last-mod-source-of-truth", "aai-schema-loader"); + cloudRegion.property(AAIProperties.AAI_URI, "/cloud-infrastructure/cloud-regions/cloud-region/att-aic/AAIAIC25"); + graph.tx().commit(); + } + } }// End of loadSchemaIntoTitan() } diff --git a/aai-core/src/main/java/org/openecomp/aai/dbmodel/ConvertDeleteScope.java b/aai-core/src/main/java/org/openecomp/aai/dbmodel/ConvertDeleteScope.java index c8eeedf7..7fbf3954 100644 --- a/aai-core/src/main/java/org/openecomp/aai/dbmodel/ConvertDeleteScope.java +++ b/aai-core/src/main/java/org/openecomp/aai/dbmodel/ConvertDeleteScope.java @@ -5,16 +5,16 @@ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. * ============LICENSE_END========================================================= */ diff --git a/aai-core/src/main/java/org/openecomp/aai/introspection/Introspector.java b/aai-core/src/main/java/org/openecomp/aai/introspection/Introspector.java index 78f59844..1c8baa10 100644 --- a/aai-core/src/main/java/org/openecomp/aai/introspection/Introspector.java +++ b/aai-core/src/main/java/org/openecomp/aai/introspection/Introspector.java @@ -20,17 +20,9 @@ package org.openecomp.aai.introspection; -import java.io.UnsupportedEncodingException; -import java.lang.reflect.InvocationTargetException; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collections; -import java.util.LinkedHashSet; -import java.util.List; -import java.util.Map; -import java.util.Optional; -import java.util.Set; - +import com.att.eelf.configuration.EELFLogger; +import com.att.eelf.configuration.EELFManager; +import com.google.common.base.CaseFormat; import org.apache.commons.lang.ClassUtils; import org.eclipse.persistence.exceptions.DynamicException; import org.openecomp.aai.introspection.exceptions.AAIUnknownObjectException; @@ -40,9 +32,9 @@ import org.openecomp.aai.schema.enums.ObjectMetadata; import org.openecomp.aai.schema.enums.PropertyMetadata; import org.openecomp.aai.workarounds.NamingExceptions; -import com.att.eelf.configuration.EELFLogger; -import com.att.eelf.configuration.EELFManager; -import com.google.common.base.CaseFormat; +import java.io.UnsupportedEncodingException; +import java.lang.reflect.InvocationTargetException; +import java.util.*; public abstract class Introspector implements Cloneable { diff --git a/aai-core/src/main/java/org/openecomp/aai/introspection/IntrospectorWalker.java b/aai-core/src/main/java/org/openecomp/aai/introspection/IntrospectorWalker.java index 8bea4dce..8eddac3b 100644 --- a/aai-core/src/main/java/org/openecomp/aai/introspection/IntrospectorWalker.java +++ b/aai-core/src/main/java/org/openecomp/aai/introspection/IntrospectorWalker.java @@ -20,16 +20,16 @@ package org.openecomp.aai.introspection; +import com.att.eelf.configuration.EELFLogger; +import com.att.eelf.configuration.EELFManager; +import org.openecomp.aai.exceptions.AAIException; +import org.openecomp.aai.introspection.exceptions.AAIUnknownObjectException; + import java.util.HashSet; import java.util.LinkedHashSet; import java.util.List; import java.util.Set; -import org.openecomp.aai.exceptions.AAIException; -import org.openecomp.aai.introspection.exceptions.AAIUnknownObjectException; -import com.att.eelf.configuration.EELFLogger; -import com.att.eelf.configuration.EELFManager; - public class IntrospectorWalker { private static final EELFLogger LOGGER = EELFManager.getInstance().getLogger(IntrospectorWalker.class); diff --git a/aai-core/src/main/java/org/openecomp/aai/introspection/JSONStrategy.java b/aai-core/src/main/java/org/openecomp/aai/introspection/JSONStrategy.java index bec1af6c..7dae20ee 100644 --- a/aai-core/src/main/java/org/openecomp/aai/introspection/JSONStrategy.java +++ b/aai-core/src/main/java/org/openecomp/aai/introspection/JSONStrategy.java @@ -20,17 +20,16 @@ package org.openecomp.aai.introspection; +import org.json.simple.JSONObject; +import org.openecomp.aai.schema.enums.ObjectMetadata; +import org.openecomp.aai.schema.enums.PropertyMetadata; + import java.io.UnsupportedEncodingException; import java.util.List; import java.util.Map; import java.util.Set; import java.util.UUID; -import org.json.simple.JSONObject; - -import org.openecomp.aai.schema.enums.ObjectMetadata; -import org.openecomp.aai.schema.enums.PropertyMetadata; - public class JSONStrategy extends Introspector { private JSONObject json = null; diff --git a/aai-core/src/main/java/org/openecomp/aai/introspection/Loader.java b/aai-core/src/main/java/org/openecomp/aai/introspection/Loader.java index 13b0ccaa..b5a029ed 100644 --- a/aai-core/src/main/java/org/openecomp/aai/introspection/Loader.java +++ b/aai-core/src/main/java/org/openecomp/aai/introspection/Loader.java @@ -20,12 +20,12 @@ package org.openecomp.aai.introspection; -import java.util.Map; - import org.openecomp.aai.introspection.exceptions.AAIUnknownObjectException; import org.openecomp.aai.introspection.exceptions.AAIUnmarshallingException; import org.openecomp.aai.restcore.MediaType; +import java.util.Map; + public abstract class Loader { private final Version version; diff --git a/aai-core/src/main/java/org/openecomp/aai/introspection/ModelInjestor.java b/aai-core/src/main/java/org/openecomp/aai/introspection/ModelInjestor.java index a8574d89..c6503a69 100644 --- a/aai-core/src/main/java/org/openecomp/aai/introspection/ModelInjestor.java +++ b/aai-core/src/main/java/org/openecomp/aai/introspection/ModelInjestor.java @@ -20,6 +20,13 @@ package org.openecomp.aai.introspection; +import org.eclipse.persistence.dynamic.DynamicType; +import org.eclipse.persistence.jaxb.JAXBContextProperties; +import org.eclipse.persistence.jaxb.dynamic.DynamicJAXBContext; +import org.eclipse.persistence.jaxb.dynamic.DynamicJAXBContextFactory; +import org.openecomp.aai.util.AAIConstants; + +import javax.xml.bind.JAXBException; import java.io.File; import java.io.FileInputStream; import java.io.FileNotFoundException; @@ -29,15 +36,6 @@ import java.util.Map; import java.util.regex.Matcher; import java.util.regex.Pattern; -import javax.xml.bind.JAXBException; - -import org.eclipse.persistence.dynamic.DynamicType; -import org.eclipse.persistence.jaxb.JAXBContextProperties; -import org.eclipse.persistence.jaxb.dynamic.DynamicJAXBContext; -import org.eclipse.persistence.jaxb.dynamic.DynamicJAXBContextFactory; - -import org.openecomp.aai.util.AAIConstants; - public class ModelInjestor { private Map<Version, DynamicJAXBContext> versionContextMap = new HashMap<>(); diff --git a/aai-core/src/main/java/org/openecomp/aai/introspection/MoxyLoader.java b/aai-core/src/main/java/org/openecomp/aai/introspection/MoxyLoader.java index 9163f297..80b05aee 100644 --- a/aai-core/src/main/java/org/openecomp/aai/introspection/MoxyLoader.java +++ b/aai-core/src/main/java/org/openecomp/aai/introspection/MoxyLoader.java @@ -20,20 +20,10 @@ package org.openecomp.aai.introspection; -import java.io.IOException; -import java.io.StringReader; -import java.util.HashSet; -import java.util.Map; -import java.util.Set; - -import javax.xml.XMLConstants; -import javax.xml.bind.JAXBException; -import javax.xml.bind.Unmarshaller; -import javax.xml.parsers.DocumentBuilder; -import javax.xml.parsers.DocumentBuilderFactory; -import javax.xml.parsers.ParserConfigurationException; -import javax.xml.transform.stream.StreamSource; - +import com.att.eelf.configuration.EELFLogger; +import com.att.eelf.configuration.EELFManager; +import com.google.common.base.CaseFormat; +import com.google.common.collect.ImmutableMap; import org.eclipse.persistence.dynamic.DynamicEntity; import org.eclipse.persistence.jaxb.UnmarshallerProperties; import org.eclipse.persistence.jaxb.dynamic.DynamicJAXBContext; @@ -47,10 +37,18 @@ import org.w3c.dom.Document; import org.w3c.dom.NodeList; import org.xml.sax.SAXException; -import com.att.eelf.configuration.EELFLogger; -import com.att.eelf.configuration.EELFManager; -import com.google.common.base.CaseFormat; -import com.google.common.collect.ImmutableMap; +import javax.xml.XMLConstants; +import javax.xml.bind.JAXBException; +import javax.xml.bind.Unmarshaller; +import javax.xml.parsers.DocumentBuilder; +import javax.xml.parsers.DocumentBuilderFactory; +import javax.xml.parsers.ParserConfigurationException; +import javax.xml.transform.stream.StreamSource; +import java.io.IOException; +import java.io.StringReader; +import java.util.HashSet; +import java.util.Map; +import java.util.Set; public class MoxyLoader extends Loader { @@ -186,7 +184,7 @@ public class MoxyLoader extends Loader { LOGGER.warn("Exception while enumerating objects for API version " + getVersion() + " (returning partial results)", e); } - result.remove("EdgePropNames"); + //result.remove("EdgePropNames"); return result; } diff --git a/aai-core/src/main/java/org/openecomp/aai/introspection/MoxyStrategy.java b/aai-core/src/main/java/org/openecomp/aai/introspection/MoxyStrategy.java index 5b9e1051..b3cda8d3 100644 --- a/aai-core/src/main/java/org/openecomp/aai/introspection/MoxyStrategy.java +++ b/aai-core/src/main/java/org/openecomp/aai/introspection/MoxyStrategy.java @@ -20,24 +20,8 @@ package org.openecomp.aai.introspection; -import java.io.StringReader; -import java.io.StringWriter; -import java.io.UnsupportedEncodingException; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collections; -import java.util.HashMap; -import java.util.LinkedHashSet; -import java.util.List; -import java.util.Map; -import java.util.Map.Entry; -import java.util.Set; - -import javax.xml.bind.JAXBException; -import javax.xml.bind.Marshaller; -import javax.xml.bind.Unmarshaller; -import javax.xml.transform.stream.StreamSource; - +import com.google.common.base.CaseFormat; +import com.google.common.base.Joiner; import org.eclipse.persistence.descriptors.ClassDescriptor; import org.eclipse.persistence.dynamic.DynamicEntity; import org.eclipse.persistence.dynamic.DynamicType; @@ -48,13 +32,20 @@ import org.eclipse.persistence.mappings.DatabaseMapping; import org.eclipse.persistence.oxm.XMLField; import org.eclipse.persistence.oxm.mappings.XMLCompositeCollectionMapping; import org.eclipse.persistence.oxm.mappings.XMLCompositeDirectCollectionMapping; -import org.springframework.web.util.UriUtils; - import org.openecomp.aai.restcore.MediaType; import org.openecomp.aai.schema.enums.ObjectMetadata; import org.openecomp.aai.schema.enums.PropertyMetadata; -import com.google.common.base.CaseFormat; -import com.google.common.base.Joiner; +import org.springframework.web.util.UriUtils; + +import javax.xml.bind.JAXBException; +import javax.xml.bind.Marshaller; +import javax.xml.bind.Unmarshaller; +import javax.xml.transform.stream.StreamSource; +import java.io.StringReader; +import java.io.StringWriter; +import java.io.UnsupportedEncodingException; +import java.util.*; +import java.util.Map.Entry; public class MoxyStrategy extends Introspector { diff --git a/aai-core/src/main/java/org/openecomp/aai/introspection/PojoInjestor.java b/aai-core/src/main/java/org/openecomp/aai/introspection/PojoInjestor.java index 56d4368e..3eea2420 100644 --- a/aai-core/src/main/java/org/openecomp/aai/introspection/PojoInjestor.java +++ b/aai-core/src/main/java/org/openecomp/aai/introspection/PojoInjestor.java @@ -20,15 +20,13 @@ package org.openecomp.aai.introspection; -import java.util.regex.Matcher; -import java.util.regex.Pattern; +import org.eclipse.persistence.jaxb.JAXBContextFactory; +import org.openecomp.aai.db.props.AAIProperties; import javax.xml.bind.JAXBContext; import javax.xml.bind.JAXBException; - -import org.eclipse.persistence.jaxb.JAXBContextFactory; - -import org.openecomp.aai.db.props.AAIProperties; +import java.util.regex.Matcher; +import java.util.regex.Pattern; public class PojoInjestor { diff --git a/aai-core/src/main/java/org/openecomp/aai/introspection/PojoLoader.java b/aai-core/src/main/java/org/openecomp/aai/introspection/PojoLoader.java index dec830a9..927ac4bc 100644 --- a/aai-core/src/main/java/org/openecomp/aai/introspection/PojoLoader.java +++ b/aai-core/src/main/java/org/openecomp/aai/introspection/PojoLoader.java @@ -20,14 +20,9 @@ package org.openecomp.aai.introspection; -import java.io.StringReader; -import java.util.Map; - -import javax.xml.bind.JAXBContext; -import javax.xml.bind.JAXBException; -import javax.xml.bind.Unmarshaller; -import javax.xml.transform.stream.StreamSource; - +import com.att.eelf.configuration.EELFLogger; +import com.att.eelf.configuration.EELFManager; +import com.google.common.base.CaseFormat; import org.eclipse.persistence.jaxb.JAXBContextFactory; import org.eclipse.persistence.jaxb.UnmarshallerProperties; import org.openecomp.aai.db.props.AAIProperties; @@ -37,9 +32,12 @@ import org.openecomp.aai.logging.ErrorLogHelper; import org.openecomp.aai.restcore.MediaType; import org.openecomp.aai.workarounds.NamingExceptions; -import com.att.eelf.configuration.EELFLogger; -import com.att.eelf.configuration.EELFManager; -import com.google.common.base.CaseFormat; +import javax.xml.bind.JAXBContext; +import javax.xml.bind.JAXBException; +import javax.xml.bind.Unmarshaller; +import javax.xml.transform.stream.StreamSource; +import java.io.StringReader; +import java.util.Map; public class PojoLoader extends Loader { diff --git a/aai-core/src/main/java/org/openecomp/aai/introspection/PojoStrategy.java b/aai-core/src/main/java/org/openecomp/aai/introspection/PojoStrategy.java index 4b8266b9..7f114bd3 100644 --- a/aai-core/src/main/java/org/openecomp/aai/introspection/PojoStrategy.java +++ b/aai-core/src/main/java/org/openecomp/aai/introspection/PojoStrategy.java @@ -20,21 +20,15 @@ package org.openecomp.aai.introspection; -import java.io.StringReader; -import java.io.StringWriter; -import java.lang.reflect.Field; -import java.lang.reflect.InvocationTargetException; -import java.lang.reflect.Method; -import java.lang.reflect.ParameterizedType; -import java.lang.reflect.Type; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collections; -import java.util.HashMap; -import java.util.LinkedHashSet; -import java.util.List; -import java.util.Map; -import java.util.Set; +import com.google.common.base.CaseFormat; +import com.google.common.base.Joiner; +import com.google.common.collect.Multimap; +import org.eclipse.persistence.jaxb.UnmarshallerProperties; +import org.openecomp.aai.annotations.Metadata; +import org.openecomp.aai.logging.ErrorLogHelper; +import org.openecomp.aai.restcore.MediaType; +import org.openecomp.aai.schema.enums.ObjectMetadata; +import org.openecomp.aai.schema.enums.PropertyMetadata; import javax.xml.bind.JAXBContext; import javax.xml.bind.JAXBException; @@ -42,17 +36,10 @@ import javax.xml.bind.Marshaller; import javax.xml.bind.Unmarshaller; import javax.xml.bind.annotation.XmlElement; import javax.xml.transform.stream.StreamSource; - -import org.eclipse.persistence.jaxb.UnmarshallerProperties; - -import org.openecomp.aai.annotations.Metadata; -import org.openecomp.aai.logging.ErrorLogHelper; -import org.openecomp.aai.restcore.MediaType; -import org.openecomp.aai.schema.enums.ObjectMetadata; -import org.openecomp.aai.schema.enums.PropertyMetadata; -import com.google.common.base.CaseFormat; -import com.google.common.base.Joiner; -import com.google.common.collect.Multimap; +import java.io.StringReader; +import java.io.StringWriter; +import java.lang.reflect.*; +import java.util.*; public class PojoStrategy extends Introspector { diff --git a/aai-core/src/main/java/org/openecomp/aai/introspection/PropertyPredicate.java b/aai-core/src/main/java/org/openecomp/aai/introspection/PropertyPredicate.java index 1f03cc41..38bdf82c 100644 --- a/aai-core/src/main/java/org/openecomp/aai/introspection/PropertyPredicate.java +++ b/aai-core/src/main/java/org/openecomp/aai/introspection/PropertyPredicate.java @@ -21,7 +21,6 @@ package org.openecomp.aai.introspection; import java.util.function.BiPredicate; -import java.util.function.Predicate; public interface PropertyPredicate<T, U> extends BiPredicate<T, U> { diff --git a/aai-core/src/main/java/org/openecomp/aai/introspection/PropertyPredicates.java b/aai-core/src/main/java/org/openecomp/aai/introspection/PropertyPredicates.java index c9d7866c..c7bbb0c0 100644 --- a/aai-core/src/main/java/org/openecomp/aai/introspection/PropertyPredicates.java +++ b/aai-core/src/main/java/org/openecomp/aai/introspection/PropertyPredicates.java @@ -20,11 +20,11 @@ package org.openecomp.aai.introspection; +import org.openecomp.aai.schema.enums.PropertyMetadata; + import java.util.Map; import java.util.Set; -import org.openecomp.aai.schema.enums.PropertyMetadata; - public final class PropertyPredicates { private PropertyPredicates() { diff --git a/aai-core/src/main/java/org/openecomp/aai/introspection/Version.java b/aai-core/src/main/java/org/openecomp/aai/introspection/Version.java index 8c7998b5..9e1fab2a 100644 --- a/aai-core/src/main/java/org/openecomp/aai/introspection/Version.java +++ b/aai-core/src/main/java/org/openecomp/aai/introspection/Version.java @@ -23,7 +23,7 @@ package org.openecomp.aai.introspection; public enum Version { v8, v9, - v10, + v10, v11; public static boolean isLatest(Version v) { diff --git a/aai-core/src/main/java/org/openecomp/aai/introspection/Wanderer.java b/aai-core/src/main/java/org/openecomp/aai/introspection/Wanderer.java index 327bbacc..5429d999 100644 --- a/aai-core/src/main/java/org/openecomp/aai/introspection/Wanderer.java +++ b/aai-core/src/main/java/org/openecomp/aai/introspection/Wanderer.java @@ -20,10 +20,10 @@ package org.openecomp.aai.introspection; -import java.util.List; - import org.openecomp.aai.exceptions.AAIException; +import java.util.List; + public interface Wanderer { /** diff --git a/aai-core/src/main/java/org/openecomp/aai/introspection/generator/CreateExample.java b/aai-core/src/main/java/org/openecomp/aai/introspection/generator/CreateExample.java index fd258460..1b3444fd 100644 --- a/aai-core/src/main/java/org/openecomp/aai/introspection/generator/CreateExample.java +++ b/aai-core/src/main/java/org/openecomp/aai/introspection/generator/CreateExample.java @@ -20,17 +20,13 @@ package org.openecomp.aai.introspection.generator; +import org.openecomp.aai.exceptions.AAIException; +import org.openecomp.aai.introspection.*; + import java.security.SecureRandom; import java.util.ArrayList; import java.util.List; -import org.openecomp.aai.exceptions.AAIException; -import org.openecomp.aai.introspection.Introspector; -import org.openecomp.aai.introspection.IntrospectorWalker; -import org.openecomp.aai.introspection.Loader; -import org.openecomp.aai.introspection.PropertyPredicates; -import org.openecomp.aai.introspection.Wanderer; - public class CreateExample implements Wanderer { private SecureRandom rand = new SecureRandom(); diff --git a/aai-core/src/main/java/org/openecomp/aai/introspection/sideeffect/DataCopy.java b/aai-core/src/main/java/org/openecomp/aai/introspection/sideeffect/DataCopy.java index e9a439dd..53c85013 100644 --- a/aai-core/src/main/java/org/openecomp/aai/introspection/sideeffect/DataCopy.java +++ b/aai-core/src/main/java/org/openecomp/aai/introspection/sideeffect/DataCopy.java @@ -20,19 +20,7 @@ package org.openecomp.aai.introspection.sideeffect; -import java.io.UnsupportedEncodingException; -import java.net.URI; -import java.net.URISyntaxException; -import java.util.Collections; -import java.util.List; -import java.util.Map.Entry; -import java.util.Objects; -import java.util.Optional; - -import javax.ws.rs.core.MultivaluedMap; - import org.apache.tinkerpop.gremlin.structure.Vertex; - import org.openecomp.aai.exceptions.AAIException; import org.openecomp.aai.introspection.Introspector; import org.openecomp.aai.introspection.sideeffect.exceptions.AAIMissingRequiredPropertyException; @@ -43,6 +31,16 @@ import org.openecomp.aai.schema.enums.PropertyMetadata; import org.openecomp.aai.serialization.db.DBSerializer; import org.openecomp.aai.serialization.engines.TransactionalGraphEngine; +import javax.ws.rs.core.MultivaluedMap; +import java.io.UnsupportedEncodingException; +import java.net.URI; +import java.net.URISyntaxException; +import java.util.Collections; +import java.util.List; +import java.util.Map.Entry; +import java.util.Objects; +import java.util.Optional; + public class DataCopy extends SideEffect { diff --git a/aai-core/src/main/java/org/openecomp/aai/introspection/sideeffect/DataLinkReader.java b/aai-core/src/main/java/org/openecomp/aai/introspection/sideeffect/DataLinkReader.java index db3dd5ac..89b03eab 100644 --- a/aai-core/src/main/java/org/openecomp/aai/introspection/sideeffect/DataLinkReader.java +++ b/aai-core/src/main/java/org/openecomp/aai/introspection/sideeffect/DataLinkReader.java @@ -20,20 +20,7 @@ package org.openecomp.aai.introspection.sideeffect; -import java.io.UnsupportedEncodingException; -import java.net.URI; -import java.net.URISyntaxException; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Map.Entry; -import java.util.Optional; -import java.util.regex.Matcher; - -import javax.ws.rs.core.MultivaluedMap; - import org.apache.tinkerpop.gremlin.structure.Vertex; - import org.openecomp.aai.db.props.AAIProperties; import org.openecomp.aai.exceptions.AAIException; import org.openecomp.aai.introspection.Introspector; @@ -44,6 +31,17 @@ import org.openecomp.aai.schema.enums.PropertyMetadata; import org.openecomp.aai.serialization.db.DBSerializer; import org.openecomp.aai.serialization.engines.TransactionalGraphEngine; +import javax.ws.rs.core.MultivaluedMap; +import java.io.UnsupportedEncodingException; +import java.net.URI; +import java.net.URISyntaxException; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; +import java.util.Optional; +import java.util.regex.Matcher; + public class DataLinkReader extends SideEffect { public DataLinkReader(Introspector obj, Vertex self, TransactionalGraphEngine dbEngine, DBSerializer serializer) { diff --git a/aai-core/src/main/java/org/openecomp/aai/introspection/sideeffect/DataLinkWriter.java b/aai-core/src/main/java/org/openecomp/aai/introspection/sideeffect/DataLinkWriter.java index 3f070153..6e93098d 100644 --- a/aai-core/src/main/java/org/openecomp/aai/introspection/sideeffect/DataLinkWriter.java +++ b/aai-core/src/main/java/org/openecomp/aai/introspection/sideeffect/DataLinkWriter.java @@ -20,17 +20,7 @@ package org.openecomp.aai.introspection.sideeffect; -import java.io.UnsupportedEncodingException; -import java.net.URI; -import java.net.URISyntaxException; -import java.util.List; -import java.util.Map.Entry; -import java.util.Optional; - -import javax.ws.rs.core.MultivaluedMap; - import org.apache.tinkerpop.gremlin.structure.Vertex; - import org.openecomp.aai.db.props.AAIProperties; import org.openecomp.aai.exceptions.AAIException; import org.openecomp.aai.introspection.Introspector; @@ -42,6 +32,14 @@ import org.openecomp.aai.schema.enums.PropertyMetadata; import org.openecomp.aai.serialization.db.DBSerializer; import org.openecomp.aai.serialization.engines.TransactionalGraphEngine; +import javax.ws.rs.core.MultivaluedMap; +import java.io.UnsupportedEncodingException; +import java.net.URI; +import java.net.URISyntaxException; +import java.util.List; +import java.util.Map.Entry; +import java.util.Optional; + public class DataLinkWriter extends SideEffect { public DataLinkWriter(Introspector obj, Vertex self, TransactionalGraphEngine dbEngine, DBSerializer serializer) { diff --git a/aai-core/src/main/java/org/openecomp/aai/introspection/sideeffect/SideEffect.java b/aai-core/src/main/java/org/openecomp/aai/introspection/sideeffect/SideEffect.java index 92402e32..95da72f3 100644 --- a/aai-core/src/main/java/org/openecomp/aai/introspection/sideeffect/SideEffect.java +++ b/aai-core/src/main/java/org/openecomp/aai/introspection/sideeffect/SideEffect.java @@ -20,19 +20,7 @@ package org.openecomp.aai.introspection.sideeffect; -import java.io.UnsupportedEncodingException; -import java.net.URISyntaxException; -import java.util.HashMap; -import java.util.LinkedHashSet; -import java.util.Map; -import java.util.Map.Entry; -import java.util.Optional; -import java.util.Set; -import java.util.regex.Matcher; -import java.util.regex.Pattern; - import org.apache.tinkerpop.gremlin.structure.Vertex; - import org.openecomp.aai.db.props.AAIProperties; import org.openecomp.aai.exceptions.AAIException; import org.openecomp.aai.introspection.Introspector; @@ -44,6 +32,13 @@ import org.openecomp.aai.schema.enums.PropertyMetadata; import org.openecomp.aai.serialization.db.DBSerializer; import org.openecomp.aai.serialization.engines.TransactionalGraphEngine; +import java.io.UnsupportedEncodingException; +import java.net.URISyntaxException; +import java.util.*; +import java.util.Map.Entry; +import java.util.regex.Matcher; +import java.util.regex.Pattern; + public abstract class SideEffect { protected static final Pattern template = Pattern.compile("\\{(.*?)\\}"); diff --git a/aai-core/src/main/java/org/openecomp/aai/introspection/sideeffect/SideEffectRunner.java b/aai-core/src/main/java/org/openecomp/aai/introspection/sideeffect/SideEffectRunner.java index 64a4d0cd..3b33be1f 100644 --- a/aai-core/src/main/java/org/openecomp/aai/introspection/sideeffect/SideEffectRunner.java +++ b/aai-core/src/main/java/org/openecomp/aai/introspection/sideeffect/SideEffectRunner.java @@ -20,19 +20,18 @@ package org.openecomp.aai.introspection.sideeffect; -import java.io.UnsupportedEncodingException; -import java.lang.reflect.InvocationTargetException; -import java.net.URISyntaxException; -import java.util.LinkedHashSet; -import java.util.Set; - import org.apache.tinkerpop.gremlin.structure.Vertex; - import org.openecomp.aai.exceptions.AAIException; import org.openecomp.aai.introspection.Introspector; import org.openecomp.aai.serialization.db.DBSerializer; import org.openecomp.aai.serialization.engines.TransactionalGraphEngine; +import java.io.UnsupportedEncodingException; +import java.lang.reflect.InvocationTargetException; +import java.net.URISyntaxException; +import java.util.LinkedHashSet; +import java.util.Set; + public class SideEffectRunner { protected final TransactionalGraphEngine dbEngine; diff --git a/aai-core/src/main/java/org/openecomp/aai/introspection/sideeffect/SideEffectRunnerHelper.java b/aai-core/src/main/java/org/openecomp/aai/introspection/sideeffect/SideEffectRunnerHelper.java index 8a55ce82..d94cd4a1 100644 --- a/aai-core/src/main/java/org/openecomp/aai/introspection/sideeffect/SideEffectRunnerHelper.java +++ b/aai-core/src/main/java/org/openecomp/aai/introspection/sideeffect/SideEffectRunnerHelper.java @@ -20,18 +20,18 @@ package org.openecomp.aai.introspection.sideeffect; -import java.io.UnsupportedEncodingException; -import java.lang.reflect.InvocationTargetException; -import java.net.URISyntaxException; -import java.util.List; -import java.util.Set; - import org.openecomp.aai.exceptions.AAIException; import org.openecomp.aai.introspection.Introspector; import org.openecomp.aai.introspection.Wanderer; import org.openecomp.aai.serialization.db.DBSerializer; import org.openecomp.aai.serialization.engines.TransactionalGraphEngine; +import java.io.UnsupportedEncodingException; +import java.lang.reflect.InvocationTargetException; +import java.net.URISyntaxException; +import java.util.List; +import java.util.Set; + class SideEffectRunnerHelper implements Wanderer { diff --git a/aai-core/src/main/java/org/openecomp/aai/introspection/tools/CreateUUID.java b/aai-core/src/main/java/org/openecomp/aai/introspection/tools/CreateUUID.java index 1d0c6033..f88a099c 100644 --- a/aai-core/src/main/java/org/openecomp/aai/introspection/tools/CreateUUID.java +++ b/aai-core/src/main/java/org/openecomp/aai/introspection/tools/CreateUUID.java @@ -20,12 +20,12 @@ package org.openecomp.aai.introspection.tools; -import java.util.Map; -import java.util.UUID; - import org.openecomp.aai.introspection.Introspector; import org.openecomp.aai.schema.enums.PropertyMetadata; +import java.util.Map; +import java.util.UUID; + public class CreateUUID implements IssueResolver { /** diff --git a/aai-core/src/main/java/org/openecomp/aai/introspection/tools/DefaultFields.java b/aai-core/src/main/java/org/openecomp/aai/introspection/tools/DefaultFields.java index 2a34e72c..c242d983 100644 --- a/aai-core/src/main/java/org/openecomp/aai/introspection/tools/DefaultFields.java +++ b/aai-core/src/main/java/org/openecomp/aai/introspection/tools/DefaultFields.java @@ -20,11 +20,11 @@ package org.openecomp.aai.introspection.tools; -import java.util.Map; - import org.openecomp.aai.introspection.Introspector; import org.openecomp.aai.schema.enums.PropertyMetadata; +import java.util.Map; + public class DefaultFields implements IssueResolver { /** diff --git a/aai-core/src/main/java/org/openecomp/aai/introspection/tools/InjectKeysFromURI.java b/aai-core/src/main/java/org/openecomp/aai/introspection/tools/InjectKeysFromURI.java index d58ee7c4..d9aea008 100644 --- a/aai-core/src/main/java/org/openecomp/aai/introspection/tools/InjectKeysFromURI.java +++ b/aai-core/src/main/java/org/openecomp/aai/introspection/tools/InjectKeysFromURI.java @@ -20,12 +20,12 @@ package org.openecomp.aai.introspection.tools; -import java.net.URI; - import org.openecomp.aai.introspection.Introspector; import org.openecomp.aai.introspection.Loader; import org.openecomp.aai.parsers.uri.URIToObject; +import java.net.URI; + public class InjectKeysFromURI implements IssueResolver { private URI uri = null; diff --git a/aai-core/src/main/java/org/openecomp/aai/introspection/tools/IntrospectorValidator.java b/aai-core/src/main/java/org/openecomp/aai/introspection/tools/IntrospectorValidator.java index 6d451cdf..cf77a3be 100644 --- a/aai-core/src/main/java/org/openecomp/aai/introspection/tools/IntrospectorValidator.java +++ b/aai-core/src/main/java/org/openecomp/aai/introspection/tools/IntrospectorValidator.java @@ -20,12 +20,6 @@ package org.openecomp.aai.introspection.tools; -import java.util.ArrayList; -import java.util.HashSet; -import java.util.List; -import java.util.Optional; -import java.util.Set; - import org.openecomp.aai.db.props.AAIProperties; import org.openecomp.aai.exceptions.AAIException; import org.openecomp.aai.introspection.Introspector; @@ -34,6 +28,8 @@ import org.openecomp.aai.introspection.Visibility; import org.openecomp.aai.introspection.Wanderer; import org.openecomp.aai.schema.enums.PropertyMetadata; +import java.util.*; + public class IntrospectorValidator implements Wanderer { @@ -49,7 +45,7 @@ public class IntrospectorValidator implements Wanderer { * * @param builder the builder */ - private IntrospectorValidator(IntrospectorValidator.Builder builder) { + private IntrospectorValidator(Builder builder) { this.validateRequired = builder.getValidateRequired(); this.issueResolvers = builder.getResolvers(); this.maximumDepth = builder.getMaximumDepth(); diff --git a/aai-core/src/main/java/org/openecomp/aai/parsers/query/LegacyQueryParser.java b/aai-core/src/main/java/org/openecomp/aai/parsers/query/LegacyQueryParser.java index f542bef2..5679fc90 100644 --- a/aai-core/src/main/java/org/openecomp/aai/parsers/query/LegacyQueryParser.java +++ b/aai-core/src/main/java/org/openecomp/aai/parsers/query/LegacyQueryParser.java @@ -20,18 +20,8 @@ package org.openecomp.aai.parsers.query; -import java.io.UnsupportedEncodingException; -import java.net.URI; -import java.net.URISyntaxException; -import java.util.HashMap; -import java.util.Iterator; -import java.util.List; -import java.util.Map; -import java.util.Map.Entry; -import java.util.Set; - -import javax.ws.rs.core.MultivaluedMap; - +import com.att.eelf.configuration.EELFLogger; +import com.att.eelf.configuration.EELFManager; import org.openecomp.aai.exceptions.AAIException; import org.openecomp.aai.introspection.Introspector; import org.openecomp.aai.introspection.Loader; @@ -43,8 +33,13 @@ import org.openecomp.aai.query.builder.QueryBuilder; import org.openecomp.aai.restcore.util.URITools; import org.openecomp.aai.schema.enums.PropertyMetadata; import org.openecomp.aai.serialization.db.EdgeType; -import com.att.eelf.configuration.EELFLogger; -import com.att.eelf.configuration.EELFManager; + +import javax.ws.rs.core.MultivaluedMap; +import java.io.UnsupportedEncodingException; +import java.net.URI; +import java.net.URISyntaxException; +import java.util.*; +import java.util.Map.Entry; /** * The Class LegacyQueryParser. diff --git a/aai-core/src/main/java/org/openecomp/aai/parsers/query/QueryParser.java b/aai-core/src/main/java/org/openecomp/aai/parsers/query/QueryParser.java index 90d9fefc..ee4e3941 100644 --- a/aai-core/src/main/java/org/openecomp/aai/parsers/query/QueryParser.java +++ b/aai-core/src/main/java/org/openecomp/aai/parsers/query/QueryParser.java @@ -20,15 +20,14 @@ package org.openecomp.aai.parsers.query; -import java.net.URI; - import org.apache.tinkerpop.gremlin.structure.Vertex; - import org.openecomp.aai.db.props.AAIProperties; import org.openecomp.aai.introspection.Loader; import org.openecomp.aai.introspection.LoaderFactory; import org.openecomp.aai.query.builder.QueryBuilder; +import java.net.URI; + /** * The Class QueryParser. */ diff --git a/aai-core/src/main/java/org/openecomp/aai/parsers/query/QueryParserStrategy.java b/aai-core/src/main/java/org/openecomp/aai/parsers/query/QueryParserStrategy.java index fa0dfa7a..b0e6cc23 100644 --- a/aai-core/src/main/java/org/openecomp/aai/parsers/query/QueryParserStrategy.java +++ b/aai-core/src/main/java/org/openecomp/aai/parsers/query/QueryParserStrategy.java @@ -20,16 +20,15 @@ package org.openecomp.aai.parsers.query; -import java.io.UnsupportedEncodingException; -import java.net.URI; - -import javax.ws.rs.core.MultivaluedMap; - import org.openecomp.aai.exceptions.AAIException; import org.openecomp.aai.introspection.Introspector; import org.openecomp.aai.introspection.Loader; import org.openecomp.aai.query.builder.QueryBuilder; +import javax.ws.rs.core.MultivaluedMap; +import java.io.UnsupportedEncodingException; +import java.net.URI; + /** * The Class QueryParserStrategy. */ diff --git a/aai-core/src/main/java/org/openecomp/aai/parsers/query/RelationshipQueryParser.java b/aai-core/src/main/java/org/openecomp/aai/parsers/query/RelationshipQueryParser.java index 10f7c05a..fb4200e5 100644 --- a/aai-core/src/main/java/org/openecomp/aai/parsers/query/RelationshipQueryParser.java +++ b/aai-core/src/main/java/org/openecomp/aai/parsers/query/RelationshipQueryParser.java @@ -20,21 +20,16 @@ package org.openecomp.aai.parsers.query; -import java.io.UnsupportedEncodingException; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; - import org.openecomp.aai.exceptions.AAIException; import org.openecomp.aai.introspection.Introspector; -import org.openecomp.aai.introspection.IntrospectorFactory; import org.openecomp.aai.introspection.Loader; import org.openecomp.aai.introspection.ModelType; import org.openecomp.aai.parsers.relationship.RelationshipToURI; import org.openecomp.aai.parsers.uri.URIParser; import org.openecomp.aai.query.builder.QueryBuilder; import org.openecomp.aai.serialization.db.EdgeRules; -import com.google.common.base.CaseFormat; + +import java.io.UnsupportedEncodingException; /** * The Class RelationshipQueryParser. diff --git a/aai-core/src/main/java/org/openecomp/aai/parsers/query/TraversalStrategy.java b/aai-core/src/main/java/org/openecomp/aai/parsers/query/TraversalStrategy.java index 6f857088..41064597 100644 --- a/aai-core/src/main/java/org/openecomp/aai/parsers/query/TraversalStrategy.java +++ b/aai-core/src/main/java/org/openecomp/aai/parsers/query/TraversalStrategy.java @@ -20,16 +20,15 @@ package org.openecomp.aai.parsers.query; -import java.io.UnsupportedEncodingException; -import java.net.URI; - -import javax.ws.rs.core.MultivaluedMap; - import org.openecomp.aai.exceptions.AAIException; import org.openecomp.aai.introspection.Introspector; import org.openecomp.aai.introspection.Loader; import org.openecomp.aai.query.builder.QueryBuilder; +import javax.ws.rs.core.MultivaluedMap; +import java.io.UnsupportedEncodingException; +import java.net.URI; + /** * The Class TraversalStrategy. */ diff --git a/aai-core/src/main/java/org/openecomp/aai/parsers/query/UniqueRelationshipQueryParser.java b/aai-core/src/main/java/org/openecomp/aai/parsers/query/UniqueRelationshipQueryParser.java index 0a210ab4..4739aa47 100644 --- a/aai-core/src/main/java/org/openecomp/aai/parsers/query/UniqueRelationshipQueryParser.java +++ b/aai-core/src/main/java/org/openecomp/aai/parsers/query/UniqueRelationshipQueryParser.java @@ -20,14 +20,14 @@ package org.openecomp.aai.parsers.query; -import java.io.UnsupportedEncodingException; - import org.openecomp.aai.exceptions.AAIException; import org.openecomp.aai.introspection.Introspector; import org.openecomp.aai.introspection.Loader; import org.openecomp.aai.parsers.relationship.RelationshipToURI; import org.openecomp.aai.query.builder.QueryBuilder; +import java.io.UnsupportedEncodingException; + /** * The Class UniqueRelationshipQueryParser. */ diff --git a/aai-core/src/main/java/org/openecomp/aai/parsers/query/UniqueStrategy.java b/aai-core/src/main/java/org/openecomp/aai/parsers/query/UniqueStrategy.java index f1e67dc3..5668036f 100644 --- a/aai-core/src/main/java/org/openecomp/aai/parsers/query/UniqueStrategy.java +++ b/aai-core/src/main/java/org/openecomp/aai/parsers/query/UniqueStrategy.java @@ -20,16 +20,15 @@ package org.openecomp.aai.parsers.query; -import java.io.UnsupportedEncodingException; -import java.net.URI; - -import javax.ws.rs.core.MultivaluedMap; - import org.openecomp.aai.exceptions.AAIException; import org.openecomp.aai.introspection.Introspector; import org.openecomp.aai.introspection.Loader; import org.openecomp.aai.query.builder.QueryBuilder; +import javax.ws.rs.core.MultivaluedMap; +import java.io.UnsupportedEncodingException; +import java.net.URI; + /** * The Class UniqueStrategy. */ diff --git a/aai-core/src/main/java/org/openecomp/aai/parsers/query/UniqueURIQueryParser.java b/aai-core/src/main/java/org/openecomp/aai/parsers/query/UniqueURIQueryParser.java index 203de01b..64fc3df2 100644 --- a/aai-core/src/main/java/org/openecomp/aai/parsers/query/UniqueURIQueryParser.java +++ b/aai-core/src/main/java/org/openecomp/aai/parsers/query/UniqueURIQueryParser.java @@ -20,12 +20,6 @@ package org.openecomp.aai.parsers.query; -import java.io.UnsupportedEncodingException; -import java.net.URI; - -import javax.ws.rs.core.MultivaluedMap; -import javax.ws.rs.core.UriBuilder; - import org.openecomp.aai.exceptions.AAIException; import org.openecomp.aai.introspection.Introspector; import org.openecomp.aai.introspection.Loader; @@ -35,6 +29,11 @@ import org.openecomp.aai.parsers.uri.URIToDBKey; import org.openecomp.aai.query.builder.QueryBuilder; import org.openecomp.aai.serialization.db.EdgeType; +import javax.ws.rs.core.MultivaluedMap; +import javax.ws.rs.core.UriBuilder; +import java.io.UnsupportedEncodingException; +import java.net.URI; + /** * The Class UniqueURIQueryParser. diff --git a/aai-core/src/main/java/org/openecomp/aai/parsers/relationship/RelationshipToURI.java b/aai-core/src/main/java/org/openecomp/aai/parsers/relationship/RelationshipToURI.java index bd9280f4..873f7211 100644 --- a/aai-core/src/main/java/org/openecomp/aai/parsers/relationship/RelationshipToURI.java +++ b/aai-core/src/main/java/org/openecomp/aai/parsers/relationship/RelationshipToURI.java @@ -20,35 +20,30 @@ package org.openecomp.aai.parsers.relationship; -import java.io.UnsupportedEncodingException; -import java.net.URI; -import java.net.URISyntaxException; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Optional; - -import javax.ws.rs.core.UriBuilder; - +import com.att.eelf.configuration.EELFLogger; +import com.att.eelf.configuration.EELFManager; import org.apache.tinkerpop.gremlin.structure.Direction; import org.openecomp.aai.exceptions.AAIException; -import org.openecomp.aai.introspection.Introspector; -import org.openecomp.aai.introspection.IntrospectorFactory; -import org.openecomp.aai.introspection.Loader; -import org.openecomp.aai.introspection.ModelType; -import org.openecomp.aai.introspection.Version; +import org.openecomp.aai.introspection.*; import org.openecomp.aai.introspection.exceptions.AAIUnknownObjectException; import org.openecomp.aai.parsers.exceptions.AAIIdentityMapParseException; import org.openecomp.aai.parsers.exceptions.AmbiguousMapAAIException; import org.openecomp.aai.parsers.uri.URIParser; import org.openecomp.aai.schema.enums.ObjectMetadata; +import org.openecomp.aai.serialization.db.AAIDirection; import org.openecomp.aai.serialization.db.EdgeRule; import org.openecomp.aai.serialization.db.EdgeRules; import org.openecomp.aai.serialization.db.EdgeType; import org.openecomp.aai.workarounds.LegacyURITransformer; -import com.att.eelf.configuration.EELFLogger; -import com.att.eelf.configuration.EELFManager; +import javax.ws.rs.core.UriBuilder; +import java.io.UnsupportedEncodingException; +import java.net.URI; +import java.net.URISyntaxException; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Optional; /** * The Class RelationshipToURI. @@ -254,7 +249,7 @@ public class RelationshipToURI { rule = edgeRules.getEdgeRule(EdgeType.TREE, startType, objectType); direction = rule.getDirection(); if (direction != null) { - if ((rule.getIsParent().equals("true") && direction.equals(Direction.IN)) || (rule.getIsParent().equals("reverse") && direction.equals(Direction.OUT))) { + if ((rule.getContains().equals(AAIDirection.OUT.toString()) && direction.equals(Direction.IN)) || (rule.getContains().equals(AAIDirection.IN.toString()) && direction.equals(Direction.OUT))) { displacedObject = data.set((data.size() - i) - 1, data.get(j)); data.set(j, displacedObject); if (sortRelationships(data, objectType, i+1)) { diff --git a/aai-core/src/main/java/org/openecomp/aai/parsers/uri/Parsable.java b/aai-core/src/main/java/org/openecomp/aai/parsers/uri/Parsable.java index 57a8d8aa..2488980e 100644 --- a/aai-core/src/main/java/org/openecomp/aai/parsers/uri/Parsable.java +++ b/aai-core/src/main/java/org/openecomp/aai/parsers/uri/Parsable.java @@ -20,12 +20,12 @@ package org.openecomp.aai.parsers.uri; -import javax.ws.rs.core.MultivaluedMap; - import org.openecomp.aai.exceptions.AAIException; import org.openecomp.aai.introspection.Introspector; import org.openecomp.aai.serialization.db.EdgeType; +import javax.ws.rs.core.MultivaluedMap; + /** * The Interface Parsable. */ diff --git a/aai-core/src/main/java/org/openecomp/aai/parsers/uri/URIParser.java b/aai-core/src/main/java/org/openecomp/aai/parsers/uri/URIParser.java index b145717f..7b08f44f 100644 --- a/aai-core/src/main/java/org/openecomp/aai/parsers/uri/URIParser.java +++ b/aai-core/src/main/java/org/openecomp/aai/parsers/uri/URIParser.java @@ -20,14 +20,6 @@ package org.openecomp.aai.parsers.uri; -import java.io.UnsupportedEncodingException; -import java.net.URI; -import java.util.Set; - -import javax.ws.rs.core.MultivaluedHashMap; -import javax.ws.rs.core.MultivaluedMap; -import javax.ws.rs.core.UriBuilder; - import org.openecomp.aai.exceptions.AAIException; import org.openecomp.aai.introspection.Introspector; import org.openecomp.aai.introspection.Loader; @@ -41,6 +33,13 @@ import org.openecomp.aai.serialization.db.EdgeType; import org.openecomp.aai.util.AAIConfig; import org.springframework.web.util.UriUtils; +import javax.ws.rs.core.MultivaluedHashMap; +import javax.ws.rs.core.MultivaluedMap; +import javax.ws.rs.core.UriBuilder; +import java.io.UnsupportedEncodingException; +import java.net.URI; +import java.util.Set; + /** * The Class URIParser. diff --git a/aai-core/src/main/java/org/openecomp/aai/parsers/uri/URIToDBKey.java b/aai-core/src/main/java/org/openecomp/aai/parsers/uri/URIToDBKey.java index ae6ff600..6aa28e27 100644 --- a/aai-core/src/main/java/org/openecomp/aai/parsers/uri/URIToDBKey.java +++ b/aai-core/src/main/java/org/openecomp/aai/parsers/uri/URIToDBKey.java @@ -20,18 +20,17 @@ package org.openecomp.aai.parsers.uri; -import java.io.UnsupportedEncodingException; -import java.net.URI; -import java.util.ArrayList; -import java.util.List; - -import javax.ws.rs.core.MultivaluedMap; - +import com.google.common.base.Joiner; import org.openecomp.aai.exceptions.AAIException; import org.openecomp.aai.introspection.Introspector; import org.openecomp.aai.introspection.Loader; import org.openecomp.aai.serialization.db.EdgeType; -import com.google.common.base.Joiner; + +import javax.ws.rs.core.MultivaluedMap; +import java.io.UnsupportedEncodingException; +import java.net.URI; +import java.util.ArrayList; +import java.util.List; /** * Creates a Unique database key from a URI diff --git a/aai-core/src/main/java/org/openecomp/aai/parsers/uri/URIToExtensionInformation.java b/aai-core/src/main/java/org/openecomp/aai/parsers/uri/URIToExtensionInformation.java index 9906437b..d32facfa 100644 --- a/aai-core/src/main/java/org/openecomp/aai/parsers/uri/URIToExtensionInformation.java +++ b/aai-core/src/main/java/org/openecomp/aai/parsers/uri/URIToExtensionInformation.java @@ -20,20 +20,19 @@ package org.openecomp.aai.parsers.uri; -import java.io.UnsupportedEncodingException; -import java.net.URI; -import java.util.ArrayList; -import java.util.List; - -import javax.ws.rs.core.MultivaluedMap; - +import com.google.common.base.CaseFormat; +import com.google.common.base.Joiner; import org.openecomp.aai.exceptions.AAIException; import org.openecomp.aai.introspection.Introspector; import org.openecomp.aai.introspection.Loader; import org.openecomp.aai.restcore.HttpMethod; import org.openecomp.aai.serialization.db.EdgeType; -import com.google.common.base.CaseFormat; -import com.google.common.base.Joiner; + +import javax.ws.rs.core.MultivaluedMap; +import java.io.UnsupportedEncodingException; +import java.net.URI; +import java.util.ArrayList; +import java.util.List; /** * The Class URIToExtensionInformation. diff --git a/aai-core/src/main/java/org/openecomp/aai/parsers/uri/URIToObject.java b/aai-core/src/main/java/org/openecomp/aai/parsers/uri/URIToObject.java index 57a1de57..decd803f 100644 --- a/aai-core/src/main/java/org/openecomp/aai/parsers/uri/URIToObject.java +++ b/aai-core/src/main/java/org/openecomp/aai/parsers/uri/URIToObject.java @@ -20,13 +20,6 @@ package org.openecomp.aai.parsers.uri; -import java.io.UnsupportedEncodingException; -import java.net.URI; -import java.util.HashMap; -import java.util.List; - -import javax.ws.rs.core.MultivaluedMap; - import org.openecomp.aai.exceptions.AAIException; import org.openecomp.aai.introspection.Introspector; import org.openecomp.aai.introspection.Loader; @@ -34,6 +27,12 @@ import org.openecomp.aai.introspection.Version; import org.openecomp.aai.schema.enums.ObjectMetadata; import org.openecomp.aai.serialization.db.EdgeType; +import javax.ws.rs.core.MultivaluedMap; +import java.io.UnsupportedEncodingException; +import java.net.URI; +import java.util.HashMap; +import java.util.List; + /** * Given a URI this class returns an object, or series of nested objects * with their keys populated based off the values in the URI. diff --git a/aai-core/src/main/java/org/openecomp/aai/parsers/uri/URIToRelationshipObject.java b/aai-core/src/main/java/org/openecomp/aai/parsers/uri/URIToRelationshipObject.java index 853b7877..a5429000 100644 --- a/aai-core/src/main/java/org/openecomp/aai/parsers/uri/URIToRelationshipObject.java +++ b/aai-core/src/main/java/org/openecomp/aai/parsers/uri/URIToRelationshipObject.java @@ -20,14 +20,6 @@ package org.openecomp.aai.parsers.uri; -import java.io.UnsupportedEncodingException; -import java.net.MalformedURLException; -import java.net.URI; -import java.net.URISyntaxException; -import java.util.List; - -import javax.ws.rs.core.MultivaluedMap; - import org.openecomp.aai.exceptions.AAIException; import org.openecomp.aai.introspection.Introspector; import org.openecomp.aai.introspection.Loader; @@ -37,6 +29,13 @@ import org.openecomp.aai.serialization.db.EdgeType; import org.openecomp.aai.util.AAIApiServerURLBase; import org.openecomp.aai.workarounds.LegacyURITransformer; +import javax.ws.rs.core.MultivaluedMap; +import java.io.UnsupportedEncodingException; +import java.net.MalformedURLException; +import java.net.URI; +import java.net.URISyntaxException; +import java.util.List; + /** * Given a URI a Relationship Object is returned. * @@ -103,7 +102,7 @@ public class URIToRelationshipObject implements Parsable { public String getCloudRegionTransform(){ return "remove"; } - + /** * @{inheritDoc} */ @@ -139,9 +138,9 @@ public class URIToRelationshipObject implements Parsable { //only return the path section of the URI past v10 relatedLink = new URI(relatedLink.getRawPath()); } - + this.relationship.setValue("related-link", relatedLink.toString()); - + this.result = relationship; return this.result; } @@ -154,7 +153,7 @@ public class URIToRelationshipObject implements Parsable { Introspector data = loader.introspectorFromName("relationship-data"); data.setValue("relationship-key", obj.getDbName() + "." + key); data.setValue("relationship-value", obj.getValue(key)); - + ((List<Object>)relationship.getValue("relationship-data")).add(data.getUnderlyingObject()); } catch (AAIUnknownObjectException e) { throw new RuntimeException("Fatal error - relationship-data object not found!"); diff --git a/aai-core/src/main/java/org/openecomp/aai/parsers/uri/URIValidate.java b/aai-core/src/main/java/org/openecomp/aai/parsers/uri/URIValidate.java index 6eed095e..b7c0958c 100644 --- a/aai-core/src/main/java/org/openecomp/aai/parsers/uri/URIValidate.java +++ b/aai-core/src/main/java/org/openecomp/aai/parsers/uri/URIValidate.java @@ -20,12 +20,12 @@ package org.openecomp.aai.parsers.uri; -import javax.ws.rs.core.MultivaluedMap; - import org.openecomp.aai.exceptions.AAIException; import org.openecomp.aai.introspection.Introspector; import org.openecomp.aai.serialization.db.EdgeType; +import javax.ws.rs.core.MultivaluedMap; + class URIValidate implements Parsable { @Override diff --git a/aai-core/src/main/java/org/openecomp/aai/rest/db/DBRequest.java b/aai-core/src/main/java/org/openecomp/aai/rest/db/DBRequest.java index 13699e96..e7b68588 100644 --- a/aai-core/src/main/java/org/openecomp/aai/rest/db/DBRequest.java +++ b/aai-core/src/main/java/org/openecomp/aai/rest/db/DBRequest.java @@ -5,16 +5,16 @@ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. * ============LICENSE_END========================================================= */ diff --git a/aai-core/src/main/java/org/openecomp/aai/serialization/db/AAIDirection.java b/aai-core/src/main/java/org/openecomp/aai/serialization/db/AAIDirection.java new file mode 100644 index 00000000..fe9be364 --- /dev/null +++ b/aai-core/src/main/java/org/openecomp/aai/serialization/db/AAIDirection.java @@ -0,0 +1,34 @@ +/*- + * ============LICENSE_START======================================================= + * org.openecomp.aai + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.aai.serialization.db; + +public enum AAIDirection { + IN, OUT, BOTH, NONE; + + public AAIDirection opposite() { + if (this.equals(OUT)) + return IN; + else if (this.equals(IN)) + return OUT; + else + return BOTH; + } +} diff --git a/aai-core/src/main/java/org/openecomp/aai/serialization/db/DBSerializer.java b/aai-core/src/main/java/org/openecomp/aai/serialization/db/DBSerializer.java index 49bcfd5a..3536d137 100644 --- a/aai-core/src/main/java/org/openecomp/aai/serialization/db/DBSerializer.java +++ b/aai-core/src/main/java/org/openecomp/aai/serialization/db/DBSerializer.java @@ -21,46 +21,19 @@ package org.openecomp.aai.serialization.db; -import java.io.UnsupportedEncodingException; -import java.lang.reflect.Array; -import java.lang.reflect.InvocationTargetException; -import java.net.MalformedURLException; -import java.net.URI; -import java.net.URISyntaxException; -import java.util.ArrayList; -import java.util.HashSet; -import java.util.Iterator; -import java.util.LinkedHashSet; -import java.util.List; -import java.util.Map; -import java.util.Optional; -import java.util.Set; -import java.util.concurrent.Callable; -import java.util.concurrent.ExecutionException; -import java.util.concurrent.ExecutorService; -import java.util.concurrent.Future; - -import javax.ws.rs.core.UriBuilder; - +import com.att.eelf.configuration.EELFLogger; +import com.att.eelf.configuration.EELFManager; +import com.google.common.base.CaseFormat; +import com.thinkaurelius.titan.core.SchemaViolationException; import org.apache.commons.collections.IteratorUtils; import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversal; import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.__; import org.apache.tinkerpop.gremlin.process.traversal.step.util.Tree; -import org.apache.tinkerpop.gremlin.structure.Direction; -import org.apache.tinkerpop.gremlin.structure.Edge; -import org.apache.tinkerpop.gremlin.structure.Element; -import org.apache.tinkerpop.gremlin.structure.Vertex; -import org.apache.tinkerpop.gremlin.structure.VertexProperty; +import org.apache.tinkerpop.gremlin.structure.*; import org.javatuples.Pair; import org.openecomp.aai.db.props.AAIProperties; import org.openecomp.aai.exceptions.AAIException; -import org.openecomp.aai.introspection.Introspector; -import org.openecomp.aai.introspection.IntrospectorFactory; -import org.openecomp.aai.introspection.Loader; -import org.openecomp.aai.introspection.LoaderFactory; -import org.openecomp.aai.introspection.ModelType; -import org.openecomp.aai.introspection.PropertyPredicates; -import org.openecomp.aai.introspection.Version; +import org.openecomp.aai.introspection.*; import org.openecomp.aai.introspection.exceptions.AAIUnknownObjectException; import org.openecomp.aai.introspection.sideeffect.DataCopy; import org.openecomp.aai.introspection.sideeffect.DataLinkReader; @@ -81,10 +54,18 @@ import org.openecomp.aai.util.AAIConfig; import org.openecomp.aai.util.AAIConstants; import org.openecomp.aai.workarounds.NamingExceptions; -import com.att.eelf.configuration.EELFLogger; -import com.att.eelf.configuration.EELFManager; -import com.google.common.base.CaseFormat; -import com.thinkaurelius.titan.core.SchemaViolationException; +import javax.ws.rs.core.UriBuilder; +import java.io.UnsupportedEncodingException; +import java.lang.reflect.Array; +import java.lang.reflect.InvocationTargetException; +import java.net.MalformedURLException; +import java.net.URI; +import java.net.URISyntaxException; +import java.util.*; +import java.util.concurrent.Callable; +import java.util.concurrent.ExecutionException; +import java.util.concurrent.ExecutorService; +import java.util.concurrent.Future; public class DBSerializer { @@ -125,9 +106,6 @@ public class DBSerializer { * @param v the v * @param isNewVertex the is new vertex */ - /* - * to be defined and expanded later - */ public void touchStandardVertexProperties(Vertex v, boolean isNewVertex) { long unixTimeNow = System.currentTimeMillis(); @@ -143,12 +121,12 @@ public class DBSerializer { } private void touchStandardVertexProperties(String nodeType, Vertex v, boolean isNewVertex) { - + v.property(AAIProperties.NODE_TYPE, nodeType); touchStandardVertexProperties(v, isNewVertex); } - + /** @@ -434,6 +412,10 @@ public class DBSerializer { if (cousinVertex != null) { try { + if (!edgeRules.hasEdgeRule(v, cousinVertex)) { + throw new AAIException("AAI_6120", "No EdgeRule found for passed nodeTypes: " + v.property(AAIProperties.NODE_TYPE).value().toString() + ", " + + cousinVertex.property(AAIProperties.NODE_TYPE).value().toString() + "."); + } e = this.getEdgeBetween(EdgeType.COUSIN, v, cousinVertex); if (e == null) { @@ -724,7 +706,7 @@ public class DBSerializer { EdgeRule rule; rule = edgeRules.getEdgeRule(EdgeType.TREE, vType, childDbName); - if (rule.getIsParent().equals("true") || rule.getIsParent().equals("reverse")) { + if (!rule.getContains().equals(AAIDirection.NONE.toString())) { //vertices = this.queryEngine.findRelatedVertices(v, Direction.OUT, rule.getLabel(), childDbName); Direction ruleDirection = rule.getDirection(); Iterator<Vertex> itr = v.vertices(ruleDirection, rule.getLabel()); @@ -954,8 +936,8 @@ public class DBSerializer { } if(list.size() > 0 && this.version.compareTo(Version.v8) >= 0){ - this.addRelatedToProperty(result, list.get(0)); - } + this.addRelatedToProperty(result, list.get(0)); + } return result.getUnderlyingObject(); } @@ -1337,87 +1319,20 @@ public class DBSerializer { * @throws AAIException the AAI exception */ private boolean verifyDeleteSemantics(Vertex vertex, String resourceVersion, boolean enableResourceVersion) throws AAIException { - boolean result = false; + boolean result = true; String nodeType = ""; - DeleteSemantic semantic = null; - List<Edge> inEdges = null; - List<Edge> outEdges = null; String errorDetail = " unknown delete semantic found"; String aaiExceptionCode = ""; nodeType = vertex.<String>property(AAIProperties.NODE_TYPE).orElse(null); if (enableResourceVersion && !this.verifyResourceVersion("delete", nodeType, vertex.<String>property(AAIProperties.RESOURCE_VERSION).orElse(null), resourceVersion, nodeType)) { } - semantic = edgeRules.getDeleteSemantic(nodeType); - inEdges = (List<Edge>)IteratorUtils.toList(vertex.edges(Direction.IN)); - outEdges = (List<Edge>)IteratorUtils.toList(vertex.edges(Direction.OUT)); - if (semantic.equals(DeleteSemantic.CASCADE_TO_CHILDREN)) { - result = true; - } else if (semantic.equals(DeleteSemantic.ERROR_IF_ANY_EDGES)) { - if (inEdges.isEmpty() && outEdges.isEmpty()) { - result = true; - } else { - errorDetail = " Node cannot be deleted because it still has Edges and the " + semantic + " scope was used.\n"; - aaiExceptionCode = "AAI_6110"; - } - } else if (semantic.equals(DeleteSemantic.ERROR_IF_ANY_IN_EDGES) || semantic.equals(DeleteSemantic.ERROR_4_IN_EDGES_OR_CASCADE)) { - - if (inEdges.isEmpty()) { - result = true; - } else { - //are there any cousin edges? - long children = 0; - for (Edge e : inEdges) { - if (e.<Boolean>property(EdgeProperties.out(EdgeProperty.IS_PARENT)).orElse(false)) { - children++; - } - } - for (Edge e : outEdges) { - if (e.<Boolean>property(EdgeProperties.in(EdgeProperty.IS_PARENT)).orElse(false)) { - children++; - } - } - - result = children == inEdges.size(); - } - - if (!result) { - errorDetail = " Node cannot be deleted because it still has Edges and the " + semantic + " scope was used.\n"; - aaiExceptionCode = "AAI_6110"; - } - } else if (semantic.equals(DeleteSemantic.THIS_NODE_ONLY)) { - if (outEdges.isEmpty() && inEdges.isEmpty()) { - result = true; - } else { - result = true; - for (Edge edge : outEdges) { - Object property = edge.<Boolean>property(EdgeProperties.out(EdgeProperty.IS_PARENT)).orElse(null); - if (property != null && property.equals(Boolean.TRUE)) { - Vertex v = edge.inVertex(); - String vType = v.<String>property(AAIProperties.NODE_TYPE).orElse(null); - errorDetail = " Node cannot be deleted using scope = " + semantic + - " another node (type = " + vType + ") depends on it for uniqueness."; - aaiExceptionCode = "AAI_6110"; - result = false; - break; - } - } - - for (Edge edge : inEdges) { - Object property = edge.<Boolean>property(EdgeProperties.in(EdgeProperty.IS_PARENT)).orElse(null); - if (property != null && property.equals(Boolean.TRUE)) { - Vertex v = edge.outVertex(); - String vType = v.<String>property(AAIProperties.NODE_TYPE).orElse(null); - errorDetail = " Node cannot be deleted using scope = " + semantic + - " another node (type = " + vType + ") depends on it for uniqueness."; - aaiExceptionCode = "AAI_6110"; - result = false; - break; - } - } - } - } - + List<Object> preventDeleteVertices = this.engine.asAdmin().getReadOnlyTraversalSource().V(vertex).union(__.inE().has(EdgeProperty.PREVENT_DELETE.toString(), AAIDirection.IN.toString()).outV().values(AAIProperties.NODE_TYPE), __.outE().has(EdgeProperty.PREVENT_DELETE.toString(), AAIDirection.OUT.toString()).inV().values(AAIProperties.NODE_TYPE)).dedup().toList(); + if (preventDeleteVertices.size() > 0) { + aaiExceptionCode = "AAI_6110"; + errorDetail = String.format("Object is being reference by additional objects preventing it from being deleted. Please clean up references from the following types %s", preventDeleteVertices); + result = false; + } if (!result) { throw new AAIException(aaiExceptionCode, errorDetail); } diff --git a/aai-core/src/main/java/org/openecomp/aai/serialization/db/EdgeProperty.java b/aai-core/src/main/java/org/openecomp/aai/serialization/db/EdgeProperty.java index ce21431d..29461bcf 100644 --- a/aai-core/src/main/java/org/openecomp/aai/serialization/db/EdgeProperty.java +++ b/aai-core/src/main/java/org/openecomp/aai/serialization/db/EdgeProperty.java @@ -21,10 +21,10 @@ package org.openecomp.aai.serialization.db; public enum EdgeProperty { - IS_PARENT("isParent"), - USES_RESOURCE("usesResource"), - HAS_DEL_TARGET("hasDelTarget"), - SVC_INFRA("SVC-INFRA"); + CONTAINS("contains-other-v"), + DELETE_OTHER_V("delete-other-v"), + SVC_INFRA("SVC-INFRA"), + PREVENT_DELETE("prevent-delete"); private final String name; private EdgeProperty(String name) { diff --git a/aai-core/src/main/java/org/openecomp/aai/serialization/db/EdgePropertyMap.java b/aai-core/src/main/java/org/openecomp/aai/serialization/db/EdgePropertyMap.java new file mode 100644 index 00000000..bce2c313 --- /dev/null +++ b/aai-core/src/main/java/org/openecomp/aai/serialization/db/EdgePropertyMap.java @@ -0,0 +1,59 @@ +/*- + * ============LICENSE_START======================================================= + * org.openecomp.aai + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.aai.serialization.db; + +import org.apache.tinkerpop.gremlin.structure.Direction; + +import java.util.HashMap; +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +public class EdgePropertyMap<K, V> extends HashMap<K, V> { + + private static final long serialVersionUID = -8298355506617458683L; + + private static final Pattern variablePattern = Pattern.compile("(!)?\\$\\{(\\w+)\\}"); + + @Override + public V get(Object arg0) { + + V value = super.get(arg0); + + Matcher m = variablePattern.matcher(value.toString()); + if (m.find()) { + if (m.groupCount() == 2) { + if (m.group(1) == null) { + value = super.get(m.group(2)); + } else { + value = reverse(super.get(m.group(2))); + } + } + } + + return value; + } + + + protected V reverse(V value) { + + return (V)Direction.valueOf(value.toString()).opposite().toString(); + } +} diff --git a/aai-core/src/main/java/org/openecomp/aai/serialization/db/EdgeRule.java b/aai-core/src/main/java/org/openecomp/aai/serialization/db/EdgeRule.java index 12548f9c..1b6c19f0 100644 --- a/aai-core/src/main/java/org/openecomp/aai/serialization/db/EdgeRule.java +++ b/aai-core/src/main/java/org/openecomp/aai/serialization/db/EdgeRule.java @@ -20,21 +20,17 @@ package org.openecomp.aai.serialization.db; +import org.apache.tinkerpop.gremlin.structure.Direction; + import java.util.HashMap; import java.util.Map; -import org.apache.tinkerpop.gremlin.structure.Direction; - public class EdgeRule { private String label = ""; private MultiplicityRule multiplicityRule = null; private Direction direction = null; - private Map<String, String> edgeProperties = null; - private final String IS_PARENT = "isParent"; - private final String USES_RESOURCE = "usesResource"; - private final String HAS_DEL_TARGET = "hasDelTarget"; - private final String SVC_INFRA = "SVC-INFRA"; + private Map<EdgeProperty, String> edgeProperties = null; /** * Instantiates a new edge rule. @@ -124,8 +120,8 @@ public class EdgeRule { * * @return the checks if is parent */ - public String getIsParent() { - return this.getProp(this.IS_PARENT); + public String getContains() { + return this.getProp(EdgeProperty.CONTAINS); } /** @@ -133,26 +129,8 @@ public class EdgeRule { * * @param isParent the new checks if is parent */ - public void setIsParent(String isParent) { - this.setProp(this.IS_PARENT, isParent); - } - - /** - * Gets the uses resource. - * - * @return the uses resource - */ - public String getUsesResource() { - return this.getProp(this.USES_RESOURCE); - } - - /** - * Sets the uses resource. - * - * @param usesResource the new uses resource - */ - public void setUsesResource(String usesResource) { - this.setProp(this.USES_RESOURCE, usesResource); + public void setContains(String isParent) { + this.setProp(EdgeProperty.CONTAINS, isParent); } /** @@ -160,8 +138,8 @@ public class EdgeRule { * * @return the checks for del target */ - public String getHasDelTarget() { - return this.getProp(this.HAS_DEL_TARGET); + public String getDeleteOtherV() { + return this.getProp(EdgeProperty.DELETE_OTHER_V); } /** @@ -169,8 +147,8 @@ public class EdgeRule { * * @param hasDelTarget the new checks for del target */ - public void setHasDelTarget(String hasDelTarget) { - this.setProp(this.HAS_DEL_TARGET, hasDelTarget); + public void setDeleteOtherV(String hasDelTarget) { + this.setProp(EdgeProperty.DELETE_OTHER_V, hasDelTarget); } /** @@ -179,7 +157,7 @@ public class EdgeRule { * @return the service infrastructure */ public String getServiceInfrastructure() { - return this.getProp(this.SVC_INFRA); + return this.getProp(EdgeProperty.SVC_INFRA); } /** @@ -188,7 +166,15 @@ public class EdgeRule { * @param serviceInfrastructure the new service infrastructure */ public void setServiceInfrastructure(String serviceInfrastructure) { - this.setProp(this.SVC_INFRA, serviceInfrastructure); + this.setProp(EdgeProperty.SVC_INFRA, serviceInfrastructure); + } + + public String getPreventDelete() { + return this.getProp(EdgeProperty.PREVENT_DELETE); + } + + public void setPreventDelete(String preventDelete) { + this.setProp(EdgeProperty.PREVENT_DELETE, preventDelete); } /** @@ -196,7 +182,7 @@ public class EdgeRule { * * @return the edge properties */ - public Map<String, String> getEdgeProperties() { + public Map<EdgeProperty, String> getEdgeProperties() { return this.edgeProperties; } @@ -206,7 +192,7 @@ public class EdgeRule { * @param key the key * @param value the value */ - private void setProp(String key, String value) { + private void setProp(EdgeProperty key, String value) { this.edgeProperties.put(key, value); } @@ -216,7 +202,7 @@ public class EdgeRule { * @param key the key * @return the prop */ - private String getProp(String key) { + private String getProp(EdgeProperty key) { return this.edgeProperties.get(key); } diff --git a/aai-core/src/main/java/org/openecomp/aai/serialization/db/EdgeRules.java b/aai-core/src/main/java/org/openecomp/aai/serialization/db/EdgeRules.java index 454aa1ee..6e5201b2 100644 --- a/aai-core/src/main/java/org/openecomp/aai/serialization/db/EdgeRules.java +++ b/aai-core/src/main/java/org/openecomp/aai/serialization/db/EdgeRules.java @@ -20,20 +20,13 @@ package org.openecomp.aai.serialization.db; -import static com.jayway.jsonpath.Criteria.where; -import static com.jayway.jsonpath.Filter.filter; - -import java.io.InputStream; -import java.util.Collection; -import java.util.Collections; -import java.util.EnumMap; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Optional; -import java.util.Scanner; -import java.util.concurrent.ConcurrentHashMap; - +import com.att.eelf.configuration.EELFLogger; +import com.att.eelf.configuration.EELFManager; +import com.google.common.collect.ArrayListMultimap; +import com.google.common.collect.Multimap; +import com.jayway.jsonpath.DocumentContext; +import com.jayway.jsonpath.Filter; +import com.jayway.jsonpath.JsonPath; import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource; import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.__; import org.apache.tinkerpop.gremlin.structure.Direction; @@ -46,13 +39,13 @@ import org.openecomp.aai.introspection.Version; import org.openecomp.aai.serialization.db.exceptions.EdgeMultiplicityException; import org.openecomp.aai.serialization.db.exceptions.NoEdgeRuleFoundException; -import com.att.eelf.configuration.EELFLogger; -import com.att.eelf.configuration.EELFManager; -import com.google.common.collect.ArrayListMultimap; -import com.google.common.collect.Multimap; -import com.jayway.jsonpath.DocumentContext; -import com.jayway.jsonpath.Filter; -import com.jayway.jsonpath.JsonPath; +import java.io.InputStream; +import java.util.*; +import java.util.Map.Entry; +import java.util.concurrent.ConcurrentHashMap; + +import static com.jayway.jsonpath.Criteria.where; +import static com.jayway.jsonpath.Filter.filter; public class EdgeRules { @@ -230,21 +223,10 @@ public class EdgeRules { // Items starting at "firstTagIndex" and up are all assumed to be booleans that map according to // tags as defined in EdgeInfoMap. // Note - if they are tagged as 'reverse', that means they get the tag name with "-REV" on it - Map<String, String> propMap = rule.getEdgeProperties(); + Map<EdgeProperty, String> propMap = rule.getEdgeProperties(); - for (String key : propMap.keySet()) { - String revKeyname = key + "-REV"; - String triple = propMap.get(key); - if(triple.equals("true")){ - edge.property(key, true); - edge.property(revKeyname,false); - } else if (triple.equals("false")) { - edge.property(key, false); - edge.property(revKeyname,false); - } else if (triple.equals("reverse")) { - edge.property(key, false); - edge.property(revKeyname,true); - } + for (Entry<EdgeProperty, String> entry : propMap.entrySet()) { + edge.property(entry.getKey().toString(), entry.getValue()); } } @@ -355,12 +337,12 @@ public class EdgeRules { private Filter buildFilter(EdgeType type, String nodeA, String nodeB) { if (EdgeType.COUSIN.equals(type)) { return filter( - where("from").is(nodeA).and("to").is(nodeB).and("isParent").is("false") + where("from").is(nodeA).and("to").is(nodeB).and(EdgeProperty.CONTAINS.toString()).is(AAIDirection.NONE.toString()) ); } else { return filter( - where("from").is(nodeA).and("to").is(nodeB).and("isParent").is("true")).or( - where("from").is(nodeA).and("to").is(nodeB).and("isParent").is("reverse") + where("from").is(nodeA).and("to").is(nodeB).and(EdgeProperty.CONTAINS.toString()).is("${direction}")).or( + where("from").is(nodeA).and("to").is(nodeB).and(EdgeProperty.CONTAINS.toString()).is("!${direction}") ); } } @@ -371,15 +353,19 @@ public class EdgeRules { * @param edge - the edge information returned from JsonPath * @return EdgeRule containing that information */ - private EdgeRule buildRule(Map<String, String> edge) { + private EdgeRule buildRule(Map<String, String> map) { + Map<String, String> edge = new EdgePropertyMap<>(); + edge.putAll(map); + EdgeRule rule = new EdgeRule(); rule.setLabel(edge.get("label")); rule.setDirection(edge.get("direction")); rule.setMultiplicityRule(edge.get("multiplicity")); - rule.setIsParent(edge.get("isParent")); - rule.setUsesResource(edge.get("usesResource")); - rule.setHasDelTarget(edge.get("hasDelTarget")); - rule.setServiceInfrastructure(edge.get("SVC-INFRA")); + rule.setContains(edge.get(EdgeProperty.CONTAINS.toString())); + rule.setDeleteOtherV(edge.get(EdgeProperty.DELETE_OTHER_V.toString())); + rule.setServiceInfrastructure(edge.get(EdgeProperty.SVC_INFRA.toString())); + rule.setPreventDelete(edge.get(EdgeProperty.PREVENT_DELETE.toString())); + return rule; } @@ -424,20 +410,6 @@ public class EdgeRules { } /** - * Gets the delete semantic. - * - * @param nodeType the node type - * @return the delete semantic - */ - public DeleteSemantic getDeleteSemantic(String nodeType) { - Collection<String> semanticCollection = deleteScope.get(nodeType); - String semantic = semanticCollection.iterator().next(); - - return DeleteSemantic.valueOf(semantic); - - } - - /** * Validate multiplicity. * * @param rule the rule @@ -510,4 +482,19 @@ public class EdgeRules { return this.deleteScope; } + public Set<EdgeRule> getChildren(String nodeType) { + + final Filter filter = filter( + where("from").is(nodeType).and(EdgeProperty.CONTAINS.toString()).is("${direction}") + ).or(where("to").is(nodeType).and(EdgeProperty.CONTAINS.toString()).is("!${direction}")); + + final List<Map<String, String>> rules = rulesDoc.read("$.rules.[?]", filter); + final Set<EdgeRule> result = new HashSet<>(); + rules.forEach(item -> { + result.add(buildRule(item)); + }); + + return result; + + } } diff --git a/aai-core/src/main/java/org/openecomp/aai/serialization/db/GraphSingleton.java b/aai-core/src/main/java/org/openecomp/aai/serialization/db/GraphSingleton.java index 46cdca5a..ba616387 100644 --- a/aai-core/src/main/java/org/openecomp/aai/serialization/db/GraphSingleton.java +++ b/aai-core/src/main/java/org/openecomp/aai/serialization/db/GraphSingleton.java @@ -20,11 +20,11 @@ package org.openecomp.aai.serialization.db; -import java.util.concurrent.atomic.AtomicInteger; - +import com.thinkaurelius.titan.core.TitanGraph; import org.openecomp.aai.dbmap.AAIGraph; import org.openecomp.aai.dbmap.DBConnectionType; -import com.thinkaurelius.titan.core.TitanGraph; + +import java.util.concurrent.atomic.AtomicInteger; /* This class simply calls AAIGraph under the covers for now */ public class GraphSingleton { diff --git a/aai-core/src/main/java/org/openecomp/aai/serialization/db/LegacyDBSerializer.java b/aai-core/src/main/java/org/openecomp/aai/serialization/db/LegacyDBSerializer.java index 36469610..5d419852 100644 --- a/aai-core/src/main/java/org/openecomp/aai/serialization/db/LegacyDBSerializer.java +++ b/aai-core/src/main/java/org/openecomp/aai/serialization/db/LegacyDBSerializer.java @@ -24,7 +24,6 @@ import org.openecomp.aai.exceptions.AAIException; import org.openecomp.aai.introspection.ModelType; import org.openecomp.aai.introspection.Version; import org.openecomp.aai.serialization.engines.TransactionalGraphEngine; -import org.apache.tinkerpop.gremlin.structure.Graph; public class LegacyDBSerializer extends DBSerializer { diff --git a/aai-core/src/main/java/org/openecomp/aai/serialization/engines/TitanDBEngine.java b/aai-core/src/main/java/org/openecomp/aai/serialization/engines/TitanDBEngine.java index 8611ba6b..0d00705f 100644 --- a/aai-core/src/main/java/org/openecomp/aai/serialization/engines/TitanDBEngine.java +++ b/aai-core/src/main/java/org/openecomp/aai/serialization/engines/TitanDBEngine.java @@ -20,16 +20,16 @@ package org.openecomp.aai.serialization.engines; -import java.util.ArrayList; -import java.util.Iterator; -import java.util.List; - import org.apache.tinkerpop.gremlin.structure.Vertex; import org.apache.tinkerpop.gremlin.structure.VertexProperty; import org.openecomp.aai.dbmap.DBConnectionType; import org.openecomp.aai.introspection.Loader; import org.openecomp.aai.serialization.db.TitanGraphSingleton; +import java.util.ArrayList; +import java.util.Iterator; +import java.util.List; + public class TitanDBEngine extends TransactionalGraphEngine { /** diff --git a/aai-core/src/main/java/org/openecomp/aai/serialization/engines/TransactionalGraphEngine.java b/aai-core/src/main/java/org/openecomp/aai/serialization/engines/TransactionalGraphEngine.java index ef91a868..51917fe6 100644 --- a/aai-core/src/main/java/org/openecomp/aai/serialization/engines/TransactionalGraphEngine.java +++ b/aai-core/src/main/java/org/openecomp/aai/serialization/engines/TransactionalGraphEngine.java @@ -20,9 +20,8 @@ package org.openecomp.aai.serialization.engines; -import java.util.List; -import java.util.concurrent.atomic.AtomicInteger; - +import com.thinkaurelius.titan.core.TitanGraph; +import com.thinkaurelius.titan.core.schema.TitanManagement; 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.Graph; @@ -37,8 +36,8 @@ import org.openecomp.aai.serialization.db.GraphSingleton; import org.openecomp.aai.serialization.engines.query.GraphTraversalQueryEngine; import org.openecomp.aai.serialization.engines.query.QueryEngine; -import com.thinkaurelius.titan.core.TitanGraph; -import com.thinkaurelius.titan.core.schema.TitanManagement; +import java.util.List; +import java.util.concurrent.atomic.AtomicInteger; public abstract class TransactionalGraphEngine { diff --git a/aai-core/src/main/java/org/openecomp/aai/serialization/engines/query/GraphTraversalQueryEngine.java b/aai-core/src/main/java/org/openecomp/aai/serialization/engines/query/GraphTraversalQueryEngine.java index a1967223..074441c5 100644 --- a/aai-core/src/main/java/org/openecomp/aai/serialization/engines/query/GraphTraversalQueryEngine.java +++ b/aai-core/src/main/java/org/openecomp/aai/serialization/engines/query/GraphTraversalQueryEngine.java @@ -20,8 +20,6 @@ package org.openecomp.aai.serialization.engines.query; -import java.util.List; -import java.util.Set; import org.apache.tinkerpop.gremlin.process.traversal.P; import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversal; @@ -34,8 +32,13 @@ import org.apache.tinkerpop.gremlin.structure.Element; import org.apache.tinkerpop.gremlin.structure.Vertex; import org.openecomp.aai.db.props.AAIProperties; import org.openecomp.aai.introspection.Loader; -import org.openecomp.aai.serialization.db.EdgeProperties; -import org.openecomp.aai.serialization.db.EdgeProperty; + +import java.util.List; +import java.util.Set; + +import static org.openecomp.aai.serialization.db.AAIDirection.*; +import static org.openecomp.aai.serialization.db.EdgeProperty.CONTAINS; +import static org.openecomp.aai.serialization.db.EdgeProperty.DELETE_OTHER_V; /* * This class needs some big explanation despite its compact size. @@ -63,7 +66,7 @@ public class GraphTraversalQueryEngine extends QueryEngine { @Override public List<Vertex> findParents(Vertex start) { - final GraphTraversal<Vertex, Vertex> pipe = this.g.V(start).emit(v -> true).repeat(__.union(__.inE().has(EdgeProperties.out(EdgeProperty.IS_PARENT), true).outV(), __.outE().has(EdgeProperties.in(EdgeProperty.IS_PARENT), true).inV())); + final GraphTraversal<Vertex, Vertex> pipe = this.g.V(start).emit(v -> true).repeat(__.union(__.inE().has(CONTAINS.toString(), OUT.toString()).outV(), __.outE().has(CONTAINS.toString(), IN.toString()).inV())); return pipe.toList(); } @@ -74,7 +77,7 @@ public class GraphTraversalQueryEngine extends QueryEngine { public List<Vertex> findAllChildren(Vertex start) { GraphTraversal<Vertex, Vertex> pipe = this.g - .V(start).emit(v -> true).repeat(__.union(__.outE().has(EdgeProperties.out(EdgeProperty.IS_PARENT), true).inV(), __.inE().has(EdgeProperties.in(EdgeProperty.IS_PARENT), true).outV())); + .V(start).emit(v -> true).repeat(__.union(__.outE().has(CONTAINS.toString(), OUT.toString()).inV(), __.inE().has(CONTAINS.toString(), IN.toString()).outV())); return pipe.toList(); @@ -83,8 +86,8 @@ public class GraphTraversalQueryEngine extends QueryEngine { public List<Vertex> findChildrenOfType(Vertex start, String type) { GraphTraversal<Vertex, Vertex> pipe = this.g.V(start).union( - __.outE().has(EdgeProperties.out(EdgeProperty.IS_PARENT), true).inV(), - __.inE().has(EdgeProperties.in(EdgeProperty.IS_PARENT), true).outV() + __.outE().has(CONTAINS.toString(), OUT.toString()).inV(), + __.inE().has(CONTAINS.toString(), IN.toString()).outV() ).has(AAIProperties.NODE_TYPE, type).dedup(); return pipe.toList(); @@ -92,8 +95,8 @@ public class GraphTraversalQueryEngine extends QueryEngine { public List<Vertex> findChildren(Vertex start) { GraphTraversal<Vertex, Vertex> pipe = this.g.V(start).union( - __.outE().has(EdgeProperties.out(EdgeProperty.IS_PARENT), true), - __.inE().has(EdgeProperties.in(EdgeProperty.IS_PARENT), true) + __.outE().has(CONTAINS.toString(), OUT.toString()), + __.inE().has(CONTAINS.toString(), IN.toString()) ).otherV().dedup(); return pipe.toList(); @@ -108,12 +111,12 @@ public class GraphTraversalQueryEngine extends QueryEngine { .V(start).emit(v -> true).repeat( __.union( __.outE().or( - __.has(EdgeProperties.out(EdgeProperty.IS_PARENT), true), - __.has(EdgeProperties.out(EdgeProperty.HAS_DEL_TARGET), true) + __.has(CONTAINS.toString(), OUT.toString()), + __.has(DELETE_OTHER_V.toString(), OUT.toString()) ).inV(), __.inE().or( - __.has(EdgeProperties.in(EdgeProperty.IS_PARENT), true), - __.has(EdgeProperties.in(EdgeProperty.HAS_DEL_TARGET), true) + __.has(CONTAINS.toString(), IN.toString()), + __.has(DELETE_OTHER_V.toString(), IN.toString()) ).outV() ) ); @@ -149,14 +152,14 @@ public class GraphTraversalQueryEngine extends QueryEngine { public Tree<Element> findSubGraph(Vertex start, int iterations, boolean nodeOnly) { final GraphTraversal<Vertex, ?> t = this.g.V(start).emit(v -> true).times(iterations).repeat( __.union( - __.outE().has(EdgeProperties.out(EdgeProperty.IS_PARENT), true).inV(), - __.inE().has(EdgeProperties.in(EdgeProperty.IS_PARENT), true).outV()) + __.outE().has(CONTAINS.toString(), OUT.toString()).inV(), + __.inE().has(CONTAINS.toString(), IN.toString()).outV()) ); if (!nodeOnly) { t.union( __.identity(), - __.bothE().and(__.has(EdgeProperties.out(EdgeProperty.IS_PARENT), false), __.has(EdgeProperties.in(EdgeProperty.IS_PARENT), false)).dedup().otherV() + __.bothE().has(CONTAINS.toString(), NONE.toString()).dedup().otherV() ); } t.tree(); @@ -171,8 +174,8 @@ public class GraphTraversalQueryEngine extends QueryEngine { public List<Edge> findEdgesForVersion(Vertex start, Loader loader) { final Set<String> objects = loader.getAllObjects().keySet(); GraphTraversal<Vertex, Edge> pipeline = this.g.V(start).union( - __.inE().has(EdgeProperties.out(EdgeProperty.IS_PARENT), false).has(EdgeProperties.in(EdgeProperty.IS_PARENT), false).where(__.outV().has(AAIProperties.NODE_TYPE, P.within(objects))), - __.outE().has(EdgeProperties.out(EdgeProperty.IS_PARENT), false).has(EdgeProperties.in(EdgeProperty.IS_PARENT), false).where(__.inV().has(AAIProperties.NODE_TYPE, P.within(objects))) + __.inE().has(CONTAINS.toString(), NONE.toString()).where(__.outV().has(AAIProperties.NODE_TYPE, P.within(objects))), + __.outE().has(CONTAINS.toString(), NONE.toString()).where(__.inV().has(AAIProperties.NODE_TYPE, P.within(objects))) ).dedup(); return pipeline.toList(); @@ -182,8 +185,8 @@ public class GraphTraversalQueryEngine extends QueryEngine { @Override public List<Vertex> findCousinVertices(Vertex start) { GraphTraversal<Vertex, Vertex> pipeline = this.g.V(start).union( - __.inE().has(EdgeProperties.out(EdgeProperty.IS_PARENT), false).has(EdgeProperties.in(EdgeProperty.IS_PARENT), false), - __.outE().has(EdgeProperties.out(EdgeProperty.IS_PARENT), false).has(EdgeProperties.in(EdgeProperty.IS_PARENT), false)).otherV().dedup(); + __.inE().has(CONTAINS.toString(), NONE.toString()), + __.outE().has(CONTAINS.toString(), NONE.toString())).otherV().dedup(); return pipeline.toList(); } diff --git a/aai-core/src/main/java/org/openecomp/aai/serialization/engines/query/GremlinPipelineQueryEngine.java b/aai-core/src/main/java/org/openecomp/aai/serialization/engines/query/GremlinPipelineQueryEngine.java index a690ff65..809b6d96 100644 --- a/aai-core/src/main/java/org/openecomp/aai/serialization/engines/query/GremlinPipelineQueryEngine.java +++ b/aai-core/src/main/java/org/openecomp/aai/serialization/engines/query/GremlinPipelineQueryEngine.java @@ -1,4 +1,4 @@ -/*- +package org.openecomp.aai.serialization.engines.query;/*- * ============LICENSE_START======================================================= * org.openecomp.aai * ================================================================================ diff --git a/aai-core/src/main/java/org/openecomp/aai/serialization/engines/query/GremlinQueryEngine.java b/aai-core/src/main/java/org/openecomp/aai/serialization/engines/query/GremlinQueryEngine.java index 1a6aa6d0..1ca02112 100644 --- a/aai-core/src/main/java/org/openecomp/aai/serialization/engines/query/GremlinQueryEngine.java +++ b/aai-core/src/main/java/org/openecomp/aai/serialization/engines/query/GremlinQueryEngine.java @@ -1,4 +1,4 @@ -/*- +package org.openecomp.aai.serialization.engines.query;/*- * ============LICENSE_START======================================================= * org.openecomp.aai * ================================================================================ diff --git a/aai-core/src/main/java/org/openecomp/aai/serialization/engines/query/QueryEngine.java b/aai-core/src/main/java/org/openecomp/aai/serialization/engines/query/QueryEngine.java index f77f726d..5ac94d6c 100644 --- a/aai-core/src/main/java/org/openecomp/aai/serialization/engines/query/QueryEngine.java +++ b/aai-core/src/main/java/org/openecomp/aai/serialization/engines/query/QueryEngine.java @@ -20,18 +20,17 @@ package org.openecomp.aai.serialization.engines.query; -import java.util.List; - import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource; import org.apache.tinkerpop.gremlin.process.traversal.step.util.Tree; import org.apache.tinkerpop.gremlin.structure.Direction; import org.apache.tinkerpop.gremlin.structure.Edge; import org.apache.tinkerpop.gremlin.structure.Element; import org.apache.tinkerpop.gremlin.structure.Vertex; - import org.openecomp.aai.db.props.AAIProperties; import org.openecomp.aai.introspection.Loader; +import java.util.List; + public abstract class QueryEngine { final protected GraphTraversalSource g; diff --git a/aai-core/src/main/java/org/openecomp/aai/serialization/queryformats/Console.java b/aai-core/src/main/java/org/openecomp/aai/serialization/queryformats/Console.java index c5746327..561fd6cf 100644 --- a/aai-core/src/main/java/org/openecomp/aai/serialization/queryformats/Console.java +++ b/aai-core/src/main/java/org/openecomp/aai/serialization/queryformats/Console.java @@ -20,8 +20,8 @@ package org.openecomp.aai.serialization.queryformats; -import org.openecomp.aai.serialization.queryformats.exceptions.AAIFormatVertexException; import com.google.gson.JsonObject; +import org.openecomp.aai.serialization.queryformats.exceptions.AAIFormatVertexException; public class Console implements FormatMapper { diff --git a/aai-core/src/main/java/org/openecomp/aai/serialization/queryformats/FormatFactory.java b/aai-core/src/main/java/org/openecomp/aai/serialization/queryformats/FormatFactory.java index 031e2a32..7753ae77 100644 --- a/aai-core/src/main/java/org/openecomp/aai/serialization/queryformats/FormatFactory.java +++ b/aai-core/src/main/java/org/openecomp/aai/serialization/queryformats/FormatFactory.java @@ -30,6 +30,9 @@ import org.openecomp.aai.serialization.queryformats.exceptions.QueryParamInjecti import org.openecomp.aai.serialization.queryformats.utils.QueryParamInjector; import org.openecomp.aai.serialization.queryformats.utils.UrlBuilder; +import javax.ws.rs.core.MultivaluedHashMap; +import javax.ws.rs.core.MultivaluedMap; + public class FormatFactory { private final Loader loader; diff --git a/aai-core/src/main/java/org/openecomp/aai/serialization/queryformats/FormatMapper.java b/aai-core/src/main/java/org/openecomp/aai/serialization/queryformats/FormatMapper.java index 6759d3b7..e9f17c6b 100644 --- a/aai-core/src/main/java/org/openecomp/aai/serialization/queryformats/FormatMapper.java +++ b/aai-core/src/main/java/org/openecomp/aai/serialization/queryformats/FormatMapper.java @@ -20,8 +20,8 @@ package org.openecomp.aai.serialization.queryformats; -import org.openecomp.aai.serialization.queryformats.exceptions.AAIFormatVertexException; import com.google.gson.JsonObject; +import org.openecomp.aai.serialization.queryformats.exceptions.AAIFormatVertexException; public interface FormatMapper { diff --git a/aai-core/src/main/java/org/openecomp/aai/serialization/queryformats/Formatter.java b/aai-core/src/main/java/org/openecomp/aai/serialization/queryformats/Formatter.java index 783d52e1..26b0411e 100644 --- a/aai-core/src/main/java/org/openecomp/aai/serialization/queryformats/Formatter.java +++ b/aai-core/src/main/java/org/openecomp/aai/serialization/queryformats/Formatter.java @@ -20,16 +20,16 @@ package org.openecomp.aai.serialization.queryformats; -import java.util.List; -import java.util.Optional; -import java.util.stream.Stream; - -import org.openecomp.aai.serialization.queryformats.exceptions.AAIFormatVertexException; import com.att.eelf.configuration.EELFLogger; import com.att.eelf.configuration.EELFManager; import com.google.gson.JsonArray; import com.google.gson.JsonObject; import com.google.gson.JsonParser; +import org.openecomp.aai.serialization.queryformats.exceptions.AAIFormatVertexException; + +import java.util.List; +import java.util.Optional; +import java.util.stream.Stream; public class Formatter { diff --git a/aai-core/src/main/java/org/openecomp/aai/serialization/queryformats/GraphSON.java b/aai-core/src/main/java/org/openecomp/aai/serialization/queryformats/GraphSON.java index fa0d9650..9d119875 100644 --- a/aai-core/src/main/java/org/openecomp/aai/serialization/queryformats/GraphSON.java +++ b/aai-core/src/main/java/org/openecomp/aai/serialization/queryformats/GraphSON.java @@ -20,18 +20,17 @@ package org.openecomp.aai.serialization.queryformats; -import java.io.ByteArrayOutputStream; -import java.io.IOException; -import java.io.OutputStream; - +import com.google.gson.JsonObject; +import com.google.gson.JsonParser; +import com.thinkaurelius.titan.graphdb.tinkerpop.TitanIoRegistry; import org.apache.tinkerpop.gremlin.structure.Direction; import org.apache.tinkerpop.gremlin.structure.Vertex; import org.apache.tinkerpop.gremlin.structure.io.graphson.GraphSONMapper; import org.apache.tinkerpop.gremlin.structure.io.graphson.GraphSONWriter; -import com.google.gson.JsonObject; -import com.google.gson.JsonParser; -import com.thinkaurelius.titan.graphdb.tinkerpop.TitanIoRegistry; +import java.io.ByteArrayOutputStream; +import java.io.IOException; +import java.io.OutputStream; public class GraphSON implements FormatMapper { diff --git a/aai-core/src/main/java/org/openecomp/aai/serialization/queryformats/IdURL.java b/aai-core/src/main/java/org/openecomp/aai/serialization/queryformats/IdURL.java index 25f291a1..d0496c65 100644 --- a/aai-core/src/main/java/org/openecomp/aai/serialization/queryformats/IdURL.java +++ b/aai-core/src/main/java/org/openecomp/aai/serialization/queryformats/IdURL.java @@ -20,8 +20,9 @@ package org.openecomp.aai.serialization.queryformats; +import com.google.gson.JsonObject; +import com.google.gson.JsonParser; import org.apache.tinkerpop.gremlin.structure.Vertex; - import org.openecomp.aai.db.props.AAIProperties; import org.openecomp.aai.exceptions.AAIException; import org.openecomp.aai.introspection.Introspector; @@ -29,8 +30,6 @@ import org.openecomp.aai.introspection.Loader; import org.openecomp.aai.introspection.exceptions.AAIUnknownObjectException; import org.openecomp.aai.serialization.queryformats.exceptions.AAIFormatVertexException; import org.openecomp.aai.serialization.queryformats.utils.UrlBuilder; -import com.google.gson.JsonObject; -import com.google.gson.JsonParser; public class IdURL implements FormatMapper { diff --git a/aai-core/src/main/java/org/openecomp/aai/serialization/queryformats/PathedURL.java b/aai-core/src/main/java/org/openecomp/aai/serialization/queryformats/PathedURL.java index a74150f6..09383c9a 100644 --- a/aai-core/src/main/java/org/openecomp/aai/serialization/queryformats/PathedURL.java +++ b/aai-core/src/main/java/org/openecomp/aai/serialization/queryformats/PathedURL.java @@ -20,8 +20,9 @@ package org.openecomp.aai.serialization.queryformats; +import com.google.gson.JsonObject; +import com.google.gson.JsonParser; import org.apache.tinkerpop.gremlin.structure.Vertex; - import org.openecomp.aai.db.props.AAIProperties; import org.openecomp.aai.exceptions.AAIException; import org.openecomp.aai.introspection.Introspector; @@ -29,8 +30,6 @@ import org.openecomp.aai.introspection.Loader; import org.openecomp.aai.introspection.exceptions.AAIUnknownObjectException; import org.openecomp.aai.serialization.queryformats.exceptions.AAIFormatVertexException; import org.openecomp.aai.serialization.queryformats.utils.UrlBuilder; -import com.google.gson.JsonObject; -import com.google.gson.JsonParser; public final class PathedURL implements FormatMapper { diff --git a/aai-core/src/main/java/org/openecomp/aai/serialization/queryformats/RawFormat.java b/aai-core/src/main/java/org/openecomp/aai/serialization/queryformats/RawFormat.java index 070e22f4..489df26d 100644 --- a/aai-core/src/main/java/org/openecomp/aai/serialization/queryformats/RawFormat.java +++ b/aai-core/src/main/java/org/openecomp/aai/serialization/queryformats/RawFormat.java @@ -20,9 +20,10 @@ package org.openecomp.aai.serialization.queryformats; -import java.util.Iterator; -import java.util.List; - +import com.google.gson.Gson; +import com.google.gson.JsonArray; +import com.google.gson.JsonObject; +import com.google.gson.JsonParser; import org.apache.tinkerpop.gremlin.structure.Direction; import org.apache.tinkerpop.gremlin.structure.Vertex; import org.apache.tinkerpop.gremlin.structure.VertexProperty; @@ -34,10 +35,8 @@ import org.openecomp.aai.serialization.queryformats.params.Depth; import org.openecomp.aai.serialization.queryformats.params.NodesOnly; import org.openecomp.aai.serialization.queryformats.utils.UrlBuilder; -import com.google.gson.Gson; -import com.google.gson.JsonArray; -import com.google.gson.JsonObject; -import com.google.gson.JsonParser; +import java.util.Iterator; +import java.util.List; public class RawFormat implements FormatMapper { diff --git a/aai-core/src/main/java/org/openecomp/aai/serialization/queryformats/Resource.java b/aai-core/src/main/java/org/openecomp/aai/serialization/queryformats/Resource.java index 9a090a4b..0a557ff9 100644 --- a/aai-core/src/main/java/org/openecomp/aai/serialization/queryformats/Resource.java +++ b/aai-core/src/main/java/org/openecomp/aai/serialization/queryformats/Resource.java @@ -20,10 +20,8 @@ package org.openecomp.aai.serialization.queryformats; -import java.io.UnsupportedEncodingException; -import java.util.ArrayList; -import java.util.List; - +import com.google.gson.JsonObject; +import com.google.gson.JsonParser; import org.apache.tinkerpop.gremlin.structure.Vertex; import org.openecomp.aai.db.props.AAIProperties; import org.openecomp.aai.exceptions.AAIException; @@ -36,8 +34,9 @@ import org.openecomp.aai.serialization.queryformats.params.Depth; import org.openecomp.aai.serialization.queryformats.params.NodesOnly; import org.openecomp.aai.serialization.queryformats.utils.UrlBuilder; -import com.google.gson.JsonObject; -import com.google.gson.JsonParser; +import java.io.UnsupportedEncodingException; +import java.util.ArrayList; +import java.util.List; public class Resource implements FormatMapper { diff --git a/aai-core/src/main/java/org/openecomp/aai/serialization/queryformats/SimpleFormat.java b/aai-core/src/main/java/org/openecomp/aai/serialization/queryformats/SimpleFormat.java index c14f9b79..6e153193 100644 --- a/aai-core/src/main/java/org/openecomp/aai/serialization/queryformats/SimpleFormat.java +++ b/aai-core/src/main/java/org/openecomp/aai/serialization/queryformats/SimpleFormat.java @@ -20,10 +20,7 @@ package org.openecomp.aai.serialization.queryformats; -import java.io.UnsupportedEncodingException; -import java.util.ArrayList; -import java.util.List; - +import com.google.gson.JsonObject; import org.apache.tinkerpop.gremlin.structure.Vertex; import org.openecomp.aai.db.props.AAIProperties; import org.openecomp.aai.exceptions.AAIException; @@ -31,7 +28,9 @@ import org.openecomp.aai.introspection.Introspector; import org.openecomp.aai.introspection.exceptions.AAIUnknownObjectException; import org.openecomp.aai.serialization.queryformats.exceptions.AAIFormatVertexException; -import com.google.gson.JsonObject; +import java.io.UnsupportedEncodingException; +import java.util.ArrayList; +import java.util.List; public class SimpleFormat extends RawFormat { @@ -59,7 +58,7 @@ public class SimpleFormat extends RawFormat { wrapper.add(v); try { - serializer.dbToObject(wrapper, obj, this.depth, false, "false"); + serializer.dbToObject(wrapper, obj, this.depth, true, "false"); } catch (AAIException | UnsupportedEncodingException e) { throw new AAIFormatVertexException("Failed to format vertex - error while serializing: " + e.getMessage(), e); } diff --git a/aai-core/src/main/java/org/openecomp/aai/serialization/queryformats/utils/QueryParamInjector.java b/aai-core/src/main/java/org/openecomp/aai/serialization/queryformats/utils/QueryParamInjector.java index 725152dd..22ff9b33 100644 --- a/aai-core/src/main/java/org/openecomp/aai/serialization/queryformats/utils/QueryParamInjector.java +++ b/aai-core/src/main/java/org/openecomp/aai/serialization/queryformats/utils/QueryParamInjector.java @@ -20,17 +20,16 @@ package org.openecomp.aai.serialization.queryformats.utils; -import java.lang.reflect.InvocationTargetException; -import java.lang.reflect.Method; -import java.util.Set; - -import javax.ws.rs.core.MultivaluedMap; - import org.openecomp.aai.serialization.queryformats.exceptions.QueryParamInjectionException; import org.openecomp.aai.serialization.queryformats.params.Inject; import org.openecomp.aai.serialization.queryformats.params.Setter; import org.reflections.Reflections; +import javax.ws.rs.core.MultivaluedMap; +import java.lang.reflect.InvocationTargetException; +import java.lang.reflect.Method; +import java.util.Set; + public class QueryParamInjector { private final Set<Class<?>> results; diff --git a/aai-core/src/main/java/org/openecomp/aai/serialization/queryformats/utils/UrlBuilder.java b/aai-core/src/main/java/org/openecomp/aai/serialization/queryformats/utils/UrlBuilder.java index 7f088569..f988ee9e 100644 --- a/aai-core/src/main/java/org/openecomp/aai/serialization/queryformats/utils/UrlBuilder.java +++ b/aai-core/src/main/java/org/openecomp/aai/serialization/queryformats/utils/UrlBuilder.java @@ -20,31 +20,31 @@ package org.openecomp.aai.serialization.queryformats.utils; -import java.io.UnsupportedEncodingException; -import java.net.URI; -import java.net.URISyntaxException; - import org.apache.tinkerpop.gremlin.structure.Vertex; -import org.openecomp.aai.db.props.AAIProperties; import org.openecomp.aai.exceptions.AAIException; import org.openecomp.aai.introspection.Version; import org.openecomp.aai.serialization.db.DBSerializer; import org.openecomp.aai.serialization.queryformats.exceptions.AAIFormatVertexException; import org.openecomp.aai.util.AAIApiServerURLBase; +import org.openecomp.aai.util.AAIConstants; import org.openecomp.aai.workarounds.LegacyURITransformer; +import java.io.UnsupportedEncodingException; +import java.net.URI; +import java.net.URISyntaxException; + public class UrlBuilder { private final DBSerializer serializer; private final Version version; private final String serverBase; - + public UrlBuilder (Version version, DBSerializer serializer) throws AAIException { this.serializer = serializer; this.version = version; - this.serverBase = AAIApiServerURLBase.get(AAIProperties.LATEST); + this.serverBase = this.getServerBase(version); } - + public UrlBuilder (Version version, DBSerializer serializer, String serverBase) { this.serializer = serializer; this.version = version; @@ -57,9 +57,13 @@ public class UrlBuilder { final StringBuilder result = new StringBuilder(); final URI uri = this.serializer.getURIForVertex(v); - result.append(this.serverBase); + if (this.version.compareTo(Version.v11) >= 0) { + result.append(AAIConstants.AAI_APP_ROOT); + } else { + result.append(this.serverBase); + } result.append(this.version); - result.append(uri.getRawPath()); + result.append(uri); return result.toString(); } catch (UnsupportedEncodingException | IllegalArgumentException | SecurityException e) { @@ -72,11 +76,15 @@ public class UrlBuilder { result.append("/resources/id/" + v.id()); result.insert(0, this.version); - result.insert(0, this.serverBase); + if (this.version.compareTo(Version.v11) >= 0) { + result.insert(0, AAIConstants.AAI_APP_ROOT); + } else { + result.insert(0, this.serverBase); + } return result.toString(); } - + protected String getServerBase(Version v) throws AAIException { return AAIApiServerURLBase.get(v); } diff --git a/aai-core/src/main/java/org/openecomp/aai/serialization/tinkerpop/TreeBackedEdge.java b/aai-core/src/main/java/org/openecomp/aai/serialization/tinkerpop/TreeBackedEdge.java index cb71383f..774ab28f 100644 --- a/aai-core/src/main/java/org/openecomp/aai/serialization/tinkerpop/TreeBackedEdge.java +++ b/aai-core/src/main/java/org/openecomp/aai/serialization/tinkerpop/TreeBackedEdge.java @@ -20,8 +20,6 @@ package org.openecomp.aai.serialization.tinkerpop; -import java.util.Iterator; - import org.apache.tinkerpop.gremlin.structure.Direction; import org.apache.tinkerpop.gremlin.structure.Edge; import org.apache.tinkerpop.gremlin.structure.Graph; @@ -29,6 +27,8 @@ import org.apache.tinkerpop.gremlin.structure.Vertex; import org.apache.tinkerpop.gremlin.structure.util.detached.DetachedEdge; import org.apache.tinkerpop.gremlin.util.iterator.IteratorUtils; +import java.util.Iterator; + /** * Represents a {@link Edge} that is disconnected from a {@link Graph} however, diff --git a/aai-core/src/main/java/org/openecomp/aai/serialization/tinkerpop/TreeBackedVertex.java b/aai-core/src/main/java/org/openecomp/aai/serialization/tinkerpop/TreeBackedVertex.java index c51c3c2d..7ebad216 100644 --- a/aai-core/src/main/java/org/openecomp/aai/serialization/tinkerpop/TreeBackedVertex.java +++ b/aai-core/src/main/java/org/openecomp/aai/serialization/tinkerpop/TreeBackedVertex.java @@ -20,19 +20,15 @@ package org.openecomp.aai.serialization.tinkerpop; +import org.apache.tinkerpop.gremlin.process.traversal.step.util.Tree; +import org.apache.tinkerpop.gremlin.structure.*; +import org.apache.tinkerpop.gremlin.structure.util.detached.DetachedVertex; + import java.util.ArrayList; import java.util.Collections; import java.util.Iterator; import java.util.List; -import org.apache.tinkerpop.gremlin.process.traversal.step.util.Tree; -import org.apache.tinkerpop.gremlin.structure.Direction; -import org.apache.tinkerpop.gremlin.structure.Edge; -import org.apache.tinkerpop.gremlin.structure.Element; -import org.apache.tinkerpop.gremlin.structure.Graph; -import org.apache.tinkerpop.gremlin.structure.Vertex; -import org.apache.tinkerpop.gremlin.structure.util.detached.DetachedVertex; - /** * Represents a {@link Vertex} that is disconnected from a {@link Graph} however, * traversals are supported as they are backed by a Tree with saturated {@link Vertex} and {@link Edge} objects. |