summaryrefslogtreecommitdiffstats
path: root/common/src/main/java/org/onap/so/client/aai
diff options
context:
space:
mode:
Diffstat (limited to 'common/src/main/java/org/onap/so/client/aai')
-rw-r--r--common/src/main/java/org/onap/so/client/aai/AAIClient.java62
-rw-r--r--common/src/main/java/org/onap/so/client/aai/AAIClientResponseExceptionMapper.java63
-rw-r--r--common/src/main/java/org/onap/so/client/aai/AAICommonObjectMapperPatchProvider.java35
-rw-r--r--common/src/main/java/org/onap/so/client/aai/AAICommonObjectMapperProvider.java52
-rw-r--r--common/src/main/java/org/onap/so/client/aai/AAIConfigurationClient.java83
-rw-r--r--common/src/main/java/org/onap/so/client/aai/AAIErrorFormatter.java56
-rw-r--r--common/src/main/java/org/onap/so/client/aai/AAINamespaceConstants.java31
-rw-r--r--common/src/main/java/org/onap/so/client/aai/AAIObjectPlurals.java69
-rw-r--r--common/src/main/java/org/onap/so/client/aai/AAIObjectType.java104
-rw-r--r--common/src/main/java/org/onap/so/client/aai/AAIProperties.java34
-rw-r--r--common/src/main/java/org/onap/so/client/aai/AAIQueryClient.java83
-rw-r--r--common/src/main/java/org/onap/so/client/aai/AAIQueryObjectMapperProvider.java39
-rw-r--r--common/src/main/java/org/onap/so/client/aai/AAIResourcesClient.java254
-rw-r--r--common/src/main/java/org/onap/so/client/aai/AAIResourcesObjectMapperProvider.java29
-rw-r--r--common/src/main/java/org/onap/so/client/aai/AAIRestClient.java131
-rw-r--r--common/src/main/java/org/onap/so/client/aai/AAIRestClientI.java51
-rw-r--r--common/src/main/java/org/onap/so/client/aai/AAIRestClientImpl.java197
-rw-r--r--common/src/main/java/org/onap/so/client/aai/AAISubgraphType.java38
-rw-r--r--common/src/main/java/org/onap/so/client/aai/AAITransactionalClient.java264
-rw-r--r--common/src/main/java/org/onap/so/client/aai/AAIUpdator.java31
-rw-r--r--common/src/main/java/org/onap/so/client/aai/AAIUpdatorImpl.java51
-rw-r--r--common/src/main/java/org/onap/so/client/aai/AAIValidator.java32
-rw-r--r--common/src/main/java/org/onap/so/client/aai/AAIValidatorImpl.java71
-rw-r--r--common/src/main/java/org/onap/so/client/aai/AAIVersion.java44
-rw-r--r--common/src/main/java/org/onap/so/client/aai/EmptyStringToNullSerializer.java52
-rw-r--r--common/src/main/java/org/onap/so/client/aai/entities/AAIEntity.java25
-rw-r--r--common/src/main/java/org/onap/so/client/aai/entities/AAIEntityObject.java29
-rw-r--r--common/src/main/java/org/onap/so/client/aai/entities/AAIError.java46
-rw-r--r--common/src/main/java/org/onap/so/client/aai/entities/AAIResultWrapper.java92
-rw-r--r--common/src/main/java/org/onap/so/client/aai/entities/Configuration.java161
-rw-r--r--common/src/main/java/org/onap/so/client/aai/entities/CustomQuery.java82
-rw-r--r--common/src/main/java/org/onap/so/client/aai/entities/Relationships.java140
-rw-r--r--common/src/main/java/org/onap/so/client/aai/entities/RequestError.java46
-rw-r--r--common/src/main/java/org/onap/so/client/aai/entities/Results.java51
-rw-r--r--common/src/main/java/org/onap/so/client/aai/entities/ServiceException.java75
-rw-r--r--common/src/main/java/org/onap/so/client/aai/entities/bulkprocess/OperationBody.java69
-rw-r--r--common/src/main/java/org/onap/so/client/aai/entities/bulkprocess/Transaction.java95
-rw-r--r--common/src/main/java/org/onap/so/client/aai/entities/bulkprocess/Transactions.java54
-rw-r--r--common/src/main/java/org/onap/so/client/aai/entities/uri/AAIResourceUri.java46
-rw-r--r--common/src/main/java/org/onap/so/client/aai/entities/uri/AAISimpleUri.java111
-rw-r--r--common/src/main/java/org/onap/so/client/aai/entities/uri/AAIUri.java60
-rw-r--r--common/src/main/java/org/onap/so/client/aai/entities/uri/AAIUriFactory.java86
-rw-r--r--common/src/main/java/org/onap/so/client/aai/entities/uri/NodesUri.java43
-rw-r--r--common/src/main/java/org/onap/so/client/aai/entities/uri/ServiceInstanceUri.java126
-rw-r--r--common/src/main/java/org/onap/so/client/aai/objects/AAIOperationalEnvironment.java159
-rw-r--r--common/src/main/java/org/onap/so/client/aai/objects/AAIServiceInstance.java141
46 files changed, 3693 insertions, 0 deletions
diff --git a/common/src/main/java/org/onap/so/client/aai/AAIClient.java b/common/src/main/java/org/onap/so/client/aai/AAIClient.java
new file mode 100644
index 0000000000..39843b2263
--- /dev/null
+++ b/common/src/main/java/org/onap/so/client/aai/AAIClient.java
@@ -0,0 +1,62 @@
+/*-
+ * ============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.aai;
+
+import java.net.URI;
+
+import javax.ws.rs.core.UriBuilder;
+
+import org.onap.so.client.RestClient;
+import org.onap.so.client.graphinventory.GraphInventoryClient;
+import org.onap.so.client.graphinventory.entities.uri.GraphInventoryUri;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public abstract class AAIClient extends GraphInventoryClient {
+
+ private static final String AAI_ROOT = "/aai";
+ protected static Logger logger = LoggerFactory.getLogger(AAIClient.class);
+ protected AAIVersion version;
+ public AAIClient() {
+ super(AAIProperties.class);
+ }
+
+ public AAIClient(AAIVersion version) {
+ super(AAIProperties.class);
+ }
+ @Override
+ protected URI constructPath(GraphInventoryUri uri) {
+
+ return UriBuilder.fromUri(AAI_ROOT + "/" + this.getVersion().toString() + uri.build().toString()).build();
+ }
+ @Override
+ protected RestClient createClient(GraphInventoryUri uri) {
+ return new AAIRestClient(getRestProperties(), constructPath(uri));
+ }
+
+ protected AAIVersion getVersion() {
+ if (version == null) {
+ return this.<AAIProperties>getRestProperties().getDefaultVersion();
+ } else {
+ return this.version;
+ }
+ }
+}
diff --git a/common/src/main/java/org/onap/so/client/aai/AAIClientResponseExceptionMapper.java b/common/src/main/java/org/onap/so/client/aai/AAIClientResponseExceptionMapper.java
new file mode 100644
index 0000000000..514eab6fc4
--- /dev/null
+++ b/common/src/main/java/org/onap/so/client/aai/AAIClientResponseExceptionMapper.java
@@ -0,0 +1,63 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.so.client.aai;
+
+import java.io.IOException;
+import java.util.Optional;
+
+import javax.annotation.Priority;
+import javax.ws.rs.ext.Provider;
+
+import javax.annotation.Priority;
+import javax.ws.rs.ext.Provider;
+
+import org.onap.so.client.ResponseExceptionMapper;
+import org.onap.so.client.aai.entities.AAIError;
+import org.onap.so.logger.MsoLogger;
+import org.slf4j.MDC;
+
+import com.fasterxml.jackson.databind.ObjectMapper;
+
+@Provider
+@Priority(Integer.MIN_VALUE)
+public class AAIClientResponseExceptionMapper extends ResponseExceptionMapper {
+
+ private final String requestId;
+ public AAIClientResponseExceptionMapper() {
+ this.requestId = MDC.get(MsoLogger.REQUEST_ID);
+ }
+ @Override
+ public Optional<String> extractMessage(String entity) {
+
+ String errorString = "Error calling A&AI. Request-Id=" + this.getRequestId() + " ";
+ try {
+ AAIError error = new ObjectMapper().readValue(entity, AAIError.class);
+ AAIErrorFormatter formatter = new AAIErrorFormatter(error);
+ return Optional.of(errorString + formatter.getMessage());
+ } catch (IOException e) {
+ return Optional.of(errorString + entity);
+ }
+ }
+
+ protected String getRequestId() {
+ return this.requestId;
+ }
+}
diff --git a/common/src/main/java/org/onap/so/client/aai/AAICommonObjectMapperPatchProvider.java b/common/src/main/java/org/onap/so/client/aai/AAICommonObjectMapperPatchProvider.java
new file mode 100644
index 0000000000..33c9769400
--- /dev/null
+++ b/common/src/main/java/org/onap/so/client/aai/AAICommonObjectMapperPatchProvider.java
@@ -0,0 +1,35 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2017 - 2018 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.so.client.aai;
+
+import com.fasterxml.jackson.databind.module.SimpleModule;
+
+public class AAICommonObjectMapperPatchProvider extends AAICommonObjectMapperProvider {
+
+
+ public AAICommonObjectMapperPatchProvider() {
+ super();
+ EmptyStringToNullSerializer sp = new EmptyStringToNullSerializer();
+ SimpleModule emptyStringModule = new SimpleModule();
+ emptyStringModule.addSerializer(String.class, sp);
+ mapper.registerModule(emptyStringModule);
+ }
+}
diff --git a/common/src/main/java/org/onap/so/client/aai/AAICommonObjectMapperProvider.java b/common/src/main/java/org/onap/so/client/aai/AAICommonObjectMapperProvider.java
new file mode 100644
index 0000000000..0e2071842f
--- /dev/null
+++ b/common/src/main/java/org/onap/so/client/aai/AAICommonObjectMapperProvider.java
@@ -0,0 +1,52 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.so.client.aai;
+
+import org.onap.so.client.policy.CommonObjectMapperProvider;
+
+import com.fasterxml.jackson.annotation.JsonInclude;
+import com.fasterxml.jackson.annotation.JsonInclude.Include;
+import com.fasterxml.jackson.databind.AnnotationIntrospector;
+import com.fasterxml.jackson.databind.DeserializationFeature;
+import com.fasterxml.jackson.databind.MapperFeature;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.fasterxml.jackson.databind.SerializationFeature;
+import com.fasterxml.jackson.databind.introspect.JacksonAnnotationIntrospector;
+import com.fasterxml.jackson.databind.type.TypeFactory;
+import com.fasterxml.jackson.module.jaxb.JaxbAnnotationIntrospector;
+
+public class AAICommonObjectMapperProvider extends CommonObjectMapperProvider {
+
+ public AAICommonObjectMapperProvider() {
+ mapper = new ObjectMapper();
+ mapper.setSerializationInclusion(Include.NON_NULL);
+ mapper.setSerializationInclusion(JsonInclude.Include.NON_EMPTY);
+ mapper.enable(MapperFeature.USE_ANNOTATIONS);
+ mapper.configure(SerializationFeature.WRAP_ROOT_VALUE, false);
+ mapper.configure(DeserializationFeature.UNWRAP_ROOT_VALUE, false);
+ mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
+ AnnotationIntrospector aiJaxb = new JaxbAnnotationIntrospector(TypeFactory.defaultInstance());
+ AnnotationIntrospector aiJackson = new JacksonAnnotationIntrospector();
+ // first Jaxb, second Jackson annotations
+ mapper.setAnnotationIntrospector(AnnotationIntrospector.pair(aiJaxb, aiJackson));
+ }
+
+}
diff --git a/common/src/main/java/org/onap/so/client/aai/AAIConfigurationClient.java b/common/src/main/java/org/onap/so/client/aai/AAIConfigurationClient.java
new file mode 100644
index 0000000000..b29c8070c8
--- /dev/null
+++ b/common/src/main/java/org/onap/so/client/aai/AAIConfigurationClient.java
@@ -0,0 +1,83 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.so.client.aai;
+
+import org.onap.so.client.aai.entities.Configuration;
+import org.onap.so.client.aai.entities.uri.AAIResourceUri;
+import org.onap.so.client.aai.entities.uri.AAIUriFactory;
+import org.onap.so.serviceinstancebeans.RequestDetails;
+
+public class AAIConfigurationClient {
+
+ private AAIResourcesClient aaiClient;
+
+ private static final String ORCHESTRATION_STATUS = "PreCreated";
+
+ public AAIConfigurationClient() {
+ aaiClient = new AAIResourcesClient();
+ }
+
+ public void createConfiguration(RequestDetails requestDetails, String configurationId, String configurationType,
+ String configurationSubType) {
+
+ AAIResourceUri uri = getConfigurationURI(configurationId);
+ Configuration payload = configurePayload(requestDetails, configurationId, configurationType, configurationSubType);
+
+ aaiClient.create(uri, payload);
+ }
+
+ public Configuration configurePayload(RequestDetails requestDetails, String configurationId, String configurationType,
+ String configurationSubType) {
+
+ Configuration payload = new Configuration();
+ payload.setConfigurationId(configurationId);
+ payload.setConfigurationType(configurationType);
+ payload.setConfigurationSubType(configurationSubType);
+ payload.setModelInvariantId(requestDetails.getModelInfo().getModelInvariantId());
+ payload.setModelVersionId(requestDetails.getModelInfo().getModelVersionId());
+ payload.setOrchestrationStatus(ORCHESTRATION_STATUS);
+ payload.setOperationalStatus("");
+ payload.setConfigurationSelflink(getConfigurationURI(configurationId).build().getPath());
+ payload.setModelCustomizationId(requestDetails.getModelInfo().getModelCustomizationId());
+
+ return payload;
+ }
+
+ public void deleteConfiguration(String uuid) {
+ aaiClient.delete(getConfigurationURI(uuid));
+ }
+
+ public void updateOrchestrationStatus(String uuid, String payload) {
+ aaiClient.update(getConfigurationURI(uuid), payload);
+ }
+
+ public Configuration getConfiguration(String uuid) {
+ return aaiClient.get(Configuration.class, getConfigurationURI(uuid)).orElse(null);
+ }
+
+ public boolean configurationExists(String uuid) {
+ return aaiClient.exists(getConfigurationURI(uuid));
+ }
+
+ public AAIResourceUri getConfigurationURI(String uuid) {
+ return AAIUriFactory.createResourceUri(AAIObjectType.CONFIGURATION, uuid);
+ }
+}
diff --git a/common/src/main/java/org/onap/so/client/aai/AAIErrorFormatter.java b/common/src/main/java/org/onap/so/client/aai/AAIErrorFormatter.java
new file mode 100644
index 0000000000..6b3bb545de
--- /dev/null
+++ b/common/src/main/java/org/onap/so/client/aai/AAIErrorFormatter.java
@@ -0,0 +1,56 @@
+/*-
+ * ============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.aai;
+
+import java.util.List;
+
+import org.onap.so.client.aai.entities.AAIError;
+import org.onap.so.client.aai.entities.ServiceException;
+
+public class AAIErrorFormatter {
+
+ private final AAIError error;
+ public AAIErrorFormatter(AAIError error) {
+ this.error = error;
+ }
+
+ public String getMessage() {
+ if (error.getRequestError() != null &&
+ error.getRequestError().getServiceException() != null) {
+ ServiceException serviceException = error.getRequestError().getServiceException();
+ return this.fillInTemplate(serviceException.getText(), serviceException.getVariables());
+ }
+
+ return "no parsable error message found";
+ }
+
+ protected String fillInTemplate(String text, List<String> variables) {
+ for (int i = 0; i < variables.size(); i++) {
+ variables.set(i, this.format(variables.get(i), variables));
+ }
+
+ return format(text, variables);
+ }
+
+ protected String format(String s, List<String> variables) {
+ return String.format(s.replaceAll("%(\\d+)", "%$1\\$s"), variables.toArray());
+ }
+}
diff --git a/common/src/main/java/org/onap/so/client/aai/AAINamespaceConstants.java b/common/src/main/java/org/onap/so/client/aai/AAINamespaceConstants.java
new file mode 100644
index 0000000000..242fd41b19
--- /dev/null
+++ b/common/src/main/java/org/onap/so/client/aai/AAINamespaceConstants.java
@@ -0,0 +1,31 @@
+/*-
+ * ============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.aai;
+
+public class AAINamespaceConstants {
+
+ protected static final String CLOUD_INFRASTRUCTURE = "/cloud-infrastructure";
+ protected static final String NETWORK = "/network";
+ protected static final String BUSINESS = "/business";
+ protected static final String SERVICE_DESIGN_AND_CREATION = "/service-design-and-creation";
+
+
+}
diff --git a/common/src/main/java/org/onap/so/client/aai/AAIObjectPlurals.java b/common/src/main/java/org/onap/so/client/aai/AAIObjectPlurals.java
new file mode 100644
index 0000000000..c50653a203
--- /dev/null
+++ b/common/src/main/java/org/onap/so/client/aai/AAIObjectPlurals.java
@@ -0,0 +1,69 @@
+/*-
+ * ============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.aai;
+
+import org.onap.so.client.graphinventory.GraphInventoryObjectPlurals;
+
+import com.google.common.base.CaseFormat;
+
+public enum AAIObjectPlurals implements GraphInventoryObjectPlurals {
+
+ GENERIC_VNF(AAINamespaceConstants.NETWORK, "/generic-vnfs"),
+ PSERVER(AAINamespaceConstants.CLOUD_INFRASTRUCTURE, "/pservers"),
+ P_INTERFACE(AAIObjectType.PSERVER.uriTemplate(), "/p-interfaces"),
+ L3_NETWORK(AAINamespaceConstants.NETWORK, "/l3-networks"),
+ SERVICE_SUBSCRIPTION(AAIObjectType.CUSTOMER.uriTemplate(), "/service-subscriptions"),
+ SERVICE_INSTANCE(AAIObjectType.SERVICE_SUBSCRIPTION.uriTemplate(), "/service-instances"),
+ OWNING_ENTITIES(AAINamespaceConstants.BUSINESS, "/owning-entities"),
+ VOLUME_GROUP(AAIObjectType.CLOUD_REGION.uriTemplate(), "/volume-groups/");
+
+
+ private final String uriTemplate;
+ private final String partialUri;
+ private AAIObjectPlurals(String parentUri, String partialUri) {
+ this.uriTemplate = parentUri + partialUri;
+ this.partialUri = partialUri;
+ }
+
+ @Override
+ public String toString() {
+ return this.uriTemplate();
+ }
+
+ @Override
+ public String uriTemplate() {
+ return this.uriTemplate;
+ }
+
+ @Override
+ public String partialUri() {
+ return this.partialUri;
+ }
+
+ @Override
+ public String typeName() {
+ return this.typeName(CaseFormat.LOWER_HYPHEN);
+ }
+ @Override
+ public String typeName(CaseFormat format) {
+ return CaseFormat.UPPER_UNDERSCORE.to(format, this.name());
+ }
+}
diff --git a/common/src/main/java/org/onap/so/client/aai/AAIObjectType.java b/common/src/main/java/org/onap/so/client/aai/AAIObjectType.java
new file mode 100644
index 0000000000..ce75b1716a
--- /dev/null
+++ b/common/src/main/java/org/onap/so/client/aai/AAIObjectType.java
@@ -0,0 +1,104 @@
+/*-
+ * ============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.aai;
+
+import org.onap.so.client.graphinventory.GraphInventoryObjectType;
+
+import com.google.common.base.CaseFormat;
+
+public enum AAIObjectType implements GraphInventoryObjectType {
+
+ DEFAULT_CLOUD_REGION(AAINamespaceConstants.CLOUD_INFRASTRUCTURE, "/cloud-regions/cloud-region/att-aic/{cloud-region-id}"),
+ CUSTOMER(AAINamespaceConstants.BUSINESS, "/customers/customer/{global-customer-id}"),
+ GENERIC_QUERY("/search", "/generic-query"),
+ BULK_PROCESS("/bulkprocess", ""),
+ GENERIC_VNF(AAINamespaceConstants.NETWORK, "/generic-vnfs/generic-vnf/{vnf-id}"),
+ VF_MODULE(AAIObjectType.GENERIC_VNF.uriTemplate(), "/vf-modules/vf-module/{vf-module-id}"),
+ L3_NETWORK(AAINamespaceConstants.NETWORK, "/l3-networks/l3-network/{network-id}"),
+ NETWORK_POLICY(AAINamespaceConstants.NETWORK, "/network-policies/network-policy/{network-policy-id}"),
+ NODES_QUERY("/search", "/nodes-query"),
+ CUSTOM_QUERY("/query", ""),
+ ROUTE_TABLE_REFERENCE(AAINamespaceConstants.NETWORK, "/route-table-references/route-table-reference/{route-table-reference-id}"),
+ DEFAULT_TENANT(AAINamespaceConstants.CLOUD_INFRASTRUCTURE + "/cloud-regions/cloud-region/att-aic/AAIAIC25", "/tenants/tenant/{tenant-id}"),
+ VCE(AAINamespaceConstants.NETWORK, "/vces/vce/{vnf-id}"),
+ VPN_BINDING(AAINamespaceConstants.NETWORK, "/vpn-bindings/vpn-binding/{vpn-id}"),
+ VPN_BINDINGS(AAINamespaceConstants.NETWORK, "/vpn-bindings"),
+ CONFIGURATION(AAINamespaceConstants.NETWORK, "/configurations/configuration/{configuration-id}"),
+ PSERVER(AAINamespaceConstants.CLOUD_INFRASTRUCTURE, "/pservers/pserver/{hostname}"),
+ SERVICE_SUBSCRIPTION(AAIObjectType.CUSTOMER.uriTemplate(), "/service-subscriptions/service-subscription/{service-type}"),
+ SERVICE_INSTANCE(AAIObjectType.SERVICE_SUBSCRIPTION.uriTemplate(), "/service-instances/service-instance/{service-instance-id}"),
+ PROJECT(AAINamespaceConstants.BUSINESS, "/projects/project/{id}"),
+ LINE_OF_BUSINESS(AAINamespaceConstants.BUSINESS, "/lines-of-business/line-of-business/{id}"),
+ PLATFORM(AAINamespaceConstants.BUSINESS, "/platforms/platform/{id}"),
+ OWNING_ENTITY(AAINamespaceConstants.BUSINESS, "/owning-entities/owning-entity/{id}"),
+ ALLOTTED_RESOURCE(AAIObjectType.SERVICE_INSTANCE.uriTemplate(), "/allotted-resources/allotted-resource/{id}"),
+ PNF(AAINamespaceConstants.NETWORK, "/pnfs/pnf/{pnf-name}"),
+ OPERATIONAL_ENVIRONMENT(AAINamespaceConstants.CLOUD_INFRASTRUCTURE, "/operational-environments/operational-environment/{operational-environment-id}"),
+ CLOUD_REGION(AAINamespaceConstants.CLOUD_INFRASTRUCTURE, "/cloud-regions/cloud-region/{cloud-owner-id}/{cloud-region-id}"),
+ TENANT(AAIObjectType.CLOUD_REGION.uriTemplate(), "/tenants/tenant/{tenant-id}"),
+ VOLUME_GROUP(AAIObjectType.CLOUD_REGION.uriTemplate(), "/volume-groups/volume-group/{volume-group-id}"),
+ VSERVER(AAIObjectType.TENANT.uriTemplate(), "/vservers/vserver/{vserver-id}"),
+ MODEL_VER(AAINamespaceConstants.SERVICE_DESIGN_AND_CREATION + "/models/model/{model-invariant-id}", "/model-vers/model-ver/{model-version-id}"),
+ TUNNEL_XCONNECT(AAIObjectType.ALLOTTED_RESOURCE.uriTemplate(), "/tunnel-xconnects/tunnel-xconnect/{tunnel-id}"),
+ P_INTERFACE(AAIObjectType.PSERVER.uriTemplate(), "/p-interfaces/p-interface/{interface-name}"),
+ PHYSICAL_LINK(AAINamespaceConstants.NETWORK, "/physical-links/physical-link/{link-name}"),
+ INSTANCE_GROUP(AAINamespaceConstants.NETWORK, "/instance-groups/instance-group/{id}"),
+ COLLECTION(AAINamespaceConstants.NETWORK, "/collections/collection/{collection-id}"),
+ UNKNOWN("", "");
+
+ private final String uriTemplate;
+ private final String parentUri;
+ private final String partialUri;
+ private AAIObjectType(String parentUri, String partialUri) {
+ this.parentUri = parentUri;
+ this.partialUri = partialUri;
+ this.uriTemplate = parentUri + partialUri;
+ }
+
+ @Override
+ public String toString() {
+ return this.uriTemplate();
+ }
+
+ @Override
+ public String typeName() {
+ return this.typeName(CaseFormat.LOWER_HYPHEN);
+ }
+ @Override
+ public String typeName(CaseFormat format) {
+ String enumName = this.name();
+ if (this.equals(AAIObjectType.DEFAULT_CLOUD_REGION) || this.equals(AAIObjectType.DEFAULT_TENANT)) {
+ enumName = enumName.replace("DEFAULT_", "");
+ }
+
+ return CaseFormat.UPPER_UNDERSCORE.to(format, enumName);
+ }
+
+ @Override
+ public String uriTemplate() {
+ return this.uriTemplate;
+ }
+
+ @Override
+ public String partialUri() {
+ return this.partialUri;
+ }
+}
diff --git a/common/src/main/java/org/onap/so/client/aai/AAIProperties.java b/common/src/main/java/org/onap/so/client/aai/AAIProperties.java
new file mode 100644
index 0000000000..9f6708200c
--- /dev/null
+++ b/common/src/main/java/org/onap/so/client/aai/AAIProperties.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.aai;
+
+import org.onap.so.client.RestProperties;
+
+public interface AAIProperties extends RestProperties {
+
+ public AAIVersion getDefaultVersion();
+ public String getAuth();
+ public String getKey();
+ @Override
+ public default boolean mapNotFoundToEmpty() {
+ return true;
+ }
+}
diff --git a/common/src/main/java/org/onap/so/client/aai/AAIQueryClient.java b/common/src/main/java/org/onap/so/client/aai/AAIQueryClient.java
new file mode 100644
index 0000000000..184b4e5251
--- /dev/null
+++ b/common/src/main/java/org/onap/so/client/aai/AAIQueryClient.java
@@ -0,0 +1,83 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.so.client.aai;
+
+import java.util.Optional;
+
+import org.onap.so.client.RestClient;
+import org.onap.so.client.aai.entities.CustomQuery;
+import org.onap.so.client.aai.entities.uri.AAIUriFactory;
+import org.onap.so.client.graphinventory.Format;
+import org.onap.so.client.graphinventory.entities.uri.GraphInventoryUri;
+
+public class AAIQueryClient extends AAIClient {
+
+ private Optional<String> depth = Optional.empty();
+ private boolean nodesOnly = false;
+ private Optional<AAISubgraphType> subgraph = Optional.empty();
+
+ public AAIQueryClient() {
+ super();
+ }
+
+ public AAIQueryClient(AAIVersion version) {
+ super();
+ this.version = version;
+ }
+
+ public String query(Format format, CustomQuery query) {
+ return this.createClient(AAIUriFactory.createResourceUri(AAIObjectType.CUSTOM_QUERY).queryParam("format", format.toString()))
+ .put(query, String.class);
+ }
+
+ public AAIQueryClient depth (String depth) {
+ this.depth = Optional.of(depth);
+ return this;
+ }
+ public AAIQueryClient nodesOnly() {
+ this.nodesOnly = true;
+ return this;
+ }
+ public AAIQueryClient subgraph(AAISubgraphType type){
+
+ subgraph = Optional.of(type);
+
+ return this;
+ }
+
+ protected GraphInventoryUri setupQueryParams(GraphInventoryUri uri) {
+ GraphInventoryUri clone = uri.clone();
+ if (this.depth.isPresent()) {
+ clone.queryParam("depth", depth.get());
+ }
+ if (this.nodesOnly) {
+ clone.queryParam("nodesOnly", "");
+ }
+ if (this.subgraph.isPresent()) {
+ clone.queryParam("subgraph", this.subgraph.get().toString());
+ }
+ return clone;
+ }
+ @Override
+ protected RestClient createClient(GraphInventoryUri uri) {
+ return super.createClient(setupQueryParams(uri));
+ }
+}
diff --git a/common/src/main/java/org/onap/so/client/aai/AAIQueryObjectMapperProvider.java b/common/src/main/java/org/onap/so/client/aai/AAIQueryObjectMapperProvider.java
new file mode 100644
index 0000000000..d5eeb83041
--- /dev/null
+++ b/common/src/main/java/org/onap/so/client/aai/AAIQueryObjectMapperProvider.java
@@ -0,0 +1,39 @@
+/*-
+ * ============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.aai;
+
+import com.fasterxml.jackson.databind.AnnotationIntrospector;
+import com.fasterxml.jackson.databind.introspect.JacksonAnnotationIntrospector;
+import com.fasterxml.jackson.databind.type.TypeFactory;
+import com.fasterxml.jackson.module.jaxb.JaxbAnnotationIntrospector;
+
+public class AAIQueryObjectMapperProvider extends AAICommonObjectMapperProvider {
+
+ public AAIQueryObjectMapperProvider() {
+ super();
+ AnnotationIntrospector aiJaxb = new JaxbAnnotationIntrospector(TypeFactory.defaultInstance());
+ AnnotationIntrospector aiJackson = new JacksonAnnotationIntrospector();
+ // first Jaxb, second Jackson annotations
+ mapper.setAnnotationIntrospector(AnnotationIntrospector.pair(aiJaxb, aiJackson));
+
+ }
+
+}
diff --git a/common/src/main/java/org/onap/so/client/aai/AAIResourcesClient.java b/common/src/main/java/org/onap/so/client/aai/AAIResourcesClient.java
new file mode 100644
index 0000000000..04757c6fc2
--- /dev/null
+++ b/common/src/main/java/org/onap/so/client/aai/AAIResourcesClient.java
@@ -0,0 +1,254 @@
+/*-
+ * ============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.aai;
+
+import java.lang.reflect.InvocationTargetException;
+import java.util.Map;
+import java.util.Optional;
+
+import javax.ws.rs.NotFoundException;
+import javax.ws.rs.core.GenericType;
+import javax.ws.rs.core.Response;
+import javax.ws.rs.core.Response.Status;
+
+import org.onap.aai.domain.yang.Relationship;
+import org.onap.so.client.RestClient;
+import org.onap.so.client.RestProperties;
+import org.onap.so.client.aai.entities.AAIResultWrapper;
+import org.onap.so.client.aai.entities.uri.AAIResourceUri;
+import org.onap.so.client.aai.entities.uri.AAIUri;
+import org.onap.so.client.graphinventory.entities.uri.Depth;
+
+public class AAIResourcesClient extends AAIClient {
+
+ public AAIResourcesClient() {
+ super();
+ }
+
+ public AAIResourcesClient(AAIVersion version) {
+ super();
+ this.version = version;
+ }
+
+ /**
+ * creates a new object in A&AI
+ *
+ * @param obj - can be any object which will marshal into a valid A&AI payload
+ * @param uri
+ * @return
+ */
+ public void create(AAIResourceUri uri, Object obj) {
+ RestClient aaiRC = this.createClient(uri);
+ aaiRC.put(obj);
+ return;
+ }
+
+ /**
+ * creates a new object in A&AI with no payload body
+ *
+ * @param uri
+ * @return
+ */
+ public void createEmpty(AAIResourceUri uri) {
+ RestClient aaiRC = this.createClient(uri);
+ aaiRC.put("");
+ return;
+ }
+
+ /**
+ * returns false if the object does not exist in A&AI
+ *
+ * @param uri
+ * @return
+ */
+ public boolean exists(AAIResourceUri uri) {
+ AAIUri forceMinimal = this.addParams(Optional.of(Depth.ZERO), true, uri);
+ RestClient aaiRC = this.createClient(forceMinimal);
+
+ return aaiRC.get().getStatus() == Status.OK.getStatusCode();
+ }
+
+ /**
+ * Adds a relationship between two objects in A&AI
+ * @param uriA
+ * @param uriB
+ * @return
+ */
+ public void connect(AAIResourceUri uriA, AAIResourceUri uriB) {
+ AAIResourceUri uriAClone = uriA.clone();
+ RestClient aaiRC = this.createClient(uriAClone.relationshipAPI());
+ aaiRC.put(this.buildRelationship(uriB));
+ return;
+ }
+
+ /**
+ * Removes relationship from two objects in A&AI
+ *
+ * @param uriA
+ * @param uriB
+ * @return
+ */
+ public void disconnect(AAIResourceUri uriA, AAIResourceUri uriB) {
+ AAIResourceUri uriAClone = uriA.clone();
+ RestClient aaiRC = this.createClient(uriAClone.relationshipAPI());
+ aaiRC.delete(this.buildRelationship(uriB));
+ return;
+ }
+
+ /**
+ * Deletes object from A&AI. Automatically handles resource-version.
+ *
+ * @param uri
+ * @return
+ */
+ public void delete(AAIResourceUri uri) {
+ AAIResourceUri clone = uri.clone();
+ RestClient aaiRC = this.createClient(clone);
+ Map<String, Object> result = aaiRC.get(new GenericType<Map<String, Object>>(){})
+ .orElseThrow(() -> new NotFoundException(clone.build() + " does not exist in A&AI"));
+ String resourceVersion = (String) result.get("resource-version");
+ aaiRC = this.createClient(clone.resourceVersion(resourceVersion));
+ aaiRC.delete();
+ return;
+ }
+
+ /**
+ * @param obj - can be any object which will marshal into a valid A&AI payload
+ * @param uri
+ * @return
+ */
+ public void update(AAIResourceUri uri, Object obj) {
+ RestClient aaiRC = this.createClient(uri);
+ aaiRC.patch(obj);
+ return;
+ }
+
+ /**
+ * Retrieves an object from A&AI and unmarshalls it into the Class specified
+ * @param clazz
+ * @param uri
+ * @return
+ */
+ public <T> Optional<T> get(Class<T> clazz, AAIResourceUri uri) {
+ return this.createClient(uri).get(clazz);
+ }
+
+ /**
+ * Retrieves an object from A&AI and returns complete response
+ * @param uri
+ * @return
+ */
+ public Response getFullResponse(AAIResourceUri uri) {
+ return this.createClient(uri).get();
+ }
+
+ /**
+ * Retrieves an object from A&AI and automatically unmarshalls it into a Map or List
+ * @param resultClass
+ * @param uri
+ * @return
+ */
+ public <T> Optional<T> get(GenericType<T> resultClass, AAIResourceUri uri) {
+ return this.createClient(uri).get(resultClass);
+ }
+
+ /**
+ * Retrieves an object from A&AI wrapped in a helper class which offer additional features
+ *
+ * @param uri
+ * @return
+ */
+ public AAIResultWrapper get(AAIResourceUri uri) {
+ String json = this.createClient(uri).get(String.class).orElse(null);
+ return new AAIResultWrapper(json);
+ }
+
+ /**
+ * Retrieves an object from A&AI wrapped in a helper class which offer additional features
+ * If the object cannot be found in A&AI the method will throw the runtime exception
+ * included as an argument
+ * @param uri
+ * @return
+ */
+ public AAIResultWrapper get(AAIResourceUri uri, Class<? extends RuntimeException> c) {
+
+ RuntimeException e;
+ try {
+ e = c.getConstructor(String.class).newInstance(uri.build() + " not found in A&AI");
+ } catch (InstantiationException | IllegalAccessException | IllegalArgumentException | InvocationTargetException
+ | NoSuchMethodException | SecurityException e1) {
+ throw new IllegalArgumentException("could not create instance for " + c.getName());
+ }
+ String json = this.createClient(uri).get(String.class)
+ .orElseThrow(() -> e);
+ return new AAIResultWrapper(json);
+ }
+
+ private Relationship buildRelationship(AAIResourceUri uri) {
+ final Relationship result = new Relationship();
+ result.setRelatedLink(uri.build().toString());
+ return result;
+ }
+
+ /**
+ * Will automatically create the object if it does not exist
+ *
+ * @param obj - Optional object which serializes to a valid A&AI payload
+ * @param uri
+ * @return
+ */
+ public AAIResourcesClient createIfNotExists(AAIResourceUri uri, Optional<Object> obj) {
+ if(!this.exists(uri)){
+ if (obj.isPresent()) {
+ this.create(uri, obj.get());
+ } else {
+ this.createEmpty(uri);
+ }
+
+ }
+ return this;
+ }
+
+ /**
+ * Starts a transaction which encloses multiple A&AI mutations
+ *
+ * @return
+ */
+ public AAITransactionalClient beginTransaction() {
+ return new AAITransactionalClient(this.getVersion());
+ }
+
+ private AAIUri addParams(Optional<Depth> depth, boolean nodesOnly, AAIUri uri) {
+ AAIUri clone = uri.clone();
+ if (depth.isPresent()) {
+ clone.depth(depth.get());
+ }
+ if (nodesOnly) {
+ clone.nodesOnly(nodesOnly);
+ }
+
+ return clone;
+ }
+ @Override
+ protected <T extends RestProperties> T getRestProperties() {
+ return super.getRestProperties();
+ }
+}
diff --git a/common/src/main/java/org/onap/so/client/aai/AAIResourcesObjectMapperProvider.java b/common/src/main/java/org/onap/so/client/aai/AAIResourcesObjectMapperProvider.java
new file mode 100644
index 0000000000..15f2ed2fa2
--- /dev/null
+++ b/common/src/main/java/org/onap/so/client/aai/AAIResourcesObjectMapperProvider.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.aai;
+
+public class AAIResourcesObjectMapperProvider extends AAICommonObjectMapperProvider {
+
+ public AAIResourcesObjectMapperProvider() {
+ super();
+ }
+
+}
diff --git a/common/src/main/java/org/onap/so/client/aai/AAIRestClient.java b/common/src/main/java/org/onap/so/client/aai/AAIRestClient.java
new file mode 100644
index 0000000000..2bd5f118c0
--- /dev/null
+++ b/common/src/main/java/org/onap/so/client/aai/AAIRestClient.java
@@ -0,0 +1,131 @@
+/*-
+ * ============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.aai;
+
+import java.net.URI;
+import java.util.List;
+import java.util.Map;
+import java.util.Optional;
+import java.util.regex.Pattern;
+
+import javax.ws.rs.core.Response;
+
+import org.onap.so.client.ResponseExceptionMapper;
+import org.onap.so.client.RestClientSSL;
+import org.onap.so.client.graphinventory.exceptions.GraphInventoryPatchDepthExceededException;
+import org.onap.so.client.policy.CommonObjectMapperProvider;
+import org.onap.so.jsonpath.JsonPathUtil;
+import org.onap.so.utils.TargetEntity;
+
+import com.fasterxml.jackson.core.JsonProcessingException;
+
+public class AAIRestClient extends RestClientSSL {
+
+ private final AAIProperties aaiProperties;
+ private static final AAICommonObjectMapperProvider standardProvider = new AAICommonObjectMapperProvider();
+ private static final AAICommonObjectMapperPatchProvider patchProvider = new AAICommonObjectMapperPatchProvider();
+ private static final Pattern LOCATE_COMPLEX_OBJECT = Pattern.compile("^((?!relationship-list).)+?\\['[^\\[\\]]+?'\\]$");
+
+ protected AAIRestClient(AAIProperties props, URI uri) {
+ super(props, Optional.of(uri));
+ this.aaiProperties = props;
+ }
+
+ @Override
+ public TargetEntity getTargetEntity(){
+ return TargetEntity.AAI;
+ }
+
+ @Override
+ protected void initializeHeaderMap(Map<String, String> headerMap) {
+ headerMap.put("X-FromAppId", "MSO");
+ headerMap.put("X-TransactionId", requestId);
+ String auth = aaiProperties.getAuth();
+ String key = aaiProperties.getKey();
+
+ if (auth != null && !auth.isEmpty() && key != null && !key.isEmpty()) {
+ addBasicAuthHeader(auth, key);
+ }
+ }
+
+ @Override
+ protected Optional<ResponseExceptionMapper> addResponseExceptionMapper() {
+
+ return Optional.of(new AAIClientResponseExceptionMapper());
+ }
+
+ @Override
+ protected CommonObjectMapperProvider getCommonObjectMapperProvider() {
+ return standardProvider;
+ }
+
+ @Override
+ public Response patch(Object obj) {
+ String value = convertObjectToPatchFormat(obj);
+ validatePatchObject(value);
+ return super.patch(value);
+ }
+
+ @Override
+ public <T> T patch(Object obj, Class<T> resultClass) {
+ String value = convertObjectToPatchFormat(obj);
+ validatePatchObject(value);
+ return super.patch(value, resultClass);
+ }
+
+ protected String convertObjectToPatchFormat(Object obj) {
+ Object value = obj;
+ try {
+ if (!(obj instanceof Map || obj instanceof String)) {
+ value = patchProvider.getMapper().writeValueAsString(obj);
+ } else if (obj instanceof Map) {
+ value = standardProvider.getMapper().writeValueAsString(obj);
+ }
+ } catch (JsonProcessingException e) {
+ value = "{}";
+ }
+
+ return (String)value;
+ }
+
+
+ protected void validatePatchObject(String payload) {
+ if (hasComplexObject(payload)) {
+ throw new GraphInventoryPatchDepthExceededException(payload);
+ }
+ }
+
+ /** validates client side that json does not include any complex objects
+ * relationship-list is omitted from this validation
+ */
+ protected boolean hasComplexObject(String json) {
+ if (json.isEmpty()) {
+ return false;
+ }
+ String complex = "$.*.*";
+ String array = "$.*.*.*";
+ List<String> result = JsonPathUtil.getInstance().getPathList(json, complex);
+ List<String> result2 = JsonPathUtil.getInstance().getPathList(json, array);
+
+ result.addAll(result2);
+ return result.stream().anyMatch(item -> LOCATE_COMPLEX_OBJECT.matcher(item).find());
+ }
+}
diff --git a/common/src/main/java/org/onap/so/client/aai/AAIRestClientI.java b/common/src/main/java/org/onap/so/client/aai/AAIRestClientI.java
new file mode 100644
index 0000000000..b56a6779cc
--- /dev/null
+++ b/common/src/main/java/org/onap/so/client/aai/AAIRestClientI.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.so.client.aai;
+
+import java.io.IOException;
+import java.io.UnsupportedEncodingException;
+import java.util.List;
+import java.util.Optional;
+
+import org.onap.aai.domain.yang.GenericVnf;
+import org.onap.aai.domain.yang.Pnf;
+import org.onap.aai.domain.yang.Pserver;
+import org.onap.aai.domain.yang.Pservers;
+
+import com.fasterxml.jackson.core.JsonParseException;
+import com.fasterxml.jackson.databind.JsonMappingException;
+
+public interface AAIRestClientI {
+
+ Pservers getPhysicalServers(String hostName, String uuid);
+
+ List<Pserver> getPhysicalServerByVnfId(String vnfId, String transactionLoggingUuid) throws UnsupportedEncodingException, JsonParseException, JsonMappingException, IOException;
+
+ void updateMaintenceFlag(String vnfId,boolean inMaint, String transactionLoggingUuid) throws Exception;
+
+ void updateMaintenceFlagVnfId(String vnfId, boolean inMaint, String transactionLoggingUuid) throws Exception;
+
+ GenericVnf getVnfByName(String vnfId, String transactionLoggingUuid) throws Exception;
+
+ Optional<Pnf> getPnfByName(String pnfId, String transactionLoggingUuid) throws Exception;
+
+ void createPnf(String pnfId, String transactionLoggingUuid, Pnf pnf) throws IOException;
+}
diff --git a/common/src/main/java/org/onap/so/client/aai/AAIRestClientImpl.java b/common/src/main/java/org/onap/so/client/aai/AAIRestClientImpl.java
new file mode 100644
index 0000000000..b471a1e53d
--- /dev/null
+++ b/common/src/main/java/org/onap/so/client/aai/AAIRestClientImpl.java
@@ -0,0 +1,197 @@
+/*-
+ * ============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.aai;
+
+
+import com.fasterxml.jackson.core.type.TypeReference;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+import java.util.Optional;
+import java.util.UUID;
+import javax.ws.rs.core.Response;
+import org.onap.aai.domain.yang.GenericVnf;
+import org.onap.aai.domain.yang.GenericVnfs;
+import org.onap.aai.domain.yang.Pnf;
+import org.onap.aai.domain.yang.Pserver;
+import org.onap.aai.domain.yang.Pservers;
+import org.onap.so.client.aai.entities.CustomQuery;
+import org.onap.so.client.aai.entities.Results;
+import org.onap.so.client.aai.entities.uri.AAIResourceUri;
+import org.onap.so.client.aai.entities.uri.AAIUriFactory;
+import org.onap.so.client.graphinventory.Format;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.stereotype.Service;
+
+
+
+public class AAIRestClientImpl implements AAIRestClientI {
+
+ private static Logger logger = LoggerFactory.getLogger(AAIClient.class);
+ private static final AAIVersion ENDPOINT_VERSION = AAIVersion.V10;
+ private static final String ENDPOINT_GET_ALL = ENDPOINT_VERSION + "/cloud-infrastructure/pservers";
+ private static final String ENDPOINT_GET_ALL_VNFS = ENDPOINT_VERSION + "/network/generic-vnfs";
+ private static final String ENDPOINT_CUSTOM_QUERY = ENDPOINT_VERSION + "/query";
+ private static final String PSERVER_VNF_QUERY = "pservers-fromVnf";
+ private static final String GENERIC_VNF_PATH = ENDPOINT_VERSION + "/network/generic-vnfs/generic-vnf";
+ private static final String SERVICE_TOPOLOGY_BY_SERVICE_INSTANCE_ID =
+ "store(‘x’).union(__.in(‘subscribesTo’).has(‘aai-node-type’,’customer’).store(‘x’),__.out(‘uses’).has(‘aai-node-type’,’allotted-resource’).store(‘x’),__.in(‘hasInstance’).has(‘aai-node-type’,’generic-vnf’).store(‘x’).union("
+ + ".out(‘has’).has(‘aai-node-type’,’vf-module’).store(‘x’),out(‘uses’).has(‘aai-node-type’,’volume-group’).store(‘x’),"
+ + ".out(‘hasLInterface’).has(‘aai-node-type’,’l-interface’).union("
+ + ".out(‘hasIpAddress’).has(‘aai-node-type’,’l3-interface-ipv4-address’).store(‘x’).out(‘isMemberOf’).has(‘aai-node-type’,’l3-network’).store(‘x’),"
+ + ".out(‘hasIpAddress’).has(‘aai-node-type’,’l3-interface-ipv6-address’).store(‘x’).out(‘isMemberOf’).has(‘aai-node-type’,’l3-network’).store(‘x’)"
+ + ")," + ".out(‘runsOnVserver’).has(‘aai-node-type’,’vserver’).store(‘x’).union("
+ + ".in(‘owns’).has(‘aai-node-type’,’tenant’).store(‘x’).in(‘has’).has(‘aai-node-type’,’cloud-region’).store(‘x’),"
+ + ".out(‘runsOnPserver’).has(‘aai-node-type’,’pserver’).store(‘x’),"
+ + ".out(‘hasLInterface’).has(‘aai-node-type’,’l-interface’).union("
+ + ".out(‘hasIpAddress’).has(‘aai-node-type’,’l3-interface-ipv4-address’).store(‘x’).out(‘isMemberOf’).has(‘aai-node-type’,’l3-network’).store(‘x’),"
+ + ".out(‘hasIpAddress’).has(‘aai-node-type’,’l3-interface-ipv6-address’).store(‘x’).out(‘isMemberOf’).has(‘aai-node-type’,’l3-network’).store(‘x’)"
+ + ")" + ")" + ")" + ").cap(‘x’).unfold().dedup()";
+
+ public AAIRestClientImpl() {
+ }
+
+ @Override
+ public Pservers getPhysicalServers(String hostName, String uuid) {
+ UUID requestId;
+ try {
+ requestId = UUID.fromString(uuid);
+ } catch (IllegalArgumentException e) {
+ logger.warn("could not parse uuid: " + uuid + " creating valid uuid automatically");
+ requestId = UUID.randomUUID();
+ }
+ return new AAIResourcesClient(ENDPOINT_VERSION)
+ .get(Pservers.class, AAIUriFactory.createResourceUri(AAIObjectPlurals.PSERVER)).orElse(null);
+ }
+
+ @Override
+ public List<Pserver> getPhysicalServerByVnfId(String vnfId, String transactionLoggingUuid) throws IOException {
+ UUID requestId;
+ try {
+ requestId = UUID.fromString(transactionLoggingUuid);
+ } catch (IllegalArgumentException e) {
+ logger.warn("could not parse uuid: " + transactionLoggingUuid + " creating valid uuid automatically");
+ requestId = UUID.randomUUID();
+ }
+ List<AAIResourceUri> startNodes = new ArrayList<>();
+ startNodes.add(AAIUriFactory.createResourceUri(AAIObjectType.GENERIC_VNF, vnfId));
+ String jsonInput = new AAIQueryClient(ENDPOINT_VERSION)
+ .query(Format.RESOURCE, new CustomQuery(startNodes, PSERVER_VNF_QUERY));
+
+ return this.getListOfPservers(jsonInput);
+
+ }
+
+ protected List<Pserver> getListOfPservers(String jsonInput) throws IOException {
+ ObjectMapper mapper = new AAICommonObjectMapperProvider().getMapper();
+ Results<Map<String, Pserver>> resultsFromJson = mapper.readValue(jsonInput,
+ new TypeReference<Results<Map<String, Pserver>>>() {
+ });
+ List<Pserver> results = new ArrayList<>();
+ for (Map<String, Pserver> m : resultsFromJson.getResult()) {
+ results.add(m.get("pserver"));
+ }
+ return results;
+ }
+
+ @Override
+ public void updateMaintenceFlag(String vnfName, boolean inMaint, String transactionLoggingUuid) throws IOException {
+ UUID requestId;
+ try {
+ requestId = UUID.fromString(transactionLoggingUuid);
+ } catch (IllegalArgumentException e) {
+ logger.warn("could not parse uuid: " + transactionLoggingUuid + " creating valid uuid automatically");
+ requestId = UUID.randomUUID();
+ }
+ GenericVnfs genericVnfs = new AAIResourcesClient(ENDPOINT_VERSION).get(GenericVnfs.class,
+ AAIUriFactory.createResourceUri(AAIObjectPlurals.GENERIC_VNF).queryParam("vnf-name", vnfName)).orElse(null);
+ if (genericVnfs.getGenericVnf().size() > 1) {
+ throw new IndexOutOfBoundsException("Multiple Generic Vnfs Returned");
+ }
+
+ GenericVnf genericVnf = genericVnfs.getGenericVnf().get(0);
+ updateMaintenceFlagVnfId(genericVnf.getVnfId(), inMaint, transactionLoggingUuid);
+ }
+
+ @Override
+ public void updateMaintenceFlagVnfId(String vnfId, boolean inMaint, String transactionLoggingUuid)
+ throws IOException {
+ UUID requestId;
+ try {
+ requestId = UUID.fromString(transactionLoggingUuid);
+ } catch (IllegalArgumentException e) {
+ logger.warn("could not parse uuid: " + transactionLoggingUuid + " creating valid uuid automatically");
+ requestId = UUID.randomUUID();
+ }
+ GenericVnf genericVnf = new GenericVnf();
+ genericVnf.setInMaint(inMaint);
+ new AAIResourcesClient(ENDPOINT_VERSION)
+ .update(AAIUriFactory.createResourceUri(AAIObjectType.GENERIC_VNF, vnfId), genericVnf);
+
+ }
+
+ @Override
+ public GenericVnf getVnfByName(String vnfId, String transactionLoggingUuid) throws IOException {
+ UUID requestId;
+ try {
+ requestId = UUID.fromString(transactionLoggingUuid);
+ } catch (IllegalArgumentException e) {
+ logger.warn("could not parse uuid: " + transactionLoggingUuid + " creating valid uuid automatically");
+ requestId = UUID.randomUUID();
+ }
+ return new AAIResourcesClient(ENDPOINT_VERSION)
+ .get(GenericVnf.class, AAIUriFactory.createResourceUri(AAIObjectType.GENERIC_VNF, vnfId)).orElse(null);
+ }
+
+ @Override
+ public Optional<Pnf> getPnfByName(String pnfId, String transactionLoggingUuid) throws IOException {
+ UUID requestId;
+ try {
+ requestId = UUID.fromString(transactionLoggingUuid);
+ } catch (IllegalArgumentException e) {
+ logger.warn("could not parse uuid: " + transactionLoggingUuid + " creating valid uuid automatically", e);
+ requestId = UUID.randomUUID();
+ }
+ Response response = new AAIResourcesClient(ENDPOINT_VERSION)
+ .getFullResponse(AAIUriFactory.createResourceUri(AAIObjectType.PNF, pnfId));
+ if (response.getStatus() != 200) {
+ return Optional.empty();
+ } else {
+ return Optional.of(response.readEntity(Pnf.class));
+ }
+ }
+
+ @Override
+ public void createPnf(String pnfId, String transactionLoggingUuid, Pnf pnf) throws IOException {
+ UUID requestId;
+ try {
+ requestId = UUID.fromString(transactionLoggingUuid);
+ } catch (IllegalArgumentException e) {
+ logger.warn("could not parse uuid: " + transactionLoggingUuid + " creating valid uuid automatically", e);
+ requestId = UUID.randomUUID();
+ }
+ new AAIResourcesClient(ENDPOINT_VERSION)
+ .createIfNotExists(AAIUriFactory.createResourceUri(AAIObjectType.PNF, pnfId), Optional.of(pnf));
+ }
+}
diff --git a/common/src/main/java/org/onap/so/client/aai/AAISubgraphType.java b/common/src/main/java/org/onap/so/client/aai/AAISubgraphType.java
new file mode 100644
index 0000000000..e9beb143fd
--- /dev/null
+++ b/common/src/main/java/org/onap/so/client/aai/AAISubgraphType.java
@@ -0,0 +1,38 @@
+/*-
+ * ============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.aai;
+
+
+public enum AAISubgraphType {
+ STAR("star"),
+ PRUNE("prune");
+
+ private final String name;
+
+ private AAISubgraphType(String name) {
+ this.name = name;
+ }
+
+ @Override
+ public String toString() {
+ return name;
+ }
+}
diff --git a/common/src/main/java/org/onap/so/client/aai/AAITransactionalClient.java b/common/src/main/java/org/onap/so/client/aai/AAITransactionalClient.java
new file mode 100644
index 0000000000..884d2aaec6
--- /dev/null
+++ b/common/src/main/java/org/onap/so/client/aai/AAITransactionalClient.java
@@ -0,0 +1,264 @@
+/*-
+ * ============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.aai;
+
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Map.Entry;
+import java.util.Optional;
+
+import javax.ws.rs.NotFoundException;
+import javax.ws.rs.core.GenericType;
+import javax.ws.rs.core.Response;
+
+import org.onap.aai.domain.yang.Relationship;
+import org.onap.so.client.RestClient;
+import org.onap.so.client.aai.entities.AAIError;
+import org.onap.so.client.aai.entities.bulkprocess.OperationBody;
+import org.onap.so.client.aai.entities.bulkprocess.Transaction;
+import org.onap.so.client.aai.entities.bulkprocess.Transactions;
+import org.onap.so.client.aai.entities.uri.AAIResourceUri;
+import org.onap.so.client.aai.entities.uri.AAIUri;
+import org.onap.so.client.aai.entities.uri.AAIUriFactory;
+import org.onap.so.client.graphinventory.exceptions.BulkProcessFailed;
+import org.onap.so.jsonpath.JsonPathUtil;
+
+import com.fasterxml.jackson.core.type.TypeReference;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.google.common.base.Joiner;
+
+public class AAITransactionalClient extends AAIClient {
+
+ private final Transactions transactions;
+ private Transaction currentTransaction;
+ private final AAIVersion version;
+ private int actionCount = 0;
+ protected AAITransactionalClient(AAIVersion version) {
+ super();
+ this.version = version;
+ this.transactions = new Transactions();
+ startTransaction();
+ }
+
+ private void startTransaction() {
+ Transaction transaction = new Transaction();
+ transactions.getTransactions().add(transaction);
+ currentTransaction = transaction;
+ }
+
+ /**
+ * adds an additional transaction and closes the previous transaction
+ *
+ * @return AAITransactionalClient
+ */
+ public AAITransactionalClient beginNewTransaction() {
+ startTransaction();
+ return this;
+ }
+
+ /**
+ * creates a new object in A&AI
+ *
+ * @param obj - can be any object which will marshal into a valid A&AI payload
+ * @param uri
+ * @return
+ */
+ public AAITransactionalClient create(AAIResourceUri uri, Object obj) {
+ currentTransaction.getPut().add(new OperationBody().withUri(uri.build().toString()).withBody(obj));
+ incrementActionAmount();
+ return this;
+ }
+
+ /**
+ * creates a new object in A&AI with no payload body
+ *
+ * @param uri
+ * @return
+ */
+ public AAITransactionalClient createEmpty(AAIResourceUri uri) {
+ currentTransaction.getPut().add(new OperationBody().withUri(uri.build().toString()).withBody(new HashMap<String, String>()));
+ incrementActionAmount();
+ return this;
+ }
+
+ /**
+ * Adds a relationship between two objects in A&AI
+ * @param uriA
+ * @param uriB
+ * @return
+ */
+ public AAITransactionalClient connect(AAIResourceUri uriA, AAIResourceUri uriB) {
+ AAIResourceUri uriAClone = uriA.clone();
+ currentTransaction.getPut().add(new OperationBody().withUri(uriAClone.relationshipAPI().build().toString()).withBody(this.buildRelationship(uriB)));
+ incrementActionAmount();
+ return this;
+ }
+
+ /**
+ * relationship between multiple objects in A&AI - connects A to all objects specified in list
+ *
+ * @param uriA
+ * @param uris
+ * @return
+ */
+ public AAITransactionalClient connect(AAIResourceUri uriA, List<AAIResourceUri> uris) {
+ for (AAIResourceUri uri : uris) {
+ this.connect(uriA, uri);
+ }
+ return this;
+ }
+
+ /**
+ * Removes relationship from two objects in A&AI
+ *
+ * @param uriA
+ * @param uriB
+ * @return
+ */
+ public AAITransactionalClient disconnect(AAIResourceUri uriA, AAIResourceUri uriB) {
+ AAIResourceUri uriAClone = uriA.clone();
+ currentTransaction.getDelete().add(new OperationBody().withUri(uriAClone.relationshipAPI().build().toString()).withBody(this.buildRelationship(uriB)));
+ incrementActionAmount();
+ return this;
+ }
+
+ /**
+ * Removes relationship from multiple objects - disconnects A from all objects specified in list
+ * @param uriA
+ * @param uris
+ * @return
+ */
+ public AAITransactionalClient disconnect(AAIResourceUri uriA, List<AAIResourceUri> uris) {
+ for (AAIResourceUri uri : uris) {
+ this.disconnect(uriA, uri);
+ }
+ return this;
+ }
+ /**
+ * Deletes object from A&AI. Automatically handles resource-version.
+ *
+ * @param uri
+ * @return
+ */
+ public AAITransactionalClient delete(AAIResourceUri uri) {
+ AAIResourcesClient client = new AAIResourcesClient();
+ AAIResourceUri clone = uri.clone();
+ Map<String, Object> result = client.get(new GenericType<Map<String, Object>>(){}, clone)
+ .orElseThrow(() -> new NotFoundException(clone.build() + " does not exist in A&AI"));
+ String resourceVersion = (String) result.get("resource-version");
+ currentTransaction.getDelete().add(new OperationBody().withUri(clone.resourceVersion(resourceVersion).build().toString()).withBody(""));
+ incrementActionAmount();
+ return this;
+ }
+
+ /**
+ * @param obj - can be any object which will marshal into a valid A&AI payload
+ * @param uri
+ * @return
+ */
+ public AAITransactionalClient update(AAIResourceUri uri, Object obj) {
+ currentTransaction.getPatch().add(new OperationBody().withUri(uri.build().toString()).withBody(obj));
+ incrementActionAmount();
+ return this;
+ }
+
+ private void incrementActionAmount() {
+ actionCount++;
+ }
+ /**
+ * Executes all created transactions in A&AI
+ * @throws BulkProcessFailed
+ */
+ public void execute() throws BulkProcessFailed {
+ RestClient client = this.createClient(AAIUriFactory.createResourceUri(AAIObjectType.BULK_PROCESS));
+ try {
+ Response response = client.put(this.transactions);
+ if (response.hasEntity()) {
+ final Optional<String> errorMessage = this.locateErrorMessages(response.readEntity(String.class));
+ if (errorMessage.isPresent()) {
+ throw new BulkProcessFailed("One or more transactions failed in A&AI. Check logs for payloads.\nMessages:\n" + errorMessage.get());
+ }
+ } else {
+ throw new BulkProcessFailed("Transactions acccepted by A&AI, but there was no response. Unsure of result.");
+ }
+ } finally {
+ this.transactions.getTransactions().clear();
+ this.currentTransaction = null;
+ this.actionCount = 0;
+ }
+ }
+
+ protected Optional<String> locateErrorMessages(String response) {
+ final List<String> errorMessages = new ArrayList<>();
+ final List<String> results = JsonPathUtil.getInstance().locateResultList(response, "$..body");
+ final ObjectMapper mapper = new ObjectMapper();
+ if (!results.isEmpty()) {
+ List<Map<String, Object>> parsed = new ArrayList<>();
+ try {
+ for (String result : results) {
+ parsed.add(mapper.readValue(result, new TypeReference<Map<String, Object>>(){}));
+ }
+ } catch (IOException e) {
+ logger.error("could not map json", e);
+ }
+ for (Map<String, Object> map : parsed) {
+ for (Entry<String, Object> entry : map.entrySet()) {
+ if (!entry.getKey().matches("2\\d\\d")) {
+ AAIError error;
+ try {
+ error = mapper.readValue(entry.getValue().toString(), AAIError.class);
+ } catch (IOException e) {
+ logger.error("could not parse error object from A&AI", e);
+ error = new AAIError();
+ }
+ AAIErrorFormatter formatter = new AAIErrorFormatter(error);
+ String outputMessage = formatter.getMessage();
+ logger.error("part of a bulk action failed in A&AI: " + entry.getValue());
+ errorMessages.add(outputMessage);
+ }
+ }
+ }
+ }
+
+ if (!errorMessages.isEmpty()) {
+ return Optional.of(Joiner.on("\n").join(errorMessages));
+ } else {
+ return Optional.empty();
+ }
+ }
+ private Relationship buildRelationship(AAIUri uri) {
+ final Relationship result = new Relationship();
+ result.setRelatedLink(uri.build().toString());
+ return result;
+ }
+
+ @Override
+ protected AAIVersion getVersion() {
+ return this.version;
+ }
+
+ protected Transactions getTransactions() {
+ return this.transactions;
+ }
+}
diff --git a/common/src/main/java/org/onap/so/client/aai/AAIUpdator.java b/common/src/main/java/org/onap/so/client/aai/AAIUpdator.java
new file mode 100644
index 0000000000..8921e4bbbe
--- /dev/null
+++ b/common/src/main/java/org/onap/so/client/aai/AAIUpdator.java
@@ -0,0 +1,31 @@
+/*-
+ * ============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.aai;
+
+import java.io.IOException;
+
+public interface AAIUpdator {
+
+ void updateVnfToLocked(String vnfName, String uuid) throws IOException, Exception;
+
+ void updateVnfToUnLocked(String vnfName, String uuid) throws IOException, Exception;
+
+}
diff --git a/common/src/main/java/org/onap/so/client/aai/AAIUpdatorImpl.java b/common/src/main/java/org/onap/so/client/aai/AAIUpdatorImpl.java
new file mode 100644
index 0000000000..a971fded0e
--- /dev/null
+++ b/common/src/main/java/org/onap/so/client/aai/AAIUpdatorImpl.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.so.client.aai;
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+
+public class AAIUpdatorImpl implements AAIUpdator {
+
+ @Autowired
+ protected AAIRestClientI client;
+
+ public AAIRestClientI getClient() {
+ return client;
+ }
+
+
+ public void setClient(AAIRestClientI client) {
+ this.client = client;
+ }
+
+ @Override
+ public void updateVnfToLocked(String vnfId, String uuid) throws Exception {
+ client.updateMaintenceFlagVnfId(vnfId, true, uuid);
+ }
+
+ @Override
+ public void updateVnfToUnLocked(String vnfId, String uuid) throws Exception {
+ client.updateMaintenceFlagVnfId(vnfId, false, uuid);
+ }
+
+}
diff --git a/common/src/main/java/org/onap/so/client/aai/AAIValidator.java b/common/src/main/java/org/onap/so/client/aai/AAIValidator.java
new file mode 100644
index 0000000000..bf6485a631
--- /dev/null
+++ b/common/src/main/java/org/onap/so/client/aai/AAIValidator.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.so.client.aai;
+
+import java.io.IOException;
+
+public interface AAIValidator {
+
+ boolean isPhysicalServerLocked(String hostName, String transactionLoggingUuid) throws IOException;
+
+ boolean isVNFLocked(String vnfId, String transactionLoggingUuid) throws IOException, Exception;
+
+
+} \ No newline at end of file
diff --git a/common/src/main/java/org/onap/so/client/aai/AAIValidatorImpl.java b/common/src/main/java/org/onap/so/client/aai/AAIValidatorImpl.java
new file mode 100644
index 0000000000..fb6d122630
--- /dev/null
+++ b/common/src/main/java/org/onap/so/client/aai/AAIValidatorImpl.java
@@ -0,0 +1,71 @@
+/*-
+ * ============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.aai;
+
+import java.io.IOException;
+import java.util.List;
+
+import org.onap.aai.domain.yang.GenericVnf;
+import org.onap.aai.domain.yang.Pserver;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+
+
+
+public class AAIValidatorImpl implements AAIValidator {
+
+
+ @Autowired
+ protected AAIRestClientI client;
+
+ public AAIRestClientI getClient() {
+ return client;
+ }
+
+
+ public void setClient(AAIRestClientI client) {
+ this.client = client;
+ }
+
+ @Override
+ public boolean isPhysicalServerLocked(String vnfId, String transactionLoggingUuid) throws IOException {
+ List<Pserver> pservers;
+ boolean isLocked = false;
+ pservers = client.getPhysicalServerByVnfId(vnfId, transactionLoggingUuid);
+ for (Pserver pserver : pservers)
+ if (pserver.isInMaint())
+ isLocked = true;
+
+ return isLocked;
+ }
+
+ @Override
+ public boolean isVNFLocked(String vnfId, String transactionLoggingUuid) throws Exception {
+ boolean isLocked = false;
+ GenericVnf genericVnf = client.getVnfByName(vnfId, transactionLoggingUuid);
+ if (genericVnf.isInMaint())
+ isLocked = true;
+
+ return isLocked;
+ }
+
+}
diff --git a/common/src/main/java/org/onap/so/client/aai/AAIVersion.java b/common/src/main/java/org/onap/so/client/aai/AAIVersion.java
new file mode 100644
index 0000000000..20ee5becca
--- /dev/null
+++ b/common/src/main/java/org/onap/so/client/aai/AAIVersion.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.so.client.aai;
+
+import org.onap.so.client.graphinventory.GraphInventoryVersion;
+
+public enum AAIVersion implements GraphInventoryVersion {
+ V8("v8"),
+ V9("v9"),
+ V10("v10"),
+ V11("v11"),
+ V12("v12"),
+ V13("v13");
+
+ public final static AAIVersion LATEST = AAIVersion.values()[AAIVersion.values().length - 1];
+ private final String value;
+ private AAIVersion(String value){
+ this.value = value;
+ }
+ @Override
+ public String toString(){
+ return this.value;
+ }
+}
+
+
diff --git a/common/src/main/java/org/onap/so/client/aai/EmptyStringToNullSerializer.java b/common/src/main/java/org/onap/so/client/aai/EmptyStringToNullSerializer.java
new file mode 100644
index 0000000000..1120ebe0b9
--- /dev/null
+++ b/common/src/main/java/org/onap/so/client/aai/EmptyStringToNullSerializer.java
@@ -0,0 +1,52 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2017 - 2018 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.so.client.aai;
+
+import java.io.IOException;
+
+import com.fasterxml.jackson.core.JsonGenerator;
+import com.fasterxml.jackson.core.JsonProcessingException;
+import com.fasterxml.jackson.databind.SerializerProvider;
+import com.fasterxml.jackson.databind.ser.std.StdSerializer;
+
+public class EmptyStringToNullSerializer extends StdSerializer<String> {
+
+ private static final long serialVersionUID = 5367385969270400106L;
+
+ public EmptyStringToNullSerializer() {
+ this(null);
+ }
+ public EmptyStringToNullSerializer(Class<String> t) {
+ super(t);
+ }
+
+ @Override
+ public void serialize(String value, JsonGenerator gen, SerializerProvider serializers)
+ throws IOException, JsonProcessingException {
+
+ if("".equals(value)) {
+ gen.writeNull();
+ } else {
+ gen.writeString(value);
+ }
+ }
+
+}
diff --git a/common/src/main/java/org/onap/so/client/aai/entities/AAIEntity.java b/common/src/main/java/org/onap/so/client/aai/entities/AAIEntity.java
new file mode 100644
index 0000000000..c2aceeeeba
--- /dev/null
+++ b/common/src/main/java/org/onap/so/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.so.client.aai.entities;
+
+public class AAIEntity{
+
+}
diff --git a/common/src/main/java/org/onap/so/client/aai/entities/AAIEntityObject.java b/common/src/main/java/org/onap/so/client/aai/entities/AAIEntityObject.java
new file mode 100644
index 0000000000..dc91c8a034
--- /dev/null
+++ b/common/src/main/java/org/onap/so/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.so.client.aai.entities;
+
+import org.onap.so.client.aai.entities.uri.AAIResourceUri;
+
+public interface AAIEntityObject {
+
+ public AAIResourceUri getUri();
+
+}
diff --git a/common/src/main/java/org/onap/so/client/aai/entities/AAIError.java b/common/src/main/java/org/onap/so/client/aai/entities/AAIError.java
new file mode 100644
index 0000000000..4261f4f3c0
--- /dev/null
+++ b/common/src/main/java/org/onap/so/client/aai/entities/AAIError.java
@@ -0,0 +1,46 @@
+/*-
+ * ============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.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/common/src/main/java/org/onap/so/client/aai/entities/AAIResultWrapper.java b/common/src/main/java/org/onap/so/client/aai/entities/AAIResultWrapper.java
new file mode 100644
index 0000000000..9087995f97
--- /dev/null
+++ b/common/src/main/java/org/onap/so/client/aai/entities/AAIResultWrapper.java
@@ -0,0 +1,92 @@
+/*-
+ * ============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.aai.entities;
+
+import java.io.IOException;
+import java.io.Serializable;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Optional;
+
+import org.onap.so.client.aai.AAICommonObjectMapperProvider;
+import org.onap.so.jsonpath.JsonPathUtil;
+
+import com.fasterxml.jackson.core.type.TypeReference;
+import com.fasterxml.jackson.databind.ObjectMapper;
+
+public class AAIResultWrapper implements Serializable {
+
+ private static final long serialVersionUID = 5895841925807816737L;
+ private final Optional<String> jsonBody;
+ private final ObjectMapper mapper;
+ public AAIResultWrapper(String json) {
+ this.jsonBody = Optional.ofNullable(json);
+ this.mapper = new AAICommonObjectMapperProvider().getMapper();
+ }
+
+ public Optional<Relationships> getRelationships() {
+ final String path = "$.relationship-list";
+ if (!jsonBody.isPresent()) {
+ return Optional.empty();
+ }
+ Optional<String> result = JsonPathUtil.getInstance().locateResult(jsonBody.get(), path);
+ if (result.isPresent()) {
+ return Optional.of(new Relationships(result.get()));
+ } else {
+ return Optional.empty();
+ }
+ }
+
+ public String getJson() {
+ return jsonBody.orElse("{}");
+ }
+
+ public Map<String, Object> asMap() {
+ if (!this.jsonBody.isPresent()) {
+ return new HashMap<>();
+ }
+ try {
+ return mapper.readValue(this.jsonBody.get(), new TypeReference<Map<String, Object>>(){});
+ } catch (IOException e) {
+ return new HashMap<>();
+ }
+ }
+
+ public <T> Optional<T> asBean(Class<T> clazz) {
+ if (!this.jsonBody.isPresent()) {
+ return Optional.empty();
+ }
+ try {
+ return Optional.of(mapper.readValue(this.jsonBody.get(), clazz));
+ } catch (IOException e) {
+ return Optional.empty();
+ }
+ }
+
+ public boolean isEmpty() {
+ return !this.jsonBody.isPresent();
+ }
+ @Override
+ public String toString() {
+ return this.getJson();
+ }
+
+}
diff --git a/common/src/main/java/org/onap/so/client/aai/entities/Configuration.java b/common/src/main/java/org/onap/so/client/aai/entities/Configuration.java
new file mode 100644
index 0000000000..e1ce3a8adc
--- /dev/null
+++ b/common/src/main/java/org/onap/so/client/aai/entities/Configuration.java
@@ -0,0 +1,161 @@
+/*-
+ * ============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.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/common/src/main/java/org/onap/so/client/aai/entities/CustomQuery.java b/common/src/main/java/org/onap/so/client/aai/entities/CustomQuery.java
new file mode 100644
index 0000000000..8203476c82
--- /dev/null
+++ b/common/src/main/java/org/onap/so/client/aai/entities/CustomQuery.java
@@ -0,0 +1,82 @@
+/*-
+ * ============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.aai.entities;
+
+import java.io.UnsupportedEncodingException;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.onap.so.client.aai.entities.uri.AAIResourceUri;
+
+import com.fasterxml.jackson.annotation.JsonInclude;
+
+
+@JsonInclude(JsonInclude.Include.NON_NULL)
+public class CustomQuery {
+
+ private List<String> start;
+ private String query;
+ private String gremlin;
+
+ public String getGremlin() {
+ return gremlin;
+ }
+
+ public void setGremlin(String gremlin) {
+ this.gremlin = gremlin;
+ }
+
+
+ public CustomQuery(List<AAIResourceUri> start){
+ this.setStart(start);
+ }
+
+ public CustomQuery(List<AAIResourceUri> start, String query){
+ this.setStart(start);
+ this.query= "query/" + query;
+ }
+
+ public CustomQuery(String gremlin) throws UnsupportedEncodingException{
+ this.gremlin=gremlin;
+ }
+
+ public List<String> getStart() {
+ return start;
+ }
+
+ public void setStart(List<AAIResourceUri> start) {
+ this.start = this.mapUris(start);
+ }
+
+ public String getQuery() {
+ return query;
+ }
+
+ public void setQuery(String query) {
+ this.query = query;
+ }
+
+ private List<String> mapUris(List<AAIResourceUri> uris) {
+ final List<String> result = new ArrayList<>();
+ uris.stream().map(item -> item.build().toString()).forEach(result::add);
+ return result;
+ }
+}
diff --git a/common/src/main/java/org/onap/so/client/aai/entities/Relationships.java b/common/src/main/java/org/onap/so/client/aai/entities/Relationships.java
new file mode 100644
index 0000000000..bab145b3fd
--- /dev/null
+++ b/common/src/main/java/org/onap/so/client/aai/entities/Relationships.java
@@ -0,0 +1,140 @@
+/*-
+ * ============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.aai.entities;
+
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Optional;
+import java.util.function.Predicate;
+
+import javax.ws.rs.core.UriBuilder;
+
+import org.onap.so.client.aai.AAICommonObjectMapperProvider;
+import org.onap.so.client.aai.AAIObjectType;
+import org.onap.so.client.aai.AAIResourcesClient;
+import org.onap.so.client.aai.entities.uri.AAIResourceUri;
+import org.onap.so.client.aai.entities.uri.AAIUriFactory;
+import org.onap.so.client.graphinventory.GraphInventoryObjectName;
+import org.onap.so.jsonpath.JsonPathUtil;
+
+import com.fasterxml.jackson.core.type.TypeReference;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.google.common.base.CaseFormat;
+
+public class Relationships {
+
+ private final ObjectMapper mapper;
+ private Map<String, Object> map;
+ private final String jsonBody;
+ public Relationships(String json) {
+ this.jsonBody = json;
+ this.mapper = new AAICommonObjectMapperProvider().getMapper();
+ try {
+ this.map = mapper.readValue(json, new TypeReference<Map<String, Object>>() {});
+ } catch (IOException e) {
+ this.map = new HashMap<>();
+ }
+ }
+
+ public List<AAIResultWrapper> getByType(GraphInventoryObjectName type) {
+
+ return this.getAll(Optional.of(type));
+ }
+
+ public List<AAIResultWrapper> getAll() {
+
+ return this.getAll(Optional.empty());
+ }
+
+
+ public List<String> getRelatedLinks() {
+ return this.getRelatedLinks(Optional.empty());
+ }
+
+ public List<String> getRelatedLinks(GraphInventoryObjectName type) {
+ return this.getRelatedLinks(Optional.of(type));
+ }
+
+ public List<AAIResourceUri> getRelatedAAIUris() {
+ return this.getRelatedAAIUris(x -> true);
+ }
+
+ public List<AAIResourceUri> getRelatedAAIUris(GraphInventoryObjectName type) {
+ return this.getRelatedAAIUris(x -> type.typeName().equals(x));
+ }
+ protected List<AAIResourceUri> getRelatedAAIUris(Predicate<String> p) {
+ List<AAIResourceUri> result = new ArrayList<>();
+ if (map.containsKey("relationship")) {
+ List<Map<String, Object>> relationships = (List<Map<String, Object>>)map.get("relationship");
+ for (Map<String, Object> relationship : relationships) {
+ final String relatedTo = (String)relationship.get("related-to");
+ if (p.test(relatedTo)) {
+ AAIObjectType type;
+ try {
+ type = AAIObjectType.valueOf(CaseFormat.LOWER_HYPHEN.to(CaseFormat.UPPER_UNDERSCORE, relatedTo));
+ } catch (IllegalArgumentException e) {
+ type = AAIObjectType.UNKNOWN;
+ }
+ final String relatedLink = (String)relationship.get("related-link");
+
+ result.add(AAIUriFactory.createResourceFromExistingURI(type, UriBuilder.fromPath(relatedLink).build()));
+ }
+ }
+ }
+ return result;
+ }
+
+
+
+ protected List<AAIResultWrapper> getAll(final Optional<GraphInventoryObjectName> type) {
+ List<AAIResourceUri> relatedLinks;
+ if (type.isPresent()) {
+ relatedLinks = this.getRelatedAAIUris(type.get());
+ } else {
+ relatedLinks = this.getRelatedAAIUris();
+ }
+ ArrayList<AAIResultWrapper> result = new ArrayList<>();
+ for (AAIResourceUri link : relatedLinks) {
+ result.add(this.get(link));
+ }
+ return result;
+ }
+
+ protected AAIResultWrapper get(AAIResourceUri uri) {
+ return new AAIResourcesClient().get(uri);
+
+ }
+
+ protected List<String> getRelatedLinks(Optional<GraphInventoryObjectName> type) {
+ String matcher = "";
+ if (type.isPresent()) {
+ matcher = "[?(@.related-to=='" + type.get() + "')]";
+ }
+ return JsonPathUtil.getInstance().locateResultList(this.jsonBody, String.format("$.relationship%s.related-link", matcher));
+ }
+
+ public String getJson() {
+ return this.jsonBody;
+ }
+}
diff --git a/common/src/main/java/org/onap/so/client/aai/entities/RequestError.java b/common/src/main/java/org/onap/so/client/aai/entities/RequestError.java
new file mode 100644
index 0000000000..bc8c283e34
--- /dev/null
+++ b/common/src/main/java/org/onap/so/client/aai/entities/RequestError.java
@@ -0,0 +1,46 @@
+/*-
+ * ============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.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/common/src/main/java/org/onap/so/client/aai/entities/Results.java b/common/src/main/java/org/onap/so/client/aai/entities/Results.java
new file mode 100644
index 0000000000..c3f0ad1fa1
--- /dev/null
+++ b/common/src/main/java/org/onap/so/client/aai/entities/Results.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.so.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<T> {
+ @JsonProperty("results")
+ protected List<T> results;
+
+ @JsonProperty("results")
+ public List<T> getResult() {
+ if (results == null) {
+ results = new ArrayList<>();
+ }
+ return this.results;
+ }
+ @JsonProperty("results")
+ public void setResult(List<T> results) {
+ this.results=results;
+ }
+}
diff --git a/common/src/main/java/org/onap/so/client/aai/entities/ServiceException.java b/common/src/main/java/org/onap/so/client/aai/entities/ServiceException.java
new file mode 100644
index 0000000000..9d9723c514
--- /dev/null
+++ b/common/src/main/java/org/onap/so/client/aai/entities/ServiceException.java
@@ -0,0 +1,75 @@
+/*-
+ * ============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.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<String> 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<String> getVariables() {
+ return variables;
+ }
+
+ @JsonProperty("variables")
+ public void setVariables(List<String> variables) {
+ this.variables = variables;
+ }
+
+}
diff --git a/common/src/main/java/org/onap/so/client/aai/entities/bulkprocess/OperationBody.java b/common/src/main/java/org/onap/so/client/aai/entities/bulkprocess/OperationBody.java
new file mode 100644
index 0000000000..1803440edd
--- /dev/null
+++ b/common/src/main/java/org/onap/so/client/aai/entities/bulkprocess/OperationBody.java
@@ -0,0 +1,69 @@
+/*-
+ * ============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.aai.entities.bulkprocess;
+
+import com.fasterxml.jackson.annotation.JsonInclude;
+import com.fasterxml.jackson.annotation.JsonProperty;
+import com.fasterxml.jackson.annotation.JsonPropertyOrder;
+
+@JsonInclude(JsonInclude.Include.NON_NULL)
+@JsonPropertyOrder({
+"uri",
+"body"
+})
+public class OperationBody {
+
+@JsonProperty("uri")
+private String uri;
+@JsonProperty("body")
+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/common/src/main/java/org/onap/so/client/aai/entities/bulkprocess/Transaction.java b/common/src/main/java/org/onap/so/client/aai/entities/bulkprocess/Transaction.java
new file mode 100644
index 0000000000..1c405753c3
--- /dev/null
+++ b/common/src/main/java/org/onap/so/client/aai/entities/bulkprocess/Transaction.java
@@ -0,0 +1,95 @@
+/*-
+ * ============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.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<OperationBody> put = new ArrayList<>();
+
+@JsonInclude(JsonInclude.Include.NON_EMPTY)
+@JsonProperty("patch")
+private List<OperationBody> patch = new ArrayList<>();
+
+@JsonInclude(JsonInclude.Include.NON_EMPTY)
+@JsonProperty("delete")
+private List<OperationBody> delete = new ArrayList<>();
+
+@JsonProperty("put")
+public List<OperationBody> getPut() {
+return put;
+}
+
+@JsonProperty("put")
+public void setPut(List<OperationBody> put) {
+this.put = put;
+}
+
+public Transaction withPut(List<OperationBody> put) {
+this.put = put;
+return this;
+}
+
+@JsonProperty("patch")
+public List<OperationBody> getPatch() {
+return patch;
+}
+
+@JsonProperty("patch")
+public void setPatch(List<OperationBody> patch) {
+this.patch = patch;
+}
+
+public Transaction withPatch(List<OperationBody> patch) {
+this.patch = patch;
+return this;
+}
+
+@JsonProperty("delete")
+public List<OperationBody> getDelete() {
+return delete;
+}
+
+@JsonProperty("delete")
+public void setDelete(List<OperationBody> delete) {
+this.delete = delete;
+}
+
+public Transaction withDelete(List<OperationBody> delete) {
+this.delete = delete;
+return this;
+}
+
+}
diff --git a/common/src/main/java/org/onap/so/client/aai/entities/bulkprocess/Transactions.java b/common/src/main/java/org/onap/so/client/aai/entities/bulkprocess/Transactions.java
new file mode 100644
index 0000000000..51d56d371a
--- /dev/null
+++ b/common/src/main/java/org/onap/so/client/aai/entities/bulkprocess/Transactions.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.so.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<Transaction> transactions = new ArrayList<>();
+
+@JsonProperty("transactions")
+public List<Transaction> getTransactions() {
+return transactions;
+}
+
+@JsonProperty("transactions")
+public void setTransactions(List<Transaction> transactions) {
+this.transactions = transactions;
+}
+
+public Transactions withTransactions(List<Transaction> transactions) {
+this.transactions = transactions;
+return this;
+}
+
+}
diff --git a/common/src/main/java/org/onap/so/client/aai/entities/uri/AAIResourceUri.java b/common/src/main/java/org/onap/so/client/aai/entities/uri/AAIResourceUri.java
new file mode 100644
index 0000000000..42fa1ad02a
--- /dev/null
+++ b/common/src/main/java/org/onap/so/client/aai/entities/uri/AAIResourceUri.java
@@ -0,0 +1,46 @@
+/*-
+ * ============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.aai.entities.uri;
+
+import org.onap.so.client.aai.AAIObjectPlurals;
+import org.onap.so.client.aai.AAIObjectType;
+import org.onap.so.client.graphinventory.Format;
+import org.onap.so.client.graphinventory.entities.uri.Depth;
+import org.onap.so.client.graphinventory.entities.uri.GraphInventoryResourceUri;
+
+public interface AAIResourceUri extends AAIUri, GraphInventoryResourceUri {
+
+ public AAIResourceUri relationshipAPI();
+ public AAIResourceUri relatedTo(AAIObjectPlurals plural);
+ public AAIResourceUri relatedTo(AAIObjectType type, String... values);
+ public AAIResourceUri resourceVersion(String version);
+ public AAIResourceUri format(Format format);
+ @Override
+ public AAIResourceUri depth(Depth depth);
+ @Override
+ public AAIResourceUri nodesOnly(boolean nodesOnly);
+ @Override
+ public AAIResourceUri queryParam(String name, String... values);
+ @Override
+ public AAIResourceUri replaceQueryParam(String name, String... values);
+ @Override
+ public AAIResourceUri clone();
+}
diff --git a/common/src/main/java/org/onap/so/client/aai/entities/uri/AAISimpleUri.java b/common/src/main/java/org/onap/so/client/aai/entities/uri/AAISimpleUri.java
new file mode 100644
index 0000000000..14671b2f85
--- /dev/null
+++ b/common/src/main/java/org/onap/so/client/aai/entities/uri/AAISimpleUri.java
@@ -0,0 +1,111 @@
+/*-
+ * ============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.aai.entities.uri;
+
+import java.net.URI;
+
+import javax.ws.rs.core.UriBuilder;
+
+import org.onap.so.client.aai.AAIObjectPlurals;
+import org.onap.so.client.aai.AAIObjectType;
+import org.onap.so.client.graphinventory.Format;
+import org.onap.so.client.graphinventory.entities.uri.Depth;
+import org.onap.so.client.graphinventory.entities.uri.SimpleUri;
+
+public class AAISimpleUri extends SimpleUri implements AAIResourceUri {
+
+ 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(AAIObjectPlurals type, UriBuilder builder, Object... values) {
+ super(type, builder, values);
+ }
+ protected AAISimpleUri(AAIObjectPlurals type) {
+ super(type);
+ }
+ protected AAISimpleUri(AAIObjectPlurals type, Object... values) {
+ super(type, values);
+ }
+
+ @Override
+ public AAISimpleUri relationshipAPI() {
+ return (AAISimpleUri) super.relationshipAPI();
+ }
+
+ @Override
+ public AAISimpleUri relatedTo(AAIObjectPlurals plural) {
+ return (AAISimpleUri) super.relatedTo(plural);
+ }
+ @Override
+ public AAISimpleUri relatedTo(AAIObjectType type, String... values) {
+ return (AAISimpleUri) super.relatedTo(type, values);
+ }
+
+ @Override
+ public AAISimpleUri resourceVersion(String version) {
+ return (AAISimpleUri) super.resourceVersion(version);
+ }
+
+ @Override
+ public AAISimpleUri queryParam(String name, String... values) {
+ return (AAISimpleUri) super.queryParam(name, values);
+ }
+
+ @Override
+ public AAISimpleUri replaceQueryParam(String name, String... values) {
+ return (AAISimpleUri) super.replaceQueryParam(name, values);
+ }
+
+ @Override
+ public AAISimpleUri clone() {
+ if (this.type != null) {
+ return new AAISimpleUri((AAIObjectType)this.type, this.internalURI.clone(), values);
+ } else {
+ return new AAISimpleUri((AAIObjectPlurals)this.pluralType, this.internalURI.clone(), values);
+ }
+ }
+
+ @Override
+ public AAIObjectType getObjectType() {
+ return (AAIObjectType)this.type;
+ }
+
+ @Override
+ public AAISimpleUri depth(Depth depth) {
+ return (AAISimpleUri) super.depth(depth);
+ }
+ @Override
+ public AAISimpleUri nodesOnly(boolean nodesOnly) {
+ return (AAISimpleUri)super.nodesOnly(nodesOnly);
+ }
+
+ @Override
+ public AAISimpleUri format(Format format) {
+ return (AAISimpleUri)super.format(format);
+ }
+}
diff --git a/common/src/main/java/org/onap/so/client/aai/entities/uri/AAIUri.java b/common/src/main/java/org/onap/so/client/aai/entities/uri/AAIUri.java
new file mode 100644
index 0000000000..eb336d9219
--- /dev/null
+++ b/common/src/main/java/org/onap/so/client/aai/entities/uri/AAIUri.java
@@ -0,0 +1,60 @@
+/*-
+ * ============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.aai.entities.uri;
+
+import java.net.URI;
+import java.util.Map;
+
+import org.onap.so.client.aai.AAIObjectType;
+import org.onap.so.client.graphinventory.GraphInventoryObjectType;
+import org.onap.so.client.graphinventory.entities.uri.Depth;
+import org.onap.so.client.graphinventory.entities.uri.GraphInventoryUri;
+
+public interface AAIUri extends GraphInventoryUri {
+
+ /**
+ * By default A&AI 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
+ */
+ @Override
+ public AAIUri depth(Depth depth);
+ /**
+ * Makes client only return object fields, no relationships
+ *
+ * @return
+ */
+ @Override
+ public AAIUri nodesOnly(boolean nodesOnly);
+ @Override
+ public AAIUri queryParam(String name, String... values);
+ @Override
+ public AAIUri replaceQueryParam(String name, String... values);
+ @Override
+ public AAIUri clone();
+
+ @Override
+ public AAIObjectType getObjectType();
+}
diff --git a/common/src/main/java/org/onap/so/client/aai/entities/uri/AAIUriFactory.java b/common/src/main/java/org/onap/so/client/aai/entities/uri/AAIUriFactory.java
new file mode 100644
index 0000000000..2a7c8ee78c
--- /dev/null
+++ b/common/src/main/java/org/onap/so/client/aai/entities/uri/AAIUriFactory.java
@@ -0,0 +1,86 @@
+/*-
+ * ============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.aai.entities.uri;
+
+import java.net.URI;
+
+import org.onap.so.client.aai.AAIObjectPlurals;
+import org.onap.so.client.aai.AAIObjectType;
+import org.onap.so.client.graphinventory.entities.uri.SimpleUri;
+
+
+public class AAIUriFactory {
+
+ /**
+ * values are filled into the URI template specified in {@link AAIObjectType} in order
+ *
+ * @param type
+ * @param values
+ * @return
+ */
+ public static AAIResourceUri createResourceUri(AAIObjectType type, Object... values) {
+ if (AAIObjectType.SERVICE_INSTANCE.equals(type)) {
+ return new ServiceInstanceUri(values);
+ } else {
+ return new AAISimpleUri(type, values);
+ }
+ }
+
+ public static AAIResourceUri createNodesUri(AAIObjectType type, Object... values) {
+ return new NodesUri(type, values);
+
+ }
+
+ /**
+ * 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 AAIResourceUri createResourceFromExistingURI(AAIObjectType type, URI uri) {
+ return new AAISimpleUri(type, uri);
+ }
+
+ /**
+ * Creates a uri for a plural type e.g. /cloud-infrastructure/pservers
+ *
+ * @param type
+ * @return
+ */
+ public static AAIResourceUri createResourceUri(AAIObjectPlurals type) {
+
+ return new AAISimpleUri(type);
+
+ }
+
+ /**
+ * Creates a uri for a plural type with values e.g. /cloud-infrastructure/pservers
+ *
+ * @param type
+ * @return
+ */
+ public static AAIResourceUri createResourceUri(AAIObjectPlurals type, Object... values) {
+
+ return new AAISimpleUri(type, values);
+
+ }
+}
diff --git a/common/src/main/java/org/onap/so/client/aai/entities/uri/NodesUri.java b/common/src/main/java/org/onap/so/client/aai/entities/uri/NodesUri.java
new file mode 100644
index 0000000000..ccae0b44b7
--- /dev/null
+++ b/common/src/main/java/org/onap/so/client/aai/entities/uri/NodesUri.java
@@ -0,0 +1,43 @@
+/*-
+ * ============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.aai.entities.uri;
+
+import org.onap.so.client.aai.AAIObjectType;
+import org.onap.so.client.graphinventory.GraphInventoryObjectPlurals;
+import org.onap.so.client.graphinventory.GraphInventoryObjectType;
+
+public class NodesUri extends AAISimpleUri {
+
+ protected NodesUri(AAIObjectType type, Object... values) {
+ super(type, values);
+ }
+
+
+ @Override
+ protected String getTemplate(GraphInventoryObjectType type) {
+ return "/nodes" + type.partialUri();
+ }
+
+ @Override
+ protected String getTemplate(GraphInventoryObjectPlurals type) {
+ return "/nodes" + type.partialUri();
+ }
+}
diff --git a/common/src/main/java/org/onap/so/client/aai/entities/uri/ServiceInstanceUri.java b/common/src/main/java/org/onap/so/client/aai/entities/uri/ServiceInstanceUri.java
new file mode 100644
index 0000000000..093918d49b
--- /dev/null
+++ b/common/src/main/java/org/onap/so/client/aai/entities/uri/ServiceInstanceUri.java
@@ -0,0 +1,126 @@
+/*-
+ * ============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.aai.entities.uri;
+
+import java.io.IOException;
+import java.net.URI;
+import java.util.Collections;
+import java.util.Map;
+import java.util.Optional;
+
+import javax.ws.rs.BadRequestException;
+import javax.ws.rs.core.UriBuilder;
+
+import org.onap.so.client.aai.AAIObjectType;
+import org.onap.so.client.aai.AAIQueryClient;
+import org.onap.so.client.graphinventory.Format;
+import org.onap.so.client.aai.entities.CustomQuery;
+import org.onap.so.client.aai.entities.Results;
+import org.onap.so.client.graphinventory.entities.uri.SimpleUri;
+import org.onap.so.client.graphinventory.exceptions.GraphInventoryPayloadException;
+import org.onap.so.client.graphinventory.exceptions.GraphInventoryUriComputationException;
+import org.onap.so.client.graphinventory.exceptions.GraphInventoryUriNotFoundException;
+
+import com.fasterxml.jackson.core.type.TypeReference;
+import com.fasterxml.jackson.databind.ObjectMapper;
+
+public class ServiceInstanceUri extends AAISimpleUri {
+
+ private Optional<String> cachedValue = Optional.empty();
+
+ protected ServiceInstanceUri(Object... values) {
+ super(AAIObjectType.SERVICE_INSTANCE, values);
+ }
+ protected ServiceInstanceUri(UriBuilder builder, Optional<String> cachedValue, Object... values) {
+ super(AAIObjectType.SERVICE_INSTANCE, builder, values);
+ this.cachedValue = cachedValue;
+ }
+ protected String getSerivceInstance(Object id) throws GraphInventoryUriNotFoundException, GraphInventoryPayloadException {
+ if (!this.getCachedValue().isPresent()) {
+ AAIResourceUri serviceInstanceUri = AAIUriFactory.createNodesUri(AAIObjectType.SERVICE_INSTANCE, id);
+ CustomQuery query = new CustomQuery(Collections.singletonList(serviceInstanceUri));
+ String resultJson;
+ try {
+ resultJson = this.getQueryClient().query(Format.PATHED, query);
+ } catch (BadRequestException e) {
+ throw new GraphInventoryUriNotFoundException("Service instance " + id + " not found at: " + serviceInstanceUri.build());
+
+ }
+ try {
+ cachedValue = extractRelatedLink(resultJson);
+ if (!cachedValue.isPresent()) {
+ throw new GraphInventoryUriNotFoundException("Service instance " + id + " not found at: " + serviceInstanceUri.build());
+ }
+ } catch (IOException e) {
+ throw new GraphInventoryPayloadException("could not map payload: " + resultJson, e);
+ }
+ }
+ Optional<String> cachedValueOpt = this.getCachedValue();
+ return cachedValueOpt.isPresent() ? cachedValueOpt.get() : "";
+ }
+
+ protected Optional<String> extractRelatedLink(String jsonString) throws IOException {
+ Optional<String> result;
+ ObjectMapper mapper = new ObjectMapper();
+
+ Results<Map<String, String>> results = mapper.readValue(jsonString, new TypeReference<Results<Map<String, String>>>(){});
+ if (results.getResult().size() == 1) {
+ String uriString = results.getResult().get(0).get("resource-link");
+ 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<String> getCachedValue() {
+ return this.cachedValue;
+ }
+
+ @Override
+ public URI build() {
+ try {
+ if (this.values.length == 1) {
+ String uri = getSerivceInstance(this.values[0]);
+ Map<String, String> map = getURIKeys(uri);
+ return super.build(map.values().toArray(values));
+ }
+ } catch (GraphInventoryUriNotFoundException | GraphInventoryPayloadException e) {
+ throw new GraphInventoryUriComputationException(e);
+ }
+ return super.build();
+ }
+
+ @Override
+ public ServiceInstanceUri clone() {
+ return new ServiceInstanceUri(this.internalURI.clone(), this.getCachedValue(), values);
+ }
+
+ protected AAIQueryClient getQueryClient() {
+ AAIResourceUri uri = AAIUriFactory.createNodesUri(AAIObjectType.ALLOTTED_RESOURCE, "").clone();
+ return new AAIQueryClient();
+ }
+}
diff --git a/common/src/main/java/org/onap/so/client/aai/objects/AAIOperationalEnvironment.java b/common/src/main/java/org/onap/so/client/aai/objects/AAIOperationalEnvironment.java
new file mode 100644
index 0000000000..02d8d56867
--- /dev/null
+++ b/common/src/main/java/org/onap/so/client/aai/objects/AAIOperationalEnvironment.java
@@ -0,0 +1,159 @@
+/*-
+ * ============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.aai.objects;
+
+import com.fasterxml.jackson.annotation.JsonInclude;
+import com.fasterxml.jackson.annotation.JsonProperty;
+import com.fasterxml.jackson.annotation.JsonPropertyOrder;
+
+@JsonInclude(JsonInclude.Include.NON_NULL)
+@JsonPropertyOrder({
+"operational-environment-id",
+"operational-environment-name",
+"operational-environment-type",
+"operational-environment-status",
+"tenant-context",
+"workload-context",
+"resource-version"
+})
+public class AAIOperationalEnvironment {
+
+@JsonProperty("operational-environment-id")
+private String operationalEnvironmentId;
+@JsonProperty("operational-environment-name")
+private String operationalEnvironmentName;
+@JsonProperty("operational-environment-type")
+private String operationalEnvironmentType;
+@JsonProperty("operational-environment-status")
+private String operationalEnvironmentStatus;
+@JsonProperty("tenant-context")
+private String tenantContext;
+@JsonProperty("workload-context")
+private String workloadContext;
+@JsonProperty("resource-version")
+private String resourceVersion;
+
+@JsonProperty("operational-environment-id")
+public String getOperationalEnvironmentId() {
+return operationalEnvironmentId;
+ }
+
+@JsonProperty("operational-environment-id")
+public void setOperationalEnvironmentId(String operationalEnvironmentId) {
+this.operationalEnvironmentId = operationalEnvironmentId;
+ }
+
+public AAIOperationalEnvironment withOperationalEnvironmentId(String operationalEnvironmentId) {
+this.operationalEnvironmentId = operationalEnvironmentId;
+return this;
+ }
+
+@JsonProperty("operational-environment-name")
+public String getOperationalEnvironmentName() {
+return operationalEnvironmentName;
+ }
+
+@JsonProperty("operational-environment-name")
+public void setOperationalEnvironmentName(String operationalEnvironmentName) {
+this.operationalEnvironmentName = operationalEnvironmentName;
+ }
+
+public AAIOperationalEnvironment withOperationalEnvironmentName(String operationalEnvironmentName) {
+this.operationalEnvironmentName = operationalEnvironmentName;
+return this;
+ }
+
+@JsonProperty("operational-environment-type")
+public String getOperationalEnvironmentType() {
+return operationalEnvironmentType;
+ }
+
+@JsonProperty("operational-environment-type")
+public void setOperationalEnvironmentType(String operationalEnvironmentType) {
+this.operationalEnvironmentType = operationalEnvironmentType;
+ }
+
+public AAIOperationalEnvironment withOperationalEnvironmentType(String operationalEnvironmentType) {
+this.operationalEnvironmentType = operationalEnvironmentType;
+return this;
+ }
+
+@JsonProperty("operational-environment-status")
+public String getOperationalEnvironmentStatus() {
+return operationalEnvironmentStatus;
+ }
+
+@JsonProperty("operational-environment-status")
+public void setOperationalEnvironmentStatus(String operationalEnvironmentStatus) {
+this.operationalEnvironmentStatus = operationalEnvironmentStatus;
+ }
+
+public AAIOperationalEnvironment withOperationalEnvironmentStatus(String operationalEnvironmentStatus) {
+this.operationalEnvironmentStatus = operationalEnvironmentStatus;
+return this;
+ }
+
+@JsonProperty("tenant-context")
+public String getTenantContext() {
+return tenantContext;
+ }
+
+@JsonProperty("tenant-context")
+public void setTenantContext(String tenantContext) {
+this.tenantContext = tenantContext;
+ }
+
+public AAIOperationalEnvironment withTenantContext(String tenantContext) {
+this.tenantContext = tenantContext;
+return this;
+ }
+
+@JsonProperty("workload-context")
+public String getWorkloadContext() {
+return workloadContext;
+ }
+
+@JsonProperty("workload-context")
+public void setWorkloadContext(String workloadContext) {
+this.workloadContext = workloadContext;
+ }
+
+public AAIOperationalEnvironment withWorkloadContext(String workloadContext) {
+this.workloadContext = workloadContext;
+return this;
+ }
+
+@JsonProperty("resource-version")
+public String getResourceVersion() {
+return resourceVersion;
+ }
+
+@JsonProperty("resource-version")
+public void setResourceVersion(String resourceVersion) {
+this.resourceVersion = resourceVersion;
+ }
+
+public AAIOperationalEnvironment withResourceVersion(String resourceVersion) {
+this.resourceVersion = resourceVersion;
+return this;
+ }
+
+}
diff --git a/common/src/main/java/org/onap/so/client/aai/objects/AAIServiceInstance.java b/common/src/main/java/org/onap/so/client/aai/objects/AAIServiceInstance.java
new file mode 100644
index 0000000000..af21949277
--- /dev/null
+++ b/common/src/main/java/org/onap/so/client/aai/objects/AAIServiceInstance.java
@@ -0,0 +1,141 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.so.client.aai.objects;
+
+import org.onap.so.client.aai.AAIObjectType;
+import org.onap.so.client.aai.entities.AAIEntityObject;
+import org.onap.so.client.aai.entities.uri.AAIResourceUri;
+import org.onap.so.client.aai.entities.uri.AAIUriFactory;
+
+import com.fasterxml.jackson.annotation.JsonProperty;
+
+public class AAIServiceInstance implements AAIEntityObject {
+
+ @JsonProperty("service-instance-id")
+ private String serviceInstanceId;
+ @JsonProperty("service-instance-name")
+ private String serviceInstanceName;
+ @JsonProperty("service-type")
+ private String serviceType;
+ @JsonProperty("service-role")
+ private String serviceRole;
+ @JsonProperty("orchestration-status")
+ private String oStatus;
+ @JsonProperty("model-invariant-id")
+ private String modelInvariantUuid;
+ @JsonProperty("model-version-id")
+ private String modelUuid;
+ @JsonProperty("environment-context")
+ private String environmentContext;
+ @JsonProperty("workload-context")
+ private String workloadContext;
+
+ public String getServiceInstanceName() {
+ return serviceInstanceName;
+ }
+
+ public void setServiceInstanceName(String serviceInstanceName) {
+ this.serviceInstanceName = serviceInstanceName;
+ }
+
+ public String getServiceType() {
+ return serviceType;
+ }
+
+ public void setServiceType(String serviceType) {
+ this.serviceType = serviceType;
+ }
+
+ public String getServiceRole() {
+ return serviceRole;
+ }
+
+ public void setServiceRole(String serviceRole) {
+ this.serviceRole = serviceRole;
+ }
+
+ public String getoStatus() {
+ return oStatus;
+ }
+
+ public void setoStatus(String oStatus) {
+ this.oStatus = oStatus;
+ }
+
+ public String getModelInvariantUuid() {
+ return modelInvariantUuid;
+ }
+
+ public void setModelInvariantUuid(String modelInvariantUuid) {
+ this.modelInvariantUuid = modelInvariantUuid;
+ }
+
+ public String getModelUuid() {
+ return modelUuid;
+ }
+
+ public void setModelUuid(String modelUuid) {
+ this.modelUuid = modelUuid;
+ }
+
+ public String getEnvironmentContext() {
+ return environmentContext;
+ }
+
+ public void setEnvironmentContext(String environmentContext) {
+ this.environmentContext = environmentContext;
+ }
+
+ public String getWorkloadContext() {
+ return workloadContext;
+ }
+
+ public void setWorkloadContext(String workloadContext) {
+ this.workloadContext = workloadContext;
+ }
+
+ public String getServiceInstanceId() {
+ return serviceInstanceId;
+ }
+
+ public void setServiceInstanceId(String serviceInstanceId) {
+ this.serviceInstanceId = serviceInstanceId;
+ }
+
+ public AAIServiceInstance withServiceInstance(String serviceInstanceId) {
+ this.setServiceInstanceId(serviceInstanceId);
+ return this;
+ }
+
+ @Override
+ public AAIResourceUri getUri() {
+ AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE, this.serviceInstanceId);
+ return uri;
+ }
+ @Override
+ public String toString() {
+ return "AAIServiceInstance [serviceInstanceId=" + serviceInstanceId + ", serviceInstanceName="
+ + serviceInstanceName + ", serviceType=" + serviceType + ", serviceRole=" + serviceRole + ", oStatus="
+ + oStatus + ", modelInvariantUuid=" + modelInvariantUuid + ", modelUuid=" + modelUuid
+ + ", environmentContext=" + environmentContext + ", workloadContext=" + workloadContext + "]";
+ }
+
+}