summaryrefslogtreecommitdiffstats
path: root/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/graphinventory
diff options
context:
space:
mode:
Diffstat (limited to 'graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/graphinventory')
-rw-r--r--graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/graphinventory/EmptyStringToNullSerializer.java52
-rw-r--r--graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/graphinventory/Format.java45
-rw-r--r--graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/graphinventory/GraphInventoryClient.java67
-rw-r--r--graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/graphinventory/GraphInventoryCommonObjectMapperPatchProvider.java35
-rw-r--r--graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/graphinventory/GraphInventoryCommonObjectMapperProvider.java52
-rw-r--r--graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/graphinventory/GraphInventoryObjectBase.java9
-rw-r--r--graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/graphinventory/GraphInventoryObjectName.java30
-rw-r--r--graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/graphinventory/GraphInventoryObjectPlurals.java27
-rw-r--r--graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/graphinventory/GraphInventoryObjectType.java25
-rw-r--r--graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/graphinventory/GraphInventoryObjectUriPartial.java26
-rw-r--r--graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/graphinventory/GraphInventoryObjectUriTemplate.java26
-rw-r--r--graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/graphinventory/GraphInventoryPatchConverter.java83
-rw-r--r--graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/graphinventory/GraphInventoryQueryClient.java141
-rw-r--r--graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/graphinventory/GraphInventoryResourcesClient.java418
-rw-r--r--graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/graphinventory/GraphInventoryRestClient.java76
-rw-r--r--graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/graphinventory/GraphInventorySubgraphType.java37
-rw-r--r--graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/graphinventory/GraphInventoryTransactionClient.java256
-rw-r--r--graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/graphinventory/GraphInventoryVersion.java25
-rw-r--r--graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/graphinventory/TransactionBuilder.java32
-rw-r--r--graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/graphinventory/entities/DSLNodeBase.java88
-rw-r--r--graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/graphinventory/entities/DSLNodeKey.java75
-rw-r--r--graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/graphinventory/entities/DSLOutputNode.java8
-rw-r--r--graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/graphinventory/entities/DSLQuery.java41
-rw-r--r--graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/graphinventory/entities/DSLQueryBuilder.java158
-rw-r--r--graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/graphinventory/entities/DSLStartNode.java19
-rw-r--r--graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/graphinventory/entities/DSLTraversal.java33
-rw-r--r--graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/graphinventory/entities/GraphInventoryEdgeLabel.java28
-rw-r--r--graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/graphinventory/entities/GraphInventoryRelationships.java133
-rw-r--r--graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/graphinventory/entities/GraphInventoryResultWrapper.java125
-rw-r--r--graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/graphinventory/entities/Id.java25
-rw-r--r--graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/graphinventory/entities/Node.java5
-rw-r--r--graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/graphinventory/entities/Output.java7
-rw-r--r--graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/graphinventory/entities/Pathed.java25
-rw-r--r--graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/graphinventory/entities/Resource.java57
-rw-r--r--graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/graphinventory/entities/ResourceAndUrl.java61
-rw-r--r--graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/graphinventory/entities/Start.java7
-rw-r--r--graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/graphinventory/entities/TraversalBuilder.java17
-rw-r--r--graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/graphinventory/entities/__.java62
-rw-r--r--graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/graphinventory/entities/uri/Depth.java38
-rw-r--r--graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/graphinventory/entities/uri/GraphInventoryPluralResourceUri.java8
-rw-r--r--graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/graphinventory/entities/uri/GraphInventoryResourceUri.java31
-rw-r--r--graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/graphinventory/entities/uri/GraphInventorySingleResourceUri.java16
-rw-r--r--graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/graphinventory/entities/uri/GraphInventoryUri.java81
-rw-r--r--graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/graphinventory/entities/uri/HttpAwareUri.java32
-rw-r--r--graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/graphinventory/entities/uri/SimpleBaseUri.java237
-rw-r--r--graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/graphinventory/entities/uri/SimplePluralUri.java77
-rw-r--r--graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/graphinventory/entities/uri/SimpleUri.java83
-rw-r--r--graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/graphinventory/entities/uri/parsers/UriParser.java30
-rw-r--r--graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/graphinventory/entities/uri/parsers/UriParserSpringImpl.java63
-rw-r--r--graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/graphinventory/exceptions/BulkProcessFailed.java28
-rw-r--r--graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/graphinventory/exceptions/GraphInventoryMultipleItemsException.java13
-rw-r--r--graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/graphinventory/exceptions/GraphInventoryPatchDepthExceededException.java31
-rw-r--r--graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/graphinventory/exceptions/GraphInventoryPayloadException.java40
-rw-r--r--graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/graphinventory/exceptions/GraphInventoryUriComputationException.java34
-rw-r--r--graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/graphinventory/exceptions/GraphInventoryUriNotFoundException.java29
-rw-r--r--graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/graphinventory/exceptions/IncorrectNumberOfUriKeys.java31
56 files changed, 3338 insertions, 0 deletions
diff --git a/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/graphinventory/EmptyStringToNullSerializer.java b/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/graphinventory/EmptyStringToNullSerializer.java
new file mode 100644
index 0000000000..27309cb461
--- /dev/null
+++ b/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/graphinventory/EmptyStringToNullSerializer.java
@@ -0,0 +1,52 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2017 - 2018 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.aaiclient.client.graphinventory;
+
+import java.io.IOException;
+import com.fasterxml.jackson.core.JsonGenerator;
+import com.fasterxml.jackson.core.JsonProcessingException;
+import com.fasterxml.jackson.databind.SerializerProvider;
+import com.fasterxml.jackson.databind.ser.std.StdSerializer;
+
+public class EmptyStringToNullSerializer extends StdSerializer<String> {
+
+ private static final long serialVersionUID = 5367385969270400106L;
+
+ public EmptyStringToNullSerializer() {
+ this(null);
+ }
+
+ public EmptyStringToNullSerializer(Class<String> t) {
+ super(t);
+ }
+
+ @Override
+ public void serialize(String value, JsonGenerator gen, SerializerProvider serializers)
+ throws IOException, JsonProcessingException {
+
+ if ("".equals(value)) {
+ gen.writeNull();
+ } else {
+ gen.writeString(value);
+ }
+ }
+
+}
diff --git a/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/graphinventory/Format.java b/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/graphinventory/Format.java
new file mode 100644
index 0000000000..37f7893f26
--- /dev/null
+++ b/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/graphinventory/Format.java
@@ -0,0 +1,45 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2017 - 2018 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.aaiclient.client.graphinventory;
+
+public enum Format {
+
+ RESOURCE("resource"),
+ RESOURCE_AND_URL("resource_and_url"),
+ SIMPLE("simple"),
+ RAW("raw"),
+ CONSOLE("console"),
+ PATHED("pathed"),
+ GRAPHSON("graphson"),
+ ID("id"),
+ COUNT("count");
+
+ private final String name;
+
+ private Format(String name) {
+ this.name = name;
+ }
+
+ @Override
+ public String toString() {
+ return name;
+ }
+}
diff --git a/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/graphinventory/GraphInventoryClient.java b/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/graphinventory/GraphInventoryClient.java
new file mode 100644
index 0000000000..a2bb8bc141
--- /dev/null
+++ b/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/graphinventory/GraphInventoryClient.java
@@ -0,0 +1,67 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2017 - 2018 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.aaiclient.client.graphinventory;
+
+import java.net.URI;
+import org.onap.so.client.RestClient;
+import org.onap.so.client.RestProperties;
+import org.onap.so.client.RestPropertiesLoader;
+import org.onap.aaiclient.client.graphinventory.entities.uri.GraphInventoryUri;
+import org.onap.aaiclient.client.graphinventory.entities.uri.HttpAwareUri;
+
+public abstract class GraphInventoryClient {
+
+ private RestProperties props;
+
+ protected GraphInventoryClient(Class<? extends RestProperties> propertiesClass) {
+
+ RestProperties props = RestPropertiesLoader.getInstance().getNewImpl(propertiesClass);
+ this.props = props;
+ }
+
+ protected abstract URI constructPath(URI uri);
+
+ protected abstract RestClient createClient(URI uri);
+
+ public RestClient createClient(GraphInventoryUri uri) {
+ final URI result;
+ if (uri instanceof HttpAwareUri) {
+ result = ((HttpAwareUri) uri).locateAndBuild();
+ } else {
+ result = uri.build();
+ }
+
+ return createClient(result);
+
+ }
+
+
+ public <T extends RestProperties> T getRestProperties() {
+ if (props == null) {
+ throw new IllegalStateException("No RestProperty implementation found on classpath");
+ }
+ return (T) props;
+ }
+
+ public abstract GraphInventoryVersion getVersion();
+
+ public abstract String getGraphDBName();
+}
diff --git a/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/graphinventory/GraphInventoryCommonObjectMapperPatchProvider.java b/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/graphinventory/GraphInventoryCommonObjectMapperPatchProvider.java
new file mode 100644
index 0000000000..c1b70dc687
--- /dev/null
+++ b/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/graphinventory/GraphInventoryCommonObjectMapperPatchProvider.java
@@ -0,0 +1,35 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2017 - 2018 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.aaiclient.client.graphinventory;
+
+import com.fasterxml.jackson.databind.module.SimpleModule;
+
+public class GraphInventoryCommonObjectMapperPatchProvider extends GraphInventoryCommonObjectMapperProvider {
+
+
+ public GraphInventoryCommonObjectMapperPatchProvider() {
+ super();
+ EmptyStringToNullSerializer sp = new EmptyStringToNullSerializer();
+ SimpleModule emptyStringModule = new SimpleModule();
+ emptyStringModule.addSerializer(String.class, sp);
+ mapper.registerModule(emptyStringModule);
+ }
+}
diff --git a/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/graphinventory/GraphInventoryCommonObjectMapperProvider.java b/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/graphinventory/GraphInventoryCommonObjectMapperProvider.java
new file mode 100644
index 0000000000..ba12bb8906
--- /dev/null
+++ b/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/graphinventory/GraphInventoryCommonObjectMapperProvider.java
@@ -0,0 +1,52 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.aaiclient.client.graphinventory;
+
+import org.onap.so.client.policy.CommonObjectMapperProvider;
+import com.fasterxml.jackson.annotation.JsonInclude;
+import com.fasterxml.jackson.annotation.JsonInclude.Include;
+import com.fasterxml.jackson.databind.AnnotationIntrospector;
+import com.fasterxml.jackson.databind.DeserializationFeature;
+import com.fasterxml.jackson.databind.MapperFeature;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.fasterxml.jackson.databind.SerializationFeature;
+import com.fasterxml.jackson.databind.introspect.JacksonAnnotationIntrospector;
+import com.fasterxml.jackson.databind.type.TypeFactory;
+import com.fasterxml.jackson.module.jaxb.JaxbAnnotationIntrospector;
+
+public class GraphInventoryCommonObjectMapperProvider extends CommonObjectMapperProvider {
+
+ public GraphInventoryCommonObjectMapperProvider() {
+ mapper = new ObjectMapper();
+ mapper.setSerializationInclusion(Include.NON_NULL);
+ mapper.setSerializationInclusion(JsonInclude.Include.NON_EMPTY);
+ mapper.enable(MapperFeature.USE_ANNOTATIONS);
+ mapper.configure(SerializationFeature.WRAP_ROOT_VALUE, false);
+ mapper.configure(SerializationFeature.FAIL_ON_EMPTY_BEANS, false);
+ mapper.configure(DeserializationFeature.UNWRAP_ROOT_VALUE, false);
+ mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
+ AnnotationIntrospector aiJaxb = new JaxbAnnotationIntrospector(TypeFactory.defaultInstance());
+ AnnotationIntrospector aiJackson = new JacksonAnnotationIntrospector();
+ // first Jaxb, second Jackson annotations
+ mapper.setAnnotationIntrospector(AnnotationIntrospector.pair(aiJaxb, aiJackson));
+ }
+
+}
diff --git a/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/graphinventory/GraphInventoryObjectBase.java b/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/graphinventory/GraphInventoryObjectBase.java
new file mode 100644
index 0000000000..959126bb91
--- /dev/null
+++ b/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/graphinventory/GraphInventoryObjectBase.java
@@ -0,0 +1,9 @@
+package org.onap.aaiclient.client.graphinventory;
+
+public interface GraphInventoryObjectBase
+ extends GraphInventoryObjectName, GraphInventoryObjectUriTemplate, GraphInventoryObjectUriPartial {
+
+ public default boolean passThrough() {
+ return false;
+ }
+}
diff --git a/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/graphinventory/GraphInventoryObjectName.java b/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/graphinventory/GraphInventoryObjectName.java
new file mode 100644
index 0000000000..c287ab6984
--- /dev/null
+++ b/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/graphinventory/GraphInventoryObjectName.java
@@ -0,0 +1,30 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.aaiclient.client.graphinventory;
+
+import com.google.common.base.CaseFormat;
+
+public interface GraphInventoryObjectName {
+
+ public String typeName();
+
+ public String typeName(CaseFormat format);
+}
diff --git a/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/graphinventory/GraphInventoryObjectPlurals.java b/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/graphinventory/GraphInventoryObjectPlurals.java
new file mode 100644
index 0000000000..3eb71b21c2
--- /dev/null
+++ b/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/graphinventory/GraphInventoryObjectPlurals.java
@@ -0,0 +1,27 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2017 - 2018 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.aaiclient.client.graphinventory;
+
+public interface GraphInventoryObjectPlurals extends GraphInventoryObjectBase {
+
+ public GraphInventoryObjectType getType();
+
+}
diff --git a/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/graphinventory/GraphInventoryObjectType.java b/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/graphinventory/GraphInventoryObjectType.java
new file mode 100644
index 0000000000..fcc21683c1
--- /dev/null
+++ b/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/graphinventory/GraphInventoryObjectType.java
@@ -0,0 +1,25 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2017 - 2018 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.aaiclient.client.graphinventory;
+
+public interface GraphInventoryObjectType extends GraphInventoryObjectBase {
+
+}
diff --git a/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/graphinventory/GraphInventoryObjectUriPartial.java b/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/graphinventory/GraphInventoryObjectUriPartial.java
new file mode 100644
index 0000000000..d9d49cebd7
--- /dev/null
+++ b/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/graphinventory/GraphInventoryObjectUriPartial.java
@@ -0,0 +1,26 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.aaiclient.client.graphinventory;
+
+public interface GraphInventoryObjectUriPartial {
+
+ public String partialUri();
+}
diff --git a/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/graphinventory/GraphInventoryObjectUriTemplate.java b/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/graphinventory/GraphInventoryObjectUriTemplate.java
new file mode 100644
index 0000000000..7c100a710b
--- /dev/null
+++ b/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/graphinventory/GraphInventoryObjectUriTemplate.java
@@ -0,0 +1,26 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.aaiclient.client.graphinventory;
+
+public interface GraphInventoryObjectUriTemplate {
+
+ public String uriTemplate();
+}
diff --git a/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/graphinventory/GraphInventoryPatchConverter.java b/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/graphinventory/GraphInventoryPatchConverter.java
new file mode 100644
index 0000000000..e626ec5492
--- /dev/null
+++ b/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/graphinventory/GraphInventoryPatchConverter.java
@@ -0,0 +1,83 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2017 - 2018 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.aaiclient.client.graphinventory;
+
+import java.util.List;
+import java.util.Map;
+import java.util.regex.Pattern;
+import org.onap.aaiclient.client.aai.AAICommonObjectMapperPatchProvider;
+import org.onap.aaiclient.client.aai.AAICommonObjectMapperProvider;
+import org.onap.aaiclient.client.graphinventory.exceptions.GraphInventoryPatchDepthExceededException;
+import org.onap.so.jsonpath.JsonPathUtil;
+import com.fasterxml.jackson.core.JsonProcessingException;
+
+public class GraphInventoryPatchConverter {
+
+ private static final AAICommonObjectMapperProvider standardProvider = new AAICommonObjectMapperProvider();
+ private static final AAICommonObjectMapperPatchProvider patchProvider = new AAICommonObjectMapperPatchProvider();
+ private static final Pattern LOCATE_COMPLEX_OBJECT =
+ Pattern.compile("^((?!relationship-list).)+?\\['[^\\[\\]]+?'\\]$");
+
+
+ public String convertPatchFormat(Object obj) {
+ return validatePatchObject(marshallObjectToPatchFormat(obj));
+ }
+
+ public String validatePatchObject(String payload) {
+ if (hasComplexObject(payload)) {
+ throw new GraphInventoryPatchDepthExceededException(payload);
+ }
+
+ return payload;
+ }
+
+ /**
+ * validates client side that json does not include any complex objects relationship-list is omitted from this
+ * validation
+ */
+ protected boolean hasComplexObject(String json) {
+ if (json.isEmpty()) {
+ return false;
+ }
+ String complex = "$.*.*";
+ String array = "$.*.*.*";
+ List<String> result = JsonPathUtil.getInstance().getPathList(json, complex);
+ List<String> result2 = JsonPathUtil.getInstance().getPathList(json, array);
+
+ result.addAll(result2);
+ return result.stream().anyMatch(item -> LOCATE_COMPLEX_OBJECT.matcher(item).find());
+ }
+
+ protected String marshallObjectToPatchFormat(Object obj) {
+ Object value = obj;
+ try {
+ if (!(obj instanceof Map || obj instanceof String)) {
+ value = patchProvider.getMapper().writeValueAsString(obj);
+ } else if (obj instanceof Map) {
+ value = standardProvider.getMapper().writeValueAsString(obj);
+ }
+ } catch (JsonProcessingException e) {
+ value = "{}";
+ }
+
+ return (String) value;
+ }
+}
diff --git a/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/graphinventory/GraphInventoryQueryClient.java b/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/graphinventory/GraphInventoryQueryClient.java
new file mode 100644
index 0000000000..8aa03e2920
--- /dev/null
+++ b/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/graphinventory/GraphInventoryQueryClient.java
@@ -0,0 +1,141 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.aaiclient.client.graphinventory;
+
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+import java.util.Map.Entry;
+import java.util.Optional;
+import java.util.stream.Collectors;
+import javax.ws.rs.core.GenericType;
+import org.onap.aaiclient.client.aai.entities.Results;
+import org.onap.aaiclient.client.graphinventory.entities.GraphInventoryResultWrapper;
+import org.onap.aaiclient.client.graphinventory.entities.Pathed;
+import org.onap.aaiclient.client.graphinventory.entities.ResourceAndUrl;
+import org.onap.aaiclient.client.graphinventory.entities.uri.GraphInventoryUri;
+import com.fasterxml.jackson.annotation.JsonTypeInfo.Id;
+import com.fasterxml.jackson.core.type.TypeReference;
+import com.fasterxml.jackson.databind.ObjectMapper;
+
+public abstract class GraphInventoryQueryClient<S, I, Wrapper extends GraphInventoryResultWrapper<?>, Type extends GraphInventoryObjectType> {
+
+ private Optional<String> depth = Optional.empty();
+ private boolean nodesOnly = false;
+ private Optional<GraphInventorySubgraphType> subgraph = Optional.empty();
+ private GraphInventoryClient client;
+ private GraphInventoryCommonObjectMapperProvider mapperProvider = new GraphInventoryCommonObjectMapperProvider();
+
+ public GraphInventoryQueryClient(GraphInventoryClient client) {
+ this.client = client;
+ }
+
+ protected abstract GraphInventoryUri getQueryUri();
+
+ public String query(Format format, I query) {
+ return client.createClient(setupQueryParams(getQueryUri().queryParam("format", format.toString()))).put(query,
+ String.class);
+ }
+
+ protected <R> List<R> querySingleType(Format format, I query, Class<R> clazz) {
+ return client.createClient(setupQueryParams(getQueryUri().queryParam("format", format.toString())))
+ .put(query, new GenericType<Results<Object>>() {}).getResult().stream().map(item -> {
+ try {
+ return mapperProvider.getMapper().readValue(mapperProvider.getMapper().writeValueAsString(item),
+ clazz);
+ } catch (IOException e) {
+ throw new IllegalArgumentException("could not map values from json", e);
+ }
+ }).collect(Collectors.toList());
+ }
+
+ public List<Pathed> queryPathed(I query) {
+ return querySingleType(Format.PATHED, query, Pathed.class);
+ }
+
+ public List<Id> queryId(I query) {
+ return querySingleType(Format.ID, query, Id.class);
+ }
+
+ public <R> List<R> querySingleResource(I query, Class<R> clazz) {
+ try {
+ return getResourceAndUrl(query).stream().map(item -> item.getWrapper().asBean(clazz).get())
+ .collect(Collectors.toList());
+ } catch (IOException e) {
+ throw new IllegalArgumentException("could not map values from json", e);
+ }
+ }
+
+ public List<ResourceAndUrl<Wrapper>> getResourceAndUrl(I query) throws IOException {
+ List<ResourceAndUrl<Wrapper>> result = new ArrayList<>();
+ ObjectMapper mapper = mapperProvider.getMapper();
+ Results<Map<String, Object>> resultsFromJson = mapper.readValue(query(Format.RESOURCE_AND_URL, query),
+ new TypeReference<Results<Map<String, Object>>>() {});
+ for (Map<String, Object> m : resultsFromJson.getResult()) {
+ for (Entry<String, Object> entrySet : m.entrySet()) {
+ if (!entrySet.getKey().equals("url")) {
+ String url = (String) m.get("url");
+ String stringJson = mapper.writeValueAsString(entrySet.getValue());
+ result.add(
+ new ResourceAndUrl<Wrapper>(url, createType(entrySet.getKey()), createWrapper(stringJson)));
+ }
+ }
+ }
+
+ return result;
+ }
+
+ public abstract Wrapper createWrapper(String json);
+
+ public abstract Type createType(String name);
+
+ public S depth(String depth) {
+ this.depth = Optional.of(depth);
+ return (S) this;
+ }
+
+ public S nodesOnly() {
+ this.nodesOnly = true;
+ return (S) this;
+ }
+
+ public S subgraph(GraphInventorySubgraphType type) {
+
+ subgraph = Optional.of(type);
+
+ return (S) this;
+ }
+
+ protected GraphInventoryUri setupQueryParams(GraphInventoryUri uri) {
+ GraphInventoryUri clone = uri.clone();
+ if (this.depth.isPresent()) {
+ clone.queryParam("depth", depth.get());
+ }
+ if (this.nodesOnly) {
+ clone.queryParam("nodesOnly", "");
+ }
+ if (this.subgraph.isPresent()) {
+ clone.queryParam("subgraph", this.subgraph.get().toString());
+ }
+ return clone;
+ }
+}
diff --git a/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/graphinventory/GraphInventoryResourcesClient.java b/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/graphinventory/GraphInventoryResourcesClient.java
new file mode 100644
index 0000000000..c564c5d5cb
--- /dev/null
+++ b/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/graphinventory/GraphInventoryResourcesClient.java
@@ -0,0 +1,418 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2017 - 2019 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.aaiclient.client.graphinventory;
+
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+import java.lang.reflect.ParameterizedType;
+import java.lang.reflect.Type;
+import java.util.Arrays;
+import java.util.List;
+import java.util.Map;
+import java.util.Optional;
+import javax.ws.rs.NotFoundException;
+import javax.ws.rs.core.GenericType;
+import javax.ws.rs.core.Response;
+import javax.ws.rs.core.Response.Status;
+import org.onap.aai.domain.yang.Relationship;
+import org.onap.so.client.RestClient;
+import org.onap.so.client.RestProperties;
+import org.onap.aaiclient.client.graphinventory.entities.GraphInventoryEdgeLabel;
+import org.onap.aaiclient.client.graphinventory.entities.GraphInventoryResultWrapper;
+import org.onap.aaiclient.client.graphinventory.entities.uri.GraphInventoryPluralResourceUri;
+import org.onap.aaiclient.client.graphinventory.entities.uri.GraphInventoryResourceUri;
+import org.onap.aaiclient.client.graphinventory.entities.uri.GraphInventorySingleResourceUri;
+import org.onap.aaiclient.client.graphinventory.entities.uri.HttpAwareUri;
+import org.onap.aaiclient.client.graphinventory.exceptions.GraphInventoryMultipleItemsException;
+
+public abstract class GraphInventoryResourcesClient<Self, Uri extends GraphInventoryResourceUri<?, ?>, SingleUri extends GraphInventorySingleResourceUri<?, ?, ?, ?>, PluralUri extends GraphInventoryPluralResourceUri<?, ?>, EdgeLabel extends GraphInventoryEdgeLabel, Wrapper extends GraphInventoryResultWrapper, TransactionalClient, SingleTransactionClient> {
+
+ protected GraphInventoryClient client;
+
+ protected GraphInventoryResourcesClient(GraphInventoryClient client) {
+ this.client = client;
+ }
+
+ /**
+ * creates a new object in GraphInventory
+ *
+ * @param obj - can be any object which will marshal into a valid GraphInventory payload
+ * @param uri
+ * @return
+ */
+ public void create(SingleUri uri, Object obj) {
+ RestClient giRC = client.createClient(uri);
+ giRC.put(obj);
+ }
+
+ /**
+ * creates a new object in GraphInventory with no payload body
+ *
+ * @param uri
+ * @return
+ */
+ public void createEmpty(SingleUri uri) {
+ RestClient giRC = client.createClient(uri);
+ giRC.put("");
+ }
+
+ /**
+ * returns false if the object does not exist in GraphInventory
+ *
+ * @param uri
+ * @return
+ */
+ public boolean exists(Uri uri) {
+ GraphInventoryResourceUri<?, ?> forceMinimal = (Uri) uri.clone();
+ forceMinimal.format(Format.COUNT);
+ forceMinimal.limit(1);
+ try {
+ RestClient giRC = client.createClient(forceMinimal);
+
+ return giRC.get().getStatus() == Status.OK.getStatusCode();
+ } catch (NotFoundException e) {
+ return false;
+ }
+ }
+
+ /**
+ * Adds a relationship between two objects in GraphInventory
+ *
+ * @param uriA
+ * @param uriB
+ * @return
+ */
+ public void connect(SingleUri uriA, SingleUri uriB) {
+ GraphInventorySingleResourceUri<?, ?, ?, ?> uriAClone = (SingleUri) uriA.clone();
+ RestClient giRC = client.createClient(uriAClone.relationshipAPI());
+ giRC.put(this.buildRelationship(uriB));
+ }
+
+ /**
+ * Adds a relationship between two objects in GraphInventory with a given edge label
+ *
+ * @param uriA
+ * @param uriB
+ * @param edge label
+ * @return
+ */
+ public void connect(SingleUri uriA, SingleUri uriB, EdgeLabel label) {
+ GraphInventorySingleResourceUri<?, ?, ?, ?> uriAClone = (SingleUri) uriA.clone();
+ RestClient giRC = client.createClient(uriAClone.relationshipAPI());
+ giRC.put(this.buildRelationship(uriB, label));
+ }
+
+ /**
+ * Removes relationship from two objects in GraphInventory
+ *
+ * @param uriA
+ * @param uriB
+ * @return
+ */
+ public void disconnect(SingleUri uriA, SingleUri uriB) {
+ GraphInventorySingleResourceUri<?, ?, ?, ?> uriAClone = (SingleUri) uriA.clone();
+ RestClient giRC = client.createClient(uriAClone.relationshipAPI());
+ giRC.delete(this.buildRelationship(uriB));
+ }
+
+ /**
+ * Deletes object from GraphInventory. Automatically handles resource-version.
+ *
+ * @param uri
+ * @return
+ */
+ public void delete(SingleUri uri) {
+ GraphInventorySingleResourceUri<?, ?, ?, ?> clone = (SingleUri) uri.clone();
+ RestClient giRC = client.createClient(clone);
+ Map<String, Object> result = giRC.get(new GenericType<Map<String, Object>>() {}).orElseThrow(
+ () -> new NotFoundException(clone.build() + " does not exist in " + client.getGraphDBName()));
+ String resourceVersion = (String) result.get("resource-version");
+ giRC = client.createClient(clone.resourceVersion(resourceVersion));
+ giRC.delete();
+ }
+
+ /**
+ * @param obj - can be any object which will marshal into a valid GraphInventory payload
+ * @param uri
+ * @return
+ */
+ public void update(SingleUri uri, Object obj) {
+ RestClient giRC = client.createClient(uri);
+ giRC.patch(obj);
+ }
+
+ /**
+ * Retrieves an object from GraphInventory and unmarshalls it into the Class specified
+ *
+ * @param clazz
+ * @param uri
+ * @return
+ */
+ public <T> Optional<T> get(Class<T> clazz, Uri uri) {
+ try {
+ return client.createClient(uri).get(clazz);
+ } catch (NotFoundException e) {
+ if (this.getRestProperties().mapNotFoundToEmpty()) {
+ return Optional.empty();
+ } else {
+ throw e;
+ }
+ }
+ }
+
+ /**
+ * Retrieves an object from GraphInventory and returns complete response
+ *
+ * @param uri
+ * @return
+ */
+ public Response getFullResponse(Uri uri) {
+ try {
+ return client.createClient(uri).get();
+ } catch (NotFoundException e) {
+ if (this.getRestProperties().mapNotFoundToEmpty()) {
+ return e.getResponse();
+ } else {
+ throw e;
+ }
+ }
+ }
+
+ /**
+ * Retrieves an object from GraphInventory and automatically unmarshalls it into a Map or List
+ *
+ * @param resultClass
+ * @param uri
+ * @return
+ */
+ public <T> Optional<T> get(GenericType<T> resultClass, Uri uri) {
+ try {
+ return client.createClient(uri).get(resultClass);
+ } catch (NotFoundException e) {
+ if (this.getRestProperties().mapNotFoundToEmpty()) {
+ return Optional.empty();
+ } else {
+ throw e;
+ }
+ }
+ }
+
+ public <T, R> Optional<R> getOne(Class<T> pluralClass, Class<R> resultClass, PluralUri uri) {
+ Optional<List<R>> result = unwrapPlural(pluralClass, resultClass, uri);
+
+ if (result.isPresent()) {
+ if (result.get().size() == 1) {
+ return Optional.of(result.get().get(0));
+ } else {
+ throw new GraphInventoryMultipleItemsException(result.get().size(), uri);
+ }
+ }
+
+ return Optional.empty();
+ }
+
+ public <T, R> Optional<R> getFirst(Class<T> pluralClass, Class<R> resultClass, PluralUri uri) {
+ Optional<List<R>> result = unwrapPlural(pluralClass, resultClass, uri);
+
+ if (result.isPresent() && !result.get().isEmpty()) {
+ return Optional.of(result.get().get(0));
+ }
+
+ return Optional.empty();
+ }
+
+ public <T, R> Optional<Wrapper> getFirstWrapper(Class<T> pluralClass, Class<R> resultClass, PluralUri uri) {
+
+ Optional<R> result = getFirst(pluralClass, resultClass, uri);
+ if (result.isPresent()) {
+ return Optional.of(this.createWrapper(result.get()));
+ } else {
+ return Optional.empty();
+ }
+ }
+
+ public <T, R> Optional<Wrapper> getOneWrapper(Class<T> pluralClass, Class<R> resultClass, PluralUri uri) {
+
+ Optional<R> result = getOne(pluralClass, resultClass, uri);
+ if (result.isPresent()) {
+ return Optional.of(this.createWrapper(result.get()));
+ } else {
+ return Optional.empty();
+ }
+ }
+
+ protected <T, R> Optional<List<R>> unwrapPlural(Class<T> pluralClass, Class<R> resultClass, PluralUri uri) {
+ try {
+ PluralUri clone = (PluralUri) uri.clone().limit(1);
+ Optional<T> obj = client.createClient(clone).get(pluralClass);
+ if (obj.isPresent()) {
+ Optional<Method> listMethod = Arrays.stream(obj.get().getClass().getMethods()).filter(method -> {
+
+ Type returnType = method.getGenericReturnType();
+ if (returnType instanceof ParameterizedType) {
+ Type[] types = ((ParameterizedType) returnType).getActualTypeArguments();
+ if (types != null && types[0] instanceof Class) {
+ Class<?> listClass = (Class<?>) types[0];
+ return resultClass.equals(listClass);
+ }
+ }
+
+ return false;
+ }).findFirst();
+ if (listMethod.isPresent()) {
+ try {
+ return Optional.of((List<R>) listMethod.get().invoke(obj.get()));
+
+ } catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException e) {
+ throw new RuntimeException(e);
+ }
+ }
+ }
+ return Optional.empty();
+
+ } catch (NotFoundException e) {
+ if (this.getRestProperties().mapNotFoundToEmpty()) {
+ return Optional.empty();
+ } else {
+ throw e;
+ }
+ }
+ }
+
+ /**
+ * Retrieves an object from GraphInventory wrapped in a helper class which offer additional features
+ *
+ * @param uri
+ * @return
+ */
+ public Wrapper get(Uri uri) {
+ String json;
+ try {
+ json = client.createClient(uri).get(String.class).orElse(null);
+ } catch (NotFoundException e) {
+ if (this.getRestProperties().mapNotFoundToEmpty()) {
+ json = null;
+ } else {
+ throw e;
+ }
+ }
+ return this.createWrapper(json);
+ }
+
+ /**
+ * Retrieves an object from GraphInventory wrapped in a helper class which offer additional features If the object
+ * cannot be found in GraphInventory the method will throw the runtime exception included as an argument
+ *
+ * @param uri
+ * @return
+ */
+ public Wrapper get(Uri uri, Class<? extends RuntimeException> c) {
+ String json;
+ try {
+ json = client.createClient(uri).get(String.class).orElseThrow(() -> createException(c,
+ uri.build() + " not found in " + client.getGraphDBName(), Optional.empty()));
+ } catch (NotFoundException e) {
+ throw createException(c, "could not construct uri for use with " + client.getGraphDBName(), Optional.of(e));
+ }
+
+ return this.createWrapper(json);
+ }
+
+ private RuntimeException createException(Class<? extends RuntimeException> c, String message,
+ Optional<Throwable> t) {
+ RuntimeException e;
+ try {
+ if (t.isPresent()) {
+ e = c.getConstructor(String.class, Throwable.class).newInstance(message, t.get());
+ } else {
+ e = c.getConstructor(String.class).newInstance(message);
+ }
+ } catch (InstantiationException | IllegalAccessException | IllegalArgumentException | InvocationTargetException
+ | NoSuchMethodException | SecurityException e1) {
+ throw new IllegalArgumentException("could not create instance for " + c.getName());
+ }
+
+ return e;
+ }
+
+ /**
+ * Will automatically create the object if it does not exist
+ *
+ * @param obj - Optional object which serializes to a valid GraphInventory payload
+ * @param uri
+ * @return
+ */
+ public Self createIfNotExists(SingleUri uri, Optional<Object> obj) {
+ if (!this.exists((Uri) uri)) {
+ if (obj.isPresent()) {
+ this.create(uri, obj.get());
+ } else {
+ this.createEmpty(uri);
+ }
+
+ }
+ return (Self) this;
+ }
+
+ protected Relationship buildRelationship(SingleUri uri) {
+ return buildRelationship(uri, Optional.empty());
+ }
+
+ protected Relationship buildRelationship(SingleUri uri, GraphInventoryEdgeLabel label) {
+ return buildRelationship(uri, Optional.of(label));
+ }
+
+ protected Relationship buildRelationship(SingleUri uri, Optional<GraphInventoryEdgeLabel> label) {
+ final Relationship result = new Relationship();
+ if (uri instanceof HttpAwareUri) {
+ result.setRelatedLink(((HttpAwareUri) uri).locateAndBuild().toString());
+ } else {
+ result.setRelatedLink(uri.build().toString());
+ }
+ if (label.isPresent()) {
+ result.setRelationshipLabel(label.get().toString());
+ }
+ return result;
+ }
+
+ public abstract Wrapper createWrapper(String json);
+
+ public abstract Wrapper createWrapper(Object json);
+
+ /**
+ * Starts a transaction which encloses multiple GraphInventory mutations
+ *
+ * @return
+ */
+ public abstract TransactionalClient beginTransaction();
+
+ /**
+ * Starts a transaction groups multiple GraphInventory mutations
+ *
+ * @return
+ */
+ public abstract SingleTransactionClient beginSingleTransaction();
+
+ public <T extends RestProperties> T getRestProperties() {
+ return client.getRestProperties();
+ }
+
+}
diff --git a/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/graphinventory/GraphInventoryRestClient.java b/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/graphinventory/GraphInventoryRestClient.java
new file mode 100644
index 0000000000..c2422085aa
--- /dev/null
+++ b/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/graphinventory/GraphInventoryRestClient.java
@@ -0,0 +1,76 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.aaiclient.client.graphinventory;
+
+import java.net.URI;
+import java.util.Map;
+import java.util.Optional;
+import javax.ws.rs.core.Response;
+import org.onap.logging.filter.base.ONAPComponentsList;
+import org.onap.so.client.ResponseExceptionMapper;
+import org.onap.so.client.RestClientSSL;
+import org.onap.so.client.RestProperties;
+import org.onap.so.client.policy.CommonObjectMapperProvider;
+
+public abstract class GraphInventoryRestClient extends RestClientSSL {
+
+ protected static final GraphInventoryCommonObjectMapperProvider standardProvider =
+ new GraphInventoryCommonObjectMapperProvider();
+
+ protected final GraphInventoryPatchConverter patchConverter = new GraphInventoryPatchConverter();
+
+ protected GraphInventoryRestClient(RestProperties props, URI uri) {
+ super(props, Optional.of(uri));
+ }
+
+ @Override
+ public abstract ONAPComponentsList getTargetEntity();
+
+ @Override
+ protected abstract void initializeHeaderMap(Map<String, String> headerMap);
+
+ @Override
+ protected abstract Optional<ResponseExceptionMapper> addResponseExceptionMapper();
+
+ @Override
+ protected CommonObjectMapperProvider getCommonObjectMapperProvider() {
+ return standardProvider;
+ }
+
+ @Override
+ public Response patch(Object obj) {
+ return super.patch(convertToPatchFormat(obj));
+ }
+
+ @Override
+ public <T> T patch(Object obj, Class<T> resultClass) {
+ return super.patch(convertToPatchFormat(obj), resultClass);
+ }
+
+ protected GraphInventoryPatchConverter getPatchConverter() {
+ return this.patchConverter;
+ }
+
+ protected String convertToPatchFormat(Object obj) {
+ return getPatchConverter().convertPatchFormat(obj);
+ }
+
+}
diff --git a/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/graphinventory/GraphInventorySubgraphType.java b/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/graphinventory/GraphInventorySubgraphType.java
new file mode 100644
index 0000000000..8566b63ef9
--- /dev/null
+++ b/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/graphinventory/GraphInventorySubgraphType.java
@@ -0,0 +1,37 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.aaiclient.client.graphinventory;
+
+
+public enum GraphInventorySubgraphType {
+ STAR("star"), PRUNE("prune");
+
+ private final String name;
+
+ private GraphInventorySubgraphType(String name) {
+ this.name = name;
+ }
+
+ @Override
+ public String toString() {
+ return name;
+ }
+}
diff --git a/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/graphinventory/GraphInventoryTransactionClient.java b/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/graphinventory/GraphInventoryTransactionClient.java
new file mode 100644
index 0000000000..7f7822b900
--- /dev/null
+++ b/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/graphinventory/GraphInventoryTransactionClient.java
@@ -0,0 +1,256 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2017 - 2018 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.aaiclient.client.graphinventory;
+
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Optional;
+import javax.ws.rs.NotFoundException;
+import javax.ws.rs.core.GenericType;
+import org.onap.aai.domain.yang.Relationship;
+import org.onap.aaiclient.client.graphinventory.entities.GraphInventoryEdgeLabel;
+import org.onap.aaiclient.client.graphinventory.entities.uri.GraphInventoryResourceUri;
+import org.onap.aaiclient.client.graphinventory.entities.uri.GraphInventorySingleResourceUri;
+import org.onap.aaiclient.client.graphinventory.exceptions.BulkProcessFailed;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public abstract class GraphInventoryTransactionClient<Self, Uri extends GraphInventoryResourceUri<?, ?>, SingleUri extends GraphInventorySingleResourceUri<?, ?, ?, ?>, EdgeLabel extends GraphInventoryEdgeLabel> {
+
+ protected static Logger logger = LoggerFactory.getLogger(GraphInventoryTransactionClient.class);
+
+ protected int actionCount = 0;
+
+ protected final GraphInventoryPatchConverter patchConverter = new GraphInventoryPatchConverter();
+
+ protected GraphInventoryTransactionClient() {}
+
+ /**
+ * creates a new object in A&AI
+ *
+ * @param obj - can be any object which will marshal into a valid A&AI payload
+ * @param uri
+ * @return
+ */
+ public Self create(SingleUri uri, Object obj) {
+ this.put(uri.build().toString(), obj);
+ incrementActionAmount();
+ return (Self) this;
+ }
+
+ /**
+ * creates a new object in A&AI with no payload body
+ *
+ * @param uri
+ * @return
+ */
+ public Self createEmpty(SingleUri uri) {
+ this.put(uri.build().toString(), new HashMap<String, String>());
+ incrementActionAmount();
+ return (Self) this;
+ }
+
+ /**
+ * Will automatically create the object if it does not exist
+ *
+ * @param obj - Optional object which serializes to a valid GraphInventory payload
+ * @param uri
+ * @return
+ */
+ public Self createIfNotExists(SingleUri uri, Optional<Object> obj) {
+ if (!this.exists((Uri) uri)) {
+ if (obj.isPresent()) {
+ this.create(uri, obj.get());
+ } else {
+ this.createEmpty(uri);
+ }
+
+ }
+ return (Self) this;
+ }
+
+ /**
+ * Adds a relationship between two objects in A&AI
+ *
+ * @param uriA
+ * @param uriB
+ * @return
+ */
+ public Self connect(SingleUri uriA, SingleUri uriB) {
+ GraphInventorySingleResourceUri uriAClone = uriA.clone();
+ this.put(uriAClone.relationshipAPI().build().toString(), this.buildRelationship(uriB));
+ incrementActionAmount();
+ return (Self) this;
+ }
+
+ /**
+ * relationship between multiple objects in A&AI - connects A to all objects specified in list
+ *
+ * @param uriA
+ * @param uris
+ * @return
+ */
+ public Self connect(SingleUri uriA, List<SingleUri> uris) {
+ for (SingleUri uri : uris) {
+ this.connect(uriA, uri);
+ }
+ return (Self) this;
+ }
+
+ /**
+ * relationship between multiple objects in A&AI - connects A to all objects specified in list
+ *
+ * @param uriA
+ * @param uris
+ * @return
+ */
+ public Self connect(SingleUri uriA, SingleUri uriB, EdgeLabel label) {
+ GraphInventorySingleResourceUri uriAClone = uriA.clone();
+ this.put(uriAClone.relationshipAPI().build().toString(), this.buildRelationship(uriB, label));
+ return (Self) this;
+ }
+
+ /**
+ * relationship between multiple objects in A&AI - connects A to all objects specified in list
+ *
+ * @param uriA
+ * @param uris
+ * @return
+ */
+ public Self connect(SingleUri uriA, List<SingleUri> uris, EdgeLabel label) {
+ for (SingleUri uri : uris) {
+ this.connect(uriA, uri, label);
+ }
+ return (Self) this;
+ }
+
+ /**
+ * Removes relationship from two objects in A&AI
+ *
+ * @param uriA
+ * @param uriB
+ * @return
+ */
+ public Self disconnect(SingleUri uriA, SingleUri uriB) {
+ GraphInventorySingleResourceUri uriAClone = uriA.clone();
+ this.delete(uriAClone.relationshipAPI().build().toString(), this.buildRelationship(uriB));
+ incrementActionAmount();
+ return (Self) this;
+ }
+
+ /**
+ * Removes relationship from multiple objects - disconnects A from all objects specified in list
+ *
+ * @param uriA
+ * @param uris
+ * @return
+ */
+ public Self disconnect(SingleUri uriA, List<SingleUri> uris) {
+ for (SingleUri uri : uris) {
+ this.disconnect(uriA, uri);
+ }
+ return (Self) this;
+ }
+
+ /**
+ * Deletes object from A&AI. Automatically handles resource-version.
+ *
+ * @param uri
+ * @return
+ */
+ public Self delete(SingleUri uri) {
+ Map<String, Object> result = this.get(new GenericType<Map<String, Object>>() {}, (Uri) uri)
+ .orElseThrow(() -> new NotFoundException(uri.build() + " does not exist in " + this.getGraphDBName()));
+ String resourceVersion = (String) result.get("resource-version");
+ this.delete(uri.resourceVersion(resourceVersion).build().toString());
+ incrementActionAmount();
+ return (Self) this;
+ }
+
+ protected abstract <T> Optional<T> get(GenericType<T> genericType, Uri clone);
+
+ protected abstract boolean exists(Uri uri);
+
+ protected abstract String getGraphDBName();
+
+ protected abstract void put(String uri, Object body);
+
+ protected abstract void delete(String uri);
+
+ protected abstract void delete(String uri, Object obj);
+
+ protected abstract void patch(String uri, Object body);
+
+ /**
+ * @param obj - can be any object which will marshal into a valid A&AI payload
+ * @param uri
+ * @return
+ */
+ public Self update(Uri uri, Object obj) {
+
+ final String payload = getPatchConverter().convertPatchFormat(obj);
+ this.patch(uri.build().toString(), payload);
+ incrementActionAmount();
+ return (Self) this;
+ }
+
+ private void incrementActionAmount() {
+ actionCount++;
+ }
+
+ /**
+ * Executes all created transactions in A&AI
+ *
+ * @throws BulkProcessFailed
+ */
+ public abstract void execute() throws BulkProcessFailed;
+
+
+ /**
+ * Executes all created transactions in A&AI, with optional dry run flag
+ *
+ * @throws BulkProcessFailed
+ */
+ public abstract void execute(boolean dryrun) throws BulkProcessFailed;
+
+ private Relationship buildRelationship(SingleUri uri) {
+ return buildRelationship(uri, Optional.empty());
+ }
+
+ private Relationship buildRelationship(SingleUri uri, EdgeLabel label) {
+ return buildRelationship(uri, Optional.of(label));
+ }
+
+ private Relationship buildRelationship(SingleUri uri, Optional<EdgeLabel> label) {
+ final Relationship result = new Relationship();
+ result.setRelatedLink(uri.build().toString());
+ if (label.isPresent()) {
+ result.setRelationshipLabel(label.toString());
+ }
+ return result;
+ }
+
+ protected GraphInventoryPatchConverter getPatchConverter() {
+ return this.patchConverter;
+ }
+
+}
diff --git a/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/graphinventory/GraphInventoryVersion.java b/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/graphinventory/GraphInventoryVersion.java
new file mode 100644
index 0000000000..d7fba87397
--- /dev/null
+++ b/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/graphinventory/GraphInventoryVersion.java
@@ -0,0 +1,25 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2017 - 2018 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.aaiclient.client.graphinventory;
+
+public interface GraphInventoryVersion {
+
+}
diff --git a/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/graphinventory/TransactionBuilder.java b/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/graphinventory/TransactionBuilder.java
new file mode 100644
index 0000000000..6a0837890e
--- /dev/null
+++ b/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/graphinventory/TransactionBuilder.java
@@ -0,0 +1,32 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2017 - 2019 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.aaiclient.client.graphinventory;
+
+public interface TransactionBuilder {
+
+
+ void put(String uri, Object body);
+
+ void delete(String uri, Object body);
+
+ void patch(String uri, Object body);
+
+}
diff --git a/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/graphinventory/entities/DSLNodeBase.java b/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/graphinventory/entities/DSLNodeBase.java
new file mode 100644
index 0000000000..c071e24391
--- /dev/null
+++ b/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/graphinventory/entities/DSLNodeBase.java
@@ -0,0 +1,88 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2017 - 2019 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.aaiclient.client.graphinventory.entities;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+import org.onap.aaiclient.client.aai.entities.QueryStep;
+import org.onap.aaiclient.client.graphinventory.GraphInventoryObjectName;
+
+public abstract class DSLNodeBase<T extends DSLNodeBase<?>> implements QueryStep {
+
+ protected final String nodeName;
+ protected final List<DSLNodeKey> nodeKeys;
+ protected final StringBuilder query;
+ protected boolean output = false;
+
+ public DSLNodeBase() {
+ this.nodeName = "";
+ this.nodeKeys = new ArrayList<>();
+ this.query = new StringBuilder();
+
+ }
+
+ public DSLNodeBase(GraphInventoryObjectName name) {
+ this.nodeName = name.typeName();
+ this.nodeKeys = new ArrayList<>();
+ this.query = new StringBuilder();
+ query.append(nodeName);
+ }
+
+ public DSLNodeBase(GraphInventoryObjectName name, DSLNodeKey... key) {
+ this.nodeName = name.typeName();
+ this.nodeKeys = Arrays.asList(key);
+ this.query = new StringBuilder();
+ query.append(nodeName);
+ }
+
+ public DSLNodeBase(DSLNodeBase<?> copy) {
+ this.nodeName = copy.nodeName;
+ this.nodeKeys = copy.nodeKeys;
+ this.query = new StringBuilder(copy.query);
+ this.output = copy.output;
+ }
+
+ public DSLOutputNode output() {
+ this.output = true;
+
+ return new DSLOutputNode(this);
+ }
+
+ public T and(DSLNodeKey... key) {
+ this.nodeKeys.addAll(Arrays.asList(key));
+
+ return (T) this;
+ }
+
+ @Override
+ public String build() {
+ StringBuilder result = new StringBuilder(query);
+ if (output) {
+ result.append("*");
+ }
+ for (DSLNodeKey key : nodeKeys) {
+ result.append(key.build());
+ }
+
+ return result.toString();
+ }
+}
diff --git a/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/graphinventory/entities/DSLNodeKey.java b/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/graphinventory/entities/DSLNodeKey.java
new file mode 100644
index 0000000000..f7a9fddba0
--- /dev/null
+++ b/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/graphinventory/entities/DSLNodeKey.java
@@ -0,0 +1,75 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2017 - 2019 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.aaiclient.client.graphinventory.entities;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+import org.onap.aaiclient.client.aai.entities.QueryStep;
+import com.google.common.base.Joiner;
+
+
+public class DSLNodeKey implements QueryStep {
+
+ private boolean not = false;
+ private final StringBuilder query = new StringBuilder();
+ private final String keyName;
+ private final List<Object> values;
+
+ public DSLNodeKey(String keyName, Object... value) {
+
+ this.keyName = keyName;
+ this.values = Arrays.asList(value);
+ }
+
+ public DSLNodeKey not() {
+
+ this.not = true;
+ return this;
+ }
+
+ @Override
+ public String build() {
+ StringBuilder result = new StringBuilder(query);
+
+ if (not) {
+ result.append(" !");
+ }
+ result.append("('").append(keyName).append("', ");
+ List<Object> temp = new ArrayList<>();
+ for (Object item : values) {
+ if ("null".equals(item)) {
+ temp.add(String.format("' %s '", item));
+ } else if ("".equals(item)) {
+ temp.add("' '");
+ } else {
+ if (item instanceof String) {
+ temp.add(String.format("'%s'", item));
+ } else {
+ temp.add(item);
+ }
+ }
+ }
+ result.append(Joiner.on(", ").join(temp)).append(")");
+
+ return result.toString();
+ }
+}
diff --git a/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/graphinventory/entities/DSLOutputNode.java b/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/graphinventory/entities/DSLOutputNode.java
new file mode 100644
index 0000000000..2e329b7841
--- /dev/null
+++ b/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/graphinventory/entities/DSLOutputNode.java
@@ -0,0 +1,8 @@
+package org.onap.aaiclient.client.graphinventory.entities;
+
+public class DSLOutputNode extends DSLNodeBase<DSLOutputNode> implements Output {
+
+ public DSLOutputNode(DSLNodeBase<?> copy) {
+ super(copy);
+ }
+}
diff --git a/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/graphinventory/entities/DSLQuery.java b/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/graphinventory/entities/DSLQuery.java
new file mode 100644
index 0000000000..6d421913e3
--- /dev/null
+++ b/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/graphinventory/entities/DSLQuery.java
@@ -0,0 +1,41 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2017 - 2019 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.aaiclient.client.graphinventory.entities;
+
+import com.fasterxml.jackson.annotation.JsonInclude;
+
+@JsonInclude(JsonInclude.Include.NON_NULL)
+public class DSLQuery {
+
+ private String dsl;
+
+ public DSLQuery() {
+
+ }
+
+ public DSLQuery(DSLTraversal<? extends Output> dsl) {
+ this.dsl = dsl.get();
+ }
+
+ public String getDsl() {
+ return dsl;
+ }
+}
diff --git a/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/graphinventory/entities/DSLQueryBuilder.java b/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/graphinventory/entities/DSLQueryBuilder.java
new file mode 100644
index 0000000000..762203258a
--- /dev/null
+++ b/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/graphinventory/entities/DSLQueryBuilder.java
@@ -0,0 +1,158 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2017 - 2019 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.aaiclient.client.graphinventory.entities;
+
+import java.lang.reflect.Field;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+import java.util.stream.Collectors;
+import org.onap.aaiclient.client.aai.entities.QueryStep;
+import org.onap.aaiclient.client.graphinventory.GraphInventoryObjectName;
+import com.google.common.base.Joiner;
+
+public class DSLQueryBuilder<S, E> {
+
+ private List<QueryStep> steps = new ArrayList<>();
+ private String suffix = "";
+
+ protected DSLQueryBuilder() {
+
+ }
+
+ protected DSLQueryBuilder(QueryStep node) {
+ steps.add(node);
+ }
+
+ public <T> DSLQueryBuilder<S, DSLNodeBase<?>> node(DSLNodeBase<?> node) {
+ steps.add(node);
+
+ return (DSLQueryBuilder<S, DSLNodeBase<?>>) this;
+ }
+
+ public DSLQueryBuilder<S, Node> output() {
+ Object obj = steps.get(steps.size() - 1);
+ if (obj instanceof DSLNodeBase) {
+ ((DSLNodeBase) steps.get(steps.size() - 1)).output();
+ } else if (obj.getClass().getName().contains("$$Lambda$")) {
+ // process lambda expressions
+ for (Field f : obj.getClass().getDeclaredFields()) {
+ f.setAccessible(true);
+ Object o;
+ try {
+ o = f.get(obj);
+ if (o instanceof DSLQueryBuilder && ((DSLQueryBuilder) o).steps.get(0) instanceof DSLNodeBase) {
+ ((DSLNodeBase) ((DSLQueryBuilder) o).steps.get(0)).output();
+ }
+ } catch (IllegalArgumentException | IllegalAccessException e) {
+ }
+ f.setAccessible(false);
+ break;
+ }
+ }
+ return (DSLQueryBuilder<S, Node>) this;
+ }
+
+ @SafeVarargs
+ public final <E2> DSLQueryBuilder<S, E2> union(final DSLQueryBuilder<?, E2>... union) {
+
+ List<DSLQueryBuilder<?, ?>> unions = Arrays.asList(union);
+ steps.add(() -> {
+ StringBuilder query = new StringBuilder();
+
+ query.append("> [ ")
+ .append(Joiner.on(", ")
+ .join(unions.stream().map(item -> item.compile()).collect(Collectors.toList())))
+ .append(" ]");
+ return query.toString();
+ });
+
+ return (DSLQueryBuilder<S, E2>) this;
+ }
+
+ public DSLQueryBuilder<S, E> where(DSLQueryBuilder<?, ?> where) {
+
+ steps.add(() -> {
+ StringBuilder query = new StringBuilder();
+ query.append(where.compile()).append(")");
+ String result = query.toString();
+ if (!result.startsWith(">")) {
+ result = "> " + result;
+ }
+ return "(" + result;
+ });
+ return this;
+ }
+
+ public <E2> DSLQueryBuilder<S, E2> to(DSLQueryBuilder<?, E2> to) {
+ steps.add(() -> {
+ StringBuilder query = new StringBuilder();
+
+ query.append("> ").append(to.compile());
+ return query.toString();
+ });
+ return (DSLQueryBuilder<S, E2>) this;
+ }
+
+ public DSLQueryBuilder<S, E> to(GraphInventoryObjectName name) {
+ return (DSLQueryBuilder<S, E>) to(__.node(name));
+ }
+
+ public DSLQueryBuilder<S, E> to(GraphInventoryObjectName name, DSLNodeKey... key) {
+ return (DSLQueryBuilder<S, E>) to(__.node(name, key));
+ }
+
+ public DSLQueryBuilder<S, E> limit(int limit) {
+ suffix = " LIMIT " + limit;
+ return this;
+ }
+
+ public DSLTraversal<E> build() {
+ return new DSLTraversal<>(compile());
+ }
+
+ @Override
+ public String toString() {
+ return build().get();
+ }
+
+ @Override
+ public boolean equals(Object o) {
+ if (o != null) {
+ return o.toString().equals(toString());
+ }
+ return false;
+ }
+
+ @Override
+ public int hashCode() {
+
+ return compile().hashCode();
+ }
+
+ private String compile() {
+ return String.join(" ", steps.stream().map(item -> item.build()).collect(Collectors.toList())) + suffix;
+ }
+
+ protected QueryStep getFirst() {
+ return steps.get(0);
+ }
+}
diff --git a/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/graphinventory/entities/DSLStartNode.java b/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/graphinventory/entities/DSLStartNode.java
new file mode 100644
index 0000000000..8abe918a9a
--- /dev/null
+++ b/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/graphinventory/entities/DSLStartNode.java
@@ -0,0 +1,19 @@
+package org.onap.aaiclient.client.graphinventory.entities;
+
+import org.onap.aaiclient.client.graphinventory.GraphInventoryObjectName;
+
+public class DSLStartNode extends DSLNodeBase<DSLStartNode> implements Start {
+
+
+ public DSLStartNode() {
+ super();
+ }
+
+ public DSLStartNode(GraphInventoryObjectName name) {
+ super(name);
+ }
+
+ public DSLStartNode(GraphInventoryObjectName name, DSLNodeKey... key) {
+ super(name, key);
+ }
+}
diff --git a/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/graphinventory/entities/DSLTraversal.java b/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/graphinventory/entities/DSLTraversal.java
new file mode 100644
index 0000000000..3befbb7220
--- /dev/null
+++ b/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/graphinventory/entities/DSLTraversal.java
@@ -0,0 +1,33 @@
+package org.onap.aaiclient.client.graphinventory.entities;
+
+public class DSLTraversal<T> {
+
+ private final String traversal;
+
+ protected DSLTraversal(String traversal) {
+ this.traversal = traversal;
+ }
+
+ public String get() {
+ return traversal;
+ }
+
+ @Override
+ public String toString() {
+ return traversal;
+ }
+
+ @Override
+ public int hashCode() {
+ return traversal.hashCode();
+ }
+
+ @Override
+ public boolean equals(Object o) {
+ if (o != null) {
+ return this.toString().equals(o);
+ }
+ return false;
+ }
+
+}
diff --git a/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/graphinventory/entities/GraphInventoryEdgeLabel.java b/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/graphinventory/entities/GraphInventoryEdgeLabel.java
new file mode 100644
index 0000000000..e0e4a5ded5
--- /dev/null
+++ b/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/graphinventory/entities/GraphInventoryEdgeLabel.java
@@ -0,0 +1,28 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2017 - 2018 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.aaiclient.client.graphinventory.entities;
+
+public interface GraphInventoryEdgeLabel {
+
+
+ @Override
+ public String toString();
+}
diff --git a/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/graphinventory/entities/GraphInventoryRelationships.java b/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/graphinventory/entities/GraphInventoryRelationships.java
new file mode 100644
index 0000000000..7d960877b0
--- /dev/null
+++ b/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/graphinventory/entities/GraphInventoryRelationships.java
@@ -0,0 +1,133 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.aaiclient.client.graphinventory.entities;
+
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Optional;
+import java.util.function.Predicate;
+import org.onap.aaiclient.client.graphinventory.GraphInventoryCommonObjectMapperProvider;
+import org.onap.aaiclient.client.graphinventory.GraphInventoryObjectName;
+import org.onap.aaiclient.client.graphinventory.GraphInventoryObjectType;
+import org.onap.aaiclient.client.graphinventory.entities.uri.GraphInventorySingleResourceUri;
+import org.onap.so.jsonpath.JsonPathUtil;
+import com.fasterxml.jackson.core.type.TypeReference;
+import com.fasterxml.jackson.databind.ObjectMapper;
+
+public abstract class GraphInventoryRelationships<Wrapper extends GraphInventoryResultWrapper<?>, Uri extends GraphInventorySingleResourceUri<?, ?, ?, ?>, Type extends GraphInventoryObjectType> {
+
+ protected final ObjectMapper mapper;
+ protected Map<String, Object> map;
+ protected final String jsonBody;
+
+ public GraphInventoryRelationships(String json) {
+ this.jsonBody = json;
+ this.mapper = new GraphInventoryCommonObjectMapperProvider().getMapper();
+ try {
+ this.map = mapper.readValue(json, new TypeReference<Map<String, Object>>() {});
+ } catch (IOException e) {
+ this.map = new HashMap<>();
+ }
+ }
+
+ public List<Wrapper> getByType(GraphInventoryObjectName type) {
+
+ return this.getAll(Optional.of(type));
+ }
+
+ public List<Wrapper> getAll() {
+
+ return this.getAll(Optional.empty());
+ }
+
+
+ public List<String> getRelatedLinks() {
+ return this.getRelatedLinks(Optional.empty());
+ }
+
+ public List<String> getRelatedLinks(GraphInventoryObjectName type) {
+ return this.getRelatedLinks(Optional.of(type));
+ }
+
+ public List<Uri> getRelatedUris() {
+ return this.getRelatedUris(x -> true);
+ }
+
+ public List<Uri> getRelatedUris(GraphInventoryObjectName type) {
+ return this.getRelatedUris(x -> type.typeName().equals(x));
+ }
+
+ protected List<Uri> getRelatedUris(Predicate<String> p) {
+ List<Uri> result = new ArrayList<>();
+ if (map.containsKey("relationship")) {
+ List<Map<String, Object>> relationships = (List<Map<String, Object>>) map.get("relationship");
+ for (Map<String, Object> relationship : relationships) {
+ final String relatedTo = (String) relationship.get("related-to");
+ if (p.test(relatedTo)) {
+ Type type;
+ type = fromTypeName(relatedTo);
+ final String relatedLink = (String) relationship.get("related-link");
+
+ result.add(createUri(type, relatedLink));
+ }
+ }
+ }
+ return result;
+ }
+
+
+
+ protected List<Wrapper> getAll(final Optional<GraphInventoryObjectName> type) {
+ List<Uri> relatedLinks;
+ if (type.isPresent()) {
+ relatedLinks = this.getRelatedUris(type.get());
+ } else {
+ relatedLinks = this.getRelatedUris();
+ }
+ ArrayList<Wrapper> result = new ArrayList<>();
+ for (Uri link : relatedLinks) {
+ result.add(this.get(link));
+ }
+ return result;
+ }
+
+ protected abstract Wrapper get(Uri uri);
+
+ protected abstract Uri createUri(Type type, String relatedLink);
+
+ protected abstract Type fromTypeName(String name);
+
+ protected List<String> getRelatedLinks(Optional<GraphInventoryObjectName> type) {
+ String matcher = "";
+ if (type.isPresent()) {
+ matcher = "[?(@.related-to=='" + type.get().typeName() + "')]";
+ }
+ return JsonPathUtil.getInstance().locateResultList(this.jsonBody,
+ String.format("$.relationship%s.related-link", matcher));
+ }
+
+ public String getJson() {
+ return this.jsonBody;
+ }
+}
diff --git a/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/graphinventory/entities/GraphInventoryResultWrapper.java b/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/graphinventory/entities/GraphInventoryResultWrapper.java
new file mode 100644
index 0000000000..9e6572388b
--- /dev/null
+++ b/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/graphinventory/entities/GraphInventoryResultWrapper.java
@@ -0,0 +1,125 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Modifications Copyright (c) 2019 Samsung
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.aaiclient.client.graphinventory.entities;
+
+import java.io.IOException;
+import java.io.Serializable;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Optional;
+import org.onap.aaiclient.client.graphinventory.GraphInventoryCommonObjectMapperProvider;
+import org.onap.so.jsonpath.JsonPathUtil;
+import org.slf4j.Logger;
+import com.fasterxml.jackson.core.JsonProcessingException;
+import com.fasterxml.jackson.core.type.TypeReference;
+import com.fasterxml.jackson.databind.ObjectMapper;
+
+public abstract class GraphInventoryResultWrapper<R extends GraphInventoryRelationships<?, ?, ?>>
+ implements Serializable {
+
+ private static final long serialVersionUID = 5895841925807816727L;
+ protected final String jsonBody;
+ protected final ObjectMapper mapper;
+ private final transient Logger logger;
+
+ protected GraphInventoryResultWrapper(String json, Logger logger) {
+ this.jsonBody = json;
+ this.mapper = new GraphInventoryCommonObjectMapperProvider().getMapper();
+ this.logger = logger;
+ }
+
+ protected GraphInventoryResultWrapper(Object aaiObject, Logger logger) {
+ this.mapper = new GraphInventoryCommonObjectMapperProvider().getMapper();
+ this.jsonBody = mapObjectToString(aaiObject);
+ this.logger = logger;
+ }
+
+ protected String mapObjectToString(Object aaiObject) {
+ try {
+ return mapper.writeValueAsString(aaiObject);
+ } catch (JsonProcessingException e) {
+ logger.warn("could not parse object into json - defaulting to empty object");
+ return "{}";
+ }
+ }
+
+ public Optional<R> getRelationships() {
+ final String path = "$.relationship-list";
+ if (isEmpty()) {
+ return Optional.empty();
+ }
+ Optional<String> result = JsonPathUtil.getInstance().locateResult(jsonBody, path);
+ if (result.isPresent()) {
+ return Optional.of(createRelationships(result.get()));
+ } else {
+ return Optional.empty();
+ }
+ }
+
+ protected abstract R createRelationships(String json);
+
+ public String getJson() {
+ if (jsonBody == null) {
+ return "{}";
+ } else {
+ return jsonBody;
+ }
+ }
+
+ public Map<String, Object> asMap() {
+
+ return asBean(new TypeReference<Map<String, Object>>() {}).orElse(new HashMap<>());
+ }
+
+ public <T> Optional<T> asBean(Class<T> clazz) {
+ if (isEmpty()) {
+ return Optional.empty();
+ }
+ try {
+ return Optional.of(mapper.readValue(this.jsonBody, clazz));
+ } catch (IOException e) {
+ return Optional.empty();
+ }
+ }
+
+ public <T> Optional<T> asBean(TypeReference<T> reference) {
+ if (isEmpty()) {
+ return Optional.empty();
+ }
+ try {
+ return Optional.of(mapper.readValue(this.jsonBody, reference));
+ } catch (IOException e) {
+ return Optional.empty();
+ }
+ }
+
+ public boolean isEmpty() {
+ return jsonBody == null;
+ }
+
+ @Override
+ public String toString() {
+ return this.getJson();
+ }
+
+}
diff --git a/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/graphinventory/entities/Id.java b/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/graphinventory/entities/Id.java
new file mode 100644
index 0000000000..6eaaadd7fa
--- /dev/null
+++ b/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/graphinventory/entities/Id.java
@@ -0,0 +1,25 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2017 - 2019 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.aaiclient.client.graphinventory.entities;
+
+public class Id extends Resource {
+
+}
diff --git a/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/graphinventory/entities/Node.java b/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/graphinventory/entities/Node.java
new file mode 100644
index 0000000000..c893f66df0
--- /dev/null
+++ b/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/graphinventory/entities/Node.java
@@ -0,0 +1,5 @@
+package org.onap.aaiclient.client.graphinventory.entities;
+
+public interface Node extends Output {
+
+}
diff --git a/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/graphinventory/entities/Output.java b/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/graphinventory/entities/Output.java
new file mode 100644
index 0000000000..c8b98aa693
--- /dev/null
+++ b/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/graphinventory/entities/Output.java
@@ -0,0 +1,7 @@
+package org.onap.aaiclient.client.graphinventory.entities;
+
+import org.onap.aaiclient.client.aai.entities.QueryStep;
+
+public interface Output extends QueryStep {
+
+}
diff --git a/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/graphinventory/entities/Pathed.java b/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/graphinventory/entities/Pathed.java
new file mode 100644
index 0000000000..874dbc183b
--- /dev/null
+++ b/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/graphinventory/entities/Pathed.java
@@ -0,0 +1,25 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2017 - 2019 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.aaiclient.client.graphinventory.entities;
+
+public class Pathed extends Resource {
+
+}
diff --git a/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/graphinventory/entities/Resource.java b/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/graphinventory/entities/Resource.java
new file mode 100644
index 0000000000..b1e6104702
--- /dev/null
+++ b/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/graphinventory/entities/Resource.java
@@ -0,0 +1,57 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2017 - 2019 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.aaiclient.client.graphinventory.entities;
+
+import com.fasterxml.jackson.annotation.JsonInclude;
+import com.fasterxml.jackson.annotation.JsonProperty;
+import com.fasterxml.jackson.annotation.JsonPropertyOrder;
+
+@JsonInclude(JsonInclude.Include.NON_NULL)
+@JsonPropertyOrder({"resource-type", "resource-link"})
+public class Resource {
+
+ @JsonProperty("resource-type")
+ private String resourceType;
+ @JsonProperty("resource-link")
+ private String resourceLink;
+
+ @JsonProperty("resource-type")
+ public String getResourceType() {
+ return resourceType;
+ }
+
+ @JsonProperty("resource-type")
+ public void setResourceType(String resourceType) {
+ this.resourceType = resourceType;
+ }
+
+ @JsonProperty("resource-link")
+ public String getResourceLink() {
+ return resourceLink;
+ }
+
+ @JsonProperty("resource-link")
+ public void setResourceLink(String resourceLink) {
+ this.resourceLink = resourceLink;
+ }
+
+}
+
diff --git a/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/graphinventory/entities/ResourceAndUrl.java b/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/graphinventory/entities/ResourceAndUrl.java
new file mode 100644
index 0000000000..fa41ce4c0e
--- /dev/null
+++ b/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/graphinventory/entities/ResourceAndUrl.java
@@ -0,0 +1,61 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2017 - 2019 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.aaiclient.client.graphinventory.entities;
+
+import org.onap.aaiclient.client.graphinventory.GraphInventoryObjectType;
+
+public class ResourceAndUrl<Wrapper extends GraphInventoryResultWrapper> {
+
+ private String url;
+ private GraphInventoryObjectType type;
+ private Wrapper wrapper;
+
+ public ResourceAndUrl(String url, GraphInventoryObjectType type, Wrapper wrapper) {
+ this.url = url;
+ this.type = type;
+ this.wrapper = wrapper;
+ }
+
+ public String getUrl() {
+ return url;
+ }
+
+ public void setUrl(String url) {
+ this.url = url;
+ }
+
+ public Wrapper getWrapper() {
+ return wrapper;
+ }
+
+ public void setWrapper(Wrapper wrapper) {
+ this.wrapper = wrapper;
+ }
+
+ public GraphInventoryObjectType getType() {
+ return type;
+ }
+
+ public void setType(GraphInventoryObjectType type) {
+ this.type = type;
+ }
+
+}
diff --git a/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/graphinventory/entities/Start.java b/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/graphinventory/entities/Start.java
new file mode 100644
index 0000000000..8282beef23
--- /dev/null
+++ b/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/graphinventory/entities/Start.java
@@ -0,0 +1,7 @@
+package org.onap.aaiclient.client.graphinventory.entities;
+
+import org.onap.aaiclient.client.aai.entities.QueryStep;
+
+public interface Start extends QueryStep {
+
+}
diff --git a/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/graphinventory/entities/TraversalBuilder.java b/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/graphinventory/entities/TraversalBuilder.java
new file mode 100644
index 0000000000..14e9715074
--- /dev/null
+++ b/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/graphinventory/entities/TraversalBuilder.java
@@ -0,0 +1,17 @@
+package org.onap.aaiclient.client.graphinventory.entities;
+
+public class TraversalBuilder {
+
+
+ private TraversalBuilder() {
+
+ }
+
+ public static DSLQueryBuilder<Start, Start> fragment(Start node) {
+ return new DSLQueryBuilder<>(node);
+ }
+
+ public static DSLQueryBuilder<Output, Output> traversal(Output node) {
+ return new DSLQueryBuilder<>(node);
+ }
+}
diff --git a/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/graphinventory/entities/__.java b/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/graphinventory/entities/__.java
new file mode 100644
index 0000000000..6f7bcdc2c9
--- /dev/null
+++ b/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/graphinventory/entities/__.java
@@ -0,0 +1,62 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2017 - 2019 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.aaiclient.client.graphinventory.entities;
+
+import org.onap.aaiclient.client.graphinventory.GraphInventoryObjectName;
+
+public class __ {
+
+ protected __() {
+
+ }
+
+ public static <A> DSLQueryBuilder<A, A> identity() {
+ return new DSLQueryBuilder<>();
+ }
+
+ public static <A> DSLQueryBuilder<A, A> start(Start node) {
+ return new DSLQueryBuilder<>(node);
+ }
+
+ public static DSLQueryBuilder<DSLStartNode, DSLStartNode> node(GraphInventoryObjectName name) {
+
+ return __.<DSLStartNode>start(new DSLStartNode(name));
+ }
+
+ public static DSLQueryBuilder<DSLStartNode, DSLStartNode> node(GraphInventoryObjectName name, DSLNodeKey... key) {
+ return __.<DSLStartNode>start(new DSLStartNode(name, key));
+ }
+
+ public static DSLNodeKey key(String keyName, Object... value) {
+ return new DSLNodeKey(keyName, value);
+ }
+
+ @SafeVarargs
+ public static final <A, B> DSLQueryBuilder<A, B> union(final DSLQueryBuilder<?, B>... traversal) {
+
+ return __.<A>identity().union(traversal);
+ }
+
+ public static <A> DSLQueryBuilder<A, A> where(DSLQueryBuilder<A, A> traversal) {
+
+ return __.<A>identity().where(traversal);
+ }
+}
diff --git a/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/graphinventory/entities/uri/Depth.java b/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/graphinventory/entities/uri/Depth.java
new file mode 100644
index 0000000000..9f2ef42b50
--- /dev/null
+++ b/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/graphinventory/entities/uri/Depth.java
@@ -0,0 +1,38 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2017 - 2018 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.aaiclient.client.graphinventory.entities.uri;
+
+public enum Depth {
+ ZERO("0"), ONE("1"), TWO("2"), THREE("3"), FOUR("4"), FIVE("5"), SIX("6"), ALL("all");
+
+ private final String depth;
+
+ private Depth(String s) {
+
+ this.depth = s;
+ }
+
+
+ @Override
+ public String toString() {
+ return this.depth;
+ }
+}
diff --git a/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/graphinventory/entities/uri/GraphInventoryPluralResourceUri.java b/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/graphinventory/entities/uri/GraphInventoryPluralResourceUri.java
new file mode 100644
index 0000000000..8326c7b9df
--- /dev/null
+++ b/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/graphinventory/entities/uri/GraphInventoryPluralResourceUri.java
@@ -0,0 +1,8 @@
+package org.onap.aaiclient.client.graphinventory.entities.uri;
+
+import org.onap.aaiclient.client.graphinventory.GraphInventoryObjectBase;
+
+public interface GraphInventoryPluralResourceUri<T extends GraphInventoryResourceUri<?, ?>, OT extends GraphInventoryObjectBase>
+ extends GraphInventoryResourceUri<T, OT> {
+
+}
diff --git a/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/graphinventory/entities/uri/GraphInventoryResourceUri.java b/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/graphinventory/entities/uri/GraphInventoryResourceUri.java
new file mode 100644
index 0000000000..d70b2d74f1
--- /dev/null
+++ b/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/graphinventory/entities/uri/GraphInventoryResourceUri.java
@@ -0,0 +1,31 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2017 - 2018 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.aaiclient.client.graphinventory.entities.uri;
+
+import org.onap.aaiclient.client.graphinventory.Format;
+import org.onap.aaiclient.client.graphinventory.GraphInventoryObjectBase;
+
+public interface GraphInventoryResourceUri<T extends GraphInventoryResourceUri<?, ?>, OT extends GraphInventoryObjectBase>
+ extends GraphInventoryUri<T, OT> {
+
+ public T format(Format format);
+
+}
diff --git a/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/graphinventory/entities/uri/GraphInventorySingleResourceUri.java b/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/graphinventory/entities/uri/GraphInventorySingleResourceUri.java
new file mode 100644
index 0000000000..ac0e4a0c94
--- /dev/null
+++ b/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/graphinventory/entities/uri/GraphInventorySingleResourceUri.java
@@ -0,0 +1,16 @@
+package org.onap.aaiclient.client.graphinventory.entities.uri;
+
+import org.onap.aaiclient.client.graphinventory.GraphInventoryObjectPlurals;
+import org.onap.aaiclient.client.graphinventory.GraphInventoryObjectType;
+
+public interface GraphInventorySingleResourceUri<T extends GraphInventorySingleResourceUri<?, ?, ?, ?>, P extends GraphInventoryPluralResourceUri<?, ?>, SingleObject extends GraphInventoryObjectType, PluralObject extends GraphInventoryObjectPlurals>
+ extends GraphInventoryResourceUri<T, SingleObject> {
+
+ public T resourceVersion(String version);
+
+ public T relationshipAPI();
+
+ public P relatedTo(PluralObject plural);
+
+ public T relatedTo(SingleObject type, String... values);
+}
diff --git a/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/graphinventory/entities/uri/GraphInventoryUri.java b/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/graphinventory/entities/uri/GraphInventoryUri.java
new file mode 100644
index 0000000000..414bf3b071
--- /dev/null
+++ b/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/graphinventory/entities/uri/GraphInventoryUri.java
@@ -0,0 +1,81 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2017 - 2018 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.aaiclient.client.graphinventory.entities.uri;
+
+import java.io.Serializable;
+import java.net.URI;
+import java.util.Map;
+import java.util.regex.Pattern;
+import org.onap.aaiclient.client.graphinventory.GraphInventoryObjectBase;
+import org.onap.aaiclient.client.graphinventory.GraphInventoryObjectType;
+
+public interface GraphInventoryUri<T extends GraphInventoryUri<?, ?>, OT extends GraphInventoryObjectBase>
+ extends Serializable {
+
+ public URI build();
+
+ /**
+ * By default GraphInventory enforces a depth of 1. Some objects can be told to retrieve objects nested beneath them
+ * by increasing this number.
+ *
+ * You can use 0 to restrict the returned information to only the object you requested You can use all to retrieve
+ * all nested objects (this should only be used if you really need a massive amount of information and are caching
+ * the retrieval)
+ *
+ * @param depth
+ * @return
+ */
+ public T depth(Depth depth);
+
+ /**
+ * Makes client only return object fields, no relationships
+ *
+ * @return
+ */
+ public T nodesOnly(boolean nodesOnly);
+
+ public T queryParam(String name, String... values);
+
+ public T replaceQueryParam(String name, String... values);
+
+ public T resultIndex(int index);
+
+ public T resultSize(int size);
+
+ public T limit(int size);
+
+ public T clone();
+
+ /**
+ * returns all key values of the URI as a map. Key names can be found in {@link GraphInventoryObjectType}
+ *
+ * @return
+ */
+ public Map<String, String> getURIKeys();
+
+ public OT getObjectType();
+
+ public boolean equals(Object o);
+
+ public int hashCode();
+
+ public Pattern getPrefixPattern();
+}
diff --git a/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/graphinventory/entities/uri/HttpAwareUri.java b/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/graphinventory/entities/uri/HttpAwareUri.java
new file mode 100644
index 0000000000..ab46f24464
--- /dev/null
+++ b/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/graphinventory/entities/uri/HttpAwareUri.java
@@ -0,0 +1,32 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2017 - 2018 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.aaiclient.client.graphinventory.entities.uri;
+
+import java.net.URI;
+import org.onap.aaiclient.client.aai.entities.uri.AAIResourceUri;
+
+public interface HttpAwareUri extends AAIResourceUri {
+
+
+ public URI buildNoNetwork();
+
+ public URI locateAndBuild();
+}
diff --git a/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/graphinventory/entities/uri/SimpleBaseUri.java b/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/graphinventory/entities/uri/SimpleBaseUri.java
new file mode 100644
index 0000000000..b668f465e9
--- /dev/null
+++ b/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/graphinventory/entities/uri/SimpleBaseUri.java
@@ -0,0 +1,237 @@
+package org.onap.aaiclient.client.graphinventory.entities.uri;
+
+import java.io.IOException;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutputStream;
+import java.net.URI;
+import java.nio.charset.StandardCharsets;
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Set;
+import java.util.stream.Collectors;
+import java.util.stream.Stream;
+import javax.ws.rs.core.UriBuilder;
+import org.apache.commons.lang3.builder.HashCodeBuilder;
+import org.apache.commons.lang3.builder.ToStringBuilder;
+import org.apache.commons.lang3.builder.ToStringStyle;
+import org.onap.aaiclient.client.graphinventory.Format;
+import org.onap.aaiclient.client.graphinventory.GraphInventoryObjectBase;
+import org.onap.aaiclient.client.graphinventory.entities.uri.parsers.UriParser;
+import org.onap.aaiclient.client.graphinventory.entities.uri.parsers.UriParserSpringImpl;
+import org.onap.aaiclient.client.graphinventory.exceptions.IncorrectNumberOfUriKeys;
+import org.springframework.web.util.UriUtils;
+
+public abstract class SimpleBaseUri<T extends GraphInventoryResourceUri<?, ?>, Parent extends GraphInventorySingleResourceUri<?, ?, ?, ?>, S extends GraphInventoryObjectBase>
+ implements GraphInventoryResourceUri<T, S> {
+
+ private static final long serialVersionUID = -1011069933894179423L;
+ protected transient UriBuilder internalURI;
+ protected static final String relationshipAPI = "/relationship-list/relationship";
+ protected static final String relatedTo = "/related-to";
+ protected Object[] values;
+ protected final S type;
+ protected final Parent parentUri;
+ protected final Map<String, Set<String>> queryParams = new HashMap<>();
+
+ protected SimpleBaseUri(S type, Object... values) {
+ this.type = type;
+ this.internalURI = UriBuilder.fromPath(this.getTemplate(type));
+ this.values = values;
+ this.parentUri = null;
+ validateValuesSize(this.getTemplate(type), values);
+ }
+
+ protected SimpleBaseUri(S type, URI uri) {
+ if (!type.passThrough()) {
+ this.type = type;
+ this.internalURI = UriBuilder.fromPath(this.getTemplate(type));
+ this.values =
+ this.getURIKeys(uri.getRawPath().replaceAll(getPrefixPattern().toString(), "")).values().toArray();
+ this.parentUri = null;
+ } else {
+ this.type = type;
+ this.internalURI = UriBuilder.fromPath(uri.getRawPath().replaceAll(getPrefixPattern().toString(), ""));
+ this.values = new Object[0];
+ this.parentUri = null;
+ }
+
+ }
+
+ protected SimpleBaseUri(S type, UriBuilder builder, Object... values) {
+ this.internalURI = builder;
+ this.values = values;
+ this.type = type;
+ this.parentUri = null;
+
+ }
+
+ protected SimpleBaseUri(Parent parentUri, S childType, Object... childValues) {
+ this.type = childType;
+ this.internalURI = UriBuilder.fromUri(type.partialUri());
+ this.values = childValues;
+ this.parentUri = parentUri;
+
+ validateValuesSize(childType.partialUri(), values);
+ }
+
+ protected SimpleBaseUri(SimpleBaseUri<T, Parent, S> copy) {
+ this.type = copy.type;
+ this.internalURI = copy.internalURI.clone();
+ this.values = copy.values.clone();
+ if (copy.parentUri != null) {
+ this.parentUri = (Parent) copy.parentUri.clone();
+ } else {
+ this.parentUri = null;
+ }
+ }
+
+ protected void setInternalURI(UriBuilder builder) {
+ this.internalURI = builder;
+ }
+
+ @Override
+ public T queryParam(String name, String... values) {
+ this.internalURI = internalURI.queryParam(name, values);
+ if (queryParams.containsKey(name)) {
+ queryParams.get(name).addAll(Arrays.asList(values));
+ } else {
+ queryParams.put(name, Stream.of(values).collect(Collectors.toSet()));
+ }
+ return (T) this;
+ }
+
+ @Override
+ public T replaceQueryParam(String name, String... values) {
+ this.internalURI = internalURI.replaceQueryParam(name, values);
+ queryParams.put(name, Stream.of(values).collect(Collectors.toSet()));
+ return (T) this;
+ }
+
+ @Override
+ public T resultIndex(int index) {
+ this.internalURI = internalURI.replaceQueryParam("resultIndex", index);
+ return (T) this;
+ }
+
+ @Override
+ public T resultSize(int size) {
+ this.internalURI = internalURI.replaceQueryParam("resultSize", size);
+ return (T) this;
+ }
+
+ @Override
+ public T limit(int size) {
+ this.resultIndex(0).resultSize(size);
+ return (T) this;
+ }
+
+ @Override
+ public URI build() {
+ return build(this.values);
+ }
+
+ protected URI build(Object... values) {
+
+ // This is a workaround because resteasy does not encode URIs correctly
+ final String[] encoded = new String[values.length];
+ for (int i = 0; i < values.length; i++) {
+ encoded[i] = UriUtils.encode(values[i].toString(), StandardCharsets.UTF_8.toString());
+ }
+ if (this.parentUri != null) {
+ return UriBuilder
+ .fromUri(this.parentUri.build().toString() + internalURI.buildFromEncoded(encoded).toString())
+ .build();
+ } else {
+ return internalURI.buildFromEncoded(encoded);
+ }
+ }
+
+ @Override
+ public Map<String, String> getURIKeys() {
+ return this.getURIKeys(this.build().toString());
+ }
+
+ protected Map<String, String> getURIKeys(String uri) {
+ UriParser parser;
+ if (!("".equals(this.getTemplate(type)))) {
+ parser = new UriParserSpringImpl(this.getTemplate(type));
+ } else {
+ return new HashMap<>();
+ }
+
+
+ return parser.parse(uri);
+ }
+
+ @Override
+ public abstract T clone();
+
+ @Override
+ public S getObjectType() {
+ return this.type;
+ }
+
+ @Override
+ public boolean equals(Object o) {
+ if (o != null) {
+ return this.toString().equals(o.toString());
+ }
+ return false;
+ }
+
+ @Override
+ public int hashCode() {
+ return new HashCodeBuilder().append(this.toString()).toHashCode();
+ }
+
+
+ @Override
+ public T depth(Depth depth) {
+ this.internalURI.replaceQueryParam("depth", depth.toString());
+ return (T) this;
+ }
+
+ @Override
+ public T nodesOnly(boolean nodesOnly) {
+ if (nodesOnly) {
+ this.internalURI.replaceQueryParam("nodes-only", "");
+ }
+ return (T) this;
+ }
+
+ @Override
+ public T format(Format format) {
+ this.internalURI.replaceQueryParam("format", format);
+ return (T) this;
+ }
+
+ public void validateValuesSize(String template, Object... values) {
+ UriParser parser = new UriParserSpringImpl(template);
+ Set<String> variables = parser.getVariables();
+ if (variables.size() != values.length) {
+ throw new IncorrectNumberOfUriKeys(String.format("Expected %s variables: %s", variables.size(), variables));
+ }
+ }
+
+ protected String getTemplate(GraphInventoryObjectBase type) {
+ return type.uriTemplate();
+ }
+
+ private void writeObject(ObjectOutputStream oos) throws IOException {
+ oos.defaultWriteObject();
+ oos.writeUTF(this.internalURI.toTemplate());
+ }
+
+ private void readObject(ObjectInputStream ois) throws ClassNotFoundException, IOException {
+ ois.defaultReadObject();
+ String uri = ois.readUTF();
+ this.setInternalURI(UriBuilder.fromUri(uri));
+ }
+
+ @Override
+ public String toString() {
+ return new ToStringBuilder(null, ToStringStyle.NO_CLASS_NAME_STYLE).append("type", type)
+ .append("parentUri", parentUri).append("values", values).append("queryParams", queryParams).toString();
+ }
+}
diff --git a/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/graphinventory/entities/uri/SimplePluralUri.java b/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/graphinventory/entities/uri/SimplePluralUri.java
new file mode 100644
index 0000000000..d76661526c
--- /dev/null
+++ b/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/graphinventory/entities/uri/SimplePluralUri.java
@@ -0,0 +1,77 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.aaiclient.client.graphinventory.entities.uri;
+
+import java.io.IOException;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutputStream;
+import java.io.Serializable;
+import javax.ws.rs.core.UriBuilder;
+import org.onap.aaiclient.client.graphinventory.GraphInventoryObjectPlurals;
+import org.onap.aaiclient.client.graphinventory.GraphInventoryObjectType;
+
+public abstract class SimplePluralUri<T extends GraphInventoryPluralResourceUri<?, ?>, Parent extends GraphInventorySingleResourceUri<?, ?, ?, ?>, PT extends GraphInventoryObjectPlurals, OT extends GraphInventoryObjectType>
+ extends SimpleBaseUri<T, Parent, PT> implements GraphInventoryPluralResourceUri<T, PT>, Serializable {
+
+ private static final long serialVersionUID = -337701171277616439L;
+
+ protected final PT pluralType;
+
+ protected SimplePluralUri(PT type, UriBuilder builder, Object... values) {
+ super(type, builder, values);
+ this.pluralType = type;
+ }
+
+ protected SimplePluralUri(PT type) {
+ super(type, new Object[0]);
+ this.pluralType = type;
+ }
+
+ protected SimplePluralUri(PT type, Object... values) {
+ super(type, values);
+ this.pluralType = type;
+ }
+
+ protected SimplePluralUri(Parent parentUri, PT childType) {
+ super(parentUri, childType, new Object[0]);
+ this.pluralType = childType;
+ }
+
+ public SimplePluralUri(SimplePluralUri<T, Parent, PT, OT> copy) {
+ super(copy);
+ this.pluralType = copy.pluralType;
+ }
+
+ protected void setInternalURI(UriBuilder builder) {
+ this.internalURI = builder;
+ }
+
+ private void writeObject(ObjectOutputStream oos) throws IOException {
+ oos.defaultWriteObject();
+ oos.writeUTF(this.internalURI.toTemplate());
+ }
+
+ private void readObject(ObjectInputStream ois) throws ClassNotFoundException, IOException {
+ ois.defaultReadObject();
+ String uri = ois.readUTF();
+ this.setInternalURI(UriBuilder.fromUri(uri));
+ }
+}
diff --git a/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/graphinventory/entities/uri/SimpleUri.java b/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/graphinventory/entities/uri/SimpleUri.java
new file mode 100644
index 0000000000..e6a162bfda
--- /dev/null
+++ b/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/graphinventory/entities/uri/SimpleUri.java
@@ -0,0 +1,83 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.aaiclient.client.graphinventory.entities.uri;
+
+import java.io.IOException;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutputStream;
+import java.net.URI;
+import javax.ws.rs.core.UriBuilder;
+import org.onap.aaiclient.client.graphinventory.GraphInventoryObjectPlurals;
+import org.onap.aaiclient.client.graphinventory.GraphInventoryObjectType;
+
+public abstract class SimpleUri<T extends GraphInventorySingleResourceUri<?, ?, ?, ?>, PT extends GraphInventoryPluralResourceUri<?, ?>, S extends GraphInventoryObjectType, P extends GraphInventoryObjectPlurals>
+ extends SimpleBaseUri<T, T, S> implements GraphInventorySingleResourceUri<T, PT, S, P> {
+
+ private static final long serialVersionUID = -337701171277616439L;
+ protected static final String relationshipAPI = "/relationship-list/relationship";
+ protected static final String relatedTo = "/related-to";
+
+ protected SimpleUri(S type, Object... values) {
+ super(type, values);
+ }
+
+ protected SimpleUri(S type, URI uri) {
+ super(type, uri);
+
+ }
+
+ protected SimpleUri(S type, UriBuilder builder, Object... values) {
+ super(type, builder, values);
+
+ }
+
+ protected SimpleUri(T parentUri, S childType, Object... childValues) {
+ super(parentUri, childType, childValues);
+ }
+
+ protected SimpleUri(SimpleBaseUri<T, T, S> copy) {
+ super(copy);
+ }
+
+ @Override
+ public T resourceVersion(String version) {
+ this.internalURI = internalURI.replaceQueryParam("resource-version", version);
+ return (T) this;
+ }
+
+ @Override
+ public T relationshipAPI() {
+ this.internalURI = internalURI.path(relationshipAPI);
+ return (T) this;
+ }
+
+ private void writeObject(ObjectOutputStream oos) throws IOException {
+ oos.defaultWriteObject();
+ oos.writeUTF(this.internalURI.toTemplate());
+ }
+
+ private void readObject(ObjectInputStream ois) throws ClassNotFoundException, IOException {
+ ois.defaultReadObject();
+ String uri = ois.readUTF();
+ this.setInternalURI(UriBuilder.fromUri(uri));
+ }
+
+}
diff --git a/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/graphinventory/entities/uri/parsers/UriParser.java b/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/graphinventory/entities/uri/parsers/UriParser.java
new file mode 100644
index 0000000000..24a20240e0
--- /dev/null
+++ b/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/graphinventory/entities/uri/parsers/UriParser.java
@@ -0,0 +1,30 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.aaiclient.client.graphinventory.entities.uri.parsers;
+
+import java.util.Map;
+import java.util.Set;
+
+public interface UriParser {
+ public Set<String> getVariables();
+
+ public Map<String, String> parse(final String uri);
+}
diff --git a/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/graphinventory/entities/uri/parsers/UriParserSpringImpl.java b/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/graphinventory/entities/uri/parsers/UriParserSpringImpl.java
new file mode 100644
index 0000000000..db13ef742a
--- /dev/null
+++ b/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/graphinventory/entities/uri/parsers/UriParserSpringImpl.java
@@ -0,0 +1,63 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.aaiclient.client.graphinventory.entities.uri.parsers;
+
+import java.util.Collections;
+import java.util.LinkedHashMap;
+import java.util.LinkedHashSet;
+import java.util.Map;
+import java.util.Map.Entry;
+import java.util.Set;
+import org.springframework.web.util.UriTemplate;
+import org.springframework.web.util.UriUtils;
+
+public class UriParserSpringImpl implements UriParser {
+
+ private final UriTemplate uriTemplate;
+
+ public UriParserSpringImpl(final String template) {
+ this.uriTemplate = new UriTemplate(template);
+ }
+
+ @Override
+ public Map<String, String> parse(final String uri) {
+ final boolean match = this.uriTemplate.matches(uri);
+ if (!match) {
+ return new LinkedHashMap<>();
+ }
+ return Collections.unmodifiableMap(decodeParams(this.uriTemplate.match(uri)));
+ }
+
+ @Override
+ public Set<String> getVariables() {
+ return Collections.unmodifiableSet(new LinkedHashSet<String>(this.uriTemplate.getVariableNames()));
+ }
+
+ protected Map<String, String> decodeParams(Map<String, String> map) {
+ final Map<String, String> result = new LinkedHashMap<>();
+
+ for (Entry<String, String> entry : map.entrySet()) {
+ result.put(entry.getKey(), UriUtils.decode(entry.getValue(), "UTF-8"));
+ }
+
+ return result;
+ }
+}
diff --git a/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/graphinventory/exceptions/BulkProcessFailed.java b/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/graphinventory/exceptions/BulkProcessFailed.java
new file mode 100644
index 0000000000..131d466608
--- /dev/null
+++ b/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/graphinventory/exceptions/BulkProcessFailed.java
@@ -0,0 +1,28 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.aaiclient.client.graphinventory.exceptions;
+
+public class BulkProcessFailed extends Exception {
+
+ public BulkProcessFailed(String message) {
+ super(message);
+ }
+}
diff --git a/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/graphinventory/exceptions/GraphInventoryMultipleItemsException.java b/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/graphinventory/exceptions/GraphInventoryMultipleItemsException.java
new file mode 100644
index 0000000000..257f1331af
--- /dev/null
+++ b/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/graphinventory/exceptions/GraphInventoryMultipleItemsException.java
@@ -0,0 +1,13 @@
+package org.onap.aaiclient.client.graphinventory.exceptions;
+
+import org.onap.aaiclient.client.graphinventory.entities.uri.GraphInventoryPluralResourceUri;
+
+public class GraphInventoryMultipleItemsException extends RuntimeException {
+
+ private static final long serialVersionUID = -1596266941681036917L;
+
+ public GraphInventoryMultipleItemsException(int size, GraphInventoryPluralResourceUri uri) {
+ super(String.format("Found %s objects at %s when we only expected to find one.", size, uri.build()));
+ }
+
+}
diff --git a/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/graphinventory/exceptions/GraphInventoryPatchDepthExceededException.java b/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/graphinventory/exceptions/GraphInventoryPatchDepthExceededException.java
new file mode 100644
index 0000000000..615f4df8cb
--- /dev/null
+++ b/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/graphinventory/exceptions/GraphInventoryPatchDepthExceededException.java
@@ -0,0 +1,31 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2017 - 2018 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.aaiclient.client.graphinventory.exceptions;
+
+public class GraphInventoryPatchDepthExceededException extends RuntimeException {
+
+ private static final long serialVersionUID = -3740429832086738907L;
+
+
+ public GraphInventoryPatchDepthExceededException(String payload) {
+ super("Object exceeds allowed depth for update action: " + payload);
+ }
+}
diff --git a/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/graphinventory/exceptions/GraphInventoryPayloadException.java b/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/graphinventory/exceptions/GraphInventoryPayloadException.java
new file mode 100644
index 0000000000..2b42fb09e7
--- /dev/null
+++ b/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/graphinventory/exceptions/GraphInventoryPayloadException.java
@@ -0,0 +1,40 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.aaiclient.client.graphinventory.exceptions;
+
+public class GraphInventoryPayloadException extends Exception {
+
+ private static final long serialVersionUID = -5712783905947711065L;
+
+ public GraphInventoryPayloadException(Throwable t) {
+ super(t);
+ }
+
+ public GraphInventoryPayloadException(String s, Throwable t) {
+ super(s, t);
+ }
+
+ public GraphInventoryPayloadException(String s) {
+ super(s);
+ }
+
+
+}
diff --git a/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/graphinventory/exceptions/GraphInventoryUriComputationException.java b/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/graphinventory/exceptions/GraphInventoryUriComputationException.java
new file mode 100644
index 0000000000..834c0d4c0e
--- /dev/null
+++ b/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/graphinventory/exceptions/GraphInventoryUriComputationException.java
@@ -0,0 +1,34 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.aaiclient.client.graphinventory.exceptions;
+
+public class GraphInventoryUriComputationException extends RuntimeException {
+
+ private static final long serialVersionUID = 5187931752227522034L;
+
+ public GraphInventoryUriComputationException(String s) {
+ super(s);
+ }
+
+ public GraphInventoryUriComputationException(Throwable t) {
+ super(t);
+ }
+}
diff --git a/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/graphinventory/exceptions/GraphInventoryUriNotFoundException.java b/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/graphinventory/exceptions/GraphInventoryUriNotFoundException.java
new file mode 100644
index 0000000000..f9965f3920
--- /dev/null
+++ b/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/graphinventory/exceptions/GraphInventoryUriNotFoundException.java
@@ -0,0 +1,29 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.aaiclient.client.graphinventory.exceptions;
+
+public class GraphInventoryUriNotFoundException extends Exception {
+ private static final long serialVersionUID = 2789643165122257833L;
+
+ public GraphInventoryUriNotFoundException(String message) {
+ super(message);
+ }
+}
diff --git a/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/graphinventory/exceptions/IncorrectNumberOfUriKeys.java b/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/graphinventory/exceptions/IncorrectNumberOfUriKeys.java
new file mode 100644
index 0000000000..d46ffae164
--- /dev/null
+++ b/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/graphinventory/exceptions/IncorrectNumberOfUriKeys.java
@@ -0,0 +1,31 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2017 - 2019 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.aaiclient.client.graphinventory.exceptions;
+
+public class IncorrectNumberOfUriKeys extends RuntimeException {
+
+ private static final long serialVersionUID = 2189285428827817518L;
+
+ public IncorrectNumberOfUriKeys(String message) {
+ super(message);
+ }
+
+}