From 8ec41ca447dcaa27daf1b3195412ff27d8f22d6d Mon Sep 17 00:00:00 2001 From: "Benjamin, Max" Date: Wed, 29 Apr 2020 16:18:28 -0400 Subject: rename package for external use rename package for external use Issue-ID: SO-2852 Signed-off-by: Benjamin, Max (mb388a) Change-Id: Id883f0c847c24a260dbf8c63ce5e1330c045d6de --- .../client/aai/entities/AAIEdgeLabel.java | 42 +++++ .../aaiclient/client/aai/entities/AAIEntity.java | 25 +++ .../client/aai/entities/AAIEntityObject.java | 29 ++++ .../aaiclient/client/aai/entities/AAIError.java | 44 ++++++ .../client/aai/entities/AAIResultWrapper.java | 45 ++++++ .../client/aai/entities/Configuration.java | 153 ++++++++++++++++++ .../aaiclient/client/aai/entities/CustomQuery.java | 79 ++++++++++ .../aaiclient/client/aai/entities/QueryStep.java | 28 ++++ .../client/aai/entities/Relationships.java | 74 +++++++++ .../client/aai/entities/RequestError.java | 44 ++++++ .../aaiclient/client/aai/entities/Results.java | 49 ++++++ .../client/aai/entities/ServiceException.java | 70 +++++++++ .../aai/entities/bulkprocess/OperationBody.java | 68 ++++++++ .../bulkprocess/OperationBodySerializer.java | 54 +++++++ .../aai/entities/bulkprocess/Transaction.java | 90 +++++++++++ .../aai/entities/bulkprocess/Transactions.java | 51 ++++++ .../singletransaction/OperationBodyRequest.java | 84 ++++++++++ .../OperationBodyRequestSerializer.java | 54 +++++++ .../singletransaction/OperationBodyResponse.java | 73 +++++++++ .../SingleTransactionRequest.java | 44 ++++++ .../SingleTransactionResponse.java | 46 ++++++ .../aai/entities/uri/AAIBaseResourceUri.java | 29 ++++ .../aai/entities/uri/AAIPluralResourceUri.java | 9 ++ .../client/aai/entities/uri/AAIResourceUri.java | 10 ++ .../aai/entities/uri/AAISimplePluralUri.java | 68 ++++++++ .../client/aai/entities/uri/AAISimpleUri.java | 73 +++++++++ .../aaiclient/client/aai/entities/uri/AAIUri.java | 32 ++++ .../client/aai/entities/uri/AAIUriFactory.java | 114 ++++++++++++++ .../entities/uri/AllottedResourceLookupUri.java | 54 +++++++ .../client/aai/entities/uri/HttpLookupUri.java | 174 +++++++++++++++++++++ .../client/aai/entities/uri/NodesPluralUri.java | 19 +++ .../client/aai/entities/uri/NodesSingleUri.java | 21 +++ .../client/aai/entities/uri/NodesUri.java | 26 +++ .../aai/entities/uri/ServiceInstanceUri.java | 54 +++++++ 34 files changed, 1929 insertions(+) create mode 100644 graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/aai/entities/AAIEdgeLabel.java create mode 100644 graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/aai/entities/AAIEntity.java create mode 100644 graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/aai/entities/AAIEntityObject.java create mode 100644 graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/aai/entities/AAIError.java create mode 100644 graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/aai/entities/AAIResultWrapper.java create mode 100644 graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/aai/entities/Configuration.java create mode 100644 graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/aai/entities/CustomQuery.java create mode 100644 graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/aai/entities/QueryStep.java create mode 100644 graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/aai/entities/Relationships.java create mode 100644 graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/aai/entities/RequestError.java create mode 100644 graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/aai/entities/Results.java create mode 100644 graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/aai/entities/ServiceException.java create mode 100644 graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/aai/entities/bulkprocess/OperationBody.java create mode 100644 graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/aai/entities/bulkprocess/OperationBodySerializer.java create mode 100644 graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/aai/entities/bulkprocess/Transaction.java create mode 100644 graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/aai/entities/bulkprocess/Transactions.java create mode 100644 graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/aai/entities/singletransaction/OperationBodyRequest.java create mode 100644 graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/aai/entities/singletransaction/OperationBodyRequestSerializer.java create mode 100644 graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/aai/entities/singletransaction/OperationBodyResponse.java create mode 100644 graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/aai/entities/singletransaction/SingleTransactionRequest.java create mode 100644 graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/aai/entities/singletransaction/SingleTransactionResponse.java create mode 100644 graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/aai/entities/uri/AAIBaseResourceUri.java create mode 100644 graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/aai/entities/uri/AAIPluralResourceUri.java create mode 100644 graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/aai/entities/uri/AAIResourceUri.java create mode 100644 graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/aai/entities/uri/AAISimplePluralUri.java create mode 100644 graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/aai/entities/uri/AAISimpleUri.java create mode 100644 graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/aai/entities/uri/AAIUri.java create mode 100644 graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/aai/entities/uri/AAIUriFactory.java create mode 100644 graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/aai/entities/uri/AllottedResourceLookupUri.java create mode 100644 graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/aai/entities/uri/HttpLookupUri.java create mode 100644 graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/aai/entities/uri/NodesPluralUri.java create mode 100644 graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/aai/entities/uri/NodesSingleUri.java create mode 100644 graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/aai/entities/uri/NodesUri.java create mode 100644 graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/aai/entities/uri/ServiceInstanceUri.java (limited to 'graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/aai/entities') diff --git a/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/aai/entities/AAIEdgeLabel.java b/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/aai/entities/AAIEdgeLabel.java new file mode 100644 index 0000000000..fdef5773ef --- /dev/null +++ b/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/aai/entities/AAIEdgeLabel.java @@ -0,0 +1,42 @@ +/*- + * ============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.aai.entities; + +import org.onap.aaiclient.client.graphinventory.entities.GraphInventoryEdgeLabel; + +public enum AAIEdgeLabel implements GraphInventoryEdgeLabel { + + BELONGS_TO("org.onap.relationships.inventory.BelongsTo"), + USES("org.onap.relationships.inventory.Uses"), + COMPOSED_OF("org.onap.relationships.inventory.ComposedOf"); + + private final String label; + + private AAIEdgeLabel(String label) { + this.label = label; + } + + + @Override + public String toString() { + return this.label; + } +} diff --git a/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/aai/entities/AAIEntity.java b/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/aai/entities/AAIEntity.java new file mode 100644 index 0000000000..bac3462dc3 --- /dev/null +++ b/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/aai/entities/AAIEntity.java @@ -0,0 +1,25 @@ +/*- + * ============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.aai.entities; + +public class AAIEntity { + +} diff --git a/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/aai/entities/AAIEntityObject.java b/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/aai/entities/AAIEntityObject.java new file mode 100644 index 0000000000..92790e23be --- /dev/null +++ b/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/aai/entities/AAIEntityObject.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.aai.entities; + +import org.onap.aaiclient.client.aai.entities.uri.AAIResourceUri; + +public interface AAIEntityObject { + + public AAIResourceUri getUri(); + +} diff --git a/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/aai/entities/AAIError.java b/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/aai/entities/AAIError.java new file mode 100644 index 0000000000..51c87d07dd --- /dev/null +++ b/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/aai/entities/AAIError.java @@ -0,0 +1,44 @@ +/*- + * ============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.aai.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({"requestError"}) +public class AAIError { + + @JsonProperty("requestError") + private RequestError requestError; + + @JsonProperty("requestError") + public RequestError getRequestError() { + return requestError; + } + + @JsonProperty("requestError") + public void setRequestError(RequestError requestError) { + this.requestError = requestError; + } + +} diff --git a/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/aai/entities/AAIResultWrapper.java b/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/aai/entities/AAIResultWrapper.java new file mode 100644 index 0000000000..baa95fbc28 --- /dev/null +++ b/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/aai/entities/AAIResultWrapper.java @@ -0,0 +1,45 @@ +/*- + * ============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.aai.entities; + +import java.io.Serializable; +import org.onap.aaiclient.client.graphinventory.entities.GraphInventoryResultWrapper; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +public class AAIResultWrapper extends GraphInventoryResultWrapper implements Serializable { + + private static final long serialVersionUID = 5895841925807816737L; + private final static transient Logger logger = LoggerFactory.getLogger(AAIResultWrapper.class); + + public AAIResultWrapper(String json) { + super(json, logger); + } + + public AAIResultWrapper(Object aaiObject) { + super(aaiObject, logger); + } + + @Override + protected Relationships createRelationships(String json) { + return new Relationships(json); + } +} diff --git a/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/aai/entities/Configuration.java b/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/aai/entities/Configuration.java new file mode 100644 index 0000000000..335558f9c1 --- /dev/null +++ b/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/aai/entities/Configuration.java @@ -0,0 +1,153 @@ +/*- + * ============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.aai.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({"configuration-id", "configuration-type", "configuration-sub-type", "model-invariant-id", + "model-version-id", "orchestration-status", "operational-status", "configuration-selflink", + "model-customization-id"}) +public class Configuration { + + @JsonProperty("configuration-id") + private String configurationId; + @JsonProperty("configuration-name") + private String configurationName; + @JsonProperty("configuration-type") + private String configurationType; + @JsonProperty("configuration-sub-type") + private String configurationSubType; + @JsonProperty("model-invariant-id") + private String modelInvariantId; + @JsonProperty("model-version-id") + private String modelVersionId; + @JsonProperty("orchestration-status") + private String orchestrationStatus; + @JsonProperty("operational-status") + private String operationalStatus; + @JsonProperty("configuration-selflink") + private String configurationSelflink; + @JsonProperty("model-customization-id") + private String modelCustomizationId; + + @JsonProperty("configuration-id") + public String getConfigurationId() { + return configurationId; + } + + @JsonProperty("configuration-id") + public void setConfigurationId(String configurationId) { + this.configurationId = configurationId; + } + + @JsonProperty("configuration-name") + public String getConfigurationName() { + return configurationName; + } + + @JsonProperty("configuration-name") + public void setConfigurationName(String configurationName) { + this.configurationName = configurationName; + } + + @JsonProperty("configuration-type") + public String getConfigurationType() { + return configurationType; + } + + @JsonProperty("configuration-type") + public void setConfigurationType(String configurationType) { + this.configurationType = configurationType; + } + + @JsonProperty("configuration-sub-type") + public String getConfigurationSubType() { + return configurationSubType; + } + + @JsonProperty("configuration-sub-type") + public void setConfigurationSubType(String configurationSubType) { + this.configurationSubType = configurationSubType; + } + + @JsonProperty("model-invariant-id") + public String getModelInvariantId() { + return modelInvariantId; + } + + @JsonProperty("model-invariant-id") + public void setModelInvariantId(String modelInvariantId) { + this.modelInvariantId = modelInvariantId; + } + + @JsonProperty("model-version-id") + public String getModelVersionId() { + return modelVersionId; + } + + @JsonProperty("model-version-id") + public void setModelVersionId(String modelVersionId) { + this.modelVersionId = modelVersionId; + } + + @JsonProperty("orchestration-status") + public String getOrchestrationStatus() { + return orchestrationStatus; + } + + @JsonProperty("orchestration-status") + public void setOrchestrationStatus(String orchestrationStatus) { + this.orchestrationStatus = orchestrationStatus; + } + + @JsonProperty("operational-status") + public String getOperationalStatus() { + return operationalStatus; + } + + @JsonProperty("operational-status") + public void setOperationalStatus(String operationalStatus) { + this.operationalStatus = operationalStatus; + } + + @JsonProperty("model-customization-id") + public String getModelCustomizationId() { + return modelCustomizationId; + } + + @JsonProperty("model-customization-id") + public void setModelCustomizationId(String modelCustomizationId) { + this.modelCustomizationId = modelCustomizationId; + } + + @JsonProperty("configuration-selflink") + public String getConfigurationSelflink() { + return configurationSelflink; + } + + @JsonProperty("configuration-selflink") + public void setConfigurationSelflink(String configurationSelflink) { + this.configurationSelflink = configurationSelflink; + } +} diff --git a/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/aai/entities/CustomQuery.java b/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/aai/entities/CustomQuery.java new file mode 100644 index 0000000000..7363ba7796 --- /dev/null +++ b/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/aai/entities/CustomQuery.java @@ -0,0 +1,79 @@ +/*- + * ============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.aai.entities; + +import java.io.UnsupportedEncodingException; +import java.util.ArrayList; +import java.util.List; +import org.onap.aaiclient.client.aai.entities.uri.AAIResourceUri; +import com.fasterxml.jackson.annotation.JsonInclude; + + +@JsonInclude(JsonInclude.Include.NON_NULL) +public class CustomQuery { + + private List start; + private String query; + private String gremlin; + + public CustomQuery(List start) { + this.setStart(start); + } + + public CustomQuery(List start, String query) { + this.setStart(start); + this.query = "query/" + query; + } + + public CustomQuery(String gremlin) throws UnsupportedEncodingException { + this.gremlin = gremlin; + } + + public String getGremlin() { + return gremlin; + } + + public void setGremlin(String gremlin) { + this.gremlin = gremlin; + } + + public List getStart() { + return start; + } + + public void setStart(List start) { + this.start = this.mapUris(start); + } + + public String getQuery() { + return query; + } + + public void setQuery(String query) { + this.query = query; + } + + private List mapUris(List uris) { + final List result = new ArrayList<>(); + uris.stream().map(item -> item.build().toString()).forEach(result::add); + return result; + } +} diff --git a/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/aai/entities/QueryStep.java b/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/aai/entities/QueryStep.java new file mode 100644 index 0000000000..cbca20f37b --- /dev/null +++ b/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/aai/entities/QueryStep.java @@ -0,0 +1,28 @@ +/*- + * ============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.aai.entities; + +@FunctionalInterface +public interface QueryStep { + + + public String build(); +} diff --git a/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/aai/entities/Relationships.java b/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/aai/entities/Relationships.java new file mode 100644 index 0000000000..fb205310fc --- /dev/null +++ b/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/aai/entities/Relationships.java @@ -0,0 +1,74 @@ +/*- + * ============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.aai.entities; + +import java.util.List; +import javax.ws.rs.core.UriBuilder; +import org.onap.aaiclient.client.aai.AAIObjectType; +import org.onap.aaiclient.client.aai.AAIResourcesClient; +import org.onap.aaiclient.client.aai.entities.uri.AAIResourceUri; +import org.onap.aaiclient.client.aai.entities.uri.AAIUriFactory; +import org.onap.aaiclient.client.graphinventory.GraphInventoryObjectName; +import org.onap.aaiclient.client.graphinventory.entities.GraphInventoryRelationships; + +public class Relationships extends GraphInventoryRelationships { + + public Relationships(String json) { + super(json); + } + + @Deprecated + /** + * Use getRelatedUris instead + * + * @return + */ + public List getRelatedAAIUris() { + return this.getRelatedUris(); + } + + @Deprecated + /** + * Use getRelatedUris instead + * + * @return + */ + public List getRelatedAAIUris(GraphInventoryObjectName type) { + return this.getRelatedUris(type); + } + + + protected AAIResultWrapper get(AAIResourceUri uri) { + return new AAIResourcesClient().get(uri); + + } + + @Override + protected AAIResourceUri createUri(AAIObjectType type, String relatedLink) { + + return AAIUriFactory.createResourceFromExistingURI(type, UriBuilder.fromPath(relatedLink).build()); + } + + @Override + protected AAIObjectType fromTypeName(String name) { + return AAIObjectType.fromTypeName(name); + } +} diff --git a/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/aai/entities/RequestError.java b/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/aai/entities/RequestError.java new file mode 100644 index 0000000000..3caabf52f4 --- /dev/null +++ b/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/aai/entities/RequestError.java @@ -0,0 +1,44 @@ +/*- + * ============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.aai.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({"serviceException"}) +public class RequestError { + + @JsonProperty("serviceException") + private ServiceException serviceException; + + @JsonProperty("serviceException") + public ServiceException getServiceException() { + return serviceException; + } + + @JsonProperty("serviceException") + public void setServiceException(ServiceException serviceException) { + this.serviceException = serviceException; + } + +} diff --git a/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/aai/entities/Results.java b/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/aai/entities/Results.java new file mode 100644 index 0000000000..57312176c2 --- /dev/null +++ b/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/aai/entities/Results.java @@ -0,0 +1,49 @@ +/*- + * ============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.aai.entities; + +import java.util.ArrayList; +import java.util.List; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; + + + +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonPropertyOrder({"results"}) +public class Results { + @JsonProperty("results") + protected List results; + + @JsonProperty("results") + public List getResult() { + if (results == null) { + results = new ArrayList<>(); + } + return this.results; + } + + @JsonProperty("results") + public void setResult(List results) { + this.results = results; + } +} diff --git a/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/aai/entities/ServiceException.java b/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/aai/entities/ServiceException.java new file mode 100644 index 0000000000..81dbbed652 --- /dev/null +++ b/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/aai/entities/ServiceException.java @@ -0,0 +1,70 @@ +/*- + * ============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.aai.entities; + +import java.util.ArrayList; +import java.util.List; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; + +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonPropertyOrder({"messageId", "text", "variables"}) +public class ServiceException { + + @JsonProperty("messageId") + private String messageId; + @JsonProperty("text") + private String text; + @JsonProperty("variables") + private List variables = new ArrayList<>(); + + @JsonProperty("messageId") + public String getMessageId() { + return messageId; + } + + @JsonProperty("messageId") + public void setMessageId(String messageId) { + this.messageId = messageId; + } + + @JsonProperty("text") + public String getText() { + return text; + } + + @JsonProperty("text") + public void setText(String text) { + this.text = text; + } + + @JsonProperty("variables") + public List getVariables() { + return variables; + } + + @JsonProperty("variables") + public void setVariables(List variables) { + this.variables = variables; + } + +} diff --git a/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/aai/entities/bulkprocess/OperationBody.java b/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/aai/entities/bulkprocess/OperationBody.java new file mode 100644 index 0000000000..e886425696 --- /dev/null +++ b/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/aai/entities/bulkprocess/OperationBody.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.aaiclient.client.aai.entities.bulkprocess; + +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import com.fasterxml.jackson.databind.annotation.JsonSerialize; + +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonPropertyOrder({"uri", "body"}) +public class OperationBody { + + @JsonProperty("uri") + private String uri; + @JsonProperty("body") + @JsonSerialize(using = OperationBodySerializer.class) + private Object body; + + @JsonProperty("uri") + public String getUri() { + return uri; + } + + @JsonProperty("uri") + public void setUri(String uri) { + this.uri = uri; + } + + public OperationBody withUri(String uri) { + this.uri = uri; + return this; + } + + @JsonProperty("body") + public Object getBody() { + return body; + } + + @JsonProperty("body") + public void setBody(Object body) { + this.body = body; + } + + public OperationBody withBody(Object body) { + this.body = body; + return this; + } + +} diff --git a/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/aai/entities/bulkprocess/OperationBodySerializer.java b/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/aai/entities/bulkprocess/OperationBodySerializer.java new file mode 100644 index 0000000000..11cd6e1ea4 --- /dev/null +++ b/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/aai/entities/bulkprocess/OperationBodySerializer.java @@ -0,0 +1,54 @@ +/*- + * ============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.aai.entities.bulkprocess; + +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 OperationBodySerializer extends StdSerializer { + + private static final long serialVersionUID = 5367385969270400106L; + + public OperationBodySerializer() { + this(null); + } + + public OperationBodySerializer(Class t) { + super(t); + } + + @Override + public void serialize(Object value, JsonGenerator gen, SerializerProvider serializers) + throws IOException, JsonProcessingException { + + if (value instanceof String) { + gen.writeRawValue((String) value); + } else { + gen.writeObject(value); + } + + } + +} + diff --git a/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/aai/entities/bulkprocess/Transaction.java b/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/aai/entities/bulkprocess/Transaction.java new file mode 100644 index 0000000000..2c32c1b0ca --- /dev/null +++ b/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/aai/entities/bulkprocess/Transaction.java @@ -0,0 +1,90 @@ +/*- + * ============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.aai.entities.bulkprocess; + +import java.util.ArrayList; +import java.util.List; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; + +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonPropertyOrder({"patch", "patch", "delete"}) +public class Transaction { + + @JsonInclude(JsonInclude.Include.NON_EMPTY) + @JsonProperty("put") + private List put = new ArrayList<>(); + + @JsonInclude(JsonInclude.Include.NON_EMPTY) + @JsonProperty("patch") + private List patch = new ArrayList<>(); + + @JsonInclude(JsonInclude.Include.NON_EMPTY) + @JsonProperty("delete") + private List delete = new ArrayList<>(); + + @JsonProperty("put") + public List getPut() { + return put; + } + + @JsonProperty("put") + public void setPut(List put) { + this.put = put; + } + + public Transaction withPut(List put) { + this.put = put; + return this; + } + + @JsonProperty("patch") + public List getPatch() { + return patch; + } + + @JsonProperty("patch") + public void setPatch(List patch) { + this.patch = patch; + } + + public Transaction withPatch(List patch) { + this.patch = patch; + return this; + } + + @JsonProperty("delete") + public List getDelete() { + return delete; + } + + @JsonProperty("delete") + public void setDelete(List delete) { + this.delete = delete; + } + + public Transaction withDelete(List delete) { + this.delete = delete; + return this; + } + +} diff --git a/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/aai/entities/bulkprocess/Transactions.java b/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/aai/entities/bulkprocess/Transactions.java new file mode 100644 index 0000000000..7d31085b71 --- /dev/null +++ b/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/aai/entities/bulkprocess/Transactions.java @@ -0,0 +1,51 @@ +/*- + * ============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.aai.entities.bulkprocess; + +import java.util.ArrayList; +import java.util.List; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; + +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonPropertyOrder({"transactions"}) +public class Transactions { + + @JsonProperty("transactions") + private List transactions = new ArrayList<>(); + + @JsonProperty("transactions") + public List getTransactions() { + return transactions; + } + + @JsonProperty("transactions") + public void setTransactions(List transactions) { + this.transactions = transactions; + } + + public Transactions withTransactions(List transactions) { + this.transactions = transactions; + return this; + } + +} diff --git a/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/aai/entities/singletransaction/OperationBodyRequest.java b/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/aai/entities/singletransaction/OperationBodyRequest.java new file mode 100644 index 0000000000..25aff9fb4a --- /dev/null +++ b/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/aai/entities/singletransaction/OperationBodyRequest.java @@ -0,0 +1,84 @@ +/*- + * ============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.aai.entities.singletransaction; + +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import com.fasterxml.jackson.databind.annotation.JsonSerialize; + +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonPropertyOrder({"action", "uri", "body"}) +public class OperationBodyRequest { + + @JsonProperty("action") + private String action; + @JsonProperty("uri") + private String uri; + @JsonProperty("body") + @JsonSerialize(using = OperationBodyRequestSerializer.class) + private Object body; + + + public String getAction() { + return action; + } + + public void setAction(String action) { + this.action = action; + } + + public OperationBodyRequest withAction(String action) { + this.action = action; + return this; + } + + @JsonProperty("uri") + public String getUri() { + return uri; + } + + @JsonProperty("uri") + public void setUri(String uri) { + this.uri = uri; + } + + public OperationBodyRequest withUri(String uri) { + this.uri = uri; + return this; + } + + @JsonProperty("body") + public Object getBody() { + return body; + } + + @JsonProperty("body") + public void setBody(Object body) { + this.body = body; + } + + public OperationBodyRequest withBody(Object body) { + this.body = body; + return this; + } + +} diff --git a/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/aai/entities/singletransaction/OperationBodyRequestSerializer.java b/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/aai/entities/singletransaction/OperationBodyRequestSerializer.java new file mode 100644 index 0000000000..5a8a2b6f73 --- /dev/null +++ b/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/aai/entities/singletransaction/OperationBodyRequestSerializer.java @@ -0,0 +1,54 @@ +/*- + * ============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.aai.entities.singletransaction; + +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 OperationBodyRequestSerializer extends StdSerializer { + + private static final long serialVersionUID = 5367385969270400106L; + + public OperationBodyRequestSerializer() { + this(null); + } + + public OperationBodyRequestSerializer(Class t) { + super(t); + } + + @Override + public void serialize(Object value, JsonGenerator gen, SerializerProvider serializers) + throws IOException, JsonProcessingException { + + if (value instanceof String) { + gen.writeRawValue((String) value); + } else { + gen.writeObject(value); + } + + } + +} + diff --git a/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/aai/entities/singletransaction/OperationBodyResponse.java b/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/aai/entities/singletransaction/OperationBodyResponse.java new file mode 100644 index 0000000000..165806fdfa --- /dev/null +++ b/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/aai/entities/singletransaction/OperationBodyResponse.java @@ -0,0 +1,73 @@ +/*- + * ============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.aai.entities.singletransaction; + +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; + +@JsonPropertyOrder({"action", "uri", "response-status-code", "response-body"}) +public class OperationBodyResponse { + + @JsonProperty("action") + public String action; + @JsonProperty("uri") + public String uri; + @JsonProperty("response-status-code") + public Integer responseStatusCode; + @JsonProperty("response-body") + public Object responseBody; + + public String getAction() { + return action; + } + + public void setAction(String action) { + this.action = action; + } + + public String getUri() { + return uri; + } + + public void setUri(String uri) { + this.uri = uri; + } + + @JsonProperty("response-status-code") + public Integer getResponseStatusCode() { + return responseStatusCode; + } + + @JsonProperty("response-status-code") + public void setResponseStatusCode(Integer responseStatusCode) { + this.responseStatusCode = responseStatusCode; + } + + @JsonProperty("response-body") + public Object getResponseBody() { + return responseBody; + } + + @JsonProperty("response-body") + public void getResponseBody(Object responseBody) { + this.responseBody = responseBody; + } +} diff --git a/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/aai/entities/singletransaction/SingleTransactionRequest.java b/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/aai/entities/singletransaction/SingleTransactionRequest.java new file mode 100644 index 0000000000..c279c18dd7 --- /dev/null +++ b/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/aai/entities/singletransaction/SingleTransactionRequest.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.aaiclient.client.aai.entities.singletransaction; + +import java.util.ArrayList; +import java.util.List; +import com.fasterxml.jackson.annotation.JsonProperty; + +public class SingleTransactionRequest { + + @JsonProperty("operations") + public List operations; + + public List getOperations() { + + if (operations == null) { + operations = new ArrayList<>(); + } + + return operations; + } + + public void setOperations(List operations) { + this.operations = operations; + } +} diff --git a/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/aai/entities/singletransaction/SingleTransactionResponse.java b/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/aai/entities/singletransaction/SingleTransactionResponse.java new file mode 100644 index 0000000000..ac4eb2c82f --- /dev/null +++ b/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/aai/entities/singletransaction/SingleTransactionResponse.java @@ -0,0 +1,46 @@ +/*- + * ============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.aai.entities.singletransaction; + +import java.util.ArrayList; +import java.util.List; +import com.fasterxml.jackson.annotation.JsonProperty; + +public class SingleTransactionResponse { + + @JsonProperty("operation-responses") + public List operationResponses; + + @JsonProperty("operation-responses") + public List getOperationResponses() { + if (operationResponses == null) { + operationResponses = new ArrayList<>(); + } + return operationResponses; + } + + @JsonProperty("operation-responses") + public void setOperationResponses(List operationResponses) { + this.operationResponses = operationResponses; + } + + +} diff --git a/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/aai/entities/uri/AAIBaseResourceUri.java b/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/aai/entities/uri/AAIBaseResourceUri.java new file mode 100644 index 0000000000..e933ffd339 --- /dev/null +++ b/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/aai/entities/uri/AAIBaseResourceUri.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.aai.entities.uri; + +import org.onap.aaiclient.client.aai.AAIObjectBase; +import org.onap.aaiclient.client.graphinventory.entities.uri.GraphInventoryResourceUri; + +public interface AAIBaseResourceUri, OT extends AAIObjectBase> + extends AAIUri, GraphInventoryResourceUri { + +} diff --git a/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/aai/entities/uri/AAIPluralResourceUri.java b/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/aai/entities/uri/AAIPluralResourceUri.java new file mode 100644 index 0000000000..0d41e1df02 --- /dev/null +++ b/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/aai/entities/uri/AAIPluralResourceUri.java @@ -0,0 +1,9 @@ +package org.onap.aaiclient.client.aai.entities.uri; + +import org.onap.aaiclient.client.aai.AAIObjectPlurals; +import org.onap.aaiclient.client.graphinventory.entities.uri.GraphInventoryPluralResourceUri; + +public interface AAIPluralResourceUri extends AAIBaseResourceUri, + GraphInventoryPluralResourceUri { + +} diff --git a/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/aai/entities/uri/AAIResourceUri.java b/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/aai/entities/uri/AAIResourceUri.java new file mode 100644 index 0000000000..3d01258f71 --- /dev/null +++ b/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/aai/entities/uri/AAIResourceUri.java @@ -0,0 +1,10 @@ +package org.onap.aaiclient.client.aai.entities.uri; + +import org.onap.aaiclient.client.aai.AAIObjectPlurals; +import org.onap.aaiclient.client.aai.AAIObjectType; +import org.onap.aaiclient.client.graphinventory.entities.uri.GraphInventorySingleResourceUri; + +public interface AAIResourceUri extends AAIBaseResourceUri, + GraphInventorySingleResourceUri { + +} diff --git a/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/aai/entities/uri/AAISimplePluralUri.java b/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/aai/entities/uri/AAISimplePluralUri.java new file mode 100644 index 0000000000..67ce0962dc --- /dev/null +++ b/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/aai/entities/uri/AAISimplePluralUri.java @@ -0,0 +1,68 @@ +/*- + * ============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.aai.entities.uri; + +import javax.ws.rs.core.UriBuilder; +import org.onap.aaiclient.client.aai.AAIObjectPlurals; +import org.onap.aaiclient.client.aai.AAIObjectType; +import org.onap.aaiclient.client.graphinventory.entities.uri.SimplePluralUri; + +public class AAISimplePluralUri + extends SimplePluralUri + implements AAIPluralResourceUri { + + private static final long serialVersionUID = -6397024057188453229L; + + protected AAISimplePluralUri(AAIObjectPlurals type, UriBuilder builder, Object... values) { + super(type, builder, values); + } + + protected AAISimplePluralUri(AAIObjectPlurals type) { + super(type); + } + + protected AAISimplePluralUri(AAIObjectPlurals type, Object... values) { + super(type, values); + } + + protected AAISimplePluralUri(AAIObjectPlurals type, AAIResourceUri uri) { + super(type, uri); + } + + protected AAISimplePluralUri(AAIResourceUri parentUri, AAIObjectPlurals childType) { + super(parentUri, childType); + } + + protected AAISimplePluralUri(AAISimplePluralUri copy) { + super(copy); + } + + @Override + public AAISimplePluralUri clone() { + return new AAISimplePluralUri(this); + } + + @Override + public AAIObjectPlurals getObjectType() { + return this.pluralType; + } + +} diff --git a/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/aai/entities/uri/AAISimpleUri.java b/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/aai/entities/uri/AAISimpleUri.java new file mode 100644 index 0000000000..40184b028b --- /dev/null +++ b/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/aai/entities/uri/AAISimpleUri.java @@ -0,0 +1,73 @@ +/*- + * ============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.aai.entities.uri; + +import java.net.URI; +import javax.ws.rs.core.UriBuilder; +import org.onap.aaiclient.client.aai.AAIObjectPlurals; +import org.onap.aaiclient.client.aai.AAIObjectType; +import org.onap.aaiclient.client.graphinventory.entities.uri.SimpleUri; + +public class AAISimpleUri extends SimpleUri + implements AAIResourceUri { + + private static final long serialVersionUID = -6397024057188453229L; + + protected AAISimpleUri(AAIObjectType type, Object... values) { + super(type, values); + + } + + protected AAISimpleUri(AAIObjectType type, URI uri) { + super(type, uri); + } + + protected AAISimpleUri(AAIObjectType type, UriBuilder builder, Object... values) { + super(type, builder, values); + } + + protected AAISimpleUri(AAIResourceUri parentUri, AAIObjectType childType, Object... childValues) { + super(parentUri, childType, childValues); + } + + // copy constructor + protected AAISimpleUri(AAISimpleUri copy) { + super(copy); + } + + @Override + public AAISimpleUri clone() { + return new AAISimpleUri(this); + } + + @Override + public AAISimpleUri relatedTo(AAIObjectType type, String... values) { + this.internalURI = internalURI.path(relatedTo); + return new AAISimpleUri(this, type, values); + } + + @Override + public AAISimplePluralUri relatedTo(AAIObjectPlurals plural) { + this.internalURI.path(relatedTo); + return new AAISimplePluralUri(this, plural); + } + +} diff --git a/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/aai/entities/uri/AAIUri.java b/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/aai/entities/uri/AAIUri.java new file mode 100644 index 0000000000..662a1ab37b --- /dev/null +++ b/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/aai/entities/uri/AAIUri.java @@ -0,0 +1,32 @@ +/*- + * ============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.aai.entities.uri; + +import java.util.regex.Pattern; +import org.onap.aaiclient.client.aai.AAIObjectBase; +import org.onap.aaiclient.client.graphinventory.entities.uri.GraphInventoryUri; + +public interface AAIUri, OP extends AAIObjectBase> extends GraphInventoryUri { + + public default Pattern getPrefixPattern() { + return Pattern.compile("/aai/v\\d+"); + } +} diff --git a/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/aai/entities/uri/AAIUriFactory.java b/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/aai/entities/uri/AAIUriFactory.java new file mode 100644 index 0000000000..31b55958d6 --- /dev/null +++ b/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/aai/entities/uri/AAIUriFactory.java @@ -0,0 +1,114 @@ +/*- + * ============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.aai.entities.uri; + +import java.net.URI; +import org.onap.aaiclient.client.aai.AAIObjectPlurals; +import org.onap.aaiclient.client.aai.AAIObjectType; + + +public class AAIUriFactory { + + /** + * values are filled into the URI template specified in {@link AAIObjectType} in order
+ * There are two special lookups performed on certain types when a single value is specified:
+ * Service Instance and AllottedResources
+ * These can be retrieved without all their required keys but an HTTP call is required to do so + * + * @param type + * @param values + * @return + */ + public static AAIResourceUri createResourceUri(AAIObjectType type, Object... values) { + if (AAIObjectType.SERVICE_INSTANCE.equals(type)) { + return new ServiceInstanceUri(values); + } else if (AAIObjectType.ALLOTTED_RESOURCE.equals(type)) { + return new AllottedResourceLookupUri(values); + } else { + return new AAISimpleUri(type, values); + } + } + + public static NodesSingleUri createNodesUri(AAIObjectType type, Object... values) { + return new NodesSingleUri(type, values); + + } + + public static NodesPluralUri createNodesUri(AAIObjectPlurals type) { + return new NodesPluralUri(type); + + } + + /** + * This method should only be used to wrap a URI retrieved from A&AI contained within an object response + * + * @param type + * @param uri + * @return + */ + public static AAISimpleUri createResourceFromExistingURI(AAIObjectType type, URI uri) { + return new AAISimpleUri(type, uri); + } + + + /** + * creates an AAIResourceUri from a parentUri + * + * @param parentUri + * @param childType + * @param childValues + * @return + */ + public static AAISimpleUri createResourceFromParentURI(AAIResourceUri parentUri, AAIObjectType childType, + Object... childValues) { + + return new AAISimpleUri(parentUri, childType, childValues); + } + + public static AAISimplePluralUri createResourceFromParentURI(AAIResourceUri parentUri, AAIObjectPlurals childType) { + + return new AAISimplePluralUri(parentUri, childType); + } + + /** + * Creates a uri for a plural type e.g. /cloud-infrastructure/pservers + * + * @param type + * @return + */ + public static AAISimplePluralUri createResourceUri(AAIObjectPlurals type) { + + return new AAISimplePluralUri(type); + + } + + /** + * Creates a uri for a plural type with values e.g. /cloud-infrastructure/pservers + * + * @param type + * @return + */ + public static AAISimplePluralUri createResourceUri(AAIObjectPlurals type, Object... values) { + + return new AAISimplePluralUri(type, values); + + } +} diff --git a/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/aai/entities/uri/AllottedResourceLookupUri.java b/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/aai/entities/uri/AllottedResourceLookupUri.java new file mode 100644 index 0000000000..7f51835580 --- /dev/null +++ b/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/aai/entities/uri/AllottedResourceLookupUri.java @@ -0,0 +1,54 @@ +/*- + * ============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.aai.entities.uri; + +import java.net.URI; +import java.util.Optional; +import javax.ws.rs.core.UriBuilder; +import org.onap.aaiclient.client.aai.AAIObjectType; +import org.onap.aaiclient.client.aai.AAIResourcesClient; + +public class AllottedResourceLookupUri extends HttpLookupUri { + + private static final long serialVersionUID = -9212594383876793188L; + + protected AllottedResourceLookupUri(Object... values) { + super(AAIObjectType.ALLOTTED_RESOURCE, values); + } + + protected AllottedResourceLookupUri(UriBuilder builder, Optional cachedValue, Object... values) { + super(AAIObjectType.ALLOTTED_RESOURCE, builder, cachedValue, values); + } + + @Override + public AllottedResourceLookupUri clone() { + return new AllottedResourceLookupUri(this.internalURI.clone(), this.getCachedValue(), values); + } + + public AAIResourcesClient getResourcesClient() { + return new AAIResourcesClient(); + } + + @Override + public URI buildNoNetwork() { + return super.build(new String[] {"NONE", "NONE", "NONE", (String) this.values[0]}); + } +} diff --git a/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/aai/entities/uri/HttpLookupUri.java b/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/aai/entities/uri/HttpLookupUri.java new file mode 100644 index 0000000000..c39eb50dc2 --- /dev/null +++ b/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/aai/entities/uri/HttpLookupUri.java @@ -0,0 +1,174 @@ +/*- + * ============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.aai.entities.uri; + +import java.io.IOException; +import java.io.ObjectInputStream; +import java.io.ObjectOutputStream; +import java.net.URI; +import java.util.Map; +import java.util.Optional; +import javax.ws.rs.BadRequestException; +import javax.ws.rs.NotFoundException; +import javax.ws.rs.core.UriBuilder; +import org.onap.aaiclient.client.aai.AAIObjectType; +import org.onap.aaiclient.client.aai.AAIResourcesClient; +import org.onap.aaiclient.client.aai.entities.Results; +import org.onap.aaiclient.client.graphinventory.Format; +import org.onap.aaiclient.client.graphinventory.entities.Pathed; +import org.onap.aaiclient.client.graphinventory.entities.uri.HttpAwareUri; +import org.onap.aaiclient.client.graphinventory.exceptions.GraphInventoryPayloadException; +import org.onap.aaiclient.client.graphinventory.exceptions.GraphInventoryUriComputationException; +import org.onap.aaiclient.client.graphinventory.exceptions.GraphInventoryUriNotFoundException; +import org.onap.aaiclient.client.graphinventory.exceptions.IncorrectNumberOfUriKeys; +import com.fasterxml.jackson.core.type.TypeReference; +import com.fasterxml.jackson.databind.ObjectMapper; + +public abstract class HttpLookupUri extends AAISimpleUri implements HttpAwareUri { + + private transient Optional cachedValue = Optional.empty(); + private final AAIObjectType aaiType; + + protected HttpLookupUri(AAIObjectType type, Object... values) { + super(type, values); + this.aaiType = type; + } + + protected HttpLookupUri(AAIObjectType type, UriBuilder builder, Optional cachedValue, Object... values) { + super(type, builder, values); + this.cachedValue = cachedValue; + this.aaiType = type; + } + + protected String getObjectById(Object id) + throws GraphInventoryUriNotFoundException, GraphInventoryPayloadException { + if (!this.getCachedValue().isPresent()) { + AAIResourceUri serviceInstanceUri = AAIUriFactory.createNodesUri(aaiType, id).format(Format.PATHED); + String resultJson; + try { + resultJson = this.getResourcesClient().get(serviceInstanceUri, NotFoundException.class).getJson(); + } catch (BadRequestException e) { + throw new GraphInventoryUriNotFoundException( + aaiType.typeName() + " " + id + " not found at: " + serviceInstanceUri.build()); + + } + try { + cachedValue = extractRelatedLink(resultJson); + if (!cachedValue.isPresent()) { + throw new GraphInventoryUriNotFoundException( + aaiType.typeName() + " " + id + " not found at: " + serviceInstanceUri.build()); + } + } catch (IOException e) { + throw new GraphInventoryPayloadException("could not map payload: " + resultJson, e); + } + } + return cachedValue.get(); + } + + protected Optional extractRelatedLink(String jsonString) throws IOException { + Optional result; + ObjectMapper mapper = new ObjectMapper(); + + Results results = mapper.readValue(jsonString, new TypeReference>() {}); + if (results.getResult().size() == 1) { + String uriString = results.getResult().get(0).getResourceLink(); + URI uri = UriBuilder.fromUri(uriString).build(); + String rawPath = uri.getRawPath(); + result = Optional.of(rawPath.replaceAll("/aai/v\\d+", "")); + } else if (results.getResult().isEmpty()) { + result = Optional.empty(); + } else { + throw new IllegalStateException("more than one result returned"); + } + + return result; + } + + protected Optional getCachedValue() { + return this.cachedValue; + } + + @Override + public URI build() { + try { + if (this.values.length == 1) { + String uri = getObjectById(this.values[0]); + Map map = super.getURIKeys(uri); + this.values = map.values().toArray(values); + return super.build(values); + } + } catch (GraphInventoryUriNotFoundException | GraphInventoryPayloadException e) { + throw new GraphInventoryUriComputationException(e); + } + return super.build(); + } + + @Override + public URI locateAndBuild() { + try { + if (this.values.length == 1) { + String uri = getObjectById(this.values[0]); + Map map = super.getURIKeys(uri); + this.values = map.values().toArray(values); + return super.build(values); + } + } catch (GraphInventoryUriNotFoundException | GraphInventoryPayloadException e) { + throw new GraphInventoryUriComputationException(e); + } + return super.build(); + } + + @Override + public abstract HttpLookupUri clone(); + + @Override + public void validateValuesSize(String template, Object... values) { + try { + super.validateValuesSize(template, values); + } catch (IncorrectNumberOfUriKeys e) { + if (values.length == 1) { + // Special case where we perform an http look up + } else { + throw e; + } + } + } + + public AAIResourcesClient getResourcesClient() { + return new AAIResourcesClient(); + } + + private void writeObject(ObjectOutputStream oos) throws IOException { + + oos.writeUTF(this.cachedValue.orElse("")); + } + + private void readObject(ObjectInputStream ois) throws IOException { + + String value = ois.readUTF(); + if ("".equals(value)) { + this.cachedValue = Optional.empty(); + } else { + this.cachedValue = Optional.ofNullable(value); + } + + } +} diff --git a/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/aai/entities/uri/NodesPluralUri.java b/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/aai/entities/uri/NodesPluralUri.java new file mode 100644 index 0000000000..80032fe9fd --- /dev/null +++ b/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/aai/entities/uri/NodesPluralUri.java @@ -0,0 +1,19 @@ +package org.onap.aaiclient.client.aai.entities.uri; + +import javax.ws.rs.core.UriBuilder; +import org.onap.aaiclient.client.aai.AAIObjectPlurals; +import org.onap.aaiclient.client.graphinventory.GraphInventoryObjectBase; + +public class NodesPluralUri extends AAISimplePluralUri implements NodesUri { + + private static final long serialVersionUID = -6743170679667245998L; + + protected NodesPluralUri(AAIObjectPlurals type) { + super(type); + } + + @Override + public String getTemplate(GraphInventoryObjectBase type) { + return UriBuilder.fromUri("/nodes").path(type.partialUri()).toTemplate(); + } +} diff --git a/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/aai/entities/uri/NodesSingleUri.java b/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/aai/entities/uri/NodesSingleUri.java new file mode 100644 index 0000000000..8ec4df5848 --- /dev/null +++ b/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/aai/entities/uri/NodesSingleUri.java @@ -0,0 +1,21 @@ +package org.onap.aaiclient.client.aai.entities.uri; + +import javax.ws.rs.core.UriBuilder; +import org.onap.aaiclient.client.aai.AAIObjectType; +import org.onap.aaiclient.client.graphinventory.GraphInventoryObjectBase; + +public class NodesSingleUri extends AAISimpleUri implements NodesUri { + + private static final long serialVersionUID = 2721165364903444248L; + + protected NodesSingleUri(AAIObjectType type, Object... values) { + super(type, values); + } + + + @Override + public String getTemplate(GraphInventoryObjectBase type) { + return UriBuilder.fromUri("/nodes").path(type.partialUri()).toTemplate(); + } + +} diff --git a/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/aai/entities/uri/NodesUri.java b/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/aai/entities/uri/NodesUri.java new file mode 100644 index 0000000000..03f1a62462 --- /dev/null +++ b/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/aai/entities/uri/NodesUri.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.aai.entities.uri; + +public interface NodesUri { + + +} diff --git a/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/aai/entities/uri/ServiceInstanceUri.java b/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/aai/entities/uri/ServiceInstanceUri.java new file mode 100644 index 0000000000..96eaac5815 --- /dev/null +++ b/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/aai/entities/uri/ServiceInstanceUri.java @@ -0,0 +1,54 @@ +/*- + * ============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.aai.entities.uri; + +import java.net.URI; +import java.util.Optional; +import javax.ws.rs.core.UriBuilder; +import org.onap.aaiclient.client.aai.AAIObjectType; +import org.onap.aaiclient.client.aai.AAIResourcesClient; + +public class ServiceInstanceUri extends HttpLookupUri { + + private static final long serialVersionUID = 2248914170527514548L; + + protected ServiceInstanceUri(Object... values) { + super(AAIObjectType.SERVICE_INSTANCE, values); + } + + protected ServiceInstanceUri(UriBuilder builder, Optional cachedValue, Object... values) { + super(AAIObjectType.SERVICE_INSTANCE, builder, cachedValue, values); + } + + @Override + public ServiceInstanceUri clone() { + return new ServiceInstanceUri(this.internalURI.clone(), this.getCachedValue(), values); + } + + public AAIResourcesClient getResourcesClient() { + return new AAIResourcesClient(); + } + + @Override + public URI buildNoNetwork() { + return super.build(new String[] {"NONE", "NONE", (String) this.values[0]}); + } +} -- cgit 1.2.3-korg