aboutsummaryrefslogtreecommitdiffstats
path: root/common/src/main/java/org/onap/so/client/graphinventory
diff options
context:
space:
mode:
Diffstat (limited to 'common/src/main/java/org/onap/so/client/graphinventory')
-rw-r--r--common/src/main/java/org/onap/so/client/graphinventory/Format.java43
-rw-r--r--common/src/main/java/org/onap/so/client/graphinventory/GraphInventoryClient.java48
-rw-r--r--common/src/main/java/org/onap/so/client/graphinventory/GraphInventoryObjectName.java29
-rw-r--r--common/src/main/java/org/onap/so/client/graphinventory/GraphInventoryObjectPlurals.java25
-rw-r--r--common/src/main/java/org/onap/so/client/graphinventory/GraphInventoryObjectType.java25
-rw-r--r--common/src/main/java/org/onap/so/client/graphinventory/GraphInventoryObjectUriPartial.java26
-rw-r--r--common/src/main/java/org/onap/so/client/graphinventory/GraphInventoryObjectUriTemplate.java26
-rw-r--r--common/src/main/java/org/onap/so/client/graphinventory/GraphInventoryVersion.java25
-rw-r--r--common/src/main/java/org/onap/so/client/graphinventory/entities/uri/Depth.java44
-rw-r--r--common/src/main/java/org/onap/so/client/graphinventory/entities/uri/GraphInventoryResourceUri.java44
-rw-r--r--common/src/main/java/org/onap/so/client/graphinventory/entities/uri/GraphInventoryUri.java60
-rw-r--r--common/src/main/java/org/onap/so/client/graphinventory/entities/uri/SimpleUri.java216
-rw-r--r--common/src/main/java/org/onap/so/client/graphinventory/entities/uri/parsers/UriParser.java29
-rw-r--r--common/src/main/java/org/onap/so/client/graphinventory/entities/uri/parsers/UriParserSpringImpl.java68
-rw-r--r--common/src/main/java/org/onap/so/client/graphinventory/exceptions/BulkProcessFailed.java28
-rw-r--r--common/src/main/java/org/onap/so/client/graphinventory/exceptions/GraphInventoryPatchDepthExceededException.java31
-rw-r--r--common/src/main/java/org/onap/so/client/graphinventory/exceptions/GraphInventoryPayloadException.java40
-rw-r--r--common/src/main/java/org/onap/so/client/graphinventory/exceptions/GraphInventoryUriComputationException.java34
-rw-r--r--common/src/main/java/org/onap/so/client/graphinventory/exceptions/GraphInventoryUriNotFoundException.java29
19 files changed, 870 insertions, 0 deletions
diff --git a/common/src/main/java/org/onap/so/client/graphinventory/Format.java b/common/src/main/java/org/onap/so/client/graphinventory/Format.java
new file mode 100644
index 0000000000..5cbf1320c1
--- /dev/null
+++ b/common/src/main/java/org/onap/so/client/graphinventory/Format.java
@@ -0,0 +1,43 @@
+/*-
+ * ============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.so.client.graphinventory;
+
+public enum Format {
+
+ RESOURCE("resource"),
+ SIMPLE("simple"),
+ RAW("raw"),
+ CONSOLE("console"),
+ PATHED("pathed"),
+ GRAPHSON("graphson"),
+ ID("id");
+
+ private final String name;
+
+ private Format(String name) {
+ this.name = name;
+ }
+
+ @Override
+ public String toString() {
+ return name;
+ }
+}
diff --git a/common/src/main/java/org/onap/so/client/graphinventory/GraphInventoryClient.java b/common/src/main/java/org/onap/so/client/graphinventory/GraphInventoryClient.java
new file mode 100644
index 0000000000..0d10c21886
--- /dev/null
+++ b/common/src/main/java/org/onap/so/client/graphinventory/GraphInventoryClient.java
@@ -0,0 +1,48 @@
+/*-
+ * ============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.so.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.so.client.graphinventory.entities.uri.GraphInventoryUri;
+
+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(GraphInventoryUri uri);
+
+ protected abstract RestClient createClient(GraphInventoryUri uri);
+
+ protected <T extends RestProperties> T getRestProperties() {
+ if (props == null) {
+ throw new IllegalStateException("No RestProperty implementation found on classpath");
+ }
+ return (T)props;
+ }
+}
diff --git a/common/src/main/java/org/onap/so/client/graphinventory/GraphInventoryObjectName.java b/common/src/main/java/org/onap/so/client/graphinventory/GraphInventoryObjectName.java
new file mode 100644
index 0000000000..4543d8523b
--- /dev/null
+++ b/common/src/main/java/org/onap/so/client/graphinventory/GraphInventoryObjectName.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.so.client.graphinventory;
+
+import com.google.common.base.CaseFormat;
+
+public interface GraphInventoryObjectName {
+
+ public String typeName();
+ public String typeName(CaseFormat format);
+}
diff --git a/common/src/main/java/org/onap/so/client/graphinventory/GraphInventoryObjectPlurals.java b/common/src/main/java/org/onap/so/client/graphinventory/GraphInventoryObjectPlurals.java
new file mode 100644
index 0000000000..ba48eb279f
--- /dev/null
+++ b/common/src/main/java/org/onap/so/client/graphinventory/GraphInventoryObjectPlurals.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.so.client.graphinventory;
+
+public interface GraphInventoryObjectPlurals extends GraphInventoryObjectName, GraphInventoryObjectUriTemplate, GraphInventoryObjectUriPartial {
+
+}
diff --git a/common/src/main/java/org/onap/so/client/graphinventory/GraphInventoryObjectType.java b/common/src/main/java/org/onap/so/client/graphinventory/GraphInventoryObjectType.java
new file mode 100644
index 0000000000..453becb75a
--- /dev/null
+++ b/common/src/main/java/org/onap/so/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.so.client.graphinventory;
+
+public interface GraphInventoryObjectType extends GraphInventoryObjectName, GraphInventoryObjectUriTemplate, GraphInventoryObjectUriPartial {
+
+}
diff --git a/common/src/main/java/org/onap/so/client/graphinventory/GraphInventoryObjectUriPartial.java b/common/src/main/java/org/onap/so/client/graphinventory/GraphInventoryObjectUriPartial.java
new file mode 100644
index 0000000000..0987221b0d
--- /dev/null
+++ b/common/src/main/java/org/onap/so/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.so.client.graphinventory;
+
+public interface GraphInventoryObjectUriPartial {
+
+ public String partialUri();
+}
diff --git a/common/src/main/java/org/onap/so/client/graphinventory/GraphInventoryObjectUriTemplate.java b/common/src/main/java/org/onap/so/client/graphinventory/GraphInventoryObjectUriTemplate.java
new file mode 100644
index 0000000000..e231ddb811
--- /dev/null
+++ b/common/src/main/java/org/onap/so/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.so.client.graphinventory;
+
+public interface GraphInventoryObjectUriTemplate {
+
+ public String uriTemplate();
+}
diff --git a/common/src/main/java/org/onap/so/client/graphinventory/GraphInventoryVersion.java b/common/src/main/java/org/onap/so/client/graphinventory/GraphInventoryVersion.java
new file mode 100644
index 0000000000..3b7dba70f8
--- /dev/null
+++ b/common/src/main/java/org/onap/so/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.so.client.graphinventory;
+
+public interface GraphInventoryVersion {
+
+}
diff --git a/common/src/main/java/org/onap/so/client/graphinventory/entities/uri/Depth.java b/common/src/main/java/org/onap/so/client/graphinventory/entities/uri/Depth.java
new file mode 100644
index 0000000000..1205511d11
--- /dev/null
+++ b/common/src/main/java/org/onap/so/client/graphinventory/entities/uri/Depth.java
@@ -0,0 +1,44 @@
+/*-
+ * ============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.so.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/common/src/main/java/org/onap/so/client/graphinventory/entities/uri/GraphInventoryResourceUri.java b/common/src/main/java/org/onap/so/client/graphinventory/entities/uri/GraphInventoryResourceUri.java
new file mode 100644
index 0000000000..08e7304978
--- /dev/null
+++ b/common/src/main/java/org/onap/so/client/graphinventory/entities/uri/GraphInventoryResourceUri.java
@@ -0,0 +1,44 @@
+/*-
+ * ============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.so.client.graphinventory.entities.uri;
+
+import org.onap.so.client.graphinventory.Format;
+import org.onap.so.client.graphinventory.entities.uri.Depth;
+import org.onap.so.client.graphinventory.GraphInventoryObjectPlurals;
+import org.onap.so.client.graphinventory.GraphInventoryObjectType;
+
+public interface GraphInventoryResourceUri extends GraphInventoryUri {
+ public GraphInventoryResourceUri relationshipAPI();
+ public GraphInventoryResourceUri relatedTo(GraphInventoryObjectPlurals plural);
+ public GraphInventoryResourceUri relatedTo(GraphInventoryObjectType type, String... values);
+ public GraphInventoryResourceUri resourceVersion(String version);
+ public GraphInventoryResourceUri format(Format format);
+ @Override
+ public GraphInventoryResourceUri depth(Depth depth);
+ @Override
+ public GraphInventoryResourceUri nodesOnly(boolean nodesOnly);
+ @Override
+ public GraphInventoryResourceUri queryParam(String name, String... values);
+ @Override
+ public GraphInventoryResourceUri replaceQueryParam(String name, String... values);
+ @Override
+ public GraphInventoryResourceUri clone();
+}
diff --git a/common/src/main/java/org/onap/so/client/graphinventory/entities/uri/GraphInventoryUri.java b/common/src/main/java/org/onap/so/client/graphinventory/entities/uri/GraphInventoryUri.java
new file mode 100644
index 0000000000..8a25c23895
--- /dev/null
+++ b/common/src/main/java/org/onap/so/client/graphinventory/entities/uri/GraphInventoryUri.java
@@ -0,0 +1,60 @@
+/*-
+ * ============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.so.client.graphinventory.entities.uri;
+
+import java.net.URI;
+import java.util.Map;
+
+import org.onap.so.client.graphinventory.entities.uri.Depth;
+import org.onap.so.client.graphinventory.GraphInventoryObjectType;
+
+public interface GraphInventoryUri {
+
+ 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 GraphInventoryUri depth(Depth depth);
+ /**
+ * Makes client only return object fields, no relationships
+ *
+ * @return
+ */
+ public GraphInventoryUri nodesOnly(boolean nodesOnly);
+ public GraphInventoryUri queryParam(String name, String... values);
+ public GraphInventoryUri replaceQueryParam(String name, String... values);
+ public GraphInventoryUri 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 GraphInventoryObjectType getObjectType();
+ public boolean equals(Object o);
+ public int hashCode();
+}
diff --git a/common/src/main/java/org/onap/so/client/graphinventory/entities/uri/SimpleUri.java b/common/src/main/java/org/onap/so/client/graphinventory/entities/uri/SimpleUri.java
new file mode 100644
index 0000000000..9c86ec6348
--- /dev/null
+++ b/common/src/main/java/org/onap/so/client/graphinventory/entities/uri/SimpleUri.java
@@ -0,0 +1,216 @@
+/*-
+ * ============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.so.client.graphinventory.entities.uri;
+
+import java.io.UnsupportedEncodingException;
+import java.net.URI;
+import java.nio.charset.StandardCharsets;
+import java.util.HashMap;
+import java.util.Map;
+
+import javax.ws.rs.core.UriBuilder;
+
+import org.apache.commons.lang3.builder.HashCodeBuilder;
+import org.onap.so.client.graphinventory.Format;
+import org.onap.so.client.aai.entities.uri.AAIUri;
+import org.onap.so.client.graphinventory.entities.uri.Depth;
+import org.onap.so.client.graphinventory.entities.uri.parsers.UriParser;
+import org.onap.so.client.graphinventory.entities.uri.parsers.UriParserSpringImpl;
+import org.onap.so.client.graphinventory.GraphInventoryObjectPlurals;
+import org.onap.so.client.graphinventory.GraphInventoryObjectType;
+import org.springframework.web.util.UriUtils;
+
+public class SimpleUri implements GraphInventoryResourceUri {
+
+ protected UriBuilder internalURI;
+ protected final static String relationshipAPI = "/relationship-list/relationship";
+ protected final static String relatedTo = "/related-to";
+ protected final Object[] values;
+ protected final GraphInventoryObjectType type;
+ protected final GraphInventoryObjectPlurals pluralType;
+ protected SimpleUri(GraphInventoryObjectType type, Object... values) {
+ this.type = type;
+ this.pluralType = null;
+ this.internalURI = UriBuilder.fromPath(this.getTemplate(type));
+ this.values = values;
+ }
+ protected SimpleUri(GraphInventoryObjectType type, URI uri) {
+ this.type = type;
+ this.pluralType = null;
+ this.internalURI = UriBuilder.fromPath(uri.getRawPath().replaceAll("/aai/v\\d+", ""));
+ this.values = new Object[0];
+ }
+ protected SimpleUri(GraphInventoryObjectType type, UriBuilder builder, Object... values) {
+ this.internalURI = builder;
+ this.values = values;
+ this.type = type;
+ this.pluralType = null;
+ }
+ protected SimpleUri(GraphInventoryObjectPlurals type, UriBuilder builder, Object... values) {
+ this.internalURI = builder;
+ this.values = values;
+ this.type = null;
+ this.pluralType = type;
+ }
+ protected SimpleUri(GraphInventoryObjectPlurals type) {
+ this.type = null;
+ this.pluralType = type;
+ this.internalURI = UriBuilder.fromPath(this.getTemplate(type));
+ this.values = new Object[0];
+ }
+ protected SimpleUri(GraphInventoryObjectPlurals type, Object... values) {
+ this.type = null;
+ this.pluralType = type;
+ this.internalURI = UriBuilder.fromPath(this.getTemplate(type));
+ this.values = values;
+ }
+
+ @Override
+ public SimpleUri relationshipAPI() {
+ this.internalURI = internalURI.path(relationshipAPI);
+ return this;
+ }
+
+ @Override
+ public SimpleUri relatedTo(GraphInventoryObjectPlurals plural) {
+
+ this.internalURI = internalURI.path(relatedTo).path(plural.partialUri());
+ return this;
+ }
+ @Override
+ public SimpleUri relatedTo(GraphInventoryObjectType type, String... values) {
+ this.internalURI = internalURI.path(relatedTo).path(UriBuilder.fromPath(type.partialUri()).build(values).toString());
+ return this;
+ }
+
+ @Override
+ public SimpleUri resourceVersion(String version) {
+ this.internalURI = internalURI.replaceQueryParam("resource-version", version);
+ return this;
+ }
+
+ @Override
+ public SimpleUri queryParam(String name, String... values) {
+ this.internalURI = internalURI.queryParam(name, values);
+ return this;
+ }
+
+ @Override
+ public SimpleUri replaceQueryParam(String name, String... values) {
+ this.internalURI = internalURI.replaceQueryParam(name, values);
+ return 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++) {
+ try {
+ encoded[i] = UriUtils.encode(values[i].toString(), StandardCharsets.UTF_8.toString());
+ } catch (UnsupportedEncodingException e) {
+ encoded[i] = values[i].toString();
+ }
+ }
+ 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 (this.type != null) {
+ if (!("".equals(this.getTemplate(type)))) {
+ parser = new UriParserSpringImpl(this.getTemplate(type));
+ } else {
+ return new HashMap<>();
+ }
+ } else {
+ parser = new UriParserSpringImpl(this.getTemplate(pluralType));
+ }
+
+
+ return parser.parse(uri);
+ }
+
+ @Override
+ public SimpleUri clone() {
+ if (this.type != null) {
+ return new SimpleUri(this.type, this.internalURI.clone(), values);
+ } else {
+ return new SimpleUri(this.pluralType, this.internalURI.clone(), values);
+ }
+ }
+
+ @Override
+ public GraphInventoryObjectType getObjectType() {
+ return this.type;
+ }
+
+ @Override
+ public boolean equals(Object o) {
+ if (o instanceof AAIUri) {
+ return this.build().equals(((AAIUri)o).build());
+ }
+ return false;
+ }
+
+ @Override
+ public int hashCode() {
+ return new HashCodeBuilder().append(this.build()).toHashCode();
+ }
+
+
+ @Override
+ public SimpleUri depth(Depth depth) {
+ this.internalURI.replaceQueryParam("depth", depth.toString());
+ return this;
+ }
+ @Override
+ public SimpleUri nodesOnly(boolean nodesOnly) {
+ if (nodesOnly) {
+ this.internalURI.replaceQueryParam("nodes-only", "");
+ }
+ return this;
+ }
+
+ @Override
+ public SimpleUri format(Format format) {
+ this.internalURI.replaceQueryParam("format", format);
+ return this;
+ }
+
+ protected String getTemplate(GraphInventoryObjectType type) {
+ return type.uriTemplate();
+ }
+
+ protected String getTemplate(GraphInventoryObjectPlurals type) {
+ return type.uriTemplate();
+ }
+
+}
diff --git a/common/src/main/java/org/onap/so/client/graphinventory/entities/uri/parsers/UriParser.java b/common/src/main/java/org/onap/so/client/graphinventory/entities/uri/parsers/UriParser.java
new file mode 100644
index 0000000000..03d83ebfb6
--- /dev/null
+++ b/common/src/main/java/org/onap/so/client/graphinventory/entities/uri/parsers/UriParser.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.so.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/common/src/main/java/org/onap/so/client/graphinventory/entities/uri/parsers/UriParserSpringImpl.java b/common/src/main/java/org/onap/so/client/graphinventory/entities/uri/parsers/UriParserSpringImpl.java
new file mode 100644
index 0000000000..aeaa923d1b
--- /dev/null
+++ b/common/src/main/java/org/onap/so/client/graphinventory/entities/uri/parsers/UriParserSpringImpl.java
@@ -0,0 +1,68 @@
+/*-
+ * ============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.so.client.graphinventory.entities.uri.parsers;
+import java.io.UnsupportedEncodingException;
+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()) {
+ try {
+ result.put(entry.getKey(), UriUtils.decode(entry.getValue(), "UTF-8"));
+ } catch (UnsupportedEncodingException e) {
+ result.put(entry.getKey(), "");
+ }
+ }
+
+ return result;
+ }
+}
diff --git a/common/src/main/java/org/onap/so/client/graphinventory/exceptions/BulkProcessFailed.java b/common/src/main/java/org/onap/so/client/graphinventory/exceptions/BulkProcessFailed.java
new file mode 100644
index 0000000000..0c973a8457
--- /dev/null
+++ b/common/src/main/java/org/onap/so/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.so.client.graphinventory.exceptions;
+
+public class BulkProcessFailed extends Exception {
+
+ public BulkProcessFailed(String message) {
+ super(message);
+ }
+}
diff --git a/common/src/main/java/org/onap/so/client/graphinventory/exceptions/GraphInventoryPatchDepthExceededException.java b/common/src/main/java/org/onap/so/client/graphinventory/exceptions/GraphInventoryPatchDepthExceededException.java
new file mode 100644
index 0000000000..07af13049c
--- /dev/null
+++ b/common/src/main/java/org/onap/so/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.so.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/common/src/main/java/org/onap/so/client/graphinventory/exceptions/GraphInventoryPayloadException.java b/common/src/main/java/org/onap/so/client/graphinventory/exceptions/GraphInventoryPayloadException.java
new file mode 100644
index 0000000000..24a6e5ccf9
--- /dev/null
+++ b/common/src/main/java/org/onap/so/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.so.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/common/src/main/java/org/onap/so/client/graphinventory/exceptions/GraphInventoryUriComputationException.java b/common/src/main/java/org/onap/so/client/graphinventory/exceptions/GraphInventoryUriComputationException.java
new file mode 100644
index 0000000000..51747d495a
--- /dev/null
+++ b/common/src/main/java/org/onap/so/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.so.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/common/src/main/java/org/onap/so/client/graphinventory/exceptions/GraphInventoryUriNotFoundException.java b/common/src/main/java/org/onap/so/client/graphinventory/exceptions/GraphInventoryUriNotFoundException.java
new file mode 100644
index 0000000000..d2f47a5b00
--- /dev/null
+++ b/common/src/main/java/org/onap/so/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.so.client.graphinventory.exceptions;
+
+public class GraphInventoryUriNotFoundException extends Exception {
+ private static final long serialVersionUID = 2789643165122257833L;
+
+ public GraphInventoryUriNotFoundException(String message) {
+ super(message);
+ }
+}