summaryrefslogtreecommitdiffstats
path: root/aai-core/src/main
diff options
context:
space:
mode:
authorFiete Ostkamp <Fiete.Ostkamp@telekom.de>2022-11-07 08:35:37 +0000
committerFiete Ostkamp <Fiete.Ostkamp@telekom.de>2022-11-07 08:38:19 +0000
commitfbb02159b84435cf37221ae8ae5e0045167be15a (patch)
tree78196f6a3e5e4d0b1e5ca6ecadec0f9e9a623303 /aai-core/src/main
parent58f0fd2f6ef58de52e1f9a73540c1bb895c0d6e6 (diff)
Reduce the number of problems in aai-common by removing unused imports
- run mvn spotless:apply across aai-commmon to remove unused imports - run mvn formatter:format across aai-common Issue-ID: AAI-3583 Signed-off-by: Fiete Ostkamp <Fiete.Ostkamp@telekom.de> Change-Id: I2dfeb395eafa2824ce8369bba3a18db3e1845522
Diffstat (limited to 'aai-core/src/main')
-rw-r--r--aai-core/src/main/java/org/onap/aai/audit/ListEndpoints.java4
-rw-r--r--aai-core/src/main/java/org/onap/aai/concurrent/AaiCallable.java2
-rw-r--r--aai-core/src/main/java/org/onap/aai/config/XmlFormatTransformerConfiguration.java3
-rw-r--r--aai-core/src/main/java/org/onap/aai/dbgen/GraphSONPartialReader.java5
-rw-r--r--aai-core/src/main/java/org/onap/aai/dbgen/SchemaGenerator.java49
-rw-r--r--aai-core/src/main/java/org/onap/aai/dbgen/SchemaGenerator4Hist.java60
-rw-r--r--aai-core/src/main/java/org/onap/aai/dbmap/AAIGraph.java8
-rw-r--r--aai-core/src/main/java/org/onap/aai/dbmap/AAIGraphConfig.java1
-rw-r--r--aai-core/src/main/java/org/onap/aai/dbmap/InMemoryGraph.java12
-rw-r--r--aai-core/src/main/java/org/onap/aai/dmaap/AAIDmaapEventJMSConsumer.java24
-rw-r--r--aai-core/src/main/java/org/onap/aai/dmaap/MessageProducer.java1
-rw-r--r--aai-core/src/main/java/org/onap/aai/domain/model/AAIResources.java4
-rw-r--r--aai-core/src/main/java/org/onap/aai/domain/notificationEvent/NotificationEvent.java4
-rw-r--r--aai-core/src/main/java/org/onap/aai/domain/responseMessage/AAIResponseMessageData.java3
-rw-r--r--aai-core/src/main/java/org/onap/aai/domain/responseMessage/AAIResponseMessages.java3
-rw-r--r--aai-core/src/main/java/org/onap/aai/domain/translog/TransactionLogEntries.java5
-rw-r--r--aai-core/src/main/java/org/onap/aai/domain/translog/TransactionLogEntry.java4
-rw-r--r--aai-core/src/main/java/org/onap/aai/extensions/ExtensionController.java5
-rw-r--r--aai-core/src/main/java/org/onap/aai/extensions/OrphanLInterfaceHandler.java1
-rw-r--r--aai-core/src/main/java/org/onap/aai/ingestModel/CreateWidgetModels.java1
-rw-r--r--aai-core/src/main/java/org/onap/aai/introspection/Introspector.java9
-rw-r--r--aai-core/src/main/java/org/onap/aai/introspection/IntrospectorWalker.java5
-rw-r--r--aai-core/src/main/java/org/onap/aai/introspection/JSONStrategy.java1
-rw-r--r--aai-core/src/main/java/org/onap/aai/introspection/MoxyLoader.java4
-rw-r--r--aai-core/src/main/java/org/onap/aai/introspection/MoxyStrategy.java6
-rw-r--r--aai-core/src/main/java/org/onap/aai/introspection/PropertyPredicates.java1
-rw-r--r--aai-core/src/main/java/org/onap/aai/introspection/exceptions/AAIUnmarshallingException.java3
-rw-r--r--aai-core/src/main/java/org/onap/aai/introspection/generator/CreateExample.java6
-rw-r--r--aai-core/src/main/java/org/onap/aai/introspection/sideeffect/DataCopy.java23
-rw-r--r--aai-core/src/main/java/org/onap/aai/introspection/sideeffect/OwnerCheck.java9
-rw-r--r--aai-core/src/main/java/org/onap/aai/introspection/sideeffect/PrivateEdge.java22
-rw-r--r--aai-core/src/main/java/org/onap/aai/introspection/sideeffect/SideEffect.java1
-rw-r--r--aai-core/src/main/java/org/onap/aai/introspection/sideeffect/SideEffectRunner.java3
-rw-r--r--aai-core/src/main/java/org/onap/aai/parsers/query/LegacyQueryParser.java5
-rw-r--r--aai-core/src/main/java/org/onap/aai/parsers/query/RelationshipQueryParser.java5
-rw-r--r--aai-core/src/main/java/org/onap/aai/parsers/relationship/RelationshipToURI.java5
-rw-r--r--aai-core/src/main/java/org/onap/aai/parsers/uri/URIParser.java2
-rw-r--r--aai-core/src/main/java/org/onap/aai/prevalidation/Validation.java13
-rw-r--r--aai-core/src/main/java/org/onap/aai/prevalidation/ValidationConfiguration.java1
-rw-r--r--aai-core/src/main/java/org/onap/aai/prevalidation/ValidationService.java102
-rw-r--r--aai-core/src/main/java/org/onap/aai/prevalidation/ValidationServiceNoAuthClient.java11
-rw-r--r--aai-core/src/main/java/org/onap/aai/prevalidation/ValidationServiceOneWayClient.java10
-rw-r--r--aai-core/src/main/java/org/onap/aai/prevalidation/ValidationServiceRestClient.java8
-rw-r--r--aai-core/src/main/java/org/onap/aai/prevalidation/Violation.java21
-rw-r--r--aai-core/src/main/java/org/onap/aai/query/builder/GraphTraversalBuilder.java47
-rw-r--r--aai-core/src/main/java/org/onap/aai/query/builder/GremlinQueryBuilder.java55
-rw-r--r--aai-core/src/main/java/org/onap/aai/query/builder/GremlinTraversal.java1
-rw-r--r--aai-core/src/main/java/org/onap/aai/query/builder/HistoryGremlinTraversal.java24
-rw-r--r--aai-core/src/main/java/org/onap/aai/query/builder/HistoryTraversalURIOptimizedQuery.java5
-rw-r--r--aai-core/src/main/java/org/onap/aai/query/builder/QueryBuilder.java40
-rw-r--r--aai-core/src/main/java/org/onap/aai/rest/db/HttpEntry.java209
-rw-r--r--aai-core/src/main/java/org/onap/aai/rest/ueb/NotificationEvent.java1
-rw-r--r--aai-core/src/main/java/org/onap/aai/rest/ueb/UEBNotification.java3
-rw-r--r--aai-core/src/main/java/org/onap/aai/restcore/RESTAPI.java2
-rw-r--r--aai-core/src/main/java/org/onap/aai/restcore/search/AAIAbstractGroovyShell.java6
-rw-r--r--aai-core/src/main/java/org/onap/aai/restcore/search/GremlinGroovyShell.java3
-rw-r--r--aai-core/src/main/java/org/onap/aai/restcore/search/GroovyQueryBuilder.java8
-rw-r--r--aai-core/src/main/java/org/onap/aai/restcore/util/URITools.java1
-rw-r--r--aai-core/src/main/java/org/onap/aai/serialization/db/DBSerializer.java382
-rw-r--r--aai-core/src/main/java/org/onap/aai/serialization/db/GraphSingleton.java4
-rw-r--r--aai-core/src/main/java/org/onap/aai/serialization/db/ImpliedDelete.java56
-rw-r--r--aai-core/src/main/java/org/onap/aai/serialization/engines/InMemoryDBEngine.java8
-rw-r--r--aai-core/src/main/java/org/onap/aai/serialization/engines/JanusGraphDBEngine.java8
-rw-r--r--aai-core/src/main/java/org/onap/aai/serialization/engines/TransactionalGraphEngine.java14
-rw-r--r--aai-core/src/main/java/org/onap/aai/serialization/engines/query/GraphTraversalQueryEngine.java26
-rw-r--r--aai-core/src/main/java/org/onap/aai/serialization/queryformats/Aggregate.java67
-rw-r--r--aai-core/src/main/java/org/onap/aai/serialization/queryformats/ChangesFormat.java45
-rw-r--r--aai-core/src/main/java/org/onap/aai/serialization/queryformats/Console.java3
-rw-r--r--aai-core/src/main/java/org/onap/aai/serialization/queryformats/Count.java3
-rw-r--r--aai-core/src/main/java/org/onap/aai/serialization/queryformats/FormatFactory.java54
-rw-r--r--aai-core/src/main/java/org/onap/aai/serialization/queryformats/FormatMapper.java4
-rw-r--r--aai-core/src/main/java/org/onap/aai/serialization/queryformats/Formatter.java43
-rw-r--r--aai-core/src/main/java/org/onap/aai/serialization/queryformats/GraphSON.java4
-rw-r--r--aai-core/src/main/java/org/onap/aai/serialization/queryformats/HistoryFormat.java26
-rw-r--r--aai-core/src/main/java/org/onap/aai/serialization/queryformats/IdURL.java18
-rw-r--r--aai-core/src/main/java/org/onap/aai/serialization/queryformats/LifecycleFormat.java116
-rw-r--r--aai-core/src/main/java/org/onap/aai/serialization/queryformats/MultiFormatMapper.java102
-rw-r--r--aai-core/src/main/java/org/onap/aai/serialization/queryformats/PathedURL.java18
-rw-r--r--aai-core/src/main/java/org/onap/aai/serialization/queryformats/RawFormat.java17
-rw-r--r--aai-core/src/main/java/org/onap/aai/serialization/queryformats/Resource.java37
-rw-r--r--aai-core/src/main/java/org/onap/aai/serialization/queryformats/ResourceWithSoT.java9
-rw-r--r--aai-core/src/main/java/org/onap/aai/serialization/queryformats/StateFormat.java37
-rw-r--r--aai-core/src/main/java/org/onap/aai/serialization/queryformats/TreeFormat.java50
-rw-r--r--aai-core/src/main/java/org/onap/aai/serialization/queryformats/utils/QueryParamInjector.java20
-rw-r--r--aai-core/src/main/java/org/onap/aai/serialization/queryformats/utils/UrlBuilder.java4
-rw-r--r--aai-core/src/main/java/org/onap/aai/service/NodeValidationService.java5
-rw-r--r--aai-core/src/main/java/org/onap/aai/tasks/ScheduledTasks.java2
-rw-r--r--aai-core/src/main/java/org/onap/aai/transforms/XmlFormatTransformer.java12
-rw-r--r--aai-core/src/main/java/org/onap/aai/util/Entity.java14
-rw-r--r--aai-core/src/main/java/org/onap/aai/util/EntityList.java14
-rw-r--r--aai-core/src/main/java/org/onap/aai/util/HttpsAuthClient.java30
-rw-r--r--aai-core/src/main/java/org/onap/aai/util/KeyValueList.java14
-rw-r--r--aai-core/src/main/java/org/onap/aai/util/PojoUtils.java98
-rw-r--r--aai-core/src/main/java/org/onap/aai/util/Request.java10
-rw-r--r--aai-core/src/main/java/org/onap/aai/util/RestController.java29
-rw-r--r--aai-core/src/main/java/org/onap/aai/util/RestControllerInterface.java1
-rw-r--r--aai-core/src/main/java/org/onap/aai/util/StoreNotificationEvent.java12
-rw-r--r--aai-core/src/main/java/org/onap/aai/util/delta/DeltaAction.java7
-rw-r--r--aai-core/src/main/java/org/onap/aai/util/delta/DeltaEvents.java24
-rw-r--r--aai-core/src/main/java/org/onap/aai/util/delta/ObjectDelta.java16
-rw-r--r--aai-core/src/main/java/org/onap/aai/util/delta/PropertyDelta.java13
-rw-r--r--aai-core/src/main/java/org/onap/aai/util/delta/PropertyDeltaFactory.java4
-rw-r--r--aai-core/src/main/java/org/onap/aai/util/delta/RelationshipDelta.java19
103 files changed, 1194 insertions, 1185 deletions
diff --git a/aai-core/src/main/java/org/onap/aai/audit/ListEndpoints.java b/aai-core/src/main/java/org/onap/aai/audit/ListEndpoints.java
index 0a027d64..ae493ef1 100644
--- a/aai-core/src/main/java/org/onap/aai/audit/ListEndpoints.java
+++ b/aai-core/src/main/java/org/onap/aai/audit/ListEndpoints.java
@@ -22,6 +22,8 @@
package org.onap.aai.audit;
+import com.google.common.base.CaseFormat;
+
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
@@ -46,8 +48,6 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
-import com.google.common.base.CaseFormat;
-
/**
* The Class ListEndpoints.
*/
diff --git a/aai-core/src/main/java/org/onap/aai/concurrent/AaiCallable.java b/aai-core/src/main/java/org/onap/aai/concurrent/AaiCallable.java
index 69560ec1..2703bdc4 100644
--- a/aai-core/src/main/java/org/onap/aai/concurrent/AaiCallable.java
+++ b/aai-core/src/main/java/org/onap/aai/concurrent/AaiCallable.java
@@ -44,7 +44,7 @@ public abstract class AaiCallable<T> implements Callable<T> {
* The call method
*/
public T call() throws Exception {
- if ( mdcCopy != null ) {
+ if (mdcCopy != null) {
MDC.setContextMap(mdcCopy);
}
return process();
diff --git a/aai-core/src/main/java/org/onap/aai/config/XmlFormatTransformerConfiguration.java b/aai-core/src/main/java/org/onap/aai/config/XmlFormatTransformerConfiguration.java
index 0c83c2b3..b945d855 100644
--- a/aai-core/src/main/java/org/onap/aai/config/XmlFormatTransformerConfiguration.java
+++ b/aai-core/src/main/java/org/onap/aai/config/XmlFormatTransformerConfiguration.java
@@ -17,6 +17,7 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
+
package org.onap.aai.config;
import org.onap.aai.transforms.XmlFormatTransformer;
@@ -27,7 +28,7 @@ import org.springframework.context.annotation.Configuration;
public class XmlFormatTransformerConfiguration {
@Bean
- public XmlFormatTransformer xmlFormatTransformer(){
+ public XmlFormatTransformer xmlFormatTransformer() {
return new XmlFormatTransformer();
}
}
diff --git a/aai-core/src/main/java/org/onap/aai/dbgen/GraphSONPartialReader.java b/aai-core/src/main/java/org/onap/aai/dbgen/GraphSONPartialReader.java
index 1b3a3287..7ed8da4f 100644
--- a/aai-core/src/main/java/org/onap/aai/dbgen/GraphSONPartialReader.java
+++ b/aai-core/src/main/java/org/onap/aai/dbgen/GraphSONPartialReader.java
@@ -20,9 +20,6 @@
package org.onap.aai.dbgen;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
import java.io.BufferedReader;
import java.io.ByteArrayInputStream;
import java.io.IOException;
@@ -60,6 +57,8 @@ import org.apache.tinkerpop.shaded.jackson.core.type.TypeReference;
import org.apache.tinkerpop.shaded.jackson.databind.JsonNode;
import org.apache.tinkerpop.shaded.jackson.databind.ObjectMapper;
import org.apache.tinkerpop.shaded.jackson.databind.node.JsonNodeType;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
/**
* This is a Wrapper around the GraphsonReader class
diff --git a/aai-core/src/main/java/org/onap/aai/dbgen/SchemaGenerator.java b/aai-core/src/main/java/org/onap/aai/dbgen/SchemaGenerator.java
index 9f3e7475..250c1263 100644
--- a/aai-core/src/main/java/org/onap/aai/dbgen/SchemaGenerator.java
+++ b/aai-core/src/main/java/org/onap/aai/dbgen/SchemaGenerator.java
@@ -19,15 +19,24 @@
*/
package org.onap.aai.dbgen;
-import org.onap.aai.util.AAIConstants;
+
import com.google.common.collect.Multimap;
+
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Map;
+import java.util.Optional;
+import java.util.Set;
+import java.util.function.Function;
+import java.util.stream.Collectors;
+
import org.apache.tinkerpop.gremlin.structure.Vertex;
import org.janusgraph.core.Cardinality;
import org.janusgraph.core.Multiplicity;
import org.janusgraph.core.PropertyKey;
-import org.janusgraph.core.schema.JanusGraphManagement;
-import org.janusgraph.core.schema.JanusGraphIndex;
import org.janusgraph.core.schema.ConsistencyModifier;
+import org.janusgraph.core.schema.JanusGraphIndex;
+import org.janusgraph.core.schema.JanusGraphManagement;
import org.onap.aai.config.SpringContextAware;
import org.onap.aai.edges.EdgeIngestor;
import org.onap.aai.edges.EdgeRule;
@@ -37,17 +46,10 @@ import org.onap.aai.introspection.LoaderUtil;
import org.onap.aai.logging.LogFormatTools;
import org.onap.aai.schema.enums.PropertyMetadata;
import org.onap.aai.util.AAIConfig;
+import org.onap.aai.util.AAIConstants;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Map;
-import java.util.Optional;
-import java.util.Set;
-import java.util.function.Function;
-import java.util.stream.Collectors;
-
public class SchemaGenerator {
private static final Logger LOGGER = LoggerFactory.getLogger(SchemaGenerator.class);
@@ -85,7 +87,6 @@ public class SchemaGenerator {
makeEdgeLabels(graphMgmt);
-
Map<String, Introspector> objs = LoaderUtil.getLatestVersion().getAllObjects();
Map<String, PropertyKey> seenProps = new HashMap<>();
@@ -112,8 +113,8 @@ public class SchemaGenerator {
if (process) {
- LOGGER.info("Creating PropertyKey: [{}], [{}], [{}]",
- dbPropName, type.getSimpleName(), cardinality);
+ LOGGER.info("Creating PropertyKey: [{}], [{}], [{}]", dbPropName, type.getSimpleName(),
+ cardinality);
PropertyKey propK;
if (!seenProps.containsKey(dbPropName)) {
propK = graphMgmt.makePropertyKey(dbPropName).dataType(type).cardinality(cardinality)
@@ -125,8 +126,7 @@ public class SchemaGenerator {
LOGGER.info(" Lock is being set for aai-uri Property.");
graphMgmt.setConsistency(propK, ConsistencyModifier.LOCK);
}
- }
- else if (dbPropName.equals("resource-version")) {
+ } else if (dbPropName.equals("resource-version")) {
String aai_rv_lock_enabled = AAIConfig.get(AAIConstants.AAI_LOCK_RV_ENABLED, "false");
LOGGER.info(" Info: aai_rv_lock_enabled:" + aai_rv_lock_enabled);
if ("true".equals(aai_rv_lock_enabled)) {
@@ -146,21 +146,23 @@ public class SchemaGenerator {
if (obj.getUniqueProperties().contains(propName)) {
LOGGER.info("Add Unique index for PropertyKey: [{}]", dbPropName);
indexG = graphMgmt.buildIndex(dbPropName, Vertex.class).addKey(propK).unique()
- .buildCompositeIndex();
+ .buildCompositeIndex();
} else {
LOGGER.info("Add index for PropertyKey: [{}]", dbPropName);
- indexG = graphMgmt.buildIndex(dbPropName, Vertex.class).addKey(propK).buildCompositeIndex();
+ indexG = graphMgmt.buildIndex(dbPropName, Vertex.class).addKey(propK)
+ .buildCompositeIndex();
}
if (indexG != null && dbPropName.equals("aai-uri")) {
- String aai_uri_lock_enabled = AAIConfig.get(AAIConstants.AAI_LOCK_URI_ENABLED, "false");
+ String aai_uri_lock_enabled =
+ AAIConfig.get(AAIConstants.AAI_LOCK_URI_ENABLED, "false");
LOGGER.info(" Info:: aai_uri_lock_enabled:" + aai_uri_lock_enabled);
if ("true".equals(aai_uri_lock_enabled)) {
LOGGER.info("Lock is being set for aai-uri Index.");
graphMgmt.setConsistency(indexG, ConsistencyModifier.LOCK);
}
- }
- else if (indexG != null && dbPropName.equals("resource-version")) {
- String aai_rv_lock_enabled = AAIConfig.get(AAIConstants.AAI_LOCK_RV_ENABLED, "false");
+ } else if (indexG != null && dbPropName.equals("resource-version")) {
+ String aai_rv_lock_enabled =
+ AAIConfig.get(AAIConstants.AAI_LOCK_RV_ENABLED, "false");
LOGGER.info(" Info:: aai_rv_lock_enabled:" + aai_rv_lock_enabled);
if ("true".equals(aai_rv_lock_enabled)) {
LOGGER.info("Lock is being set for resource-version Index.");
@@ -189,8 +191,7 @@ public class SchemaGenerator {
EdgeIngestor edgeIngestor = SpringContextAware.getBean(EdgeIngestor.class);
Set<String> labels = Optional.ofNullable(edgeIngestor.getAllCurrentRules())
- .map(collectValues(EdgeRule::getLabel))
- .orElseGet(HashSet::new);
+ .map(collectValues(EdgeRule::getLabel)).orElseGet(HashSet::new);
labels.forEach(label -> {
if (graphMgmt.containsRelationType(label)) {
diff --git a/aai-core/src/main/java/org/onap/aai/dbgen/SchemaGenerator4Hist.java b/aai-core/src/main/java/org/onap/aai/dbgen/SchemaGenerator4Hist.java
index a35625f6..95825685 100644
--- a/aai-core/src/main/java/org/onap/aai/dbgen/SchemaGenerator4Hist.java
+++ b/aai-core/src/main/java/org/onap/aai/dbgen/SchemaGenerator4Hist.java
@@ -20,7 +20,16 @@
package org.onap.aai.dbgen;
+import static org.onap.aai.db.props.AAIProperties.*;
+
import com.google.common.collect.Multimap;
+
+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.janusgraph.core.Cardinality;
import org.janusgraph.core.Multiplicity;
@@ -39,21 +48,14 @@ import org.onap.aai.util.AAIConfig;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Map;
-import java.util.Optional;
-import java.util.Set;
-
-import static org.onap.aai.db.props.AAIProperties.*;
-
public class SchemaGenerator4Hist {
private static final Logger LOGGER = LoggerFactory.getLogger(SchemaGenerator4Hist.class);
- private SchemaGenerator4Hist(){
+ private SchemaGenerator4Hist() {
}
+
/**
* Load schema into JanusGraph.
*
@@ -125,12 +127,12 @@ public class SchemaGenerator4Hist {
Cardinality cardinality = Cardinality.LIST;
boolean process = false;
if (obj.isListType(propName) && obj.isSimpleGenericType(propName)) {
- // NOTE - For history - All properties have cardinality = LIST
- // It is assumed that there is special processing in the Resources MS
- // for History to turn what used to be SET (referred to as isListType
- // above) will be stored in our db as a single String. And that
- // single string will have Cardinality = LIST so we can track its
- // history.
+ // NOTE - For history - All properties have cardinality = LIST
+ // It is assumed that there is special processing in the Resources MS
+ // for History to turn what used to be SET (referred to as isListType
+ // above) will be stored in our db as a single String. And that
+ // single string will have Cardinality = LIST so we can track its
+ // history.
type = obj.getGenericTypeClass(propName);
process = true;
} else if (obj.isSimpleType(propName)) {
@@ -139,8 +141,8 @@ public class SchemaGenerator4Hist {
if (process) {
- LOGGER.info(" Creating PropertyKey: [{}], [{}], [{}]",
- dbPropName, type.getSimpleName(), cardinality);
+ LOGGER.info(" Creating PropertyKey: [{}], [{}], [{}]", dbPropName, type.getSimpleName(),
+ cardinality);
PropertyKey propK;
if (!seenProps.containsKey(dbPropName)) {
propK = graphMgmt.makePropertyKey(dbPropName).dataType(type).cardinality(cardinality)
@@ -153,7 +155,7 @@ public class SchemaGenerator4Hist {
LOGGER.debug(" Index [{}] already existed in the DB. ", dbPropName);
} else {
if (obj.getIndexedProperties().contains(propName)) {
- // NOTE - for History we never add a unique index - just a regular index
+ // NOTE - for History we never add a unique index - just a regular index
LOGGER.info("Add index for PropertyKey: [{}]", dbPropName);
graphMgmt.buildIndex(dbPropName, Vertex.class).addKey(propK).buildCompositeIndex();
} else {
@@ -163,20 +165,19 @@ public class SchemaGenerator4Hist {
}
}
}
- }// Done processing all properties defined in the OXM
+ } // Done processing all properties defined in the OXM
// Add the 3 new History properties are in the DB
// They are all Cardinality=Single since instance of a Node, Edge or Property can
- // only have one of them. That is, a Property can show up many times in a
- // node, but each instance of that property will only have a single start-ts,
- // end-ts, end-source-of-truth. Same goes for a node or edge itself.
+ // only have one of them. That is, a Property can show up many times in a
+ // node, but each instance of that property will only have a single start-ts,
+ // end-ts, end-source-of-truth. Same goes for a node or edge itself.
makeNewProperty(graphMgmt, seenProps, String.class, END_SOT);
makeNewProperty(graphMgmt, seenProps, Long.class, START_TS);
makeNewProperty(graphMgmt, seenProps, Long.class, END_TS);
makeNewProperty(graphMgmt, seenProps, String.class, START_TX_ID);
makeNewProperty(graphMgmt, seenProps, String.class, END_TX_ID);
-
String imsg = "-- About to call graphMgmt commit";
LOGGER.info(imsg);
graphMgmt.commit();
@@ -186,17 +187,14 @@ public class SchemaGenerator4Hist {
}
- private static <T> void makeNewProperty(JanusGraphManagement graphMgmt,
- Map<String, PropertyKey> seenProps,
- Class<T> type,
- String propertyName) {
+ private static <T> void makeNewProperty(JanusGraphManagement graphMgmt, Map<String, PropertyKey> seenProps,
+ Class<T> type, String propertyName) {
if (graphMgmt.containsRelationType(propertyName)) {
LOGGER.debug("PropertyKey [{}] already existed in the DB.", propertyName);
} else if (!seenProps.containsKey(propertyName)) {
- LOGGER.info("Creating PropertyKey: [{}], [{}], [{}]",
- propertyName, type.getSimpleName(), Cardinality.SINGLE);
- graphMgmt.makePropertyKey(propertyName).dataType(type).cardinality(Cardinality.SINGLE)
- .make();
+ LOGGER.info("Creating PropertyKey: [{}], [{}], [{}]", propertyName, type.getSimpleName(),
+ Cardinality.SINGLE);
+ graphMgmt.makePropertyKey(propertyName).dataType(type).cardinality(Cardinality.SINGLE).make();
}
}
}
diff --git a/aai-core/src/main/java/org/onap/aai/dbmap/AAIGraph.java b/aai-core/src/main/java/org/onap/aai/dbmap/AAIGraph.java
index 62ac4f06..cb388ccc 100644
--- a/aai-core/src/main/java/org/onap/aai/dbmap/AAIGraph.java
+++ b/aai-core/src/main/java/org/onap/aai/dbmap/AAIGraph.java
@@ -58,8 +58,6 @@ public class AAIGraph {
protected JanusGraph graph;
private static boolean isInit = false;
-
-
/**
* Instantiates a new AAI graph.
*/
@@ -139,7 +137,8 @@ public class AAIGraph {
transaction.tx().commit();
logger.info("Snapshot loaded to inmemory graph.");
} catch (Exception e) {
- logger.info(String.format("ERROR: Could not load datasnapshot to in memory graph. %n%s", ExceptionUtils.getStackTrace(e)));
+ logger.info(String.format("ERROR: Could not load datasnapshot to in memory graph. %n%s",
+ ExceptionUtils.getStackTrace(e)));
throw new RuntimeException(e);
}
}
@@ -151,7 +150,8 @@ public class AAIGraph {
JanusGraphManagement graphMgt = graph.openManagement();
logger.info("-- loading schema into JanusGraph");
- if ("true".equals(SpringContextAware.getApplicationContext().getEnvironment().getProperty("history.enabled", "false"))) {
+ if ("true".equals(
+ SpringContextAware.getApplicationContext().getEnvironment().getProperty("history.enabled", "false"))) {
SchemaGenerator4Hist.loadSchemaIntoJanusGraph(graphMgt, IN_MEMORY);
} else {
SchemaGenerator.loadSchemaIntoJanusGraph(graphMgt, IN_MEMORY);
diff --git a/aai-core/src/main/java/org/onap/aai/dbmap/AAIGraphConfig.java b/aai-core/src/main/java/org/onap/aai/dbmap/AAIGraphConfig.java
index 4dbc1224..b6afe626 100644
--- a/aai-core/src/main/java/org/onap/aai/dbmap/AAIGraphConfig.java
+++ b/aai-core/src/main/java/org/onap/aai/dbmap/AAIGraphConfig.java
@@ -35,7 +35,6 @@ import org.janusgraph.diskstorage.configuration.ConfigElement;
*/
public class AAIGraphConfig {
-
private AAIGraphConfig() {
}
diff --git a/aai-core/src/main/java/org/onap/aai/dbmap/InMemoryGraph.java b/aai-core/src/main/java/org/onap/aai/dbmap/InMemoryGraph.java
index ac9407e3..51a2c221 100644
--- a/aai-core/src/main/java/org/onap/aai/dbmap/InMemoryGraph.java
+++ b/aai-core/src/main/java/org/onap/aai/dbmap/InMemoryGraph.java
@@ -20,9 +20,6 @@
package org.onap.aai.dbmap;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
@@ -36,6 +33,8 @@ import org.janusgraph.core.schema.JanusGraphManagement;
import org.onap.aai.dbgen.GraphSONPartialIO;
import org.onap.aai.dbgen.SchemaGenerator;
import org.onap.aai.logging.LogFormatTools;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
public class InMemoryGraph {
@@ -46,7 +45,7 @@ public class InMemoryGraph {
/*
* Create a In-memory graph
*/
- try(InputStream is = new FileInputStream(builder.propertyFile)){
+ try (InputStream is = new FileInputStream(builder.propertyFile)) {
graph = JanusGraphFactory.open(builder.propertyFile);
Properties graphProps = new Properties();
@@ -63,7 +62,7 @@ public class InMemoryGraph {
transaction.io(GraphSONPartialIO.build()).readGraph(builder.graphsonLocation);
} else {
transaction.io(GraphSONPartialIO.build()).reader().create().readGraph(builder.seqInputStream,
- graph);
+ graph);
}
} else {
if ((builder.graphsonLocation != null) && (builder.graphsonLocation.length() > 0)) {
@@ -76,7 +75,8 @@ public class InMemoryGraph {
}
} catch (Exception e) {
- LOGGER.error(String.format("ERROR: Could not load datasnapshot to in memory graph. %n%s", LogFormatTools.getStackTop(e)));
+ LOGGER.error(String.format("ERROR: Could not load datasnapshot to in memory graph. %n%s",
+ LogFormatTools.getStackTop(e)));
throw new IllegalStateException("Could not load datasnapshot to in memory graph");
}
diff --git a/aai-core/src/main/java/org/onap/aai/dmaap/AAIDmaapEventJMSConsumer.java b/aai-core/src/main/java/org/onap/aai/dmaap/AAIDmaapEventJMSConsumer.java
index 3c030466..2858ece3 100644
--- a/aai-core/src/main/java/org/onap/aai/dmaap/AAIDmaapEventJMSConsumer.java
+++ b/aai-core/src/main/java/org/onap/aai/dmaap/AAIDmaapEventJMSConsumer.java
@@ -22,6 +22,14 @@
package org.onap.aai.dmaap;
+import java.util.Map;
+import java.util.Objects;
+
+import javax.jms.JMSException;
+import javax.jms.Message;
+import javax.jms.MessageListener;
+import javax.jms.TextMessage;
+
import org.json.JSONException;
import org.json.JSONObject;
import org.onap.aai.aailog.logs.AaiDmaapMetricLog;
@@ -37,13 +45,6 @@ import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpMethod;
import org.springframework.web.client.RestTemplate;
-import javax.jms.JMSException;
-import javax.jms.Message;
-import javax.jms.MessageListener;
-import javax.jms.TextMessage;
-import java.util.Map;
-import java.util.Objects;
-
public class AAIDmaapEventJMSConsumer implements MessageListener {
private static final String EVENT_TOPIC = "event-topic";
@@ -57,7 +58,6 @@ public class AAIDmaapEventJMSConsumer implements MessageListener {
private Environment environment;
private Map<String, String> mdcCopy;
-
public AAIDmaapEventJMSConsumer(Environment environment, RestTemplate restTemplate, HttpHeaders httpHeaders) {
super();
mdcCopy = MDC.getCopyOfContextMap();
@@ -86,7 +86,7 @@ public class AAIDmaapEventJMSConsumer implements MessageListener {
String aaiElsErrorCode = AaiElsErrorCode.SUCCESS;
String errorDescription = "";
- if ( mdcCopy != null ) {
+ if (mdcCopy != null) {
MDC.setContextMap(mdcCopy);
}
@@ -113,8 +113,7 @@ public class AAIDmaapEventJMSConsumer implements MessageListener {
if (aaiEventHeader.has("entity-link")) {
serviceName = aaiEventHeader.get("entity-link").toString();
}
- }
- catch (JSONException jexc) {
+ } catch (JSONException jexc) {
// ignore, this is just used for logging
}
}
@@ -139,8 +138,7 @@ public class AAIDmaapEventJMSConsumer implements MessageListener {
aaiElsErrorCode = AaiElsErrorCode.AVAILABILITY_TIMEOUT_ERROR;
errorDescription = e.getMessage();
ErrorLogHelper.logException(new AAIException("AAI_7304", jsmMessageTxt));
- }
- finally {
+ } finally {
metricLog.post(aaiElsErrorCode, errorDescription);
}
}
diff --git a/aai-core/src/main/java/org/onap/aai/dmaap/MessageProducer.java b/aai-core/src/main/java/org/onap/aai/dmaap/MessageProducer.java
index 1df64b69..da70d505 100644
--- a/aai-core/src/main/java/org/onap/aai/dmaap/MessageProducer.java
+++ b/aai-core/src/main/java/org/onap/aai/dmaap/MessageProducer.java
@@ -25,5 +25,6 @@ import org.json.JSONObject;
public interface MessageProducer {
void sendMessageToDefaultDestination(JSONObject finalJson);
+
void sendMessageToDefaultDestination(String msg);
}
diff --git a/aai-core/src/main/java/org/onap/aai/domain/model/AAIResources.java b/aai-core/src/main/java/org/onap/aai/domain/model/AAIResources.java
index ac13ab07..7b5b2da7 100644
--- a/aai-core/src/main/java/org/onap/aai/domain/model/AAIResources.java
+++ b/aai-core/src/main/java/org/onap/aai/domain/model/AAIResources.java
@@ -20,11 +20,11 @@
package org.onap.aai.domain.model;
-import org.eclipse.persistence.jaxb.dynamic.DynamicJAXBContext;
-
import java.util.HashMap;
import java.util.Map;
+import org.eclipse.persistence.jaxb.dynamic.DynamicJAXBContext;
+
public class AAIResources {
private DynamicJAXBContext jaxbContext;
diff --git a/aai-core/src/main/java/org/onap/aai/domain/notificationEvent/NotificationEvent.java b/aai-core/src/main/java/org/onap/aai/domain/notificationEvent/NotificationEvent.java
index 1e6307cc..dad35669 100644
--- a/aai-core/src/main/java/org/onap/aai/domain/notificationEvent/NotificationEvent.java
+++ b/aai-core/src/main/java/org/onap/aai/domain/notificationEvent/NotificationEvent.java
@@ -26,10 +26,10 @@
package org.onap.aai.domain.notificationEvent;
-import org.w3c.dom.Element;
-
import javax.xml.bind.annotation.*;
+import org.w3c.dom.Element;
+
/**
* <p>
* Java class for anonymous complex type.
diff --git a/aai-core/src/main/java/org/onap/aai/domain/responseMessage/AAIResponseMessageData.java b/aai-core/src/main/java/org/onap/aai/domain/responseMessage/AAIResponseMessageData.java
index c48f1ed8..f7fe13b5 100644
--- a/aai-core/src/main/java/org/onap/aai/domain/responseMessage/AAIResponseMessageData.java
+++ b/aai-core/src/main/java/org/onap/aai/domain/responseMessage/AAIResponseMessageData.java
@@ -29,10 +29,11 @@ package org.onap.aai.domain.responseMessage;
//Generated on: 2015.09.11 at 11:53:27 AM EDT
//
-import javax.xml.bind.annotation.*;
import java.util.ArrayList;
import java.util.List;
+import javax.xml.bind.annotation.*;
+
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "", propOrder = {"aaiResponseMessageDatum", "any"})
@XmlRootElement(name = "aai-response-message-data", namespace = "http://org.onap.aai.inventory")
diff --git a/aai-core/src/main/java/org/onap/aai/domain/responseMessage/AAIResponseMessages.java b/aai-core/src/main/java/org/onap/aai/domain/responseMessage/AAIResponseMessages.java
index 8263e58d..f5068742 100644
--- a/aai-core/src/main/java/org/onap/aai/domain/responseMessage/AAIResponseMessages.java
+++ b/aai-core/src/main/java/org/onap/aai/domain/responseMessage/AAIResponseMessages.java
@@ -27,10 +27,11 @@ package org.onap.aai.domain.responseMessage;
//Generated on: 2015.09.11 at 11:53:27 AM EDT
//
-import javax.xml.bind.annotation.*;
import java.util.ArrayList;
import java.util.List;
+import javax.xml.bind.annotation.*;
+
/**
* <p>
* Java class for anonymous complex type.
diff --git a/aai-core/src/main/java/org/onap/aai/domain/translog/TransactionLogEntries.java b/aai-core/src/main/java/org/onap/aai/domain/translog/TransactionLogEntries.java
index cde4f4b9..d1caf511 100644
--- a/aai-core/src/main/java/org/onap/aai/domain/translog/TransactionLogEntries.java
+++ b/aai-core/src/main/java/org/onap/aai/domain/translog/TransactionLogEntries.java
@@ -26,12 +26,13 @@
package org.onap.aai.domain.translog;
+import java.util.ArrayList;
+import java.util.List;
+
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlType;
-import java.util.ArrayList;
-import java.util.List;
/**
* <p>
diff --git a/aai-core/src/main/java/org/onap/aai/domain/translog/TransactionLogEntry.java b/aai-core/src/main/java/org/onap/aai/domain/translog/TransactionLogEntry.java
index 16c773ae..37a1eeff 100644
--- a/aai-core/src/main/java/org/onap/aai/domain/translog/TransactionLogEntry.java
+++ b/aai-core/src/main/java/org/onap/aai/domain/translog/TransactionLogEntry.java
@@ -20,10 +20,10 @@
package org.onap.aai.domain.translog;
-import org.eclipse.persistence.oxm.annotations.XmlCDATA;
-
import javax.xml.bind.annotation.*;
+import org.eclipse.persistence.oxm.annotations.XmlCDATA;
+
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(
name = "",
diff --git a/aai-core/src/main/java/org/onap/aai/extensions/ExtensionController.java b/aai-core/src/main/java/org/onap/aai/extensions/ExtensionController.java
index ec28858e..612273d4 100644
--- a/aai-core/src/main/java/org/onap/aai/extensions/ExtensionController.java
+++ b/aai-core/src/main/java/org/onap/aai/extensions/ExtensionController.java
@@ -20,13 +20,12 @@
package org.onap.aai.extensions;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
import java.lang.reflect.Method;
import org.onap.aai.exceptions.AAIException;
import org.onap.aai.util.AAIConfig;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
public class ExtensionController {
diff --git a/aai-core/src/main/java/org/onap/aai/extensions/OrphanLInterfaceHandler.java b/aai-core/src/main/java/org/onap/aai/extensions/OrphanLInterfaceHandler.java
index 094e7cee..5f7a9a1c 100644
--- a/aai-core/src/main/java/org/onap/aai/extensions/OrphanLInterfaceHandler.java
+++ b/aai-core/src/main/java/org/onap/aai/extensions/OrphanLInterfaceHandler.java
@@ -31,7 +31,6 @@ import org.onap.aai.edges.enums.EdgeType;
import org.onap.aai.exceptions.AAIException;
import org.onap.aai.introspection.Introspector;
import org.onap.aai.introspection.Loader;
-import org.onap.aai.introspection.exceptions.AAIUnknownObjectException;
import org.onap.aai.parsers.query.QueryParser;
import org.onap.aai.query.builder.QueryBuilder;
import org.onap.aai.rest.db.DBRequest;
diff --git a/aai-core/src/main/java/org/onap/aai/ingestModel/CreateWidgetModels.java b/aai-core/src/main/java/org/onap/aai/ingestModel/CreateWidgetModels.java
index 62cadab3..1d66a8a5 100644
--- a/aai-core/src/main/java/org/onap/aai/ingestModel/CreateWidgetModels.java
+++ b/aai-core/src/main/java/org/onap/aai/ingestModel/CreateWidgetModels.java
@@ -30,7 +30,6 @@ import java.util.UUID;
import javax.xml.transform.stream.StreamSource;
-import org.onap.aai.config.SpringContextAware;
import org.onap.aai.introspection.Introspector;
import org.onap.aai.introspection.Loader;
import org.onap.aai.introspection.LoaderFactory;
diff --git a/aai-core/src/main/java/org/onap/aai/introspection/Introspector.java b/aai-core/src/main/java/org/onap/aai/introspection/Introspector.java
index 117610ff..c9e1f455 100644
--- a/aai-core/src/main/java/org/onap/aai/introspection/Introspector.java
+++ b/aai-core/src/main/java/org/onap/aai/introspection/Introspector.java
@@ -20,6 +20,8 @@
package org.onap.aai.introspection;
+import com.google.common.base.CaseFormat;
+
import java.io.UnsupportedEncodingException;
import java.lang.reflect.InvocationTargetException;
import java.util.ArrayList;
@@ -48,8 +50,6 @@ import org.onap.aai.workarounds.NamingExceptions;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import com.google.common.base.CaseFormat;
-
public abstract class Introspector implements Cloneable {
private static final Logger LOGGER = LoggerFactory.getLogger(Introspector.class);
@@ -185,7 +185,7 @@ public abstract class Introspector implements Cloneable {
if (obj != null) {
try {
- if (! (obj.getClass().getCanonicalName().equals(nameClass.getCanonicalName()))) {
+ if (!(obj.getClass().getCanonicalName().equals(nameClass.getCanonicalName()))) {
if (nameClass.isPrimitive()) {
nameClass = ClassUtils.primitiveToWrapper(nameClass);
result = nameClass.getConstructor(String.class).newInstance(obj.toString());
@@ -317,8 +317,7 @@ public abstract class Introspector implements Cloneable {
String indexedKeys = this.getMetadata(ObjectMetadata.INDEXED_PROPS);
if (dslKeys != null) {
Arrays.stream(dslKeys.split(",")).forEach(result::add);
- }
- else if(indexedKeys != null){
+ } else if (indexedKeys != null) {
Arrays.stream(indexedKeys.split(",")).forEach(result::add);
}
this.dslStartNodeProperties = Collections.unmodifiableSet(result);
diff --git a/aai-core/src/main/java/org/onap/aai/introspection/IntrospectorWalker.java b/aai-core/src/main/java/org/onap/aai/introspection/IntrospectorWalker.java
index 93a48290..e6ecef0f 100644
--- a/aai-core/src/main/java/org/onap/aai/introspection/IntrospectorWalker.java
+++ b/aai-core/src/main/java/org/onap/aai/introspection/IntrospectorWalker.java
@@ -20,9 +20,6 @@
package org.onap.aai.introspection;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
import java.util.HashSet;
import java.util.LinkedHashSet;
import java.util.List;
@@ -31,6 +28,8 @@ import java.util.Set;
import org.onap.aai.exceptions.AAIException;
import org.onap.aai.introspection.exceptions.AAIUnknownObjectException;
import org.onap.aai.logging.LogFormatTools;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
public class IntrospectorWalker {
diff --git a/aai-core/src/main/java/org/onap/aai/introspection/JSONStrategy.java b/aai-core/src/main/java/org/onap/aai/introspection/JSONStrategy.java
index 484e5612..40352360 100644
--- a/aai-core/src/main/java/org/onap/aai/introspection/JSONStrategy.java
+++ b/aai-core/src/main/java/org/onap/aai/introspection/JSONStrategy.java
@@ -25,6 +25,7 @@ import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.UUID;
+
import org.json.simple.JSONArray;
import org.json.simple.JSONObject;
import org.onap.aai.schema.enums.ObjectMetadata;
diff --git a/aai-core/src/main/java/org/onap/aai/introspection/MoxyLoader.java b/aai-core/src/main/java/org/onap/aai/introspection/MoxyLoader.java
index 7471c745..6099e1b4 100644
--- a/aai-core/src/main/java/org/onap/aai/introspection/MoxyLoader.java
+++ b/aai-core/src/main/java/org/onap/aai/introspection/MoxyLoader.java
@@ -20,8 +20,6 @@
package org.onap.aai.introspection;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
import com.google.common.base.CaseFormat;
import com.google.common.collect.ImmutableMap;
@@ -49,6 +47,8 @@ import org.onap.aai.restcore.MediaType;
import org.onap.aai.schema.enums.ObjectMetadata;
import org.onap.aai.setup.SchemaVersion;
import org.onap.aai.workarounds.NamingExceptions;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
public class MoxyLoader extends Loader {
diff --git a/aai-core/src/main/java/org/onap/aai/introspection/MoxyStrategy.java b/aai-core/src/main/java/org/onap/aai/introspection/MoxyStrategy.java
index 57e41081..df8e9238 100644
--- a/aai-core/src/main/java/org/onap/aai/introspection/MoxyStrategy.java
+++ b/aai-core/src/main/java/org/onap/aai/introspection/MoxyStrategy.java
@@ -20,8 +20,6 @@
package org.onap.aai.introspection;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
import com.google.common.base.CaseFormat;
import com.google.common.base.Joiner;
@@ -44,12 +42,12 @@ import org.eclipse.persistence.oxm.mappings.XMLCompositeCollectionMapping;
import org.eclipse.persistence.oxm.mappings.XMLCompositeDirectCollectionMapping;
import org.onap.aai.config.SpringContextAware;
import org.onap.aai.logging.LogFormatTools;
-import org.onap.aai.nodes.CaseFormatStore;
-import org.onap.aai.nodes.NodeIngestor;
import org.onap.aai.restcore.MediaType;
import org.onap.aai.schema.enums.ObjectMetadata;
import org.onap.aai.schema.enums.PropertyMetadata;
import org.onap.aai.setup.SchemaVersion;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
import org.springframework.web.util.UriUtils;
public class MoxyStrategy extends Introspector {
diff --git a/aai-core/src/main/java/org/onap/aai/introspection/PropertyPredicates.java b/aai-core/src/main/java/org/onap/aai/introspection/PropertyPredicates.java
index 1aca431f..822b0464 100644
--- a/aai-core/src/main/java/org/onap/aai/introspection/PropertyPredicates.java
+++ b/aai-core/src/main/java/org/onap/aai/introspection/PropertyPredicates.java
@@ -22,6 +22,7 @@ package org.onap.aai.introspection;
import java.util.Map;
import java.util.Set;
+
import org.onap.aai.schema.enums.PropertyMetadata;
public final class PropertyPredicates {
diff --git a/aai-core/src/main/java/org/onap/aai/introspection/exceptions/AAIUnmarshallingException.java b/aai-core/src/main/java/org/onap/aai/introspection/exceptions/AAIUnmarshallingException.java
index 6ce42e4e..0cf19962 100644
--- a/aai-core/src/main/java/org/onap/aai/introspection/exceptions/AAIUnmarshallingException.java
+++ b/aai-core/src/main/java/org/onap/aai/introspection/exceptions/AAIUnmarshallingException.java
@@ -26,7 +26,8 @@ public class AAIUnmarshallingException extends AAIException {
private static final long serialVersionUID = -5615651557821878103L;
- private static final String AAI_MSG="AAI_3000";
+ private static final String AAI_MSG = "AAI_3000";
+
public AAIUnmarshallingException() {
}
diff --git a/aai-core/src/main/java/org/onap/aai/introspection/generator/CreateExample.java b/aai-core/src/main/java/org/onap/aai/introspection/generator/CreateExample.java
index 8288fd68..c5a14ce0 100644
--- a/aai-core/src/main/java/org/onap/aai/introspection/generator/CreateExample.java
+++ b/aai-core/src/main/java/org/onap/aai/introspection/generator/CreateExample.java
@@ -20,13 +20,13 @@
package org.onap.aai.introspection.generator;
-import org.onap.aai.exceptions.AAIException;
-import org.onap.aai.introspection.*;
-
import java.security.SecureRandom;
import java.util.ArrayList;
import java.util.List;
+import org.onap.aai.exceptions.AAIException;
+import org.onap.aai.introspection.*;
+
public class CreateExample implements Wanderer {
private SecureRandom rand = new SecureRandom();
diff --git a/aai-core/src/main/java/org/onap/aai/introspection/sideeffect/DataCopy.java b/aai-core/src/main/java/org/onap/aai/introspection/sideeffect/DataCopy.java
index 0994f023..d7780928 100644
--- a/aai-core/src/main/java/org/onap/aai/introspection/sideeffect/DataCopy.java
+++ b/aai-core/src/main/java/org/onap/aai/introspection/sideeffect/DataCopy.java
@@ -20,6 +20,17 @@
package org.onap.aai.introspection.sideeffect;
+import java.io.UnsupportedEncodingException;
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.util.Collections;
+import java.util.List;
+import java.util.Map.Entry;
+import java.util.Objects;
+import java.util.Optional;
+
+import javax.ws.rs.core.MultivaluedMap;
+
import org.apache.tinkerpop.gremlin.structure.Vertex;
import org.onap.aai.exceptions.AAIException;
import org.onap.aai.introspection.Introspector;
@@ -31,16 +42,6 @@ import org.onap.aai.schema.enums.PropertyMetadata;
import org.onap.aai.serialization.db.DBSerializer;
import org.onap.aai.serialization.engines.TransactionalGraphEngine;
-import javax.ws.rs.core.MultivaluedMap;
-import java.io.UnsupportedEncodingException;
-import java.net.URI;
-import java.net.URISyntaxException;
-import java.util.Collections;
-import java.util.List;
-import java.util.Map.Entry;
-import java.util.Objects;
-import java.util.Optional;
-
public class DataCopy extends SideEffect {
public DataCopy(Introspector obj, Vertex self, TransactionalGraphEngine dbEngine, DBSerializer serializer) {
@@ -73,7 +74,7 @@ public class DataCopy extends SideEffect {
"multiple values of " + entry.getKey() + " found when searching " + uri);
}
}
- } //else skip processing because no required properties were specified
+ } // else skip processing because no required properties were specified
}
@Override
diff --git a/aai-core/src/main/java/org/onap/aai/introspection/sideeffect/OwnerCheck.java b/aai-core/src/main/java/org/onap/aai/introspection/sideeffect/OwnerCheck.java
index 4d75f38a..d9976455 100644
--- a/aai-core/src/main/java/org/onap/aai/introspection/sideeffect/OwnerCheck.java
+++ b/aai-core/src/main/java/org/onap/aai/introspection/sideeffect/OwnerCheck.java
@@ -42,14 +42,13 @@ public class OwnerCheck extends SideEffect {
}
@Override
- protected void processURI(Optional<String> completeUri, Entry<String, String> entry)
- throws AAIException {
+ protected void processURI(Optional<String> completeUri, Entry<String, String> entry) throws AAIException {
if (!isAuthorized(serializer.getGroups(), self)) {
throw new AAIException("AAI_3304",
- "Group(s) :" + serializer.getGroups() + " not authorized to perform function");
+ "Group(s) :" + serializer.getGroups() + " not authorized to perform function");
- } //else skip processing because no required properties were specified
+ } // else skip processing because no required properties were specified
}
@@ -60,7 +59,7 @@ public class OwnerCheck extends SideEffect {
String dataOwner = dataOwnerProperty.toString();
String dataOwnerWithReadAccess = dataOwner + READ_ONLY_SUFFIX;
return groups.stream()
- .anyMatch(group -> group.equals(dataOwner) || group.equals(dataOwnerWithReadAccess));
+ .anyMatch(group -> group.equals(dataOwner) || group.equals(dataOwnerWithReadAccess));
}
}
return true;
diff --git a/aai-core/src/main/java/org/onap/aai/introspection/sideeffect/PrivateEdge.java b/aai-core/src/main/java/org/onap/aai/introspection/sideeffect/PrivateEdge.java
index 06586317..9e32ef40 100644
--- a/aai-core/src/main/java/org/onap/aai/introspection/sideeffect/PrivateEdge.java
+++ b/aai-core/src/main/java/org/onap/aai/introspection/sideeffect/PrivateEdge.java
@@ -21,6 +21,15 @@
package org.onap.aai.introspection.sideeffect;
import com.google.common.collect.Multimap;
+
+import java.io.UnsupportedEncodingException;
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.util.*;
+import java.util.Map.Entry;
+
+import javax.ws.rs.core.MultivaluedMap;
+
import org.apache.tinkerpop.gremlin.structure.Edge;
import org.apache.tinkerpop.gremlin.structure.Vertex;
import org.apache.tinkerpop.gremlin.structure.VertexProperty;
@@ -46,13 +55,6 @@ import org.onap.aai.serialization.db.EdgeSerializer;
import org.onap.aai.serialization.db.exceptions.EdgeMultiplicityException;
import org.onap.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.*;
-import java.util.Map.Entry;
-
public class PrivateEdge extends SideEffect {
public PrivateEdge(Introspector obj, Vertex self, TransactionalGraphEngine dbEngine, DBSerializer serializer) {
@@ -134,8 +136,8 @@ public class PrivateEdge extends SideEffect {
break;
}
} else {
- edgeSerializer.addPrivateEdge(this.dbEngine.asAdmin().getTraversalSource(), self,
- otherVertex, edgeRule.getLabel());
+ edgeSerializer.addPrivateEdge(this.dbEngine.asAdmin().getTraversalSource(), self, otherVertex,
+ edgeRule.getLabel());
}
}
} else {
@@ -143,7 +145,7 @@ public class PrivateEdge extends SideEffect {
throw new AAIException("AAI_6114", "object located at " + uri + " not found");
} else {
throw new AAIMultiplePropertiesException(
- "multiple values of " + entry.getKey() + " found when searching " + uri);
+ "multiple values of " + entry.getKey() + " found when searching " + uri);
}
}
}
diff --git a/aai-core/src/main/java/org/onap/aai/introspection/sideeffect/SideEffect.java b/aai-core/src/main/java/org/onap/aai/introspection/sideeffect/SideEffect.java
index 9ca396ad..bec46520 100644
--- a/aai-core/src/main/java/org/onap/aai/introspection/sideeffect/SideEffect.java
+++ b/aai-core/src/main/java/org/onap/aai/introspection/sideeffect/SideEffect.java
@@ -31,6 +31,7 @@ import java.util.Optional;
import java.util.Set;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
+
import org.apache.tinkerpop.gremlin.structure.Vertex;
import org.onap.aai.edges.exceptions.AmbiguousRuleChoiceException;
import org.onap.aai.edges.exceptions.EdgeRuleNotFoundException;
diff --git a/aai-core/src/main/java/org/onap/aai/introspection/sideeffect/SideEffectRunner.java b/aai-core/src/main/java/org/onap/aai/introspection/sideeffect/SideEffectRunner.java
index 8bc83156..5862767c 100644
--- a/aai-core/src/main/java/org/onap/aai/introspection/sideeffect/SideEffectRunner.java
+++ b/aai-core/src/main/java/org/onap/aai/introspection/sideeffect/SideEffectRunner.java
@@ -20,9 +20,6 @@
package org.onap.aai.introspection.sideeffect;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
import java.io.UnsupportedEncodingException;
import java.lang.reflect.InvocationTargetException;
import java.net.URISyntaxException;
diff --git a/aai-core/src/main/java/org/onap/aai/parsers/query/LegacyQueryParser.java b/aai-core/src/main/java/org/onap/aai/parsers/query/LegacyQueryParser.java
index ca735357..dfa7c95a 100644
--- a/aai-core/src/main/java/org/onap/aai/parsers/query/LegacyQueryParser.java
+++ b/aai-core/src/main/java/org/onap/aai/parsers/query/LegacyQueryParser.java
@@ -20,9 +20,6 @@
package org.onap.aai.parsers.query;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
import java.io.UnsupportedEncodingException;
import java.net.URI;
import java.net.URISyntaxException;
@@ -43,6 +40,8 @@ import org.onap.aai.parsers.uri.URIToObject;
import org.onap.aai.query.builder.QueryBuilder;
import org.onap.aai.restcore.util.URITools;
import org.onap.aai.schema.enums.PropertyMetadata;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
/**
* The Class LegacyQueryParser.
diff --git a/aai-core/src/main/java/org/onap/aai/parsers/query/RelationshipQueryParser.java b/aai-core/src/main/java/org/onap/aai/parsers/query/RelationshipQueryParser.java
index e1319802..7df49b2e 100644
--- a/aai-core/src/main/java/org/onap/aai/parsers/query/RelationshipQueryParser.java
+++ b/aai-core/src/main/java/org/onap/aai/parsers/query/RelationshipQueryParser.java
@@ -20,9 +20,6 @@
package org.onap.aai.parsers.query;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
import java.io.UnsupportedEncodingException;
import org.onap.aai.config.SpringContextAware;
@@ -34,6 +31,8 @@ import org.onap.aai.introspection.ModelType;
import org.onap.aai.parsers.relationship.RelationshipToURI;
import org.onap.aai.parsers.uri.URIParser;
import org.onap.aai.query.builder.QueryBuilder;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
import org.springframework.context.ApplicationContext;
/**
diff --git a/aai-core/src/main/java/org/onap/aai/parsers/relationship/RelationshipToURI.java b/aai-core/src/main/java/org/onap/aai/parsers/relationship/RelationshipToURI.java
index 0ee22f50..8ed0fcb6 100644
--- a/aai-core/src/main/java/org/onap/aai/parsers/relationship/RelationshipToURI.java
+++ b/aai-core/src/main/java/org/onap/aai/parsers/relationship/RelationshipToURI.java
@@ -20,9 +20,6 @@
package org.onap.aai.parsers.relationship;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
import java.io.UnsupportedEncodingException;
import java.net.URI;
import java.net.URISyntaxException;
@@ -50,6 +47,8 @@ import org.onap.aai.parsers.exceptions.AmbiguousMapAAIException;
import org.onap.aai.parsers.uri.URIParser;
import org.onap.aai.schema.enums.ObjectMetadata;
import org.onap.aai.setup.SchemaVersions;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
import org.springframework.context.ApplicationContext;
/**
diff --git a/aai-core/src/main/java/org/onap/aai/parsers/uri/URIParser.java b/aai-core/src/main/java/org/onap/aai/parsers/uri/URIParser.java
index 80643429..3ca20c5e 100644
--- a/aai-core/src/main/java/org/onap/aai/parsers/uri/URIParser.java
+++ b/aai-core/src/main/java/org/onap/aai/parsers/uri/URIParser.java
@@ -52,7 +52,7 @@ public class URIParser {
private URI originalURI = null;
private MultivaluedMap<String, String> queryParams = null;
-
+
private static String aaiExceptionCode = "AAI_3001";
/**
diff --git a/aai-core/src/main/java/org/onap/aai/prevalidation/Validation.java b/aai-core/src/main/java/org/onap/aai/prevalidation/Validation.java
index d420c558..db1e36b5 100644
--- a/aai-core/src/main/java/org/onap/aai/prevalidation/Validation.java
+++ b/aai-core/src/main/java/org/onap/aai/prevalidation/Validation.java
@@ -19,6 +19,7 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
+
package org.onap.aai.prevalidation;
import com.google.gson.annotations.SerializedName;
@@ -70,9 +71,8 @@ public class Validation {
return false;
}
Validation that = (Validation) o;
- return Objects.equals(validationId, that.validationId) &&
- Objects.equals(action, that.action) &&
- Objects.equals(violations, that.violations);
+ return Objects.equals(validationId, that.validationId) && Objects.equals(action, that.action)
+ && Objects.equals(violations, that.violations);
}
@Override
@@ -82,11 +82,8 @@ public class Validation {
@Override
public String toString() {
- return "Validation{" +
- "validationId='" + validationId + '\'' +
- ", action='" + action + '\'' +
- ", violations=" + violations +
- '}';
+ return "Validation{" + "validationId='" + validationId + '\'' + ", action='" + action + '\'' + ", violations="
+ + violations + '}';
}
}
diff --git a/aai-core/src/main/java/org/onap/aai/prevalidation/ValidationConfiguration.java b/aai-core/src/main/java/org/onap/aai/prevalidation/ValidationConfiguration.java
index 36569dd0..7030cf7d 100644
--- a/aai-core/src/main/java/org/onap/aai/prevalidation/ValidationConfiguration.java
+++ b/aai-core/src/main/java/org/onap/aai/prevalidation/ValidationConfiguration.java
@@ -19,6 +19,7 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
+
package org.onap.aai.prevalidation;
import org.onap.aai.restclient.RestClient;
diff --git a/aai-core/src/main/java/org/onap/aai/prevalidation/ValidationService.java b/aai-core/src/main/java/org/onap/aai/prevalidation/ValidationService.java
index 29b31081..c66511f0 100644
--- a/aai-core/src/main/java/org/onap/aai/prevalidation/ValidationService.java
+++ b/aai-core/src/main/java/org/onap/aai/prevalidation/ValidationService.java
@@ -19,10 +19,12 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
+
package org.onap.aai.prevalidation;
import com.google.gson.Gson;
import com.google.gson.JsonSyntaxException;
+
import java.net.ConnectException;
import java.net.SocketTimeoutException;
import java.util.ArrayList;
@@ -34,7 +36,9 @@ import java.util.Set;
import java.util.UUID;
import java.util.regex.Pattern;
import java.util.stream.Collectors;
+
import javax.annotation.PostConstruct;
+
import org.apache.http.conn.ConnectTimeoutException;
import org.onap.aai.exceptions.AAIException;
import org.onap.aai.introspection.Introspector;
@@ -63,25 +67,24 @@ public class ValidationService {
* Error indicating that the service trying to connect is down
*/
static final String CONNECTION_REFUSED_STRING =
- "Connection refused to the validation microservice due to service unreachable";
+ "Connection refused to the validation microservice due to service unreachable";
/**
* Error indicating that the server is unable to reach the port
* Could be server related connectivity issue
*/
- static final String CONNECTION_TIMEOUT_STRING =
- "Connection timeout to the validation microservice as this could " +
- "indicate the server is unable to reach port, " +
- "please check on server by running: nc -w10 -z -v ${VALIDATION_HOST} ${VALIDATION_PORT}";
+ static final String CONNECTION_TIMEOUT_STRING = "Connection timeout to the validation microservice as this could "
+ + "indicate the server is unable to reach port, "
+ + "please check on server by running: nc -w10 -z -v ${VALIDATION_HOST} ${VALIDATION_PORT}";
/**
* Error indicating that the request exceeded the allowed time
*
* Note: This means that the service could be active its
- * just taking some time to process our request
+ * just taking some time to process our request
*/
static final String REQUEST_TIMEOUT_STRING =
- "Request to validation service took longer than the currently set timeout";
+ "Request to validation service took longer than the currently set timeout";
static final String VALIDATION_ENDPOINT = "/v1/validate";
static final String VALIDATION_HEALTH_ENDPOINT = "/v1/info";
@@ -105,26 +108,20 @@ public class ValidationService {
private final Gson gson;
@Autowired
- public ValidationService(
- @Qualifier("validationRestClient") RestClient validationRestClient,
- @Value("${spring.application.name}") String appName,
- @Value("${validation.service.node-types}") String validationNodes,
- @Value("${validation.service.exclusion-regexes}") String exclusionRegexes
- ){
+ public ValidationService(@Qualifier("validationRestClient") RestClient validationRestClient,
+ @Value("${spring.application.name}") String appName,
+ @Value("${validation.service.node-types}") String validationNodes,
+ @Value("${validation.service.exclusion-regexes}") String exclusionRegexes) {
this.validationRestClient = validationRestClient;
this.appName = appName;
- this.validationNodeTypes = Arrays
- .stream(validationNodes.split(","))
- .collect(Collectors.toSet());
+ this.validationNodeTypes = Arrays.stream(validationNodes.split(",")).collect(Collectors.toSet());
- if(exclusionRegexes == null || exclusionRegexes.isEmpty()){
+ if (exclusionRegexes == null || exclusionRegexes.isEmpty()) {
this.exclusionList = new ArrayList<>();
} else {
- this.exclusionList = Arrays
- .stream(exclusionRegexes.split(","))
- .map(Pattern::compile)
- .collect(Collectors.toList());
+ this.exclusionList =
+ Arrays.stream(exclusionRegexes.split(",")).map(Pattern::compile).collect(Collectors.toList());
}
this.gson = new Gson();
LOGGER.info("Successfully initialized the pre validation service");
@@ -143,32 +140,28 @@ public class ValidationService {
try {
- healthCheckResponse = validationRestClient.execute(
- VALIDATION_HEALTH_ENDPOINT,
- HttpMethod.GET,
- httpHeaders,
- null
- );
+ healthCheckResponse =
+ validationRestClient.execute(VALIDATION_HEALTH_ENDPOINT, HttpMethod.GET, httpHeaders, null);
- } catch(Exception ex){
+ } catch (Exception ex) {
AAIException validationException = new AAIException("AAI_4021", ex);
throw validationException;
}
- if(!isSuccess(healthCheckResponse)){
+ if (!isSuccess(healthCheckResponse)) {
throw new AAIException("AAI_4021");
}
LOGGER.info("Successfully connected to the validation service endpoint");
}
- public boolean shouldValidate(String nodeType){
+ public boolean shouldValidate(String nodeType) {
return this.validationNodeTypes.contains(nodeType);
}
public void validate(List<NotificationEvent> notificationEvents) throws AAIException {
- if(notificationEvents == null || notificationEvents.isEmpty()){
+ if (notificationEvents == null || notificationEvents.isEmpty()) {
return;
}
@@ -177,10 +170,10 @@ public class ValidationService {
// is in one of the regexes then we skip sending it to validation
NotificationEvent notification = notificationEvents.get(0);
Introspector eventHeader = notification.getEventHeader();
- if(eventHeader != null){
+ if (eventHeader != null) {
String source = eventHeader.getValue(SOURCE_NAME);
- for(Pattern pattern: exclusionList){
- if(pattern.matcher(source).matches()){
+ for (Pattern pattern : exclusionList) {
+ if (pattern.matcher(source).matches()) {
return;
}
}
@@ -192,7 +185,7 @@ public class ValidationService {
Introspector eventHeader = event.getEventHeader();
- if(eventHeader == null){
+ if (eventHeader == null) {
// Should I skip processing the request and let it continue
// or fail the request and cause client impact
continue;
@@ -205,13 +198,13 @@ public class ValidationService {
* Skipping the delete events for now
* Note: Might revisit this later when validation supports DELETE events
*/
- if(DELETE.equalsIgnoreCase(action)){
+ if (DELETE.equalsIgnoreCase(action)) {
continue;
}
if (this.shouldValidate(entityType)) {
List<String> violations = this.preValidate(event.getNotificationEvent());
- if(!violations.isEmpty()){
+ if (!violations.isEmpty()) {
AAIException aaiException = new AAIException("AAI_4019");
aaiException.getTemplateVars().addAll(violations);
throw aaiException;
@@ -232,47 +225,40 @@ public class ValidationService {
ResponseEntity responseEntity;
try {
- responseEntity = validationRestClient.execute(
- VALIDATION_ENDPOINT,
- HttpMethod.POST,
- httpHeaders,
- body
- );
+ responseEntity = validationRestClient.execute(VALIDATION_ENDPOINT, HttpMethod.POST, httpHeaders, body);
Object responseBody = responseEntity.getBody();
- if(isSuccess(responseEntity)){
- LOGGER.debug("Validation Service returned following response status code {} and body {}", responseEntity.getStatusCodeValue(), responseEntity.getBody());
+ if (isSuccess(responseEntity)) {
+ LOGGER.debug("Validation Service returned following response status code {} and body {}",
+ responseEntity.getStatusCodeValue(), responseEntity.getBody());
} else if (responseBody != null) {
Validation validation = null;
try {
validation = gson.fromJson(responseBody.toString(), Validation.class);
- } catch(JsonSyntaxException jsonException){
+ } catch (JsonSyntaxException jsonException) {
LOGGER.warn("Unable to convert the response body {}", jsonException.getMessage());
}
- if(validation == null){
- LOGGER.debug(
- "Validation Service following status code {} with body {}",
- responseEntity.getStatusCodeValue(),
- responseEntity.getBody()
- );
+ if (validation == null) {
+ LOGGER.debug("Validation Service following status code {} with body {}",
+ responseEntity.getStatusCodeValue(), responseEntity.getBody());
} else {
violations.addAll(extractViolations(validation));
}
} else {
LOGGER.warn("Unable to convert the response body null");
}
- } catch(Exception e){
+ } catch (Exception e) {
// If the exception cause is client side timeout
// then proceed as if it passed validation
// resources microservice shouldn't be blocked because of validation service
// is taking too long or if the validation service is down
// Any other exception it should block the request from passing?
- if(e.getCause() instanceof SocketTimeoutException){
+ if (e.getCause() instanceof SocketTimeoutException) {
LOGGER.error(REQUEST_TIMEOUT_STRING, e.getCause());
- } else if(e.getCause() instanceof ConnectException){
+ } else if (e.getCause() instanceof ConnectException) {
LOGGER.error(CONNECTION_REFUSED_STRING, e.getCause());
- } else if(e.getCause() instanceof ConnectTimeoutException){
+ } else if (e.getCause() instanceof ConnectTimeoutException) {
LOGGER.error(CONNECTION_TIMEOUT_STRING, e.getCause());
} else {
LOGGER.error("Unknown exception thrown please investigate", e.getCause());
@@ -281,7 +267,7 @@ public class ValidationService {
return violations;
}
- boolean isSuccess(ResponseEntity responseEntity){
+ boolean isSuccess(ResponseEntity responseEntity) {
return responseEntity != null && responseEntity.getStatusCode().is2xxSuccessful();
}
@@ -289,7 +275,7 @@ public class ValidationService {
List<String> errorMessages = new ArrayList<>();
- if(validation == null){
+ if (validation == null) {
return errorMessages;
}
diff --git a/aai-core/src/main/java/org/onap/aai/prevalidation/ValidationServiceNoAuthClient.java b/aai-core/src/main/java/org/onap/aai/prevalidation/ValidationServiceNoAuthClient.java
index 6173e4bd..f899e9fe 100644
--- a/aai-core/src/main/java/org/onap/aai/prevalidation/ValidationServiceNoAuthClient.java
+++ b/aai-core/src/main/java/org/onap/aai/prevalidation/ValidationServiceNoAuthClient.java
@@ -20,20 +20,19 @@
package org.onap.aai.prevalidation;
+import java.util.Collections;
+import java.util.Map;
+import java.util.UUID;
+
+import org.onap.aai.restclient.NoAuthRestClient;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import org.onap.aai.restclient.NoAuthRestClient;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.http.HttpHeaders;
import org.springframework.http.MediaType;
-import org.springframework.http.client.ClientHttpRequestFactory;
import org.springframework.http.client.HttpComponentsClientHttpRequestFactory;
import org.springframework.util.MultiValueMap;
-import java.util.Collections;
-import java.util.Map;
-import java.util.UUID;
-
public class ValidationServiceNoAuthClient extends NoAuthRestClient {
private static Logger logger = LoggerFactory.getLogger(ValidationServiceNoAuthClient.class);
diff --git a/aai-core/src/main/java/org/onap/aai/prevalidation/ValidationServiceOneWayClient.java b/aai-core/src/main/java/org/onap/aai/prevalidation/ValidationServiceOneWayClient.java
index 40efd469..f72f6bcf 100644
--- a/aai-core/src/main/java/org/onap/aai/prevalidation/ValidationServiceOneWayClient.java
+++ b/aai-core/src/main/java/org/onap/aai/prevalidation/ValidationServiceOneWayClient.java
@@ -20,6 +20,10 @@
package org.onap.aai.prevalidation;
+import java.util.Collections;
+import java.util.Map;
+import java.util.UUID;
+
import org.onap.aai.restclient.OneWaySSLRestClient;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.http.HttpHeaders;
@@ -27,10 +31,6 @@ import org.springframework.http.MediaType;
import org.springframework.http.client.HttpComponentsClientHttpRequestFactory;
import org.springframework.util.MultiValueMap;
-import java.util.Collections;
-import java.util.Map;
-import java.util.UUID;
-
public class ValidationServiceOneWayClient extends OneWaySSLRestClient {
@Value("${validation.service.base.url}")
@@ -75,7 +75,7 @@ public class ValidationServiceOneWayClient extends OneWaySSLRestClient {
String defaultAccept = headers.getOrDefault(HttpHeaders.ACCEPT, MediaType.APPLICATION_JSON.toString());
String defaultContentType =
- headers.getOrDefault(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON.toString());
+ headers.getOrDefault(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON.toString());
if (headers.isEmpty()) {
httpHeaders.setAccept(Collections.singletonList(MediaType.parseMediaType(defaultAccept)));
diff --git a/aai-core/src/main/java/org/onap/aai/prevalidation/ValidationServiceRestClient.java b/aai-core/src/main/java/org/onap/aai/prevalidation/ValidationServiceRestClient.java
index 8674272e..af283063 100644
--- a/aai-core/src/main/java/org/onap/aai/prevalidation/ValidationServiceRestClient.java
+++ b/aai-core/src/main/java/org/onap/aai/prevalidation/ValidationServiceRestClient.java
@@ -22,6 +22,10 @@
package org.onap.aai.prevalidation;
+import java.util.Collections;
+import java.util.Map;
+import java.util.UUID;
+
import org.onap.aai.restclient.TwoWaySSLRestClient;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.http.HttpHeaders;
@@ -29,10 +33,6 @@ import org.springframework.http.MediaType;
import org.springframework.http.client.HttpComponentsClientHttpRequestFactory;
import org.springframework.util.MultiValueMap;
-import java.util.Collections;
-import java.util.Map;
-import java.util.UUID;
-
public class ValidationServiceRestClient extends TwoWaySSLRestClient {
@Value("${validation.service.base.url}")
diff --git a/aai-core/src/main/java/org/onap/aai/prevalidation/Violation.java b/aai-core/src/main/java/org/onap/aai/prevalidation/Violation.java
index e5472a7c..59b9f41f 100644
--- a/aai-core/src/main/java/org/onap/aai/prevalidation/Violation.java
+++ b/aai-core/src/main/java/org/onap/aai/prevalidation/Violation.java
@@ -94,14 +94,9 @@ public class Violation {
@Override
public String toString() {
- return "Violation{" +
- "violationId='" + violationId + '\'' +
- ", modelName='" + modelName + '\'' +
- ", category='" + category + '\'' +
- ", severity='" + severity + '\'' +
- ", violationType='" + violationType + '\'' +
- ", errorMessage='" + errorMessage + '\'' +
- '}';
+ return "Violation{" + "violationId='" + violationId + '\'' + ", modelName='" + modelName + '\'' + ", category='"
+ + category + '\'' + ", severity='" + severity + '\'' + ", violationType='" + violationType + '\''
+ + ", errorMessage='" + errorMessage + '\'' + '}';
}
@Override
@@ -113,12 +108,10 @@ public class Violation {
return false;
}
Violation violation = (Violation) o;
- return Objects.equals(violationId, violation.violationId) &&
- Objects.equals(modelName, violation.modelName) &&
- Objects.equals(category, violation.category) &&
- Objects.equals(severity, violation.severity) &&
- Objects.equals(violationType, violation.violationType) &&
- Objects.equals(errorMessage, violation.errorMessage);
+ return Objects.equals(violationId, violation.violationId) && Objects.equals(modelName, violation.modelName)
+ && Objects.equals(category, violation.category) && Objects.equals(severity, violation.severity)
+ && Objects.equals(violationType, violation.violationType)
+ && Objects.equals(errorMessage, violation.errorMessage);
}
@Override
diff --git a/aai-core/src/main/java/org/onap/aai/query/builder/GraphTraversalBuilder.java b/aai-core/src/main/java/org/onap/aai/query/builder/GraphTraversalBuilder.java
index 1dc3f1d6..2517e2c0 100644
--- a/aai-core/src/main/java/org/onap/aai/query/builder/GraphTraversalBuilder.java
+++ b/aai-core/src/main/java/org/onap/aai/query/builder/GraphTraversalBuilder.java
@@ -72,7 +72,7 @@ public abstract class GraphTraversalBuilder<E> extends QueryBuilder<E> {
* Instantiates a new graph traversal builder.
*
* @param loader the loader
- * @param start the start
+ * @param start the start
*/
public GraphTraversalBuilder(Loader loader, GraphTraversalSource source, Vertex start) {
super(loader, source, start);
@@ -108,12 +108,14 @@ public abstract class GraphTraversalBuilder<E> extends QueryBuilder<E> {
traversal.has(key);
}
- //TODO: Remove this once we test this - at this point i dont thib this is required
- //because predicare is an object
- /*@Override
- protected void vertexHas(final String key, final P<?> predicate) {
- traversal.has(key, predicate);
- }*/
+ // TODO: Remove this once we test this - at this point i dont thib this is required
+ // because predicare is an object
+ /*
+ * @Override
+ * protected void vertexHas(final String key, final P<?> predicate) {
+ * traversal.has(key, predicate);
+ * }
+ */
/**
* @{inheritDoc}
@@ -154,7 +156,7 @@ public abstract class GraphTraversalBuilder<E> extends QueryBuilder<E> {
public QueryBuilder<Vertex> getVerticesStartsWithProperty(String key, Object value) {
// correct value call because the index is registered as an Integer
- //TODO Check if this needs to be in QB and add these as internal
+ // TODO Check if this needs to be in QB and add these as internal
this.vertexHas(key, org.janusgraph.core.attribute.Text.textPrefix(value));
stepIndex++;
@@ -355,7 +357,7 @@ public abstract class GraphTraversalBuilder<E> extends QueryBuilder<E> {
*/
@Override
public QueryBuilder<Vertex> createEdgeTraversal(EdgeType type, Introspector parent, Introspector child)
- throws AAIException {
+ throws AAIException {
createTraversal(type, parent, child, false);
return (QueryBuilder<Vertex>) this;
@@ -363,13 +365,13 @@ public abstract class GraphTraversalBuilder<E> extends QueryBuilder<E> {
@Override
public QueryBuilder<Vertex> createPrivateEdgeTraversal(EdgeType type, Introspector parent, Introspector child)
- throws AAIException {
+ throws AAIException {
this.createTraversal(type, parent, child, true);
return (QueryBuilder<Vertex>) this;
}
private void createTraversal(EdgeType type, Introspector parent, Introspector child, boolean isPrivateEdge)
- throws AAIException {
+ throws AAIException {
String isAbstractType = parent.getMetadata(ObjectMetadata.ABSTRACT);
if ("true".equals(isAbstractType)) {
markParentBoundary();
@@ -385,13 +387,13 @@ public abstract class GraphTraversalBuilder<E> extends QueryBuilder<E> {
*/
@Override
public QueryBuilder<Vertex> createEdgeTraversalWithLabels(EdgeType type, Introspector out, Introspector in,
- List<String> labels) throws AAIException {
+ List<String> labels) throws AAIException {
this.edgeQueryToVertex(type, out, in, labels);
return (QueryBuilder<Vertex>) this;
}
private Traversal<Vertex, Vertex>[] handleAbstractEdge(EdgeType type, Introspector abstractParent,
- Introspector child, boolean isPrivateEdge) throws AAIException {
+ Introspector child, boolean isPrivateEdge) throws AAIException {
String childName = child.getDbName();
String inheritorMetadata = abstractParent.getMetadata(ObjectMetadata.INHERITORS);
String[] inheritors = inheritorMetadata.split(",");
@@ -427,7 +429,7 @@ public abstract class GraphTraversalBuilder<E> extends QueryBuilder<E> {
innerTraversal.in(inLabels.toArray(new String[inLabels.size()]));
} else {
innerTraversal.union(__.out(outLabels.toArray(new String[outLabels.size()])),
- __.in(inLabels.toArray(new String[inLabels.size()])));
+ __.in(inLabels.toArray(new String[inLabels.size()])));
}
innerTraversal.has(AAIProperties.NODE_TYPE, childName);
@@ -439,7 +441,7 @@ public abstract class GraphTraversalBuilder<E> extends QueryBuilder<E> {
}
public QueryBuilder<Edge> getEdgesBetweenWithLabels(EdgeType type, String outNodeType, String inNodeType,
- List<String> labels) throws AAIException {
+ List<String> labels) throws AAIException {
Introspector outObj = loader.introspectorFromName(outNodeType);
Introspector inObj = loader.introspectorFromName(inNodeType);
this.edgeQuery(type, outObj, inObj, labels);
@@ -600,7 +602,6 @@ public abstract class GraphTraversalBuilder<E> extends QueryBuilder<E> {
return this;
}
-
/**
* {@inheritDoc}
*/
@@ -694,12 +695,12 @@ public abstract class GraphTraversalBuilder<E> extends QueryBuilder<E> {
* Edge query.
*
* @param outObj the out type
- * @param inObj the in type
+ * @param inObj the in type
* @throws NoEdgeRuleFoundException
* @throws AAIException
*/
private void edgeQueryToVertex(EdgeType type, Introspector outObj, Introspector inObj, List<String> labels)
- throws AAIException {
+ throws AAIException {
String outType = outObj.getDbName();
String inType = inObj.getDbName();
@@ -731,7 +732,7 @@ public abstract class GraphTraversalBuilder<E> extends QueryBuilder<E> {
}
if (rules.isEmpty()) {
throw new NoEdgeRuleFoundException(
- "No edge rules found for " + outType + " and " + inType + " of type " + type.toString());
+ "No edge rules found for " + outType + " and " + inType + " of type " + type.toString());
}
}
@@ -756,7 +757,7 @@ public abstract class GraphTraversalBuilder<E> extends QueryBuilder<E> {
traversal.in(inLabels.toArray(new String[inLabels.size()]));
} else {
traversal.union(__.out(outLabels.toArray(new String[outLabels.size()])),
- __.in(inLabels.toArray(new String[inLabels.size()])));
+ __.in(inLabels.toArray(new String[inLabels.size()])));
}
stepIndex++;
@@ -769,12 +770,12 @@ public abstract class GraphTraversalBuilder<E> extends QueryBuilder<E> {
* Edge query.
*
* @param outObj the out type
- * @param inObj the in type
+ * @param inObj the in type
* @throws NoEdgeRuleFoundException
* @throws AAIException
*/
private void edgeQuery(EdgeType type, Introspector outObj, Introspector inObj, List<String> labels)
- throws AAIException {
+ throws AAIException {
String outType = outObj.getDbName();
String inType = inObj.getDbName();
@@ -822,7 +823,7 @@ public abstract class GraphTraversalBuilder<E> extends QueryBuilder<E> {
traversal.inE(inLabels.toArray(new String[inLabels.size()]));
} else {
traversal.union(__.outE(outLabels.toArray(new String[outLabels.size()])),
- __.inE(inLabels.toArray(new String[inLabels.size()])));
+ __.inE(inLabels.toArray(new String[inLabels.size()])));
}
}
diff --git a/aai-core/src/main/java/org/onap/aai/query/builder/GremlinQueryBuilder.java b/aai-core/src/main/java/org/onap/aai/query/builder/GremlinQueryBuilder.java
index 712a1ddb..4500a47e 100644
--- a/aai-core/src/main/java/org/onap/aai/query/builder/GremlinQueryBuilder.java
+++ b/aai-core/src/main/java/org/onap/aai/query/builder/GremlinQueryBuilder.java
@@ -22,8 +22,6 @@
package org.onap.aai.query.builder;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
import com.google.common.base.Joiner;
import com.google.common.collect.ArrayListMultimap;
import com.google.common.collect.Multimap;
@@ -48,6 +46,8 @@ import org.onap.aai.introspection.Loader;
import org.onap.aai.restcore.search.GremlinGroovyShell;
import org.onap.aai.schema.enums.ObjectMetadata;
import org.onap.aai.serialization.db.exceptions.NoEdgeRuleFoundException;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
/**
* The Class GremlinQueryBuilder.
@@ -85,7 +85,6 @@ public abstract class GremlinQueryBuilder<E> extends QueryBuilder<E> {
list = new ArrayList<>();
}
-
@Override
public QueryBuilder<Vertex> exactMatchQuery(Introspector obj) {
// TODO not implemented because this is implementation is no longer used
@@ -121,7 +120,7 @@ public abstract class GremlinQueryBuilder<E> extends QueryBuilder<E> {
String valueString = value.toString();
if (valueString.indexOf('\'') != -1) {
- value = valueString.replace(SINGLE_QUOTE, ESCAPE_SINGLE_QUOTE);
+ value = valueString.replace(SINGLE_QUOTE, ESCAPE_SINGLE_QUOTE);
}
LOGGER.trace("Inside getVerticesByProperty(): key = {}, value = {}", key, value);
term = value.toString();
@@ -129,7 +128,7 @@ public abstract class GremlinQueryBuilder<E> extends QueryBuilder<E> {
String valueString = value.toString();
if (valueString.indexOf('\'') != -1) {
- value = valueString.replace(SINGLE_QUOTE, ESCAPE_SINGLE_QUOTE);
+ value = valueString.replace(SINGLE_QUOTE, ESCAPE_SINGLE_QUOTE);
}
LOGGER.trace("Inside getVerticesByProperty(): key = {}, value = {}", key, value);
term = "'" + value + "'";
@@ -189,22 +188,20 @@ public abstract class GremlinQueryBuilder<E> extends QueryBuilder<E> {
stepIndex++;
return (QueryBuilder<Vertex>) this;
}
-
+
/**
* @{inheritDoc}
*/
@Override
public QueryBuilder<Vertex> getVerticesByCommaSeperatedValue(String key, String value) {
ArrayList<String> arguments = new ArrayList<>(Arrays.asList(value.split(",")));
- //add the single quotes
+ // add the single quotes
for (int i = 0; i < arguments.size(); i++) {
- if(arguments.get(i) != null && !arguments.get(i).startsWith("'")
- && !arguments.get(i).endsWith("'")) {
- arguments.set(i,"'" + arguments.get(i).trim() + "'");
- }
- else {
- arguments.set(i, arguments.get(i).trim());
- }
+ if (arguments.get(i) != null && !arguments.get(i).startsWith("'") && !arguments.get(i).endsWith("'")) {
+ arguments.set(i, "'" + arguments.get(i).trim() + "'");
+ } else {
+ arguments.set(i, arguments.get(i).trim());
+ }
}
String predicate = "P.within(#!#argument#!#)";
String argument = Joiner.on(",").join(arguments);
@@ -339,7 +336,7 @@ public abstract class GremlinQueryBuilder<E> extends QueryBuilder<E> {
public QueryBuilder<Vertex> getTypedVerticesByMap(String type, Map<String, String> map) {
for (Map.Entry<String, String> es : map.entrySet()) {
- //TODO what is this and where is it used - need to check
+ // TODO what is this and where is it used - need to check
list.add(HAS + es.getKey() + "', '" + es.getValue() + "')");
stepIndex++;
}
@@ -729,7 +726,7 @@ public abstract class GremlinQueryBuilder<E> extends QueryBuilder<E> {
return this;
}
-
+
@Override
public QueryBuilder<E> valueMap() {
this.list.add(".valueMap()");
@@ -737,23 +734,22 @@ public abstract class GremlinQueryBuilder<E> extends QueryBuilder<E> {
return this;
}
-
+
@Override
public QueryBuilder<E> valueMap(String... names) {
- String stepString = ".valueMap('";
- for (int i = 0; i < names.length; i++) {
- stepString = stepString + names[i] + "'";
- if (i != (names.length - 1)) {
- stepString = stepString + ",'";
- }
- }
- stepString = stepString + ")";
- this.list.add(stepString);
- stepIndex++;
+ String stepString = ".valueMap('";
+ for (int i = 0; i < names.length; i++) {
+ stepString = stepString + names[i] + "'";
+ if (i != (names.length - 1)) {
+ stepString = stepString + ",'";
+ }
+ }
+ stepString = stepString + ")";
+ this.list.add(stepString);
+ stepIndex++;
- return this;
+ return this;
}
-
/**
* {@inheritDoc}
@@ -955,5 +951,4 @@ public abstract class GremlinQueryBuilder<E> extends QueryBuilder<E> {
* This is required for the subgraphstrategies to work
*/
-
}
diff --git a/aai-core/src/main/java/org/onap/aai/query/builder/GremlinTraversal.java b/aai-core/src/main/java/org/onap/aai/query/builder/GremlinTraversal.java
index 9cd35ab9..710db480 100644
--- a/aai-core/src/main/java/org/onap/aai/query/builder/GremlinTraversal.java
+++ b/aai-core/src/main/java/org/onap/aai/query/builder/GremlinTraversal.java
@@ -61,7 +61,6 @@ public class GremlinTraversal<E> extends GremlinQueryBuilder<E> {
this.factory = new TraversalStrategy(this.loader, this);
}
-
protected GremlinTraversal(List<String> traversal, Loader loader, GraphTraversalSource source,
GremlinQueryBuilder<E> gtb) {
super(loader, source);
diff --git a/aai-core/src/main/java/org/onap/aai/query/builder/HistoryGremlinTraversal.java b/aai-core/src/main/java/org/onap/aai/query/builder/HistoryGremlinTraversal.java
index 5b14995c..49772b08 100644
--- a/aai-core/src/main/java/org/onap/aai/query/builder/HistoryGremlinTraversal.java
+++ b/aai-core/src/main/java/org/onap/aai/query/builder/HistoryGremlinTraversal.java
@@ -20,21 +20,20 @@
package org.onap.aai.query.builder;
+import java.io.UnsupportedEncodingException;
+import java.net.URI;
+import java.util.ArrayList;
+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.process.traversal.dsl.graph.__;
import org.apache.tinkerpop.gremlin.structure.Vertex;
import org.onap.aai.db.props.AAIProperties;
import org.onap.aai.exceptions.AAIException;
import org.onap.aai.introspection.Introspector;
import org.onap.aai.introspection.Loader;
import org.onap.aai.parsers.query.QueryParser;
-import org.onap.aai.parsers.query.TraversalStrategy;
-
-import javax.ws.rs.core.MultivaluedMap;
-import java.io.UnsupportedEncodingException;
-import java.net.URI;
-import java.util.ArrayList;
-import java.util.List;
/**
* The Class GremlinTraversal.
@@ -60,9 +59,8 @@ public class HistoryGremlinTraversal<E> extends GremlinTraversal<E> {
super(loader, source, start);
}
-
protected HistoryGremlinTraversal(List<String> traversal, Loader loader, GraphTraversalSource source,
- GremlinQueryBuilder<E> gtb) {
+ GremlinQueryBuilder<E> gtb) {
super(traversal, loader, source, gtb);
}
@@ -155,15 +153,15 @@ public class HistoryGremlinTraversal<E> extends GremlinTraversal<E> {
/*
* This is required for the subgraphstrategies to work
*/
- private void touchHistoryProperties(String key){
- if(key != null && !key.isEmpty() && !key.equals(AAIProperties.NODE_TYPE)) {
+ private void touchHistoryProperties(String key) {
+ if (key != null && !key.isEmpty() && !key.equals(AAIProperties.NODE_TYPE)) {
list.add(".where(__.properties('" + key + "'))");
}
}
private void touchHistoryProperties(String key, Object value) {
- if(key != null && !key.isEmpty() && !key.equals(AAIProperties.NODE_TYPE)) {
+ if (key != null && !key.isEmpty() && !key.equals(AAIProperties.NODE_TYPE)) {
list.add(".where(__.properties('" + key + "').hasValue(" + value + "))");
}
}
diff --git a/aai-core/src/main/java/org/onap/aai/query/builder/HistoryTraversalURIOptimizedQuery.java b/aai-core/src/main/java/org/onap/aai/query/builder/HistoryTraversalURIOptimizedQuery.java
index 119f8522..c30850ce 100644
--- a/aai-core/src/main/java/org/onap/aai/query/builder/HistoryTraversalURIOptimizedQuery.java
+++ b/aai-core/src/main/java/org/onap/aai/query/builder/HistoryTraversalURIOptimizedQuery.java
@@ -21,6 +21,7 @@
package org.onap.aai.query.builder;
import java.util.Map;
+
import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversal;
import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource;
import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.__;
@@ -39,12 +40,12 @@ public class HistoryTraversalURIOptimizedQuery<E> extends TraversalURIOptimizedQ
}
protected HistoryTraversalURIOptimizedQuery(GraphTraversal traversal, Loader loader, GraphTraversalSource source,
- GraphTraversalBuilder gtb) {
+ GraphTraversalBuilder gtb) {
super(traversal, loader, source, gtb);
}
protected HistoryTraversalURIOptimizedQuery(GraphTraversal traversal, Loader loader, GraphTraversalSource source,
- GraphTraversalBuilder gtb, Map<Integer, String> stepToAaiUri) {
+ GraphTraversalBuilder gtb, Map<Integer, String> stepToAaiUri) {
super(traversal, loader, source, gtb, stepToAaiUri);
}
diff --git a/aai-core/src/main/java/org/onap/aai/query/builder/QueryBuilder.java b/aai-core/src/main/java/org/onap/aai/query/builder/QueryBuilder.java
index 007f9798..423583f4 100644
--- a/aai-core/src/main/java/org/onap/aai/query/builder/QueryBuilder.java
+++ b/aai-core/src/main/java/org/onap/aai/query/builder/QueryBuilder.java
@@ -20,6 +20,14 @@
package org.onap.aai.query.builder;
+import java.io.UnsupportedEncodingException;
+import java.net.URI;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+
+import javax.ws.rs.core.MultivaluedMap;
+
import org.apache.tinkerpop.gremlin.process.traversal.Path;
import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource;
import org.apache.tinkerpop.gremlin.process.traversal.step.util.Tree;
@@ -38,13 +46,6 @@ import org.onap.aai.parsers.query.QueryParser;
import org.onap.aai.parsers.query.QueryParserStrategy;
import org.springframework.context.ApplicationContext;
-import javax.ws.rs.core.MultivaluedMap;
-import java.io.UnsupportedEncodingException;
-import java.net.URI;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-
/**
* The Class QueryBuilder.
*/
@@ -111,7 +112,6 @@ public abstract class QueryBuilder<E> implements Iterator<E> {
*/
public abstract QueryBuilder<Vertex> getVerticesByProperty(String key, Object value);
-
/**
* Gets the edges by property.
*
@@ -374,7 +374,7 @@ public abstract class QueryBuilder<E> implements Iterator<E> {
* @throws AAIException
*/
public QueryBuilder<Vertex> createEdgeTraversalWithLabels(MissingOptionalParameter edgeType, String outNodeType,
- String inNodeType, List<String> labels) throws AAIException {
+ String inNodeType, List<String> labels) throws AAIException {
/*
* When no optional parameter edgetype is sent get all edges between the 2 nodetypes
*/
@@ -413,7 +413,8 @@ public abstract class QueryBuilder<E> implements Iterator<E> {
return queryBuilder;
}
- public QueryBuilder<Vertex> createEdgeTraversalWithLabels(String outNodeType, String inNodeType, List<String> labels) throws AAIException {
+ public QueryBuilder<Vertex> createEdgeTraversalWithLabels(String outNodeType, String inNodeType,
+ List<String> labels) throws AAIException {
Introspector out = loader.introspectorFromName(outNodeType);
Introspector in = loader.introspectorFromName(inNodeType);
@@ -480,13 +481,13 @@ public abstract class QueryBuilder<E> implements Iterator<E> {
public abstract QueryBuilder<Vertex> createEdgeTraversalWithLabels(EdgeType type, Introspector out, Introspector in,
List<String> labels) throws AAIException;
-
/**
* This method and it's overloaded counterpart are conditional statements.
* This method creates an edge traversal step if an optional property is present
* This is necessary in cases such as "if the Optional Property 1 is sent,
* find all Nodes of type A with edges to Nodes of type B with property 1,
* otherwise, simply find all nodes of type A".
+ *
* @param type
* @param outNodeType
* @param inNodeType
@@ -494,9 +495,9 @@ public abstract class QueryBuilder<E> implements Iterator<E> {
* @return
* @throws AAIException
*/
- public QueryBuilder<Vertex> createEdgeTraversalIfParameterIsPresent(EdgeType type, String outNodeType, String inNodeType,
- Object value) throws AAIException {
- return this.createEdgeTraversal(type, outNodeType, inNodeType);
+ public QueryBuilder<Vertex> createEdgeTraversalIfParameterIsPresent(EdgeType type, String outNodeType,
+ String inNodeType, Object value) throws AAIException {
+ return this.createEdgeTraversal(type, outNodeType, inNodeType);
}
/**
@@ -505,6 +506,7 @@ public abstract class QueryBuilder<E> implements Iterator<E> {
* This is necessary in cases such as "if the Optional Property 1 is sent,
* find all Nodes of type A with edges to Nodes of type B with property 1,
* otherwise, simply find all nodes of type A".
+ *
* @param type
* @param outNodeType
* @param inNodeType
@@ -512,9 +514,9 @@ public abstract class QueryBuilder<E> implements Iterator<E> {
* @return
* @throws AAIException
*/
- public QueryBuilder<Vertex> createEdgeTraversalIfParameterIsPresent(EdgeType type, String outNodeType, String inNodeType,
- MissingOptionalParameter value) throws AAIException {
- return (QueryBuilder<Vertex>) this;
+ public QueryBuilder<Vertex> createEdgeTraversalIfParameterIsPresent(EdgeType type, String outNodeType,
+ String inNodeType, MissingOptionalParameter value) throws AAIException {
+ return (QueryBuilder<Vertex>) this;
}
/**
@@ -783,12 +785,12 @@ public abstract class QueryBuilder<E> implements Iterator<E> {
return getVerticesByProperty(key, value);
}
- protected abstract void vertexHas(String key, Object value) ;
+ protected abstract void vertexHas(String key, Object value);
protected abstract void vertexHasNot(String key);
protected abstract void vertexHas(String key);
- //TODO: This probably is not required but need to test
+ // TODO: This probably is not required but need to test
// protected abstract void vertexHas(final String key, final P<?> predicate);
}
diff --git a/aai-core/src/main/java/org/onap/aai/rest/db/HttpEntry.java b/aai-core/src/main/java/org/onap/aai/rest/db/HttpEntry.java
index 554ecb36..28d66dd0 100644
--- a/aai-core/src/main/java/org/onap/aai/rest/db/HttpEntry.java
+++ b/aai-core/src/main/java/org/onap/aai/rest/db/HttpEntry.java
@@ -20,13 +20,23 @@
package org.onap.aai.rest.db;
-import org.onap.aai.introspection.sideeffect.OwnerCheck;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.github.fge.jsonpatch.JsonPatchException;
import com.github.fge.jsonpatch.mergepatch.JsonMergePatch;
+
+import java.io.IOException;
+import java.io.UnsupportedEncodingException;
+import java.lang.reflect.InvocationTargetException;
+import java.net.MalformedURLException;
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.util.*;
+import java.util.stream.Collectors;
+
+import javax.ws.rs.core.*;
+import javax.ws.rs.core.Response.Status;
+
import org.apache.tinkerpop.gremlin.structure.Vertex;
import org.janusgraph.core.JanusGraphException;
import org.javatuples.Pair;
@@ -35,6 +45,7 @@ import org.onap.aai.db.props.AAIProperties;
import org.onap.aai.exceptions.AAIException;
import org.onap.aai.introspection.*;
import org.onap.aai.introspection.exceptions.AAIUnknownObjectException;
+import org.onap.aai.introspection.sideeffect.OwnerCheck;
import org.onap.aai.logging.ErrorLogHelper;
import org.onap.aai.nodes.NodeIngestor;
import org.onap.aai.parsers.query.QueryParser;
@@ -56,20 +67,10 @@ import org.onap.aai.transforms.XmlFormatTransformer;
import org.onap.aai.util.AAIConfig;
import org.onap.aai.util.AAIConstants;
import org.onap.aai.util.delta.DeltaEvents;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
-import org.springframework.http.ResponseEntity;
-
-import javax.ws.rs.core.*;
-import javax.ws.rs.core.Response.Status;
-import java.io.IOException;
-import java.io.UnsupportedEncodingException;
-import java.lang.reflect.InvocationTargetException;
-import java.net.MalformedURLException;
-import java.net.URI;
-import java.net.URISyntaxException;
-import java.util.*;
-import java.util.stream.Collectors;
/**
* The Class HttpEntry.
@@ -187,7 +188,8 @@ public class HttpEntry {
return this;
}
- public HttpEntry setHttpEntryProperties(SchemaVersion version, UEBNotification notification, int notificationDepth) {
+ public HttpEntry setHttpEntryProperties(SchemaVersion version, UEBNotification notification,
+ int notificationDepth) {
this.version = version;
this.loader = loaderFactory.createLoaderForVersion(introspectorFactoryType, version);
this.dbEngine = new JanusGraphDBEngine(queryStyle, loader);
@@ -244,10 +246,8 @@ public class HttpEntry {
return dbEngine;
}
- public Pair<Boolean, List<Pair<URI, Response>>> process(List<DBRequest> requests,
- String sourceOfTruth,
- Set<String> groups)
- throws AAIException {
+ public Pair<Boolean, List<Pair<URI, Response>>> process(List<DBRequest> requests, String sourceOfTruth,
+ Set<String> groups) throws AAIException {
return this.process(requests, sourceOfTruth, groups, true);
}
@@ -347,21 +347,21 @@ public class HttpEntry {
* @throws AAIException the AAI exception
*/
public Pair<Boolean, List<Pair<URI, Response>>> process(List<DBRequest> requests, String sourceOfTruth,
- boolean enableResourceVersion) throws AAIException {
+ boolean enableResourceVersion) throws AAIException {
return this.process(requests, sourceOfTruth, Collections.EMPTY_SET, enableResourceVersion);
}
- private Pair<Boolean, List<Pair<URI, Response>>> process(List<DBRequest> requests,
- String sourceOfTruth,
- Set<String> groups,
- boolean enableResourceVersion) throws AAIException {
+ private Pair<Boolean, List<Pair<URI, Response>>> process(List<DBRequest> requests, String sourceOfTruth,
+ Set<String> groups, boolean enableResourceVersion) throws AAIException {
DBSerializer serializer = null;
- if(serverBase != null){
- serializer = new DBSerializer(version, dbEngine, introspectorFactoryType, sourceOfTruth, groups, notificationDepth, serverBase);
+ if (serverBase != null) {
+ serializer = new DBSerializer(version, dbEngine, introspectorFactoryType, sourceOfTruth, groups,
+ notificationDepth, serverBase);
} else {
- serializer = new DBSerializer(version, dbEngine, introspectorFactoryType, sourceOfTruth, groups, notificationDepth);
+ serializer = new DBSerializer(version, dbEngine, introspectorFactoryType, sourceOfTruth, groups,
+ notificationDepth);
}
Response response;
@@ -383,7 +383,7 @@ public class HttpEntry {
String outputMediaType = null;
- if(requests != null && !requests.isEmpty()){
+ if (requests != null && !requests.isEmpty()) {
HttpHeaders headers = requests.get(0).getHeaders();
outputMediaType = getMediaType(headers.getAcceptableMediaTypes());
}
@@ -451,8 +451,8 @@ public class HttpEntry {
String resourceVersion = obj.getValue(AAIProperties.RESOURCE_VERSION);
if (vertices.isEmpty()) {
if (enableResourceVersion) {
- serializer.verifyResourceVersion("create", query.getResultType(), "",
- resourceVersion, obj.getURI());
+ serializer.verifyResourceVersion("create", query.getResultType(), "", resourceVersion,
+ obj.getURI());
}
isNewVertex = true;
} else {
@@ -477,10 +477,13 @@ public class HttpEntry {
}
/*
- * This skip-related-to query parameter is used to determine if the relationships object will omit the related-to-property
- * If a GET is sent to resources without a format, if format=resource, or if format=resource_and_url with this param set to false
+ * This skip-related-to query parameter is used to determine if the relationships object will omit
+ * the related-to-property
+ * If a GET is sent to resources without a format, if format=resource, or if format=resource_and_url
+ * with this param set to false
* then behavior will be keep the related-to properties. By default, set to true.
- * Otherwise, for any other case, when the skip-related-to parameter exists, has value=true, or some unfamiliar input (e.g. skip-related-to=bogusvalue), the value is true.
+ * Otherwise, for any other case, when the skip-related-to parameter exists, has value=true, or some
+ * unfamiliar input (e.g. skip-related-to=bogusvalue), the value is true.
*/
boolean isSkipRelatedTo = true;
if (params.containsKey("skip-related-to")) {
@@ -498,27 +501,29 @@ public class HttpEntry {
case GET:
if (format == null) {
- obj = this.getObjectFromDb(vertices, serializer, query, obj, request.getUri(),
- depth, isNodeOnly, cleanUp, isSkipRelatedTo);
+ obj = this.getObjectFromDb(vertices, serializer, query, obj, request.getUri(), depth,
+ isNodeOnly, cleanUp, isSkipRelatedTo);
if (obj != null) {
status = Status.OK;
MarshallerProperties properties;
- Optional<MarshallerProperties> marshallerPropOpt = request.getMarshallerProperties();
+ Optional<MarshallerProperties> marshallerPropOpt =
+ request.getMarshallerProperties();
if (marshallerPropOpt.isPresent()) {
properties = marshallerPropOpt.get();
} else {
properties = new MarshallerProperties.Builder(
- org.onap.aai.restcore.MediaType.getEnum(outputMediaType)).build();
+ org.onap.aai.restcore.MediaType.getEnum(outputMediaType)).build();
}
result = obj.marshal(properties);
}
} else {
- FormatFactory ff =
- new FormatFactory(loader, serializer, schemaVersions, basePath + "/", serverBase);
+ FormatFactory ff = new FormatFactory(loader, serializer, schemaVersions, basePath + "/",
+ serverBase);
Formatter formatter = ff.get(format, params);
- result = formatter.output(vertices.stream().map(vertex -> (Object) vertex)
- .collect(Collectors.toList())).toString();
+ result = formatter.output(
+ vertices.stream().map(vertex -> (Object) vertex).collect(Collectors.toList()))
+ .toString();
if (outputMediaType == null) {
outputMediaType = MediaType.APPLICATION_JSON;
@@ -547,16 +552,17 @@ public class HttpEntry {
}
result = obj.marshal(properties);
} else {
- String msg = createRelationshipNotFoundMessage(query.getResultType(),
- request.getUri());
+ String msg =
+ createRelationshipNotFoundMessage(query.getResultType(), request.getUri());
throw new AAIException("AAI_6149", msg);
}
} else {
- FormatFactory ff =
- new FormatFactory(loader, serializer, schemaVersions, basePath + "/", serverBase);
+ FormatFactory ff = new FormatFactory(loader, serializer, schemaVersions, basePath + "/",
+ serverBase);
Formatter formatter = ff.get(format, params);
- result = formatter.output(vertices.stream().map(vertex -> (Object) vertex)
- .collect(Collectors.toList())).toString();
+ result = formatter.output(
+ vertices.stream().map(vertex -> (Object) vertex).collect(Collectors.toList()))
+ .toString();
if (outputMediaType == null) {
outputMediaType = MediaType.APPLICATION_JSON;
@@ -580,16 +586,19 @@ public class HttpEntry {
mainVertexesToNotifyOn.add(v);
if (notificationDepth == AAIProperties.MINIMUM_DEPTH) {
- Map<String, Pair<Introspector, LinkedHashMap<String,Introspector>>> allImpliedDeleteObjs = serializer.getImpliedDeleteUriObjectPair();
+ Map<String, Pair<Introspector, LinkedHashMap<String, Introspector>>> allImpliedDeleteObjs =
+ serializer.getImpliedDeleteUriObjectPair();
- for (Map.Entry<String, Pair<Introspector, LinkedHashMap<String,Introspector>>> entry: allImpliedDeleteObjs.entrySet()) {
+ for (Map.Entry<String, Pair<Introspector, LinkedHashMap<String, Introspector>>> entry : allImpliedDeleteObjs
+ .entrySet()) {
// The format is purposefully %s/%s%s due to the fact
// that every aai-uri will have a slash at the beginning
// If that assumption isn't true, then its best to change this code
- String curUri = String.format("%s/%s%s", basePath , version , entry.getKey());
+ String curUri = String.format("%s/%s%s", basePath, version, entry.getKey());
Introspector curObj = entry.getValue().getValue0();
HashMap<String, Introspector> curObjRelated = entry.getValue().getValue1();
- notification.createNotificationEvent(transactionId, sourceOfTruth, Status.NO_CONTENT, URI.create(curUri), curObj, curObjRelated, basePath);
+ notification.createNotificationEvent(transactionId, sourceOfTruth,
+ Status.NO_CONTENT, URI.create(curUri), curObj, curObjRelated, basePath);
}
}
@@ -638,8 +647,7 @@ public class HttpEntry {
String resourceVersion = params.getFirst(AAIProperties.RESOURCE_VERSION);
obj = serializer.getLatestVersionView(v, notificationDepth);
if (query.isDependent()) {
- relatedObjects =
- serializer.getRelatedObjects(queryEngine, v, obj, this.loader);
+ relatedObjects = serializer.getRelatedObjects(queryEngine, v, obj, this.loader);
}
/*
* Find all Delete-other-vertex vertices and create structure for notify
@@ -664,8 +672,7 @@ public class HttpEntry {
deleteObjects = this.buildIntrospectorObjects(serializer, deletableVertices);
uriMap = this.buildURIMap(serializer, deleteObjects);
- deleteRelatedObjects =
- this.buildRelatedObjects(serializer, queryEngine, deleteObjects);
+ deleteRelatedObjects = this.buildRelatedObjects(serializer, queryEngine, deleteObjects);
}
serializer.delete(v, deletableVertices, resourceVersion, enableResourceVersion);
@@ -701,10 +708,8 @@ public class HttpEntry {
* to be able to use for testing the vertex id endpoint functionality
* since we presently have no other way of generating those id urls
*/
- if (response == null && v != null
- && (method.equals(HttpMethod.PUT) || method.equals(HttpMethod.GET)
- || method.equals(HttpMethod.MERGE_PATCH)
- || method.equals(HttpMethod.GET_RELATIONSHIP))
+ if (response == null && v != null && (method.equals(HttpMethod.PUT) || method.equals(HttpMethod.GET)
+ || method.equals(HttpMethod.MERGE_PATCH) || method.equals(HttpMethod.GET_RELATIONSHIP))
) {
String myvertid = v.id().toString();
@@ -734,10 +739,11 @@ public class HttpEntry {
templateVars.add(request.getUri().getPath());
templateVars.addAll(e.getTemplateVars());
ErrorLogHelper.logException(e);
- response = Response.status(e.getErrorObject().getHTTPResponseCode()).entity(ErrorLogHelper
- .getRESTAPIErrorResponse(request.getHeaders().getAcceptableMediaTypes(), e, templateVars))
- .type(outputMediaType)
- .build();
+ response =
+ Response.status(e.getErrorObject().getHTTPResponseCode())
+ .entity(ErrorLogHelper.getRESTAPIErrorResponse(
+ request.getHeaders().getAcceptableMediaTypes(), e, templateVars))
+ .type(outputMediaType).build();
Pair<URI, Response> pairedResp = Pair.with(request.getUri(), response);
responses.add(pairedResp);
} catch (Exception e) {
@@ -747,23 +753,23 @@ public class HttpEntry {
templateVars.add(request.getMethod().toString()); // GET, PUT, etc
templateVars.add(request.getUri().getPath());
ErrorLogHelper.logException(ex);
- response = Response.status(ex.getErrorObject().getHTTPResponseCode()).entity(ErrorLogHelper
- .getRESTAPIErrorResponse(request.getHeaders().getAcceptableMediaTypes(), ex, templateVars))
- .type(outputMediaType)
- .build();
+ response =
+ Response.status(ex.getErrorObject().getHTTPResponseCode())
+ .entity(ErrorLogHelper.getRESTAPIErrorResponse(
+ request.getHeaders().getAcceptableMediaTypes(), ex, templateVars))
+ .type(outputMediaType).build();
Pair<URI, Response> pairedResp = Pair.with(request.getUri(), response);
responses.add(pairedResp);
- }
- finally {
+ } finally {
if (response != null) {
metricLog.post(request, response);
}
}
}
- if (success) {
- generateEvents(sourceOfTruth, serializer, transactionId, queryEngine, mainVertexesToNotifyOn);
- } else {
+ if (success) {
+ generateEvents(sourceOfTruth, serializer, transactionId, queryEngine, mainVertexesToNotifyOn);
+ } else {
notification.clearEvents();
}
@@ -774,18 +780,19 @@ public class HttpEntry {
* Generate notification events for the resulting db requests.
*/
private void generateEvents(String sourceOfTruth, DBSerializer serializer, String transactionId,
- QueryEngine queryEngine, Set<Vertex> mainVertexesToNotifyOn)
- throws AAIException {
+ QueryEngine queryEngine, Set<Vertex> mainVertexesToNotifyOn) throws AAIException {
if (notificationDepth == AAIProperties.MINIMUM_DEPTH) {
- serializer.getUpdatedVertexes().entrySet().stream().filter(Map.Entry::getValue)
- .map(Map.Entry::getKey).forEach(mainVertexesToNotifyOn::add);
+ serializer.getUpdatedVertexes().entrySet().stream().filter(Map.Entry::getValue).map(Map.Entry::getKey)
+ .forEach(mainVertexesToNotifyOn::add);
}
Set<Vertex> edgeVertexes = serializer.touchStandardVertexPropertiesForEdges().stream()
- .filter(v -> !mainVertexesToNotifyOn.contains(v)).collect(Collectors.toSet());
+ .filter(v -> !mainVertexesToNotifyOn.contains(v)).collect(Collectors.toSet());
try {
- createNotificationEvents(mainVertexesToNotifyOn, sourceOfTruth, serializer, transactionId, queryEngine, notificationDepth);
- if("true".equals(AAIConfig.get("aai.notification.both.sides.enabled", "true"))){
- createNotificationEvents(edgeVertexes, sourceOfTruth, serializer, transactionId, queryEngine, AAIProperties.MINIMUM_DEPTH);
+ createNotificationEvents(mainVertexesToNotifyOn, sourceOfTruth, serializer, transactionId, queryEngine,
+ notificationDepth);
+ if ("true".equals(AAIConfig.get("aai.notification.both.sides.enabled", "true"))) {
+ createNotificationEvents(edgeVertexes, sourceOfTruth, serializer, transactionId, queryEngine,
+ AAIProperties.MINIMUM_DEPTH);
}
} catch (UnsupportedEncodingException e) {
LOGGER.warn("Encountered exception generating events", e);
@@ -793,15 +800,14 @@ public class HttpEntry {
// Since @Autowired required is set to false, we need to do a null check
// for the existence of the validationService since its only enabled if profile is enabled
- if (validationService != null){
+ if (validationService != null) {
validationService.validate(notification.getEvents());
}
notification.triggerEvents();
if (isDeltaEventsEnabled) {
try {
DeltaEvents deltaEvents =
- new DeltaEvents(transactionId, sourceOfTruth, version.toString(),
- serializer.getObjectDeltas());
+ new DeltaEvents(transactionId, sourceOfTruth, version.toString(), serializer.getObjectDeltas());
deltaEvents.triggerEvents();
} catch (Exception e) {
LOGGER.error("Error sending Delta Events", e);
@@ -813,10 +819,12 @@ public class HttpEntry {
* Generate notification events for provided set of vertexes at the specified depth
*/
private void createNotificationEvents(Set<Vertex> vertexesToNotifyOn, String sourceOfTruth, DBSerializer serializer,
- String transactionId, QueryEngine queryEngine, int eventDepth) throws AAIException, UnsupportedEncodingException {
+ String transactionId, QueryEngine queryEngine, int eventDepth)
+ throws AAIException, UnsupportedEncodingException {
for (Vertex vertex : vertexesToNotifyOn) {
if (canGenerateEvent(vertex)) {
- boolean isCurVertexNew = vertex.value(AAIProperties.CREATED_TS).equals(vertex.value(AAIProperties.LAST_MOD_TS));
+ boolean isCurVertexNew =
+ vertex.value(AAIProperties.CREATED_TS).equals(vertex.value(AAIProperties.LAST_MOD_TS));
Status curObjStatus = (isCurVertexNew) ? Status.CREATED : Status.OK;
Introspector curObj = serializer.getLatestVersionView(vertex, eventDepth);
@@ -826,14 +834,15 @@ public class HttpEntry {
if (!curObj.isTopLevel()) {
curRelatedObjs = serializer.getRelatedObjects(queryEngine, vertex, curObj, this.loader);
}
- notification.createNotificationEvent(transactionId, sourceOfTruth, curObjStatus,
- URI.create(uri), curObj, curRelatedObjs, basePath);
+ notification.createNotificationEvent(transactionId, sourceOfTruth, curObjStatus, URI.create(uri),
+ curObj, curRelatedObjs, basePath);
}
}
}
/**
* Verifies that vertex has needed properties to generate on
+ *
* @param vertex Vertex to be verified
* @return <code>true</code> if vertex has necessary properties and exists
*/
@@ -843,8 +852,8 @@ public class HttpEntry {
if (!vertex.property(AAIProperties.AAI_URI).isPresent()) {
LOGGER.debug("Encountered an vertex {} with missing aai-uri", vertex.id());
canGenerate = false;
- } else if (!vertex.property(AAIProperties.CREATED_TS).isPresent() ||
- !vertex.property(AAIProperties.LAST_MOD_TS).isPresent()) {
+ } else if (!vertex.property(AAIProperties.CREATED_TS).isPresent()
+ || !vertex.property(AAIProperties.LAST_MOD_TS).isPresent()) {
LOGGER.debug("Encountered an vertex {} with missing timestamp", vertex.id());
canGenerate = false;
}
@@ -912,6 +921,7 @@ public class HttpEntry {
return serializer.dbToObject(results, obj, depth, nodeOnly, cleanUp);
}
+
/**
* Gets the object from db.
*
@@ -971,8 +981,8 @@ public class HttpEntry {
* @throws URISyntaxException
*/
private Introspector getRelationshipObjectFromDb(List<Vertex> results, DBSerializer serializer, QueryParser query,
- URI uri, boolean isSkipRelatedTo) throws AAIException, IllegalArgumentException, SecurityException, UnsupportedEncodingException,
- AAIUnknownObjectException {
+ URI uri, boolean isSkipRelatedTo) throws AAIException, IllegalArgumentException, SecurityException,
+ UnsupportedEncodingException, AAIUnknownObjectException {
// nothing found
if (results.isEmpty()) {
@@ -996,7 +1006,7 @@ public class HttpEntry {
* @return the string
*/
private String createNotFoundMessage(String resultType, URI uri) {
- return "No Node of type " + resultType + " found at: " + uri.getPath();
+ return "No Node of type " + resultType + " found at: " + uri.getPath();
}
/**
@@ -1007,7 +1017,7 @@ public class HttpEntry {
* @return the string
*/
private String createRelationshipNotFoundMessage(String resultType, URI uri) {
- return "No relationship found of type " + resultType + " at the given URI: " + uri.getPath()
+ return "No relationship found of type " + resultType + " at the given URI: " + uri.getPath()
+ "/relationship-list";
}
@@ -1105,8 +1115,7 @@ public class HttpEntry {
if (null != entry.getValue()) {
relatedObjectsMap.put(entry.getValue().getObjectId(), relatedObjects);
}
- } catch (IllegalArgumentException | SecurityException
- | UnsupportedEncodingException | AAIException e) {
+ } catch (IllegalArgumentException | SecurityException | UnsupportedEncodingException | AAIException e) {
LOGGER.warn("Unable to get realted Objects, Just continue");
}
@@ -1153,14 +1162,16 @@ public class HttpEntry {
List<Object> vertexList = (List<Object>) aggregateVertexList.get(0);
this.setTotalsForPaging(vertexList.size(), this.getPaginationBucket());
int startIndex = (this.getPaginationIndex() - 1) * this.getPaginationBucket();
- int endIndex = Math.min((this.getPaginationBucket() * this.getPaginationIndex()), vertexList.size());
+ int endIndex =
+ Math.min((this.getPaginationBucket() * this.getPaginationIndex()), vertexList.size());
if (startIndex > endIndex) {
throw new AAIException("AAI_6150",
- " ResultIndex is not appropriate for the result set, Needs to be <= " + endIndex);
+ " ResultIndex is not appropriate for the result set, Needs to be <= " + endIndex);
}
finalList.add(new ArrayList<Object>());
for (int i = startIndex; i < endIndex; i++) {
- ((ArrayList<Object>) finalList.get(0)).add(((ArrayList<Object>) aggregateVertexList.get(0)).get(i));
+ ((ArrayList<Object>) finalList.get(0))
+ .add(((ArrayList<Object>) aggregateVertexList.get(0)).get(i));
}
return finalList;
}
diff --git a/aai-core/src/main/java/org/onap/aai/rest/ueb/NotificationEvent.java b/aai-core/src/main/java/org/onap/aai/rest/ueb/NotificationEvent.java
index 14e554cd..b8e93c5b 100644
--- a/aai-core/src/main/java/org/onap/aai/rest/ueb/NotificationEvent.java
+++ b/aai-core/src/main/java/org/onap/aai/rest/ueb/NotificationEvent.java
@@ -70,6 +70,7 @@ public class NotificationEvent {
public String getNotificationEvent() throws AAIException {
return new StoreNotificationEvent(transactionId, sourceOfTruth).storeEventOnly(loader, eventHeader, obj);
}
+
/**
* Gets the notification version.
*
diff --git a/aai-core/src/main/java/org/onap/aai/rest/ueb/UEBNotification.java b/aai-core/src/main/java/org/onap/aai/rest/ueb/UEBNotification.java
index d9516315..be30c468 100644
--- a/aai-core/src/main/java/org/onap/aai/rest/ueb/UEBNotification.java
+++ b/aai-core/src/main/java/org/onap/aai/rest/ueb/UEBNotification.java
@@ -27,7 +27,9 @@ import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
+
import javax.ws.rs.core.Response.Status;
+
import org.onap.aai.exceptions.AAIException;
import org.onap.aai.introspection.Introspector;
import org.onap.aai.introspection.Loader;
@@ -204,6 +206,7 @@ public class UEBNotification {
public List<NotificationEvent> getEvents() {
return new ArrayList<>(this.events.values());
}
+
public Map<String, NotificationEvent> getEventsMap() {
return this.events;
}
diff --git a/aai-core/src/main/java/org/onap/aai/restcore/RESTAPI.java b/aai-core/src/main/java/org/onap/aai/restcore/RESTAPI.java
index 7c5d43c1..3666eb67 100644
--- a/aai-core/src/main/java/org/onap/aai/restcore/RESTAPI.java
+++ b/aai-core/src/main/java/org/onap/aai/restcore/RESTAPI.java
@@ -32,10 +32,12 @@ import java.util.concurrent.Executors;
import java.util.concurrent.Future;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;
+
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 org.onap.aai.db.props.AAIProperties;
import org.onap.aai.exceptions.AAIException;
import org.onap.aai.introspection.Introspector;
diff --git a/aai-core/src/main/java/org/onap/aai/restcore/search/AAIAbstractGroovyShell.java b/aai-core/src/main/java/org/onap/aai/restcore/search/AAIAbstractGroovyShell.java
index 13f3f05e..4a8760ec 100644
--- a/aai-core/src/main/java/org/onap/aai/restcore/search/AAIAbstractGroovyShell.java
+++ b/aai-core/src/main/java/org/onap/aai/restcore/search/AAIAbstractGroovyShell.java
@@ -92,11 +92,11 @@ public abstract class AAIAbstractGroovyShell {
* @return result of graph traversal
*/
public abstract String executeTraversal(TransactionalGraphEngine engine, String traversal,
- Map<String, Object> params, QueryStyle style, GraphTraversalSource source);
+ Map<String, Object> params, QueryStyle style, GraphTraversalSource source);
- protected Loader getLoader(){
+ protected Loader getLoader() {
SchemaVersions schemaVersions = (SchemaVersions) SpringContextAware.getBean("schemaVersions");
return SpringContextAware.getBean(LoaderFactory.class).createLoaderForVersion(ModelType.MOXY,
- schemaVersions.getDefaultVersion());
+ schemaVersions.getDefaultVersion());
}
}
diff --git a/aai-core/src/main/java/org/onap/aai/restcore/search/GremlinGroovyShell.java b/aai-core/src/main/java/org/onap/aai/restcore/search/GremlinGroovyShell.java
index 85e47223..cc7a601b 100644
--- a/aai-core/src/main/java/org/onap/aai/restcore/search/GremlinGroovyShell.java
+++ b/aai-core/src/main/java/org/onap/aai/restcore/search/GremlinGroovyShell.java
@@ -61,7 +61,8 @@ public class GremlinGroovyShell extends AAIAbstractGroovyShell {
}
@Override
- public String executeTraversal(TransactionalGraphEngine engine, String traversal, Map<String, Object> params, QueryStyle style, GraphTraversalSource source) {
+ public String executeTraversal(TransactionalGraphEngine engine, String traversal, Map<String, Object> params,
+ QueryStyle style, GraphTraversalSource source) {
throw new UnsupportedOperationException();
}
}
diff --git a/aai-core/src/main/java/org/onap/aai/restcore/search/GroovyQueryBuilder.java b/aai-core/src/main/java/org/onap/aai/restcore/search/GroovyQueryBuilder.java
index fbaa7465..7a948761 100644
--- a/aai-core/src/main/java/org/onap/aai/restcore/search/GroovyQueryBuilder.java
+++ b/aai-core/src/main/java/org/onap/aai/restcore/search/GroovyQueryBuilder.java
@@ -28,14 +28,9 @@ import java.util.Map;
import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversal;
import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource;
import org.apache.tinkerpop.gremlin.structure.Vertex;
-import org.onap.aai.config.SpringContextAware;
-import org.onap.aai.introspection.Loader;
-import org.onap.aai.introspection.LoaderFactory;
-import org.onap.aai.introspection.ModelType;
import org.onap.aai.query.builder.QueryBuilder;
import org.onap.aai.serialization.engines.QueryStyle;
import org.onap.aai.serialization.engines.TransactionalGraphEngine;
-import org.onap.aai.setup.SchemaVersions;
/**
* Creates and returns a groovy shell with the
@@ -74,7 +69,8 @@ public class GroovyQueryBuilder extends AAIAbstractGroovyShell {
}
@Override
- public String executeTraversal(TransactionalGraphEngine engine, String traversal, Map<String, Object> params, QueryStyle style, GraphTraversalSource traversalSource) {
+ public String executeTraversal(TransactionalGraphEngine engine, String traversal, Map<String, Object> params,
+ QueryStyle style, GraphTraversalSource traversalSource) {
QueryBuilder<Vertex> builder = engine.getQueryBuilder(style, traversalSource);
builder.changeLoader(getLoader());
Binding binding = new Binding(params);
diff --git a/aai-core/src/main/java/org/onap/aai/restcore/util/URITools.java b/aai-core/src/main/java/org/onap/aai/restcore/util/URITools.java
index fc32f859..962d2e99 100644
--- a/aai-core/src/main/java/org/onap/aai/restcore/util/URITools.java
+++ b/aai-core/src/main/java/org/onap/aai/restcore/util/URITools.java
@@ -20,7 +20,6 @@
package org.onap.aai.restcore.util;
-import java.io.UnsupportedEncodingException;
import java.net.URI;
import java.util.HashMap;
import java.util.LinkedHashSet;
diff --git a/aai-core/src/main/java/org/onap/aai/serialization/db/DBSerializer.java b/aai-core/src/main/java/org/onap/aai/serialization/db/DBSerializer.java
index db92babc..dc478337 100644
--- a/aai-core/src/main/java/org/onap/aai/serialization/db/DBSerializer.java
+++ b/aai-core/src/main/java/org/onap/aai/serialization/db/DBSerializer.java
@@ -17,8 +17,11 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
+
package org.onap.aai.serialization.db;
+import com.google.common.base.CaseFormat;
+
import java.io.UnsupportedEncodingException;
import java.lang.reflect.Array;
import java.lang.reflect.InvocationTargetException;
@@ -111,8 +114,6 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.context.ApplicationContext;
-import com.google.common.base.CaseFormat;
-
public class DBSerializer {
private static final Logger LOGGER = LoggerFactory.getLogger(DBSerializer.class);
@@ -140,7 +141,8 @@ public class DBSerializer {
private Map<String, ObjectDelta> objectDeltas = new LinkedHashMap<>();
private Map<Vertex, Boolean> updatedVertexes = new LinkedHashMap<>();
private Set<Vertex> edgeVertexes = new LinkedHashSet<>();
- private Map<String, Pair<Introspector, LinkedHashMap<String, Introspector>>> impliedDeleteUriObjectPair = new LinkedHashMap<>();
+ private Map<String, Pair<Introspector, LinkedHashMap<String, Introspector>>> impliedDeleteUriObjectPair =
+ new LinkedHashMap<>();
private int notificationDepth;
private boolean isDeltaEventsEnabled;
private boolean isMultiTenancyEnabled;
@@ -162,8 +164,8 @@ public class DBSerializer {
this.introspectionType = introspectionType;
this.schemaVersions = (SchemaVersions) SpringContextAware.getBean("schemaVersions");
SchemaVersion latestVersion = schemaVersions.getDefaultVersion();
- this.latestLoader =
- SpringContextAware.getBean(LoaderFactory.class).createLoaderForVersion(introspectionType, latestVersion);
+ this.latestLoader = SpringContextAware.getBean(LoaderFactory.class).createLoaderForVersion(introspectionType,
+ latestVersion);
this.version = version;
this.loader =
SpringContextAware.getBean(LoaderFactory.class).createLoaderForVersion(introspectionType, version);
@@ -176,18 +178,18 @@ public class DBSerializer {
}
public DBSerializer(SchemaVersion version, TransactionalGraphEngine engine, ModelType introspectionType,
- String sourceOfTruth, Set<String> groups) throws AAIException {
+ String sourceOfTruth, Set<String> groups) throws AAIException {
this.engine = engine;
this.sourceOfTruth = sourceOfTruth;
this.groups = groups;
this.introspectionType = introspectionType;
this.schemaVersions = (SchemaVersions) SpringContextAware.getBean("schemaVersions");
SchemaVersion latestVersion = schemaVersions.getDefaultVersion();
- this.latestLoader =
- SpringContextAware.getBean(LoaderFactory.class).createLoaderForVersion(introspectionType, latestVersion);
+ this.latestLoader = SpringContextAware.getBean(LoaderFactory.class).createLoaderForVersion(introspectionType,
+ latestVersion);
this.version = version;
this.loader =
- SpringContextAware.getBean(LoaderFactory.class).createLoaderForVersion(introspectionType, version);
+ SpringContextAware.getBean(LoaderFactory.class).createLoaderForVersion(introspectionType, version);
this.namedPropNodes = this.latestLoader.getNamedPropNodes();
this.baseURL = AAIConfig.get(AAIConstants.AAI_SERVER_URL_BASE);
this.currentTimeMillis = System.currentTimeMillis();
@@ -196,22 +198,19 @@ public class DBSerializer {
initBeans();
}
- public DBSerializer(SchemaVersion version,
- TransactionalGraphEngine engine,
- ModelType introspectionType,
- String sourceOfTruth,
- int notificationDepth) throws AAIException {
+ public DBSerializer(SchemaVersion version, TransactionalGraphEngine engine, ModelType introspectionType,
+ String sourceOfTruth, int notificationDepth) throws AAIException {
this.engine = engine;
this.sourceOfTruth = sourceOfTruth;
this.groups = Collections.EMPTY_SET;
this.introspectionType = introspectionType;
this.schemaVersions = (SchemaVersions) SpringContextAware.getBean("schemaVersions");
SchemaVersion latestVersion = schemaVersions.getDefaultVersion();
- this.latestLoader =
- SpringContextAware.getBean(LoaderFactory.class).createLoaderForVersion(introspectionType, latestVersion);
+ this.latestLoader = SpringContextAware.getBean(LoaderFactory.class).createLoaderForVersion(introspectionType,
+ latestVersion);
this.version = version;
this.loader =
- SpringContextAware.getBean(LoaderFactory.class).createLoaderForVersion(introspectionType, version);
+ SpringContextAware.getBean(LoaderFactory.class).createLoaderForVersion(introspectionType, version);
this.namedPropNodes = this.latestLoader.getNamedPropNodes();
this.baseURL = AAIConfig.get(AAIConstants.AAI_SERVER_URL_BASE);
this.currentTimeMillis = System.currentTimeMillis();
@@ -219,23 +218,19 @@ public class DBSerializer {
initBeans();
}
- public DBSerializer(SchemaVersion version,
- TransactionalGraphEngine engine,
- ModelType introspectionType,
- String sourceOfTruth,
- Set<String> groups,
- int notificationDepth) throws AAIException {
+ public DBSerializer(SchemaVersion version, TransactionalGraphEngine engine, ModelType introspectionType,
+ String sourceOfTruth, Set<String> groups, int notificationDepth) throws AAIException {
this.engine = engine;
this.sourceOfTruth = sourceOfTruth;
this.groups = groups;
this.introspectionType = introspectionType;
this.schemaVersions = (SchemaVersions) SpringContextAware.getBean("schemaVersions");
SchemaVersion latestVersion = schemaVersions.getDefaultVersion();
- this.latestLoader =
- SpringContextAware.getBean(LoaderFactory.class).createLoaderForVersion(introspectionType, latestVersion);
+ this.latestLoader = SpringContextAware.getBean(LoaderFactory.class).createLoaderForVersion(introspectionType,
+ latestVersion);
this.version = version;
this.loader =
- SpringContextAware.getBean(LoaderFactory.class).createLoaderForVersion(introspectionType, version);
+ SpringContextAware.getBean(LoaderFactory.class).createLoaderForVersion(introspectionType, version);
this.namedPropNodes = this.latestLoader.getNamedPropNodes();
this.baseURL = AAIConfig.get(AAIConstants.AAI_SERVER_URL_BASE);
this.currentTimeMillis = System.currentTimeMillis();
@@ -243,23 +238,19 @@ public class DBSerializer {
initBeans();
}
- public DBSerializer(SchemaVersion version,
- TransactionalGraphEngine engine,
- ModelType introspectionType,
- String sourceOfTruth,
- int notificationDepth,
- String serverBase) throws AAIException {
+ public DBSerializer(SchemaVersion version, TransactionalGraphEngine engine, ModelType introspectionType,
+ String sourceOfTruth, int notificationDepth, String serverBase) throws AAIException {
this.engine = engine;
this.sourceOfTruth = sourceOfTruth;
this.groups = Collections.EMPTY_SET;
this.introspectionType = introspectionType;
this.schemaVersions = (SchemaVersions) SpringContextAware.getBean("schemaVersions");
SchemaVersion latestVersion = schemaVersions.getDefaultVersion();
- this.latestLoader =
- SpringContextAware.getBean(LoaderFactory.class).createLoaderForVersion(introspectionType, latestVersion);
+ this.latestLoader = SpringContextAware.getBean(LoaderFactory.class).createLoaderForVersion(introspectionType,
+ latestVersion);
this.version = version;
this.loader =
- SpringContextAware.getBean(LoaderFactory.class).createLoaderForVersion(introspectionType, version);
+ SpringContextAware.getBean(LoaderFactory.class).createLoaderForVersion(introspectionType, version);
this.namedPropNodes = this.latestLoader.getNamedPropNodes();
this.baseURL = serverBase;
this.currentTimeMillis = System.currentTimeMillis();
@@ -267,24 +258,19 @@ public class DBSerializer {
initBeans();
}
- public DBSerializer(SchemaVersion version,
- TransactionalGraphEngine engine,
- ModelType introspectionType,
- String sourceOfTruth,
- Set<String> groups,
- int notificationDepth,
- String serverBase) throws AAIException {
+ public DBSerializer(SchemaVersion version, TransactionalGraphEngine engine, ModelType introspectionType,
+ String sourceOfTruth, Set<String> groups, int notificationDepth, String serverBase) throws AAIException {
this.engine = engine;
this.sourceOfTruth = sourceOfTruth;
this.groups = groups;
this.introspectionType = introspectionType;
this.schemaVersions = (SchemaVersions) SpringContextAware.getBean("schemaVersions");
SchemaVersion latestVersion = schemaVersions.getDefaultVersion();
- this.latestLoader =
- SpringContextAware.getBean(LoaderFactory.class).createLoaderForVersion(introspectionType, latestVersion);
+ this.latestLoader = SpringContextAware.getBean(LoaderFactory.class).createLoaderForVersion(introspectionType,
+ latestVersion);
this.version = version;
this.loader =
- SpringContextAware.getBean(LoaderFactory.class).createLoaderForVersion(introspectionType, version);
+ SpringContextAware.getBean(LoaderFactory.class).createLoaderForVersion(introspectionType, version);
this.namedPropNodes = this.latestLoader.getNamedPropNodes();
this.baseURL = serverBase;
this.currentTimeMillis = System.currentTimeMillis();
@@ -299,8 +285,10 @@ public class DBSerializer {
setEdgeIngestor(ei);
EdgeSerializer es = ctx.getBean(EdgeSerializer.class);
setEdgeSerializer(es);
- isDeltaEventsEnabled = Boolean.parseBoolean(SpringContextAware.getApplicationContext().getEnvironment().getProperty("delta.events.enabled", FALSE));
- isMultiTenancyEnabled = Boolean.parseBoolean(SpringContextAware.getApplicationContext().getEnvironment().getProperty("multi.tenancy.enabled", FALSE));
+ isDeltaEventsEnabled = Boolean.parseBoolean(
+ SpringContextAware.getApplicationContext().getEnvironment().getProperty("delta.events.enabled", FALSE));
+ isMultiTenancyEnabled = Boolean.parseBoolean(SpringContextAware.getApplicationContext().getEnvironment()
+ .getProperty("multi.tenancy.enabled", FALSE));
}
public void setEdgeSerializer(EdgeSerializer edgeSer) {
@@ -333,7 +321,8 @@ public class DBSerializer {
/**
* Touch standard vertex properties.
- * @param v the v
+ *
+ * @param v the v
* @param isNewVertex the is new vertex
*/
public void touchStandardVertexProperties(Vertex v, boolean isNewVertex) {
@@ -347,7 +336,7 @@ public class DBSerializer {
v.property(AAIProperties.LAST_MOD_TS, currentTimeMillis);
v.property(AAIProperties.LAST_MOD_SOURCE_OF_TRUTH, this.sourceOfTruth);
} else {
- if(isDeltaEventsEnabled) {
+ if (isDeltaEventsEnabled) {
standardVertexPropsDeltas(v, timeNowInSec);
}
v.property(AAIProperties.RESOURCE_VERSION, timeNowInSec);
@@ -364,42 +353,37 @@ public class DBSerializer {
getObjectDeltas().get(uri).setAction(objDeltaAction);
}
- addPropDelta(uri, AAIProperties.AAI_UUID, PropertyDeltaFactory
- .getDelta(DeltaAction.STATIC, v.property(AAIProperties.AAI_UUID).value()),
- objDeltaAction);
- addPropDelta(uri, AAIProperties.NODE_TYPE, PropertyDeltaFactory
- .getDelta(DeltaAction.STATIC, v.property(AAIProperties.NODE_TYPE).value()),
- objDeltaAction);
- addPropDelta(uri, AAIProperties.SOURCE_OF_TRUTH, PropertyDeltaFactory
- .getDelta(DeltaAction.STATIC, v.property(AAIProperties.SOURCE_OF_TRUTH).value()),
- objDeltaAction);
- addPropDelta(uri, AAIProperties.CREATED_TS, PropertyDeltaFactory
- .getDelta(DeltaAction.STATIC, v.property(AAIProperties.CREATED_TS).value()),
- objDeltaAction);
+ addPropDelta(uri, AAIProperties.AAI_UUID,
+ PropertyDeltaFactory.getDelta(DeltaAction.STATIC, v.property(AAIProperties.AAI_UUID).value()),
+ objDeltaAction);
+ addPropDelta(uri, AAIProperties.NODE_TYPE,
+ PropertyDeltaFactory.getDelta(DeltaAction.STATIC, v.property(AAIProperties.NODE_TYPE).value()),
+ objDeltaAction);
+ addPropDelta(uri, AAIProperties.SOURCE_OF_TRUTH,
+ PropertyDeltaFactory.getDelta(DeltaAction.STATIC, v.property(AAIProperties.SOURCE_OF_TRUTH).value()),
+ objDeltaAction);
+ addPropDelta(uri, AAIProperties.CREATED_TS,
+ PropertyDeltaFactory.getDelta(DeltaAction.STATIC, v.property(AAIProperties.CREATED_TS).value()),
+ objDeltaAction);
if (objDeltaAction.equals(DeltaAction.UPDATE)) {
+ addPropDelta(uri, AAIProperties.RESOURCE_VERSION, PropertyDeltaFactory.getDelta(objDeltaAction,
+ timeNowInSec, v.property(AAIProperties.RESOURCE_VERSION).value()), objDeltaAction);
+ addPropDelta(uri, AAIProperties.LAST_MOD_TS, PropertyDeltaFactory.getDelta(objDeltaAction,
+ currentTimeMillis, v.property(AAIProperties.LAST_MOD_TS).value()), objDeltaAction);
addPropDelta(
- uri,
- AAIProperties.RESOURCE_VERSION,
- PropertyDeltaFactory.getDelta(objDeltaAction, timeNowInSec, v.property(AAIProperties.RESOURCE_VERSION).value()),
- objDeltaAction
- );
- addPropDelta(
- uri,
- AAIProperties.LAST_MOD_TS,
- PropertyDeltaFactory.getDelta(objDeltaAction, currentTimeMillis, v.property(AAIProperties.LAST_MOD_TS).value()),
- objDeltaAction
- );
- addPropDelta(
- uri,
- AAIProperties.LAST_MOD_SOURCE_OF_TRUTH,
- PropertyDeltaFactory.getDelta(objDeltaAction, this.sourceOfTruth, v.property(AAIProperties.LAST_MOD_SOURCE_OF_TRUTH).value()),
- objDeltaAction
- );
+ uri, AAIProperties.LAST_MOD_SOURCE_OF_TRUTH, PropertyDeltaFactory.getDelta(objDeltaAction,
+ this.sourceOfTruth, v.property(AAIProperties.LAST_MOD_SOURCE_OF_TRUTH).value()),
+ objDeltaAction);
} else {
- addPropDelta(uri, AAIProperties.RESOURCE_VERSION, PropertyDeltaFactory.getDelta(objDeltaAction, v.property(AAIProperties.RESOURCE_VERSION).value()), objDeltaAction);
- addPropDelta(uri, AAIProperties.LAST_MOD_TS, PropertyDeltaFactory.getDelta(objDeltaAction, v.property(AAIProperties.LAST_MOD_TS).value()), objDeltaAction);
- addPropDelta(uri, AAIProperties.LAST_MOD_SOURCE_OF_TRUTH, PropertyDeltaFactory.getDelta(objDeltaAction, v.property(AAIProperties.LAST_MOD_SOURCE_OF_TRUTH).value()), objDeltaAction);
+ addPropDelta(uri, AAIProperties.RESOURCE_VERSION,
+ PropertyDeltaFactory.getDelta(objDeltaAction, v.property(AAIProperties.RESOURCE_VERSION).value()),
+ objDeltaAction);
+ addPropDelta(uri, AAIProperties.LAST_MOD_TS,
+ PropertyDeltaFactory.getDelta(objDeltaAction, v.property(AAIProperties.LAST_MOD_TS).value()),
+ objDeltaAction);
+ addPropDelta(uri, AAIProperties.LAST_MOD_SOURCE_OF_TRUTH, PropertyDeltaFactory.getDelta(objDeltaAction,
+ v.property(AAIProperties.LAST_MOD_SOURCE_OF_TRUTH).value()), objDeltaAction);
}
}
@@ -408,13 +392,15 @@ public class DBSerializer {
}
private void addPropDelta(String uri, String prop, PropertyDelta delta, DeltaAction objDeltaAction) {
- ObjectDelta objectDelta = this.objectDeltas.getOrDefault(uri, new ObjectDelta(uri, objDeltaAction, this.sourceOfTruth, this.currentTimeMillis));
+ ObjectDelta objectDelta = this.objectDeltas.getOrDefault(uri,
+ new ObjectDelta(uri, objDeltaAction, this.sourceOfTruth, this.currentTimeMillis));
objectDelta.addPropertyDelta(prop, delta);
objectDeltas.put(uri, objectDelta);
}
private void addRelationshipDelta(String uri, RelationshipDelta delta, DeltaAction objDeltaAction) {
- ObjectDelta objectDelta = this.objectDeltas.getOrDefault(uri, new ObjectDelta(uri, objDeltaAction, this.sourceOfTruth, this.currentTimeMillis));
+ ObjectDelta objectDelta = this.objectDeltas.getOrDefault(uri,
+ new ObjectDelta(uri, objDeltaAction, this.sourceOfTruth, this.currentTimeMillis));
objectDelta.addRelationshipDelta(delta);
objectDeltas.put(uri, objectDelta);
}
@@ -552,12 +538,12 @@ public class DBSerializer {
List<Vertex> dependentVertexes = new ArrayList<>();
List<Vertex> processedVertexes = new ArrayList<>();
- boolean isComplexType ;
+ boolean isComplexType;
boolean isListType;
// If the notification depth is set to maximum
// this is the behavior of the expected clients
- if(notificationDepth == AAIProperties.MAXIMUM_DEPTH) {
+ if (notificationDepth == AAIProperties.MAXIMUM_DEPTH) {
if (!obj.isContainer()) {
this.touchStandardVertexProperties(v, false);
}
@@ -602,7 +588,9 @@ public class DBSerializer {
if (oldValue != null) {
v.property(dbProperty).remove();
if (isDeltaEventsEnabled) {
- addPropDelta(uri, dbProperty, PropertyDeltaFactory.getDelta(DeltaAction.DELETE, oldValue), DeltaAction.UPDATE);
+ addPropDelta(uri, dbProperty,
+ PropertyDeltaFactory.getDelta(DeltaAction.DELETE, oldValue),
+ DeltaAction.UPDATE);
}
this.updatedVertexes.putIfAbsent(v, false);
}
@@ -626,7 +614,8 @@ public class DBSerializer {
engine.setListProperty(v, property, list);
if (list == null || list.isEmpty()) { // property delete scenario, there is no new value
if (oldVal != null && !oldVal.isEmpty()) { // and there is an old value
- addPropDelta(uri, property, PropertyDeltaFactory.getDelta(DeltaAction.DELETE, oldVal), DeltaAction.UPDATE);
+ addPropDelta(uri, property, PropertyDeltaFactory.getDelta(DeltaAction.DELETE, oldVal),
+ DeltaAction.UPDATE);
}
} else { // is either a create or update and is handled by the called method
createDeltaProperty(uri, list, property, oldVal);
@@ -680,7 +669,8 @@ public class DBSerializer {
}
ImpliedDelete impliedDelete = new ImpliedDelete(engine, this);
- List<Vertex> impliedDeleteVertices = impliedDelete.execute(v.id(), sourceOfTruth, obj.getName(), dependentVertexes);
+ List<Vertex> impliedDeleteVertices =
+ impliedDelete.execute(v.id(), sourceOfTruth, obj.getName(), dependentVertexes);
if (notificationDepth == AAIProperties.MINIMUM_DEPTH) {
for (Vertex curVertex : impliedDeleteVertices) {
@@ -694,7 +684,8 @@ public class DBSerializer {
LinkedHashMap<String, Introspector> curObjRelated = new LinkedHashMap<>();
if (!curObj.isTopLevel()) {
- curObjRelated.putAll(this.getRelatedObjects(engine.getQueryEngine(), curVertex, curObj, this.loader));
+ curObjRelated
+ .putAll(this.getRelatedObjects(engine.getQueryEngine(), curVertex, curObj, this.loader));
}
if (!impliedDeleteUriObjectPair.containsKey(curAaiUri)) {
@@ -707,14 +698,12 @@ public class DBSerializer {
// touch svp using vertex list for what changed
// if the notification depth is zero
- if(notificationDepth == AAIProperties.MINIMUM_DEPTH){
- this.updatedVertexes.entrySet().stream()
- .filter(e -> !e.getValue())
- .filter(e -> !edgeVertexes.contains(e.getKey()))
- .forEach(e -> {
- this.touchStandardVertexProperties(e.getKey(), false);
- e.setValue(true);
- });
+ if (notificationDepth == AAIProperties.MINIMUM_DEPTH) {
+ this.updatedVertexes.entrySet().stream().filter(e -> !e.getValue())
+ .filter(e -> !edgeVertexes.contains(e.getKey())).forEach(e -> {
+ this.touchStandardVertexProperties(e.getKey(), false);
+ e.setValue(true);
+ });
}
this.executePostSideEffects(obj, v);
return processedVertexes;
@@ -724,12 +713,14 @@ public class DBSerializer {
if (oldValue == null) {
addPropDelta(uri, dbProperty, PropertyDeltaFactory.getDelta(DeltaAction.CREATE, value), DeltaAction.UPDATE);
} else {
- addPropDelta(uri, dbProperty, PropertyDeltaFactory.getDelta(DeltaAction.UPDATE, value, oldValue), DeltaAction.UPDATE);
+ addPropDelta(uri, dbProperty, PropertyDeltaFactory.getDelta(DeltaAction.UPDATE, value, oldValue),
+ DeltaAction.UPDATE);
}
}
- public HashMap<String, Introspector> getRelatedObjects(QueryEngine queryEngine, Vertex v,
- Introspector obj, Loader loader) throws IllegalArgumentException, SecurityException, UnsupportedEncodingException, AAIException {
+ public HashMap<String, Introspector> getRelatedObjects(QueryEngine queryEngine, Vertex v, Introspector obj,
+ Loader loader)
+ throws IllegalArgumentException, SecurityException, UnsupportedEncodingException, AAIException {
HashMap<String, Introspector> relatedVertices = new HashMap<>();
VertexProperty aaiUriProperty = v.property(AAIProperties.AAI_URI);
@@ -737,10 +728,10 @@ public class DBSerializer {
if (!aaiUriProperty.isPresent()) {
if (LOGGER.isDebugEnabled()) {
LOGGER.debug("For the given vertex {}, it seems aai-uri is not present so not getting related objects",
- v.id().toString());
+ v.id().toString());
} else {
LOGGER.info(
- "It seems aai-uri is not present in vertex, so not getting related objects, for more info enable debug log");
+ "It seems aai-uri is not present in vertex, so not getting related objects, for more info enable debug log");
}
return relatedVertices;
}
@@ -754,13 +745,14 @@ public class DBSerializer {
// into a list of aai-uris so falling back to the old mechanism for finding parents
if (uriList == null) {
LOGGER.info(
- "Falling back to the old mechanism due to unable to convert aai-uri to list of uris but this is not optimal");
+ "Falling back to the old mechanism due to unable to convert aai-uri to list of uris but this is not optimal");
vertexChain = queryEngine.findParents(v);
} else if (uriList.length == 1) {
// If the uri list is size 1 the only uri in the list is the one represented by v thus no need to query
vertexChain = Collections.singletonList(v);
} else {
- // the uriList at element 0 is the node in question and should not be included in the vertex chain lookup.
+ // the uriList at element 0 is the node in question and should not be included in the vertex chain
+ // lookup.
vertexChain = queryEngine.findParents(Arrays.copyOfRange(uriList, 1, uriList.length));
// inject v into start of vertexChain
vertexChain.add(0, v);
@@ -829,7 +821,7 @@ public class DBSerializer {
* @throws AAIException
*/
String[] convertIntrospectorToUriList(String aaiUri, Introspector obj, Loader loader)
- throws UnsupportedEncodingException, AAIException {
+ throws UnsupportedEncodingException, AAIException {
List<String> uriList = new ArrayList<>();
String template;
@@ -893,17 +885,15 @@ public class DBSerializer {
* @throws AAIException the AAI exception
*/
private void processRelationshipList(Introspector wrapped, Vertex v)
- throws UnsupportedEncodingException, AAIException {
+ throws UnsupportedEncodingException, AAIException {
List<Object> relationships = wrapped.getValue("relationship");
String mainUri = getURIForVertex(v).toString();
String aNodeType = v.property(AAIProperties.NODE_TYPE).value().toString();
- EdgeRuleQuery.Builder cousinQueryBuilder = new EdgeRuleQuery.Builder(aNodeType)
- .edgeType(EdgeType.COUSIN)
- .version(wrapped.getVersion());
- EdgeRuleQuery.Builder treeQueryBuilder = new EdgeRuleQuery.Builder(aNodeType)
- .edgeType(EdgeType.TREE)
- .version(wrapped.getVersion());
+ EdgeRuleQuery.Builder cousinQueryBuilder =
+ new EdgeRuleQuery.Builder(aNodeType).edgeType(EdgeType.COUSIN).version(wrapped.getVersion());
+ EdgeRuleQuery.Builder treeQueryBuilder =
+ new EdgeRuleQuery.Builder(aNodeType).edgeType(EdgeType.TREE).version(wrapped.getVersion());
EdgeIngestor edgeIngestor = SpringContextAware.getBean(EdgeIngestor.class);
@@ -918,8 +908,9 @@ public class DBSerializer {
QueryParser parser = engine.getQueryBuilder().createQueryFromRelationship(wrappedRel);
List<Vertex> results = parser.getQueryBuilder().toList();
if (results.isEmpty()) {
- final AAIException ex = new AAIException(AAI_6129,
- String.format("Node of type %s. Could not find object at: %s", parser.getResultType(), parser.getUri()));
+ final AAIException ex =
+ new AAIException(AAI_6129, String.format("Node of type %s. Could not find object at: %s",
+ parser.getResultType(), parser.getUri()));
ex.getTemplateVars().add(parser.getResultType());
ex.getTemplateVars().add(parser.getUri().toString());
throw ex;
@@ -928,7 +919,8 @@ public class DBSerializer {
if (results.get(0).property(AAIProperties.AAI_URI).isPresent()) {
relUri = results.get(0).value(AAIProperties.AAI_URI);
} else {
- LOGGER.warn("Not processing the vertex {} because its missing required property aai-uri", results.get(0).id());
+ LOGGER.warn("Not processing the vertex {} because its missing required property aai-uri",
+ results.get(0).id());
continue;
}
}
@@ -943,19 +935,18 @@ public class DBSerializer {
if (!edgeIngestor.hasRule(ruleQuery)) {
EdgeRuleQuery treeQuery = treeQueryBuilder.to(bNodeType).build();
if (edgeIngestor.hasRule(treeQuery)) {
- throw new AAIException(AAI_6145); //attempted to create cousin edge for a parent-child edge rule
+ throw new AAIException(AAI_6145); // attempted to create cousin edge for a parent-child edge
+ // rule
}
- throw new AAIException("AAI_6120", String.format(
- "No EdgeRule found for passed nodeTypes: %s, %s.",
- aNodeType, bNodeType));
+ throw new AAIException("AAI_6120",
+ String.format("No EdgeRule found for passed nodeTypes: %s, %s.", aNodeType, bNodeType));
} else {
try {
final List<EdgeRule> rules = new ArrayList<>(edgeIngestor.getRules(ruleQuery).values());
if (rules.size() == 1) {
label = rules.get(0).getLabel();
} else {
- Optional<EdgeRule>
- defaultRule = rules.stream().filter(EdgeRule::isDefault).findFirst();
+ Optional<EdgeRule> defaultRule = rules.stream().filter(EdgeRule::isDefault).findFirst();
if (defaultRule.isPresent()) {
label = defaultRule.get().getLabel();
} else {
@@ -973,18 +964,17 @@ public class DBSerializer {
List<Path> paths = this.engine.getQueryEngine().findCousinsAsPath(v);
Set<Path> toRemove = new HashSet<>();
-
- // for each path 3 things can happen:
- // 1. The edge rule that created it is not in this version no action is to be taken on that edge
- // 2. The edge rule exits in this version it's included in the request the edge is left alone
- // 3. The edge rule exits in this version and is not included in the request it is marked for removal
+ // for each path 3 things can happen:
+ // 1. The edge rule that created it is not in this version no action is to be taken on that edge
+ // 2. The edge rule exits in this version it's included in the request the edge is left alone
+ // 3. The edge rule exits in this version and is not included in the request it is marked for removal
for (Path path : paths) {
if (path.size() < 3) {
continue;
}
// Path represents
- // v ----related-to--> otherV
+ // v ----related-to--> otherV
// In the above case,
// path objects get(0) returns vertex v
// path objects.get(1) returns edge related-to
@@ -1028,7 +1018,7 @@ public class DBSerializer {
List<Vertex> results = parser.getQueryBuilder().toList();
if (results.isEmpty()) {
final AAIException ex = new AAIException(AAI_6129,
- "Node of type " + parser.getResultType() + ". Could not find object at: " + parser.getUri());
+ "Node of type " + parser.getResultType() + ". Could not find object at: " + parser.getUri());
ex.getTemplateVars().add(parser.getResultType());
ex.getTemplateVars().add(parser.getUri().toString());
throw ex;
@@ -1043,11 +1033,11 @@ public class DBSerializer {
EdgeRuleQuery.Builder baseQ = new EdgeRuleQuery.Builder(vType, cousinType).label(label);
if (!edgeRules.hasRule(baseQ.build())) {
- throw new AAIException("AAI_6120", String.format(
- "No EdgeRule found for passed nodeTypes: %s, %s%s.",
- aNodeType, cousinType, label != null ? (" with label " + label) : ""));
+ throw new AAIException("AAI_6120",
+ String.format("No EdgeRule found for passed nodeTypes: %s, %s%s.", aNodeType, cousinType,
+ label != null ? (" with label " + label) : ""));
} else if (edgeRules.hasRule(baseQ.edgeType(EdgeType.TREE).build())
- && !edgeRules.hasRule(baseQ.edgeType(EdgeType.COUSIN).build())) {
+ && !edgeRules.hasRule(baseQ.edgeType(EdgeType.COUSIN).build())) {
throw new AAIException(AAI_6145);
}
@@ -1060,7 +1050,7 @@ public class DBSerializer {
}
for (Path path : toRemove) {
- if(isDeltaEventsEnabled) {
+ if (isDeltaEventsEnabled) {
deltaForEdge(mainUri, path.get(1), DeltaAction.DELETE_REL, DeltaAction.UPDATE);
}
this.updatedVertexes.putIfAbsent(v, false);
@@ -1070,7 +1060,8 @@ public class DBSerializer {
for (Pair<Vertex, String> create : toBeCreated) {
try {
- Edge e = edgeSer.addEdge(this.engine.asAdmin().getTraversalSource(), v, create.getValue0(), create.getValue1());
+ Edge e = edgeSer.addEdge(this.engine.asAdmin().getTraversalSource(), v, create.getValue0(),
+ create.getValue1());
if (isDeltaEventsEnabled) {
deltaForEdge(mainUri, e, DeltaAction.CREATE_REL, DeltaAction.UPDATE);
}
@@ -1082,15 +1073,12 @@ public class DBSerializer {
}
}
-
private void deltaForEdge(String mainUri, Edge edge, DeltaAction edgeAction, DeltaAction mainAction) {
- RelationshipDelta relationshipDelta = new RelationshipDelta(
- edgeAction,
- edge.inVertex().property(AAIProperties.AAI_UUID).value().toString(),
- edge.outVertex().property(AAIProperties.AAI_UUID).value().toString(),
- edge.inVertex().property(AAIProperties.AAI_URI).value().toString(),
- edge.outVertex().property(AAIProperties.AAI_URI).value().toString(),
- edge.label());
+ RelationshipDelta relationshipDelta =
+ new RelationshipDelta(edgeAction, edge.inVertex().property(AAIProperties.AAI_UUID).value().toString(),
+ edge.outVertex().property(AAIProperties.AAI_UUID).value().toString(),
+ edge.inVertex().property(AAIProperties.AAI_URI).value().toString(),
+ edge.outVertex().property(AAIProperties.AAI_URI).value().toString(), edge.label());
edge.properties().forEachRemaining(p -> relationshipDelta.addProp(p.key(), p.value().toString()));
addRelationshipDelta(mainUri, relationshipDelta, mainAction);
}
@@ -1196,8 +1184,9 @@ public class DBSerializer {
}
}
e = edgeSer.addTreeEdge(this.engine.asAdmin().getTraversalSource(), parent, child);
- if(isDeltaEventsEnabled) {
- deltaForEdge(child.property(AAIProperties.AAI_URI).value().toString(), e, DeltaAction.CREATE_REL, DeltaAction.CREATE);
+ if (isDeltaEventsEnabled) {
+ deltaForEdge(child.property(AAIProperties.AAI_URI).value().toString(), e, DeltaAction.CREATE_REL,
+ DeltaAction.CREATE);
}
}
return child;
@@ -1230,7 +1219,7 @@ public class DBSerializer {
* @throws URISyntaxException
*/
public Introspector dbToObject(List<Vertex> vertices, final Introspector obj, int depth, boolean nodeOnly,
- String cleanUp, boolean isSkipRelatedTo) throws UnsupportedEncodingException, AAIException {
+ String cleanUp, boolean isSkipRelatedTo) throws UnsupportedEncodingException, AAIException {
final int internalDepth;
if (depth == Integer.MAX_VALUE) {
internalDepth = depth--;
@@ -1241,7 +1230,7 @@ public class DBSerializer {
if (vertices.size() > 1 && !obj.isContainer()) {
dbTimeMsecs += StopWatch.stopIfStarted();
throw new AAIException("AAI_6136",
- "query object mismatch: this object cannot hold multiple items." + obj.getDbName());
+ "query object mismatch: this object cannot hold multiple items." + obj.getDbName());
} else if (obj.isContainer()) {
final List getList;
String listProperty = null;
@@ -1357,7 +1346,7 @@ public class DBSerializer {
* @throws URISyntaxException
*/
private Introspector dbToObject(Introspector obj, Vertex v, Set<Vertex> seen, int depth, boolean nodeOnly,
- String cleanUp, boolean isSkipRelatedTo) throws AAIException, UnsupportedEncodingException {
+ String cleanUp, boolean isSkipRelatedTo) throws AAIException, UnsupportedEncodingException {
if (depth < 0) {
return null;
@@ -1406,7 +1395,7 @@ public class DBSerializer {
try {
rule = edgeRules.getRule(
- new EdgeRuleQuery.Builder(vType, childDbName).edgeType(EdgeType.TREE).build());
+ new EdgeRuleQuery.Builder(vType, childDbName).edgeType(EdgeType.TREE).build());
} catch (EdgeRuleNotFoundException e) {
throw new NoEdgeRuleFoundException(e);
} catch (AmbiguousRuleChoiceException e) {
@@ -1429,8 +1418,8 @@ public class DBSerializer {
if (!seen.contains(childVertex)) {
Introspector argumentObject = obj.newIntrospectorInstanceOfNestedProperty(property);
- Object result =
- dbToObject(argumentObject, childVertex, seen, depth, nodeOnly, cleanUp, isSkipRelatedTo);
+ Object result = dbToObject(argumentObject, childVertex, seen, depth, nodeOnly,
+ cleanUp, isSkipRelatedTo);
if (result != null && getList != null) {
getList.add(argumentObject.getUnderlyingObject());
}
@@ -1438,7 +1427,7 @@ public class DBSerializer {
processed++;
} else {
LOGGER.warn("Cycle found while serializing vertex id={}",
- childVertex.id().toString());
+ childVertex.id().toString());
}
}
if (processed == 0) {
@@ -1532,7 +1521,8 @@ public class DBSerializer {
return simplePropsHashMap;
}
- public Introspector dbToRelationshipObject(Vertex v, boolean isSkipRelatedTo) throws UnsupportedEncodingException, AAIException {
+ public Introspector dbToRelationshipObject(Vertex v, boolean isSkipRelatedTo)
+ throws UnsupportedEncodingException, AAIException {
Introspector relationshipList = this.latestLoader.introspectorFromName("relationship-list");
relationshipList = createRelationshipList(v, relationshipList, FALSE, isSkipRelatedTo);
return relationshipList;
@@ -1588,9 +1578,8 @@ public class DBSerializer {
EdgeIngestor edgeIngestor = SpringContextAware.getBean(EdgeIngestor.class);
- EdgeRuleQuery.Builder queryBuilder = new EdgeRuleQuery.Builder(aNodeType)
- .edgeType(EdgeType.COUSIN)
- .version(obj.getVersion());
+ EdgeRuleQuery.Builder queryBuilder =
+ new EdgeRuleQuery.Builder(aNodeType).edgeType(EdgeType.COUSIN).version(obj.getVersion());
for (Path path : paths) {
if (path.size() < 3) {
@@ -1598,7 +1587,7 @@ public class DBSerializer {
}
// Path represents
- // v ----related-to--> otherV
+ // v ----related-to--> otherV
// In the above case,
// path objects get(0) returns vertex v
// path objects.get(1) returns edge related-to
@@ -1627,7 +1616,7 @@ public class DBSerializer {
EdgeRuleQuery ruleQuery = queryBuilder.to(bNodeType).label(edgeLabel).build();
if (!edgeIngestor.hasRule(ruleQuery)) {
- LOGGER.debug( "Caught an edge rule not found for query {}", ruleQuery);
+ LOGGER.debug("Caught an edge rule not found for query {}", ruleQuery);
continue;
}
@@ -1724,7 +1713,6 @@ public class DBSerializer {
return uri;
}
-
public void addRelatedToProperty(Introspector relationship, Vertex cousinVertex, String cousinType)
throws AAIUnknownObjectException {
@@ -1816,8 +1804,9 @@ public class DBSerializer {
e = this.getEdgeBetween(EdgeType.COUSIN, inputVertex, relatedVertex, label);
if (e == null) {
e = edgeSer.addEdge(this.engine.asAdmin().getTraversalSource(), inputVertex, relatedVertex, label);
- if(isDeltaEventsEnabled) {
- deltaForEdge(inputVertex.property(AAIProperties.AAI_URI).value().toString(), e, DeltaAction.CREATE_REL, DeltaAction.UPDATE);
+ if (isDeltaEventsEnabled) {
+ deltaForEdge(inputVertex.property(AAIProperties.AAI_URI).value().toString(), e,
+ DeltaAction.CREATE_REL, DeltaAction.UPDATE);
}
} else {
// attempted to link two vertexes already linked
@@ -2046,23 +2035,22 @@ public class DBSerializer {
for (Vertex v : vertices) {
LOGGER.debug("Removing vertex {} with label {}", v.id(), v.label());
- if(isDeltaEventsEnabled) {
+ if (isDeltaEventsEnabled) {
deltaForVertexDelete(v);
}
- //add the cousin vertexes of v to have their resource-version updated and notified on.
- v.edges(Direction.BOTH)
- .forEachRemaining(e -> {
- if (e.property(EdgeProperty.CONTAINS.toString()).isPresent()
+ // add the cousin vertexes of v to have their resource-version updated and notified on.
+ v.edges(Direction.BOTH).forEachRemaining(e -> {
+ if (e.property(EdgeProperty.CONTAINS.toString()).isPresent()
&& AAIDirection.NONE.toString().equals(e.<String>value(EdgeProperty.CONTAINS.toString()))) {
- e.bothVertices().forEachRemaining(cousinV -> {
- if (!v.equals(cousinV)) {
- edgeVertexes.add(cousinV);
- }
- });
- }
- });
+ e.bothVertices().forEachRemaining(cousinV -> {
+ if (!v.equals(cousinV)) {
+ edgeVertexes.add(cousinV);
+ }
+ });
+ }
+ });
- //if somewhere along the way v was added to the sets tracking the what is to be updated/notified on
+ // if somewhere along the way v was added to the sets tracking the what is to be updated/notified on
// it should be removed from them as v is to be deleted
edgeVertexes.remove(v);
updatedVertexes.remove(v);
@@ -2078,16 +2066,15 @@ public class DBSerializer {
List<Object> list = new ArrayList<>();
vertex.properties(k).forEachRemaining(vp -> list.add(vp.value()));
if (list.size() == 1) {
- addPropDelta(aaiUri, k,
- PropertyDeltaFactory.getDelta(DeltaAction.DELETE, list.get(0)),
- DeltaAction.DELETE);
+ addPropDelta(aaiUri, k, PropertyDeltaFactory.getDelta(DeltaAction.DELETE, list.get(0)),
+ DeltaAction.DELETE);
} else {
- addPropDelta(aaiUri, k, PropertyDeltaFactory.getDelta(DeltaAction.DELETE, list),
- DeltaAction.DELETE);
+ addPropDelta(aaiUri, k, PropertyDeltaFactory.getDelta(DeltaAction.DELETE, list), DeltaAction.DELETE);
}
});
- vertex.edges(Direction.BOTH).forEachRemaining(e -> deltaForEdge(aaiUri, e, DeltaAction.DELETE, DeltaAction.DELETE));
+ vertex.edges(Direction.BOTH)
+ .forEachRemaining(e -> deltaForEdge(aaiUri, e, DeltaAction.DELETE, DeltaAction.DELETE));
}
/**
@@ -2162,7 +2149,7 @@ public class DBSerializer {
nodeType = vertex.<String>property(AAIProperties.NODE_TYPE).orElse(null);
if (enableResourceVersion) {
this.verifyResourceVersion("delete", nodeType,
- vertex.<String>property(AAIProperties.RESOURCE_VERSION).orElse(null), resourceVersion, nodeType);
+ vertex.<String>property(AAIProperties.RESOURCE_VERSION).orElse(null), resourceVersion, nodeType);
}
List<Vertex> vertices = new ArrayList<>();
vertices.add(vertex);
@@ -2202,10 +2189,9 @@ public class DBSerializer {
dbTimeMsecs += StopWatch.stopIfStarted();
if (!preventDeleteVertices.isEmpty()) {
aaiExceptionCode = "AAI_6110";
- errorDetail = String.format(
- "Object is being reference by additional objects preventing it from being deleted." +
- " Please clean up references from the following types %s",
- preventDeleteVertices);
+ errorDetail =
+ String.format("Object is being reference by additional objects preventing it from being deleted."
+ + " Please clean up references from the following types %s", preventDeleteVertices);
result = false;
}
if (!result) {
@@ -2319,9 +2305,8 @@ public class DBSerializer {
private void executePreSideEffects(Introspector obj, Vertex self) throws AAIException {
- SideEffectRunner.Builder runnerBuilder =
- new SideEffectRunner.Builder(this.engine, this).addSideEffect(DataCopy.class)
- .addSideEffect(PrivateEdge.class);
+ SideEffectRunner.Builder runnerBuilder = new SideEffectRunner.Builder(this.engine, this)
+ .addSideEffect(DataCopy.class).addSideEffect(PrivateEdge.class);
if (isMultiTenancyEnabled) {
runnerBuilder.addSideEffect(OwnerCheck.class);
}
@@ -2339,7 +2324,7 @@ public class DBSerializer {
private void enrichData(Introspector obj, Vertex self) throws AAIException {
SideEffectRunner.Builder runnerBuilder =
- new SideEffectRunner.Builder(this.engine, this).addSideEffect(DataLinkReader.class);
+ new SideEffectRunner.Builder(this.engine, this).addSideEffect(DataLinkReader.class);
if (isMultiTenancyEnabled) {
runnerBuilder.addSideEffect(OwnerCheck.class);
@@ -2373,11 +2358,10 @@ public class DBSerializer {
* @throws AAIUnknownObjectException
* @throws URISyntaxException
*/
- public Introspector dbToObjectWithFilters(Introspector obj, Vertex vertex, Set<Vertex> seen, int depth, boolean nodeOnly,
- List<String> filterCousinNodes, List<String> filterParentNodes)
- throws AAIException, UnsupportedEncodingException {
- return dbToObjectWithFilters(obj, vertex, seen, depth, nodeOnly,
- filterCousinNodes, filterParentNodes, false);
+ public Introspector dbToObjectWithFilters(Introspector obj, Vertex vertex, Set<Vertex> seen, int depth,
+ boolean nodeOnly, List<String> filterCousinNodes, List<String> filterParentNodes)
+ throws AAIException, UnsupportedEncodingException {
+ return dbToObjectWithFilters(obj, vertex, seen, depth, nodeOnly, filterCousinNodes, filterParentNodes, false);
}
/**
@@ -2405,8 +2389,8 @@ public class DBSerializer {
* @throws URISyntaxException
*/
// TODO - See if you can merge the 2 dbToObjectWithFilters
- public Introspector dbToObjectWithFilters(Introspector obj, Vertex vertexParam, Set<Vertex> seen, int depth, boolean nodeOnly,
- List<String> filterCousinNodes, List<String> filterParentNodes, boolean isSkipRelatedTo)
+ public Introspector dbToObjectWithFilters(Introspector obj, Vertex vertexParam, Set<Vertex> seen, int depth,
+ boolean nodeOnly, List<String> filterCousinNodes, List<String> filterParentNodes, boolean isSkipRelatedTo)
throws AAIException, UnsupportedEncodingException {
String cleanUp = FALSE;
if (depth < 0) {
@@ -2436,8 +2420,7 @@ public class DBSerializer {
} else if (property.equals("relationship-list") && !nodeOnly) {
/* relationships need to be handled correctly */
Introspector relationshipList = obj.newIntrospectorInstanceOfProperty(property);
- relationshipList =
- createFilteredRelationshipList(vertexParam, relationshipList, cleanUp,
+ relationshipList = createFilteredRelationshipList(vertexParam, relationshipList, cleanUp,
filterCousinNodes, isSkipRelatedTo);
if (relationshipList != null) {
obj.setValue(property, relationshipList.getUnderlyingObject());
@@ -2459,7 +2442,8 @@ public class DBSerializer {
boolean isThisParentRequired =
filterParentNodes.parallelStream().anyMatch(childDbName::contains);
- EdgeRuleQuery query = new EdgeRuleQuery.Builder(vertexType, childDbName).edgeType(EdgeType.TREE).build();
+ EdgeRuleQuery query =
+ new EdgeRuleQuery.Builder(vertexType, childDbName).edgeType(EdgeType.TREE).build();
try {
rule = edgeRules.getRule(query);
@@ -2547,7 +2531,7 @@ public class DBSerializer {
Iterator<Vertex> cousinVertices = allCousins.stream().filter(item -> {
String node = (String) item.property(AAIProperties.NODE_TYPE).orElse("");
return filterNodes.parallelStream().anyMatch(node::contains);
- }).iterator();
+ }).iterator();
List<Object> relationshipObjList = obj.getValue(RELATIONSHIP);
diff --git a/aai-core/src/main/java/org/onap/aai/serialization/db/GraphSingleton.java b/aai-core/src/main/java/org/onap/aai/serialization/db/GraphSingleton.java
index 3a7c6d2d..f7d97f33 100644
--- a/aai-core/src/main/java/org/onap/aai/serialization/db/GraphSingleton.java
+++ b/aai-core/src/main/java/org/onap/aai/serialization/db/GraphSingleton.java
@@ -20,11 +20,11 @@
package org.onap.aai.serialization.db;
+import java.util.concurrent.atomic.AtomicInteger;
+
import org.janusgraph.core.JanusGraph;
import org.onap.aai.dbmap.AAIGraph;
-import java.util.concurrent.atomic.AtomicInteger;
-
/* This class simply calls AAIGraph under the covers for now */
public class GraphSingleton {
diff --git a/aai-core/src/main/java/org/onap/aai/serialization/db/ImpliedDelete.java b/aai-core/src/main/java/org/onap/aai/serialization/db/ImpliedDelete.java
index f8f057d6..2c0a91c2 100644
--- a/aai-core/src/main/java/org/onap/aai/serialization/db/ImpliedDelete.java
+++ b/aai-core/src/main/java/org/onap/aai/serialization/db/ImpliedDelete.java
@@ -17,6 +17,7 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
+
package org.onap.aai.serialization.db;
import java.util.List;
@@ -57,7 +58,7 @@ public class ImpliedDelete implements AAIConfigProxy {
private TransactionalGraphEngine engine;
private DBSerializer serializer;
- public ImpliedDelete(TransactionalGraphEngine engine, DBSerializer serializer){
+ public ImpliedDelete(TransactionalGraphEngine engine, DBSerializer serializer) {
this.engine = engine;
this.serializer = serializer;
}
@@ -83,22 +84,21 @@ public class ImpliedDelete implements AAIConfigProxy {
* @param dependentVertexes - list of children vertexes
* @throws AAIException if the user is not allowed to implicitly delete children
*/
- public List<Vertex> execute(Object id, String sot, String objectType, List<Vertex> dependentVertexes) throws AAIException {
- if(dependentVertexes != null && !dependentVertexes.isEmpty()){
+ public List<Vertex> execute(Object id, String sot, String objectType, List<Vertex> dependentVertexes)
+ throws AAIException {
+ if (dependentVertexes != null && !dependentVertexes.isEmpty()) {
// Find all the deletable vertices from the dependent vertices that should be deleted
// So for each of the following dependent vertices,
// we will use the edge properties and do the cascade delete
QueryEngine queryEngine = this.engine.getQueryEngine();
List<Vertex> impliedDeleteVertices = queryEngine.findDeletable(dependentVertexes);
- if(this.allow(sot, objectType)){
+ if (this.allow(sot, objectType)) {
int impliedDeleteCount = impliedDeleteVertices.size();
LOGGER.warn(
- "For the vertex with id {}, doing an implicit delete on update will delete total of {} vertexes",
- id,
- impliedDeleteCount
- );
+ "For the vertex with id {}, doing an implicit delete on update will delete total of {} vertexes",
+ id, impliedDeleteCount);
String impliedDeleteLogEnabled = get(AAIConstants.AAI_IMPLIED_DELETE_LOG_ENABLED, "true");
@@ -120,8 +120,8 @@ public class ImpliedDelete implements AAIConfigProxy {
}
} catch (Exception ex) {
LOGGER.warn(
- "Encountered an exception during retrieval of vertex properties with vertex-id {} -> {}",
- id, LogFormatTools.getStackTop(ex));
+ "Encountered an exception during retrieval of vertex properties with vertex-id {} -> {}",
+ id, LogFormatTools.getStackTop(ex));
}
}
}
@@ -136,11 +136,11 @@ public class ImpliedDelete implements AAIConfigProxy {
}
}
- public void delete(List<Vertex> vertices){
- // After all the appropriate logging, calling the serializer delete to delete the affected vertices
- if(vertices != null && !vertices.isEmpty()){
- serializer.delete(vertices);
- }
+ public void delete(List<Vertex> vertices) {
+ // After all the appropriate logging, calling the serializer delete to delete the affected vertices
+ if (vertices != null && !vertices.isEmpty()) {
+ serializer.delete(vertices);
+ }
}
/**
@@ -157,13 +157,13 @@ public class ImpliedDelete implements AAIConfigProxy {
* So in the above code, the expectation is for any of the following user:
*
* <ul>
- * <li>SDC</li>
- * <li>SDc</li>
- * <li>Sdc</li>
- * <li>sDc</li>
- * <li>SdC</li>
- * <li>sdC</li>
- * <li>sdc</li>
+ * <li>SDC</li>
+ * <li>SDc</li>
+ * <li>Sdc</li>
+ * <li>sDc</li>
+ * <li>SdC</li>
+ * <li>sdC</li>
+ * <li>sdc</li>
* </ul>
*
* They are allowed to delete the children of pserver and vserver by implicit delete
@@ -175,28 +175,28 @@ public class ImpliedDelete implements AAIConfigProxy {
* or loading into an set which is unnecessary and it could potentially be done for every request
*
* @param sourceOfTruth - the original requester that the request is coming from,
- * derived from HTTP Header X-FromAppId
+ * derived from HTTP Header X-FromAppId
* @param parentObjectType - parent object in which they are trying to do the implicit delete against
*
- * @return true - if the requester is allowed to implicit delete against the object type
+ * @return true - if the requester is allowed to implicit delete against the object type
* false - if they are not allowed
*/
- private boolean allow(String sourceOfTruth, String parentObjectType){
+ private boolean allow(String sourceOfTruth, String parentObjectType) {
Objects.requireNonNull(sourceOfTruth);
Objects.requireNonNull(parentObjectType);
String propertyName = AAIConstants.AAI_IMPLIED_DELETE_WHITELIST + sourceOfTruth.toLowerCase();
String whitelist = get(propertyName, StringUtils.EMPTY);
- if(whitelist.isEmpty()){
+ if (whitelist.isEmpty()) {
return false;
}
- if(STAR.equals(whitelist)){
+ if (STAR.equals(whitelist)) {
return true;
}
- if(whitelist.contains("'" + parentObjectType + "'")){
+ if (whitelist.contains("'" + parentObjectType + "'")) {
return true;
}
diff --git a/aai-core/src/main/java/org/onap/aai/serialization/engines/InMemoryDBEngine.java b/aai-core/src/main/java/org/onap/aai/serialization/engines/InMemoryDBEngine.java
index 66509c97..e11b4aef 100644
--- a/aai-core/src/main/java/org/onap/aai/serialization/engines/InMemoryDBEngine.java
+++ b/aai-core/src/main/java/org/onap/aai/serialization/engines/InMemoryDBEngine.java
@@ -20,6 +20,10 @@
package org.onap.aai.serialization.engines;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource;
import org.apache.tinkerpop.gremlin.process.traversal.strategy.verification.ReadOnlyStrategy;
import org.apache.tinkerpop.gremlin.structure.Graph;
@@ -32,10 +36,6 @@ import org.onap.aai.serialization.db.InMemoryGraphSingleton;
import org.onap.aai.serialization.engines.query.GraphTraversalQueryEngine;
import org.onap.aai.serialization.engines.query.QueryEngine;
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-
public class InMemoryDBEngine extends TransactionalGraphEngine {
/**
diff --git a/aai-core/src/main/java/org/onap/aai/serialization/engines/JanusGraphDBEngine.java b/aai-core/src/main/java/org/onap/aai/serialization/engines/JanusGraphDBEngine.java
index 2a4511d0..f2e40afb 100644
--- a/aai-core/src/main/java/org/onap/aai/serialization/engines/JanusGraphDBEngine.java
+++ b/aai-core/src/main/java/org/onap/aai/serialization/engines/JanusGraphDBEngine.java
@@ -20,15 +20,15 @@
package org.onap.aai.serialization.engines;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
import org.apache.tinkerpop.gremlin.structure.Vertex;
import org.apache.tinkerpop.gremlin.structure.VertexProperty;
import org.onap.aai.introspection.Loader;
import org.onap.aai.serialization.db.JanusGraphSingleton;
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-
public class JanusGraphDBEngine extends TransactionalGraphEngine {
/**
diff --git a/aai-core/src/main/java/org/onap/aai/serialization/engines/TransactionalGraphEngine.java b/aai-core/src/main/java/org/onap/aai/serialization/engines/TransactionalGraphEngine.java
index b945db05..6327272b 100644
--- a/aai-core/src/main/java/org/onap/aai/serialization/engines/TransactionalGraphEngine.java
+++ b/aai-core/src/main/java/org/onap/aai/serialization/engines/TransactionalGraphEngine.java
@@ -20,6 +20,9 @@
package org.onap.aai.serialization.engines;
+import java.util.List;
+import java.util.concurrent.atomic.AtomicInteger;
+
import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource;
import org.apache.tinkerpop.gremlin.process.traversal.strategy.verification.ReadOnlyStrategy;
import org.apache.tinkerpop.gremlin.structure.Graph;
@@ -32,9 +35,6 @@ import org.onap.aai.serialization.db.GraphSingleton;
import org.onap.aai.serialization.engines.query.GraphTraversalQueryEngine;
import org.onap.aai.serialization.engines.query.QueryEngine;
-import java.util.List;
-import java.util.concurrent.atomic.AtomicInteger;
-
public abstract class TransactionalGraphEngine {
protected GraphSingleton singleton = null;
@@ -163,7 +163,7 @@ public abstract class TransactionalGraphEngine {
throw new IllegalArgumentException("History Traversal needs history traversal source");
} else if (style.equals(QueryStyle.HISTORY_GREMLIN_TRAVERSAL)) {
throw new IllegalArgumentException("History Gremlin Traversal needs history traversal source");
- }else {
+ } else {
throw new IllegalArgumentException("Query Builder type not recognized");
}
return queryBuilder;
@@ -182,9 +182,9 @@ public abstract class TransactionalGraphEngine {
return new TraversalURIOptimizedQuery<>(loader, source);
} else if (style.equals(QueryStyle.HISTORY_TRAVERSAL)) {
return new HistoryTraversalURIOptimizedQuery<>(loader, source);
- }else if (style.equals(QueryStyle.HISTORY_GREMLIN_TRAVERSAL)) {
+ } else if (style.equals(QueryStyle.HISTORY_GREMLIN_TRAVERSAL)) {
return new HistoryGremlinTraversal<>(loader, source);
- }else {
+ } else {
throw new IllegalArgumentException("Query Builder type not recognized");
}
return queryBuilder;
@@ -225,7 +225,7 @@ public abstract class TransactionalGraphEngine {
if (this.tx() == null) {
this.currentTx = this.getGraph().newTransaction();
this.currentTraversal = this.tx().traversal();
- this.readOnlyTraversal =this.tx().traversal().withStrategies(ReadOnlyStrategy.instance());
+ this.readOnlyTraversal = this.tx().traversal().withStrategies(ReadOnlyStrategy.instance());
}
return currentTx;
}
diff --git a/aai-core/src/main/java/org/onap/aai/serialization/engines/query/GraphTraversalQueryEngine.java b/aai-core/src/main/java/org/onap/aai/serialization/engines/query/GraphTraversalQueryEngine.java
index 376a2798..c96e8d22 100644
--- a/aai-core/src/main/java/org/onap/aai/serialization/engines/query/GraphTraversalQueryEngine.java
+++ b/aai-core/src/main/java/org/onap/aai/serialization/engines/query/GraphTraversalQueryEngine.java
@@ -20,6 +20,14 @@
package org.onap.aai.serialization.engines.query;
+import static org.onap.aai.edges.enums.AAIDirection.*;
+import static org.onap.aai.edges.enums.EdgeField.PRIVATE;
+import static org.onap.aai.edges.enums.EdgeProperty.CONTAINS;
+import static org.onap.aai.edges.enums.EdgeProperty.DELETE_OTHER_V;
+
+import java.util.List;
+import java.util.Set;
+
import org.apache.tinkerpop.gremlin.process.traversal.Order;
import org.apache.tinkerpop.gremlin.process.traversal.P;
import org.apache.tinkerpop.gremlin.process.traversal.Path;
@@ -37,14 +45,6 @@ import org.onap.aai.edges.enums.EdgeProperty;
import org.onap.aai.introspection.Loader;
import org.onap.aai.logging.StopWatch;
-import java.util.List;
-import java.util.Set;
-
-import static org.onap.aai.edges.enums.AAIDirection.*;
-import static org.onap.aai.edges.enums.EdgeField.PRIVATE;
-import static org.onap.aai.edges.enums.EdgeProperty.CONTAINS;
-import static org.onap.aai.edges.enums.EdgeProperty.DELETE_OTHER_V;
-
/*
* This class needs some big explanation despite its compact size.
* This controls all the queries performed by the CRUD API in A&AI.
@@ -257,13 +257,9 @@ public class GraphTraversalQueryEngine extends QueryEngine {
return pipeline.toList();
}
- public List<Path> findCousinsAsPath(Vertex start){
- return this.g.V(start).bothE().where(
- __.and(
- __.has(EdgeProperty.CONTAINS.toString(), NONE.toString()),
- __.not(__.has(EdgeField.PRIVATE.toString(), true))
- )
- ).otherV().path().toList();
+ public List<Path> findCousinsAsPath(Vertex start) {
+ return this.g.V(start).bothE().where(__.and(__.has(EdgeProperty.CONTAINS.toString(), NONE.toString()),
+ __.not(__.has(EdgeField.PRIVATE.toString(), true)))).otherV().path().toList();
}
public double getDBTimeMsecs() {
diff --git a/aai-core/src/main/java/org/onap/aai/serialization/queryformats/Aggregate.java b/aai-core/src/main/java/org/onap/aai/serialization/queryformats/Aggregate.java
index 9ce343f6..28362826 100644
--- a/aai-core/src/main/java/org/onap/aai/serialization/queryformats/Aggregate.java
+++ b/aai-core/src/main/java/org/onap/aai/serialization/queryformats/Aggregate.java
@@ -20,11 +20,13 @@
package org.onap.aai.serialization.queryformats;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
import com.google.gson.*;
-import org.apache.tinkerpop.gremlin.structure.Direction;
-import org.apache.tinkerpop.gremlin.structure.Edge;
+
+import java.io.UnsupportedEncodingException;
+import java.util.*;
+import java.util.stream.Collectors;
+import java.util.stream.Stream;
+
import org.apache.tinkerpop.gremlin.structure.Vertex;
import org.apache.tinkerpop.gremlin.structure.VertexProperty;
import org.onap.aai.db.props.AAIProperties;
@@ -40,11 +42,8 @@ import org.onap.aai.serialization.queryformats.params.AsTree;
import org.onap.aai.serialization.queryformats.params.Depth;
import org.onap.aai.serialization.queryformats.params.NodesOnly;
import org.onap.aai.serialization.queryformats.utils.UrlBuilder;
-
-import java.io.UnsupportedEncodingException;
-import java.util.*;
-import java.util.stream.Collectors;
-import java.util.stream.Stream;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
public class Aggregate extends MultiFormatMapper {
private static final Logger LOGGER = LoggerFactory.getLogger(LifecycleFormat.class);
@@ -65,13 +64,14 @@ public class Aggregate extends MultiFormatMapper {
}
@Override
- public Optional<JsonObject> getJsonFromVertex(Vertex v, Map<String, List<String>> selectedProps) throws AAIFormatVertexException{
+ public Optional<JsonObject> getJsonFromVertex(Vertex v, Map<String, List<String>> selectedProps)
+ throws AAIFormatVertexException {
JsonObject json = new JsonObject();
JsonObject outer = new JsonObject();
- Optional<JsonObject> properties = this.createSelectedPropertiesObject(v,selectedProps);
+ Optional<JsonObject> properties = this.createSelectedPropertiesObject(v, selectedProps);
if (properties.isPresent()) {
json.add("properties", properties.get());
- outer.add(this.urlBuilder.pathed(v),json.getAsJsonObject());
+ outer.add(this.urlBuilder.pathed(v), json.getAsJsonObject());
} else {
return Optional.empty();
}
@@ -86,7 +86,7 @@ public class Aggregate extends MultiFormatMapper {
public Optional<JsonObject> createPropertiesObject(Vertex v) throws AAIFormatVertexException {
try {
final Introspector obj =
- loader.introspectorFromName(v.<String>property(AAIProperties.NODE_TYPE).orElse(null));
+ loader.introspectorFromName(v.<String>property(AAIProperties.NODE_TYPE).orElse(null));
final List<Vertex> wrapper = new ArrayList<>();
wrapper.add(v);
@@ -95,7 +95,7 @@ public class Aggregate extends MultiFormatMapper {
serializer.dbToObject(wrapper, obj, 0, true, "false");
} catch (AAIException | UnsupportedEncodingException e) {
throw new AAIFormatVertexException(
- "Failed to format vertex - error while serializing: " + e.getMessage(), e);
+ "Failed to format vertex - error while serializing: " + e.getMessage(), e);
}
final String json = obj.marshal(false);
@@ -105,7 +105,8 @@ public class Aggregate extends MultiFormatMapper {
}
}
- public Optional<JsonObject> createSelectedPropertiesObject(Vertex v, Map<String, List<String>> selectedProps) throws AAIFormatVertexException {
+ public Optional<JsonObject> createSelectedPropertiesObject(Vertex v, Map<String, List<String>> selectedProps)
+ throws AAIFormatVertexException {
JsonObject json = new JsonObject();
Set<String> propList = null;
String nodeType = v.<String>value(AAIProperties.NODE_TYPE);
@@ -140,10 +141,9 @@ public class Aggregate extends MultiFormatMapper {
return Optional.of(json);
}
- private Set<String> removeSingleQuotesForProperties(List<String> props){
+ private Set<String> removeSingleQuotesForProperties(List<String> props) {
if (props != null && !props.isEmpty()) {
- return props.stream().map(
- e -> e.substring(1, e.length()-1)).collect(Collectors.toSet());
+ return props.stream().map(e -> e.substring(1, e.length() - 1)).collect(Collectors.toSet());
} else {
return Collections.emptySet();
}
@@ -169,23 +169,21 @@ public class Aggregate extends MultiFormatMapper {
}
return Optional.<JsonObject>empty();
- }).filter(Optional::isPresent)
- .map(Optional::get)
- .forEach(json -> {
- if (isParallel) {
- synchronized (body) {
- body.add(json);
- }
- } else {
+ }).filter(Optional::isPresent).map(Optional::get).forEach(json -> {
+ if (isParallel) {
+ synchronized (body) {
body.add(json);
}
- });
+ } else {
+ body.add(json);
+ }
+ });
return body;
}
@Override
public Optional<JsonObject> formatObject(Object input, Map<String, List<String>> properties)
- throws AAIFormatVertexException, AAIFormatQueryResultFormatNotSupported {
+ throws AAIFormatVertexException, AAIFormatQueryResultFormatNotSupported {
JsonObject json = new JsonObject();
if (input instanceof ArrayList) {
Optional<JsonArray> ja = processInput(input, properties);
@@ -198,7 +196,7 @@ public class Aggregate extends MultiFormatMapper {
private Optional<JsonArray> processInput(Object input, Map properties) throws AAIFormatVertexException {
JsonArray json = new JsonArray();
- for (Object l : (ArrayList) input) {
+ for (Object l : (ArrayList) input) {
if (l instanceof ArrayList) {
JsonArray inner = new JsonArray();
for (Vertex o : (ArrayList<Vertex>) l) {
@@ -213,8 +211,9 @@ public class Aggregate extends MultiFormatMapper {
}
json.add(inner);
} else {
- Optional<JsonObject> obj = this.getJsonFromVertex((Vertex)l, properties);
- if(obj.isPresent()) json.add(obj.get());
+ Optional<JsonObject> obj = this.getJsonFromVertex((Vertex) l, properties);
+ if (obj.isPresent())
+ json.add(obj.get());
}
}
return Optional.of(json);
@@ -237,7 +236,9 @@ public class Aggregate extends MultiFormatMapper {
this.urlBuilder = urlBuilder;
}
- protected boolean isTree() { return this.tree; }
+ protected boolean isTree() {
+ return this.tree;
+ }
public Builder isTree(Boolean tree) {
this.tree = tree;
@@ -293,7 +294,7 @@ public class Aggregate extends MultiFormatMapper {
}
public Aggregate build() {
- return new Aggregate(this);
+ return new Aggregate(this);
}
}
diff --git a/aai-core/src/main/java/org/onap/aai/serialization/queryformats/ChangesFormat.java b/aai-core/src/main/java/org/onap/aai/serialization/queryformats/ChangesFormat.java
index bbaed360..7caa1bd3 100644
--- a/aai-core/src/main/java/org/onap/aai/serialization/queryformats/ChangesFormat.java
+++ b/aai-core/src/main/java/org/onap/aai/serialization/queryformats/ChangesFormat.java
@@ -22,15 +22,16 @@ package org.onap.aai.serialization.queryformats;
import com.google.gson.JsonArray;
import com.google.gson.JsonObject;
+
+import java.util.*;
+import java.util.concurrent.TimeUnit;
+
import org.apache.tinkerpop.gremlin.structure.Direction;
import org.apache.tinkerpop.gremlin.structure.Vertex;
import org.onap.aai.config.SpringContextAware;
import org.onap.aai.db.props.AAIProperties;
import org.onap.aai.serialization.queryformats.exceptions.AAIFormatVertexException;
-import java.util.*;
-import java.util.concurrent.TimeUnit;
-
public class ChangesFormat extends MultiFormatMapper {
private Long startTs = 0L;
@@ -39,9 +40,11 @@ public class ChangesFormat extends MultiFormatMapper {
/*
* StartTs = truncate time
*/
- if (startTime == null || startTime.isEmpty() || "now".equals(startTime) || "0".equals(startTime) || "-1".equals(startTime)){
- String historyTruncateDays = SpringContextAware.getApplicationContext().getEnvironment().getProperty("history.truncate.window.days", "365");
- this.startTs = System.currentTimeMillis() - TimeUnit.DAYS.toMillis(Long.parseLong(historyTruncateDays));
+ if (startTime == null || startTime.isEmpty() || "now".equals(startTime) || "0".equals(startTime)
+ || "-1".equals(startTime)) {
+ String historyTruncateDays = SpringContextAware.getApplicationContext().getEnvironment()
+ .getProperty("history.truncate.window.days", "365");
+ this.startTs = System.currentTimeMillis() - TimeUnit.DAYS.toMillis(Long.parseLong(historyTruncateDays));
} else {
this.startTs = Long.parseLong(startTime);
}
@@ -50,29 +53,28 @@ public class ChangesFormat extends MultiFormatMapper {
@Override
protected Optional<JsonObject> getJsonFromVertex(Vertex v) {
JsonObject json = new JsonObject();
- if (!v.properties(AAIProperties.RESOURCE_VERSION).hasNext() ||
- !v.properties(AAIProperties.NODE_TYPE).hasNext() ||
- !v.properties(AAIProperties.AAI_URI).hasNext()) {
+ if (!v.properties(AAIProperties.RESOURCE_VERSION).hasNext() || !v.properties(AAIProperties.NODE_TYPE).hasNext()
+ || !v.properties(AAIProperties.AAI_URI).hasNext()) {
return Optional.empty();
}
json.addProperty("node-type", v.<String>value(AAIProperties.NODE_TYPE));
json.addProperty("uri", v.<String>value(AAIProperties.AAI_URI));
final Set<Long> changes = new HashSet<>();
- v.properties(AAIProperties.RESOURCE_VERSION).forEachRemaining(o->
- o.properties(AAIProperties.START_TS, AAIProperties.END_TS)
- .forEachRemaining(p -> {
- Long val = (Long) p.value();
- if(val >= startTs) {
- changes.add(val);
- }
- }
- ));
+ v.properties(AAIProperties.RESOURCE_VERSION).forEachRemaining(
+ o -> o.properties(AAIProperties.START_TS, AAIProperties.END_TS).forEachRemaining(p -> {
+ Long val = (Long) p.value();
+ if (val >= startTs) {
+ changes.add(val);
+ }
+ }));
v.edges(Direction.BOTH).forEachRemaining(e -> {
- if(e.property(AAIProperties.START_TS).isPresent() && (Long)e.property(AAIProperties.START_TS).value() >= startTs) {
+ if (e.property(AAIProperties.START_TS).isPresent()
+ && (Long) e.property(AAIProperties.START_TS).value() >= startTs) {
changes.add((Long) e.property(AAIProperties.START_TS).value());
}
- if(e.property(AAIProperties.END_TS).isPresent() && (Long)e.property(AAIProperties.END_TS).value() >= startTs) {
+ if (e.property(AAIProperties.END_TS).isPresent()
+ && (Long) e.property(AAIProperties.END_TS).value() >= startTs) {
changes.add((Long) e.property(AAIProperties.END_TS).value());
}
});
@@ -88,7 +90,8 @@ public class ChangesFormat extends MultiFormatMapper {
}
@Override
- protected Optional<JsonObject> getJsonFromVertex(Vertex input, Map<String, List<String>> properties) throws AAIFormatVertexException {
+ protected Optional<JsonObject> getJsonFromVertex(Vertex input, Map<String, List<String>> properties)
+ throws AAIFormatVertexException {
return Optional.empty();
}
diff --git a/aai-core/src/main/java/org/onap/aai/serialization/queryformats/Console.java b/aai-core/src/main/java/org/onap/aai/serialization/queryformats/Console.java
index 7e230c3a..0e7642cd 100644
--- a/aai-core/src/main/java/org/onap/aai/serialization/queryformats/Console.java
+++ b/aai-core/src/main/java/org/onap/aai/serialization/queryformats/Console.java
@@ -41,7 +41,8 @@ public class Console implements FormatMapper {
}
@Override
- public Optional<JsonObject> formatObject(Object o, Map<String, List<String>> properties) throws AAIFormatVertexException, AAIFormatQueryResultFormatNotSupported {
+ public Optional<JsonObject> formatObject(Object o, Map<String, List<String>> properties)
+ throws AAIFormatVertexException, AAIFormatQueryResultFormatNotSupported {
JsonObject json = new JsonObject();
json.addProperty("result", o.toString());
return Optional.of(json);
diff --git a/aai-core/src/main/java/org/onap/aai/serialization/queryformats/Count.java b/aai-core/src/main/java/org/onap/aai/serialization/queryformats/Count.java
index 60a10c51..216d021d 100644
--- a/aai-core/src/main/java/org/onap/aai/serialization/queryformats/Count.java
+++ b/aai-core/src/main/java/org/onap/aai/serialization/queryformats/Count.java
@@ -52,7 +52,8 @@ public class Count implements FormatMapper {
}
@Override
- public Optional<JsonObject> formatObject(Object o, Map<String, List<String>> properties) throws AAIFormatVertexException, AAIFormatQueryResultFormatNotSupported {
+ public Optional<JsonObject> formatObject(Object o, Map<String, List<String>> properties)
+ throws AAIFormatVertexException, AAIFormatQueryResultFormatNotSupported {
return Optional.empty();
}
diff --git a/aai-core/src/main/java/org/onap/aai/serialization/queryformats/FormatFactory.java b/aai-core/src/main/java/org/onap/aai/serialization/queryformats/FormatFactory.java
index 50aa8dd4..e102f1f4 100644
--- a/aai-core/src/main/java/org/onap/aai/serialization/queryformats/FormatFactory.java
+++ b/aai-core/src/main/java/org/onap/aai/serialization/queryformats/FormatFactory.java
@@ -20,6 +20,9 @@
package org.onap.aai.serialization.queryformats;
+import javax.ws.rs.core.MultivaluedHashMap;
+import javax.ws.rs.core.MultivaluedMap;
+
import org.onap.aai.exceptions.AAIException;
import org.onap.aai.introspection.Loader;
import org.onap.aai.serialization.db.DBSerializer;
@@ -28,9 +31,6 @@ import org.onap.aai.serialization.queryformats.utils.QueryParamInjector;
import org.onap.aai.serialization.queryformats.utils.UrlBuilder;
import org.onap.aai.setup.SchemaVersions;
-import javax.ws.rs.core.MultivaluedHashMap;
-import javax.ws.rs.core.MultivaluedMap;
-
public class FormatFactory {
private final Loader loader;
@@ -46,8 +46,8 @@ public class FormatFactory {
this.injector = QueryParamInjector.getInstance();
}
- public FormatFactory(Loader loader, DBSerializer serializer, SchemaVersions schemaVersions, String basePath, String serverBase)
- throws AAIException {
+ public FormatFactory(Loader loader, DBSerializer serializer, SchemaVersions schemaVersions, String basePath,
+ String serverBase) throws AAIException {
this.loader = loader;
this.serializer = serializer;
this.urlBuilder = new UrlBuilder(loader.getVersion(), serializer, serverBase, schemaVersions, basePath);
@@ -67,34 +67,43 @@ public class FormatFactory {
formatter = new Formatter(inject(new GraphSON(), params));
break;
case pathed:
- formatter = new Formatter(inject(new PathedURL.Builder(loader, serializer, urlBuilder), params).build(), params);
+ formatter = new Formatter(inject(new PathedURL.Builder(loader, serializer, urlBuilder), params).build(),
+ params);
break;
case pathed_resourceversion:
- formatter = new Formatter(inject(new PathedURL.Builder(loader, serializer, urlBuilder).includeUrl(), params).build(), params);
+ formatter = new Formatter(
+ inject(new PathedURL.Builder(loader, serializer, urlBuilder).includeUrl(), params).build(),
+ params);
break;
case id:
- formatter = new Formatter(inject(new IdURL.Builder(loader, serializer, urlBuilder), params).build(), params);
+ formatter = new Formatter(inject(new IdURL.Builder(loader, serializer, urlBuilder), params).build(),
+ params);
break;
case resource:
- formatter = new Formatter(inject(new Resource.Builder(loader, serializer, urlBuilder, params), params).build(), params);
+ formatter = new Formatter(
+ inject(new Resource.Builder(loader, serializer, urlBuilder, params), params).build(), params);
break;
case resource_and_url:
formatter = new Formatter(
- inject(new Resource.Builder(loader, serializer, urlBuilder, params).includeUrl(), params).build(), params);
+ inject(new Resource.Builder(loader, serializer, urlBuilder, params).includeUrl(), params)
+ .build(),
+ params);
break;
case raw:
- formatter =
- new Formatter(inject(new RawFormat.Builder(loader, serializer, urlBuilder), params).build(), params);
+ formatter = new Formatter(inject(new RawFormat.Builder(loader, serializer, urlBuilder), params).build(),
+ params);
break;
case simple:
formatter = new Formatter(
inject(new RawFormat.Builder(loader, serializer, urlBuilder).depth(0).modelDriven(), params)
- .build(), params);
+ .build(),
+ params);
break;
case aggregate:
formatter = new Formatter(
- inject(new Aggregate.Builder(loader, serializer, urlBuilder).depth(0).modelDriven(), params)
- .build(), params);
+ inject(new Aggregate.Builder(loader, serializer, urlBuilder).depth(0).modelDriven(), params)
+ .build(),
+ params);
break;
case console:
formatter = new Formatter(inject(new Console(), params));
@@ -107,20 +116,19 @@ public class FormatFactory {
inject(new ResourceWithSoT.Builder(loader, serializer, urlBuilder), params).build(), params);
break;
case changes:
- formatter =
- new Formatter(inject(new ChangesFormat(), params));
+ formatter = new Formatter(inject(new ChangesFormat(), params));
break;
case state:
- formatter =
- new Formatter(inject(new StateFormat.Builder(loader, serializer, urlBuilder), params).build(format));
+ formatter = new Formatter(
+ inject(new StateFormat.Builder(loader, serializer, urlBuilder), params).build(format));
break;
case lifecycle:
- formatter =
- new Formatter(inject(new LifecycleFormat.Builder(loader, serializer, urlBuilder), params).build(format));
+ formatter = new Formatter(
+ inject(new LifecycleFormat.Builder(loader, serializer, urlBuilder), params).build(format));
break;
case tree:
- formatter = new Formatter(
- inject(new TreeFormat.Builder(loader, serializer, urlBuilder), params).build());
+ formatter =
+ new Formatter(inject(new TreeFormat.Builder(loader, serializer, urlBuilder), params).build());
break;
default:
break;
diff --git a/aai-core/src/main/java/org/onap/aai/serialization/queryformats/FormatMapper.java b/aai-core/src/main/java/org/onap/aai/serialization/queryformats/FormatMapper.java
index cf967f0f..5369c060 100644
--- a/aai-core/src/main/java/org/onap/aai/serialization/queryformats/FormatMapper.java
+++ b/aai-core/src/main/java/org/onap/aai/serialization/queryformats/FormatMapper.java
@@ -32,7 +32,9 @@ import org.onap.aai.serialization.queryformats.exceptions.AAIFormatVertexExcepti
public interface FormatMapper {
Optional<JsonObject> formatObject(Object o) throws AAIFormatVertexException, AAIFormatQueryResultFormatNotSupported;
- Optional<JsonObject> formatObject(Object o, Map<String, List<String>> properties) throws AAIFormatVertexException, AAIFormatQueryResultFormatNotSupported;
+
+ Optional<JsonObject> formatObject(Object o, Map<String, List<String>> properties)
+ throws AAIFormatVertexException, AAIFormatQueryResultFormatNotSupported;
int parallelThreshold();
}
diff --git a/aai-core/src/main/java/org/onap/aai/serialization/queryformats/Formatter.java b/aai-core/src/main/java/org/onap/aai/serialization/queryformats/Formatter.java
index 0e15173a..da5d5425 100644
--- a/aai-core/src/main/java/org/onap/aai/serialization/queryformats/Formatter.java
+++ b/aai-core/src/main/java/org/onap/aai/serialization/queryformats/Formatter.java
@@ -20,26 +20,22 @@
package org.onap.aai.serialization.queryformats;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
import com.google.gson.JsonArray;
-import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
-import com.google.gson.JsonParser;
-import org.json.JSONArray;
-import org.json.simple.JSONObject;
-import org.json.simple.parser.JSONParser;
-import org.onap.aai.logging.LogFormatTools;
-import org.onap.aai.serialization.queryformats.exceptions.AAIFormatQueryResultFormatNotSupported;
-import org.onap.aai.serialization.queryformats.exceptions.AAIFormatVertexException;
-import javax.ws.rs.core.MultivaluedMap;
-import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Optional;
import java.util.stream.Stream;
+import javax.ws.rs.core.MultivaluedMap;
+
+import org.onap.aai.logging.LogFormatTools;
+import org.onap.aai.serialization.queryformats.exceptions.AAIFormatQueryResultFormatNotSupported;
+import org.onap.aai.serialization.queryformats.exceptions.AAIFormatVertexException;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
public class Formatter {
private static final Logger LOGGER = LoggerFactory.getLogger(Formatter.class);
@@ -94,7 +90,7 @@ public class Formatter {
stream.map(o -> {
try {
- if (properties!= null && !properties.isEmpty()){
+ if (properties != null && !properties.isEmpty()) {
return format.formatObject(o, properties);
} else {
return format.formatObject(o);
@@ -106,24 +102,21 @@ public class Formatter {
}
return Optional.<JsonObject>empty();
- }).filter(Optional::isPresent)
- .map(Optional::get)
- .forEach(json -> {
- if (isParallel) {
- synchronized (body) {
- body.add(json);
- }
- } else {
+ }).filter(Optional::isPresent).map(Optional::get).forEach(json -> {
+ if (isParallel) {
+ synchronized (body) {
body.add(json);
}
- });
+ } else {
+ body.add(json);
+ }
+ });
}
- if (params !=null && params.containsKey("as-tree")) {
+ if (params != null && params.containsKey("as-tree")) {
String isAsTree = params.get("as-tree").get(0);
- if (isAsTree != null && isAsTree.equalsIgnoreCase("true")
- && body != null && body.size() != 0) {
+ if (isAsTree != null && isAsTree.equalsIgnoreCase("true") && body != null && body.size() != 0) {
JsonObject jsonObjectBody = body.get(0).getAsJsonObject();
if (jsonObjectBody != null && jsonObjectBody.size() > 0) {
return body.get(0).getAsJsonObject();
diff --git a/aai-core/src/main/java/org/onap/aai/serialization/queryformats/GraphSON.java b/aai-core/src/main/java/org/onap/aai/serialization/queryformats/GraphSON.java
index e3c2989d..fc3316d4 100644
--- a/aai-core/src/main/java/org/onap/aai/serialization/queryformats/GraphSON.java
+++ b/aai-core/src/main/java/org/onap/aai/serialization/queryformats/GraphSON.java
@@ -24,6 +24,7 @@ import com.google.gson.JsonArray;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import com.google.gson.JsonParser;
+
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.OutputStream;
@@ -31,6 +32,7 @@ import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Optional;
+
import org.apache.tinkerpop.gremlin.structure.Direction;
import org.apache.tinkerpop.gremlin.structure.Vertex;
import org.apache.tinkerpop.gremlin.structure.io.graphson.GraphSONMapper;
@@ -84,7 +86,7 @@ public class GraphSON implements FormatMapper {
@Override
public Optional<JsonObject> formatObject(Object obj, Map<String, List<String>> properties)
- throws AAIFormatVertexException, AAIFormatQueryResultFormatNotSupported {
+ throws AAIFormatVertexException, AAIFormatQueryResultFormatNotSupported {
return Optional.empty();
}
diff --git a/aai-core/src/main/java/org/onap/aai/serialization/queryformats/HistoryFormat.java b/aai-core/src/main/java/org/onap/aai/serialization/queryformats/HistoryFormat.java
index b11f14aa..fccc17c6 100644
--- a/aai-core/src/main/java/org/onap/aai/serialization/queryformats/HistoryFormat.java
+++ b/aai-core/src/main/java/org/onap/aai/serialization/queryformats/HistoryFormat.java
@@ -20,12 +20,17 @@
package org.onap.aai.serialization.queryformats;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
import com.google.gson.Gson;
import com.google.gson.JsonArray;
import com.google.gson.JsonObject;
import com.google.gson.JsonParser;
+
+import java.util.Iterator;
+import java.util.List;
+import java.util.Set;
+import java.util.stream.Collectors;
+import java.util.stream.Stream;
+
import org.apache.tinkerpop.gremlin.structure.*;
import org.onap.aai.db.props.AAIProperties;
import org.onap.aai.introspection.Loader;
@@ -36,12 +41,8 @@ import org.onap.aai.serialization.queryformats.params.EndTs;
import org.onap.aai.serialization.queryformats.params.NodesOnly;
import org.onap.aai.serialization.queryformats.params.StartTs;
import org.onap.aai.serialization.queryformats.utils.UrlBuilder;
-
-import java.util.Iterator;
-import java.util.List;
-import java.util.Set;
-import java.util.stream.Collectors;
-import java.util.stream.Stream;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
public abstract class HistoryFormat extends MultiFormatMapper {
@@ -69,8 +70,8 @@ public abstract class HistoryFormat extends MultiFormatMapper {
protected long startTs;
protected long endTs;
protected static final Set<String> ignoredKeys =
- Stream.of(AAIProperties.LAST_MOD_TS, AAIProperties.LAST_MOD_SOURCE_OF_TRUTH, AAIProperties.CREATED_TS)
- .collect(Collectors.toSet());
+ Stream.of(AAIProperties.LAST_MOD_TS, AAIProperties.LAST_MOD_SOURCE_OF_TRUTH, AAIProperties.CREATED_TS)
+ .collect(Collectors.toSet());
protected HistoryFormat(Builder builder) {
this.urlBuilder = builder.getUrlBuilder();
@@ -145,8 +146,6 @@ public abstract class HistoryFormat extends MultiFormatMapper {
protected abstract JsonObject getRelatedObject(Edge e, Vertex related) throws AAIFormatVertexException;
-
-
public static class Builder implements NodesOnly<Builder>, Depth<Builder>, StartTs<Builder>, EndTs<Builder> {
protected final Loader loader;
@@ -197,7 +196,6 @@ public abstract class HistoryFormat extends MultiFormatMapper {
return this;
}
-
public boolean isNodesOnly() {
return this.nodesOnly;
}
@@ -234,7 +232,7 @@ public abstract class HistoryFormat extends MultiFormatMapper {
public HistoryFormat build(Format format) {
- if(Format.state.equals(format)) {
+ if (Format.state.equals(format)) {
return new StateFormat(this);
} else {
return new LifecycleFormat(this);
diff --git a/aai-core/src/main/java/org/onap/aai/serialization/queryformats/IdURL.java b/aai-core/src/main/java/org/onap/aai/serialization/queryformats/IdURL.java
index c2c252a2..10bba7f6 100644
--- a/aai-core/src/main/java/org/onap/aai/serialization/queryformats/IdURL.java
+++ b/aai-core/src/main/java/org/onap/aai/serialization/queryformats/IdURL.java
@@ -27,6 +27,8 @@ import java.util.List;
import java.util.Map;
import java.util.Optional;
+import javax.ws.rs.core.MultivaluedMap;
+
import org.apache.tinkerpop.gremlin.structure.Vertex;
import org.onap.aai.db.props.AAIProperties;
import org.onap.aai.exceptions.AAIException;
@@ -40,8 +42,6 @@ import org.onap.aai.serialization.queryformats.params.Depth;
import org.onap.aai.serialization.queryformats.params.NodesOnly;
import org.onap.aai.serialization.queryformats.utils.UrlBuilder;
-import javax.ws.rs.core.MultivaluedMap;
-
public class IdURL extends MultiFormatMapper {
private final UrlBuilder urlBuilder;
@@ -86,7 +86,8 @@ public class IdURL extends MultiFormatMapper {
}
@Override
- protected Optional<JsonObject> getJsonFromVertex(Vertex input, Map<String, List<String>> properties) throws AAIFormatVertexException {
+ protected Optional<JsonObject> getJsonFromVertex(Vertex input, Map<String, List<String>> properties)
+ throws AAIFormatVertexException {
return Optional.empty();
}
@@ -107,7 +108,8 @@ public class IdURL extends MultiFormatMapper {
this.urlBuilder = urlBuilder;
}
- public Builder(Loader loader, DBSerializer serializer, UrlBuilder urlBuilder, MultivaluedMap<String, String> params) {
+ public Builder(Loader loader, DBSerializer serializer, UrlBuilder urlBuilder,
+ MultivaluedMap<String, String> params) {
this.loader = loader;
this.serializer = serializer;
this.urlBuilder = urlBuilder;
@@ -126,7 +128,9 @@ public class IdURL extends MultiFormatMapper {
return this.urlBuilder;
}
- protected MultivaluedMap<String, String> getParams() { return this.params; }
+ protected MultivaluedMap<String, String> getParams() {
+ return this.params;
+ }
public boolean isSkipRelatedTo() {
if (params != null) {
@@ -143,7 +147,9 @@ public class IdURL extends MultiFormatMapper {
return true;
}
- protected boolean isTree() { return this.tree; }
+ protected boolean isTree() {
+ return this.tree;
+ }
public Builder isTree(Boolean tree) {
this.tree = tree;
diff --git a/aai-core/src/main/java/org/onap/aai/serialization/queryformats/LifecycleFormat.java b/aai-core/src/main/java/org/onap/aai/serialization/queryformats/LifecycleFormat.java
index 57bb17c2..74742c98 100644
--- a/aai-core/src/main/java/org/onap/aai/serialization/queryformats/LifecycleFormat.java
+++ b/aai-core/src/main/java/org/onap/aai/serialization/queryformats/LifecycleFormat.java
@@ -20,10 +20,13 @@
package org.onap.aai.serialization.queryformats;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
import com.google.gson.JsonArray;
import com.google.gson.JsonObject;
+
+import java.util.*;
+import java.util.stream.Collectors;
+import java.util.stream.Stream;
+
import org.apache.tinkerpop.gremlin.structure.Edge;
import org.apache.tinkerpop.gremlin.structure.Vertex;
import org.apache.tinkerpop.gremlin.structure.VertexProperty;
@@ -31,14 +34,11 @@ import org.onap.aai.db.props.AAIProperties;
import org.onap.aai.logging.LogFormatTools;
import org.onap.aai.serialization.queryformats.exceptions.AAIFormatQueryResultFormatNotSupported;
import org.onap.aai.serialization.queryformats.exceptions.AAIFormatVertexException;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
import org.springframework.util.LinkedMultiValueMap;
import org.springframework.util.MultiValueMap;
-import java.util.*;
-import java.util.stream.Collectors;
-import java.util.stream.Stream;
-
-
public class LifecycleFormat extends HistoryFormat {
private static final Logger LOGGER = LoggerFactory.getLogger(LifecycleFormat.class);
@@ -52,11 +52,11 @@ public class LifecycleFormat extends HistoryFormat {
Iterator<VertexProperty<Object>> iter = v.properties();
List<JsonObject> jsonList = new ArrayList<>();
- Map<String, Set<Long>> propStartTimes = new HashMap<>(); //vertex end
+ Map<String, Set<Long>> propStartTimes = new HashMap<>(); // vertex end
while (iter.hasNext()) {
JsonObject json = new JsonObject();
VertexProperty<Object> prop = iter.next();
- if(prop.key() != null && ignoredKeys.contains(prop.key())){
+ if (prop.key() != null && ignoredKeys.contains(prop.key())) {
continue;
}
if (!propStartTimes.containsKey(prop.key())) {
@@ -79,10 +79,9 @@ public class LifecycleFormat extends HistoryFormat {
jsonList.add(jo);
propStartTimes.get(prop.key()).add(metaProperties.get(AAIProperties.START_TS).getAsLong());
}
- if (!AAIProperties.RESOURCE_VERSION.equals(prop.key())
- && metaProperties.has(AAIProperties.END_TS)
- && isTsInRange(metaProperties.get(AAIProperties.END_TS).getAsLong())
- && !propStartTimes.get(prop.key()).contains(metaProperties.get(AAIProperties.END_TS).getAsLong())) {
+ if (!AAIProperties.RESOURCE_VERSION.equals(prop.key()) && metaProperties.has(AAIProperties.END_TS)
+ && isTsInRange(metaProperties.get(AAIProperties.END_TS).getAsLong())
+ && !propStartTimes.get(prop.key()).contains(metaProperties.get(AAIProperties.END_TS).getAsLong())) {
JsonObject jo = new JsonObject();
jo.add(KEY, json.get(KEY));
jo.add(VALUE, null);
@@ -94,16 +93,17 @@ public class LifecycleFormat extends HistoryFormat {
}
jsonList.stream()
- // remove all the null values that is the start time for another value
- .filter(jo -> !jo.get(VALUE).isJsonNull() || !propStartTimes.get(jo.get(KEY).getAsString()).contains(jo.get(TIMESTAMP).getAsLong()))
- // sort by ts in decreasing order
- .sorted((o1, o2) -> {
- if (o1.get(TIMESTAMP).getAsLong() == o2.get(TIMESTAMP).getAsLong()) {
- return o1.get(KEY).getAsString().compareTo(o2.get(KEY).getAsString());
- } else {
- return Long.compare(o2.get(TIMESTAMP).getAsLong(), o1.get(TIMESTAMP).getAsLong());
- }
- }).forEach(jsonArray::add);
+ // remove all the null values that is the start time for another value
+ .filter(jo -> !jo.get(VALUE).isJsonNull()
+ || !propStartTimes.get(jo.get(KEY).getAsString()).contains(jo.get(TIMESTAMP).getAsLong()))
+ // sort by ts in decreasing order
+ .sorted((o1, o2) -> {
+ if (o1.get(TIMESTAMP).getAsLong() == o2.get(TIMESTAMP).getAsLong()) {
+ return o1.get(KEY).getAsString().compareTo(o2.get(KEY).getAsString());
+ } else {
+ return Long.compare(o2.get(TIMESTAMP).getAsLong(), o1.get(TIMESTAMP).getAsLong());
+ }
+ }).forEach(jsonArray::add);
return jsonArray;
}
@@ -112,7 +112,6 @@ public class LifecycleFormat extends HistoryFormat {
return ts >= startTs && ts <= endTs;
}
-
@Override
protected boolean isValidEdge(Edge e) {
if (e.property(AAIProperties.END_TS).isPresent()) {
@@ -139,21 +138,27 @@ public class LifecycleFormat extends HistoryFormat {
json.addProperty("uri", "NA");
}
- if(e.property(AAIProperties.START_TS).isPresent()) {
+ if (e.property(AAIProperties.START_TS).isPresent()) {
long edgeStartTimestamp = e.<Long>value(AAIProperties.START_TS);
if (isTsInRange(edgeStartTimestamp)) {
- json.addProperty(TIMESTAMP, e.property(AAIProperties.START_TS).isPresent()? e.<Long>value(AAIProperties.START_TS) : 0);
- json.addProperty(SOT, e.property(AAIProperties.SOURCE_OF_TRUTH).isPresent()? e.value(AAIProperties.SOURCE_OF_TRUTH) : "");
- json.addProperty(TX_ID, e.property(AAIProperties.START_TX_ID).isPresent()? e.value(AAIProperties.START_TX_ID) : "N/A");
+ json.addProperty(TIMESTAMP,
+ e.property(AAIProperties.START_TS).isPresent() ? e.<Long>value(AAIProperties.START_TS) : 0);
+ json.addProperty(SOT,
+ e.property(AAIProperties.SOURCE_OF_TRUTH).isPresent() ? e.value(AAIProperties.SOURCE_OF_TRUTH)
+ : "");
+ json.addProperty(TX_ID,
+ e.property(AAIProperties.START_TX_ID).isPresent() ? e.value(AAIProperties.START_TX_ID) : "N/A");
}
}
- if(e.property(AAIProperties.END_TS).isPresent()) {
+ if (e.property(AAIProperties.END_TS).isPresent()) {
long edgeEndTimestamp = e.<Long>value(AAIProperties.END_TS);
if (isTsInRange(edgeEndTimestamp)) {
json.addProperty(END_TIMESTAMP, edgeEndTimestamp);
- json.addProperty(END_SOT, e.property(AAIProperties.END_SOT).isPresent() ? e.value(AAIProperties.END_SOT) : "");
- json.addProperty(END_TX_ID, e.property(AAIProperties.END_TX_ID).isPresent() ? e.value(AAIProperties.END_TX_ID) : "N/A");
+ json.addProperty(END_SOT,
+ e.property(AAIProperties.END_SOT).isPresent() ? e.value(AAIProperties.END_SOT) : "");
+ json.addProperty(END_TX_ID,
+ e.property(AAIProperties.END_TX_ID).isPresent() ? e.value(AAIProperties.END_TX_ID) : "N/A");
}
}
@@ -182,14 +187,14 @@ public class LifecycleFormat extends HistoryFormat {
json.add(NODE_ACTIONS, getNodeActions(v, json));
if (json.getAsJsonObject().get(PROPERTIES).getAsJsonArray().size() == 0
- && json.getAsJsonObject().get(RELATED_TO).getAsJsonArray().size() == 0
- && json.getAsJsonObject().get(NODE_ACTIONS).getAsJsonArray().size() == 0) {
+ && json.getAsJsonObject().get(RELATED_TO).getAsJsonArray().size() == 0
+ && json.getAsJsonObject().get(NODE_ACTIONS).getAsJsonArray().size() == 0) {
return Optional.empty();
} else if (json.getAsJsonObject().get(PROPERTIES).getAsJsonArray().size() == 1
- && (json.getAsJsonObject().get(RELATED_TO).getAsJsonArray().size() > 0
- || json.getAsJsonObject().get(NODE_ACTIONS).getAsJsonArray().size() > 0)) {
- if (json.getAsJsonObject().get(PROPERTIES).getAsJsonArray()
- .get(0).getAsJsonObject().get("key").getAsString().equals(AAIProperties.END_TS)) {
+ && (json.getAsJsonObject().get(RELATED_TO).getAsJsonArray().size() > 0
+ || json.getAsJsonObject().get(NODE_ACTIONS).getAsJsonArray().size() > 0)) {
+ if (json.getAsJsonObject().get(PROPERTIES).getAsJsonArray().get(0).getAsJsonObject().get("key")
+ .getAsString().equals(AAIProperties.END_TS)) {
json.getAsJsonObject().add(PROPERTIES, new JsonArray());
}
}
@@ -198,7 +203,8 @@ public class LifecycleFormat extends HistoryFormat {
}
@Override
- protected Optional<JsonObject> getJsonFromVertex(Vertex input, Map<String, List<String>> properties) throws AAIFormatVertexException {
+ protected Optional<JsonObject> getJsonFromVertex(Vertex input, Map<String, List<String>> properties)
+ throws AAIFormatVertexException {
return Optional.empty();
}
@@ -212,7 +218,8 @@ public class LifecycleFormat extends HistoryFormat {
action.addProperty("action", "DELETED");
action.addProperty(TIMESTAMP, deletedTs);
if (v.property(AAIProperties.END_TS).property(AAIProperties.SOURCE_OF_TRUTH).isPresent()) {
- action.addProperty(SOT, v.property(AAIProperties.END_TS).<String>value(AAIProperties.SOURCE_OF_TRUTH));
+ action.addProperty(SOT,
+ v.property(AAIProperties.END_TS).<String>value(AAIProperties.SOURCE_OF_TRUTH));
}
if (v.property(AAIProperties.END_TS).property(AAIProperties.END_TX_ID).isPresent()) {
action.addProperty(TX_ID, v.property(AAIProperties.END_TS).<String>value(AAIProperties.END_TX_ID));
@@ -229,7 +236,8 @@ public class LifecycleFormat extends HistoryFormat {
action.addProperty(TIMESTAMP, createdTs);
action.addProperty(SOT, v.<String>value(AAIProperties.SOURCE_OF_TRUTH));
if (v.property(AAIProperties.SOURCE_OF_TRUTH).property(AAIProperties.START_TX_ID).isPresent()) {
- action.addProperty(TX_ID, v.property(AAIProperties.SOURCE_OF_TRUTH).<String>value(AAIProperties.START_TX_ID));
+ action.addProperty(TX_ID,
+ v.property(AAIProperties.SOURCE_OF_TRUTH).<String>value(AAIProperties.START_TX_ID));
} else {
action.addProperty(TX_ID, "N/A");
}
@@ -259,17 +267,15 @@ public class LifecycleFormat extends HistoryFormat {
}
return Optional.<JsonObject>empty();
- }).filter(Optional::isPresent)
- .map(Optional::get)
- .forEach(json -> {
- if (isParallel) {
- synchronized (body) {
- body.add(json);
- }
- } else {
+ }).filter(Optional::isPresent).map(Optional::get).forEach(json -> {
+ if (isParallel) {
+ synchronized (body) {
body.add(json);
}
- });
+ } else {
+ body.add(json);
+ }
+ });
JsonArray result = organizeBody(body);
result.forEach(jsonElement -> jsonElement.getAsJsonObject().remove(TIMESTAMP));
return result;
@@ -282,21 +288,23 @@ public class LifecycleFormat extends HistoryFormat {
toBeMerged.add(body.get(i).getAsJsonObject().get("uri").getAsString(), i);
}
- final List<List<Integer>> dupes = toBeMerged.values().stream().filter(l -> l.size() > 1).collect(Collectors.toList());
+ final List<List<Integer>> dupes =
+ toBeMerged.values().stream().filter(l -> l.size() > 1).collect(Collectors.toList());
if (dupes.isEmpty()) {
return body;
} else {
Set<Integer> remove = new HashSet<>();
for (List<Integer> dupe : dupes) {
- dupe.sort((a,b) -> Long.compare(body.get(b).getAsJsonObject().get(TIMESTAMP).getAsLong(), body.get(a).getAsJsonObject().get(TIMESTAMP).getAsLong()));
+ dupe.sort((a, b) -> Long.compare(body.get(b).getAsJsonObject().get(TIMESTAMP).getAsLong(),
+ body.get(a).getAsJsonObject().get(TIMESTAMP).getAsLong()));
int keep = dupe.remove(0);
for (Integer idx : dupe) {
body.get(keep).getAsJsonObject().getAsJsonArray(NODE_ACTIONS)
- .addAll(body.get(idx).getAsJsonObject().getAsJsonArray(NODE_ACTIONS));
+ .addAll(body.get(idx).getAsJsonObject().getAsJsonArray(NODE_ACTIONS));
body.get(keep).getAsJsonObject().getAsJsonArray(PROPERTIES)
- .addAll(body.get(idx).getAsJsonObject().getAsJsonArray(PROPERTIES));
+ .addAll(body.get(idx).getAsJsonObject().getAsJsonArray(PROPERTIES));
body.get(keep).getAsJsonObject().getAsJsonArray(RELATED_TO)
- .addAll(body.get(idx).getAsJsonObject().getAsJsonArray(RELATED_TO));
+ .addAll(body.get(idx).getAsJsonObject().getAsJsonArray(RELATED_TO));
remove.add(idx);
}
}
diff --git a/aai-core/src/main/java/org/onap/aai/serialization/queryformats/MultiFormatMapper.java b/aai-core/src/main/java/org/onap/aai/serialization/queryformats/MultiFormatMapper.java
index 12e046b9..186816e0 100644
--- a/aai-core/src/main/java/org/onap/aai/serialization/queryformats/MultiFormatMapper.java
+++ b/aai-core/src/main/java/org/onap/aai/serialization/queryformats/MultiFormatMapper.java
@@ -20,6 +20,10 @@
package org.onap.aai.serialization.queryformats;
+import com.google.gson.JsonArray;
+import com.google.gson.JsonElement;
+import com.google.gson.JsonObject;
+
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@@ -37,10 +41,6 @@ import org.onap.aai.serialization.queryformats.exceptions.AAIFormatVertexExcepti
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import com.google.gson.JsonArray;
-import com.google.gson.JsonElement;
-import com.google.gson.JsonObject;
-
public abstract class MultiFormatMapper implements FormatMapper {
private static final Logger logger = LoggerFactory.getLogger(MultiFormatMapper.class);
@@ -50,11 +50,11 @@ public abstract class MultiFormatMapper implements FormatMapper {
protected static final String NODE_TYPE_KEY = "node-type";
protected static final String RETURNED_EMPTY_JSONARRAY_MSG =
- "Returned empty JsonArray - Could not populate nested json objects for wrapper: {}";
+ "Returned empty JsonArray - Could not populate nested json objects for wrapper: {}";
@Override
public Optional<JsonObject> formatObject(Object input)
- throws AAIFormatVertexException, AAIFormatQueryResultFormatNotSupported {
+ throws AAIFormatVertexException, AAIFormatQueryResultFormatNotSupported {
if (input instanceof Vertex) {
logger.debug("Formatting vertex object");
return this.getJsonFromVertex((Vertex) input);
@@ -75,7 +75,7 @@ public abstract class MultiFormatMapper implements FormatMapper {
@Override
public Optional<JsonObject> formatObject(Object input, Map<String, List<String>> properties)
- throws AAIFormatVertexException, AAIFormatQueryResultFormatNotSupported {
+ throws AAIFormatVertexException, AAIFormatQueryResultFormatNotSupported {
if (input instanceof Vertex) {
logger.debug("Formatting vertex object with properties map filter");
return this.getJsonFromVertex((Vertex) input, properties);
@@ -95,7 +95,9 @@ public abstract class MultiFormatMapper implements FormatMapper {
}
protected abstract Optional<JsonObject> getJsonFromVertex(Vertex input) throws AAIFormatVertexException;
- protected abstract Optional<JsonObject> getJsonFromVertex(Vertex input, Map<String, List<String>> properties) throws AAIFormatVertexException;
+
+ protected abstract Optional<JsonObject> getJsonFromVertex(Vertex input, Map<String, List<String>> properties)
+ throws AAIFormatVertexException;
protected Optional<JsonObject> getJsonFromPath(Path input) throws AAIFormatVertexException {
List<Object> path = input.objects();
@@ -116,6 +118,7 @@ public abstract class MultiFormatMapper implements FormatMapper {
/**
* Returns an Optional<JsonObject> object using "nodes" as a wrapper to encapsulate json objects
+ *
* @param tree
* @return
* @throws AAIFormatVertexException
@@ -140,12 +143,14 @@ public abstract class MultiFormatMapper implements FormatMapper {
/**
* Returns an Optional<JsonObject> object using "related-nodes" to encapsulate nested json objects.
* Primarily intended to be utilized by the "as-tree" query parameter feature
+ *
* @param tree
* @param properties
* @return
* @throws AAIFormatVertexException
*/
- protected Optional<JsonObject> getRelatedNodesFromTree(Tree<?> tree, Map<String, List<String>> properties) throws AAIFormatVertexException {
+ protected Optional<JsonObject> getRelatedNodesFromTree(Tree<?> tree, Map<String, List<String>> properties)
+ throws AAIFormatVertexException {
if (tree.isEmpty()) {
return Optional.of(new JsonObject());
}
@@ -168,13 +173,15 @@ public abstract class MultiFormatMapper implements FormatMapper {
/**
* Returns JsonArray Object populated with nested json wrapped by the nodeIdentifier parameter
+ *
* @param tree
* @param filterPropertiesMap
* @param nodeIdentifier
* @return
* @throws AAIFormatVertexException
*/
- protected JsonArray getNodesArray(Tree<?> tree, Map<String, Set<String>> filterPropertiesMap, String nodeIdentifier) throws AAIFormatVertexException {
+ protected JsonArray getNodesArray(Tree<?> tree, Map<String, Set<String>> filterPropertiesMap, String nodeIdentifier)
+ throws AAIFormatVertexException {
JsonArray nodes = new JsonArray();
for (Map.Entry<?, ? extends Tree<?>> entry : tree.entrySet()) {
JsonObject me = new JsonObject();
@@ -199,6 +206,7 @@ public abstract class MultiFormatMapper implements FormatMapper {
/**
* Returns a Map<String, Set<String>> object through converting given map parameter
+ *
* @param properties
* @return
*/
@@ -206,19 +214,16 @@ public abstract class MultiFormatMapper implements FormatMapper {
if (properties == null)
return new HashMap<>();
- return properties.entrySet().stream()
- .map(entry -> {
- Set<String> newSet = entry.getValue().stream()
- .map(this::truncateApostrophes)
- .collect(Collectors.toSet());
+ return properties.entrySet().stream().map(entry -> {
+ Set<String> newSet = entry.getValue().stream().map(this::truncateApostrophes).collect(Collectors.toSet());
- return Pair.of(entry.getKey(), newSet);
- }
- ).collect(Collectors.toMap(Pair::getKey, Pair::getValue));
+ return Pair.of(entry.getKey(), newSet);
+ }).collect(Collectors.toMap(Pair::getKey, Pair::getValue));
}
/**
* Returns a string with it's apostrophes truncated at the start and end.
+ *
* @param s
* @return
*/
@@ -235,40 +240,39 @@ public abstract class MultiFormatMapper implements FormatMapper {
/**
* Filters the given Optional<JsonObject> with the properties under a properties field
* or the properties under its respective node type.
+ *
* @param obj
* @param filterPropertiesMap
* @return
*/
protected JsonObject getPropertyFilteredObject(Optional<JsonObject> obj,
- Map<String, Set<String>> filterPropertiesMap) {
- return obj.map(
- jsonObj -> {
- if (filterPropertiesMap == null || filterPropertiesMap.isEmpty()) {
- return jsonObj;
- } else {
- ImmutableTriple<JsonObject, Optional<String>, Optional<JsonObject>> triple =
+ Map<String, Set<String>> filterPropertiesMap) {
+ return obj.map(jsonObj -> {
+ if (filterPropertiesMap == null || filterPropertiesMap.isEmpty()) {
+ return jsonObj;
+ } else {
+ ImmutableTriple<JsonObject, Optional<String>, Optional<JsonObject>> triple =
cloneObjectAndExtractNodeTypeAndProperties(jsonObj);
- JsonObject result = triple.left;
- Optional<String> nodeType = triple.middle;
- Optional<JsonObject> properties = triple.right;
+ JsonObject result = triple.left;
+ Optional<String> nodeType = triple.middle;
+ Optional<JsonObject> properties = triple.right;
- // Filter current object based on it containing fields: "node-type" and "properties"
- if (nodeType.isPresent() && properties.isPresent()) {
- filterByNodeTypeAndProperties(result, nodeType.get(), properties.get(), filterPropertiesMap);
- } else {
- // filter current object based on the: key - nodeType & value - JsonObject of nodes properties
- filterByJsonObj(result, jsonObj, filterPropertiesMap);
- }
-
- return result;
+ // Filter current object based on it containing fields: "node-type" and "properties"
+ if (nodeType.isPresent() && properties.isPresent()) {
+ filterByNodeTypeAndProperties(result, nodeType.get(), properties.get(), filterPropertiesMap);
+ } else {
+ // filter current object based on the: key - nodeType & value - JsonObject of nodes properties
+ filterByJsonObj(result, jsonObj, filterPropertiesMap);
}
+
+ return result;
}
- ).orElseGet(JsonObject::new);
+ }).orElseGet(JsonObject::new);
}
private ImmutableTriple<JsonObject, Optional<String>, Optional<JsonObject>> cloneObjectAndExtractNodeTypeAndProperties(
- JsonObject jsonObj) {
+ JsonObject jsonObj) {
JsonObject result = new JsonObject();
Optional<String> nodeType = Optional.empty();
Optional<JsonObject> properties = Optional.empty();
@@ -293,20 +297,25 @@ public abstract class MultiFormatMapper implements FormatMapper {
/**
* Returns a JsonObject with filtered properties using "node-type" and "properties"
* Used for formats with payloads similar to simple and raw
+ *
* @param result
* @param nodeType
* @param properties
* @param filterPropertiesMap
* @return
*/
- private JsonObject filterByNodeTypeAndProperties(JsonObject result, String nodeType, JsonObject properties, Map<String, Set<String>> filterPropertiesMap) {
- if (result == null || nodeType == null || nodeType.isEmpty() || properties == null || filterPropertiesMap == null) {
+ private JsonObject filterByNodeTypeAndProperties(JsonObject result, String nodeType, JsonObject properties,
+ Map<String, Set<String>> filterPropertiesMap) {
+ if (result == null || nodeType == null || nodeType.isEmpty() || properties == null
+ || filterPropertiesMap == null) {
return result;
}
- if (filterPropertiesMap.containsKey(nodeType)) { // filterPropertiesMap keys are nodeTypes - keys are obtained from the incoming query request
+ if (filterPropertiesMap.containsKey(nodeType)) { // filterPropertiesMap keys are nodeTypes - keys are obtained
+ // from the incoming query request
Set<String> filterSet = filterPropertiesMap.get(nodeType);
JsonObject filteredProperties = new JsonObject();
- for (String property : filterSet) { // Each nodeType should have a set of properties to be retained in the response
+ for (String property : filterSet) { // Each nodeType should have a set of properties to be retained in the
+ // response
if (properties.get(property) != null) {
filteredProperties.add(property, properties.get(property));
}
@@ -319,12 +328,14 @@ public abstract class MultiFormatMapper implements FormatMapper {
/**
* Returns a JsonObject with its properties filtered
+ *
* @param result
* @param jsonObj
* @param filterPropertiesMap
* @return
*/
- private JsonObject filterByJsonObj(JsonObject result, JsonObject jsonObj, Map<String, Set<String>> filterPropertiesMap) {
+ private JsonObject filterByJsonObj(JsonObject result, JsonObject jsonObj,
+ Map<String, Set<String>> filterPropertiesMap) {
if (result == null || jsonObj == null || filterPropertiesMap == null) {
return result;
}
@@ -350,12 +361,13 @@ public abstract class MultiFormatMapper implements FormatMapper {
/**
* Returns a filtered JsonObject with properties contained in the parameter filterPropertiesMap
+ *
* @param properties
* @param filterPropertiesMap
* @return
*/
protected JsonObject filterProperties(Optional<JsonObject> properties, String nodeType,
- Map<String, Set<String>> filterPropertiesMap) {
+ Map<String, Set<String>> filterPropertiesMap) {
return properties.map(jo -> {
if (filterPropertiesMap == null || filterPropertiesMap.isEmpty()) {
return properties.get();
diff --git a/aai-core/src/main/java/org/onap/aai/serialization/queryformats/PathedURL.java b/aai-core/src/main/java/org/onap/aai/serialization/queryformats/PathedURL.java
index e21be992..f052f778 100644
--- a/aai-core/src/main/java/org/onap/aai/serialization/queryformats/PathedURL.java
+++ b/aai-core/src/main/java/org/onap/aai/serialization/queryformats/PathedURL.java
@@ -27,6 +27,8 @@ import java.util.List;
import java.util.Map;
import java.util.Optional;
+import javax.ws.rs.core.MultivaluedMap;
+
import org.apache.tinkerpop.gremlin.structure.Vertex;
import org.onap.aai.db.props.AAIProperties;
import org.onap.aai.exceptions.AAIException;
@@ -40,8 +42,6 @@ import org.onap.aai.serialization.queryformats.params.Depth;
import org.onap.aai.serialization.queryformats.params.NodesOnly;
import org.onap.aai.serialization.queryformats.utils.UrlBuilder;
-import javax.ws.rs.core.MultivaluedMap;
-
public final class PathedURL extends MultiFormatMapper {
private final UrlBuilder urlBuilder;
@@ -91,7 +91,8 @@ public final class PathedURL extends MultiFormatMapper {
}
@Override
- protected Optional<JsonObject> getJsonFromVertex(Vertex input, Map<String, List<String>> properties) throws AAIFormatVertexException {
+ protected Optional<JsonObject> getJsonFromVertex(Vertex input, Map<String, List<String>> properties)
+ throws AAIFormatVertexException {
return Optional.empty();
}
@@ -112,7 +113,8 @@ public final class PathedURL extends MultiFormatMapper {
this.urlBuilder = urlBuilder;
}
- public Builder(Loader loader, DBSerializer serializer, UrlBuilder urlBuilder, MultivaluedMap<String, String> params) {
+ public Builder(Loader loader, DBSerializer serializer, UrlBuilder urlBuilder,
+ MultivaluedMap<String, String> params) {
this.loader = loader;
this.serializer = serializer;
this.urlBuilder = urlBuilder;
@@ -131,7 +133,9 @@ public final class PathedURL extends MultiFormatMapper {
return this.urlBuilder;
}
- protected MultivaluedMap<String, String> getParams() { return this.params; }
+ protected MultivaluedMap<String, String> getParams() {
+ return this.params;
+ }
public boolean isSkipRelatedTo() {
if (params != null) {
@@ -148,7 +152,9 @@ public final class PathedURL extends MultiFormatMapper {
return true;
}
- protected boolean isTree() { return this.tree; }
+ protected boolean isTree() {
+ return this.tree;
+ }
public Builder isTree(Boolean tree) {
this.tree = tree;
diff --git a/aai-core/src/main/java/org/onap/aai/serialization/queryformats/RawFormat.java b/aai-core/src/main/java/org/onap/aai/serialization/queryformats/RawFormat.java
index a41ed2b3..bd858f4b 100644
--- a/aai-core/src/main/java/org/onap/aai/serialization/queryformats/RawFormat.java
+++ b/aai-core/src/main/java/org/onap/aai/serialization/queryformats/RawFormat.java
@@ -24,6 +24,7 @@ import com.google.gson.Gson;
import com.google.gson.JsonArray;
import com.google.gson.JsonObject;
import com.google.gson.JsonParser;
+
import java.util.Collections;
import java.util.Iterator;
import java.util.List;
@@ -31,6 +32,7 @@ import java.util.Map;
import java.util.Optional;
import java.util.Set;
import java.util.stream.Collectors;
+
import org.apache.tinkerpop.gremlin.structure.Direction;
import org.apache.tinkerpop.gremlin.structure.Edge;
import org.apache.tinkerpop.gremlin.structure.Vertex;
@@ -62,7 +64,8 @@ public class RawFormat extends MultiFormatMapper {
}
@Override
- public Optional<JsonObject> getJsonFromVertex(Vertex v, Map<String, List<String>> selectedProps) throws AAIFormatVertexException {
+ public Optional<JsonObject> getJsonFromVertex(Vertex v, Map<String, List<String>> selectedProps)
+ throws AAIFormatVertexException {
JsonObject json = new JsonObject();
json.addProperty("id", v.id().toString());
json.addProperty("node-type", v.<String>value(AAIProperties.NODE_TYPE));
@@ -110,7 +113,8 @@ public class RawFormat extends MultiFormatMapper {
return Optional.of(json);
}
- public Optional<JsonObject> createSelectedPropertiesObject(Vertex v, Map<String, List<String>> selectedProps) throws AAIFormatVertexException {
+ public Optional<JsonObject> createSelectedPropertiesObject(Vertex v, Map<String, List<String>> selectedProps)
+ throws AAIFormatVertexException {
JsonObject json = new JsonObject();
String nodeType = v.<String>value(AAIProperties.NODE_TYPE);
Set<String> propList = removeSingleQuotesForProperties(selectedProps.get(nodeType));
@@ -142,10 +146,9 @@ public class RawFormat extends MultiFormatMapper {
return Optional.of(json);
}
- private Set<String> removeSingleQuotesForProperties(List<String> props){
+ private Set<String> removeSingleQuotesForProperties(List<String> props) {
if (props != null && !props.isEmpty()) {
- return props.stream().map(
- e -> e.substring(1, e.length()-1)).collect(Collectors.toSet());
+ return props.stream().map(e -> e.substring(1, e.length() - 1)).collect(Collectors.toSet());
} else {
return Collections.emptySet();
}
@@ -215,7 +218,9 @@ public class RawFormat extends MultiFormatMapper {
return this.urlBuilder;
}
- protected boolean isTree() { return this.tree; }
+ protected boolean isTree() {
+ return this.tree;
+ }
public Builder isTree(Boolean tree) {
this.tree = tree;
diff --git a/aai-core/src/main/java/org/onap/aai/serialization/queryformats/Resource.java b/aai-core/src/main/java/org/onap/aai/serialization/queryformats/Resource.java
index c4b7f575..f4fd921f 100644
--- a/aai-core/src/main/java/org/onap/aai/serialization/queryformats/Resource.java
+++ b/aai-core/src/main/java/org/onap/aai/serialization/queryformats/Resource.java
@@ -24,13 +24,16 @@ import com.google.gson.JsonArray;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import com.google.gson.JsonParser;
+
import java.io.UnsupportedEncodingException;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.Optional;
import java.util.Set;
+
import javax.ws.rs.core.MultivaluedMap;
+
import org.apache.tinkerpop.gremlin.process.traversal.step.util.Tree;
import org.apache.tinkerpop.gremlin.structure.Vertex;
import org.onap.aai.db.props.AAIProperties;
@@ -73,7 +76,8 @@ public class Resource extends MultiFormatMapper {
}
@Override
- protected Optional<JsonObject> getRelatedNodesFromTree(Tree<?> tree, Map<String, List<String>> properties) throws AAIFormatVertexException {
+ protected Optional<JsonObject> getRelatedNodesFromTree(Tree<?> tree, Map<String, List<String>> properties)
+ throws AAIFormatVertexException {
if (tree.isEmpty()) {
return Optional.of(new JsonObject());
}
@@ -81,7 +85,7 @@ public class Resource extends MultiFormatMapper {
Map<String, Set<String>> filterPropertiesMap = createFilteredPropertyMap(properties);
JsonObject t = new JsonObject();
- JsonArray ja = this.getRelatedNodesArray(tree, filterPropertiesMap,"related-nodes");
+ JsonArray ja = this.getRelatedNodesArray(tree, filterPropertiesMap, "related-nodes");
if (ja.size() > 0) {
t.add("results", ja);
return Optional.of(t);
@@ -90,7 +94,8 @@ public class Resource extends MultiFormatMapper {
return Optional.empty();
}
- protected JsonArray getRelatedNodesArray(Tree<?> tree, Map<String, Set<String>> filterPropertiesMap, String nodeIdentifier) throws AAIFormatVertexException {
+ protected JsonArray getRelatedNodesArray(Tree<?> tree, Map<String, Set<String>> filterPropertiesMap,
+ String nodeIdentifier) throws AAIFormatVertexException {
JsonArray nodes = new JsonArray();
if (tree.isEmpty()) {
return nodes;
@@ -114,7 +119,7 @@ public class Resource extends MultiFormatMapper {
value.getAsJsonObject().add(nodeIdentifier, ja);
}
}
- } catch(Exception e) {
+ } catch (Exception e) {
logger.debug("Failed to add related-nodes array: {}", e.getMessage());
throw new AAIFormatVertexException("Failed to add related-nodes array: " + e.getMessage(), e);
}
@@ -142,7 +147,8 @@ public class Resource extends MultiFormatMapper {
}
@Override
- protected Optional<JsonObject> getJsonFromVertex(Vertex v, Map<String, List<String>> properties) throws AAIFormatVertexException {
+ protected Optional<JsonObject> getJsonFromVertex(Vertex v, Map<String, List<String>> properties)
+ throws AAIFormatVertexException {
JsonObject json = new JsonObject();
if (this.includeUrl) {
@@ -151,7 +157,10 @@ public class Resource extends MultiFormatMapper {
Optional<JsonObject> jsonObject = this.vertexToJsonObject(v);
if (jsonObject.isPresent()) {
String nodeType = v.<String>value(AAIProperties.NODE_TYPE);
- Map<String, Set<String>> filterPropertiesMap = createFilteredPropertyMap(properties); // this change is for resource_and_url with/out as-tree. and no as-tree req
+ Map<String, Set<String>> filterPropertiesMap = createFilteredPropertyMap(properties); // this change is for
+ // resource_and_url
+ // with/out as-tree.
+ // and no as-tree req
JsonObject jo = filterProperties(jsonObject, nodeType, filterPropertiesMap);
json.add(v.<String>property(AAIProperties.NODE_TYPE).orElse(null), jo);
} else {
@@ -166,7 +175,7 @@ public class Resource extends MultiFormatMapper {
}
try {
final Introspector obj =
- getLoader().introspectorFromName(v.<String>property(AAIProperties.NODE_TYPE).orElse(null));
+ getLoader().introspectorFromName(v.<String>property(AAIProperties.NODE_TYPE).orElse(null));
final List<Vertex> wrapper = new ArrayList<>();
@@ -176,7 +185,7 @@ public class Resource extends MultiFormatMapper {
getSerializer().dbToObject(wrapper, obj, this.depth, this.nodesOnly, "false", isSkipRelatedTo);
} catch (AAIException | UnsupportedEncodingException e) {
throw new AAIFormatVertexException(
- "Failed to format vertex - error while serializing: " + e.getMessage(), e);
+ "Failed to format vertex - error while serializing: " + e.getMessage(), e);
}
final String json = obj.marshal(false);
@@ -221,7 +230,8 @@ public class Resource extends MultiFormatMapper {
this.urlBuilder = urlBuilder;
}
- public Builder(Loader loader, DBSerializer serializer, UrlBuilder urlBuilder, MultivaluedMap<String, String> params) {
+ public Builder(Loader loader, DBSerializer serializer, UrlBuilder urlBuilder,
+ MultivaluedMap<String, String> params) {
this.loader = loader;
this.serializer = serializer;
this.urlBuilder = urlBuilder;
@@ -240,7 +250,9 @@ public class Resource extends MultiFormatMapper {
return this.urlBuilder;
}
- protected MultivaluedMap<String, String> getParams() { return this.params; }
+ protected MultivaluedMap<String, String> getParams() {
+ return this.params;
+ }
public boolean isSkipRelatedTo() {
if (params != null) {
@@ -257,14 +269,15 @@ public class Resource extends MultiFormatMapper {
return true;
}
- protected boolean isTree() { return this.tree; }
+ protected boolean isTree() {
+ return this.tree;
+ }
public Builder isTree(Boolean tree) {
this.tree = tree;
return this;
}
-
public Builder includeUrl() {
this.includeUrl = true;
return this;
diff --git a/aai-core/src/main/java/org/onap/aai/serialization/queryformats/ResourceWithSoT.java b/aai-core/src/main/java/org/onap/aai/serialization/queryformats/ResourceWithSoT.java
index 1a56805c..076f665d 100644
--- a/aai-core/src/main/java/org/onap/aai/serialization/queryformats/ResourceWithSoT.java
+++ b/aai-core/src/main/java/org/onap/aai/serialization/queryformats/ResourceWithSoT.java
@@ -22,9 +22,11 @@ package org.onap.aai.serialization.queryformats;
import com.google.gson.JsonObject;
import com.google.gson.JsonParser;
+
import java.util.List;
import java.util.Map;
import java.util.Optional;
+
import org.apache.tinkerpop.gremlin.structure.Vertex;
import org.onap.aai.db.props.AAIProperties;
import org.onap.aai.introspection.Loader;
@@ -92,7 +94,9 @@ public class ResourceWithSoT extends MultiFormatMapper {
return this;
}
- protected boolean isTree() { return this.tree; }
+ protected boolean isTree() {
+ return this.tree;
+ }
public Builder isTree(Boolean tree) {
this.tree = tree;
@@ -185,7 +189,8 @@ public class ResourceWithSoT extends MultiFormatMapper {
}
@Override
- protected Optional<JsonObject> getJsonFromVertex(Vertex input, Map<String, List<String>> properties) throws AAIFormatVertexException {
+ protected Optional<JsonObject> getJsonFromVertex(Vertex input, Map<String, List<String>> properties)
+ throws AAIFormatVertexException {
return Optional.empty();
}
}
diff --git a/aai-core/src/main/java/org/onap/aai/serialization/queryformats/StateFormat.java b/aai-core/src/main/java/org/onap/aai/serialization/queryformats/StateFormat.java
index b2813476..24405953 100644
--- a/aai-core/src/main/java/org/onap/aai/serialization/queryformats/StateFormat.java
+++ b/aai-core/src/main/java/org/onap/aai/serialization/queryformats/StateFormat.java
@@ -20,17 +20,18 @@
package org.onap.aai.serialization.queryformats;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
import com.google.gson.JsonArray;
import com.google.gson.JsonObject;
+
+import java.util.*;
+
import org.apache.tinkerpop.gremlin.structure.Edge;
import org.apache.tinkerpop.gremlin.structure.Vertex;
import org.apache.tinkerpop.gremlin.structure.VertexProperty;
import org.onap.aai.db.props.AAIProperties;
import org.onap.aai.serialization.queryformats.exceptions.AAIFormatVertexException;
-
-import java.util.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
public class StateFormat extends HistoryFormat {
@@ -102,18 +103,29 @@ public class StateFormat extends HistoryFormat {
LOGGER.warn("Vertex {} is missing aai-uri", related.id());
json.addProperty("uri", "NA");
}
- json.addProperty(TIMESTAMP, e.property(AAIProperties.START_TS).isPresent()? e.value(AAIProperties.START_TS) : 0);
- json.addProperty(SOT, e.property(AAIProperties.SOURCE_OF_TRUTH).isPresent()? e.value(AAIProperties.SOURCE_OF_TRUTH) : "");
- json.addProperty(TX_ID, e.property(AAIProperties.START_TX_ID).isPresent()? e.value(AAIProperties.START_TX_ID) : "N/A");
+ json.addProperty(TIMESTAMP,
+ e.property(AAIProperties.START_TS).isPresent() ? e.value(AAIProperties.START_TS) : 0);
+ json.addProperty(SOT,
+ e.property(AAIProperties.SOURCE_OF_TRUTH).isPresent() ? e.value(AAIProperties.SOURCE_OF_TRUTH) : "");
+ json.addProperty(TX_ID,
+ e.property(AAIProperties.START_TX_ID).isPresent() ? e.value(AAIProperties.START_TX_ID) : "N/A");
return json;
}
-
protected void addMetaProperties(JsonObject json, JsonObject metaProperties) {
- json.addProperty(TIMESTAMP, metaProperties.get(AAIProperties.START_TS) != null ? metaProperties.get(AAIProperties.START_TS).getAsLong() : 0);
- json.addProperty(SOT, metaProperties.get(AAIProperties.SOURCE_OF_TRUTH) != null ? metaProperties.get(AAIProperties.SOURCE_OF_TRUTH).getAsString() : "");
- json.addProperty(TX_ID, metaProperties.get(AAIProperties.START_TX_ID) != null ? metaProperties.get(AAIProperties.START_TX_ID).getAsString() : "N/A");
+ json.addProperty(TIMESTAMP,
+ metaProperties.get(AAIProperties.START_TS) != null
+ ? metaProperties.get(AAIProperties.START_TS).getAsLong()
+ : 0);
+ json.addProperty(SOT,
+ metaProperties.get(AAIProperties.SOURCE_OF_TRUTH) != null
+ ? metaProperties.get(AAIProperties.SOURCE_OF_TRUTH).getAsString()
+ : "");
+ json.addProperty(TX_ID,
+ metaProperties.get(AAIProperties.START_TX_ID) != null
+ ? metaProperties.get(AAIProperties.START_TX_ID).getAsString()
+ : "N/A");
}
@Override
@@ -137,7 +149,8 @@ public class StateFormat extends HistoryFormat {
}
@Override
- protected Optional<JsonObject> getJsonFromVertex(Vertex input, Map<String, List<String>> properties) throws AAIFormatVertexException {
+ protected Optional<JsonObject> getJsonFromVertex(Vertex input, Map<String, List<String>> properties)
+ throws AAIFormatVertexException {
return Optional.empty();
}
diff --git a/aai-core/src/main/java/org/onap/aai/serialization/queryformats/TreeFormat.java b/aai-core/src/main/java/org/onap/aai/serialization/queryformats/TreeFormat.java
index d94c4b92..2e1cbf6e 100644
--- a/aai-core/src/main/java/org/onap/aai/serialization/queryformats/TreeFormat.java
+++ b/aai-core/src/main/java/org/onap/aai/serialization/queryformats/TreeFormat.java
@@ -26,7 +26,11 @@ import com.google.gson.JsonArray;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import com.google.gson.JsonParser;
+
+import java.io.UnsupportedEncodingException;
+import java.util.*;
import java.util.Map.Entry;
+
import org.apache.tinkerpop.gremlin.process.traversal.step.util.BulkSet;
import org.apache.tinkerpop.gremlin.process.traversal.step.util.Tree;
import org.apache.tinkerpop.gremlin.structure.Vertex;
@@ -43,9 +47,6 @@ import org.onap.aai.serialization.queryformats.params.Depth;
import org.onap.aai.serialization.queryformats.params.NodesOnly;
import org.onap.aai.serialization.queryformats.utils.UrlBuilder;
-import java.io.UnsupportedEncodingException;
-import java.util.*;
-
public class TreeFormat extends MultiFormatMapper {
private static final EELFLogger TREE_FORMAT_LOGGER = EELFManager.getInstance().getLogger(TreeFormat.class);
protected JsonParser parser = new JsonParser();
@@ -141,12 +142,13 @@ public class TreeFormat extends MultiFormatMapper {
JsonArray body = new JsonArray();
for (Object o : queryResults) {
try {
- return this.formatObjectToJsonArray(o, properties).orElseGet( () -> {
+ return this.formatObjectToJsonArray(o, properties).orElseGet(() -> {
TREE_FORMAT_LOGGER.warn("Empty Optional returned by 'formatObjectToJsonArray'");
return body;
});
} catch (AAIFormatVertexException e) {
- TREE_FORMAT_LOGGER.warn("Failed to format vertex, returning a partial list " + LogFormatTools.getStackTop(e));
+ TREE_FORMAT_LOGGER
+ .warn("Failed to format vertex, returning a partial list " + LogFormatTools.getStackTop(e));
} catch (AAIFormatQueryResultFormatNotSupported e) {
TREE_FORMAT_LOGGER.warn("Failed to format result type of the query " + LogFormatTools.getStackTop(e));
}
@@ -155,7 +157,7 @@ public class TreeFormat extends MultiFormatMapper {
}
public Optional<JsonArray> formatObjectToJsonArray(Object input, Map<String, List<String>> properties)
- throws AAIFormatVertexException, AAIFormatQueryResultFormatNotSupported {
+ throws AAIFormatVertexException, AAIFormatQueryResultFormatNotSupported {
JsonArray json = new JsonArray();
if (input == null)
return Optional.of(json);
@@ -185,13 +187,11 @@ public class TreeFormat extends MultiFormatMapper {
if (obj.isPresent()) {
jsonObject = obj.get();
for (Map.Entry<String, JsonElement> mapEntry : jsonObject.entrySet()) {
- JsonElement jsonRootElementContents = mapEntry.getValue(); // getting everyObject inside
+ JsonElement jsonRootElementContents = mapEntry.getValue(); // getting everyObject inside
if (jsonRootElementContents != null && jsonRootElementContents.isJsonObject()) {
JsonObject relatedJsonNode = (JsonObject) jsonRootElementContents;
- addRelatedNodesToJsonObject(
- jsonRootElementContents.getAsJsonObject(),
- getRelatedNodes(relatedJsonNode)
- );
+ addRelatedNodesToJsonObject(jsonRootElementContents.getAsJsonObject(),
+ getRelatedNodes(relatedJsonNode));
}
}
jsonArray.add(jsonObject);
@@ -206,9 +206,8 @@ public class TreeFormat extends MultiFormatMapper {
for (Map.Entry<String, JsonElement> mapEntry : jsonObject.entrySet()) {
JsonElement jsonRootElementContents = mapEntry.getValue();
if (jsonRootElementContents != null && jsonRootElementContents.isJsonObject()) {
- addRelatedNodesToJsonObject(
- jsonRootElementContents.getAsJsonObject(),
- getRelatedNodes(entry.getValue()));
+ addRelatedNodesToJsonObject(jsonRootElementContents.getAsJsonObject(),
+ getRelatedNodes(entry.getValue()));
}
}
jsonArray.add(jsonObject);
@@ -225,10 +224,7 @@ public class TreeFormat extends MultiFormatMapper {
JsonElement jsonRootElementContents = jsonObj.get(s);
if (jsonRootElementContents != null && jsonRootElementContents.isJsonObject()) {
JsonObject relatedJsonNode = jsonRootElementContents.getAsJsonObject();
- addRelatedNodesToJsonObject(
- relatedJsonNode,
- this.getRelatedNodes(relatedJsonNode)
- );
+ addRelatedNodesToJsonObject(relatedJsonNode, this.getRelatedNodes(relatedJsonNode));
relatedNodes.add(relatedJsonNode);
}
}
@@ -248,25 +244,23 @@ public class TreeFormat extends MultiFormatMapper {
}
private void processVertex(JsonArray relatedNodes, Entry<Object, Tree<Object>> entry, Vertex o)
- throws AAIFormatVertexException {
+ throws AAIFormatVertexException {
Optional<JsonObject> obj = this.getJsonFromVertex(o);
if (obj.isPresent()) {
JsonObject jsonObj = obj.get();
for (Entry<String, JsonElement> mapEntry : jsonObj.entrySet()) {
JsonElement jsonRootElementContents = mapEntry.getValue();
if (jsonRootElementContents != null && jsonRootElementContents.isJsonObject()) {
- JsonObject jsonObject = addRelatedNodesToJsonObject(
- jsonRootElementContents.getAsJsonObject(),
- getRelatedNodes(entry.getValue()));
+ JsonObject jsonObject = addRelatedNodesToJsonObject(jsonRootElementContents.getAsJsonObject(),
+ getRelatedNodes(entry.getValue()));
relatedNodes.add(jsonObject);
}
}
}
}
-
private static JsonObject addRelatedNodesToJsonObject(JsonObject jsonObject, Optional<JsonArray> relatedNodesOpt) {
- relatedNodesOpt.ifPresent( relatedNodes -> {
+ relatedNodesOpt.ifPresent(relatedNodes -> {
if (relatedNodes.size() > 0) {
jsonObject.add("related-nodes", relatedNodes);
}
@@ -303,7 +297,7 @@ public class TreeFormat extends MultiFormatMapper {
protected Optional<JsonObject> vertexToJsonObject(Vertex v) throws AAIFormatVertexException {
try {
final Introspector obj =
- getLoader().introspectorFromName(v.<String>property(AAIProperties.NODE_TYPE).orElse(null));
+ getLoader().introspectorFromName(v.<String>property(AAIProperties.NODE_TYPE).orElse(null));
final List<Vertex> wrapper = new ArrayList<>();
@@ -313,7 +307,7 @@ public class TreeFormat extends MultiFormatMapper {
getSerializer().dbToObject(wrapper, obj, this.depth, this.nodesOnly, "false");
} catch (AAIException | UnsupportedEncodingException e) {
throw new AAIFormatVertexException(
- "Failed to format vertex - error while serializing: " + e.getMessage(), e);
+ "Failed to format vertex - error while serializing: " + e.getMessage(), e);
}
final String json = obj.marshal(false);
@@ -336,9 +330,9 @@ public class TreeFormat extends MultiFormatMapper {
return parser;
}
-
@Override
- protected Optional<JsonObject> getJsonFromVertex(Vertex input, Map<String, List<String>> properties) throws AAIFormatVertexException {
+ protected Optional<JsonObject> getJsonFromVertex(Vertex input, Map<String, List<String>> properties)
+ throws AAIFormatVertexException {
return Optional.empty();
}
}
diff --git a/aai-core/src/main/java/org/onap/aai/serialization/queryformats/utils/QueryParamInjector.java b/aai-core/src/main/java/org/onap/aai/serialization/queryformats/utils/QueryParamInjector.java
index f90907e2..a0693a8e 100644
--- a/aai-core/src/main/java/org/onap/aai/serialization/queryformats/utils/QueryParamInjector.java
+++ b/aai-core/src/main/java/org/onap/aai/serialization/queryformats/utils/QueryParamInjector.java
@@ -20,23 +20,19 @@
package org.onap.aai.serialization.queryformats.utils;
-import org.onap.aai.serialization.queryformats.exceptions.QueryParamInjectionException;
-import org.onap.aai.serialization.queryformats.params.*;
-
-import javax.ws.rs.core.MultivaluedMap;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
+import javax.ws.rs.core.MultivaluedMap;
+
+import org.onap.aai.serialization.queryformats.exceptions.QueryParamInjectionException;
+import org.onap.aai.serialization.queryformats.params.*;
+
public class QueryParamInjector {
- //TODO reimplement this using reflections.
- private static final Class<?>[] PARAM_CLASSES = new Class[] {
- AsTree.class,
- Depth.class,
- EndTs.class,
- NodesOnly.class,
- StartTs.class
- };
+ // TODO reimplement this using reflections.
+ private static final Class<?>[] PARAM_CLASSES =
+ new Class[] {AsTree.class, Depth.class, EndTs.class, NodesOnly.class, StartTs.class};
private static class Helper {
private static final QueryParamInjector INSTANCE = new QueryParamInjector();
diff --git a/aai-core/src/main/java/org/onap/aai/serialization/queryformats/utils/UrlBuilder.java b/aai-core/src/main/java/org/onap/aai/serialization/queryformats/utils/UrlBuilder.java
index 2d37f1b4..3fcecf6a 100644
--- a/aai-core/src/main/java/org/onap/aai/serialization/queryformats/utils/UrlBuilder.java
+++ b/aai-core/src/main/java/org/onap/aai/serialization/queryformats/utils/UrlBuilder.java
@@ -57,8 +57,8 @@ public class UrlBuilder {
String basePath) throws AAIException {
this.serializer = serializer;
this.version = version;
- if(serverBase == null){
- this.serverBase = getServerBase();
+ if (serverBase == null) {
+ this.serverBase = getServerBase();
} else {
this.serverBase = serverBase;
}
diff --git a/aai-core/src/main/java/org/onap/aai/service/NodeValidationService.java b/aai-core/src/main/java/org/onap/aai/service/NodeValidationService.java
index 6c57616e..ca4666ae 100644
--- a/aai-core/src/main/java/org/onap/aai/service/NodeValidationService.java
+++ b/aai-core/src/main/java/org/onap/aai/service/NodeValidationService.java
@@ -20,12 +20,11 @@
package org.onap.aai.service;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
import javax.annotation.PostConstruct;
import org.onap.aai.validation.nodes.NodeValidator;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.context.annotation.PropertySource;
diff --git a/aai-core/src/main/java/org/onap/aai/tasks/ScheduledTasks.java b/aai-core/src/main/java/org/onap/aai/tasks/ScheduledTasks.java
index 282d8819..64d67c0c 100644
--- a/aai-core/src/main/java/org/onap/aai/tasks/ScheduledTasks.java
+++ b/aai-core/src/main/java/org/onap/aai/tasks/ScheduledTasks.java
@@ -53,7 +53,7 @@ public class ScheduledTasks {
// configuration properties files
@Scheduled(fixedRate = PROPERTY_READ_INTERVAL)
public void loadAAIProperties() {
- auditLog.logBefore("LoadAaiPropertiesTask", ONAPComponents.AAI.toString() );
+ auditLog.logBefore("LoadAaiPropertiesTask", ONAPComponents.AAI.toString());
String dir = FilenameUtils.getFullPathNoEndSeparator(GlobalPropFileName);
if (dir == null || dir.length() < 3) {
dir = "/opt/aai/etc";
diff --git a/aai-core/src/main/java/org/onap/aai/transforms/XmlFormatTransformer.java b/aai-core/src/main/java/org/onap/aai/transforms/XmlFormatTransformer.java
index ce7ead4f..9ff146be 100644
--- a/aai-core/src/main/java/org/onap/aai/transforms/XmlFormatTransformer.java
+++ b/aai-core/src/main/java/org/onap/aai/transforms/XmlFormatTransformer.java
@@ -17,17 +17,19 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
+
package org.onap.aai.transforms;
import com.bazaarvoice.jolt.Chainr;
import com.bazaarvoice.jolt.JsonUtils;
+
+import java.util.List;
+
import org.json.JSONObject;
import org.json.XML;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import java.util.List;
-
public class XmlFormatTransformer {
private static final Logger LOGGER = LoggerFactory.getLogger(XmlFormatTransformer.class);
@@ -39,19 +41,19 @@ public class XmlFormatTransformer {
public XmlFormatTransformer() {
List<Object> spec = JsonUtils.classpathToList("/specs/transform-related-to-node.json");
- this.chainr = Chainr.fromSpec(spec);
+ this.chainr = Chainr.fromSpec(spec);
}
public String transform(String input) {
Object transformedOutput;
- if(!input.contains(RESULT_WITH_QUOTES)){
+ if (!input.contains(RESULT_WITH_QUOTES)) {
Object inputMap = JsonUtils.jsonToMap(input);
transformedOutput = chainr.transform(inputMap);
JSONObject jsonObject;
- if(transformedOutput == null){
+ if (transformedOutput == null) {
LOGGER.debug("For the input {}, unable to transform it so returning null", input);
jsonObject = new JSONObject();
} else {
diff --git a/aai-core/src/main/java/org/onap/aai/util/Entity.java b/aai-core/src/main/java/org/onap/aai/util/Entity.java
index 4605414b..52a78d3c 100644
--- a/aai-core/src/main/java/org/onap/aai/util/Entity.java
+++ b/aai-core/src/main/java/org/onap/aai/util/Entity.java
@@ -20,6 +20,13 @@
package org.onap.aai.util;
+import com.fasterxml.jackson.annotation.JsonAnyGetter;
+import com.fasterxml.jackson.annotation.JsonAnySetter;
+import com.fasterxml.jackson.annotation.JsonIgnore;
+import com.fasterxml.jackson.annotation.JsonInclude;
+import com.fasterxml.jackson.annotation.JsonProperty;
+import com.fasterxml.jackson.annotation.JsonPropertyOrder;
+
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
@@ -31,13 +38,6 @@ import org.apache.commons.lang3.builder.EqualsBuilder;
import org.apache.commons.lang3.builder.HashCodeBuilder;
import org.apache.commons.lang3.builder.ToStringBuilder;
-import com.fasterxml.jackson.annotation.JsonAnyGetter;
-import com.fasterxml.jackson.annotation.JsonAnySetter;
-import com.fasterxml.jackson.annotation.JsonIgnore;
-import com.fasterxml.jackson.annotation.JsonInclude;
-import com.fasterxml.jackson.annotation.JsonProperty;
-import com.fasterxml.jackson.annotation.JsonPropertyOrder;
-
@JsonInclude(JsonInclude.Include.NON_NULL)
@Generated("org.jsonschema2pojo")
@JsonPropertyOrder({"equipment-role", "action", "key-value-list", "self-link"})
diff --git a/aai-core/src/main/java/org/onap/aai/util/EntityList.java b/aai-core/src/main/java/org/onap/aai/util/EntityList.java
index 375614bc..e2bab6f5 100644
--- a/aai-core/src/main/java/org/onap/aai/util/EntityList.java
+++ b/aai-core/src/main/java/org/onap/aai/util/EntityList.java
@@ -20,6 +20,13 @@
package org.onap.aai.util;
+import com.fasterxml.jackson.annotation.JsonAnyGetter;
+import com.fasterxml.jackson.annotation.JsonAnySetter;
+import com.fasterxml.jackson.annotation.JsonIgnore;
+import com.fasterxml.jackson.annotation.JsonInclude;
+import com.fasterxml.jackson.annotation.JsonProperty;
+import com.fasterxml.jackson.annotation.JsonPropertyOrder;
+
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
@@ -31,13 +38,6 @@ import org.apache.commons.lang3.builder.EqualsBuilder;
import org.apache.commons.lang3.builder.HashCodeBuilder;
import org.apache.commons.lang3.builder.ToStringBuilder;
-import com.fasterxml.jackson.annotation.JsonAnyGetter;
-import com.fasterxml.jackson.annotation.JsonAnySetter;
-import com.fasterxml.jackson.annotation.JsonIgnore;
-import com.fasterxml.jackson.annotation.JsonInclude;
-import com.fasterxml.jackson.annotation.JsonProperty;
-import com.fasterxml.jackson.annotation.JsonPropertyOrder;
-
@JsonInclude(JsonInclude.Include.NON_NULL)
@Generated("org.jsonschema2pojo")
@JsonPropertyOrder({"entity"})
diff --git a/aai-core/src/main/java/org/onap/aai/util/HttpsAuthClient.java b/aai-core/src/main/java/org/onap/aai/util/HttpsAuthClient.java
index 0cc3aef8..f8f0b65e 100644
--- a/aai-core/src/main/java/org/onap/aai/util/HttpsAuthClient.java
+++ b/aai-core/src/main/java/org/onap/aai/util/HttpsAuthClient.java
@@ -26,6 +26,7 @@ import com.sun.jersey.api.client.config.ClientConfig;
import com.sun.jersey.api.client.config.DefaultClientConfig;
import com.sun.jersey.api.json.JSONConfiguration;
import com.sun.jersey.client.urlconnection.HTTPSProperties;
+
import java.io.FileInputStream;
import java.io.IOException;
import java.security.KeyManagementException;
@@ -34,11 +35,13 @@ import java.security.KeyStoreException;
import java.security.NoSuchAlgorithmException;
import java.security.UnrecoverableKeyException;
import java.security.cert.CertificateException;
+
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.onap.aai.aailog.filter.RestControllerClientLoggingInterceptor;
import org.onap.aai.exceptions.AAIException;
import org.slf4j.Logger;
@@ -71,6 +74,7 @@ public class HttpsAuthClient {
logger.debug("HttpsAuthClient error : {}", e.getMessage());
}
}
+
/**
* Gets the client.
*
@@ -81,7 +85,9 @@ public class HttpsAuthClient {
* @return the client
* @throws KeyManagementException the key management exception
*/
- public static Client getClient(String truststorePath, String truststorePassword, String keystorePath, String keystorePassword) throws KeyManagementException, UnrecoverableKeyException, CertificateException, NoSuchAlgorithmException, KeyStoreException, IOException {
+ public static Client getClient(String truststorePath, String truststorePassword, String keystorePath,
+ String keystorePassword) throws KeyManagementException, UnrecoverableKeyException, CertificateException,
+ NoSuchAlgorithmException, KeyStoreException, IOException {
ClientConfig config = new DefaultClientConfig();
config.getFeatures().put(JSONConfiguration.FEATURE_POJO_MAPPING, Boolean.TRUE);
@@ -112,12 +118,12 @@ public class HttpsAuthClient {
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));
+ 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.getMessage());
throw e;
@@ -130,22 +136,22 @@ public class HttpsAuthClient {
return client;
}
+
/**
* Gets the client.
*
* @return the client
* @throws KeyManagementException the key management exception
*/
- public static Client getClient() throws KeyManagementException, AAIException, UnrecoverableKeyException, CertificateException, NoSuchAlgorithmException, KeyStoreException, IOException {
+ public static Client getClient() throws KeyManagementException, AAIException, UnrecoverableKeyException,
+ CertificateException, NoSuchAlgorithmException, KeyStoreException, IOException {
String truststorePath = null;
String truststorePassword = null;
String keystorePath = null;
String keystorePassword = null;
- truststorePath =
- AAIConstants.AAI_HOME_ETC_AUTH + AAIConfig.get(AAIConstants.AAI_TRUSTSTORE_FILENAME);
+ truststorePath = AAIConstants.AAI_HOME_ETC_AUTH + AAIConfig.get(AAIConstants.AAI_TRUSTSTORE_FILENAME);
truststorePassword = AAIConfig.get(AAIConstants.AAI_TRUSTSTORE_PASSWD);
- keystorePath =
- AAIConstants.AAI_HOME_ETC_AUTH + AAIConfig.get(AAIConstants.AAI_KEYSTORE_FILENAME);
+ keystorePath = AAIConstants.AAI_HOME_ETC_AUTH + AAIConfig.get(AAIConstants.AAI_KEYSTORE_FILENAME);
keystorePassword = AAIConfig.get(AAIConstants.AAI_KEYSTORE_PASSWD);
return getClient(truststorePath, truststorePassword, keystorePath, keystorePassword);
}
diff --git a/aai-core/src/main/java/org/onap/aai/util/KeyValueList.java b/aai-core/src/main/java/org/onap/aai/util/KeyValueList.java
index c3382b2d..8c9ea52b 100644
--- a/aai-core/src/main/java/org/onap/aai/util/KeyValueList.java
+++ b/aai-core/src/main/java/org/onap/aai/util/KeyValueList.java
@@ -20,6 +20,13 @@
package org.onap.aai.util;
+import com.fasterxml.jackson.annotation.JsonAnyGetter;
+import com.fasterxml.jackson.annotation.JsonAnySetter;
+import com.fasterxml.jackson.annotation.JsonIgnore;
+import com.fasterxml.jackson.annotation.JsonInclude;
+import com.fasterxml.jackson.annotation.JsonProperty;
+import com.fasterxml.jackson.annotation.JsonPropertyOrder;
+
import java.util.HashMap;
import java.util.Map;
@@ -29,13 +36,6 @@ import org.apache.commons.lang3.builder.EqualsBuilder;
import org.apache.commons.lang3.builder.HashCodeBuilder;
import org.apache.commons.lang3.builder.ToStringBuilder;
-import com.fasterxml.jackson.annotation.JsonAnyGetter;
-import com.fasterxml.jackson.annotation.JsonAnySetter;
-import com.fasterxml.jackson.annotation.JsonIgnore;
-import com.fasterxml.jackson.annotation.JsonInclude;
-import com.fasterxml.jackson.annotation.JsonProperty;
-import com.fasterxml.jackson.annotation.JsonPropertyOrder;
-
@JsonInclude(JsonInclude.Include.NON_NULL)
@Generated("org.jsonschema2pojo")
@JsonPropertyOrder({"key", "value"})
diff --git a/aai-core/src/main/java/org/onap/aai/util/PojoUtils.java b/aai-core/src/main/java/org/onap/aai/util/PojoUtils.java
index d83c9ec3..f974ba14 100644
--- a/aai-core/src/main/java/org/onap/aai/util/PojoUtils.java
+++ b/aai-core/src/main/java/org/onap/aai/util/PojoUtils.java
@@ -20,6 +20,17 @@
package org.onap.aai.util;
+import com.fasterxml.jackson.annotation.JsonInclude;
+import com.fasterxml.jackson.core.JsonGenerationException;
+import com.fasterxml.jackson.databind.DeserializationFeature;
+import com.fasterxml.jackson.databind.JsonMappingException;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.fasterxml.jackson.databind.SerializationFeature;
+import com.fasterxml.jackson.databind.json.JsonMapper;
+import com.fasterxml.jackson.module.jaxb.JaxbAnnotationModule;
+import com.google.common.base.CaseFormat;
+import com.google.common.collect.Multimap;
+
import java.io.IOException;
import java.io.StringWriter;
import java.lang.reflect.InvocationTargetException;
@@ -45,28 +56,17 @@ import org.eclipse.persistence.jaxb.MarshallerProperties;
import org.onap.aai.domain.model.AAIResource;
import org.onap.aai.exceptions.AAIException;
-import com.fasterxml.jackson.annotation.JsonInclude;
-import com.fasterxml.jackson.core.JsonGenerationException;
-import com.fasterxml.jackson.databind.DeserializationFeature;
-import com.fasterxml.jackson.databind.JsonMappingException;
-import com.fasterxml.jackson.databind.ObjectMapper;
-import com.fasterxml.jackson.databind.SerializationFeature;
-import com.fasterxml.jackson.databind.json.JsonMapper;
-import com.fasterxml.jackson.module.jaxb.JaxbAnnotationModule;
-import com.google.common.base.CaseFormat;
-import com.google.common.collect.Multimap;
-
public class PojoUtils {
/**
* Gets the key value list.
*
- * @param <T> the generic type
- * @param e the e
+ * @param <T> the generic type
+ * @param e the e
* @param clazz the clazz
* @return the key value list
- * @throws IllegalAccessException the illegal access exception
- * @throws IllegalArgumentException the illegal argument exception
+ * @throws IllegalAccessException the illegal access exception
+ * @throws IllegalArgumentException the illegal argument exception
* @throws InvocationTargetException the invocation target exception
*/
public <T> List<KeyValueList> getKeyValueList(Entity e, T clazz)
@@ -99,12 +99,12 @@ public class PojoUtils {
/**
* Gets the json from object.
*
- * @param <T> the generic type
+ * @param <T> the generic type
* @param clazz the clazz
* @return the json from object
* @throws JsonGenerationException the json generation exception
- * @throws JsonMappingException the json mapping exception
- * @throws IOException Signals that an I/O exception has occurred.
+ * @throws JsonMappingException the json mapping exception
+ * @throws IOException Signals that an I/O exception has occurred.
*/
public <T> String getJsonFromObject(T clazz) throws JsonGenerationException, JsonMappingException, IOException {
return getJsonFromObject(clazz, false, true);
@@ -113,26 +113,24 @@ public class PojoUtils {
/**
* Gets the json from object.
*
- * @param <T> the generic type
- * @param clazz the clazz
+ * @param <T> the generic type
+ * @param clazz the clazz
* @param wrapRoot the wrap root
- * @param indent the indent
+ * @param indent the indent
* @return the json from object
* @throws JsonGenerationException the json generation exception
- * @throws JsonMappingException the json mapping exception
- * @throws IOException Signals that an I/O exception has occurred.
+ * @throws JsonMappingException the json mapping exception
+ * @throws IOException Signals that an I/O exception has occurred.
*/
public <T> String getJsonFromObject(T clazz, boolean wrapRoot, boolean indent)
throws JsonGenerationException, JsonMappingException, IOException {
- ObjectMapper mapper = JsonMapper.builder()
- .serializationInclusion(JsonInclude.Include.NON_NULL)
- .configure(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS, false)
- .configure(SerializationFeature.INDENT_OUTPUT, indent)
- .configure(SerializationFeature.WRAP_ROOT_VALUE, wrapRoot)
- .configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false)
- .configure(DeserializationFeature.UNWRAP_ROOT_VALUE, wrapRoot)
- .addModule(new JaxbAnnotationModule())
- .build();
+ ObjectMapper mapper = JsonMapper.builder().serializationInclusion(JsonInclude.Include.NON_NULL)
+ .configure(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS, false)
+ .configure(SerializationFeature.INDENT_OUTPUT, indent)
+ .configure(SerializationFeature.WRAP_ROOT_VALUE, wrapRoot)
+ .configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false)
+ .configure(DeserializationFeature.UNWRAP_ROOT_VALUE, wrapRoot).addModule(new JaxbAnnotationModule())
+ .build();
return mapper.writeValueAsString(clazz);
}
@@ -140,14 +138,14 @@ public class PojoUtils {
/**
* Gets the json from dynamic object.
*
- * @param ent the ent
+ * @param ent the ent
* @param jaxbContext the jaxb context
* @param includeRoot the include root
* @return the json from dynamic object
* @throws JsonGenerationException the json generation exception
- * @throws JsonMappingException the json mapping exception
- * @throws IOException Signals that an I/O exception has occurred.
- * @throws JAXBException the JAXB exception
+ * @throws JsonMappingException the json mapping exception
+ * @throws IOException Signals that an I/O exception has occurred.
+ * @throws JAXBException the JAXB exception
*/
public String getJsonFromDynamicObject(DynamicEntity ent, org.eclipse.persistence.jaxb.JAXBContext jaxbContext,
boolean includeRoot) throws JsonGenerationException, JsonMappingException, IOException, JAXBException {
@@ -166,7 +164,7 @@ public class PojoUtils {
/**
* Gets the xml from object.
*
- * @param <T> the generic type
+ * @param <T> the generic type
* @param clazz the clazz
* @return the xml from object
* @throws JAXBException the JAXB exception
@@ -179,7 +177,7 @@ public class PojoUtils {
Marshaller marshaller = jc.createMarshaller();
marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true);
marshaller.marshal(clazz, baos);
-
+
return baos.toString(Charset.defaultCharset());
}
}
@@ -187,9 +185,9 @@ public class PojoUtils {
/**
* Gets the lookup key.
*
- * @param baseKey the base key
+ * @param baseKey the base key
* @param lookupHash the lookup hash
- * @param keyProps the key props
+ * @param keyProps the key props
* @return the lookup key
*/
public String getLookupKey(String baseKey, HashMap<String, Object> lookupHash, Collection<String> keyProps) {
@@ -213,7 +211,7 @@ public class PojoUtils {
/**
* Gets the lookup keys.
*
- * @param lookupHashes the lookup hashes
+ * @param lookupHashes the lookup hashes
* @param _dbRulesNodeKeyProps the db rules node key props
* @return the lookup keys
*/
@@ -237,16 +235,16 @@ public class PojoUtils {
/**
* Gets the example object.
*
- * @param <T> the generic type
- * @param clazz the clazz
+ * @param <T> the generic type
+ * @param clazz the clazz
* @param singleton the singleton
* @return the example object
- * @throws IllegalAccessException the illegal access exception
- * @throws IllegalArgumentException the illegal argument exception
+ * @throws IllegalAccessException the illegal access exception
+ * @throws IllegalArgumentException the illegal argument exception
* @throws InvocationTargetException the invocation target exception
- * @throws NoSuchMethodException the no such method exception
- * @throws SecurityException the security exception
- * @throws AAIException the AAI exception
+ * @throws NoSuchMethodException the no such method exception
+ * @throws SecurityException the security exception
+ * @throws AAIException the AAI exception
*/
public <T> void getExampleObject(T clazz, boolean singleton)
throws IllegalAccessException, IllegalArgumentException, InvocationTargetException, NoSuchMethodException,
@@ -304,8 +302,8 @@ public class PojoUtils {
* Gets the dynamic example object.
*
* @param childObject the child object
- * @param aaiRes the aai res
- * @param singleton the singleton
+ * @param aaiRes the aai res
+ * @param singleton the singleton
* @return the dynamic example object
*/
public void getDynamicExampleObject(DynamicEntity childObject, AAIResource aaiRes, boolean singleton) {
diff --git a/aai-core/src/main/java/org/onap/aai/util/Request.java b/aai-core/src/main/java/org/onap/aai/util/Request.java
index 890398d5..c373738d 100644
--- a/aai-core/src/main/java/org/onap/aai/util/Request.java
+++ b/aai-core/src/main/java/org/onap/aai/util/Request.java
@@ -20,16 +20,6 @@
package org.onap.aai.util;
-import java.io.UnsupportedEncodingException;
-import java.net.URI;
-import java.net.URISyntaxException;
-import java.net.URLEncoder;
-import java.nio.charset.StandardCharsets;
-
-import javax.ws.rs.core.UriBuilder;
-
-import org.onap.aai.exceptions.AAIException;
-
public class Request<T> {
public static final String V14 = "v14";
diff --git a/aai-core/src/main/java/org/onap/aai/util/RestController.java b/aai-core/src/main/java/org/onap/aai/util/RestController.java
index 433458ac..6c57040d 100644
--- a/aai-core/src/main/java/org/onap/aai/util/RestController.java
+++ b/aai-core/src/main/java/org/onap/aai/util/RestController.java
@@ -20,8 +20,6 @@
package org.onap.aai.util;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.type.TypeFactory;
import com.sun.jersey.api.client.Client;
@@ -31,14 +29,16 @@ import com.sun.jersey.api.client.ClientResponse;
import java.io.IOException;
import java.security.KeyManagementException;
import java.security.KeyStoreException;
+import java.security.NoSuchAlgorithmException;
import java.security.UnrecoverableKeyException;
import java.security.cert.CertificateException;
-import java.security.NoSuchAlgorithmException;
import java.util.ArrayList;
import java.util.List;
import java.util.UUID;
import org.onap.aai.exceptions.AAIException;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
public class RestController implements RestControllerInterface {
@@ -85,15 +85,18 @@ public class RestController implements RestControllerInterface {
public static final String REST_APIPATH_LOGICALLINKS = "network/logical-links/";
public static final String REST_APIPATH_LOGICALLINK = "network/logical-links/logical-link/";
- public RestController(String truststorePath, String truststorePassword, String keystorePath, String keystorePassword) throws AAIException {
+ public RestController(String truststorePath, String truststorePassword, String keystorePath,
+ String keystorePassword) throws AAIException {
this.initRestClient(truststorePath, truststorePassword, keystorePath, keystorePassword);
}
+
/**
* Inits the rest client.
*
* @throws AAIException the AAI exception
*/
- public void initRestClient(String truststorePath, String truststorePassword, String keystorePath, String keystorePassword) throws AAIException {
+ public void initRestClient(String truststorePath, String truststorePassword, String keystorePath,
+ String keystorePassword) throws AAIException {
if (client == null) {
try {
client = getHttpsAuthClient(truststorePath, truststorePassword, keystorePath, keystorePassword);
@@ -104,13 +107,18 @@ public class RestController implements RestControllerInterface {
}
}
}
- public Client getHttpsAuthClient(String truststorePath, String truststorePassword, String keystorePath, String keystorePassword) throws KeyManagementException, UnrecoverableKeyException, CertificateException, NoSuchAlgorithmException, KeyStoreException, IOException {
+
+ public Client getHttpsAuthClient(String truststorePath, String truststorePassword, String keystorePath,
+ String keystorePassword) throws KeyManagementException, UnrecoverableKeyException, CertificateException,
+ NoSuchAlgorithmException, KeyStoreException, IOException {
return HttpsAuthClient.getClient(truststorePath, truststorePassword, keystorePath, keystorePassword);
}
- public Client getHttpsAuthClient() throws KeyManagementException, UnrecoverableKeyException, CertificateException, NoSuchAlgorithmException, KeyStoreException, IOException, AAIException {
+ public Client getHttpsAuthClient() throws KeyManagementException, UnrecoverableKeyException, CertificateException,
+ NoSuchAlgorithmException, KeyStoreException, IOException, AAIException {
return HttpsAuthClient.getClient();
}
+
/**
* Sets the rest srvr base URL.
*
@@ -335,7 +343,7 @@ public class RestController implements RestControllerInterface {
+ cres.getEntity(String.class));
}
}
-
+
/**
* Put.
*
@@ -347,14 +355,13 @@ public class RestController implements RestControllerInterface {
* @param apiVersion version number
* @throws AAIException the AAI exception
*/
- public <T> void Put(T t, String sourceID, String transId, String path, String apiVersion)
- throws AAIException {
+ public <T> void Put(T t, String sourceID, String transId, String path, String apiVersion) throws AAIException {
String methodName = "Put";
String url = "";
transId += ":" + UUID.randomUUID().toString();
LOGGER.debug(methodName + " start");
-
+
url = AAIConfig.get(AAIConstants.AAI_SERVER_URL_BASE) + apiVersion + "/" + path;
ClientResponse cres = client.resource(url).accept("application/json").header("X-TransactionId", transId)
diff --git a/aai-core/src/main/java/org/onap/aai/util/RestControllerInterface.java b/aai-core/src/main/java/org/onap/aai/util/RestControllerInterface.java
index f5eed42d..3304e9a5 100644
--- a/aai-core/src/main/java/org/onap/aai/util/RestControllerInterface.java
+++ b/aai-core/src/main/java/org/onap/aai/util/RestControllerInterface.java
@@ -21,7 +21,6 @@
package org.onap.aai.util;
import org.onap.aai.exceptions.AAIException;
-import org.onap.aai.util.RestObject;
public interface RestControllerInterface {
diff --git a/aai-core/src/main/java/org/onap/aai/util/StoreNotificationEvent.java b/aai-core/src/main/java/org/onap/aai/util/StoreNotificationEvent.java
index 01d21ca7..598ef231 100644
--- a/aai-core/src/main/java/org/onap/aai/util/StoreNotificationEvent.java
+++ b/aai-core/src/main/java/org/onap/aai/util/StoreNotificationEvent.java
@@ -20,9 +20,6 @@
package org.onap.aai.util;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
import java.io.StringWriter;
import java.util.Iterator;
import java.util.UUID;
@@ -40,6 +37,8 @@ import org.onap.aai.exceptions.AAIException;
import org.onap.aai.introspection.Introspector;
import org.onap.aai.introspection.Loader;
import org.onap.aai.introspection.exceptions.AAIUnknownObjectException;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
import org.springframework.context.ApplicationContext;
import org.springframework.core.env.Environment;
@@ -273,7 +272,7 @@ public class StoreNotificationEvent {
if (eventHeader.getValue("sequence-number") == null) {
eventHeader.setValue("sequence-number",
- AAIConfig.get("aai.notificationEvent.default.sequenceNumber", "UNK"));
+ AAIConfig.get("aai.notificationEvent.default.sequenceNumber", "UNK"));
}
if (eventHeader.getValue("severity") == null) {
@@ -286,7 +285,7 @@ public class StoreNotificationEvent {
if (notificationEvent.getValue("cambria-partition") == null) {
notificationEvent.setValue("cambria-partition",
- AAIConfig.get("aai.notificationEvent.default.partition", AAIConstants.UEB_PUB_PARTITION_AAI));
+ AAIConfig.get("aai.notificationEvent.default.partition", AAIConstants.UEB_PUB_PARTITION_AAI));
}
notificationEvent.setValue("event-header", eventHeader.getUnderlyingObject());
@@ -322,7 +321,8 @@ public class StoreNotificationEvent {
}
}
- public String storeEventAndSendToJms(Loader loader, Introspector eventHeader, Introspector obj) throws AAIException {
+ public String storeEventAndSendToJms(Loader loader, Introspector eventHeader, Introspector obj)
+ throws AAIException {
if (obj == null) {
throw new AAIException("AAI_7350");
}
diff --git a/aai-core/src/main/java/org/onap/aai/util/delta/DeltaAction.java b/aai-core/src/main/java/org/onap/aai/util/delta/DeltaAction.java
index 1b1e49ae..7db4e834 100644
--- a/aai-core/src/main/java/org/onap/aai/util/delta/DeltaAction.java
+++ b/aai-core/src/main/java/org/onap/aai/util/delta/DeltaAction.java
@@ -21,10 +21,5 @@
package org.onap.aai.util.delta;
public enum DeltaAction {
- CREATE,
- UPDATE,
- DELETE,
- CREATE_REL,
- DELETE_REL,
- STATIC
+ CREATE, UPDATE, DELETE, CREATE_REL, DELETE_REL, STATIC
}
diff --git a/aai-core/src/main/java/org/onap/aai/util/delta/DeltaEvents.java b/aai-core/src/main/java/org/onap/aai/util/delta/DeltaEvents.java
index 138652a4..10d47cd6 100644
--- a/aai-core/src/main/java/org/onap/aai/util/delta/DeltaEvents.java
+++ b/aai-core/src/main/java/org/onap/aai/util/delta/DeltaEvents.java
@@ -20,26 +20,26 @@
package org.onap.aai.util.delta;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
import com.google.gson.*;
-import org.onap.aai.db.props.AAIProperties;
-import org.onap.aai.dmaap.AAIDmaapEventJMSProducer;
-import org.onap.aai.dmaap.MessageProducer;
-import org.onap.aai.util.AAIConfig;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Map;
+import org.onap.aai.db.props.AAIProperties;
+import org.onap.aai.dmaap.AAIDmaapEventJMSProducer;
+import org.onap.aai.dmaap.MessageProducer;
+import org.onap.aai.util.AAIConfig;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
public class DeltaEvents {
private static final Logger LOGGER = LoggerFactory.getLogger(DeltaEvents.class);
- private static final Gson gson = new GsonBuilder()
- .setFieldNamingPolicy(FieldNamingPolicy.LOWER_CASE_WITH_DASHES)
- .create();
+ private static final Gson gson =
+ new GsonBuilder().setFieldNamingPolicy(FieldNamingPolicy.LOWER_CASE_WITH_DASHES).create();
private String transId;
private String sourceName;
@@ -53,7 +53,8 @@ public class DeltaEvents {
this(transId, sourceName, schemaVersion, objectDeltas, new AAIDmaapEventJMSProducer());
}
- public DeltaEvents(String transId, String sourceName, String schemaVersion, Map<String, ObjectDelta> objectDeltas, MessageProducer messageProducer) {
+ public DeltaEvents(String transId, String sourceName, String schemaVersion, Map<String, ObjectDelta> objectDeltas,
+ MessageProducer messageProducer) {
this.transId = transId;
this.sourceName = sourceName;
this.schemaVersion = schemaVersion;
@@ -125,11 +126,12 @@ public class DeltaEvents {
/**
* Given Long timestamp convert to format YYYYMMdd-HH:mm:ss:SSS
+ *
* @param timestamp milliseconds since epoc
* @return long timestamp in format YYYYMMdd-HH:mm:ss:SSS
*/
private String getTimeStamp(long timestamp) {
- //SimpleDateFormat is not thread safe new instance needed
+ // SimpleDateFormat is not thread safe new instance needed
DateFormat df = new SimpleDateFormat("yyyyMMdd-HH:mm:ss:SSS");
return df.format(new Date(timestamp));
}
diff --git a/aai-core/src/main/java/org/onap/aai/util/delta/ObjectDelta.java b/aai-core/src/main/java/org/onap/aai/util/delta/ObjectDelta.java
index 5ba99aff..23476675 100644
--- a/aai-core/src/main/java/org/onap/aai/util/delta/ObjectDelta.java
+++ b/aai-core/src/main/java/org/onap/aai/util/delta/ObjectDelta.java
@@ -20,6 +20,8 @@
package org.onap.aai.util.delta;
+import com.google.gson.annotations.SerializedName;
+
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
@@ -27,8 +29,6 @@ import java.util.Map;
import org.apache.commons.lang3.builder.ToStringBuilder;
-import com.google.gson.annotations.SerializedName;
-
public class ObjectDelta {
@SerializedName("uri")
@@ -64,7 +64,6 @@ public class ObjectDelta {
relationshipDeltas.add(relationshipDelta);
}
-
public String getUri() {
return uri;
}
@@ -115,13 +114,8 @@ public class ObjectDelta {
@Override
public String toString() {
- return new ToStringBuilder(this)
- .append("uri", uri)
- .append("action", action)
- .append("sourceOfTruth", sourceOfTruth)
- .append("timestamp", timestamp)
- .append("propertyDeltas", propertyDeltas)
- .append("relationshipDeltas", relationshipDeltas)
- .toString();
+ return new ToStringBuilder(this).append("uri", uri).append("action", action)
+ .append("sourceOfTruth", sourceOfTruth).append("timestamp", timestamp)
+ .append("propertyDeltas", propertyDeltas).append("relationshipDeltas", relationshipDeltas).toString();
}
}
diff --git a/aai-core/src/main/java/org/onap/aai/util/delta/PropertyDelta.java b/aai-core/src/main/java/org/onap/aai/util/delta/PropertyDelta.java
index 3f4da75a..98296d35 100644
--- a/aai-core/src/main/java/org/onap/aai/util/delta/PropertyDelta.java
+++ b/aai-core/src/main/java/org/onap/aai/util/delta/PropertyDelta.java
@@ -17,12 +17,13 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
-package org.onap.aai.util.delta;
-import org.apache.commons.lang3.builder.ToStringBuilder;
+package org.onap.aai.util.delta;
import com.google.gson.annotations.SerializedName;
+import org.apache.commons.lang3.builder.ToStringBuilder;
+
public class PropertyDelta {
@SerializedName("action")
@@ -34,7 +35,6 @@ public class PropertyDelta {
@SerializedName("old-value")
private Object oldValue;
-
public PropertyDelta(DeltaAction action, Object value) {
this.action = action;
this.value = value;
@@ -71,10 +71,7 @@ public class PropertyDelta {
@Override
public String toString() {
- return new ToStringBuilder(this)
- .append("action", action)
- .append("value", value)
- .append("oldValue", oldValue)
- .toString();
+ return new ToStringBuilder(this).append("action", action).append("value", value).append("oldValue", oldValue)
+ .toString();
}
}
diff --git a/aai-core/src/main/java/org/onap/aai/util/delta/PropertyDeltaFactory.java b/aai-core/src/main/java/org/onap/aai/util/delta/PropertyDeltaFactory.java
index 366d6886..a6641c2c 100644
--- a/aai-core/src/main/java/org/onap/aai/util/delta/PropertyDeltaFactory.java
+++ b/aai-core/src/main/java/org/onap/aai/util/delta/PropertyDeltaFactory.java
@@ -23,12 +23,12 @@ package org.onap.aai.util.delta;
public class PropertyDeltaFactory {
public static PropertyDelta getDelta(DeltaAction action, Object value, Object oldValue) {
- //TODO handle if action is not UPDATE
+ // TODO handle if action is not UPDATE
return new PropertyDelta(action, value, oldValue);
}
public static PropertyDelta getDelta(DeltaAction action, Object value) {
- //TODO handle if action is UPDATE
+ // TODO handle if action is UPDATE
return new PropertyDelta(action, value);
}
}
diff --git a/aai-core/src/main/java/org/onap/aai/util/delta/RelationshipDelta.java b/aai-core/src/main/java/org/onap/aai/util/delta/RelationshipDelta.java
index 75349ea3..8d8f9c4c 100644
--- a/aai-core/src/main/java/org/onap/aai/util/delta/RelationshipDelta.java
+++ b/aai-core/src/main/java/org/onap/aai/util/delta/RelationshipDelta.java
@@ -20,13 +20,13 @@
package org.onap.aai.util.delta;
+import com.google.gson.annotations.SerializedName;
+
import java.util.HashMap;
import java.util.Map;
import org.apache.commons.lang3.builder.ToStringBuilder;
-import com.google.gson.annotations.SerializedName;
-
public class RelationshipDelta {
@SerializedName("action")
@@ -50,7 +50,8 @@ public class RelationshipDelta {
@SerializedName("props")
private Map<String, Object> props = new HashMap<>();
- public RelationshipDelta(DeltaAction action, String inVUUID, String outVUUID, String inVUri, String outVUri, String label) {
+ public RelationshipDelta(DeltaAction action, String inVUUID, String outVUUID, String inVUri, String outVUri,
+ String label) {
this.action = action;
this.inVUuid = inVUUID;
this.outVUuid = outVUUID;
@@ -121,14 +122,8 @@ public class RelationshipDelta {
@Override
public String toString() {
- return new ToStringBuilder(this)
- .append("action", action)
- .append("inVUuid", inVUuid)
- .append("outVUuid", outVUuid)
- .append("inVUri", inVUri)
- .append("outVUri", outVUri)
- .append("label", label)
- .append("props", props)
- .toString();
+ return new ToStringBuilder(this).append("action", action).append("inVUuid", inVUuid)
+ .append("outVUuid", outVUuid).append("inVUri", inVUri).append("outVUri", outVUri).append("label", label)
+ .append("props", props).toString();
}
}