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;
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 {
* @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;
* @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 {
* @throws SecurityException the security exception
* @throws AAIException the AAI exception
* @throws UnsupportedEncodingException the unsupported encoding exception
- * @throws AAIUnknownObjectException
+ * @throws AAIUnknownObjectException
*/
/*
* Helper method for reflectToDb
*
* @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());
* @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 {
* @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);
* @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 {
* @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 {
//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();
}
- 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");
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");
* @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 {
* @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 {
* @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) {
/**
* Adds the r
- * @throws AAIUnknownObjectException
+ * @throws AAIUnknownObjectException
* @throws IllegalArgumentException elated to property.
*
* @param relationship the relationship
* @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 {
* @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 {
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)) {
if (!result) {
- throw new AAIException(aaiExceptionCode, errorDetail);
+ throw new AAIException(aaiExceptionCode, errorDetail);
}
return result;
}
aaiExceptionCode = "AAI_6131";
}
- throw new AAIException(aaiExceptionCode, errorDetail);
+ throw new AAIException(aaiExceptionCode, errorDetail);
}
}
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();