summaryrefslogtreecommitdiffstats
path: root/aai-core
diff options
context:
space:
mode:
authorVenkata Harish K Kajur <vk250x@att.com>2017-05-24 13:46:23 -0400
committerVenkata Harish K Kajur <vk250x@att.com>2017-05-24 13:46:59 -0400
commita93b19450f6fb966afa1c30a6795e8e670d2aee7 (patch)
treea248d180e9d41a177887a02c4b4d82cfb7176871 /aai-core
parentc2fddaed33f9f7bbec3feca7bf905f0a1e56b3ed (diff)
Update the aai-common with the latest code
Change-Id: Ia4758a3d7e462e5120fa1db7ebe97adaeac3ebc2 Signed-off-by: Venkata Harish K Kajur <vk250x@att.com>
Diffstat (limited to 'aai-core')
-rw-r--r--aai-core/.gitignore11
-rw-r--r--aai-core/src/main/java/org/openecomp/aai/db/DbMethHelper.java158
-rw-r--r--aai-core/src/main/java/org/openecomp/aai/dbgen/DataGrooming.java101
-rw-r--r--aai-core/src/main/java/org/openecomp/aai/dbgen/GenTester.java58
-rw-r--r--aai-core/src/main/java/org/openecomp/aai/dbgen/SchemaGenerator.java66
-rw-r--r--aai-core/src/main/java/org/openecomp/aai/dbmodel/DbEdgeRules.java2
-rw-r--r--aai-core/src/main/java/org/openecomp/aai/introspection/Introspector.java2
-rw-r--r--aai-core/src/main/java/org/openecomp/aai/introspection/ModelInjestor.java1
-rw-r--r--aai-core/src/main/java/org/openecomp/aai/introspection/sideeffect/DataLinkReader.java24
-rw-r--r--aai-core/src/main/java/org/openecomp/aai/introspection/sideeffect/SideEffectRunner.java13
-rw-r--r--aai-core/src/main/java/org/openecomp/aai/introspection/sideeffect/SideEffectRunnerHelper.java14
-rw-r--r--aai-core/src/main/java/org/openecomp/aai/introspection/tools/IntrospectorValidator.java12
-rw-r--r--aai-core/src/main/java/org/openecomp/aai/introspection/tools/IssueType.java2
-rw-r--r--aai-core/src/main/java/org/openecomp/aai/logging/EcompElapsedTime.java3
-rw-r--r--aai-core/src/main/java/org/openecomp/aai/logging/EcompStartTime.java3
-rw-r--r--aai-core/src/main/java/org/openecomp/aai/logging/ErrorLogHelper.java65
-rw-r--r--aai-core/src/main/java/org/openecomp/aai/logging/LoggingContext.java101
-rw-r--r--aai-core/src/main/java/org/openecomp/aai/parsers/query/LegacyQueryParser.java13
-rw-r--r--aai-core/src/main/java/org/openecomp/aai/parsers/query/QueryParser.java14
-rw-r--r--aai-core/src/main/java/org/openecomp/aai/parsers/query/UniqueURIQueryParser.java60
-rw-r--r--aai-core/src/main/java/org/openecomp/aai/parsers/uri/Parsable.java18
-rw-r--r--aai-core/src/main/java/org/openecomp/aai/parsers/uri/URIParser.java35
-rw-r--r--aai-core/src/main/java/org/openecomp/aai/parsers/uri/URIToDBKey.java38
-rw-r--r--aai-core/src/main/java/org/openecomp/aai/parsers/uri/URIToExtensionInformation.java38
-rw-r--r--aai-core/src/main/java/org/openecomp/aai/parsers/uri/URIToObject.java102
-rw-r--r--aai-core/src/main/java/org/openecomp/aai/parsers/uri/URIToRelationshipObject.java61
-rw-r--r--aai-core/src/main/java/org/openecomp/aai/parsers/uri/URIValidate.java29
-rw-r--r--aai-core/src/main/java/org/openecomp/aai/query/builder/GraphTraversalBuilder.java125
-rw-r--r--aai-core/src/main/java/org/openecomp/aai/query/builder/GremlinPipelineBuilder.java2
-rw-r--r--aai-core/src/main/java/org/openecomp/aai/query/builder/GremlinQueryBuilder.java104
-rw-r--r--aai-core/src/main/java/org/openecomp/aai/query/builder/GremlinTraversal.java16
-rw-r--r--aai-core/src/main/java/org/openecomp/aai/query/builder/GremlinUnique.java16
-rw-r--r--aai-core/src/main/java/org/openecomp/aai/query/builder/QueryBuilder.java50
-rw-r--r--aai-core/src/main/java/org/openecomp/aai/query/builder/TraversalQuery.java28
-rw-r--r--aai-core/src/main/java/org/openecomp/aai/rest/RestTokens.java36
-rw-r--r--aai-core/src/main/java/org/openecomp/aai/restcore/RESTAPI.java61
-rw-r--r--aai-core/src/main/java/org/openecomp/aai/restcore/search/GremlinGroovyShellSingleton.java4
-rw-r--r--aai-core/src/main/java/org/openecomp/aai/serialization/db/DBSerializer.java106
-rw-r--r--aai-core/src/main/java/org/openecomp/aai/serialization/db/EdgeRules.java51
-rw-r--r--aai-core/src/main/java/org/openecomp/aai/serialization/db/exceptions/EdgeMultiplicityException.java40
-rw-r--r--aai-core/src/main/java/org/openecomp/aai/serialization/engines/TransactionalGraphEngine.java22
-rw-r--r--aai-core/src/main/java/org/openecomp/aai/serialization/engines/query/GraphTraversalQueryEngine.java9
-rw-r--r--aai-core/src/main/java/org/openecomp/aai/serialization/engines/query/GremlinPipelineQueryEngine.java2
-rw-r--r--aai-core/src/main/java/org/openecomp/aai/serialization/engines/query/QueryEngine.java2
-rw-r--r--aai-core/src/main/java/org/openecomp/aai/serialization/queryformats/Formatter.java20
-rw-r--r--aai-core/src/main/java/org/openecomp/aai/util/AAIConfig.java19
-rw-r--r--aai-core/src/main/java/org/openecomp/aai/util/AAITxnLog.java32
-rw-r--r--aai-core/src/main/java/org/openecomp/aai/util/HttpsAuthClient.java140
-rw-r--r--aai-core/src/test/java/org/openecomp/aai/exceptions/AAIExceptionTest.java15
-rw-r--r--aai-core/src/test/java/org/openecomp/aai/exceptions/AAIExceptionWithInfoTest.java9
-rw-r--r--aai-core/src/test/java/org/openecomp/aai/introspection/IntrospectorTestSpec.java9
-rw-r--r--aai-core/src/test/java/org/openecomp/aai/introspection/MoxyEngineTest.java12
-rw-r--r--aai-core/src/test/java/org/openecomp/aai/introspection/PojoInjestorTest.java9
-rw-r--r--aai-core/src/test/java/org/openecomp/aai/introspection/PojoLoaderTest.java6
-rw-r--r--aai-core/src/test/java/org/openecomp/aai/introspection/PojoStrategyTest.java5
-rw-r--r--aai-core/src/test/java/org/openecomp/aai/introspection/PropertyPredicatesTest.java11
-rw-r--r--aai-core/src/test/java/org/openecomp/aai/introspection/ReflectionEngineTest.java16
-rw-r--r--aai-core/src/test/java/org/openecomp/aai/introspection/sideeffect/DataCopyTest.java4
-rw-r--r--aai-core/src/test/java/org/openecomp/aai/introspection/sideeffect/DataLinkTest.java4
-rw-r--r--aai-core/src/test/java/org/openecomp/aai/introspection/validation/IntrospectorValidationTest.java99
-rw-r--r--aai-core/src/test/java/org/openecomp/aai/logging/LoggingContextTest.java114
-rw-r--r--aai-core/src/test/java/org/openecomp/aai/parsers/query/GraphTraversalTest.java145
-rw-r--r--aai-core/src/test/java/org/openecomp/aai/parsers/query/LegacyQueryTest.java67
-rw-r--r--aai-core/src/test/java/org/openecomp/aai/parsers/query/RelationshipGremlinQueryTest.java4
-rw-r--r--aai-core/src/test/java/org/openecomp/aai/parsers/query/RelationshipQueryTest.java6
-rw-r--r--aai-core/src/test/java/org/openecomp/aai/parsers/query/UniqueRelationshipQueryTest.java30
-rw-r--r--aai-core/src/test/java/org/openecomp/aai/parsers/relationship/RelationshipToURITest.java4
-rw-r--r--aai-core/src/test/java/org/openecomp/aai/parsers/uri/URIParserTest.java4
-rw-r--r--aai-core/src/test/java/org/openecomp/aai/parsers/uri/URIToExtensionInformationTest.java4
-rw-r--r--aai-core/src/test/java/org/openecomp/aai/parsers/uri/URIToObjectTest.java4
-rw-r--r--aai-core/src/test/java/org/openecomp/aai/parsers/uri/URIToRelationshipObjectTest.java7
-rw-r--r--aai-core/src/test/java/org/openecomp/aai/query/builder/TraversalQueryTest.java19
-rw-r--r--aai-core/src/test/java/org/openecomp/aai/serialization/db/DbAliasTest.java6
-rw-r--r--aai-core/src/test/java/org/openecomp/aai/workarounds/RemoveDME2QueryParamsTest.java91
-rw-r--r--aai-core/src/test/resources/bundleconfig-local/etc/appprops/error.properties1
-rw-r--r--aai-core/src/test/resources/bundleconfig-local/etc/oxm/aai_oxm_v10.xml6
-rw-r--r--aai-core/src/test/resources/bundleconfig-local/etc/oxm/aai_oxm_v9.xml6
-rw-r--r--aai-core/src/test/resources/bundleconfig-local/etc/scriptdata/dependencies/vRouterServiceInstanceFile.txt6
-rw-r--r--aai-core/src/test/resources/log4j.properties3
-rw-r--r--aai-core/src/test/resources/logback.xml292
80 files changed, 2239 insertions, 708 deletions
diff --git a/aai-core/.gitignore b/aai-core/.gitignore
new file mode 100644
index 00000000..574ae547
--- /dev/null
+++ b/aai-core/.gitignore
@@ -0,0 +1,11 @@
+.settings
+target/
+**/logs/
+bundleconfig-local/etc/auth/aai-client-cert.p12
+bundleconfig-local/etc/auth/tomcat_keystore
+bundleconfig-local/etc/oxm
+src/main/aai_schema
+bundleconfig-local/etc/logback.xml
+/.pydevproject
+/test_csvWriter.csv
+/bin/
diff --git a/aai-core/src/main/java/org/openecomp/aai/db/DbMethHelper.java b/aai-core/src/main/java/org/openecomp/aai/db/DbMethHelper.java
new file mode 100644
index 00000000..79172d9b
--- /dev/null
+++ b/aai-core/src/main/java/org/openecomp/aai/db/DbMethHelper.java
@@ -0,0 +1,158 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * org.openecomp.aai
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.aai.db;
+
+import java.io.UnsupportedEncodingException;
+import java.net.URI;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.Map.Entry;
+import java.util.Optional;
+
+import org.apache.tinkerpop.gremlin.structure.Vertex;
+import org.apache.tinkerpop.gremlin.structure.VertexProperty;
+
+import org.openecomp.aai.exceptions.AAIException;
+import org.openecomp.aai.introspection.Introspector;
+import org.openecomp.aai.introspection.Loader;
+import org.openecomp.aai.introspection.exceptions.AAIUnknownObjectException;
+import org.openecomp.aai.parsers.query.QueryParser;
+import org.openecomp.aai.parsers.relationship.RelationshipToURI;
+import org.openecomp.aai.query.builder.QueryBuilder;
+import org.openecomp.aai.serialization.engines.TransactionalGraphEngine;
+
+public class DbMethHelper {
+
+ private final Loader loader;
+ private final TransactionalGraphEngine engine;
+
+ protected DbMethHelper() {
+ this.loader = null;
+ this.engine = null;
+ }
+ public DbMethHelper(Loader loader, TransactionalGraphEngine engine) {
+ this.loader = loader;
+ this.engine = engine;
+ }
+ /**
+ *
+ * @param type
+ * @param map - form [{type}.{propname}:{value}]
+ * @return
+ * @throws UnsupportedEncodingException
+ * @throws AAIException
+ */
+ public Optional<Vertex> searchVertexByIdentityMap(String type, Map<String, Object> map) throws AAIException {
+
+ Introspector relationship = constructRelationship(type, map);
+ RelationshipToURI parser;
+ URI uri;
+ QueryParser queryParser;
+ try {
+ parser = new RelationshipToURI(loader, relationship);
+ uri = parser.getUri();
+ queryParser = this.engine.getQueryBuilder().createQueryFromURI(uri);
+ } catch (UnsupportedEncodingException e) {
+ throw new AAIException("AAI_3000");
+ }
+
+ List<Vertex> results = queryParser.getQueryBuilder().toList();
+
+ return reduceToSingleVertex(results, map);
+ }
+
+ /**
+ * @param type
+ * @param map - form [{propname}:{value}]
+ * @return
+ * @throws AAIException
+ */
+ public Optional<Vertex> locateUniqueVertex(String type, Map<String, Object> map) throws AAIException {
+
+ return reduceToSingleVertex(locateUniqueVertices(type, map), map);
+ }
+
+ public List<Vertex> locateUniqueVertices(String type, Map<String, Object> map) throws AAIException {
+ Introspector obj = this.createIntrospectorFromMap(type, map);
+ QueryBuilder builder = this.engine.getQueryBuilder().exactMatchQuery(obj);
+
+ return builder.toList();
+ }
+ private Introspector constructRelationship(String type, Map<String, Object> map) throws AAIUnknownObjectException {
+ final Introspector relationship = loader.introspectorFromName("relationship");
+ relationship.setValue("related-to", type);
+ final List<Object> data = relationship.getValue("relationship-data");
+ for (Entry<String, Object> entry : map.entrySet()) {
+ final Introspector dataObj = loader.introspectorFromName("relationship-data");
+ dataObj.setValue("relationship-key", entry.getKey());
+ dataObj.setValue("relationship-value", entry.getValue());
+ data.add(dataObj.getUnderlyingObject());
+ }
+
+ return relationship;
+ }
+
+ private Introspector createIntrospectorFromMap(String targetNodeType, Map<String, Object> propHash) throws AAIUnknownObjectException {
+ final Introspector result = loader.introspectorFromName(targetNodeType);
+ for (Entry<String, Object> entry : propHash.entrySet()) {
+ result.setValue(entry.getKey(), entry.getValue());
+ }
+ return result;
+ }
+
+ private Optional<Vertex> reduceToSingleVertex(List<Vertex> vertices, Map<String, Object> map) throws AAIException {
+ if (vertices.isEmpty()){
+ return Optional.empty();
+ } else if (vertices.size() > 1) {
+ throw new AAIException("AAI_6112", "More than one Node found by getUniqueNode for params: " + map);
+ }
+
+ return Optional.of(vertices.get(0));
+ }
+ public List<String> getVertexProperties(Vertex v) {
+ List<String> retArr = new ArrayList<>();
+ if( v == null ){
+ retArr.add("null Node object passed to showPropertiesForNode()\n");
+ }
+ else {
+ String nodeType;
+ Object ob = v.<Object>property("aai-node-type").orElse(null);
+ if( ob == null ){
+ nodeType = "null";
+ }
+ else{
+ nodeType = ob.toString();
+ }
+
+ retArr.add(" AAINodeType/VtxID for this Node = [" + nodeType + "/" + v.id() + "]");
+ retArr.add(" Property Detail: ");
+ Iterator<VertexProperty<Object>> pI = v.properties();
+ while( pI.hasNext() ){
+ VertexProperty<Object> tp = pI.next();
+ Object val = tp.value();
+ retArr.add("Prop: [" + tp.key() + "], val = [" + val + "] ");
+ }
+ }
+ return retArr;
+ }
+}
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 6a8ad1b6..18f43ba8 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
@@ -67,7 +67,7 @@ import com.thinkaurelius.titan.core.TitanVertex;
public class DataGrooming {
- private static final EELFLogger LOGGER = EELFManager.getInstance().getLogger(DataGrooming.class);
+ private static EELFLogger LOGGER;
private static final String FROMAPPID = "AAI-DB";
private static final String TRANSID = UUID.randomUUID().toString();
private static int dupeGrpsDeleted = 0;
@@ -83,7 +83,7 @@ public class DataGrooming {
Properties props = System.getProperties();
props.setProperty(Configuration.PROPERTY_LOGGING_FILE_NAME, AAIConstants.AAI_DATA_GROOMING_LOGBACK_PROPS);
props.setProperty(Configuration.PROPERTY_LOGGING_FILE_PATH, AAIConstants.AAI_HOME_ETC_APP_PROPERTIES);
-
+ LOGGER = EELFManager.getInstance().getLogger(DataGrooming.class);
String ver = "version"; // Placeholder
Boolean doAutoFix = false;
Boolean edgesOnlyFlag = false;
@@ -557,7 +557,8 @@ public class DataGrooming {
// NOTE --- We're just going to do the same check from the other direction - because
// there could be duplicates or the pointer going the other way could be broken
ArrayList <TitanVertex> tmpListSec = new ArrayList <> ();
- tmpListSec = getConnectedChildren( g, parentVtx ) ;
+
+ tmpListSec = getConnectedChildrenOfOneType( g, parentVtx, nType ) ;
Iterator<TitanVertex> vIter = tmpListSec.iterator();
while (vIter.hasNext()) {
TitanVertex tmpV = vIter.next();
@@ -682,7 +683,7 @@ public class DataGrooming {
LOGGER.warn(">>> WARNING trying to get next vertex on the vItor2 ");
continue;
}
-
+
counter++;
String thisVertId = "";
try {
@@ -1315,15 +1316,28 @@ public class DataGrooming {
* @return the boolean
*/
private static Boolean anyKeyFieldsMissing(String nType, Vertex v, DbMaps dbMaps) {
-
+
try {
+ if( nType != null && !nType.trim().equals("")
+ && !dbMaps.NodeKeyProps.containsKey(nType) ){
+ // They gave us a non-empty nodeType but our NodeKeyProps does
+ // not have data for it. Since we do not know what the
+ // key params are for this type of node, we will just
+ // return "false".
+ String emsg = " -- WARNING -- Unrecognized nodeType: [" + nType
+ + "]. We cannot determine required keys for this nType. ";
+ // NOTE - this will be caught below and a "false" returned
+ throw new AAIException("AAI_6121", emsg);
+ }
+
// Determine what the key fields are for this nodeType
Collection <String> keyPropNamesColl = new ArrayList <>();
if( dbMaps.NodeKeyProps.containsKey(nType) ){
keyPropNamesColl = dbMaps.NodeKeyProps.get(nType);
}
else {
- throw new AAIException("AAI_6105", "Required Property name(s) not found for nodeType = " + nType + ")");
+ // NOTE - this will be caught below and a "false" returned
+ throw new AAIException("AAI_6121", "Definition of key props not found for nodeType = " + nType + ")");
}
Iterator<String> keyPropI = keyPropNamesColl.iterator();
@@ -1336,8 +1350,9 @@ public class DataGrooming {
}
}
} catch (AAIException e) {
- // Something was wrong
- return true;
+ // Something was wrong -- but since we weren't able to check
+ // the keys, we will not declare that it is missing keys.
+ return false;
}
return false;
}
@@ -1769,14 +1784,12 @@ public class DataGrooming {
}
} else {
// More than one node have the same key fields since they may
- // depend on a parent node for
- // uniqueness. Since we're finding more than one, we want to
- // check to see if any of the
- // vertices that have this set of keys are also pointing at the
- // same 'parent' node.
+ // depend on a parent node for uniqueness. Since we're finding
+ // more than one, we want to check to see if any of the
+ // vertices that have this set of keys (and are the same nodeType)
+ // are also pointing at the same 'parent' node.
// Note: for a given set of key data, it is possible that there
- // could be more than one set of
- // duplicates.
+ // could be more than one set of duplicates.
HashMap<String, ArrayList<TitanVertex>> vertsGroupedByParentHash = groupVertsByDepNodes(
transId, fromAppId, g, version, nType,
checkVertList, dbMaps);
@@ -1849,10 +1862,10 @@ public class DataGrooming {
String transId, String fromAppId, TitanTransaction g, String version,
String nType, ArrayList<TitanVertex> passedVertList, DbMaps dbMaps)
throws AAIException {
- // Given a list of Titan Vertices, group them together by dependent
- // nodes. Ie. if given a list of
- // ip address nodes (assumed to all have the same key info) they might
- // sit under several different parent vertices.
+ // Given a list of Titan Vertices of one nodeType (see AAI-8956), group
+ // them together by the parent node they depend on.
+ // Ie. if given a list of ip address nodes (assumed to all have the
+ // same key info) they might sit under several different parent vertices.
// Under Normal conditions, there would only be one per parent -- but
// we're trying to find duplicates - so we
// allow for the case where more than one is under the same parent node.
@@ -1873,24 +1886,22 @@ public class DataGrooming {
while (ntItr.hasNext()) {
depNodeTypeL.add(ntItr.next());
}
- // For each vertex, we want find its dependent vertex and add it to
- // other vertexes that are dependent on that same guy.
+ // For each vertex, we want find its depended-on/parent vertex so we
+ // can track what other vertexes that are dependent on that same guy.
if (passedVertList != null) {
Iterator<TitanVertex> iter = passedVertList.iterator();
while (iter.hasNext()) {
TitanVertex thisVert = iter.next();
- ArrayList<TitanVertex> connectedVList = getConnectedNodes( g, thisVert );
- Iterator<TitanVertex> connIter = connectedVList.iterator();
- while (connIter.hasNext()) {
- TitanVertex tvCon = connIter.next();
- String conNt = "";
- Object obj = tvCon.<Object>property("aai-node-type").orElse(null);
+ TitanVertex tmpParentVtx = getConnectedParent( g, thisVert );
+ if( tmpParentVtx != null ) {
+ String parentNt = null;
+ Object obj = tmpParentVtx.<Object>property("aai-node-type").orElse(null);
if (obj != null) {
- conNt = obj.toString();
+ parentNt = obj.toString();
}
- if (depNTColl.contains(conNt)) {
+ if (depNTColl.contains(parentNt)) {
// This must be the parent/dependent node
- String parentVid = tvCon.id().toString();
+ String parentVid = tmpParentVtx.id().toString();
if (retHash.containsKey(parentVid)) {
// add this vert to the list for this parent key
retHash.get(parentVid).add(thisVert);
@@ -2200,23 +2211,43 @@ public class DataGrooming {
}// End of getConnectedNodes()
- private static ArrayList <TitanVertex> getConnectedChildren( TitanTransaction graph,
- TitanVertex startVtx ) throws AAIException{
+ private static ArrayList <TitanVertex> getConnectedChildrenOfOneType( TitanTransaction graph,
+ TitanVertex startVtx, String childNType ) throws AAIException{
ArrayList <TitanVertex> childList = new ArrayList <> ();
-
Iterable <?> verts = startVtx.query().direction(Direction.OUT).has("isParent",true).vertices();
Iterator <?> vertI = verts.iterator();
TitanVertex tmpVtx = null;
while( vertI != null && vertI.hasNext() ){
tmpVtx = (TitanVertex) vertI.next();
- childList.add(tmpVtx);
+ Object ob = tmpVtx.<Object>property("aai-node-type").orElse(null);
+ if (ob != null) {
+ String tmpNt = ob.toString();
+ if( tmpNt.equals(childNType)){
+ childList.add(tmpVtx);
+ }
+ }
}
return childList;
- }// End of getConnectedChildren()
+ }// End of getConnectedChildrenOfOneType()
+
+
+ private static TitanVertex getConnectedParent( TitanTransaction graph,
+ TitanVertex startVtx ) throws AAIException{
+
+ TitanVertex parentVtx = null;
+ Iterable <?> verts = startVtx.query().direction(Direction.IN).has("isParent",true).vertices();
+ Iterator <?> vertI = verts.iterator();
+ while( vertI != null && vertI.hasNext() ){
+ // Note - there better only be one!
+ parentVtx = (TitanVertex) vertI.next();
+ }
+
+ return parentVtx;
+ }// End of getConnectedParent()
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 a3273fb3..14c58cb5 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,22 +20,24 @@
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 {
- private static final EELFLogger LOGGER = EELFManager.getInstance().getLogger(GenTester.class);
+ private static EELFLogger LOGGER;
/**
* The main method.
@@ -50,20 +52,23 @@ public class GenTester {
Properties props = System.getProperties();
props.setProperty(Configuration.PROPERTY_LOGGING_FILE_NAME, AAIConstants.AAI_CREATE_DB_SCHEMA_LOGBACK_PROPS);
props.setProperty(Configuration.PROPERTY_LOGGING_FILE_PATH, AAIConstants.AAI_HOME_ETC_APP_PROPERTIES);
+ LOGGER = EELFManager.getInstance().getLogger(GenTester.class);
boolean addDefaultCR = true;
try {
AAIConfig.init();
if (args != null && args.length > 0 ){
if( "genDbRulesOnly".equals(args[0]) ){
- ErrorLogHelper.logError("AAI_3100",
+ ErrorLogHelper.logError("AAI_3100",
" This option is no longer supported. What was in DbRules is now derived from the OXM files. ");
return;
}
else if ( "GEN_DB_WITH_NO_SCHEMA".equals(args[0]) ){
// Note this is done to create an empty DB with no Schema so that
// an HBase copyTable can be used to set up a copy of the db.
- LOGGER.info(" ---- NOTE --- about to load a graph without doing any schema processing (takes a little while) -------- ");
+ String imsg = " ---- NOTE --- about to load a graph without doing any schema processing (takes a little while) -------- ";
+ System.out.println(imsg);
+ LOGGER.info(imsg);
graph = AAIGraph.getInstance().getGraph();
if( graph == null ){
@@ -71,7 +76,9 @@ public class GenTester {
return;
}
else {
- LOGGER.auditEvent("Successfully loaded a Titan graph without doing any schema work. ");
+ String amsg = "Successfully loaded a Titan graph without doing any schema work. ";
+ System.out.println(amsg);
+ LOGGER.auditEvent(amsg);
return;
}
} else if ("GEN_DB_WITH_NO_DEFAULT_CR".equals(args[0])) {
@@ -79,15 +86,24 @@ public class GenTester {
}
else {
ErrorLogHelper.logError("AAI_3000", "Unrecognized argument passed to GenTester.java: [" + args[0] + "]. ");
- LOGGER.error("Unrecognized argument passed to GenTester.java: [" + args[0] + "]. ");
- LOGGER.error("Either pass no argument for normal processing, or use 'GEN_DB_WITH_NO_SCHEMA'.");
+
+ String emsg = "Unrecognized argument passed to GenTester.java: [" + args[0] + "]. ";
+ System.out.println(emsg);
+ LOGGER.error(emsg);
+
+ emsg = "Either pass no argument for normal processing, or use 'GEN_DB_WITH_NO_SCHEMA'.";
+ System.out.println(emsg);
+ LOGGER.error(emsg);
+
return;
}
}
//AAIConfig.init();
ErrorLogHelper.loadProperties();
- LOGGER.info(" ---- NOTE --- about to open graph (takes a little while)--------;");
+ String imsg = " ---- NOTE --- about to open graph (takes a little while)--------;";
+ System.out.println(imsg);
+ LOGGER.info(imsg);
graph = AAIGraph.getInstance().getGraph();
if( graph == null ){
@@ -95,11 +111,13 @@ public class GenTester {
return;
}
- // Load the propertyKeys, indexes and edge-Labels into the DB
- TitanManagement graphMgt = graph.openManagement();
+ // Load the propertyKeys, indexes and edge-Labels into the DB
+ TitanManagement graphMgt = graph.openManagement();
- LOGGER.info("-- Loading new schema elements into Titan --");
- SchemaGenerator.loadSchemaIntoTitan( graph, graphMgt, addDefaultCR );
+ imsg = "-- Loading new schema elements into Titan --";
+ System.out.println(imsg);
+ LOGGER.info(imsg);
+ SchemaGenerator.loadSchemaIntoTitan( graph, graphMgt, addDefaultCR );
} catch(Exception ex) {
ErrorLogHelper.logError("AAI_4000", ex.getMessage());
@@ -107,10 +125,14 @@ public class GenTester {
if( graph != null ){
- LOGGER.info("-- graph commit");
+ String imsg = "-- graph commit";
+ System.out.println(imsg);
+ LOGGER.info(imsg);
graph.tx().commit();
- LOGGER.info("-- graph shutdown ");
+ imsg = "-- graph shutdown ";
+ System.out.println(imsg);
+ LOGGER.info(imsg);
graph.close();
}
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 fa1d8e49..63606017 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 com.att.eelf.configuration.EELFLogger;
-import com.att.eelf.configuration.EELFManager;
-import com.google.common.collect.Multimap;
-import com.thinkaurelius.titan.core.*;
-import com.thinkaurelius.titan.core.schema.TitanManagement;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Map;
+import java.util.Optional;
+import java.util.Set;
+
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;
@@ -37,11 +39,18 @@ import org.openecomp.aai.schema.enums.PropertyMetadata;
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 {
+public class SchemaGenerator{
private static final EELFLogger LOGGER = EELFManager.getInstance().getLogger(SchemaGenerator.class);
private static boolean addDefaultCR = true;
@@ -72,6 +81,7 @@ public class SchemaGenerator {
}
catch (Exception ex){
LOGGER.error(" ERROR - Could not run AAIConfig.init(). ", ex);
+ System.out.println(" ERROR - Could not run AAIConfig.init(). ");
System.exit(1);
}
@@ -93,13 +103,18 @@ public class SchemaGenerator {
}
} catch (AAIException e) {
LOGGER.error("could not get edge rules", e);
+ System.out.println("could not get edge rules");
System.exit(1);
}
for( String label: labels){
if( graphMgmt.containsRelationType(label) ) {
- LOGGER.debug(" EdgeLabel [" + label + "] already existed. ");
+ String dmsg = " EdgeLabel [" + label + "] already existed. ";
+ System.out.println(dmsg);
+ LOGGER.debug(dmsg);
} else {
- LOGGER.debug("Making EdgeLabel: [" + label + "]");
+ String dmsg = "Making EdgeLabel: [" + label + "]";
+ System.out.println(dmsg);
+ LOGGER.debug(dmsg);
graphMgmt.makeEdgeLabel(label).multiplicity(Multiplicity.valueOf("MULTI")).make();
}
}
@@ -116,7 +131,9 @@ public class SchemaGenerator {
dbPropName = alias.get();
}
if( graphMgmt.containsRelationType(propName) ){
- LOGGER.debug(" PropertyKey [" + propName + "] already existed in the DB. ");
+ String dmsg = " PropertyKey [" + propName + "] already existed in the DB. ";
+ System.out.println(dmsg);
+ LOGGER.debug(dmsg);
} else {
Class<?> type = obj.getClass(propName);
Cardinality cardinality = Cardinality.SINGLE;
@@ -131,7 +148,9 @@ public class SchemaGenerator {
if (process) {
- LOGGER.info("Creating PropertyKey: [" + dbPropName + "], ["+ type.getSimpleName() + "], [" + cardinality + "]");
+ String imsg = "Creating PropertyKey: [" + dbPropName + "], ["+ type.getSimpleName() + "], [" + cardinality + "]";
+ System.out.println(imsg);
+ LOGGER.info(imsg);
PropertyKey propK;
if (!seenProps.containsKey(dbPropName)) {
propK = graphMgmt.makePropertyKey(dbPropName).dataType(type).cardinality(cardinality).make();
@@ -140,18 +159,26 @@ public class SchemaGenerator {
propK = seenProps.get(dbPropName);
}
if (graphMgmt.containsGraphIndex(dbPropName)) {
- LOGGER.debug(" Index [" + dbPropName + "] already existed in the DB. ");
+ String dmsg = " Index [" + dbPropName + "] already existed in the DB. ";
+ System.out.println(dmsg);
+ LOGGER.debug(dmsg);
} else {
if( obj.getIndexedProperties().contains(propName) ){
if( obj.getUniqueProperties().contains(propName) ){
- LOGGER.info("Add Unique index for PropertyKey: [" + dbPropName + "]");
- graphMgmt.buildIndex(dbPropName,Vertex.class).addKey(propK).unique().buildCompositeIndex();
+ imsg = "Add Unique index for PropertyKey: [" + dbPropName + "]";
+ System.out.println(imsg);
+ LOGGER.info(imsg);
+ graphMgmt.buildIndex(dbPropName,Vertex.class).addKey(propK).unique().buildCompositeIndex();
} else {
- LOGGER.info("Add index for PropertyKey: [" + dbPropName + "]");
- graphMgmt.buildIndex(dbPropName,Vertex.class).addKey(propK).buildCompositeIndex();
+ imsg = "Add index for PropertyKey: [" + dbPropName + "]";
+ System.out.println(imsg);
+ LOGGER.info(imsg);
+ graphMgmt.buildIndex(dbPropName,Vertex.class).addKey(propK).buildCompositeIndex();
}
} else {
- LOGGER.info("No index added for PropertyKey: [" + dbPropName + "]");
+ imsg = "No index added for PropertyKey: [" + dbPropName + "]";
+ System.out.println(imsg);
+ LOGGER.info(imsg);
}
}
}
@@ -159,7 +186,10 @@ public class SchemaGenerator {
}
}
- LOGGER.info("-- About to call graphMgmt commit");
+ String imsg = "-- About to call graphMgmt commit";
+ System.out.println(imsg);
+ LOGGER.info(imsg);
+
graphMgmt.commit();
}// End of loadSchemaIntoTitan()
diff --git a/aai-core/src/main/java/org/openecomp/aai/dbmodel/DbEdgeRules.java b/aai-core/src/main/java/org/openecomp/aai/dbmodel/DbEdgeRules.java
index 3f7dfb2e..f4b55504 100644
--- a/aai-core/src/main/java/org/openecomp/aai/dbmodel/DbEdgeRules.java
+++ b/aai-core/src/main/java/org/openecomp/aai/dbmodel/DbEdgeRules.java
@@ -397,7 +397,7 @@ public class DbEdgeRules {
.putAll("ctag-pool", "THIS_NODE_ONLY")
.putAll("subnet", "THIS_NODE_ONLY")
.putAll("sriov-vf", "THIS_NODE_ONLY")
- .putAll("vpn-binding", "ERROR_IF_ANY_IN_EDGES")
+ .putAll("vpn-binding", "ERROR_4_IN_EDGES_OR_CASCADE")
.putAll("vnf-image", "ERROR_IF_ANY_IN_EDGES")
.putAll("site-pair-set", "CASCADE_TO_CHILDREN")
.putAll("routing-instance", "CASCADE_TO_CHILDREN")
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 d3f4b0fe..ff0ae173 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
@@ -171,7 +171,7 @@ public abstract class Introspector implements Cloneable {
nameClass = ClassUtils.primitiveToWrapper(nameClass);
result = nameClass.getConstructor(String.class).newInstance(obj.toString());
}
- if (obj.getClass().getName().equals("java.lang.String")) {
+ if (obj instanceof String) {
result = nameClass.getConstructor(String.class).newInstance(obj);
} else if (!this.isListType(name) && !this.isComplexType(name)){
//box = obj.toString();
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 38775160..a8574d89 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
@@ -38,7 +38,6 @@ 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/sideeffect/DataLinkReader.java b/aai-core/src/main/java/org/openecomp/aai/introspection/sideeffect/DataLinkReader.java
index 89b03eab..db3dd5ac 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,7 +20,20 @@
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;
@@ -31,17 +44,6 @@ 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/SideEffectRunner.java b/aai-core/src/main/java/org/openecomp/aai/introspection/sideeffect/SideEffectRunner.java
index 3b33be1f..64a4d0cd 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,18 +20,19 @@
package org.openecomp.aai.introspection.sideeffect;
-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;
+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;
+
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 7362b70b..8a55ce82 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 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;
+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;
+
class SideEffectRunnerHelper implements Wanderer {
@@ -77,7 +77,7 @@ class SideEffectRunnerHelper implements Wanderer {
@Override
public void modifyComplexList(List<Introspector> list, List<Object> listReference, Introspector parent,
- Introspector child) {
+ Introspector child) {
// TODO Auto-generated method stub
}
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 cbe16b4e..6d451cdf 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
@@ -165,14 +165,22 @@ public class IntrospectorValidator implements Wanderer {
}
final Optional<String> visibility = obj.getPropertyMetadata(prop, PropertyMetadata.VISIBILITY);
- if(visibility.isPresent() && Visibility.internal.equals(Visibility.valueOf(visibility.get()))) {
+ if(visibility.isPresent() && Visibility.internal.equals(Visibility.valueOf(visibility.get())) && obj.getValue(prop) != null) {
Issue message =
this.buildMessage(Severity.ERROR, IssueType.PROPERTY_NOT_VISIBLE, "client attemptted to set property not visible: " + prop);
message.setIntrospector(obj);
message.setPropName(prop);
issues.add(message);
- }
+ }
+ final Optional<String> requires = obj.getPropertyMetadata(prop, PropertyMetadata.REQUIRES);
+ if (requires.isPresent() && (obj.getValue(prop) != null && obj.getValue(requires.get()) == null)) {
+ Issue message =
+ this.buildMessage(Severity.CRITICAL, IssueType.DEPENDENT_PROP_NOT_FOUND, prop + " requires " + requires.get() + " to also be popluated.");
+ message.setIntrospector(obj);
+ message.setPropName(prop);
+ issues.add(message);
+ }
}
if (!relationshipChain.contains(obj.getDbName())) {
diff --git a/aai-core/src/main/java/org/openecomp/aai/introspection/tools/IssueType.java b/aai-core/src/main/java/org/openecomp/aai/introspection/tools/IssueType.java
index 90fd4d5a..5606926c 100644
--- a/aai-core/src/main/java/org/openecomp/aai/introspection/tools/IssueType.java
+++ b/aai-core/src/main/java/org/openecomp/aai/introspection/tools/IssueType.java
@@ -21,5 +21,5 @@
package org.openecomp.aai.introspection.tools;
public enum IssueType {
- MISSING_REQUIRED_PROP, MISSING_KEY_PROP, EXCEEDED_ALLOWED_DEPTH, PROPERTY_NOT_VISIBLE
+ MISSING_REQUIRED_PROP, MISSING_KEY_PROP, EXCEEDED_ALLOWED_DEPTH, PROPERTY_NOT_VISIBLE, DEPENDENT_PROP_NOT_FOUND
}
diff --git a/aai-core/src/main/java/org/openecomp/aai/logging/EcompElapsedTime.java b/aai-core/src/main/java/org/openecomp/aai/logging/EcompElapsedTime.java
index e5f82471..f56a6fe5 100644
--- a/aai-core/src/main/java/org/openecomp/aai/logging/EcompElapsedTime.java
+++ b/aai-core/src/main/java/org/openecomp/aai/logging/EcompElapsedTime.java
@@ -20,9 +20,10 @@
package org.openecomp.aai.logging;
+import org.openecomp.aai.logging.LoggingContext.LoggingField;
+
import ch.qos.logback.classic.pattern.ClassicConverter;
import ch.qos.logback.classic.spi.ILoggingEvent;
-import org.openecomp.aai.logging.LoggingContext.LoggingField;
public class EcompElapsedTime extends ClassicConverter {
diff --git a/aai-core/src/main/java/org/openecomp/aai/logging/EcompStartTime.java b/aai-core/src/main/java/org/openecomp/aai/logging/EcompStartTime.java
index cc2f1fa3..c08b273a 100644
--- a/aai-core/src/main/java/org/openecomp/aai/logging/EcompStartTime.java
+++ b/aai-core/src/main/java/org/openecomp/aai/logging/EcompStartTime.java
@@ -20,9 +20,10 @@
package org.openecomp.aai.logging;
+import org.openecomp.aai.logging.LoggingContext.LoggingField;
+
import ch.qos.logback.classic.pattern.ClassicConverter;
import ch.qos.logback.classic.spi.ILoggingEvent;
-import org.openecomp.aai.logging.LoggingContext.LoggingField;
public class EcompStartTime extends ClassicConverter {
diff --git a/aai-core/src/main/java/org/openecomp/aai/logging/ErrorLogHelper.java b/aai-core/src/main/java/org/openecomp/aai/logging/ErrorLogHelper.java
index 0affc788..37a10748 100644
--- a/aai-core/src/main/java/org/openecomp/aai/logging/ErrorLogHelper.java
+++ b/aai-core/src/main/java/org/openecomp/aai/logging/ErrorLogHelper.java
@@ -20,24 +20,31 @@
package org.openecomp.aai.logging;
-import com.att.eelf.configuration.EELFLogger;
-import com.att.eelf.configuration.EELFManager;
-import org.apache.commons.lang.StringUtils;
-import org.openecomp.aai.exceptions.AAIException;
-import org.openecomp.aai.logging.LoggingContext.StatusCode;
-import org.openecomp.aai.util.AAIConstants;
-import org.openecomp.aai.util.MapperUtil;
-import org.slf4j.MDC;
-
-import javax.ws.rs.core.MediaType;
-import javax.xml.bind.JAXBContext;
-import javax.xml.bind.Marshaller;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.StringWriter;
-import java.util.*;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
import java.util.Map.Entry;
+import java.util.Properties;
+
+import javax.ws.rs.core.MediaType;
+import javax.xml.bind.JAXBContext;
+import javax.xml.bind.Marshaller;
+
+import org.apache.commons.lang.StringUtils;
+import org.slf4j.MDC;
+
+import org.openecomp.aai.exceptions.AAIException;
+import org.openecomp.aai.logging.LoggingContext.StatusCode;
+import org.openecomp.aai.util.AAIConstants;
+import org.openecomp.aai.util.MapperUtil;
+import com.att.eelf.configuration.EELFLogger;
+import com.att.eelf.configuration.EELFManager;
/**
*
@@ -67,7 +74,7 @@ public class ErrorLogHelper {
* @throws Exception the exception
*/
public static void loadProperties() throws IOException, ErrorObjectFormatException {
- final String filePath = AAIConstants.AAI_HOME_ETC_APP_PROPERTIES + "error.properties";
+ final String filePath = AAIConstants.AAI_HOME_ETC_APP_PROPERTIES + "error.properties";
final InputStream is = Thread.currentThread().getContextClassLoader().getResourceAsStream(filePath);
final Properties properties = new Properties();
@@ -105,8 +112,8 @@ public class ErrorLogHelper {
*
* @param key The key for the error in the error.properties file
* @throws IOException
- * @throws ErrorObjectNotFoundException
- * @throws ErrorObjectFormatException
+ * @throws ErrorObjectNotFoundException
+ * @throws ErrorObjectFormatException
*/
public static ErrorObject getErrorObject(String code) throws ErrorObjectNotFoundException {
@@ -130,8 +137,8 @@ public class ErrorLogHelper {
* @param are must have a restError value whose numeric value must match what should be returned in the REST API
* @param variables optional list of variables to flesh out text in error string
* @return appropriately formatted JSON response per the REST API spec.
- * @throws ErrorObjectFormatException
- * @throws ErrorObjectNotFoundException
+ * @throws ErrorObjectFormatException
+ * @throws ErrorObjectNotFoundException
* @throws IOException
* @deprecated
*/
@@ -152,8 +159,8 @@ public class ErrorLogHelper {
* @param are must have a restError value whose numeric value must match what should be returned in the REST API
* @param variables optional list of variables to flesh out text in error string
* @return appropriately formatted JSON response per the REST API spec.
- * @throws ErrorObjectFormatException
- * @throws ErrorObjectNotFoundException
+ * @throws ErrorObjectFormatException
+ * @throws ErrorObjectNotFoundException
* @throws IOException
*/
public static String getRESTAPIErrorResponse(List<MediaType> acceptHeadersOrig, AAIException are, ArrayList<String> variables) {
@@ -326,8 +333,8 @@ public class ErrorLogHelper {
* @param variables the variables
* @param logline the logline
* @return the RESTAPI error response with logging
- * @throws ErrorObjectFormatException
- * @throws ErrorObjectNotFoundException
+ * @throws ErrorObjectFormatException
+ * @throws ErrorObjectNotFoundException
* @throws IOException
*/
public static String getRESTAPIErrorResponseWithLogging(List<MediaType> acceptHeadersOrig, AAIException are, ArrayList<String> variables) {
@@ -344,8 +351,8 @@ public class ErrorLogHelper {
* @param acceptHeaders the accept headers
* @param areList the are list
* @return the RESTAPI info response
- * @throws ErrorObjectFormatException
- * @throws ErrorObjectNotFoundException
+ * @throws ErrorObjectFormatException
+ * @throws ErrorObjectNotFoundException
* @throws IOException
*/
public static Object getRESTAPIInfoResponse(List<MediaType> acceptHeaders, HashMap<AAIException,ArrayList<String>> areList) {
@@ -355,10 +362,10 @@ public class ErrorLogHelper {
org.openecomp.aai.domain.restResponseInfo.ObjectFactory factory = new org.openecomp.aai.domain.restResponseInfo.ObjectFactory();
org.openecomp.aai.domain.restResponseInfo.Info info = factory.createInfo();
org.openecomp.aai.domain.restResponseInfo.Info.ResponseMessages responseMessages = factory.createInfoResponseMessages();
- Iterator<Entry<AAIException, ArrayList<String>>> it = areList.entrySet().iterator();
-
+ Iterator<Map.Entry<AAIException, ArrayList<String>>> it = areList.entrySet().iterator();
+
while (it.hasNext()) {
- Entry<AAIException,ArrayList<String>> pair = (Entry<AAIException, ArrayList<String>>)it.next();
+ Map.Entry<AAIException,ArrayList<String>> pair = (Map.Entry<AAIException, ArrayList<String>>)it.next();
AAIException are = pair.getKey();
ArrayList<String> variables = pair.getValue();
@@ -436,8 +443,8 @@ public class ErrorLogHelper {
* @param are must have a restError value whose numeric value must match what should be returned in the REST API
* @param variables optional list of variables to flesh out text in error string
* @return appropriately formatted JSON response per the REST API spec.
- * @throws ErrorObjectFormatException
- * @throws ErrorObjectNotFoundException
+ * @throws ErrorObjectFormatException
+ * @throws ErrorObjectNotFoundException
* @throws IOException
*/
public static String getRESTAPIPolicyErrorResponseXML(AAIException are, ArrayList<String> variables) {
diff --git a/aai-core/src/main/java/org/openecomp/aai/logging/LoggingContext.java b/aai-core/src/main/java/org/openecomp/aai/logging/LoggingContext.java
index e1d641f9..1a46bb25 100644
--- a/aai-core/src/main/java/org/openecomp/aai/logging/LoggingContext.java
+++ b/aai-core/src/main/java/org/openecomp/aai/logging/LoggingContext.java
@@ -20,18 +20,22 @@
package org.openecomp.aai.logging;
-import com.att.eelf.configuration.EELFLogger;
-import com.att.eelf.configuration.EELFManager;
-import org.json.JSONException;
-import org.json.JSONObject;
-import org.slf4j.MDC;
-
import java.net.InetAddress;
import java.net.UnknownHostException;
+import java.util.HashMap;
import java.util.Iterator;
+import java.util.Map;
import java.util.UUID;
import java.util.concurrent.TimeUnit;
+import org.json.JSONArray;
+import org.json.JSONException;
+import org.json.JSONObject;
+import org.slf4j.MDC;
+
+import com.att.eelf.configuration.EELFLogger;
+import com.att.eelf.configuration.EELFManager;
+
public class LoggingContext {
public enum StatusCode {
@@ -41,7 +45,7 @@ public class LoggingContext {
private static final EELFLogger LOGGER = EELFManager.getInstance().getLogger(LoggingContext.class);
- private static final String PREVIOUS_CONTEXT_KEY = "_PREVIOUS_CONTEXT";
+ private static final String PREVIOUS_CONTEXTS_KEY = "_PREVIOUS_CONTEXTS";
//ECOMP Specific Log Event Fields
public static enum LoggingField {
@@ -97,6 +101,14 @@ public class LoggingContext {
MDC.put(LoggingField.START_TIME.toString(), LogFormatTools.getCurrentDateTime());
}
+ public static UUID requestId() {
+ final String sUuid = MDC.get(LoggingField.REQUEST_ID.toString());
+
+ if (sUuid == null) return null;
+
+ return UUID.fromString(sUuid);
+ }
+
public static void requestId(UUID requestId) {
MDC.put(LoggingField.REQUEST_ID.toString(), requestId.toString());
}
@@ -143,6 +155,10 @@ public class LoggingContext {
MDC.put(LoggingField.RESPONSE_DESCRIPTION.toString(), responseDescription);
}
+ public static Object instanceUuid() {
+ return UUID.fromString(MDC.get(LoggingField.INSTANCE_UUID.toString()));
+ }
+
public static void instanceUuid(UUID instanceUuid) {
MDC.put(LoggingField.INSTANCE_UUID.toString(), instanceUuid.toString());
}
@@ -193,6 +209,10 @@ public class LoggingContext {
MDC.put(LoggingField.PROCESS_KEY.toString(), processKey);
}
+ public static String customField1() {
+ return MDC.get(LoggingField.CUSTOM_FIELD_1.toString());
+ }
+
public static void customField1(String customField1) {
MDC.put(LoggingField.CUSTOM_FIELD_1.toString(), customField1);
}
@@ -223,9 +243,11 @@ public class LoggingContext {
public static double stopWatchStop() {
final long stopWatchEnd = System.nanoTime();
- final Long stopWatchStart = Long.valueOf(MDC.get(LoggingField.STOP_WATCH_START.toString()));
+ final String rawStopWatchStart = MDC.get(LoggingField.STOP_WATCH_START.toString());
- if (stopWatchStart == null) throw new StopWatchNotStartedException();
+ if (rawStopWatchStart == null) throw new StopWatchNotStartedException();
+
+ final Long stopWatchStart = Long.valueOf(rawStopWatchStart);
MDC.remove(LoggingField.STOP_WATCH_START.toString());
@@ -263,19 +285,36 @@ public class LoggingContext {
}
}
- MDC.put("_PREVIOUS_CONTEXT", context.toString());
+ final String rawJsonArray = MDC.get(PREVIOUS_CONTEXTS_KEY);
+
+ if (rawJsonArray == null) {
+ final JSONArray stack = new JSONArray()
+ .put(context);
+
+ MDC.put(PREVIOUS_CONTEXTS_KEY, stack.toString());
+ } else {
+ try {
+ final JSONArray stack = new JSONArray(rawJsonArray)
+ .put(context);
+
+ MDC.put(PREVIOUS_CONTEXTS_KEY, stack.toString());
+ } catch (JSONException e) {
+ //Ignore
+ }
+ }
}
public static void restore() {
- final String rawPreviousContext = MDC.get(PREVIOUS_CONTEXT_KEY);
+ final String rawPreviousContexts = MDC.get(PREVIOUS_CONTEXTS_KEY);
- if (rawPreviousContext == null) {
+ if (rawPreviousContexts == null) {
throw new LoggingContextNotExistsException();
}
try {
- final JSONObject previousContext = new JSONObject(rawPreviousContext);
+ final JSONArray previousContexts = new JSONArray(rawPreviousContexts);
+ final JSONObject previousContext = previousContexts.getJSONObject(previousContexts.length() - 1);
@SuppressWarnings("unchecked")
final Iterator<String> keys = previousContext.keys();
@@ -290,10 +329,42 @@ public class LoggingContext {
// or the value is invalid (they are all strings)
}
}
-
- MDC.remove(PREVIOUS_CONTEXT_KEY);
+
+ MDC.put(PREVIOUS_CONTEXTS_KEY, removeLast(previousContexts).toString());
} catch (JSONException e) {
//Ignore, the previousContext is serialized from a JSONObject
}
}
+
+ /**
+ * AJSC declares an ancient version of org.json:json in one of the parent POMs of this project.
+ * I tried to update our version of that library in our POM, but it's ignored because of the way
+ * AJSC has organized their <dependencies>. Had they put it into the <dependencyManagement> section,
+ * this method would not be necessary.
+ */
+ private static JSONArray removeLast(JSONArray previousContexts) {
+ final JSONArray result = new JSONArray();
+
+ for (int i = 0; i < previousContexts.length() - 1; i++) {
+ try {
+ result.put(previousContexts.getJSONObject(i));
+ } catch (JSONException e) {
+ //Ignore - not possible
+ }
+ }
+
+ return result;
+ }
+
+ public static Map<String, String> getCopy() {
+ final Map<String, String> copy = new HashMap<String, String> ();
+
+ for (LoggingField field : LoggingField.values()) {
+ final String value = MDC.get(field.toString());
+
+ if (value != null) copy.put(field.toString(), value);
+ }
+
+ return copy;
+ }
}
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 489774fa..f542bef2 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
@@ -95,16 +95,16 @@ public class LegacyQueryParser extends QueryParser implements Parsable {
public LegacyQueryParser(Loader loader, QueryBuilder queryBuilder) {
super(loader, queryBuilder);
}
-
+
/**
* @throws AAIException
* @{inheritDoc}
*/
@Override
- public void processObject(Introspector obj, MultivaluedMap<String, String> uriKeys) throws AAIException {
+ public void processObject(Introspector obj, EdgeType type, MultivaluedMap<String, String> uriKeys) throws AAIException {
if (previous != null) {
this.parentResourceType = previous.getDbName();
- queryBuilder.createEdgeTraversal(EdgeType.TREE, previous, obj);
+ queryBuilder.createEdgeTraversal(type, previous, obj);
}
if (previous == null) {
queryBuilder.createDBQuery(obj);
@@ -114,18 +114,18 @@ public class LegacyQueryParser extends QueryParser implements Parsable {
this.handleUriKeys(obj, uriKeys);
}
previous = obj;
- this.resultResource = obj.getDbName();
+ this.resultResource = obj.getDbName();
}
/**
* @{inheritDoc}
*/
@Override
- public void processContainer(Introspector obj, MultivaluedMap<String, String> uriKeys, boolean isFinalContainer) throws AAIException {
+ public void processContainer(Introspector obj, EdgeType type, MultivaluedMap<String, String> uriKeys, boolean isFinalContainer) throws AAIException {
if (isFinalContainer) {
if (previous != null) {
this.parentResourceType = previous.getDbName();
- queryBuilder.createEdgeTraversal(EdgeType.TREE, previous, obj);
+ queryBuilder.createEdgeTraversal(type, previous, obj);
}
if (previous == null) {
@@ -146,7 +146,6 @@ public class LegacyQueryParser extends QueryParser implements Parsable {
this.containerResource = obj.getName();
}
}
-
private void handleUriKeys(Introspector obj, MultivaluedMap<String, String> uriKeys) throws AAIException {
for (String key : uriKeys.keySet()) {
//to validate whether this property exists
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 f568f224..90d9fefc 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
@@ -22,6 +22,8 @@ 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;
@@ -34,9 +36,9 @@ public abstract class QueryParser {
protected Loader loader = null;
protected Loader latestLoader = null;
- protected QueryBuilder queryBuilder = null;
+ protected QueryBuilder<Vertex> queryBuilder = null;
- protected QueryBuilder parentQueryBuilder = null;
+ protected QueryBuilder<Vertex> parentQueryBuilder = null;
protected URI uri = null;
@@ -53,7 +55,7 @@ public abstract class QueryParser {
* @param queryBuilder the query builder
* @param uri the uri
*/
- protected QueryParser(Loader loader, QueryBuilder queryBuilder, URI uri) {
+ protected QueryParser(Loader loader, QueryBuilder<Vertex> queryBuilder, URI uri) {
this.uri = uri;
this.queryBuilder = queryBuilder;
this.loader = loader;
@@ -66,7 +68,7 @@ public abstract class QueryParser {
* @param loader the loader
* @param queryBuilder the query builder
*/
- protected QueryParser(Loader loader, QueryBuilder queryBuilder) {
+ protected QueryParser(Loader loader, QueryBuilder<Vertex> queryBuilder) {
this.queryBuilder = queryBuilder;
this.loader = loader;
this.latestLoader = LoaderFactory.createLoaderForVersion(loader.getModelType(), AAIProperties.LATEST);
@@ -105,7 +107,7 @@ public abstract class QueryParser {
*
* @return the query builder
*/
- public QueryBuilder getQueryBuilder() {
+ public QueryBuilder<Vertex> getQueryBuilder() {
return this.queryBuilder;
}
@@ -123,7 +125,7 @@ public abstract class QueryParser {
*
* @return the parent query builder
*/
- public QueryBuilder getParentQueryBuilder() {
+ public QueryBuilder<Vertex> getParentQueryBuilder() {
if (this.parentQueryBuilder != null) {
return this.parentQueryBuilder;
} else {
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 2d5dea72..203de01b 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
@@ -109,28 +109,47 @@ public class UniqueURIQueryParser extends QueryParser implements Parsable {
public UniqueURIQueryParser(Loader loader, QueryBuilder queryBuilder) {
super(loader, queryBuilder);
}
+
+ /**
+ * @{inheritDoc}
+ */
+ @Override
+ public void processNamespace(Introspector obj) {
+
+ }
+ /**
+ * @{inheritDoc}
+ */
+ @Override
+ public String getCloudRegionTransform() {
+ return "add";
+ }
/**
* @{inheritDoc}
*/
@Override
- public void processObject(Introspector obj, MultivaluedMap<String, String> uriKeys) {
+ public boolean useOriginalLoader() {
+ return false;
+ }
+
+
+ @Override
+ public void processObject(Introspector obj, EdgeType type, MultivaluedMap<String, String> uriKeys)
+ throws AAIException {
this.resultResource = obj.getDbName();
if (previous != null) {
this.parentName = previous.getDbName();
}
this.previous = obj;
-
-
+
}
- /**
- * @{inheritDoc}
- */
@Override
- public void processContainer(Introspector obj, MultivaluedMap<String, String> uriKeys, boolean isFinalContainer) {
+ public void processContainer(Introspector obj, EdgeType type, MultivaluedMap<String, String> uriKeys,
+ boolean isFinalContainer) throws AAIException {
this.containerResource = obj.getName();
if (previous != null) {
this.parentName = previous.getDbName();
@@ -140,32 +159,7 @@ public class UniqueURIQueryParser extends QueryParser implements Parsable {
this.resultResource = obj.getChildDBName();
this.finalContainer = obj;
- }
-
- }
-
- /**
- * @{inheritDoc}
- */
- @Override
- public void processNamespace(Introspector obj) {
-
- }
-
- /**
- * @{inheritDoc}
- */
- @Override
- public String getCloudRegionTransform() {
- return "add";
- }
-
- /**
- * @{inheritDoc}
- */
- @Override
- public boolean useOriginalLoader() {
- return false;
+ }
}
}
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 7c511425..57a8d8aa 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
@@ -24,6 +24,7 @@ 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;
/**
* The Interface Parsable.
@@ -31,14 +32,13 @@ import org.openecomp.aai.introspection.Introspector;
public interface Parsable {
/**
- * Process object.
- *
- * @param obj the obj
- * @param uriKeys the uri keys
- * @throws AAIException
+ *
+ * @param obj
+ * @param type
+ * @param uriKeys
+ * @throws AAIException
*/
- public void processObject(Introspector obj, MultivaluedMap<String, String> uriKeys) throws AAIException;
-
+ public void processObject(Introspector obj, EdgeType type, MultivaluedMap<String, String> uriKeys) throws AAIException;
/**
* Process container.
*
@@ -47,8 +47,8 @@ public interface Parsable {
* @param isFinalContainer the is final container
* @throws AAIException the AAI exception
*/
- public void processContainer(Introspector obj, MultivaluedMap<String, String> uriKeys, boolean isFinalContainer) throws AAIException;
-
+ public void processContainer(Introspector obj, EdgeType type, MultivaluedMap<String, String> uriKeys, boolean isFinalContainer) throws AAIException;
+
/**
* Process namespace.
*
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 e796732d..8f867172 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
@@ -36,7 +36,9 @@ import org.openecomp.aai.introspection.Loader;
import org.openecomp.aai.introspection.LoaderFactory;
import org.openecomp.aai.introspection.Version;
import org.openecomp.aai.logging.ErrorLogHelper;
+import org.openecomp.aai.rest.RestTokens;
import org.openecomp.aai.schema.enums.ObjectMetadata;
+import org.openecomp.aai.serialization.db.EdgeType;
import org.openecomp.aai.util.AAIConfig;
@@ -130,10 +132,35 @@ public class URIParser {
Set<String> keys = null;
String part = "";
Introspector previousObj = null;
-
+ EdgeType type = EdgeType.TREE;
for (int i = 0; i < parts.length;) {
part = parts[i];
Introspector introspector = null;
+ if (part.equals(RestTokens.COUSIN.toString())) {
+ if (i == parts.length-1) {
+ throw new AAIException("AAI_3000", uri + " not a valid path. Cannot end in " + RestTokens.COUSIN);
+ }
+ introspector = loader.introspectorFromName(parts[i+1]);
+ if (previousObj.isContainer() && introspector.isContainer()) {
+ throw new AAIException("AAI_3000", uri + " not a valid path. Cannot chain plurals together");
+ }
+ MultivaluedMap<String, String> uriKeys = new MultivaluedHashMap<>();
+ if (i == parts.length-2 && queryParams != null) {
+ Set<String> queryKeys = queryParams.keySet();
+ for (String key : queryKeys) {
+ uriKeys.put(key, queryParams.get(key));
+
+ }
+ }
+ if (introspector.isContainer()) {
+ boolean isFinalContainer = i == parts.length-2;
+ p.processContainer(introspector, EdgeType.COUSIN, uriKeys, isFinalContainer);
+ }
+ previousObj = introspector;
+ type = EdgeType.COUSIN;
+ i+=2;
+ continue;
+ }
introspector = loader.introspectorFromName(part);
if (introspector != null) {
@@ -172,8 +199,8 @@ public class URIParser {
}
}
- p.processObject(introspector, uriKeys);
-
+ p.processObject(introspector, type, uriKeys);
+ type = EdgeType.TREE;
} else if (introspector.isContainer()) {
boolean isFinalContainer = i == parts.length-1;
MultivaluedMap<String, String> uriKeys = new MultivaluedHashMap<>();
@@ -185,7 +212,7 @@ public class URIParser {
}
}
- p.processContainer(introspector, uriKeys, isFinalContainer);
+ p.processContainer(introspector, type, uriKeys, isFinalContainer);
i++;
} else {
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 4bb4ab95..ae6ff600 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
@@ -30,6 +30,7 @@ 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.serialization.db.EdgeType;
import com.google.common.base.Joiner;
/**
@@ -75,27 +76,6 @@ public class URIToDBKey implements Parsable {
* @{inheritDoc}
*/
@Override
- public void processObject (Introspector obj, MultivaluedMap<String, String> uriKeys) {
-
- dbKeys.add(obj.getDbName());
-
- for (String key : uriKeys.keySet()) {
- dbKeys.add(uriKeys.getFirst(key).toString());
- }
- }
-
- /**
- * @{inheritDoc}
- */
- @Override
- public void processContainer (Introspector obj, MultivaluedMap<String, String> uriKeys, boolean isFinalContainer) {
-
- }
-
- /**
- * @{inheritDoc}
- */
- @Override
public void processNamespace(Introspector obj) {
}
@@ -124,4 +104,20 @@ public class URIToDBKey implements Parsable {
public boolean useOriginalLoader() {
return false;
}
+
+ @Override
+ public void processObject(Introspector obj, EdgeType type, MultivaluedMap<String, String> uriKeys)
+ throws AAIException {
+
+ dbKeys.add(obj.getDbName());
+
+ for (String key : uriKeys.keySet()) {
+ dbKeys.add(uriKeys.getFirst(key).toString());
+ }
+ }
+
+ @Override
+ public void processContainer(Introspector obj, EdgeType type, MultivaluedMap<String, String> uriKeys,
+ boolean isFinalContainer) throws AAIException {
+ }
}
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 defd1285..9906437b 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
@@ -31,6 +31,7 @@ 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;
@@ -68,27 +69,6 @@ public class URIToExtensionInformation implements Parsable {
* @{inheritDoc}
*/
@Override
- public void processObject(Introspector obj, MultivaluedMap<String, String> uriKeys) {
- String upperCamel = toUpperCamel(obj.getDbName());
- if (topObject.equals("")) {
- topObject = upperCamel;
- }
- pieces.add(upperCamel);
-
- }
-
- /**
- * @{inheritDoc}
- */
- @Override
- public void processContainer(Introspector obj, MultivaluedMap<String, String> uriKeys, boolean isFinalContainer) {
- pieces.add(toUpperCamel(obj.getName()));
- }
-
- /**
- * @{inheritDoc}
- */
- @Override
public void processNamespace(Introspector obj) {
this.namespace = CaseFormat.LOWER_HYPHEN.to(CaseFormat.LOWER_CAMEL, obj.getDbName());
pieces.add(toUpperCamel(obj.getDbName()));
@@ -166,4 +146,20 @@ public class URIToExtensionInformation implements Parsable {
result = CaseFormat.LOWER_HYPHEN.to(CaseFormat.UPPER_CAMEL, name);
return result;
}
+
+ @Override
+ public void processObject(Introspector obj, EdgeType type, MultivaluedMap<String, String> uriKeys)
+ throws AAIException {
+ String upperCamel = toUpperCamel(obj.getDbName());
+ if (topObject.equals("")) {
+ topObject = upperCamel;
+ }
+ pieces.add(upperCamel);
+ }
+
+ @Override
+ public void processContainer(Introspector obj, EdgeType type, MultivaluedMap<String, String> uriKeys,
+ boolean isFinalContainer) throws AAIException {
+ pieces.add(toUpperCamel(obj.getName()));
+ }
}
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 5b8d25c3..cf011bf6 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
@@ -32,6 +32,7 @@ import org.openecomp.aai.introspection.Introspector;
import org.openecomp.aai.introspection.Loader;
import org.openecomp.aai.introspection.Version;
import org.openecomp.aai.schema.enums.ObjectMetadata;
+import org.openecomp.aai.serialization.db.EdgeType;
/**
* Given a URI this class returns an object, or series of nested objects
@@ -94,61 +95,6 @@ public class URIToObject implements Parsable {
* @{inheritDoc}
*/
@Override
- public void processObject(Introspector obj, MultivaluedMap<String, String> uriKeys) {
-
- if (this.entityName == null) {
- this.topEntityName = obj.getDbName();
- this.topEntity = obj;
- }
- this.entityName = obj.getDbName();
- this.entity = obj;
- this.parentList = (List<Object>)this.previous.getValue(obj.getName());
- this.parentList.add(entity.getUnderlyingObject());
-
- for (String key : uriKeys.keySet()) {
- entity.setValue(key, uriKeys.getFirst(key));
- }
- try {
- if (relatedObjects.containsKey(entity.getObjectId())) {
- Introspector relatedObject = relatedObjects.get(entity.getObjectId());
- String nameProp = relatedObject.getMetadata(ObjectMetadata.NAME_PROPS);
- if (nameProp == null) {
- nameProp = "";
- }
- if (nameProp != null && !nameProp.equals("")) {
- String[] nameProps = nameProp.split(",");
- for (String prop : nameProps) {
- entity.setValue(prop, relatedObject.getValue(prop));
- }
- }
- }
- } catch (UnsupportedEncodingException e) {
- }
- this.previous = entity;
-
- }
-
- /**
- * @{inheritDoc}
- */
- @Override
- public void processContainer(Introspector obj, MultivaluedMap<String, String> uriKeys, boolean isFinalContainer) {
-
- this.previous = obj;
-
- if (this.entity != null) {
- this.entity.setValue(obj.getName(), obj.getUnderlyingObject());
- } else {
- this.entity = obj;
- this.topEntity = obj;
- }
-
- }
-
- /**
- * @{inheritDoc}
- */
- @Override
public void processNamespace(Introspector obj) {
}
@@ -226,4 +172,50 @@ public class URIToObject implements Parsable {
public Loader getLoader() {
return this.loader;
}
+ @Override
+ public void processObject(Introspector obj, EdgeType type, MultivaluedMap<String, String> uriKeys)
+ throws AAIException {
+
+ if (this.entityName == null) {
+ this.topEntityName = obj.getDbName();
+ this.topEntity = obj;
+ }
+ this.entityName = obj.getDbName();
+ this.entity = obj;
+ this.parentList = (List<Object>)this.previous.getValue(obj.getName());
+ this.parentList.add(entity.getUnderlyingObject());
+
+ for (String key : uriKeys.keySet()) {
+ entity.setValue(key, uriKeys.getFirst(key));
+ }
+ try {
+ if (relatedObjects.containsKey(entity.getObjectId())) {
+ Introspector relatedObject = relatedObjects.get(entity.getObjectId());
+ String nameProp = relatedObject.getMetadata(ObjectMetadata.NAME_PROPS);
+ if (nameProp == null) {
+ nameProp = "";
+ }
+ if (nameProp != null && !nameProp.equals("")) {
+ String[] nameProps = nameProp.split(",");
+ for (String prop : nameProps) {
+ entity.setValue(prop, relatedObject.getValue(prop));
+ }
+ }
+ }
+ } catch (UnsupportedEncodingException e) {
+ }
+ this.previous = entity;
+ }
+ @Override
+ public void processContainer(Introspector obj, EdgeType type, MultivaluedMap<String, String> uriKeys,
+ boolean isFinalContainer) throws AAIException {
+ this.previous = obj;
+
+ if (this.entity != null) {
+ this.entity.setValue(obj.getName(), obj.getUnderlyingObject());
+ } else {
+ this.entity = obj;
+ this.topEntity = obj;
+ }
+ }
}
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 83a3a621..853b7877 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
@@ -33,6 +33,7 @@ import org.openecomp.aai.introspection.Introspector;
import org.openecomp.aai.introspection.Loader;
import org.openecomp.aai.introspection.Version;
import org.openecomp.aai.introspection.exceptions.AAIUnknownObjectException;
+import org.openecomp.aai.serialization.db.EdgeType;
import org.openecomp.aai.util.AAIApiServerURLBase;
import org.openecomp.aai.workarounds.LegacyURITransformer;
@@ -102,35 +103,6 @@ public class URIToRelationshipObject implements Parsable {
public String getCloudRegionTransform(){
return "remove";
}
-
- /**
- * @{inheritDoc}
- */
- @Override
- public void processObject(Introspector obj, MultivaluedMap<String, String> uriKeys) {
-
-
- for (String key : obj.getKeys()) {
- try {
- 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!");
- }
- }
- relationship.setValue("related-to", obj.getDbName());
- }
-
- /**
- * @{inheritDoc}
- */
- @Override
- public void processContainer(Introspector obj, MultivaluedMap<String, String> uriKeys, boolean isFinalContainer) {
-
- }
/**
* @{inheritDoc}
@@ -163,9 +135,36 @@ public class URIToRelationshipObject implements Parsable {
URI relatedLink = new URI(this.baseURL + this.originalVersion + "/" + originalUri);
this.relationship.setValue("related-link", relatedLink);
-
-
+ if (this.originalVersion.compareTo(Version.v10) >= 0) {
+ //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;
}
+
+ @Override
+ public void processObject(Introspector obj, EdgeType type, MultivaluedMap<String, String> uriKeys)
+ throws AAIException {
+ for (String key : obj.getKeys()) {
+ try {
+ 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!");
+ }
+ }
+ relationship.setValue("related-to", obj.getDbName());
+ }
+
+ @Override
+ public void processContainer(Introspector obj, EdgeType type, MultivaluedMap<String, String> uriKeys,
+ boolean isFinalContainer) throws AAIException {
+ }
}
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 4f7a7c15..6eed095e 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
@@ -24,24 +24,11 @@ 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;
class URIValidate implements Parsable {
@Override
- public void processObject(Introspector obj, MultivaluedMap<String, String> uriKeys) throws AAIException {
- //NO-OP
- //just want to make sure this URI has valid tokens
- }
-
- @Override
- public void processContainer(Introspector obj, MultivaluedMap<String, String> uriKeys, boolean isFinalContainer)
- throws AAIException {
- //NO-OP
- //just want to make sure this URI has valid tokens
-
- }
-
- @Override
public void processNamespace(Introspector obj) {
//NO-OP
//just want to make sure this URI has valid tokens
@@ -59,4 +46,18 @@ class URIValidate implements Parsable {
return true;
}
+ @Override
+ public void processObject(Introspector obj, EdgeType type, MultivaluedMap<String, String> uriKeys)
+ throws AAIException {
+ //NO-OP
+ //just want to make sure this URI has valid tokens
+ }
+
+ @Override
+ public void processContainer(Introspector obj, EdgeType type, MultivaluedMap<String, String> uriKeys,
+ boolean isFinalContainer) throws AAIException {
+ //NO-OP
+ //just want to make sure this URI has valid tokens
+ }
+
}
diff --git a/aai-core/src/main/java/org/openecomp/aai/query/builder/GraphTraversalBuilder.java b/aai-core/src/main/java/org/openecomp/aai/query/builder/GraphTraversalBuilder.java
index b212f75f..11164d96 100644
--- a/aai-core/src/main/java/org/openecomp/aai/query/builder/GraphTraversalBuilder.java
+++ b/aai-core/src/main/java/org/openecomp/aai/query/builder/GraphTraversalBuilder.java
@@ -30,11 +30,13 @@ import java.util.Set;
import org.apache.tinkerpop.gremlin.process.traversal.P;
import org.apache.tinkerpop.gremlin.process.traversal.Traversal;
import org.apache.tinkerpop.gremlin.process.traversal.Traversal.Admin;
+import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.DefaultGraphTraversal;
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.process.traversal.util.TraversalHelper;
import org.apache.tinkerpop.gremlin.structure.Direction;
+import org.apache.tinkerpop.gremlin.structure.Edge;
import org.apache.tinkerpop.gremlin.structure.Vertex;
import org.openecomp.aai.db.props.AAIProperties;
@@ -51,10 +53,10 @@ import org.openecomp.aai.serialization.db.exceptions.NoEdgeRuleFoundException;
/**
* The Class GraphTraversalBuilder.
*/
-public abstract class GraphTraversalBuilder extends QueryBuilder {
+public abstract class GraphTraversalBuilder<E> extends QueryBuilder<E> {
- protected GraphTraversal<Vertex, Vertex> traversal = null;
- protected Admin<Vertex, Vertex> completeTraversal = null;
+ protected GraphTraversal<Vertex, E> traversal = null;
+ protected Admin<Vertex, E> completeTraversal = null;
private EdgeRules edgeRules = EdgeRules.getInstance();
protected int parentStepIndex = 0;
@@ -69,7 +71,7 @@ public abstract class GraphTraversalBuilder extends QueryBuilder {
public GraphTraversalBuilder(Loader loader, GraphTraversalSource source) {
super(loader, source);
- traversal = __.start();
+ traversal = new DefaultGraphTraversal<>();
}
@@ -82,7 +84,7 @@ public abstract class GraphTraversalBuilder extends QueryBuilder {
public GraphTraversalBuilder(Loader loader, GraphTraversalSource source, Vertex start) {
super(loader, source, start);
- traversal = __.start();
+ traversal = new DefaultGraphTraversal<>();
}
@@ -90,7 +92,7 @@ public abstract class GraphTraversalBuilder extends QueryBuilder {
* @{inheritDoc}
*/
@Override
- public QueryBuilder getVerticesByIndexedProperty(String key, Object value) {
+ public QueryBuilder<Vertex> getVerticesByIndexedProperty(String key, Object value) {
return this.getVerticesByProperty(key, value);
}
@@ -99,7 +101,7 @@ public abstract class GraphTraversalBuilder extends QueryBuilder {
* @{inheritDoc}
*/
@Override
- public QueryBuilder getVerticesByIndexedProperty(String key, List<?> values) {
+ public QueryBuilder<Vertex> getVerticesByIndexedProperty(String key, List<?> values) {
return this.getVerticesByProperty(key, values);
}
@@ -107,7 +109,7 @@ public abstract class GraphTraversalBuilder extends QueryBuilder {
* @{inheritDoc}
*/
@Override
- public QueryBuilder getVerticesByProperty(String key, Object value) {
+ public QueryBuilder<Vertex> getVerticesByProperty(String key, Object value) {
//this is because the index is registered as an Integer
value = this.correctObjectType(value);
@@ -115,14 +117,14 @@ public abstract class GraphTraversalBuilder extends QueryBuilder {
traversal.has(key, value);
stepIndex++;
- return this;
+ return (QueryBuilder<Vertex>) this;
}
/**
* @{inheritDoc}
*/
@Override
- public QueryBuilder getVerticesByProperty(final String key, final List<?> values) {
+ public QueryBuilder<Vertex> getVerticesByProperty(final String key, final List<?> values) {
//this is because the index is registered as an Integer
List<Object> correctedValues = new ArrayList<>();
@@ -133,24 +135,24 @@ public abstract class GraphTraversalBuilder extends QueryBuilder {
traversal.has(key, P.within(correctedValues));
stepIndex++;
- return this;
+ return (QueryBuilder<Vertex>) this;
}
/**
* @{inheritDoc}
*/
@Override
- public QueryBuilder getChildVerticesFromParent(String parentKey, String parentValue, String childType) {
+ public QueryBuilder<Vertex> getChildVerticesFromParent(String parentKey, String parentValue, String childType) {
traversal.has(parentKey, parentValue).has(AAIProperties.NODE_TYPE, childType);
stepIndex++;
- return this;
+ return (QueryBuilder<Vertex>) this;
}
/**
* @{inheritDoc}
*/
@Override
- public QueryBuilder getTypedVerticesByMap(String type, LinkedHashMap<String, String> map) {
+ public QueryBuilder<Vertex> getTypedVerticesByMap(String type, LinkedHashMap<String, String> map) {
for (String key : map.keySet()) {
traversal.has(key, map.get(key));
@@ -158,24 +160,24 @@ public abstract class GraphTraversalBuilder extends QueryBuilder {
}
traversal.has(AAIProperties.NODE_TYPE, type);
stepIndex++;
- return this;
+ return (QueryBuilder<Vertex>) this;
}
/**
* @{inheritDoc}
*/
@Override
- public QueryBuilder createDBQuery(Introspector obj) {
+ public QueryBuilder<Vertex> createDBQuery(Introspector obj) {
this.createKeyQuery(obj);
this.createContainerQuery(obj);
- return this;
+ return (QueryBuilder<Vertex>) this;
}
/**
* @{inheritDoc}
*/
@Override
- public QueryBuilder createKeyQuery(Introspector obj) {
+ public QueryBuilder<Vertex> createKeyQuery(Introspector obj) {
Set<String> keys = obj.getKeys();
Object val;
for (String key : keys) {
@@ -195,15 +197,15 @@ public abstract class GraphTraversalBuilder extends QueryBuilder {
stepIndex++;
}
}
- return this;
+ return (QueryBuilder<Vertex>) this;
}
@Override
- public QueryBuilder exactMatchQuery(Introspector obj) {
+ public QueryBuilder<Vertex> exactMatchQuery(Introspector obj) {
this.createKeyQuery(obj);
allPropertiesQuery(obj);
this.createContainerQuery(obj);
- return this;
+ return (QueryBuilder<Vertex>) this;
}
private void allPropertiesQuery(Introspector obj) {
@@ -236,7 +238,7 @@ public abstract class GraphTraversalBuilder extends QueryBuilder {
*/
@Override
- public QueryBuilder createContainerQuery(Introspector obj) {
+ public QueryBuilder<Vertex> createContainerQuery(Introspector obj) {
String type = obj.getChildDBName();
String abstractType = obj.getMetadata(ObjectMetadata.ABSTRACT);
if (abstractType != null) {
@@ -247,7 +249,7 @@ public abstract class GraphTraversalBuilder extends QueryBuilder {
}
stepIndex++;
markContainer();
- return this;
+ return (QueryBuilder<Vertex>) this;
}
/**
@@ -256,16 +258,16 @@ public abstract class GraphTraversalBuilder extends QueryBuilder {
* @{inheritDoc}
*/
@Override
- public QueryBuilder createEdgeTraversal(EdgeType type, Introspector parent, Introspector child) throws AAIException, NoEdgeRuleFoundException {
+ public QueryBuilder<Vertex> createEdgeTraversal(EdgeType type, Introspector parent, Introspector child) throws AAIException, NoEdgeRuleFoundException {
String isAbstractType = parent.getMetadata(ObjectMetadata.ABSTRACT);
if ("true".equals(isAbstractType)) {
markParentBoundary();
traversal.union(handleAbstractEdge(type, parent, child));
stepIndex += 1;
} else {
- this.edgeQuery(type, parent, child);
+ this.edgeQueryToVertex(type, parent, child);
}
- return this;
+ return (QueryBuilder<Vertex>) this;
}
@@ -302,20 +304,29 @@ public abstract class GraphTraversalBuilder extends QueryBuilder {
* @{inheritDoc}
*/
@Override
- public QueryBuilder createEdgeTraversal(EdgeType type, Vertex parent, Introspector child) throws AAIException, NoEdgeRuleFoundException {
+ public QueryBuilder<Vertex> createEdgeTraversal(EdgeType type, Vertex parent, Introspector child) throws AAIException, NoEdgeRuleFoundException {
String nodeType = parent.<String>property(AAIProperties.NODE_TYPE).orElse(null);
Introspector parentObj = loader.introspectorFromName(nodeType);
- this.edgeQuery(type, parentObj, child);
- return this;
+ this.edgeQueryToVertex(type, parentObj, child);
+ return (QueryBuilder<Vertex>) this;
}
+ @Override
+ public QueryBuilder<Edge> getEdgesBetween(EdgeType type, String outNodeType, String inNodeType) throws AAIException {
+ Introspector outObj = loader.introspectorFromName(outNodeType);
+ Introspector inObj = loader.introspectorFromName(inNodeType);
+ this.edgeQuery(type, outObj, inObj);
+
+ return (QueryBuilder<Edge>)this;
+
+ }
/**
* @{inheritDoc}
*/
@Override
- public QueryBuilder union(QueryBuilder... builder) {
+ public QueryBuilder<E> union(QueryBuilder... builder) {
GraphTraversal<Vertex, Vertex>[] traversals = new GraphTraversal[builder.length];
for (int i = 0; i < builder.length; i++) {
traversals[i] = (GraphTraversal<Vertex, Vertex>)builder[i].getQuery();
@@ -330,7 +341,7 @@ public abstract class GraphTraversalBuilder extends QueryBuilder {
* @{inheritDoc}
*/
@Override
- public QueryBuilder where(QueryBuilder... builder) {
+ public QueryBuilder<E> where(QueryBuilder... builder) {
GraphTraversal<Vertex, Vertex>[] traversals = new GraphTraversal[builder.length];
for (int i = 0; i < builder.length; i++) {
this.traversal.where((GraphTraversal<Vertex, Vertex>)builder[i].getQuery());
@@ -348,7 +359,7 @@ public abstract class GraphTraversalBuilder extends QueryBuilder {
* @throws NoEdgeRuleFoundException
* @throws AAIException
*/
- private void edgeQuery(EdgeType type, Introspector outObj, Introspector inObj) throws AAIException, NoEdgeRuleFoundException {
+ private void edgeQueryToVertex(EdgeType type, Introspector outObj, Introspector inObj) throws AAIException, NoEdgeRuleFoundException {
String outType = outObj.getDbName();
String inType = inObj.getDbName();
@@ -367,10 +378,40 @@ public abstract class GraphTraversalBuilder extends QueryBuilder {
}
stepIndex++;
this.createContainerQuery(inObj);
+
+ }
+
+ /**
+ * Edge query.
+ *
+ * @param outType the out type
+ * @param inType the in type
+ * @throws NoEdgeRuleFoundException
+ * @throws AAIException
+ */
+ private void edgeQuery(EdgeType type, Introspector outObj, Introspector inObj) throws AAIException, NoEdgeRuleFoundException {
+ String outType = outObj.getDbName();
+ String inType = inObj.getDbName();
+
+ if (outObj.isContainer()) {
+ outType = outObj.getChildDBName();
+ }
+ if (inObj.isContainer()) {
+ inType = inObj.getChildDBName();
+ }
+ markParentBoundary();
+ EdgeRule rule = edgeRules.getEdgeRule(type, outType, inType);
+ if (rule.getDirection().equals(Direction.OUT)) {
+ traversal.outE(rule.getLabel());
+ } else {
+ traversal.inE(rule.getLabel());
+ }
+ stepIndex++;
+
}
@Override
- public QueryBuilder limit(long amount) {
+ public QueryBuilder<E> limit(long amount) {
traversal.limit(amount);
return this;
}
@@ -379,21 +420,21 @@ public abstract class GraphTraversalBuilder extends QueryBuilder {
* @{inheritDoc}
*/
@Override
- public <T> T getQuery() {
- return (T)this.traversal;
+ public <E2> E2 getQuery() {
+ return (E2)this.traversal;
}
/**
* @{inheritDoc}
*/
@Override
- public QueryBuilder getParentQuery() {
+ public QueryBuilder<E> getParentQuery() {
return cloneQueryAtStep(parentStepIndex);
}
@Override
- public QueryBuilder getContainerQuery() {
+ public QueryBuilder<E> getContainerQuery() {
if (this.parentStepIndex == 0) {
return removeQueryStepsBetween(0, containerStepIndex);
@@ -436,7 +477,7 @@ public abstract class GraphTraversalBuilder extends QueryBuilder {
return stepIndex;
}
- protected abstract QueryBuilder cloneQueryAtStep(int index);
+ protected abstract QueryBuilder<E> cloneQueryAtStep(int index);
/**
* end is exclusive
*
@@ -444,7 +485,7 @@ public abstract class GraphTraversalBuilder extends QueryBuilder {
* @param end
* @return
*/
- protected abstract QueryBuilder removeQueryStepsBetween(int start, int end);
+ protected abstract QueryBuilder<E> removeQueryStepsBetween(int start, int end);
private void executeQuery() {
@@ -458,7 +499,7 @@ public abstract class GraphTraversalBuilder extends QueryBuilder {
TraversalHelper.insertTraversal(admin.getEndStep(), traversal.asAdmin(), admin);
- this.completeTraversal = admin;
+ this.completeTraversal = (Admin<Vertex, E>) admin;
}
@Override
@@ -471,7 +512,7 @@ public abstract class GraphTraversalBuilder extends QueryBuilder {
}
@Override
- public Vertex next() {
+ public E next() {
if (this.completeTraversal == null) {
executeQuery();
}
@@ -480,7 +521,7 @@ public abstract class GraphTraversalBuilder extends QueryBuilder {
}
@Override
- public List<Vertex> toList() {
+ public List<E> toList() {
if (this.completeTraversal == null) {
executeQuery();
}
diff --git a/aai-core/src/main/java/org/openecomp/aai/query/builder/GremlinPipelineBuilder.java b/aai-core/src/main/java/org/openecomp/aai/query/builder/GremlinPipelineBuilder.java
index 1b32e736..729acbb4 100644
--- a/aai-core/src/main/java/org/openecomp/aai/query/builder/GremlinPipelineBuilder.java
+++ b/aai-core/src/main/java/org/openecomp/aai/query/builder/GremlinPipelineBuilder.java
@@ -26,7 +26,7 @@ import java.util.List;
import org.apache.tinkerpop.gremlin.structure.Vertex;
-import org.openecomp.aai.db.props.AAIProperties;
+import org.openecomp.aai.db.AAIProperties;
import org.openecomp.aai.exceptions.AAIException;
import org.openecomp.aai.introspection.Introspector;
import org.openecomp.aai.introspection.Loader;
diff --git a/aai-core/src/main/java/org/openecomp/aai/query/builder/GremlinQueryBuilder.java b/aai-core/src/main/java/org/openecomp/aai/query/builder/GremlinQueryBuilder.java
index 3fa4dedb..e4e1fd5a 100644
--- a/aai-core/src/main/java/org/openecomp/aai/query/builder/GremlinQueryBuilder.java
+++ b/aai-core/src/main/java/org/openecomp/aai/query/builder/GremlinQueryBuilder.java
@@ -30,6 +30,7 @@ import java.util.Set;
import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversal;
import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource;
import org.apache.tinkerpop.gremlin.structure.Direction;
+import org.apache.tinkerpop.gremlin.structure.Edge;
import org.apache.tinkerpop.gremlin.structure.Vertex;
import org.openecomp.aai.db.props.AAIProperties;
@@ -47,7 +48,7 @@ import com.google.common.base.Joiner;
/**
* The Class GremlinQueryBuilder.
*/
-public abstract class GremlinQueryBuilder extends QueryBuilder {
+public abstract class GremlinQueryBuilder<E> extends QueryBuilder<E> {
private EdgeRules edgeRules = EdgeRules.getInstance();
private GremlinGroovyShellSingleton gremlinGroovy = GremlinGroovyShellSingleton.getInstance();
@@ -83,26 +84,26 @@ public abstract class GremlinQueryBuilder extends QueryBuilder {
* @{inheritDoc}
*/
@Override
- public QueryBuilder createDBQuery(Introspector obj) {
+ public QueryBuilder<Vertex> createDBQuery(Introspector obj) {
this.createKeyQuery(obj);
this.createContainerQuery(obj);
- return this;
+ return (QueryBuilder<Vertex>) this;
}
@Override
- public QueryBuilder exactMatchQuery(Introspector obj) {
+ public QueryBuilder<Vertex> exactMatchQuery(Introspector obj) {
// TODO not implemented because this is implementation is no longer used
this.createKeyQuery(obj);
//allPropertiesQuery(obj);
this.createContainerQuery(obj);
- return this;
+ return (QueryBuilder<Vertex>) this;
}
/**
* @{inheritDoc}
*/
@Override
- public QueryBuilder getVerticesByIndexedProperty(String key, Object value) {
+ public QueryBuilder<Vertex> getVerticesByIndexedProperty(String key, Object value) {
return this.getVerticesByProperty(key, value);
}
@@ -110,7 +111,7 @@ public abstract class GremlinQueryBuilder extends QueryBuilder {
* @{inheritDoc}
*/
@Override
- public QueryBuilder getVerticesByIndexedProperty(String key, List<?> values) {
+ public QueryBuilder<Vertex> getVerticesByIndexedProperty(String key, List<?> values) {
return this.getVerticesByProperty(key, values);
}
@@ -118,7 +119,7 @@ public abstract class GremlinQueryBuilder extends QueryBuilder {
* @{inheritDoc}
*/
@Override
- public QueryBuilder getVerticesByProperty(String key, Object value) {
+ public QueryBuilder<Vertex> getVerticesByProperty(String key, Object value) {
String term = "";
if (value != null && !value.getClass().getName().equals("java.lang.String")) {
@@ -128,14 +129,14 @@ public abstract class GremlinQueryBuilder extends QueryBuilder {
}
list.add(".has('" + key + "', " + term + ")");
stepIndex++;
- return this;
+ return (QueryBuilder<Vertex>) this;
}
/**
* @{inheritDoc}
*/
@Override
- public QueryBuilder getVerticesByProperty(String key, List<?> values) {
+ public QueryBuilder<Vertex> getVerticesByProperty(String key, List<?> values) {
String term = "";
String predicate = "P.within(#!#argument#!#)";
@@ -151,7 +152,7 @@ public abstract class GremlinQueryBuilder extends QueryBuilder {
predicate = predicate.replace("#!#argument#!#", argument);
list.add(".has('" + key + "', " + predicate + ")");
stepIndex++;
- return this;
+ return (QueryBuilder<Vertex>) this;
}
@@ -159,21 +160,21 @@ public abstract class GremlinQueryBuilder extends QueryBuilder {
* @{inheritDoc}
*/
@Override
- public QueryBuilder getChildVerticesFromParent(String parentKey, String parentValue, String childType) {
+ public QueryBuilder<Vertex> getChildVerticesFromParent(String parentKey, String parentValue, String childType) {
/*
String query = ".has('aai-node-type', '" + childType + "')";
return this.processGremlinQuery(parentKey, parentValue, query);
*/
//TODO
- return this;
+ return (QueryBuilder<Vertex>) this;
}
/**
* @{inheritDoc}
*/
@Override
- public QueryBuilder getTypedVerticesByMap(String type, LinkedHashMap<String, String> map) {
+ public QueryBuilder<Vertex> getTypedVerticesByMap(String type, LinkedHashMap<String, String> map) {
for (String key : map.keySet()) {
list.add(".has('" + key + "', '" + map.get(key) + "')");
@@ -181,14 +182,14 @@ public abstract class GremlinQueryBuilder extends QueryBuilder {
}
list.add(".has('aai-node-type', '" + type + "')");
stepIndex++;
- return this;
+ return (QueryBuilder<Vertex>) this;
}
/**
* @{inheritDoc}
*/
@Override
- public QueryBuilder createKeyQuery(Introspector obj) {
+ public QueryBuilder<Vertex> createKeyQuery(Introspector obj) {
Set<String> keys = obj.getKeys();
for (String key : keys) {
@@ -196,7 +197,7 @@ public abstract class GremlinQueryBuilder extends QueryBuilder {
this.getVerticesByProperty(key, obj.<Object>getValue(key));
}
- return this;
+ return (QueryBuilder<Vertex>) this;
}
/**
@@ -214,7 +215,7 @@ public abstract class GremlinQueryBuilder extends QueryBuilder {
if (child.isContainer()) {
childName = child.getChildDBName();
}
- this.edgeQuery(type, parentName, childName);
+ this.edgeQueryToVertex(type, parentName, childName);
return this;
}
@@ -225,14 +226,21 @@ public abstract class GremlinQueryBuilder extends QueryBuilder {
* @{inheritDoc}
*/
@Override
- public QueryBuilder createEdgeTraversal(EdgeType type, Vertex parent, Introspector child) throws AAIException, NoEdgeRuleFoundException {
+ public QueryBuilder<Vertex> createEdgeTraversal(EdgeType type, Vertex parent, Introspector child) throws AAIException, NoEdgeRuleFoundException {
String nodeType = parent.<String>property(AAIProperties.NODE_TYPE).orElse(null);
- this.edgeQuery(type, nodeType, child.getDbName());
+ this.edgeQueryToVertex(type, nodeType, child.getDbName());
- return this;
+ return (QueryBuilder<Vertex>) this;
}
+ @Override
+ public QueryBuilder<Edge> getEdgesBetween(EdgeType type, String outNodeType, String inNodeType) throws AAIException {
+ this.edgeQuery(type, outNodeType, inNodeType);
+
+ return (QueryBuilder<Edge>)this;
+
+ }
/**
* Edge query.
*
@@ -241,7 +249,7 @@ public abstract class GremlinQueryBuilder extends QueryBuilder {
* @throws NoEdgeRuleFoundException
* @throws AAIException
*/
- private void edgeQuery(EdgeType type, String outType, String inType) throws AAIException, NoEdgeRuleFoundException {
+ private void edgeQueryToVertex(EdgeType type, String outType, String inType) throws AAIException, NoEdgeRuleFoundException {
markParentBoundary();
EdgeRule rule = edgeRules.getEdgeRule(type, outType, inType);
if (rule.getDirection().equals(Direction.OUT)) {
@@ -249,11 +257,33 @@ public abstract class GremlinQueryBuilder extends QueryBuilder {
} else {
list.add(".in('" + rule.getLabel() + "')");
}
+ stepIndex++;
list.add(".has('" + AAIProperties.NODE_TYPE + "', '" + inType + "')");
- stepIndex += 2;
+ stepIndex++;
+
+ }
+
+ /**
+ * Edge query.
+ *
+ * @param outType the out type
+ * @param inType the in type
+ * @throws NoEdgeRuleFoundException
+ * @throws AAIException
+ */
+ private void edgeQuery(EdgeType type, String outType, String inType) throws AAIException, NoEdgeRuleFoundException {
+ markParentBoundary();
+ EdgeRule rule = edgeRules.getEdgeRule(type, outType, inType);
+ if (rule.getDirection().equals(Direction.OUT)) {
+ list.add(".outE('" + rule.getLabel() + "')");
+ } else {
+ list.add(".inV('" + rule.getLabel() + "')");
+ }
+ stepIndex++;
+
}
@Override
- public QueryBuilder limit(long amount) {
+ public QueryBuilder<E> limit(long amount) {
list.add(".limit(" + amount + ")");
return this;
}
@@ -261,7 +291,7 @@ public abstract class GremlinQueryBuilder extends QueryBuilder {
* @{inheritDoc}
*/
@Override
- public QueryBuilder createContainerQuery(Introspector obj) {
+ public QueryBuilder<Vertex> createContainerQuery(Introspector obj) {
String type = obj.getChildDBName();
String abstractType = obj.getMetadata(ObjectMetadata.ABSTRACT);
if (abstractType != null) {
@@ -281,11 +311,11 @@ public abstract class GremlinQueryBuilder extends QueryBuilder {
}
stepIndex++;
this.markContainer();
- return this;
+ return (QueryBuilder<Vertex>) this;
}
@Override
- public QueryBuilder union(QueryBuilder... builder) {
+ public QueryBuilder<E> union(QueryBuilder<E>... builder) {
markParentBoundary();
String[] traversals = new String[builder.length];
StringBuilder command = new StringBuilder();
@@ -302,7 +332,7 @@ public abstract class GremlinQueryBuilder extends QueryBuilder {
}
@Override
- public QueryBuilder where(QueryBuilder... builder) {
+ public QueryBuilder<E> where(QueryBuilder<E>... builder) {
markParentBoundary();
List<String> traversals = new ArrayList<>();
for (int i = 0; i < builder.length; i++) {
@@ -319,12 +349,12 @@ public abstract class GremlinQueryBuilder extends QueryBuilder {
* @{inheritDoc}
*/
@Override
- public QueryBuilder getParentQuery() {
+ public QueryBuilder<E> getParentQuery() {
return cloneQueryAtStep(parentStepIndex);
}
@Override
- public QueryBuilder getContainerQuery() {
+ public QueryBuilder<E> getContainerQuery() {
return cloneQueryAtStep(containerStepIndex);
}
@@ -332,14 +362,14 @@ public abstract class GremlinQueryBuilder extends QueryBuilder {
* @{inheritDoc}
*/
@Override
- public <T> T getQuery() {
+ public <T2> T2 getQuery() {
StringBuilder sb = new StringBuilder();
for (String piece : this.list) {
sb.append(piece);
}
- return (T)sb.toString();
+ return (T2)sb.toString();
}
/**
@@ -355,7 +385,7 @@ public abstract class GremlinQueryBuilder extends QueryBuilder {
this.containerStepIndex = stepIndex;
}
- protected abstract QueryBuilder cloneQueryAtStep(int index);
+ protected abstract QueryBuilder<E> cloneQueryAtStep(int index);
/**
* @{inheritDoc}
*/
@@ -396,21 +426,21 @@ public abstract class GremlinQueryBuilder extends QueryBuilder {
}
@Override
- public Vertex next() {
+ public E next() {
if (this.completeTraversal == null) {
executeQuery();
}
- return (Vertex)this.completeTraversal.next();
+ return (E)this.completeTraversal.next();
}
@Override
- public List<Vertex> toList() {
+ public List<E> toList() {
if (this.completeTraversal == null) {
executeQuery();
}
- return (List<Vertex>)this.completeTraversal.toList();
+ return (List<E>)this.completeTraversal.toList();
}
}
diff --git a/aai-core/src/main/java/org/openecomp/aai/query/builder/GremlinTraversal.java b/aai-core/src/main/java/org/openecomp/aai/query/builder/GremlinTraversal.java
index 43ef850d..3daad5ef 100644
--- a/aai-core/src/main/java/org/openecomp/aai/query/builder/GremlinTraversal.java
+++ b/aai-core/src/main/java/org/openecomp/aai/query/builder/GremlinTraversal.java
@@ -39,7 +39,7 @@ import org.openecomp.aai.parsers.query.TraversalStrategy;
/**
* The Class GremlinTraversal.
*/
-public class GremlinTraversal extends GremlinQueryBuilder {
+public class GremlinTraversal<E> extends GremlinQueryBuilder<E> {
/**
* Instantiates a new gremlin traversal.
@@ -62,7 +62,7 @@ public class GremlinTraversal extends GremlinQueryBuilder {
this.factory = new TraversalStrategy(this.loader, this);
}
- protected GremlinTraversal(List<String> traversal, Loader loader, GraphTraversalSource source, GremlinQueryBuilder gtb) {
+ protected GremlinTraversal(List<String> traversal, Loader loader, GraphTraversalSource source, GremlinQueryBuilder<E> gtb) {
super(loader, source);
this.list = traversal;
this.stepIndex = gtb.getStepIndex();
@@ -110,20 +110,20 @@ public class GremlinTraversal extends GremlinQueryBuilder {
* @{inheritDoc}
*/
@Override
- public QueryBuilder newInstance(Vertex start) {
- return new GremlinTraversal(loader, source, start);
+ public QueryBuilder<E> newInstance(Vertex start) {
+ return new GremlinTraversal<>(loader, source, start);
}
/**
* @{inheritDoc}
*/
@Override
- public QueryBuilder newInstance() {
- return new GremlinTraversal(loader, source);
+ public QueryBuilder<E> newInstance() {
+ return new GremlinTraversal<>(loader, source);
}
@Override
- protected QueryBuilder cloneQueryAtStep(int index) {
+ protected QueryBuilder<E> cloneQueryAtStep(int index) {
if (index == 0) {
index = stepIndex;
}
@@ -132,6 +132,6 @@ public class GremlinTraversal extends GremlinQueryBuilder {
newList.add(this.list.get(i));
}
- return new GremlinTraversal(newList, loader, source, this);
+ return new GremlinTraversal<>(newList, loader, source, this);
}
}
diff --git a/aai-core/src/main/java/org/openecomp/aai/query/builder/GremlinUnique.java b/aai-core/src/main/java/org/openecomp/aai/query/builder/GremlinUnique.java
index 50c1e402..ee2353f1 100644
--- a/aai-core/src/main/java/org/openecomp/aai/query/builder/GremlinUnique.java
+++ b/aai-core/src/main/java/org/openecomp/aai/query/builder/GremlinUnique.java
@@ -40,7 +40,7 @@ import org.openecomp.aai.parsers.query.UniqueStrategy;
/**
* The Class GremlinUnique.
*/
-public class GremlinUnique extends GremlinQueryBuilder {
+public class GremlinUnique<E> extends GremlinQueryBuilder<E> {
/**
* Instantiates a new gremlin unique.
@@ -63,7 +63,7 @@ public class GremlinUnique extends GremlinQueryBuilder {
this.factory = new UniqueStrategy(this.loader, this);
}
- protected GremlinUnique(List<String> traversal, Loader loader, GraphTraversalSource source, GremlinQueryBuilder gtb) {
+ protected GremlinUnique(List<String> traversal, Loader loader, GraphTraversalSource source, GremlinQueryBuilder<E> gtb) {
super(loader, source);
this.list = traversal;
this.stepIndex = gtb.getStepIndex();
@@ -110,20 +110,20 @@ public class GremlinUnique extends GremlinQueryBuilder {
* @{inheritDoc}
*/
@Override
- public QueryBuilder newInstance() {
- return new GremlinUnique(loader, source);
+ public QueryBuilder<E> newInstance() {
+ return new GremlinUnique<>(loader, source);
}
/**
* @{inheritDoc}
*/
@Override
- public QueryBuilder newInstance(Vertex start) {
- return new GremlinUnique(loader, source, start);
+ public QueryBuilder<E> newInstance(Vertex start) {
+ return new GremlinUnique<>(loader, source, start);
}
@Override
- protected QueryBuilder cloneQueryAtStep(int index) {
+ protected QueryBuilder<E> cloneQueryAtStep(int index) {
if (index == 0) {
index = stepIndex;
}
@@ -132,6 +132,6 @@ public class GremlinUnique extends GremlinQueryBuilder {
newList.add(this.list.get(i));
}
- return new GremlinUnique(newList, loader, source, this);
+ return new GremlinUnique<>(newList, loader, source, this);
}
}
diff --git a/aai-core/src/main/java/org/openecomp/aai/query/builder/QueryBuilder.java b/aai-core/src/main/java/org/openecomp/aai/query/builder/QueryBuilder.java
index a9fa7cab..565e8682 100644
--- a/aai-core/src/main/java/org/openecomp/aai/query/builder/QueryBuilder.java
+++ b/aai-core/src/main/java/org/openecomp/aai/query/builder/QueryBuilder.java
@@ -29,6 +29,7 @@ import java.util.List;
import javax.ws.rs.core.MultivaluedMap;
import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource;
+import org.apache.tinkerpop.gremlin.structure.Edge;
import org.apache.tinkerpop.gremlin.structure.Vertex;
import org.openecomp.aai.exceptions.AAIException;
@@ -42,7 +43,7 @@ import org.openecomp.aai.serialization.db.exceptions.NoEdgeRuleFoundException;
/**
* The Class QueryBuilder.
*/
-public abstract class QueryBuilder implements Iterator<Vertex> {
+public abstract class QueryBuilder<E> implements Iterator<E> {
protected QueryParserStrategy factory = null;
@@ -82,7 +83,7 @@ public abstract class QueryBuilder implements Iterator<Vertex> {
* @param value the value
* @return the vertices by indexed property
*/
- public abstract QueryBuilder getVerticesByIndexedProperty(String key, Object value);
+ public abstract QueryBuilder<Vertex> getVerticesByIndexedProperty(String key, Object value);
/**
* Gets the vertices by property.
@@ -91,7 +92,7 @@ public abstract class QueryBuilder implements Iterator<Vertex> {
* @param value the value
* @return the vertices by property
*/
- public abstract QueryBuilder getVerticesByProperty(String key, Object value);
+ public abstract QueryBuilder<Vertex> getVerticesByProperty(String key, Object value);
/**
* filters by all the values for this property
@@ -99,7 +100,7 @@ public abstract class QueryBuilder implements Iterator<Vertex> {
* @param values
* @return vertices that match these values
*/
- public abstract QueryBuilder getVerticesByIndexedProperty(String key, List<?> values);
+ public abstract QueryBuilder<Vertex> getVerticesByIndexedProperty(String key, List<?> values);
/**
* filters by all the values for this property
@@ -107,7 +108,7 @@ public abstract class QueryBuilder implements Iterator<Vertex> {
* @param values
* @return vertices that match these values
*/
- public abstract QueryBuilder getVerticesByProperty(String key, List<?> values);
+ public abstract QueryBuilder<Vertex> getVerticesByProperty(String key, List<?> values);
/**
* Gets the child vertices from parent.
@@ -117,7 +118,7 @@ public abstract class QueryBuilder implements Iterator<Vertex> {
* @param childType the child type
* @return the child vertices from parent
*/
- public abstract QueryBuilder getChildVerticesFromParent(String parentKey, String parentValue, String childType);
+ public abstract QueryBuilder<Vertex> getChildVerticesFromParent(String parentKey, String parentValue, String childType);
/**
* Gets the typed vertices by map.
@@ -126,7 +127,7 @@ public abstract class QueryBuilder implements Iterator<Vertex> {
* @param map the map
* @return the typed vertices by map
*/
- public abstract QueryBuilder getTypedVerticesByMap(String type, LinkedHashMap<String, String> map);
+ public abstract QueryBuilder<Vertex> getTypedVerticesByMap(String type, LinkedHashMap<String, String> map);
/**
* Creates the DB query.
@@ -134,7 +135,7 @@ public abstract class QueryBuilder implements Iterator<Vertex> {
* @param obj the obj
* @return the query builder
*/
- public abstract QueryBuilder createDBQuery(Introspector obj);
+ public abstract QueryBuilder<Vertex> createDBQuery(Introspector obj);
/**
* Creates the key query.
@@ -142,7 +143,7 @@ public abstract class QueryBuilder implements Iterator<Vertex> {
* @param obj the obj
* @return the query builder
*/
- public abstract QueryBuilder createKeyQuery(Introspector obj);
+ public abstract QueryBuilder<Vertex> createKeyQuery(Introspector obj);
/**
* Creates the container query.
@@ -150,7 +151,7 @@ public abstract class QueryBuilder implements Iterator<Vertex> {
* @param obj the obj
* @return the query builder
*/
- public abstract QueryBuilder createContainerQuery(Introspector obj);
+ public abstract QueryBuilder<Vertex> createContainerQuery(Introspector obj);
/**
* Creates the edge traversal.
@@ -159,7 +160,7 @@ public abstract class QueryBuilder implements Iterator<Vertex> {
* @param child the child
* @return the query builder
*/
- public abstract QueryBuilder createEdgeTraversal(EdgeType type, Introspector parent, Introspector child) throws AAIException;
+ public abstract QueryBuilder<Vertex> createEdgeTraversal(EdgeType type, Introspector parent, Introspector child) throws AAIException;
/**
* Creates the edge traversal.
@@ -168,15 +169,16 @@ public abstract class QueryBuilder implements Iterator<Vertex> {
* @param child the child
* @return the query builder
*/
- public abstract QueryBuilder createEdgeTraversal(EdgeType type, Vertex parent, Introspector child) throws AAIException;
+ public abstract QueryBuilder<Vertex> createEdgeTraversal(EdgeType type, Vertex parent, Introspector child) throws AAIException;
- public QueryBuilder createEdgeTraversal(EdgeType type, String outNodeType, String inNodeType) throws NoEdgeRuleFoundException, AAIException {
+ public QueryBuilder<Vertex> createEdgeTraversal(EdgeType type, String outNodeType, String inNodeType) throws NoEdgeRuleFoundException, AAIException {
Introspector out = loader.introspectorFromName(outNodeType);
Introspector in = loader.introspectorFromName(inNodeType);
return createEdgeTraversal(type, out, in);
}
-
+
+ public abstract QueryBuilder<Edge> getEdgesBetween(EdgeType type, String outNodeType, String inNodeType) throws AAIException;
/**
* Creates the query from URI.
*
@@ -221,35 +223,35 @@ public abstract class QueryBuilder implements Iterator<Vertex> {
*
* @return the parent query
*/
- public abstract QueryBuilder getParentQuery();
+ public abstract QueryBuilder<E> getParentQuery();
/**
* Gets the query.
*
* @return the query
*/
- public abstract <T> T getQuery();
+ public abstract <E2> E2 getQuery();
/**
* Form boundary.
*/
public abstract void markParentBoundary();
- public abstract QueryBuilder limit(long amount);
+ public abstract QueryBuilder<E> limit(long amount);
/**
* New instance.
*
* @param start the start
* @return the query builder
*/
- public abstract QueryBuilder newInstance(Vertex start);
+ public abstract QueryBuilder<E> newInstance(Vertex start);
/**
* New instance.
*
* @return the query builder
*/
- public abstract QueryBuilder newInstance();
+ public abstract QueryBuilder<E> newInstance();
/**
* Gets the start.
@@ -272,7 +274,7 @@ public abstract class QueryBuilder implements Iterator<Vertex> {
* @param obj
* @return
*/
- public abstract QueryBuilder exactMatchQuery(Introspector obj);
+ public abstract QueryBuilder<Vertex> exactMatchQuery(Introspector obj);
/**
* lets you join any number of QueryBuilders
@@ -280,14 +282,14 @@ public abstract class QueryBuilder implements Iterator<Vertex> {
* @param builder
* @return
*/
- public abstract QueryBuilder union(QueryBuilder[] builder);
+ public abstract QueryBuilder<E> union(QueryBuilder<E>... builder);
- public abstract QueryBuilder where(QueryBuilder[] builder);
+ public abstract QueryBuilder<E> where(QueryBuilder<E>... builder);
public abstract void markContainer();
- public abstract QueryBuilder getContainerQuery();
+ public abstract QueryBuilder<E> getContainerQuery();
- public abstract List<Vertex> toList();
+ public abstract List<E> toList();
}
diff --git a/aai-core/src/main/java/org/openecomp/aai/query/builder/TraversalQuery.java b/aai-core/src/main/java/org/openecomp/aai/query/builder/TraversalQuery.java
index 42934023..628e055e 100644
--- a/aai-core/src/main/java/org/openecomp/aai/query/builder/TraversalQuery.java
+++ b/aai-core/src/main/java/org/openecomp/aai/query/builder/TraversalQuery.java
@@ -40,7 +40,7 @@ import org.openecomp.aai.parsers.query.TraversalStrategy;
/**
* The Class TraversalQuery.
*/
-public class TraversalQuery extends GraphTraversalBuilder {
+public class TraversalQuery<E> extends GraphTraversalBuilder<E> {
/**
* Instantiates a new traversal query.
@@ -63,7 +63,7 @@ public class TraversalQuery extends GraphTraversalBuilder {
this.factory = new TraversalStrategy(this.loader, this);
}
- protected TraversalQuery(GraphTraversal<Vertex, Vertex> traversal, Loader loader, GraphTraversalSource source, GraphTraversalBuilder gtb) {
+ protected TraversalQuery(GraphTraversal<Vertex, E> traversal, Loader loader, GraphTraversalSource source, GraphTraversalBuilder<E> gtb) {
super(loader, source);
this.traversal = traversal;
this.stepIndex = gtb.getStepIndex();
@@ -110,41 +110,41 @@ public class TraversalQuery extends GraphTraversalBuilder {
* @{inheritDoc}
*/
@Override
- public QueryBuilder newInstance(Vertex start) {
- return new TraversalQuery(loader, source, start);
+ public QueryBuilder<E> newInstance(Vertex start) {
+ return new TraversalQuery<>(loader, source, start);
}
/**
* @{inheritDoc}
*/
@Override
- public QueryBuilder newInstance() {
- return new TraversalQuery(loader, source);
+ public QueryBuilder<E> newInstance() {
+ return new TraversalQuery<>(loader, source);
}
@Override
- protected QueryBuilder cloneQueryAtStep(int index) {
+ protected QueryBuilder<E> cloneQueryAtStep(int index) {
if (index == 0) {
index = stepIndex;
}
- GraphTraversal<Vertex, Vertex> clone = this.traversal.asAdmin().clone();
- GraphTraversal.Admin<Vertex, Vertex> cloneAdmin = clone.asAdmin();
+ GraphTraversal<Vertex, E> clone = this.traversal.asAdmin().clone();
+ GraphTraversal.Admin<Vertex, E> cloneAdmin = clone.asAdmin();
List<Step> steps = cloneAdmin.getSteps();
for (int i = steps.size()-1; i >= index; i--) {
cloneAdmin.removeStep(i);
}
- return new TraversalQuery(cloneAdmin, loader, source, this);
+ return new TraversalQuery<>(cloneAdmin, loader, source, this);
}
@Override
- protected QueryBuilder removeQueryStepsBetween(int start, int end) {
- GraphTraversal<Vertex, Vertex> clone = this.traversal.asAdmin().clone();
- GraphTraversal.Admin<Vertex, Vertex> cloneAdmin = clone.asAdmin();
+ protected QueryBuilder<E> removeQueryStepsBetween(int start, int end) {
+ GraphTraversal<Vertex, E> clone = this.traversal.asAdmin().clone();
+ GraphTraversal.Admin<Vertex, E> cloneAdmin = clone.asAdmin();
for (int i = end-2; i >= start; i--) {
cloneAdmin.removeStep(i);
}
- return new TraversalQuery(cloneAdmin, loader, source, this);
+ return new TraversalQuery<>(cloneAdmin, loader, source, this);
}
}
diff --git a/aai-core/src/main/java/org/openecomp/aai/rest/RestTokens.java b/aai-core/src/main/java/org/openecomp/aai/rest/RestTokens.java
new file mode 100644
index 00000000..13bfe650
--- /dev/null
+++ b/aai-core/src/main/java/org/openecomp/aai/rest/RestTokens.java
@@ -0,0 +1,36 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * org.openecomp.aai
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.aai.rest;
+
+public enum RestTokens {
+
+ COUSIN("related-to");
+ private final String name;
+
+ private RestTokens(String name) {
+ this.name = name;
+ }
+
+ @Override
+ public String toString() {
+ return name;
+ }
+}
diff --git a/aai-core/src/main/java/org/openecomp/aai/restcore/RESTAPI.java b/aai-core/src/main/java/org/openecomp/aai/restcore/RESTAPI.java
index 4f462273..e5ab80e6 100644
--- a/aai-core/src/main/java/org/openecomp/aai/restcore/RESTAPI.java
+++ b/aai-core/src/main/java/org/openecomp/aai/restcore/RESTAPI.java
@@ -20,31 +20,46 @@
package org.openecomp.aai.restcore;
-import com.att.eelf.configuration.EELFLogger;
-import com.att.eelf.configuration.EELFManager;
-import com.google.common.base.Joiner;
+import java.io.StringReader;
+import java.io.UnsupportedEncodingException;
+import java.net.URI;
+import java.text.DateFormat;
+import java.text.SimpleDateFormat;
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.List;
+
+import javax.ws.rs.core.HttpHeaders;
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.Response;
+import javax.ws.rs.core.UriInfo;
+import javax.xml.bind.JAXBException;
+import javax.xml.transform.stream.StreamSource;
+
+import org.eclipse.persistence.dynamic.DynamicEntity;
+import org.eclipse.persistence.jaxb.JAXBUnmarshaller;
+import org.eclipse.persistence.jaxb.dynamic.DynamicJAXBContext;
+
import org.openecomp.aai.db.props.AAIProperties;
import org.openecomp.aai.dbmap.DBConnectionType;
+import org.openecomp.aai.domain.model.AAIResource;
import org.openecomp.aai.exceptions.AAIException;
import org.openecomp.aai.introspection.Introspector;
import org.openecomp.aai.introspection.Loader;
-import org.openecomp.aai.introspection.tools.*;
+import org.openecomp.aai.introspection.tools.CreateUUID;
+import org.openecomp.aai.introspection.tools.DefaultFields;
+import org.openecomp.aai.introspection.tools.InjectKeysFromURI;
+import org.openecomp.aai.introspection.tools.IntrospectorValidator;
+import org.openecomp.aai.introspection.tools.Issue;
+import org.openecomp.aai.introspection.tools.RemoveNonVisibleProperty;
import org.openecomp.aai.logging.ErrorLogHelper;
+import org.openecomp.aai.logging.LoggingContext;
import org.openecomp.aai.util.AAIConfig;
import org.openecomp.aai.util.AAIConstants;
import org.openecomp.aai.util.AAITxnLog;
-
-import javax.ws.rs.core.HttpHeaders;
-import javax.ws.rs.core.MediaType;
-import javax.ws.rs.core.Response;
-import javax.ws.rs.core.UriInfo;
-import java.io.UnsupportedEncodingException;
-import java.net.URI;
-import java.text.DateFormat;
-import java.text.SimpleDateFormat;
-import java.util.ArrayList;
-import java.util.Date;
-import java.util.List;
+import com.att.eelf.configuration.EELFLogger;
+import com.att.eelf.configuration.EELFManager;
+import com.google.common.base.Joiner;
/**
@@ -79,7 +94,7 @@ public class RESTAPI {
* @return the from app id
* @throws AAIException the AAI exception
*/
- protected String getFromAppId(HttpHeaders headers) throws AAIException {
+ protected String getFromAppId(HttpHeaders headers) throws AAIException {
String fromAppId = null;
if (headers != null) {
List<String> fromAppIdHeader = headers.getRequestHeader("X-FromAppId");
@@ -93,7 +108,9 @@ public class RESTAPI {
if (fromAppId == null) {
throw new AAIException("AAI_4009");
}
-
+
+ LoggingContext.partnerName(fromAppId);
+
return fromAppId;
}
@@ -105,7 +122,7 @@ public class RESTAPI {
* @return the trans id
* @throws AAIException the AAI exception
*/
- protected String getTransId(HttpHeaders headers) throws AAIException {
+ protected String getTransId(HttpHeaders headers) throws AAIException {
String transId = null;
if (headers != null) {
List<String> transIdHeader = headers.getRequestHeader("X-TransactionId");
@@ -119,7 +136,9 @@ public class RESTAPI {
if (transId == null) {
throw new AAIException("AAI_4010");
}
-
+
+ LoggingContext.requestId(transId);
+
return transId;
}
@@ -233,7 +252,7 @@ public class RESTAPI {
* @throws AAIException the AAI exception
*/
protected int setDepth(String depthParam) throws AAIException {
- int depth = AAIProperties.MAXIMUM_DEPTH; //default
+ int depth = AAIProperties.MAXIMUM_DEPTH; //default
if (depthParam != null && depthParam.length() > 0 && !depthParam.equals("all")){
try {
depth = Integer.valueOf(depthParam);
diff --git a/aai-core/src/main/java/org/openecomp/aai/restcore/search/GremlinGroovyShellSingleton.java b/aai-core/src/main/java/org/openecomp/aai/restcore/search/GremlinGroovyShellSingleton.java
index e722e092..b098dcc4 100644
--- a/aai-core/src/main/java/org/openecomp/aai/restcore/search/GremlinGroovyShellSingleton.java
+++ b/aai-core/src/main/java/org/openecomp/aai/restcore/search/GremlinGroovyShellSingleton.java
@@ -58,7 +58,9 @@ public class GremlinGroovyShellSingleton {
imports.addImports(
"org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.__",
"org.apache.tinkerpop.gremlin.structure.T",
- "org.apache.tinkerpop.gremlin.process.traversal.P");
+ "org.apache.tinkerpop.gremlin.process.traversal.P",
+ "java.util.Map.Entry");
+ imports.addStarImports("java.util");
CompilerConfiguration config = new CompilerConfiguration();
config.addCompilationCustomizers(custom, imports);
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 d5ae54d7..5f59a931 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,19 +21,46 @@
package org.openecomp.aai.serialization.db;
-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 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.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 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.*;
+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.javatuples.Pair;
+
import org.openecomp.aai.db.props.AAIProperties;
import org.openecomp.aai.exceptions.AAIException;
-import org.openecomp.aai.introspection.*;
+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.exceptions.AAIUnknownObjectException;
import org.openecomp.aai.introspection.sideeffect.DataCopy;
import org.openecomp.aai.introspection.sideeffect.DataLinkReader;
@@ -53,19 +80,10 @@ import org.openecomp.aai.util.AAIApiServerURLBase;
import org.openecomp.aai.util.AAIConfig;
import org.openecomp.aai.util.AAIConstants;
import org.openecomp.aai.workarounds.NamingExceptions;
-
-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;
+import com.att.eelf.configuration.EELFLogger;
+import com.att.eelf.configuration.EELFManager;
+import com.google.common.base.CaseFormat;
+import com.thinkaurelius.titan.core.SchemaViolationException;
public class DBSerializer {
@@ -88,7 +106,7 @@ public class DBSerializer {
* @param introspectionType the introspection type
* @param sourceOfTruth the source of truth
* @param llBuilder the ll builder
- * @throws AAIException
+ * @throws AAIException
*/
public DBSerializer(Version version, TransactionalGraphEngine engine, ModelType introspectionType, String sourceOfTruth) throws AAIException {
this.engine = engine;
@@ -179,7 +197,7 @@ public class DBSerializer {
* @throws NoSuchMethodException the no such method exception
* @throws AAIException the AAI exception
* @throws UnsupportedEncodingException the unsupported encoding exception
- * @throws AAIUnknownObjectException
+ * @throws AAIUnknownObjectException
*/
public void serializeToDb(Introspector obj, Vertex v, QueryParser uriQuery, String identifier, String requestContext) throws AAIException, UnsupportedEncodingException {
@@ -240,7 +258,7 @@ public class DBSerializer {
* @throws SecurityException the security exception
* @throws AAIException the AAI exception
* @throws UnsupportedEncodingException the unsupported encoding exception
- * @throws AAIUnknownObjectException
+ * @throws AAIUnknownObjectException
*/
/*
* Helper method for reflectToDb
@@ -435,7 +453,7 @@ public class DBSerializer {
*
* @param v the v
* @param obj the obj
- * @throws AAIUnknownObjectException
+ * @throws AAIUnknownObjectException
*/
private void writeThroughDefaults(Vertex v, Introspector obj) throws AAIUnknownObjectException {
Introspector latest = this.latestLoader.introspectorFromName(obj.getName());
@@ -472,7 +490,7 @@ public class DBSerializer {
* @throws SecurityException the security exception
* @throws AAIException the AAI exception
* @throws UnsupportedEncodingException the unsupported encoding exception
- * @throws AAIUnknownObjectException
+ * @throws AAIUnknownObjectException
*/
private Vertex reflectDependentVertex(Vertex v, Introspector dependentObj, String requestContext) throws AAIException, UnsupportedEncodingException {
@@ -512,13 +530,15 @@ public class DBSerializer {
* @throws SecurityException the security exception
* @throws AAIException the AAI exception
* @throws UnsupportedEncodingException the unsupported encoding exception
- * @throws AAIUnknownObjectException
+ * @throws AAIUnknownObjectException
*/
private Vertex reflectDependentVertex(Vertex parent, Vertex child, Introspector obj, String requestContext) throws AAIException, UnsupportedEncodingException {
String parentUri = parent.<String>property(AAIProperties.AAI_URI).orElse(null);
if (parentUri != null) {
- child.property(AAIProperties.AAI_URI, parentUri + obj.getURI());
+ String uri;
+ uri = obj.getURI();
+ child.property(AAIProperties.AAI_URI, parentUri + uri);
}
processObject(obj, child, requestContext);
@@ -555,7 +575,7 @@ public class DBSerializer {
* @throws NoSuchMethodException the no such method exception
* @throws UnsupportedEncodingException the unsupported encoding exception
* @throws MalformedURLException the malformed URL exception
- * @throws AAIUnknownObjectException
+ * @throws AAIUnknownObjectException
* @throws URISyntaxException
*/
public Introspector dbToObject(List<Vertex> vertices, final Introspector obj, int depth, boolean nodeOnly, String cleanUp) throws UnsupportedEncodingException, AAIException {
@@ -639,7 +659,7 @@ public class DBSerializer {
* @throws UnsupportedEncodingException the unsupported encoding exception
* @throws AAIException the AAI exception
* @throws MalformedURLException the malformed URL exception
- * @throws AAIUnknownObjectException
+ * @throws AAIUnknownObjectException
* @throws URISyntaxException
*/
private Introspector dbToObject(Introspector obj, Vertex v, Set<Vertex> seen, int depth, boolean nodeOnly, String cleanUp) throws AAIException, UnsupportedEncodingException {
@@ -696,7 +716,7 @@ public class DBSerializer {
//vertices = this.queryEngine.findRelatedVertices(v, Direction.OUT, rule.getLabel(), childDbName);
Direction ruleDirection = rule.getDirection();
Iterator<Vertex> itr = v.vertices(ruleDirection, rule.getLabel());
- List<Vertex> verticesList = (List<Vertex>) IteratorUtils.toList(itr);
+ List<Vertex> verticesList = (List<Vertex>)IteratorUtils.toList(itr);
itr = verticesList.stream().filter(item -> {
return item.property(AAIProperties.NODE_TYPE).orElse("").equals(childDbName);
}).iterator();
@@ -754,7 +774,7 @@ public class DBSerializer {
}
- public Introspector getVertexProperties(Vertex v) throws AAIException, IllegalAccessException, IllegalArgumentException, InvocationTargetException, SecurityException, InstantiationException, NoSuchMethodException, UnsupportedEncodingException, AAIUnknownObjectException, URISyntaxException {
+ public Introspector getVertexProperties(Vertex v) throws AAIException, UnsupportedEncodingException {
String nodeType = v.<String>property(AAIProperties.NODE_TYPE).orElse(null);
if (nodeType == null) {
throw new AAIException("AAI_6143");
@@ -769,7 +789,7 @@ public class DBSerializer {
return obj;
}
- public Introspector getLatestVersionView(Vertex v) throws AAIException, IllegalAccessException, IllegalArgumentException, InvocationTargetException, SecurityException, InstantiationException, NoSuchMethodException, UnsupportedEncodingException, AAIUnknownObjectException, URISyntaxException {
+ public Introspector getLatestVersionView(Vertex v) throws AAIException, UnsupportedEncodingException {
String nodeType = v.<String>property(AAIProperties.NODE_TYPE).orElse(null);
if (nodeType == null) {
throw new AAIException("AAI_6143");
@@ -892,7 +912,7 @@ public class DBSerializer {
* @throws UnsupportedEncodingException the unsupported encoding exception
* @throws AAIException the AAI exception
* @throws MalformedURLException the malformed URL exception
- * @throws AAIUnknownObjectException
+ * @throws AAIUnknownObjectException
* @throws URISyntaxException
*/
private Object processEdgeRelationship(Introspector relationshipObj, Vertex cousin, String cleanUp) throws UnsupportedEncodingException, AAIUnknownObjectException {
@@ -940,7 +960,7 @@ public class DBSerializer {
* @throws NoSuchMethodException the no such method exception
* @throws SecurityException the security exception
* @throws UnsupportedEncodingException the unsupported encoding exception
- * @throws AAIUnknownObjectException
+ * @throws AAIUnknownObjectException
*/
public URI getURIForVertex(Vertex v) throws UnsupportedEncodingException {
@@ -992,7 +1012,7 @@ public class DBSerializer {
* @throws InvocationTargetException the invocation target exception
* @throws NoSuchMethodException the no such method exception
* @throws SecurityException the security exception
- * @throws AAIUnknownObjectException
+ * @throws AAIUnknownObjectException
*/
private Pair<Vertex, List<Introspector>> getParents(Loader loader, Vertex start, boolean removeDamaged) {
@@ -1069,7 +1089,7 @@ public class DBSerializer {
/**
* Adds the r
- * @throws AAIUnknownObjectException
+ * @throws AAIUnknownObjectException
* @throws IllegalArgumentException elated to property.
*
* @param relationship the relationship
@@ -1154,7 +1174,7 @@ public class DBSerializer {
* @param bVertex the in vertex
* @return the edges between
* @throws AAIException the AAI exception
- * @throws NoEdgeRuleFoundException
+ * @throws NoEdgeRuleFoundException
*/
private List<Edge> getEdgesBetween(EdgeType type, Vertex aVertex, Vertex bVertex) throws AAIException, NoEdgeRuleFoundException {
@@ -1183,9 +1203,9 @@ public class DBSerializer {
* @param bVertex the in vertex
* @return the edge between
* @throws AAIException the AAI exception
- * @throws NoEdgeRuleFoundException
+ * @throws NoEdgeRuleFoundException
*/
- private Edge getEdgeBetween(EdgeType type, Vertex aVertex, Vertex bVertex) throws AAIException {
+ public Edge getEdgeBetween(EdgeType type, Vertex aVertex, Vertex bVertex) throws AAIException {
@@ -1314,8 +1334,8 @@ public class DBSerializer {
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));
+ 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)) {
@@ -1380,7 +1400,7 @@ public class DBSerializer {
if (!result) {
- throw new AAIException(aaiExceptionCode, errorDetail);
+ throw new AAIException(aaiExceptionCode, errorDetail);
}
return result;
}
@@ -1426,7 +1446,7 @@ public class DBSerializer {
aaiExceptionCode = "AAI_6131";
}
- throw new AAIException(aaiExceptionCode, errorDetail);
+ throw new AAIException(aaiExceptionCode, errorDetail);
}
}
@@ -1478,7 +1498,7 @@ public class DBSerializer {
runner.execute(obj, self);
}
- private void enrichData(Introspector obj, Vertex self) throws AAIException {
+ private void enrichData(Introspector obj, Vertex self) throws AAIException {
SideEffectRunner runner = new SideEffectRunner
.Builder(this.engine, this).addSideEffect(DataLinkReader.class).build();
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 2a34262b..9e4e8396 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
@@ -25,6 +25,7 @@ import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
+import java.util.Optional;
import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource;
import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.__;
@@ -35,6 +36,7 @@ import org.apache.tinkerpop.gremlin.structure.Vertex;
import org.openecomp.aai.db.props.AAIProperties;
import org.openecomp.aai.dbmodel.DbEdgeRules;
import org.openecomp.aai.exceptions.AAIException;
+import org.openecomp.aai.serialization.db.exceptions.EdgeMultiplicityException;
import org.openecomp.aai.serialization.db.exceptions.NoEdgeRuleFoundException;
import com.google.common.collect.ArrayListMultimap;
import com.google.common.collect.Multimap;
@@ -82,7 +84,7 @@ public class EdgeRules {
* @throws NoEdgeRuleFoundException
*/
public Edge addTreeEdge(GraphTraversalSource traversalSource, Vertex aVertex, Vertex bVertex) throws AAIException {
- return this.addEdge(EdgeType.TREE, traversalSource, aVertex, bVertex);
+ return this.addEdge(EdgeType.TREE, traversalSource, aVertex, bVertex, false);
}
/**
@@ -95,7 +97,33 @@ public class EdgeRules {
* @throws NoEdgeRuleFoundException
*/
public Edge addEdge(GraphTraversalSource traversalSource, Vertex aVertex, Vertex bVertex) throws AAIException {
- return this.addEdge(EdgeType.COUSIN, traversalSource, aVertex, bVertex);
+ return this.addEdge(EdgeType.COUSIN, traversalSource, aVertex, bVertex, false);
+ }
+
+ /**
+ * Adds the tree edge.
+ *
+ * @param aVertex the out vertex
+ * @param bVertex the in vertex
+ * @return the edge
+ * @throws AAIException the AAI exception
+ * @throws NoEdgeRuleFoundException
+ */
+ public Edge addTreeEdgeIfPossible(GraphTraversalSource traversalSource, Vertex aVertex, Vertex bVertex) throws AAIException {
+ return this.addEdge(EdgeType.TREE, traversalSource, aVertex, bVertex, true);
+ }
+
+ /**
+ * Adds the edge.
+ *
+ * @param aVertex the out vertex
+ * @param bVertex the in vertex
+ * @return the edge
+ * @throws AAIException the AAI exception
+ * @throws NoEdgeRuleFoundException
+ */
+ public Edge addEdgeIfPossible(GraphTraversalSource traversalSource, Vertex aVertex, Vertex bVertex) throws AAIException {
+ return this.addEdge(EdgeType.COUSIN, traversalSource, aVertex, bVertex, true);
}
/**
@@ -108,12 +136,18 @@ public class EdgeRules {
* @throws AAIException the AAI exception
* @throws NoEdgeRuleFoundException
*/
- private Edge addEdge(EdgeType type, GraphTraversalSource traversalSource, Vertex aVertex, Vertex bVertex) throws AAIException, NoEdgeRuleFoundException {
+ private Edge addEdge(EdgeType type, GraphTraversalSource traversalSource, Vertex aVertex, Vertex bVertex, boolean isBestEffort) throws AAIException, NoEdgeRuleFoundException {
EdgeRule rule = this.getEdgeRule(type, aVertex, bVertex);
Edge e = null;
- if (this.validateMultiplicity(rule, traversalSource, aVertex, bVertex)) {
+
+ Optional<String> message = this.validateMultiplicity(rule, traversalSource, aVertex, bVertex);
+
+ if (message.isPresent() && !isBestEffort) {
+ throw new EdgeMultiplicityException(message.get());
+ }
+ if (!message.isPresent()) {
if (rule.getDirection().equals(Direction.OUT)) {
e = aVertex.addEdge(rule.getLabel(), bVertex);
} else if (rule.getDirection().equals(Direction.IN)) {
@@ -319,7 +353,7 @@ public class EdgeRules {
* @return true, if successful
* @throws AAIException the AAI exception
*/
- private boolean validateMultiplicity(EdgeRule rule, GraphTraversalSource traversalSource, Vertex aVertex, Vertex bVertex) throws AAIException {
+ private Optional<String> validateMultiplicity(EdgeRule rule, GraphTraversalSource traversalSource, Vertex aVertex, Vertex bVertex) {
if (rule.getDirection().equals(Direction.OUT)) {
@@ -353,11 +387,12 @@ public class EdgeRules {
}
if (!detail.equals("")) {
- throw new AAIException("AAI_6140", detail);
+ return Optional.of(detail);
+ } else {
+ return Optional.empty();
}
- return true;
-
+
}
public Multimap<String, EdgeRule> getAllRules() throws AAIException {
diff --git a/aai-core/src/main/java/org/openecomp/aai/serialization/db/exceptions/EdgeMultiplicityException.java b/aai-core/src/main/java/org/openecomp/aai/serialization/db/exceptions/EdgeMultiplicityException.java
new file mode 100644
index 00000000..081a2d62
--- /dev/null
+++ b/aai-core/src/main/java/org/openecomp/aai/serialization/db/exceptions/EdgeMultiplicityException.java
@@ -0,0 +1,40 @@
+/*-
+ * ============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.exceptions;
+
+import org.openecomp.aai.exceptions.AAIException;
+
+public class EdgeMultiplicityException extends AAIException {
+
+ private static final long serialVersionUID = -5575661036426538012L;
+
+ public EdgeMultiplicityException(String message) {
+ super("AAI_6140", message);
+ }
+
+ public EdgeMultiplicityException(Throwable cause) {
+ super("AAI_6140",cause);
+ }
+
+ public EdgeMultiplicityException(String message, Throwable cause) {
+ super("AAI_6140", cause, message);
+ }
+}
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 ca12eabd..3f259aed 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
@@ -44,7 +44,7 @@ public abstract class TransactionalGraphEngine {
protected GraphSingleton singleton = null;
protected QueryEngine queryEngine = null;
- protected QueryBuilder queryBuilder = null;
+ protected QueryBuilder<Vertex> queryBuilder = null;
protected QueryStyle style = null;
protected final DBConnectionType connectionType;
protected final Loader loader;
@@ -141,19 +141,19 @@ public abstract class TransactionalGraphEngine {
*
* @return the query builder
*/
- public QueryBuilder getQueryBuilder() {
+ public QueryBuilder<Vertex> getQueryBuilder() {
return getQueryBuilder(this.loader);
}
- public QueryBuilder getQueryBuilder(Loader loader) {
+ public QueryBuilder<Vertex> getQueryBuilder(Loader loader) {
if (style.equals(QueryStyle.GREMLIN_TRAVERSAL)) {
- return new GremlinTraversal(loader, this.asAdmin().getTraversalSource());
+ return new GremlinTraversal<>(loader, this.asAdmin().getTraversalSource());
} else if (style.equals(QueryStyle.GREMLIN_UNIQUE)) {
- return new GremlinUnique(loader, this.asAdmin().getTraversalSource());
+ return new GremlinUnique<>(loader, this.asAdmin().getTraversalSource());
} else if (style.equals(QueryStyle.GREMLINPIPELINE_TRAVERSAL)) {
//return new GremlinPipelineTraversal(loader);
} else if (style.equals(QueryStyle.TRAVERSAL)) {
- return new TraversalQuery(loader, this.asAdmin().getTraversalSource());
+ return new TraversalQuery<>(loader, this.asAdmin().getTraversalSource());
} else {
throw new IllegalArgumentException("Query Builder type not recognized");
}
@@ -165,19 +165,19 @@ public abstract class TransactionalGraphEngine {
* @param start the start
* @return the query builder
*/
- public QueryBuilder getQueryBuilder(Vertex start) {
+ public QueryBuilder<Vertex> getQueryBuilder(Vertex start) {
return getQueryBuilder(this.loader, start);
}
- public QueryBuilder getQueryBuilder(Loader loader, Vertex start) {
+ public QueryBuilder<Vertex> getQueryBuilder(Loader loader, Vertex start) {
if (style.equals(QueryStyle.GREMLIN_TRAVERSAL)) {
- return new GremlinTraversal(loader, this.asAdmin().getTraversalSource(), start);
+ return new GremlinTraversal<>(loader, this.asAdmin().getTraversalSource(), start);
} else if (style.equals(QueryStyle.GREMLIN_UNIQUE)) {
- return new GremlinUnique(loader, this.asAdmin().getTraversalSource(), start);
+ return new GremlinUnique<>(loader, this.asAdmin().getTraversalSource(), start);
} else if (style.equals(QueryStyle.GREMLINPIPELINE_TRAVERSAL)) {
//return new GremlinPipelineTraversal(loader,start);
} else if (style.equals(QueryStyle.TRAVERSAL)) {
- return new TraversalQuery(loader, this.asAdmin().getTraversalSource(), start);
+ return new TraversalQuery<>(loader, this.asAdmin().getTraversalSource(), start);
} else {
throw new IllegalArgumentException("Query Builder type not recognized");
}
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 926998f3..7144aa69 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
@@ -88,6 +88,15 @@ public class GraphTraversalQueryEngine extends QueryEngine {
return pipe.toList();
}
+
+ public List<Vertex> findChildren(Vertex start) {
+ GraphTraversal<Vertex, Vertex> pipe = this.g.V(start).union(
+ __.outE().has("isParent", true),
+ __.inE().has("isParent-REV", true)
+ ).otherV().dedup();
+
+ return pipe.toList();
+ }
/**
* {@inheritDoc}
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 1d757428..a690ff65 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
@@ -25,7 +25,7 @@ import java.util.HashSet;
import java.util.List;
import java.util.Set;
-import org.openecomp.aai.db.props.AAIProperties;
+import org.openecomp.aai.db.AAIProperties;
import org.openecomp.aai.query.builder.QueryBuilder;
import org.openecomp.aai.serialization.engines.TransactionalGraphEngine;
import com.tinkerpop.blueprints.Direction;
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 0285fbd5..f77f726d 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
@@ -62,6 +62,8 @@ public abstract class QueryEngine {
public abstract List<Vertex> findAllChildren(Vertex start);
public abstract List<Vertex> findChildrenOfType(Vertex start, String type);
+
+ public abstract List<Vertex> findChildren(Vertex start);
/**
* Find deletable.
*
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 feb8893c..783d52e1 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 {
@@ -37,7 +37,7 @@ public class Formatter {
protected JsonParser parser = new JsonParser();
protected final FormatMapper format;
- public Formatter(FormatMapper format) {
+ public Formatter (FormatMapper format) {
this.format = format;
}
@@ -50,7 +50,7 @@ public class Formatter {
} else {
stream = vertices.stream();
}
-
+ final boolean isParallel = stream.isParallel();
stream.map(v -> {
try {
return Optional.<JsonObject>of(format.formatObject(v));
@@ -61,7 +61,11 @@ public class Formatter {
return Optional.<JsonObject>empty();
}).forEach(obj -> {
if (obj.isPresent()) {
- synchronized (body) {
+ if (isParallel) {
+ synchronized (body) {
+ body.add(obj.get());
+ }
+ } else {
body.add(obj.get());
}
}
diff --git a/aai-core/src/main/java/org/openecomp/aai/util/AAIConfig.java b/aai-core/src/main/java/org/openecomp/aai/util/AAIConfig.java
index bea50db9..9fcb521d 100644
--- a/aai-core/src/main/java/org/openecomp/aai/util/AAIConfig.java
+++ b/aai-core/src/main/java/org/openecomp/aai/util/AAIConfig.java
@@ -20,12 +20,6 @@
package org.openecomp.aai.util;
-import com.att.eelf.configuration.EELFLogger;
-import com.att.eelf.configuration.EELFManager;
-import org.eclipse.jetty.util.security.Password;
-import org.openecomp.aai.exceptions.AAIException;
-import org.openecomp.aai.logging.ErrorLogHelper;
-
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
@@ -36,6 +30,13 @@ import java.util.HashMap;
import java.util.Properties;
import java.util.Timer;
+import org.eclipse.jetty.util.security.Password;
+
+import org.openecomp.aai.exceptions.AAIException;
+import org.openecomp.aai.logging.ErrorLogHelper;
+import com.att.eelf.configuration.EELFLogger;
+import com.att.eelf.configuration.EELFManager;
+
public class AAIConfig {
@@ -59,7 +60,7 @@ public class AAIConfig {
*
* @throws AAIException the AAI exception
*/
- public synchronized static void init() throws AAIException {
+ public synchronized static void init() throws AAIException{
LOGGER.info("Initializing AAIConfig");
ArrayList<String> genericVnfBools = new ArrayList<String>();
@@ -89,7 +90,7 @@ public class AAIConfig {
AAIConfig.getConfigFile();
AAIConfig.reloadConfig();
- if (AAIConstants.AAI_NODENAME == null || AAIConstants.AAI_NODENAME == "") {
+ if (AAIConstants.AAI_NODENAME == null || AAIConstants.AAI_NODENAME == "") {
ErrorLogHelper.logError("AAI_4005", " AAI_NODENAME is not defined");
} else {
LOGGER.info("A&AI Server Node Name = " + AAIConstants.AAI_NODENAME);
@@ -217,7 +218,7 @@ public class AAIConfig {
* @return the int
* @throws AAIException the AAI exception
*/
- public static int getInt(String key) throws AAIException {
+ public static int getInt(String key) throws AAIException{
return Integer.valueOf(AAIConfig.get(key));
}
diff --git a/aai-core/src/main/java/org/openecomp/aai/util/AAITxnLog.java b/aai-core/src/main/java/org/openecomp/aai/util/AAITxnLog.java
index eeef94e7..0da84840 100644
--- a/aai-core/src/main/java/org/openecomp/aai/util/AAITxnLog.java
+++ b/aai-core/src/main/java/org/openecomp/aai/util/AAITxnLog.java
@@ -20,29 +20,35 @@
package org.openecomp.aai.util;
-import com.att.eelf.configuration.EELFLogger;
-import com.att.eelf.configuration.EELFManager;
+import java.io.IOException;
+import java.text.DateFormat;
+import java.text.SimpleDateFormat;
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.List;
+
import org.apache.hadoop.hbase.HBaseConfiguration;
-import org.apache.hadoop.hbase.client.*;
+import org.apache.hadoop.hbase.client.Get;
+import org.apache.hadoop.hbase.client.HTable;
+import org.apache.hadoop.hbase.client.Put;
+import org.apache.hadoop.hbase.client.Result;
+import org.apache.hadoop.hbase.client.ResultScanner;
+import org.apache.hadoop.hbase.client.Scan;
import org.apache.hadoop.hbase.filter.CompareFilter.CompareOp;
import org.apache.hadoop.hbase.filter.Filter;
import org.apache.hadoop.hbase.filter.FilterList;
import org.apache.hadoop.hbase.filter.RegexStringComparator;
import org.apache.hadoop.hbase.filter.SingleColumnValueFilter;
import org.apache.hadoop.hbase.util.Bytes;
+
import org.openecomp.aai.domain.notificationEvent.NotificationEvent;
import org.openecomp.aai.domain.translog.TransactionLogEntries;
import org.openecomp.aai.domain.translog.TransactionLogEntry;
import org.openecomp.aai.exceptions.AAIException;
+import com.att.eelf.configuration.EELFLogger;
+import com.att.eelf.configuration.EELFManager;
-import java.io.IOException;
-import java.text.DateFormat;
-import java.text.SimpleDateFormat;
-import java.util.ArrayList;
-import java.util.Date;
-import java.util.List;
-
-public class AAITxnLog {
+public class AAITxnLog {
private static final EELFLogger LOGGER = EELFManager.getInstance().getLogger(AAITxnLog.class);
@@ -340,8 +346,8 @@ public class AAITxnLog {
* @param fromAppIdFilter the from app id filter
* @return the transaction log entries
*/
- public TransactionLogEntries scanFiltered(long startMillis, long endMillis, List<String> methodList,
- String putFilter, String getFilter, String resourceFilter, String fromAppIdFilter) {
+ public TransactionLogEntries scanFiltered(long startMillis, long endMillis, List<String> methodList,
+ String putFilter, String getFilter, String resourceFilter, String fromAppIdFilter) {
LOGGER.debug("Starting scanFiltered()");
diff --git a/aai-core/src/main/java/org/openecomp/aai/util/HttpsAuthClient.java b/aai-core/src/main/java/org/openecomp/aai/util/HttpsAuthClient.java
new file mode 100644
index 00000000..85225041
--- /dev/null
+++ b/aai-core/src/main/java/org/openecomp/aai/util/HttpsAuthClient.java
@@ -0,0 +1,140 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * org.openecomp.aai
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.aai.util;
+
+import java.io.FileInputStream;
+import java.security.KeyManagementException;
+import java.security.KeyStore;
+
+import javax.net.ssl.HostnameVerifier;
+import javax.net.ssl.HttpsURLConnection;
+import javax.net.ssl.KeyManagerFactory;
+import javax.net.ssl.SSLContext;
+import javax.net.ssl.SSLSession;
+
+import org.openecomp.aai.domain.yang.Customers;
+import com.sun.jersey.api.client.Client;
+import com.sun.jersey.api.client.ClientResponse;
+import com.sun.jersey.api.client.config.ClientConfig;
+import com.sun.jersey.api.client.config.DefaultClientConfig;
+import com.sun.jersey.api.client.filter.LoggingFilter;
+import com.sun.jersey.api.json.JSONConfiguration;
+import com.sun.jersey.client.urlconnection.HTTPSProperties;
+
+public class HttpsAuthClient{
+
+ /**
+ * The main method.
+ *
+ * @param args the arguments
+ */
+ public static void main(String[] args) {
+ try {
+ String url = AAIConfig.get(AAIConstants.AAI_SERVER_URL) + "business/customers";
+ System.out.println("Making Jersey https call...");
+ Client client = HttpsAuthClient.getClient();
+
+ ClientResponse res = client.resource(url)
+ .accept("application/json")
+ .header("X-TransactionId", "PROV001")
+ .header("X-FromAppId", "AAI")
+ .type("application/json")
+ .get(ClientResponse.class);
+
+// System.out.println("Jersey result: ");
+// System.out.println(res.getEntity(String.class).toString());
+
+ Customers customers = res.getEntity(Customers.class);
+ System.out.println("Jersey result: ");
+ System.out.println("Number of customers: " + customers.getCustomer().size());
+
+ } catch (KeyManagementException e) {
+ e.printStackTrace();
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+
+
+ /**
+ * Gets the client.
+ *
+ * @return the client
+ * @throws KeyManagementException the key management exception
+ */
+ public static Client getClient() throws KeyManagementException {
+
+ ClientConfig config = new DefaultClientConfig();
+ config.getFeatures().put(JSONConfiguration.FEATURE_POJO_MAPPING, Boolean.TRUE);
+ config.getClasses().add(org.openecomp.aai.restcore.CustomJacksonJaxBJsonProvider.class);
+
+ SSLContext ctx = null;
+ try {
+ String truststore_path = AAIConstants.AAI_HOME_ETC_AUTH + AAIConfig.get(AAIConstants.AAI_TRUSTSTORE_FILENAME);
+ String truststore_password = AAIConfig.get(AAIConstants.AAI_TRUSTSTORE_PASSWD);
+ String keystore_path = AAIConstants.AAI_HOME_ETC_AUTH + AAIConfig.get(AAIConstants.AAI_KEYSTORE_FILENAME);
+ String keystore_password = AAIConfig.get(AAIConstants.AAI_KEYSTORE_PASSWD);
+
+ System.setProperty("javax.net.ssl.trustStore", truststore_path);
+ System.setProperty("javax.net.ssl.trustStorePassword", truststore_password);
+ HttpsURLConnection.setDefaultHostnameVerifier( new HostnameVerifier(){
+ public boolean verify(String string,SSLSession ssls) {
+ return true;
+ }
+ });
+
+ ctx = SSLContext.getInstance("TLSv1.2");
+ KeyManagerFactory kmf = null;
+ try {
+ kmf = KeyManagerFactory.getInstance("SunX509");
+ FileInputStream fin = new FileInputStream(keystore_path);
+ KeyStore ks = KeyStore.getInstance("PKCS12");
+ char[] pwd = keystore_password.toCharArray();
+ ks.load(fin, pwd);
+ kmf.init(ks, pwd);
+ } catch (Exception e) {
+ System.out.println("Error setting up kmf: exiting");
+ e.printStackTrace();
+ System.exit(1);
+ }
+
+ ctx.init(kmf.getKeyManagers(), null, null);
+ config.getProperties().put(HTTPSProperties.PROPERTY_HTTPS_PROPERTIES,
+ new HTTPSProperties( new HostnameVerifier() {
+ @Override
+ public boolean verify( String s, SSLSession sslSession ) {
+ return true;
+ }
+ }, ctx));
+ } catch (Exception e) {
+ System.out.println("Error setting up config: exiting");
+ e.printStackTrace();
+ System.exit(1);
+ }
+
+ Client client = Client.create(config);
+ // uncomment this line to get more logging for the request/response
+ // client.addFilter(new LoggingFilter(System.out));
+
+ return client;
+ }
+
+}
diff --git a/aai-core/src/test/java/org/openecomp/aai/exceptions/AAIExceptionTest.java b/aai-core/src/test/java/org/openecomp/aai/exceptions/AAIExceptionTest.java
index 25b777d0..862f6911 100644
--- a/aai-core/src/test/java/org/openecomp/aai/exceptions/AAIExceptionTest.java
+++ b/aai-core/src/test/java/org/openecomp/aai/exceptions/AAIExceptionTest.java
@@ -20,14 +20,12 @@
package org.openecomp.aai.exceptions;
-
import static org.junit.Assert.assertEquals;
import org.junit.BeforeClass;
-
import org.junit.Test;
-
-import static org.junit.Assert.assertEquals;
+import org.openecomp.aai.serialization.queryformats.QueryFormatTestHelper;
+import org.openecomp.aai.util.AAIConstants;
public class AAIExceptionTest {
private static final String code = "4004";
@@ -36,11 +34,12 @@ public class AAIExceptionTest {
private static final Throwable noMessage = new RuntimeException();
@BeforeClass
- public static void configure() {
- System.setProperty("AJSC_HOME", "./src/test/resources/");
- System.setProperty("BUNDLECONFIG_DIR", "bundleconfig-local");
+ public static void configure() throws NoSuchFieldException, SecurityException, Exception {
+ System.setProperty("AJSC_HOME", ".");
+ System.setProperty("BUNDLECONFIG_DIR", "src/test/resources/bundleconfig-local");
+ QueryFormatTestHelper.setFinalStatic(AAIConstants.class.getField("AAI_HOME_ETC_OXM"), "src/test/resources/org/openecomp/aai/introspection/");
}
-
+
/**
* Test constructor with 0 params.
*
diff --git a/aai-core/src/test/java/org/openecomp/aai/exceptions/AAIExceptionWithInfoTest.java b/aai-core/src/test/java/org/openecomp/aai/exceptions/AAIExceptionWithInfoTest.java
index 65381d64..b6357e43 100644
--- a/aai-core/src/test/java/org/openecomp/aai/exceptions/AAIExceptionWithInfoTest.java
+++ b/aai-core/src/test/java/org/openecomp/aai/exceptions/AAIExceptionWithInfoTest.java
@@ -22,6 +22,8 @@ package org.openecomp.aai.exceptions;
import org.junit.BeforeClass;
import org.junit.Test;
+import org.openecomp.aai.serialization.queryformats.QueryFormatTestHelper;
+import org.openecomp.aai.util.AAIConstants;
import java.util.HashMap;
@@ -44,9 +46,10 @@ public class AAIExceptionWithInfoTest {
private static final Throwable cause = new RuntimeException("This is a runtime exception.");
@BeforeClass
- public static void configure() {
- System.setProperty("AJSC_HOME", "./src/test/resources/");
- System.setProperty("BUNDLECONFIG_DIR", "bundleconfig-local");
+ public static void configure() throws NoSuchFieldException, SecurityException, Exception {
+ System.setProperty("AJSC_HOME", ".");
+ System.setProperty("BUNDLECONFIG_DIR", "src/test/resources/bundleconfig-local");
+ QueryFormatTestHelper.setFinalStatic(AAIConstants.class.getField("AAI_HOME_ETC_OXM"), "src/test/resources/org/openecomp/aai/introspection/");
}
/**
diff --git a/aai-core/src/test/java/org/openecomp/aai/introspection/IntrospectorTestSpec.java b/aai-core/src/test/java/org/openecomp/aai/introspection/IntrospectorTestSpec.java
index 73d8101f..47fef7ee 100644
--- a/aai-core/src/test/java/org/openecomp/aai/introspection/IntrospectorTestSpec.java
+++ b/aai-core/src/test/java/org/openecomp/aai/introspection/IntrospectorTestSpec.java
@@ -20,12 +20,13 @@
package org.openecomp.aai.introspection;
-import com.google.common.collect.Sets;
-import org.openecomp.aai.introspection.exceptions.AAIUnknownObjectException;
+import static org.junit.Assert.assertEquals;
+import java.util.Arrays;
import java.util.Set;
-import static org.junit.Assert.assertEquals;
+import org.openecomp.aai.introspection.exceptions.AAIUnknownObjectException;
+import com.google.common.collect.Sets;
public class IntrospectorTestSpec {
@@ -35,7 +36,7 @@ public class IntrospectorTestSpec {
* Container test set.
*
* @param wrappedPortGroups the wrapped port groups
- * @throws AAIUnknownObjectException
+ * @throws AAIUnknownObjectException
*/
protected void containerTestSet(Introspector wrappedPortGroups) throws AAIUnknownObjectException {
diff --git a/aai-core/src/test/java/org/openecomp/aai/introspection/MoxyEngineTest.java b/aai-core/src/test/java/org/openecomp/aai/introspection/MoxyEngineTest.java
index 7b8f338e..9504c46b 100644
--- a/aai-core/src/test/java/org/openecomp/aai/introspection/MoxyEngineTest.java
+++ b/aai-core/src/test/java/org/openecomp/aai/introspection/MoxyEngineTest.java
@@ -20,19 +20,21 @@
package org.openecomp.aai.introspection;
+import java.io.StringReader;
+
+import javax.xml.bind.JAXBException;
+import javax.xml.bind.Unmarshaller;
+
import org.eclipse.persistence.dynamic.DynamicEntity;
import org.eclipse.persistence.jaxb.UnmarshallerProperties;
import org.eclipse.persistence.jaxb.dynamic.DynamicJAXBContext;
import org.junit.BeforeClass;
import org.junit.Test;
+
import org.openecomp.aai.introspection.exceptions.AAIUnknownObjectException;
import org.openecomp.aai.serialization.queryformats.QueryFormatTestHelper;
import org.openecomp.aai.util.AAIConstants;
-import javax.xml.bind.JAXBException;
-import javax.xml.bind.Unmarshaller;
-import java.io.StringReader;
-
public class MoxyEngineTest extends IntrospectorTestSpec {
/**
@@ -50,7 +52,7 @@ public class MoxyEngineTest extends IntrospectorTestSpec {
/**
* Container object.
- * @throws AAIUnknownObjectException
+ * @throws AAIUnknownObjectException
*/
@Test
public void containerObject() throws AAIUnknownObjectException {
diff --git a/aai-core/src/test/java/org/openecomp/aai/introspection/PojoInjestorTest.java b/aai-core/src/test/java/org/openecomp/aai/introspection/PojoInjestorTest.java
index 333bc9e3..34a6279b 100644
--- a/aai-core/src/test/java/org/openecomp/aai/introspection/PojoInjestorTest.java
+++ b/aai-core/src/test/java/org/openecomp/aai/introspection/PojoInjestorTest.java
@@ -20,15 +20,16 @@
package org.openecomp.aai.introspection;
-import org.junit.BeforeClass;
-import org.junit.Test;
-import org.openecomp.aai.db.props.AAIProperties;
+import static org.junit.Assert.*;
import javax.xml.bind.JAXBContext;
import javax.xml.bind.JAXBException;
import javax.xml.bind.Marshaller;
-import static org.junit.Assert.*;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+import org.openecomp.aai.db.props.AAIProperties;
public class PojoInjestorTest {
diff --git a/aai-core/src/test/java/org/openecomp/aai/introspection/PojoLoaderTest.java b/aai-core/src/test/java/org/openecomp/aai/introspection/PojoLoaderTest.java
index d1e35a22..0eeb966b 100644
--- a/aai-core/src/test/java/org/openecomp/aai/introspection/PojoLoaderTest.java
+++ b/aai-core/src/test/java/org/openecomp/aai/introspection/PojoLoaderTest.java
@@ -20,15 +20,15 @@
package org.openecomp.aai.introspection;
+import static org.junit.Assert.*;
+
import org.junit.BeforeClass;
import org.junit.Test;
+
import org.openecomp.aai.domain.yang.v9.VnfImage;
import org.openecomp.aai.introspection.exceptions.AAIUnmarshallingException;
import org.openecomp.aai.restcore.MediaType;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
-
public class PojoLoaderTest {
diff --git a/aai-core/src/test/java/org/openecomp/aai/introspection/PojoStrategyTest.java b/aai-core/src/test/java/org/openecomp/aai/introspection/PojoStrategyTest.java
index 0bd61178..4843b10d 100644
--- a/aai-core/src/test/java/org/openecomp/aai/introspection/PojoStrategyTest.java
+++ b/aai-core/src/test/java/org/openecomp/aai/introspection/PojoStrategyTest.java
@@ -20,13 +20,14 @@
package org.openecomp.aai.introspection;
+import static org.junit.Assert.*;
+
import org.junit.Test;
+
import org.openecomp.aai.domain.yang.CloudRegion;
import org.openecomp.aai.domain.yang.VolumeGroup;
import org.openecomp.aai.schema.enums.ObjectMetadata;
-import static org.junit.Assert.assertEquals;
-
public class PojoStrategyTest {
@Test
diff --git a/aai-core/src/test/java/org/openecomp/aai/introspection/PropertyPredicatesTest.java b/aai-core/src/test/java/org/openecomp/aai/introspection/PropertyPredicatesTest.java
index a7cde118..1f997333 100644
--- a/aai-core/src/test/java/org/openecomp/aai/introspection/PropertyPredicatesTest.java
+++ b/aai-core/src/test/java/org/openecomp/aai/introspection/PropertyPredicatesTest.java
@@ -20,18 +20,17 @@
package org.openecomp.aai.introspection;
+import static org.hamcrest.Matchers.*;
+import static org.junit.Assert.*;
+import java.util.Set;
+
import org.junit.BeforeClass;
import org.junit.Test;
+
import org.openecomp.aai.introspection.exceptions.AAIUnknownObjectException;
import org.openecomp.aai.serialization.queryformats.QueryFormatTestHelper;
import org.openecomp.aai.util.AAIConstants;
-import java.util.Set;
-
-import static org.hamcrest.Matchers.hasItems;
-import static org.hamcrest.Matchers.not;
-import static org.junit.Assert.assertThat;
-
public class PropertyPredicatesTest {
diff --git a/aai-core/src/test/java/org/openecomp/aai/introspection/ReflectionEngineTest.java b/aai-core/src/test/java/org/openecomp/aai/introspection/ReflectionEngineTest.java
index 52ed0d87..8781d59c 100644
--- a/aai-core/src/test/java/org/openecomp/aai/introspection/ReflectionEngineTest.java
+++ b/aai-core/src/test/java/org/openecomp/aai/introspection/ReflectionEngineTest.java
@@ -20,17 +20,19 @@
package org.openecomp.aai.introspection;
-import org.junit.BeforeClass;
-import org.junit.Test;
-import org.openecomp.aai.introspection.exceptions.AAIUnknownObjectException;
-import org.openecomp.aai.restcore.CustomJacksonJaxBJsonProvider;
-
-import javax.xml.bind.JAXBException;
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.nio.charset.StandardCharsets;
+import javax.xml.bind.JAXBException;
+
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+import org.openecomp.aai.introspection.exceptions.AAIUnknownObjectException;
+import org.openecomp.aai.restcore.CustomJacksonJaxBJsonProvider;
+
public class ReflectionEngineTest extends IntrospectorTestSpec {
/**
@@ -48,7 +50,7 @@ public class ReflectionEngineTest extends IntrospectorTestSpec {
* @throws InstantiationException the instantiation exception
* @throws IllegalAccessException the illegal access exception
* @throws ClassNotFoundException the class not found exception
- * @throws AAIUnknownObjectException
+ * @throws AAIUnknownObjectException
*/
@Test
public void containerObject() throws InstantiationException, IllegalAccessException, ClassNotFoundException, AAIUnknownObjectException {
diff --git a/aai-core/src/test/java/org/openecomp/aai/introspection/sideeffect/DataCopyTest.java b/aai-core/src/test/java/org/openecomp/aai/introspection/sideeffect/DataCopyTest.java
index 70d6b123..4d18835e 100644
--- a/aai-core/src/test/java/org/openecomp/aai/introspection/sideeffect/DataCopyTest.java
+++ b/aai-core/src/test/java/org/openecomp/aai/introspection/sideeffect/DataCopyTest.java
@@ -83,8 +83,8 @@ public class DataCopyTest {
@BeforeClass
public static void setup() throws NoSuchFieldException, SecurityException, Exception {
graph = TitanFactory.build().set("storage.backend","inmemory").open();
- System.setProperty("AJSC_HOME", "./src/test/resources/");
- System.setProperty("BUNDLECONFIG_DIR", "bundleconfig-local");
+ System.setProperty("AJSC_HOME", ".");
+ System.setProperty("BUNDLECONFIG_DIR", "src/test/resources/bundleconfig-local");
QueryFormatTestHelper.setFinalStatic(AAIConstants.class.getField("AAI_HOME_ETC_OXM"), "src/test/resources/org/openecomp/aai/introspection/");
loader = LoaderFactory.createLoaderForVersion(introspectorFactoryType, version);
dbEngine = new TitanDBEngine(
diff --git a/aai-core/src/test/java/org/openecomp/aai/introspection/sideeffect/DataLinkTest.java b/aai-core/src/test/java/org/openecomp/aai/introspection/sideeffect/DataLinkTest.java
index a9e707a2..595cb868 100644
--- a/aai-core/src/test/java/org/openecomp/aai/introspection/sideeffect/DataLinkTest.java
+++ b/aai-core/src/test/java/org/openecomp/aai/introspection/sideeffect/DataLinkTest.java
@@ -80,8 +80,8 @@ public class DataLinkTest {
@BeforeClass
public static void setup() throws NoSuchFieldException, SecurityException, Exception {
graph = TitanFactory.build().set("storage.backend","inmemory").open();
- System.setProperty("AJSC_HOME", "./src/test/resources/");
- System.setProperty("BUNDLECONFIG_DIR", "bundleconfig-local");
+ System.setProperty("AJSC_HOME", ".");
+ System.setProperty("BUNDLECONFIG_DIR", "src/test/resources/bundleconfig-local");
QueryFormatTestHelper.setFinalStatic(AAIConstants.class.getField("AAI_HOME_ETC_OXM"), "src/test/resources/org/openecomp/aai/introspection/");
loader = LoaderFactory.createLoaderForVersion(introspectorFactoryType, version);
dbEngine = new TitanDBEngine(
diff --git a/aai-core/src/test/java/org/openecomp/aai/introspection/validation/IntrospectorValidationTest.java b/aai-core/src/test/java/org/openecomp/aai/introspection/validation/IntrospectorValidationTest.java
new file mode 100644
index 00000000..459746bc
--- /dev/null
+++ b/aai-core/src/test/java/org/openecomp/aai/introspection/validation/IntrospectorValidationTest.java
@@ -0,0 +1,99 @@
+/*-
+ * ============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.introspection.validation;
+
+import static org.junit.Assert.assertEquals;
+
+import java.util.List;
+
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.Ignore;
+import org.junit.Test;
+
+import org.openecomp.aai.exceptions.AAIException;
+import org.openecomp.aai.introspection.Introspector;
+import org.openecomp.aai.introspection.Loader;
+import org.openecomp.aai.introspection.LoaderFactory;
+import org.openecomp.aai.introspection.ModelType;
+import org.openecomp.aai.introspection.Version;
+import org.openecomp.aai.introspection.tools.IntrospectorValidator;
+import org.openecomp.aai.introspection.tools.Issue;
+import org.openecomp.aai.introspection.tools.IssueType;
+import org.openecomp.aai.serialization.queryformats.QueryFormatTestHelper;
+import org.openecomp.aai.util.AAIConstants;
+
+public class IntrospectorValidationTest {
+
+
+ private final static Version version = Version.v10;
+ private final static ModelType introspectorFactoryType = ModelType.MOXY;
+ private static Loader loader;
+ private IntrospectorValidator validator;
+ @BeforeClass
+ public static void setUp() throws NoSuchFieldException, SecurityException, Exception {
+ System.setProperty("AJSC_HOME", ".");
+ System.setProperty("BUNDLECONFIG_DIR", "bundleconfig-local");
+ QueryFormatTestHelper.setFinalStatic(AAIConstants.class.getField("AAI_HOME_ETC_OXM"), "src/test/resources/org/openecomp/aai/introspection/");
+
+ loader = LoaderFactory.createLoaderForVersion(introspectorFactoryType, version);
+
+ }
+ @Before
+ public void createValidator() {
+ validator = new IntrospectorValidator.Builder()
+ .validateRequired(false)
+ .restrictDepth(10000)
+ .build();
+ }
+ @Test
+ public void verifySuccessWhenEmpty() throws AAIException {
+ Introspector obj = loader.introspectorFromName("test-object");
+ obj.setValue("vnf-id", "key1");
+ validator.validate(obj);
+ List<Issue> issues = validator.getIssues();
+ assertEquals("no issues found", true, issues.isEmpty());
+ }
+
+ @Ignore
+ @Test
+ public void verifyRequiresSingleFieldFailure() throws AAIException {
+ Introspector obj = loader.introspectorFromName("test-object");
+ obj.setValue("vnf-id", "key1");
+ obj.setValue("model-invariant-id", "id1");
+ validator.validate(obj);
+ List<Issue> issues = validator.getIssues();
+ assertEquals("issues found", true, issues.size() == 1);
+ Issue issue = issues.get(0);
+ assertEquals("found expected issue", IssueType.DEPENDENT_PROP_NOT_FOUND, issue.getType());
+ }
+
+ @Test
+ public void verifyRequiresSuccess() throws AAIException {
+ Introspector obj = loader.introspectorFromName("test-object");
+ obj.setValue("vnf-id", "key1");
+ obj.setValue("model-invariant-id", "id1");
+ obj.setValue("model-version-id", "version-id1");
+ validator.validate(obj);
+ List<Issue> issues = validator.getIssues();
+ assertEquals("no issues found", true, issues.isEmpty());
+ }
+}
diff --git a/aai-core/src/test/java/org/openecomp/aai/logging/LoggingContextTest.java b/aai-core/src/test/java/org/openecomp/aai/logging/LoggingContextTest.java
new file mode 100644
index 00000000..3fe2098c
--- /dev/null
+++ b/aai-core/src/test/java/org/openecomp/aai/logging/LoggingContextTest.java
@@ -0,0 +1,114 @@
+/*-
+ * ============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.logging;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+
+import java.util.Collections;
+import java.util.Deque;
+import java.util.LinkedList;
+import java.util.Map;
+import java.util.UUID;
+
+import org.junit.Test;
+
+public class LoggingContextTest {
+
+ private static final int MAX_STORED_CONTEXTS = 100;
+
+ @Test
+ public void testStopWatch() {
+ try {
+ LoggingContext.stopWatchStop();
+ throw new AssertionError("No exception thrown when LoggingContext.stopWatchStop() called without a prior LoggingContext.stopWatchStart()");
+ } catch (StopWatchNotStartedException e) {
+ //Expected
+ }
+
+ LoggingContext.stopWatchStart();
+
+ assertTrue(LoggingContext.stopWatchStop() >= 0);
+
+ try {
+ LoggingContext.stopWatchStop();
+ throw new AssertionError("No exception thrown when LoggingContext.stopWatchStop() twice in succession");
+ } catch (StopWatchNotStartedException e) {
+ //Expected
+ }
+ }
+
+ @Test
+ public void testRequestId() { //AKA Transaction ID
+ final String sUuid = "57d51eaa-edc6-4f50-a69d-f2d4d2445120";
+
+ LoggingContext.requestId(sUuid);
+
+ assertEquals(LoggingContext.requestId(), UUID.fromString(sUuid));
+
+ final UUID uuid = UUID.randomUUID();
+
+ LoggingContext.requestId(uuid);
+
+ assertEquals(LoggingContext.requestId(), uuid);
+
+ LoggingContext.requestId("foo"); //Illegal - this will result in a new, randomly
+ //generated UUID as per the logging spec
+
+ assertNotNull(LoggingContext.requestId()); //Make sure ANY UUID was assigned
+ assertNotEquals(LoggingContext.requestId(), uuid); //Make sure it actually changed from the last
+ //known valid UUID
+ }
+
+ @Test
+ public void testClear() {
+ LoggingContext.init();
+ LoggingContext.clear();
+
+ assertEquals(Collections.emptyMap(), LoggingContext.getCopy());
+ }
+
+ @Test
+ public void testSaveRestore() {
+
+ final Deque<Map<String, String>> contexts = new LinkedList<Map<String, String>> ();
+
+ LoggingContext.init();
+
+ for (int i = 0; i < MAX_STORED_CONTEXTS; i++) {
+ LoggingContext.customField1(String.valueOf(i));
+
+ assertEquals(LoggingContext.customField1(), String.valueOf(i));
+
+ LoggingContext.save();
+
+ contexts.push(LoggingContext.getCopy());
+ }
+
+ while (contexts.peek() != null) {
+ LoggingContext.restore();
+
+ assertEquals(LoggingContext.getCopy(), contexts.pop());
+ }
+ }
+}
diff --git a/aai-core/src/test/java/org/openecomp/aai/parsers/query/GraphTraversalTest.java b/aai-core/src/test/java/org/openecomp/aai/parsers/query/GraphTraversalTest.java
index 79f75ab9..099ea37e 100644
--- a/aai-core/src/test/java/org/openecomp/aai/parsers/query/GraphTraversalTest.java
+++ b/aai-core/src/test/java/org/openecomp/aai/parsers/query/GraphTraversalTest.java
@@ -39,6 +39,7 @@ import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversal;
import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.__;
import org.apache.tinkerpop.gremlin.structure.Vertex;
import org.junit.BeforeClass;
+import org.junit.Ignore;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;
@@ -48,6 +49,7 @@ import org.openecomp.aai.exceptions.AAIException;
import org.openecomp.aai.introspection.LoaderFactory;
import org.openecomp.aai.introspection.ModelType;
import org.openecomp.aai.introspection.Version;
+import org.openecomp.aai.rest.RestTokens;
import org.openecomp.aai.serialization.engines.QueryStyle;
import org.openecomp.aai.serialization.engines.TitanDBEngine;
import org.openecomp.aai.serialization.engines.TransactionalGraphEngine;
@@ -72,8 +74,8 @@ public class GraphTraversalTest {
*/
@BeforeClass
public static void configure() throws NoSuchFieldException, SecurityException, Exception {
- System.setProperty("AJSC_HOME", "./src/test/resources/");
- System.setProperty("BUNDLECONFIG_DIR", "bundleconfig-local");
+ System.setProperty("AJSC_HOME", ".");
+ System.setProperty("BUNDLECONFIG_DIR", "src/test/resources/bundleconfig-local");
QueryFormatTestHelper.setFinalStatic(AAIConstants.class.getField("AAI_HOME_ETC_OXM"), "src/test/resources/org/openecomp/aai/introspection/");
dbEngine =
new TitanDBEngine(QueryStyle.TRAVERSAL,
@@ -486,8 +488,7 @@ public class GraphTraversalTest {
QueryParser query = dbEngine.getQueryBuilder().createQueryFromURI(uri);
GraphTraversal<Vertex, Vertex> expected = __.<Vertex>start()
- .has("vnf-id", "key1").has(
- AAIProperties.NODE_TYPE, P.within("vce" , "vpe" , "generic-vnf"));
+ .has("vnf-id", "key1").has(AAIProperties.NODE_TYPE, P.within("vce", "vpe", "generic-vnf"));
GraphTraversal<Vertex, Vertex> expectedParent = expected;
assertEquals(
@@ -534,8 +535,7 @@ public class GraphTraversalTest {
GraphTraversal<Vertex, Vertex> expected = __.<Vertex>start()
.has("vnf-id", "key1").has(AAIProperties.NODE_TYPE, P.within("vce", "vpe", "generic-vnf"))
- .union(__.out("has").has("aai-node-type", "vf-module"))
- .has("vf-module-id", "key2");
+ .union(__.out("has").has(AAIProperties.NODE_TYPE, "vf-module")).has("vf-module-id", "key2");
GraphTraversal<Vertex, Vertex> expectedParent = __.<Vertex>start()
.has("vnf-id", "key1").has(AAIProperties.NODE_TYPE, P.within("vce", "vpe", "generic-vnf"));
@@ -691,7 +691,138 @@ public class GraphTraversalTest {
"",
query.getParentResultType());
assertEquals("dependent",true, query.isDependent());
-
+ }
+
+ @Ignore
+ @Test
+ public void pluralCousin() throws UnsupportedEncodingException, AAIException {
+ URI uri = UriBuilder.fromPath("cloud-infrastructure/complexes/complex/key1/related-to/pservers").build();
+
+ QueryParser query = dbEnginev9.getQueryBuilder().createQueryFromURI(uri);
+ GraphTraversal<Vertex, Vertex> expected = __.<Vertex>start()
+ .has("physical-location-id", "key1")
+ .has("aai-node-type", "complex")
+ .in("locatedIn").has("aai-node-type", "pserver");
+ GraphTraversal<Vertex, Vertex> expectedParent = __.<Vertex>start()
+ .has("physical-location-id", "key1")
+ .has("aai-node-type", "complex");
+
+ assertEquals(
+ "gremlin query should be " + expected.toString(),
+ expected.toString(),
+ query.getQueryBuilder().getQuery().toString());
+ assertEquals(
+ "parent",
+ expectedParent.toString(),
+ query.getQueryBuilder().getParentQuery().getQuery().toString());
+
+ assertEquals(
+ "result type should be",
+ "pserver",
+ query.getResultType());
+ assertEquals(
+ "result type should be",
+ "complex",
+ query.getParentResultType());
+ //this is controversial but we're not allowing writes on this currently
+ assertEquals("dependent",true, query.isDependent());
+ }
+
+ @Ignore
+ @Test
+ public void specificCousin() throws UnsupportedEncodingException, AAIException {
+ URI uri = UriBuilder.fromPath("cloud-infrastructure/complexes/complex/key1/related-to/pservers/pserver/key2").build();
+
+ QueryParser query = dbEnginev9.getQueryBuilder().createQueryFromURI(uri);
+ GraphTraversal<Vertex, Vertex> expected = __.<Vertex>start()
+ .has("physical-location-id", "key1")
+ .has("aai-node-type", "complex")
+ .in("locatedIn").has("aai-node-type", "pserver")
+ .has("hostname", "key2");
+ GraphTraversal<Vertex, Vertex> expectedParent = __.<Vertex>start()
+ .has("physical-location-id", "key1")
+ .has("aai-node-type", "complex");
+
+ assertEquals(
+ "gremlin query should be " + expected.toString(),
+ expected.toString(),
+ query.getQueryBuilder().getQuery().toString());
+ assertEquals(
+ "parent",
+ expectedParent.toString(),
+ query.getQueryBuilder().getParentQuery().getQuery().toString());
+
+ assertEquals(
+ "result type should be",
+ "pserver",
+ query.getResultType());
+ assertEquals(
+ "result type should be",
+ "complex",
+ query.getParentResultType());
+ //this is controversial but we're not allowing writes on this currently
+ assertEquals("dependent",true, query.isDependent());
+ }
+
+ @Ignore
+ @Test
+ public void doubleSpecificCousin() throws UnsupportedEncodingException, AAIException {
+ URI uri = UriBuilder.fromPath("cloud-infrastructure/complexes/complex/key1/related-to/pservers/pserver/key2/related-to/vservers/vserver/key3").build();
+
+ QueryParser query = dbEnginev9.getQueryBuilder().createQueryFromURI(uri);
+ GraphTraversal<Vertex, Vertex> expected = __.<Vertex>start()
+ .has("physical-location-id", "key1")
+ .has("aai-node-type", "complex")
+ .in("locatedIn").has("aai-node-type", "pserver")
+ .has("hostname", "key2")
+ .in("runsOnPserver").has("aai-node-type", "vserver")
+ .has("vserver-id", "key3");
+ GraphTraversal<Vertex, Vertex> expectedParent = __.<Vertex>start()
+ .has("physical-location-id", "key1")
+ .has("aai-node-type", "complex")
+ .in("locatedIn").has("aai-node-type", "pserver")
+ .has("hostname", "key2");
+
+ assertEquals(
+ "gremlin query should be " + expected.toString(),
+ expected.toString(),
+ query.getQueryBuilder().getQuery().toString());
+ assertEquals(
+ "parent",
+ expectedParent.toString(),
+ query.getQueryBuilder().getParentQuery().getQuery().toString());
+
+ assertEquals(
+ "result type should be",
+ "vserver",
+ query.getResultType());
+ assertEquals(
+ "result type should be",
+ "pserver",
+ query.getParentResultType());
+ //this is controversial but we're not allowing writes on this currently
+ assertEquals("dependent",true, query.isDependent());
+ }
+
+ @Ignore
+ @Test
+ public void traversalEndsInRelatedTo() throws UnsupportedEncodingException, AAIException {
+ URI uri = UriBuilder.fromPath("cloud-infrastructure/complexes/complex/key1/related-to").build();
+
+ thrown.expect(AAIException.class);
+ thrown.expectMessage(containsString(RestTokens.COUSIN.toString()));
+ QueryParser query = dbEnginev9.getQueryBuilder().createQueryFromURI(uri);
+
+ }
+
+ @Ignore
+ @Test
+ public void pluralCousinToPluralCousin() throws UnsupportedEncodingException, AAIException {
+ URI uri = UriBuilder.fromPath("cloud-infrastructure/complexes/related-to/pservers").build();
+
+ thrown.expect(AAIException.class);
+ thrown.expectMessage(containsString("chain plurals"));
+ QueryParser query = dbEnginev9.getQueryBuilder().createQueryFromURI(uri);
}
}
diff --git a/aai-core/src/test/java/org/openecomp/aai/parsers/query/LegacyQueryTest.java b/aai-core/src/test/java/org/openecomp/aai/parsers/query/LegacyQueryTest.java
index bab74ed0..af61fcb0 100644
--- a/aai-core/src/test/java/org/openecomp/aai/parsers/query/LegacyQueryTest.java
+++ b/aai-core/src/test/java/org/openecomp/aai/parsers/query/LegacyQueryTest.java
@@ -20,9 +20,19 @@
package org.openecomp.aai.parsers.query;
+import static org.junit.Assert.assertEquals;
+
+import java.io.UnsupportedEncodingException;
+import java.net.URI;
+
+import javax.ws.rs.core.UriBuilder;
+import javax.xml.bind.JAXBException;
+
import org.eclipse.persistence.jaxb.dynamic.DynamicJAXBContext;
import org.junit.BeforeClass;
+import org.junit.Ignore;
import org.junit.Test;
+
import org.openecomp.aai.exceptions.AAIException;
import org.openecomp.aai.introspection.LoaderFactory;
import org.openecomp.aai.introspection.ModelInjestor;
@@ -32,13 +42,6 @@ import org.openecomp.aai.serialization.engines.QueryStyle;
import org.openecomp.aai.serialization.engines.TitanDBEngine;
import org.openecomp.aai.serialization.engines.TransactionalGraphEngine;
-import javax.ws.rs.core.UriBuilder;
-import javax.xml.bind.JAXBException;
-import java.io.UnsupportedEncodingException;
-import java.net.URI;
-
-import static org.junit.Assert.assertEquals;
-
public class LegacyQueryTest {
private ModelInjestor injestor = ModelInjestor.getInstance();
@@ -55,8 +58,8 @@ public class LegacyQueryTest {
*/
@BeforeClass
public static void configure() {
- System.setProperty("AJSC_HOME", "./src/test/resources/");
- System.setProperty("BUNDLECONFIG_DIR", "bundleconfig-local");
+ System.setProperty("AJSC_HOME", ".");
+ System.setProperty("BUNDLECONFIG_DIR", "src/test/resources/bundleconfig-local");
}
/**
@@ -104,11 +107,15 @@ public class LegacyQueryTest {
String expected =
".has('hostname', 'key1').has('aai-node-type', 'pserver')"
- + ".in('tosca.relationships.BindsTo').has('aai-node-type', 'lag-interface')"
+ + ".out('hasLAGInterface').has('aai-node-type', 'lag-interface')"
+ ".has('interface-name', 'key2')";
String parentExpected =
".has('hostname', 'key1').has('aai-node-type', 'pserver')";
assertEquals(
+ "gremlin query should be for node",
+ expected,
+ query.getQueryBuilder().getQuery());
+ assertEquals(
"parent gremlin query should be for parent",
parentExpected,
query.getQueryBuilder().getParentQuery().getQuery());
@@ -117,5 +124,43 @@ public class LegacyQueryTest {
"lag-interface",
query.getResultType());
}
-
+
+ /**
+ * Naming exceptions.
+ *
+ * @throws JAXBException the JAXB exception
+ * @throws UnsupportedEncodingException the unsupported encoding exception
+ * @throws AAIException the AAI exception
+ */
+ @Ignore
+ @Test
+ public void namingExceptions() throws JAXBException, UnsupportedEncodingException, AAIException {
+ URI uri = UriBuilder.fromPath("network/vces/vce/key1/port-groups/port-group/key2/cvlan-tags/cvlan-tag/655").build();
+
+ QueryParser query = dbEngine.getQueryBuilder().createQueryFromURI(uri);
+ String expected =
+ ".has('vnf-id', 'key1').has('aai-node-type', 'vce')"
+ + ".in('org.onap.relationships.inventory.BelongsTo').has('aai-node-type', 'port-group')"
+ + ".has('interface-id', 'key2')"
+ + ".in('org.onap.relationships.inventory.BelongsTo').has('aai-node-type', 'cvlan-tag')"
+ + ".has('cvlan-tag', 655)";
+ String expectedParent =
+ ".has('vnf-id', 'key1').has('aai-node-type', 'vce')"
+ + ".in('org.onap.relationships.inventory.BelongsTo').has('aai-node-type', 'port-group')"
+ + ".has('interface-id', 'key2')";
+ assertEquals(
+ "gremlin query should be " + expected,
+ expected,
+ query.getQueryBuilder().getQuery());
+ assertEquals(
+ "parent gremlin query should be equal the query for port group",
+ expectedParent,
+ query.getQueryBuilder().getParentQuery().getQuery());
+ assertEquals(
+ "result type should be cvlan-tag",
+ "cvlan-tag",
+ query.getResultType());
+
+ }
+
}
diff --git a/aai-core/src/test/java/org/openecomp/aai/parsers/query/RelationshipGremlinQueryTest.java b/aai-core/src/test/java/org/openecomp/aai/parsers/query/RelationshipGremlinQueryTest.java
index 12a689f4..b3385e32 100644
--- a/aai-core/src/test/java/org/openecomp/aai/parsers/query/RelationshipGremlinQueryTest.java
+++ b/aai-core/src/test/java/org/openecomp/aai/parsers/query/RelationshipGremlinQueryTest.java
@@ -69,8 +69,8 @@ public class RelationshipGremlinQueryTest {
*/
@BeforeClass
public static void configure() {
- System.setProperty("AJSC_HOME", "./src/test/resources/");
- System.setProperty("BUNDLECONFIG_DIR", "bundleconfig-local");
+ System.setProperty("AJSC_HOME", ".");
+ System.setProperty("BUNDLECONFIG_DIR", "src/test/resources/bundleconfig-local");
}
diff --git a/aai-core/src/test/java/org/openecomp/aai/parsers/query/RelationshipQueryTest.java b/aai-core/src/test/java/org/openecomp/aai/parsers/query/RelationshipQueryTest.java
index 82378577..807c750f 100644
--- a/aai-core/src/test/java/org/openecomp/aai/parsers/query/RelationshipQueryTest.java
+++ b/aai-core/src/test/java/org/openecomp/aai/parsers/query/RelationshipQueryTest.java
@@ -62,8 +62,8 @@ public class RelationshipQueryTest {
*/
@BeforeClass
public static void configure() {
- System.setProperty("AJSC_HOME", "./src/test/resources/");
- System.setProperty("BUNDLECONFIG_DIR", "bundleconfig-local");
+ System.setProperty("AJSC_HOME", ".");
+ System.setProperty("BUNDLECONFIG_DIR", "src/test/resources/bundleconfig-local");
}
@@ -171,8 +171,8 @@ public class RelationshipQueryTest {
* @throws UnsupportedEncodingException the unsupported encoding exception
* @throws AAIException the AAI exception
*/
- @Test
@Ignore
+ @Test
public void namingExceptions() throws JAXBException, UnsupportedEncodingException, AAIException {
String content =
"{"
diff --git a/aai-core/src/test/java/org/openecomp/aai/parsers/query/UniqueRelationshipQueryTest.java b/aai-core/src/test/java/org/openecomp/aai/parsers/query/UniqueRelationshipQueryTest.java
index b8dbc2a9..50bbbd0e 100644
--- a/aai-core/src/test/java/org/openecomp/aai/parsers/query/UniqueRelationshipQueryTest.java
+++ b/aai-core/src/test/java/org/openecomp/aai/parsers/query/UniqueRelationshipQueryTest.java
@@ -20,6 +20,15 @@
package org.openecomp.aai.parsers.query;
+import static org.junit.Assert.assertEquals;
+
+import java.io.StringReader;
+import java.io.UnsupportedEncodingException;
+
+import javax.xml.bind.JAXBException;
+import javax.xml.bind.Unmarshaller;
+import javax.xml.transform.stream.StreamSource;
+
import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversal;
import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.__;
import org.apache.tinkerpop.gremlin.structure.Vertex;
@@ -30,25 +39,22 @@ import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Ignore;
import org.junit.Test;
+
import org.openecomp.aai.exceptions.AAIException;
-import org.openecomp.aai.introspection.*;
+import org.openecomp.aai.introspection.Introspector;
+import org.openecomp.aai.introspection.IntrospectorFactory;
+import org.openecomp.aai.introspection.LoaderFactory;
+import org.openecomp.aai.introspection.ModelInjestor;
+import org.openecomp.aai.introspection.ModelType;
+import org.openecomp.aai.introspection.Version;
import org.openecomp.aai.serialization.engines.QueryStyle;
import org.openecomp.aai.serialization.engines.TitanDBEngine;
import org.openecomp.aai.serialization.engines.TransactionalGraphEngine;
-
-import javax.xml.bind.JAXBException;
-import javax.xml.bind.Unmarshaller;
-import javax.xml.transform.stream.StreamSource;
-import java.io.StringReader;
-import java.io.UnsupportedEncodingException;
-
-import static org.junit.Assert.assertEquals;
-
@Ignore
public class UniqueRelationshipQueryTest {
private ModelInjestor injestor = ModelInjestor.getInstance();
- private TransactionalGraphEngine dbEngine =
- new TitanDBEngine(QueryStyle.GREMLIN_UNIQUE,
+ private TransactionalGraphEngine dbEngine =
+ new TitanDBEngine(QueryStyle.GREMLIN_UNIQUE,
LoaderFactory.createLoaderForVersion(ModelType.MOXY, Version.v8),
false);
private final Version version = Version.v8;
diff --git a/aai-core/src/test/java/org/openecomp/aai/parsers/relationship/RelationshipToURITest.java b/aai-core/src/test/java/org/openecomp/aai/parsers/relationship/RelationshipToURITest.java
index a676b9bd..185814b8 100644
--- a/aai-core/src/test/java/org/openecomp/aai/parsers/relationship/RelationshipToURITest.java
+++ b/aai-core/src/test/java/org/openecomp/aai/parsers/relationship/RelationshipToURITest.java
@@ -59,8 +59,8 @@ public class RelationshipToURITest {
@BeforeClass
public static void setup() throws NoSuchFieldException, SecurityException, Exception {
- System.setProperty("AJSC_HOME", "./src/test/resources/");
- System.setProperty("BUNDLECONFIG_DIR", "bundleconfig-local");
+ System.setProperty("AJSC_HOME", ".");
+ System.setProperty("BUNDLECONFIG_DIR", "src/test/resources/bundleconfig-local");
QueryFormatTestHelper.setFinalStatic(AAIConstants.class.getField("AAI_HOME_ETC_OXM"), "src/test/resources/org/openecomp/aai/introspection/");
}
diff --git a/aai-core/src/test/java/org/openecomp/aai/parsers/uri/URIParserTest.java b/aai-core/src/test/java/org/openecomp/aai/parsers/uri/URIParserTest.java
index c2312b2b..899119ee 100644
--- a/aai-core/src/test/java/org/openecomp/aai/parsers/uri/URIParserTest.java
+++ b/aai-core/src/test/java/org/openecomp/aai/parsers/uri/URIParserTest.java
@@ -53,8 +53,8 @@ public class URIParserTest {
*/
@BeforeClass
public static void configure() {
- System.setProperty("AJSC_HOME", "./src/test/resources/");
- System.setProperty("BUNDLECONFIG_DIR", "bundleconfig-local");
+ System.setProperty("AJSC_HOME", ".");
+ System.setProperty("BUNDLECONFIG_DIR", "src/test/resources/bundleconfig-local");
}
/**
diff --git a/aai-core/src/test/java/org/openecomp/aai/parsers/uri/URIToExtensionInformationTest.java b/aai-core/src/test/java/org/openecomp/aai/parsers/uri/URIToExtensionInformationTest.java
index 52c44c12..bc586b86 100644
--- a/aai-core/src/test/java/org/openecomp/aai/parsers/uri/URIToExtensionInformationTest.java
+++ b/aai-core/src/test/java/org/openecomp/aai/parsers/uri/URIToExtensionInformationTest.java
@@ -48,8 +48,8 @@ public class URIToExtensionInformationTest {
*/
@BeforeClass
public static void configure() {
- System.setProperty("AJSC_HOME", "./src/test/resources/");
- System.setProperty("BUNDLECONFIG_DIR", "bundleconfig-local");
+ System.setProperty("AJSC_HOME", ".");
+ System.setProperty("BUNDLECONFIG_DIR", "src/test/resources/bundleconfig-local");
}
/**
diff --git a/aai-core/src/test/java/org/openecomp/aai/parsers/uri/URIToObjectTest.java b/aai-core/src/test/java/org/openecomp/aai/parsers/uri/URIToObjectTest.java
index 3750e473..7cdcfc56 100644
--- a/aai-core/src/test/java/org/openecomp/aai/parsers/uri/URIToObjectTest.java
+++ b/aai-core/src/test/java/org/openecomp/aai/parsers/uri/URIToObjectTest.java
@@ -61,8 +61,8 @@ public class URIToObjectTest {
*/
@BeforeClass
public static void configure() {
- System.setProperty("AJSC_HOME", "./src/test/resources/");
- System.setProperty("BUNDLECONFIG_DIR", "bundleconfig-local");
+ System.setProperty("AJSC_HOME", ".");
+ System.setProperty("BUNDLECONFIG_DIR", "src/test/resources/bundleconfig-local");
}
diff --git a/aai-core/src/test/java/org/openecomp/aai/parsers/uri/URIToRelationshipObjectTest.java b/aai-core/src/test/java/org/openecomp/aai/parsers/uri/URIToRelationshipObjectTest.java
index 1c945ee7..ed278243 100644
--- a/aai-core/src/test/java/org/openecomp/aai/parsers/uri/URIToRelationshipObjectTest.java
+++ b/aai-core/src/test/java/org/openecomp/aai/parsers/uri/URIToRelationshipObjectTest.java
@@ -33,6 +33,7 @@ import javax.ws.rs.core.UriBuilder;
import javax.xml.bind.JAXBException;
import org.junit.BeforeClass;
+import org.junit.Ignore;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;
@@ -45,7 +46,7 @@ import org.openecomp.aai.introspection.LoaderFactory;
import org.openecomp.aai.introspection.ModelType;
import org.openecomp.aai.introspection.Version;
-
+@Ignore
public class URIToRelationshipObjectTest {
private Version latest = AAIProperties.LATEST;
@@ -59,8 +60,8 @@ public class URIToRelationshipObjectTest {
*/
@BeforeClass
public static void configure() {
- System.setProperty("AJSC_HOME", "./src/test/resources/");
- System.setProperty("BUNDLECONFIG_DIR", "bundleconfig-local");
+ System.setProperty("AJSC_HOME", ".");
+ System.setProperty("BUNDLECONFIG_DIR", "src/test/resources/bundleconfig-local");
}
/**
diff --git a/aai-core/src/test/java/org/openecomp/aai/query/builder/TraversalQueryTest.java b/aai-core/src/test/java/org/openecomp/aai/query/builder/TraversalQueryTest.java
index a9d2c001..eae1c970 100644
--- a/aai-core/src/test/java/org/openecomp/aai/query/builder/TraversalQueryTest.java
+++ b/aai-core/src/test/java/org/openecomp/aai/query/builder/TraversalQueryTest.java
@@ -50,17 +50,17 @@ public class TraversalQueryTest {
@BeforeClass
public static void configure() throws NoSuchFieldException, SecurityException, Exception {
- System.setProperty("AJSC_HOME", "./src/test/resources/");
- System.setProperty("BUNDLECONFIG_DIR", "bundleconfig-local");
+ System.setProperty("AJSC_HOME", ".");
+ System.setProperty("BUNDLECONFIG_DIR", "src/test/resources/bundleconfig-local");
QueryFormatTestHelper.setFinalStatic(AAIConstants.class.getField("AAI_HOME_ETC_OXM"), "src/test/resources/org/openecomp/aai/introspection/");
loader = LoaderFactory.createLoaderForVersion(ModelType.MOXY, AAIProperties.LATEST);
}
@Test
public void unionQuery() {
- TraversalQuery tQ = new TraversalQuery(loader, g);
- TraversalQuery tQ2 = new TraversalQuery(loader, g);
- TraversalQuery tQ3 = new TraversalQuery(loader, g);
+ TraversalQuery<Vertex> tQ = new TraversalQuery<>(loader, g);
+ TraversalQuery<Vertex> tQ2 = new TraversalQuery<>(loader, g);
+ TraversalQuery<Vertex> tQ3 = new TraversalQuery<>(loader, g);
tQ.union(
tQ2.getVerticesByProperty("test1", "value1"),
tQ3.getVerticesByIndexedProperty("test2", "value2"));
@@ -74,9 +74,8 @@ public class TraversalQueryTest {
@Test
public void traversalClones() throws UnsupportedEncodingException, AAIException, URISyntaxException {
- TraversalQuery tQ = new TraversalQuery(loader, g);
- Introspector test = loader.introspectorFromName("test-object");
- QueryBuilder builder = tQ.createQueryFromURI(new URI("network/test-objects/test-object/key1")).getQueryBuilder();
+ TraversalQuery<Vertex> tQ = new TraversalQuery<>(loader, g);
+ QueryBuilder<Vertex> builder = tQ.createQueryFromURI(new URI("network/test-objects/test-object/key1")).getQueryBuilder();
GraphTraversal<Vertex, Vertex> expected = __.<Vertex>start().has("vnf-id", "key1").has("aai-node-type", "test-object");
GraphTraversal<Vertex, Vertex> containerExpected = __.<Vertex>start().has("aai-node-type", "test-object");
@@ -88,8 +87,8 @@ public class TraversalQueryTest {
@Test
public void nestedTraversalClones() throws UnsupportedEncodingException, AAIException, URISyntaxException {
- TraversalQuery tQ = new TraversalQuery(loader, g);
- QueryBuilder builder = tQ.createQueryFromURI(new URI("network/generic-vnfs/generic-vnf/key1/l-interfaces/l-interface/key2")).getQueryBuilder();
+ TraversalQuery<Vertex> tQ = new TraversalQuery<>(loader, g);
+ QueryBuilder<Vertex> builder = tQ.createQueryFromURI(new URI("network/generic-vnfs/generic-vnf/key1/l-interfaces/l-interface/key2")).getQueryBuilder();
GraphTraversal<Vertex, Vertex> expected = __.<Vertex>start().has("vnf-id", "key1").has("aai-node-type", "generic-vnf").out("hasLInterface").has(AAIProperties.NODE_TYPE, "l-interface").has("interface-name", "key2");
GraphTraversal<Vertex, Vertex> containerExpected = __.<Vertex>start().has("vnf-id", "key1").has("aai-node-type", "generic-vnf").out("hasLInterface").has(AAIProperties.NODE_TYPE, "l-interface");
diff --git a/aai-core/src/test/java/org/openecomp/aai/serialization/db/DbAliasTest.java b/aai-core/src/test/java/org/openecomp/aai/serialization/db/DbAliasTest.java
index 10586fb4..78e91109 100644
--- a/aai-core/src/test/java/org/openecomp/aai/serialization/db/DbAliasTest.java
+++ b/aai-core/src/test/java/org/openecomp/aai/serialization/db/DbAliasTest.java
@@ -56,7 +56,7 @@ import com.thinkaurelius.titan.core.TitanTransaction;
import java.util.Collections;
-@Ignore("Causing problems when only parallel tests are run")
+@Ignore
public class DbAliasTest {
@@ -71,8 +71,8 @@ public class DbAliasTest {
@Before
public void setup() throws NoSuchFieldException, SecurityException, Exception {
graph = TitanFactory.build().set("storage.backend","inmemory").open();
- System.setProperty("AJSC_HOME", "./src/test/resources/");
- System.setProperty("BUNDLECONFIG_DIR", "bundleconfig-local");
+ System.setProperty("AJSC_HOME", ".");
+ System.setProperty("BUNDLECONFIG_DIR", "src/test/resources/bundleconfig-local");
loader = LoaderFactory.createLoaderForVersion(introspectorFactoryType, version);
dbEngine = new TitanDBEngine(
queryStyle,
diff --git a/aai-core/src/test/java/org/openecomp/aai/workarounds/RemoveDME2QueryParamsTest.java b/aai-core/src/test/java/org/openecomp/aai/workarounds/RemoveDME2QueryParamsTest.java
new file mode 100644
index 00000000..61ba275d
--- /dev/null
+++ b/aai-core/src/test/java/org/openecomp/aai/workarounds/RemoveDME2QueryParamsTest.java
@@ -0,0 +1,91 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * org.openecomp.aai
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.aai.workarounds;
+
+import static org.junit.Assert.*;
+
+import javax.ws.rs.core.MultivaluedHashMap;
+import javax.ws.rs.core.MultivaluedMap;
+
+import org.junit.Before;
+import org.junit.Test;
+
+public class RemoveDME2QueryParamsTest {
+
+ private MultivaluedMap<String, String> hasParams;
+ private MultivaluedMap<String, String> doesNotHaveParams;
+ private RemoveDME2QueryParams removeParams = new RemoveDME2QueryParams();
+
+ /**
+ * Setup.
+ */
+ @Before
+ public void setup() {
+ hasParams = new MultivaluedHashMap<>();
+ doesNotHaveParams = new MultivaluedHashMap<>();
+
+ hasParams.add("version", "1");
+ hasParams.add("envContext", "DEV");
+ hasParams.add("routeOffer", "INT1");
+ hasParams.add("test1", "peppermints");
+ hasParams.add("test2", "amber");
+
+ doesNotHaveParams.add("version", "1");
+ doesNotHaveParams.add("envContext", "DEV");
+ doesNotHaveParams.add("test1", "peppermints");
+ doesNotHaveParams.add("test2", "amber");
+
+ }
+
+ /**
+ * Test removal.
+ */
+ @Test
+ public void testRemoval() {
+
+ if (removeParams.shouldRemoveQueryParams(hasParams)) {
+ removeParams.removeQueryParams(hasParams);
+ }
+
+ assertEquals("no version", false, hasParams.containsKey("version"));
+ assertEquals("no envContext", false, hasParams.containsKey("envContext"));
+ assertEquals("no routeOffer", false, hasParams.containsKey("routeOffer"));
+ assertEquals("has test1", true, hasParams.containsKey("test1"));
+ assertEquals("has test2", true, hasParams.containsKey("test2"));
+
+ }
+
+ /**
+ * Should not remove.
+ */
+ @Test
+ public void shouldNotRemove() {
+
+ if (removeParams.shouldRemoveQueryParams(doesNotHaveParams)) {
+ removeParams.removeQueryParams(doesNotHaveParams);
+ }
+
+ assertEquals("no version", true, doesNotHaveParams.containsKey("version"));
+ assertEquals("no envContext", true, doesNotHaveParams.containsKey("envContext"));
+ assertEquals("has test1", true, doesNotHaveParams.containsKey("test1"));
+ assertEquals("has test2", true, doesNotHaveParams.containsKey("test2"));
+ }
+}
diff --git a/aai-core/src/test/resources/bundleconfig-local/etc/appprops/error.properties b/aai-core/src/test/resources/bundleconfig-local/etc/appprops/error.properties
index 4e98d62c..11416ca4 100644
--- a/aai-core/src/test/resources/bundleconfig-local/etc/appprops/error.properties
+++ b/aai-core/src/test/resources/bundleconfig-local/etc/appprops/error.properties
@@ -110,6 +110,7 @@ AAI_6142=5:4:INFO:6142:400:3000:Retrying transaction
AAI_6143=5:4:INFO:6143:400:3000:Ghost vertex found
AAI_6144=5:4:WARN:6144:400:3000:Cycle found in graph
AAI_6145=5:4:ERROR:6145:400:3000:Cannot create a nested/containment edge via relationship
+AAI_6146=5:4:ERROR:6146:400:3000:Ambiguous identity map found, use a URI instead
#--- aaicsvp: 7101-7199
AAI_7101=5:4:ERROR:7101:500:3002:Unexpected error in CSV file processing
diff --git a/aai-core/src/test/resources/bundleconfig-local/etc/oxm/aai_oxm_v10.xml b/aai-core/src/test/resources/bundleconfig-local/etc/oxm/aai_oxm_v10.xml
index 9c3c5e87..af05d3d9 100644
--- a/aai-core/src/test/resources/bundleconfig-local/etc/oxm/aai_oxm_v10.xml
+++ b/aai-core/src/test/resources/bundleconfig-local/etc/oxm/aai_oxm_v10.xml
@@ -5048,7 +5048,7 @@
</xml-element>
<xml-element java-attribute="ikev1Encryption" name="ikev1-encryption" type="java.lang.String">
<xml-properties>
- <xml-property name="description" value="Encyption values like 3des-cbc, des-cbc, aes-128-cbc, aes-192-cbc, aes-265-cbc" />
+ <xml-property name="description" value="Encyption values like 3des-cbc, des-cbc, aes-128-cbc,? aes-192-cbc, aes-265-cbc" />
<xml-property name="sourceOfTruthType" value="aai" />
</xml-properties>
</xml-element>
@@ -5084,7 +5084,7 @@
</xml-element>
<xml-element java-attribute="ipsecEncryption" name="ipsec-encryption" type="java.lang.String">
<xml-properties>
- <xml-property name="description" value="3des-cbc, des-cbc, aes-128-cbc, aes-192-cbc, aes-265-cbc" />
+ <xml-property name="description" value="3des-cbc, des-cbc, aes-128-cbc,? aes-192-cbc, aes-265-cbc" />
<xml-property name="sourceOfTruthType" value="aai" />
</xml-properties>
</xml-element>
@@ -6405,7 +6405,7 @@
</xml-element>
<xml-element java-attribute="designType" name="design-type" required="true" type="java.lang.String">
<xml-properties>
- <xml-property name="description" value="Design of zone [Medium/Large…]" />
+ <xml-property name="description" value="Design of zone [Medium/Large?]" />
<xml-property name="sourceOfTruthType" value="aai" />
</xml-properties>
</xml-element>
diff --git a/aai-core/src/test/resources/bundleconfig-local/etc/oxm/aai_oxm_v9.xml b/aai-core/src/test/resources/bundleconfig-local/etc/oxm/aai_oxm_v9.xml
index ea77e8e5..dab82440 100644
--- a/aai-core/src/test/resources/bundleconfig-local/etc/oxm/aai_oxm_v9.xml
+++ b/aai-core/src/test/resources/bundleconfig-local/etc/oxm/aai_oxm_v9.xml
@@ -4342,7 +4342,7 @@
</xml-element>
<xml-element java-attribute="ikev1Encryption" name="ikev1-encryption" type="java.lang.String">
<xml-properties>
- <xml-property name="description" value="Encyption values like 3des-cbc, des-cbc, aes-128-cbc, aes-192-cbc, aes-265-cbc" />
+ <xml-property name="description" value="Encyption values like 3des-cbc, des-cbc, aes-128-cbc,?aes-192-cbc, aes-265-cbc" />
</xml-properties>
</xml-element>
<xml-element java-attribute="ikev1DhGroup" name="ikev1-dh-group" type="java.lang.String">
@@ -4372,7 +4372,7 @@
</xml-element>
<xml-element java-attribute="ipsecEncryption" name="ipsec-encryption" type="java.lang.String">
<xml-properties>
- <xml-property name="description" value="3des-cbc, des-cbc, aes-128-cbc, aes-192-cbc, aes-265-cbc" />
+ <xml-property name="description" value="3des-cbc, des-cbc, aes-128-cbc,?aes-192-cbc, aes-265-cbc" />
</xml-properties>
</xml-element>
<xml-element java-attribute="ipsecSaLifetime" name="ipsec-sa-lifetime" type="java.lang.String">
@@ -5417,7 +5417,7 @@
</xml-element>
<xml-element java-attribute="designType" name="design-type" required="true" type="java.lang.String">
<xml-properties>
- <xml-property name="description" value="Design of zone [Medium/Large…]" />
+ <xml-property name="description" value="Design of zone [Medium/Large?]" />
</xml-properties>
</xml-element>
<xml-element java-attribute="zoneContext" name="zone-context" required="true" type="java.lang.String">
diff --git a/aai-core/src/test/resources/bundleconfig-local/etc/scriptdata/dependencies/vRouterServiceInstanceFile.txt b/aai-core/src/test/resources/bundleconfig-local/etc/scriptdata/dependencies/vRouterServiceInstanceFile.txt
new file mode 100644
index 00000000..a5be7911
--- /dev/null
+++ b/aai-core/src/test/resources/bundleconfig-local/etc/scriptdata/dependencies/vRouterServiceInstanceFile.txt
@@ -0,0 +1,6 @@
+vnf-id,service-instance-id,global-customer-id
+vnf-id1,sample-service-instance-id,customer-id1
+vnf-id2,sample-service-instance-id-1,customer-id1
+vnf-id3,sample-service-instance-id-2,customer-id2
+vnf-id5,sample-service-instance-id-3,customer-id3
+vnf-id6,sample-service-instance-id-4,customer-id4
diff --git a/aai-core/src/test/resources/log4j.properties b/aai-core/src/test/resources/log4j.properties
new file mode 100644
index 00000000..2e68f61a
--- /dev/null
+++ b/aai-core/src/test/resources/log4j.properties
@@ -0,0 +1,3 @@
+log4j.logger.org.apache.zookeeper=WARN
+log4j.logger.org.apache.hadoop.hbase.zookeeper=WARN
+log4j.logger.org.apache.hadoop.hbase.client=WARN \ No newline at end of file
diff --git a/aai-core/src/test/resources/logback.xml b/aai-core/src/test/resources/logback.xml
new file mode 100644
index 00000000..d9627b22
--- /dev/null
+++ b/aai-core/src/test/resources/logback.xml
@@ -0,0 +1,292 @@
+<!--
+ ============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=========================================================
+ -->
+
+<configuration scan="true" scanPeriod="60 seconds" debug="false">
+ <contextName>${module.ajsc.namespace.name}</contextName>
+ <jmxConfigurator />
+ <property name="logDirectory" value="${AJSC_HOME}/logs" />
+
+ <!-- Example evaluator filter applied against console appender -->
+ <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
+ <filter class="ch.qos.logback.classic.filter.LevelFilter">
+ <!-- <filter class="ch.qos.logback.classic.filter.ThresholdFilter"> -->
+ <level>ERROR</level>
+ <onMatch>ACCEPT</onMatch>
+ <onMismatch>DENY</onMismatch>
+ </filter>
+ <encoder>
+ <pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{1024} - %msg%n
+ </pattern>
+ </encoder>
+ </appender>
+
+ <appender name="METRIC"
+ class="ch.qos.logback.core.rolling.RollingFileAppender">
+ <filter class="ch.qos.logback.classic.filter.LevelFilter">
+ <level>INFO</level>
+ <onMatch>ACCEPT</onMatch>
+ <onMismatch>DENY</onMismatch>
+ </filter>
+ <file>${logDirectory}/rest/metric.log</file>
+ <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
+ <fileNamePattern>${logDirectory}/rest/metric.log.%d{yyyy-MM-dd}</fileNamePattern>
+ </rollingPolicy>
+ <!-- <triggeringPolicy
+ class="ch.qos.logback.core.rolling.SizeBasedTriggeringPolicy">
+ <maxFileSize>5MB</maxFileSize>
+ </triggeringPolicy> -->
+ <encoder>
+ <pattern>%d{yyyy-MM-dd'T'HH:mm:ss.SSSXXX}|%m%n</pattern>
+ </encoder>
+ </appender>
+
+ <appender name="DEBUG"
+ class="ch.qos.logback.core.rolling.RollingFileAppender">
+ <filter class="ch.qos.logback.classic.filter.ThresholdFilter">
+ <level>DEBUG</level>
+ <onMatch>ACCEPT</onMatch>
+ <onMismatch>DENY</onMismatch>
+ </filter>
+ <file>${logDirectory}/rest/debug.log</file>
+ <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
+ <fileNamePattern>${logDirectory}/rest/debug.log.%d{yyyy-MM-dd}</fileNamePattern>
+ </rollingPolicy>
+ <!-- <triggeringPolicy
+ class="ch.qos.logback.core.rolling.SizeBasedTriggeringPolicy">
+ <maxFileSize>5MB</maxFileSize>
+ </triggeringPolicy>-->
+ <encoder>
+ <pattern>%d{yyyy-MM-dd'T'HH:mm:ss.SSSXXX}|%m%n</pattern>
+ </encoder>
+ </appender>
+
+ <appender name="ERROR"
+ class="ch.qos.logback.core.rolling.RollingFileAppender">
+ <filter class="ch.qos.logback.classic.filter.ThresholdFilter">
+ <level>WARN</level>
+ <onMatch>ACCEPT</onMatch>
+ <onMismatch>DENY</onMismatch>
+ </filter>
+ <file>${logDirectory}/rest/error.log</file>
+ <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
+ <fileNamePattern>${logDirectory}/rest/error.log.%d{yyyy-MM-dd}</fileNamePattern>
+ </rollingPolicy>
+ <!-- <triggeringPolicy
+ class="ch.qos.logback.core.rolling.SizeBasedTriggeringPolicy">
+ <maxFileSize>5MB</maxFileSize>
+ </triggeringPolicy>-->
+ <encoder>
+ <!-- <pattern>"%d{HH:mm:ss.SSS} [%thread] %-5level %logger{1024} - %msg%n"</pattern> -->
+ <pattern>%d{yyyy-MM-dd'T'HH:mm:ss.SSSXXX}|%m%n</pattern>
+ </encoder>
+ </appender>
+
+ <appender name="AUDIT"
+ class="ch.qos.logback.core.rolling.RollingFileAppender">
+ <filter class="ch.qos.logback.core.filter.EvaluatorFilter">
+ <evaluator>
+ <matcher>
+ <Name>audit</Name>
+ <!-- filter out odd numbered statements -->
+ <regex>co\=aairest</regex>
+ </matcher>
+ <expression>level == INFO &amp;&amp; audit.matches(formattedMessage)</expression>
+ </evaluator>
+ <OnMatch>ACCEPT</OnMatch>
+ <OnMismatch>DENY</OnMismatch>
+ </filter>
+ <file>${logDirectory}/rest/audit.log</file>
+ <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
+ <fileNamePattern>${logDirectory}/rest/metric.log.%d{yyyy-MM-dd}</fileNamePattern>
+ </rollingPolicy>
+ <encoder>
+ <pattern>%d{yyyy-MM-dd'T'HH:mm:ss.SSSXXX}|%m%n</pattern>
+ </encoder>
+ </appender>
+
+ <appender name="auditLogs"
+ class="ch.qos.logback.core.rolling.RollingFileAppender">
+ <filter class="ch.qos.logback.classic.filter.ThresholdFilter">
+ </filter>
+ <file>${logDirectory}/rest/audit.log</file>
+ <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
+ <fileNamePattern>${logDirectory}/rest/audit-${Pid}.%d{yyyy-MM-dd}.log.zip
+ </fileNamePattern>
+ </rollingPolicy>
+ <triggeringPolicy
+ class="ch.qos.logback.core.rolling.SizeBasedTriggeringPolicy">
+ <maxFileSize>5MB</maxFileSize>
+ </triggeringPolicy>
+ <encoder>
+ <pattern>"%d [%thread] %-5level %logger{1024} - %msg%n"</pattern>
+ </encoder>
+ </appender>
+
+ <appender name="perfLogs"
+ class="ch.qos.logback.core.rolling.RollingFileAppender">
+ <filter class="ch.qos.logback.classic.filter.ThresholdFilter">
+ </filter>
+ <file>${logDirectory}/rest/perform.log</file>
+ <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
+ <fileNamePattern>${logDirectory}/rest/perform-${Pid}.%d{yyyy-MM-dd}.log.zip
+ </fileNamePattern>
+ </rollingPolicy>
+ <!-- <triggeringPolicy
+ class="ch.qos.logback.core.rolling.SizeBasedTriggeringPolicy">
+ <maxFileSize>5MB</maxFileSize>
+ </triggeringPolicy> -->
+ <encoder>
+ <pattern>"%d [%thread] %-5level %logger{1024} - %msg%n"</pattern>
+ </encoder>
+ </appender>
+
+ <!-- Spring related loggers -->
+ <logger name="org.springframework" level="WARN" />
+ <logger name="org.springframework.beans" level="WARN" />
+ <logger name="org.springframework.web" level="WARN" />
+ <logger name="com.blog.spring.jms" level="WARN" />
+
+ <!-- AJSC Services (bootstrap services) -->
+ <logger name="ajsc" level="WARN" />
+ <logger name="ajsc.RouteMgmtService" level="WARN" />
+ <logger name="ajsc.ComputeService" level="WARN" />
+ <logger name="ajsc.VandelayService" level="WARN" />
+ <logger name="ajsc.FilePersistenceService" level="WARN" />
+ <logger name="ajsc.UserDefinedJarService" level="WARN" />
+ <logger name="ajsc.UserDefinedBeansDefService" level="WARN" />
+ <logger name="ajsc.LoggingConfigurationService" level="WARN" />
+
+ <!-- AJSC related loggers (DME2 Registration, csi logging, restlet, servlet
+ logging) -->
+ <logger name="ajsc.utils" level="WARN" />
+ <logger name="ajsc.utils.DME2Helper" level="WARN" />
+ <logger name="ajsc.filters" level="WARN" />
+ <logger name="ajsc.beans.interceptors" level="WARN" />
+ <logger name="ajsc.restlet" level="WARN" />
+ <logger name="ajsc.servlet" level="WARN" />
+ <logger name="com.att.ajsc" level="WARN" />
+ <logger name="com.att.ajsc.csi.logging" level="WARN" />
+ <logger name="com.att.ajsc.filemonitor" level="WARN" />
+
+ <!-- Other Loggers that may help troubleshoot -->
+ <logger name="net.sf" level="WARN" />
+ <logger name="org.apache.commons.httpclient" level="WARN" />
+ <logger name="org.apache.commons" level="WARN" />
+ <logger name="org.apache.coyote" level="WARN" />
+ <logger name="org.apache.jasper" level="WARN" />
+
+ <!-- Camel Related Loggers (including restlet/servlet/jaxrs/cxf logging.
+ May aid in troubleshooting) -->
+ <logger name="org.apache.camel" level="WARN" />
+ <logger name="org.apache.cxf" level="WARN" />
+ <logger name="org.apache.camel.processor.interceptor" level="WARN" />
+ <logger name="org.apache.cxf.jaxrs.interceptor" level="WARN" />
+ <logger name="org.apache.cxf.service" level="WARN" />
+ <logger name="org.restlet" level="WARN" />
+ <logger name="org.apache.camel.component.restlet" level="WARN" />
+
+ <!-- logback internals logging -->
+ <logger name="ch.qos.logback.classic" level="INFO" />
+ <logger name="ch.qos.logback.core" level="INFO" />
+
+ <!-- logback jms appenders & loggers definition starts here -->
+
+ <if condition='property("JMS_BROKER").contains("WMQ")'>
+ <then>
+ <appender name="Audit-Record-Queue" class="ajsc.JMSQueueAppender">
+ <param name="InitialContextFactoryName" value="${JMS_WMQ_INITIAL_CONNECTION_FACTORY_NAME}" />
+ <param name="ProviderURL" value="${JMS_WMQ_PROVIDER_URL}" />
+ <param name="DestinationName" value="${JMS_WMQ_AUDIT_DESTINATION_NAME}" />
+ <param name="ConnectionFactoryName" value="${JMS_WMQ_CONNECTION_FACTORY_NAME}" />
+ </appender>
+ <appender name="Performance-Tracker-Queue" class="ajsc.JMSQueueAppender">
+ <param name="InitialContextFactoryName" value="${JMS_WMQ_INITIAL_CONNECTION_FACTORY_NAME}" />
+ <param name="ProviderURL" value="${JMS_WMQ_PROVIDER_URL}" />
+ <param name="DestinationName" value="${JMS_WMQ_PERF_DESTINATION_NAME}" />
+ <param name="ConnectionFactoryName" value="${JMS_WMQ_CONNECTION_FACTORY_NAME}" />
+ </appender>
+ </then>
+ <else> <!-- logback jms appenders definition starts here -->
+ <appender name="Audit-Record-Queue" class="ajsc.JMSQueueAppender">
+ <param name="InitialContextFactoryName"
+ value="com.tibco.tibjms.naming.TibjmsInitialContextFactory" />
+ <param name="ProviderURL" value="${JMS_TIBCO_PROVIDER_URL}" />
+ <param name="userName" value="${JMS_LOGGER_USER_NAME}" />
+ <param name="password" value="${JMS_LOGGER_PASSWORD}" />
+ <QueueBindingName>${JMS_LOGGER_AUDIT_QUEUE_BINDING}
+ </QueueBindingName>
+ </appender>
+ <appender name="Performance-Tracker-Queue" class="ajsc.JMSQueueAppender">
+ <param name="InitialContextFactoryName"
+ value="com.tibco.tibjms.naming.TibjmsInitialContextFactory" />
+ <param name="ProviderURL" value="${JMS_TIBCO_PROVIDER_URL}" />
+ <param name="userName" value="${JMS_LOGGER_USER_NAME}" />
+ <param name="password" value="${JMS_LOGGER_PASSWORD}" />
+ <QueueBindingName>${JMS_LOGGER_PERF_QUEUE_BINDING}
+ </QueueBindingName>
+ </appender>
+ </else>
+ </if>
+
+ <appender name="ASYNC-audit" class="ch.qos.logback.classic.AsyncAppender">
+ <queueSize>1000</queueSize>
+ <discardingThreshold>0</discardingThreshold>
+ <appender-ref ref="Audit-Record-Queue" />
+ </appender>
+
+ <appender name="ASYNC-perf" class="ch.qos.logback.classic.AsyncAppender">
+ <queueSize>1000</queueSize>
+ <discardingThreshold>0</discardingThreshold>
+ <appender-ref ref="Performance-Tracker-Queue" />
+ </appender>
+
+ <!--
+ <logger name="AuditRecord" level="INFO" additivity="FALSE">
+ <appender-ref ref="ASYNC-audit" />
+ <appender-ref ref="auditLogs" />
+ </logger>
+ <logger name="AuditRecord_DirectCall" level="INFO" additivity="FALSE">
+ <appender-ref ref="ASYNC-audit" />
+ <appender-ref ref="auditLogs" />
+ </logger>
+ <logger name="PerfTrackerRecord" level="INFO" additivity="FALSE">
+ <appender-ref ref="ASYNC-perf" />
+ <appender-ref ref="perfLogs" />
+ </logger>
+ -->
+
+ <logger name="org.openecomp.aai" level="INFO" />
+
+ <!--
+ <logger name="org.openecomp.aai.util" level="WARN" />
+ <logger name="org.openecomp.aai.rest" level="WARN" />
+ <logger name="org.openecomp.aai.rest.Business" level="WARN" />
+ -->
+
+ <logger name="org.apache" level="WARN" />
+ <logger name="org.zookeeper" level="WARN" />
+ <logger name="com.thinkaurelius" level="WARN" />
+
+ <root level="WARN">
+ <appender-ref ref="DEBUG" />
+ <appender-ref ref="ERROR" />
+ <appender-ref ref="METRIC" />
+ <appender-ref ref="AUDIT" />
+ </root>
+
+</configuration>