aboutsummaryrefslogtreecommitdiffstats
path: root/common/src/main/java/org/openecomp/mso/client/aai
diff options
context:
space:
mode:
authorRob Daugherty <rd472p@att.com>2018-03-14 02:07:32 -0400
committerRob Daugherty <rd472p@att.com>2018-03-14 04:08:41 -0400
commit38f720752af4d4aad8c4e467a288d9048659f688 (patch)
treee81066a8b5c77272e30fb57a64999573c4db4d86 /common/src/main/java/org/openecomp/mso/client/aai
parentaee3d223f92a6f250f43e17558a2dfd576ff7294 (diff)
AT&T 1712 and 1802 release code
This is code from AT&T's 1712 and 1802 releases. Change-Id: Ie1e85851e94bc66c4d9514a0226c221939531a04 Issue-ID: SO-425 Signed-off-by: Rob Daugherty <rd472p@att.com>
Diffstat (limited to 'common/src/main/java/org/openecomp/mso/client/aai')
-rw-r--r--common/src/main/java/org/openecomp/mso/client/aai/AAIClient.java69
-rw-r--r--common/src/main/java/org/openecomp/mso/client/aai/AAIClientResponseExceptionMapper.java61
-rw-r--r--common/src/main/java/org/openecomp/mso/client/aai/AAICommonObjectMapperProvider.java62
-rw-r--r--common/src/main/java/org/openecomp/mso/client/aai/AAIConfigurationClient.java74
-rw-r--r--common/src/main/java/org/openecomp/mso/client/aai/AAIErrorFormatter.java57
-rw-r--r--common/src/main/java/org/openecomp/mso/client/aai/AAINamespaceConstants.java31
-rw-r--r--common/src/main/java/org/openecomp/mso/client/aai/AAIObjectName.java29
-rw-r--r--common/src/main/java/org/openecomp/mso/client/aai/AAIObjectPlurals.java65
-rw-r--r--common/src/main/java/org/openecomp/mso/client/aai/AAIObjectType.java98
-rw-r--r--common/src/main/java/org/openecomp/mso/client/aai/AAIObjectUriPartial.java26
-rw-r--r--common/src/main/java/org/openecomp/mso/client/aai/AAIObjectUriTemplate.java26
-rw-r--r--common/src/main/java/org/openecomp/mso/client/aai/AAIProperties.java28
-rw-r--r--common/src/main/java/org/openecomp/mso/client/aai/AAIQueryClient.java93
-rw-r--r--common/src/main/java/org/openecomp/mso/client/aai/AAIQueryObjectMapperProvider.java44
-rw-r--r--common/src/main/java/org/openecomp/mso/client/aai/AAIResourcesClient.java244
-rw-r--r--common/src/main/java/org/openecomp/mso/client/aai/AAIResourcesObjectMapperProvider.java35
-rw-r--r--common/src/main/java/org/openecomp/mso/client/aai/AAIRestClient.java67
-rw-r--r--common/src/main/java/org/openecomp/mso/client/aai/AAIRestClientI.java44
-rw-r--r--common/src/main/java/org/openecomp/mso/client/aai/AAIRestClientImpl.java165
-rw-r--r--common/src/main/java/org/openecomp/mso/client/aai/AAISubgraphType.java38
-rw-r--r--common/src/main/java/org/openecomp/mso/client/aai/AAITransactionalClient.java263
-rw-r--r--common/src/main/java/org/openecomp/mso/client/aai/AAIUpdator.java31
-rw-r--r--common/src/main/java/org/openecomp/mso/client/aai/AAIUpdatorImpl.java49
-rw-r--r--common/src/main/java/org/openecomp/mso/client/aai/AAIValidator.java32
-rw-r--r--common/src/main/java/org/openecomp/mso/client/aai/AAIValidatorImpl.java71
-rw-r--r--common/src/main/java/org/openecomp/mso/client/aai/AAIVersion.java41
-rw-r--r--common/src/main/java/org/openecomp/mso/client/aai/Format.java43
-rw-r--r--common/src/main/java/org/openecomp/mso/client/aai/entities/AAIEntity.java25
-rw-r--r--common/src/main/java/org/openecomp/mso/client/aai/entities/AAIEntityObject.java29
-rw-r--r--common/src/main/java/org/openecomp/mso/client/aai/entities/AAIError.java46
-rw-r--r--common/src/main/java/org/openecomp/mso/client/aai/entities/AAIResultWrapper.java78
-rw-r--r--common/src/main/java/org/openecomp/mso/client/aai/entities/Configuration.java162
-rw-r--r--common/src/main/java/org/openecomp/mso/client/aai/entities/CustomQuery.java82
-rw-r--r--common/src/main/java/org/openecomp/mso/client/aai/entities/Relationships.java140
-rw-r--r--common/src/main/java/org/openecomp/mso/client/aai/entities/RequestError.java46
-rw-r--r--common/src/main/java/org/openecomp/mso/client/aai/entities/Results.java51
-rw-r--r--common/src/main/java/org/openecomp/mso/client/aai/entities/ServiceException.java75
-rw-r--r--common/src/main/java/org/openecomp/mso/client/aai/entities/bulkprocess/OperationBody.java69
-rw-r--r--common/src/main/java/org/openecomp/mso/client/aai/entities/bulkprocess/Transaction.java95
-rw-r--r--common/src/main/java/org/openecomp/mso/client/aai/entities/bulkprocess/Transactions.java54
-rw-r--r--common/src/main/java/org/openecomp/mso/client/aai/entities/uri/AAIResourceUri.java36
-rw-r--r--common/src/main/java/org/openecomp/mso/client/aai/entities/uri/AAIUri.java58
-rw-r--r--common/src/main/java/org/openecomp/mso/client/aai/entities/uri/AAIUriFactory.java73
-rw-r--r--common/src/main/java/org/openecomp/mso/client/aai/entities/uri/Depth.java45
-rw-r--r--common/src/main/java/org/openecomp/mso/client/aai/entities/uri/NodesUri.java44
-rw-r--r--common/src/main/java/org/openecomp/mso/client/aai/entities/uri/ServiceInstanceUri.java129
-rw-r--r--common/src/main/java/org/openecomp/mso/client/aai/entities/uri/SimpleUri.java187
-rw-r--r--common/src/main/java/org/openecomp/mso/client/aai/entities/uri/parsers/UriParser.java29
-rw-r--r--common/src/main/java/org/openecomp/mso/client/aai/entities/uri/parsers/UriParserSpringImpl.java68
-rw-r--r--common/src/main/java/org/openecomp/mso/client/aai/exceptions/AAIPayloadException.java40
-rw-r--r--common/src/main/java/org/openecomp/mso/client/aai/exceptions/AAIUriComputationException.java34
-rw-r--r--common/src/main/java/org/openecomp/mso/client/aai/exceptions/AAIUriNotFoundException.java29
-rw-r--r--common/src/main/java/org/openecomp/mso/client/aai/exceptions/BulkProcessFailed.java28
-rw-r--r--common/src/main/java/org/openecomp/mso/client/aai/objects/AAIOperationalEnvironment.java159
-rw-r--r--common/src/main/java/org/openecomp/mso/client/aai/objects/AAIOwningEntity.java67
-rw-r--r--common/src/main/java/org/openecomp/mso/client/aai/objects/AAIProject.java55
-rw-r--r--common/src/main/java/org/openecomp/mso/client/aai/objects/AAIServiceInstance.java135
57 files changed, 4054 insertions, 0 deletions
diff --git a/common/src/main/java/org/openecomp/mso/client/aai/AAIClient.java b/common/src/main/java/org/openecomp/mso/client/aai/AAIClient.java
new file mode 100644
index 0000000000..9150dcab15
--- /dev/null
+++ b/common/src/main/java/org/openecomp/mso/client/aai/AAIClient.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.openecomp.mso.client.aai;
+
+import java.net.URI;
+import java.util.UUID;
+
+import javax.ws.rs.core.UriBuilder;
+
+import org.openecomp.mso.client.RestPropertiesLoader;
+import org.openecomp.mso.client.aai.entities.uri.AAIUri;
+import org.openecomp.mso.client.defaultproperties.DefaultAAIPropertiesImpl;
+import org.openecomp.mso.client.policy.RestClient;
+
+import com.att.eelf.configuration.EELFLogger;
+import com.att.eelf.configuration.EELFManager;
+
+public abstract class AAIClient {
+
+ protected final AAIVersion defaultVersion;
+ private static final String AAI_ROOT = "/aai";
+ protected final EELFLogger metricsLogger = EELFManager.getInstance().getMetricsLogger();
+ private final AAIProperties properties;
+ protected final UUID requestId;
+ public AAIClient(UUID requestId) {
+ AAIProperties props = RestPropertiesLoader.getInstance().getNewImpl(AAIProperties.class);
+ if (props == null) {
+ metricsLogger.error("No RestProperty.AAIProperties implementation found on classpath");
+ props = new DefaultAAIPropertiesImpl();
+ }
+ this.properties = props;
+ this.defaultVersion = props.getDefaultVersion();
+ this.requestId = requestId;
+ }
+ protected URI constructPath(AAIUri uri) {
+
+ return UriBuilder.fromUri(AAI_ROOT + "/" + this.getVersion().toString() + uri.build().toString()).build();
+ }
+
+ protected RestClient createClient(AAIUri uri) {
+ return new AAIRestClient(properties, this.getRequestId(), constructPath(uri)).addRequestId(this.getRequestId());
+
+ }
+
+ protected UUID getRequestId() {
+ return this.requestId;
+ }
+ protected AAIVersion getVersion() {
+ return defaultVersion;
+ }
+} \ No newline at end of file
diff --git a/common/src/main/java/org/openecomp/mso/client/aai/AAIClientResponseExceptionMapper.java b/common/src/main/java/org/openecomp/mso/client/aai/AAIClientResponseExceptionMapper.java
new file mode 100644
index 0000000000..657b4c5a2c
--- /dev/null
+++ b/common/src/main/java/org/openecomp/mso/client/aai/AAIClientResponseExceptionMapper.java
@@ -0,0 +1,61 @@
+/*-
+ * ============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.openecomp.mso.client.aai;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.Optional;
+import java.util.UUID;
+
+import javax.annotation.Priority;
+import javax.ws.rs.ext.Provider;
+
+import org.openecomp.mso.client.ResponseExceptionMapper;
+import org.openecomp.mso.client.aai.entities.AAIError;
+
+import com.fasterxml.jackson.core.JsonParseException;
+import com.fasterxml.jackson.databind.ObjectMapper;
+
+@Provider
+@Priority(Integer.MIN_VALUE)
+public class AAIClientResponseExceptionMapper extends ResponseExceptionMapper {
+
+ private final UUID requestId;
+ public AAIClientResponseExceptionMapper(UUID requestId) {
+ this.requestId = requestId;
+ }
+ @Override
+ public Optional<String> extractMessage(InputStream stream) throws IOException {
+
+ String errorString = "Error calling A&AI. Request-Id=" + this.getRequestId() + " ";
+ try {
+ AAIError error = new ObjectMapper().readValue(stream, AAIError.class);
+ AAIErrorFormatter formatter = new AAIErrorFormatter(error);
+ return Optional.of(errorString + formatter.getMessage());
+ } catch (JsonParseException e) {
+ return Optional.of(errorString);
+ }
+ }
+
+ protected UUID getRequestId() {
+ return this.requestId;
+ }
+}
diff --git a/common/src/main/java/org/openecomp/mso/client/aai/AAICommonObjectMapperProvider.java b/common/src/main/java/org/openecomp/mso/client/aai/AAICommonObjectMapperProvider.java
new file mode 100644
index 0000000000..cbee903835
--- /dev/null
+++ b/common/src/main/java/org/openecomp/mso/client/aai/AAICommonObjectMapperProvider.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.openecomp.mso.client.aai;
+
+import javax.ws.rs.ext.ContextResolver;
+
+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 implements ContextResolver<ObjectMapper> {
+
+ final ObjectMapper mapper;
+
+ 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));
+ }
+
+ @Override
+ public ObjectMapper getContext(Class<?> type) {
+ return mapper;
+ }
+
+ public ObjectMapper getMapper() {
+ return mapper;
+ }
+}
diff --git a/common/src/main/java/org/openecomp/mso/client/aai/AAIConfigurationClient.java b/common/src/main/java/org/openecomp/mso/client/aai/AAIConfigurationClient.java
new file mode 100644
index 0000000000..fdeb975ad1
--- /dev/null
+++ b/common/src/main/java/org/openecomp/mso/client/aai/AAIConfigurationClient.java
@@ -0,0 +1,74 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.mso.client.aai;
+
+import org.openecomp.mso.client.aai.entities.Configuration;
+import org.openecomp.mso.client.aai.entities.uri.AAIResourceUri;
+import org.openecomp.mso.client.aai.entities.uri.AAIUriFactory;
+import org.openecomp.mso.serviceinstancebeans.RequestDetails;
+
+public class AAIConfigurationClient {
+
+ private AAIResourcesClient aaiClient;
+
+ private static final String ORCHESTRATION_STATUS = "PendingCreate";
+
+ public AAIConfigurationClient() {
+ aaiClient = new AAIResourcesClient();
+ }
+
+ public void createConfiguration(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("");
+ AAIResourceUri uri = getConfigurationURI(payload.getConfigurationId());
+ payload.setConfigurationSelflink(uri.build().getPath());
+ payload.setModelCustomizationId(requestDetails.getModelInfo().getModelCustomizationId());
+
+ aaiClient.create(uri, 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));
+ }
+
+ 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/openecomp/mso/client/aai/AAIErrorFormatter.java b/common/src/main/java/org/openecomp/mso/client/aai/AAIErrorFormatter.java
new file mode 100644
index 0000000000..dd56e9712f
--- /dev/null
+++ b/common/src/main/java/org/openecomp/mso/client/aai/AAIErrorFormatter.java
@@ -0,0 +1,57 @@
+/*-
+ * ============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.openecomp.mso.client.aai;
+
+import java.util.List;
+import java.util.Optional;
+
+import org.openecomp.mso.client.aai.entities.AAIError;
+import org.openecomp.mso.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/openecomp/mso/client/aai/AAINamespaceConstants.java b/common/src/main/java/org/openecomp/mso/client/aai/AAINamespaceConstants.java
new file mode 100644
index 0000000000..4bdfc4d793
--- /dev/null
+++ b/common/src/main/java/org/openecomp/mso/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.openecomp.mso.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/openecomp/mso/client/aai/AAIObjectName.java b/common/src/main/java/org/openecomp/mso/client/aai/AAIObjectName.java
new file mode 100644
index 0000000000..c7459d31b5
--- /dev/null
+++ b/common/src/main/java/org/openecomp/mso/client/aai/AAIObjectName.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.openecomp.mso.client.aai;
+
+import com.google.common.base.CaseFormat;
+
+public interface AAIObjectName {
+
+ public String typeName();
+ public String typeName(CaseFormat format);
+}
diff --git a/common/src/main/java/org/openecomp/mso/client/aai/AAIObjectPlurals.java b/common/src/main/java/org/openecomp/mso/client/aai/AAIObjectPlurals.java
new file mode 100644
index 0000000000..dc2831c1ed
--- /dev/null
+++ b/common/src/main/java/org/openecomp/mso/client/aai/AAIObjectPlurals.java
@@ -0,0 +1,65 @@
+/*-
+ * ============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.openecomp.mso.client.aai;
+
+import com.google.common.base.CaseFormat;
+
+public enum AAIObjectPlurals implements AAIObjectName, AAIObjectUriTemplate, AAIObjectUriPartial {
+
+ GENERIC_VNF(AAINamespaceConstants.NETWORK, "/generic-vnfs"),
+ PSERVER(AAINamespaceConstants.CLOUD_INFRASTRUCTURE, "/pservers");
+
+ 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) {
+ 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);
+ }
+}
diff --git a/common/src/main/java/org/openecomp/mso/client/aai/AAIObjectType.java b/common/src/main/java/org/openecomp/mso/client/aai/AAIObjectType.java
new file mode 100644
index 0000000000..9026c29522
--- /dev/null
+++ b/common/src/main/java/org/openecomp/mso/client/aai/AAIObjectType.java
@@ -0,0 +1,98 @@
+/*-
+ * ============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.openecomp.mso.client.aai;
+
+import com.google.common.base.CaseFormat;
+
+public enum AAIObjectType implements AAIObjectName, AAIObjectUriTemplate, AAIObjectUriPartial {
+
+ 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}"),
+ 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}"),
+ 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/{id}"),
+ P_INTERFACE(AAIObjectType.PSERVER.uriTemplate(), "/p-interfaces/p-interface/{interface-name}"),
+ PHYSICAL_LINK(AAINamespaceConstants.NETWORK, "/physical-links/physical-link/{link-name}"),
+ 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;
+ }
+} \ No newline at end of file
diff --git a/common/src/main/java/org/openecomp/mso/client/aai/AAIObjectUriPartial.java b/common/src/main/java/org/openecomp/mso/client/aai/AAIObjectUriPartial.java
new file mode 100644
index 0000000000..3fb867d6fa
--- /dev/null
+++ b/common/src/main/java/org/openecomp/mso/client/aai/AAIObjectUriPartial.java
@@ -0,0 +1,26 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.mso.client.aai;
+
+public interface AAIObjectUriPartial {
+
+ public String partialUri();
+}
diff --git a/common/src/main/java/org/openecomp/mso/client/aai/AAIObjectUriTemplate.java b/common/src/main/java/org/openecomp/mso/client/aai/AAIObjectUriTemplate.java
new file mode 100644
index 0000000000..397b66d547
--- /dev/null
+++ b/common/src/main/java/org/openecomp/mso/client/aai/AAIObjectUriTemplate.java
@@ -0,0 +1,26 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.mso.client.aai;
+
+public interface AAIObjectUriTemplate {
+
+ public String uriTemplate();
+}
diff --git a/common/src/main/java/org/openecomp/mso/client/aai/AAIProperties.java b/common/src/main/java/org/openecomp/mso/client/aai/AAIProperties.java
new file mode 100644
index 0000000000..358bbbbbec
--- /dev/null
+++ b/common/src/main/java/org/openecomp/mso/client/aai/AAIProperties.java
@@ -0,0 +1,28 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.mso.client.aai;
+
+import org.openecomp.mso.client.RestProperties;
+
+public interface AAIProperties extends RestProperties {
+
+ public AAIVersion getDefaultVersion();
+}
diff --git a/common/src/main/java/org/openecomp/mso/client/aai/AAIQueryClient.java b/common/src/main/java/org/openecomp/mso/client/aai/AAIQueryClient.java
new file mode 100644
index 0000000000..f8707dec3e
--- /dev/null
+++ b/common/src/main/java/org/openecomp/mso/client/aai/AAIQueryClient.java
@@ -0,0 +1,93 @@
+/*-
+ * ============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.openecomp.mso.client.aai;
+
+import java.util.Optional;
+import java.util.UUID;
+
+import org.openecomp.mso.client.aai.entities.CustomQuery;
+import org.openecomp.mso.client.aai.entities.uri.AAIUri;
+import org.openecomp.mso.client.aai.entities.uri.AAIUriFactory;
+import org.openecomp.mso.client.policy.RestClient;
+import org.openecomp.mso.client.aai.AAIVersion;
+
+public class AAIQueryClient extends AAIClient {
+
+
+ private final AAIVersion version;
+ private Optional<String> depth = Optional.empty();
+ private boolean nodesOnly = false;
+ private Optional<AAISubgraphType> subgraph = Optional.empty();
+
+ public AAIQueryClient() {
+ super(UUID.randomUUID());
+ this.version = super.getVersion();
+ }
+
+ public AAIQueryClient(AAIVersion version, UUID requestId) {
+ super(requestId);
+ this.version = version;
+ }
+
+ public AAIQueryClient(AAIVersion version) {
+ this(version, UUID.randomUUID());
+ }
+
+ public String query(Format format, CustomQuery query) {
+ return this.createClient(AAIUriFactory.createResourceUri(AAIObjectType.CUSTOM_QUERY).queryParam("format", format.toString()))
+ .addRequestId(requestId).put(query, String.class);
+ }
+
+ @Override
+ protected AAIVersion getVersion() {
+ return this.version;
+ }
+
+ 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;
+ }
+
+ @Override
+ public RestClient createClient(AAIUri uri) {
+ AAIUri 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 super.createClient(clone);
+ }
+} \ No newline at end of file
diff --git a/common/src/main/java/org/openecomp/mso/client/aai/AAIQueryObjectMapperProvider.java b/common/src/main/java/org/openecomp/mso/client/aai/AAIQueryObjectMapperProvider.java
new file mode 100644
index 0000000000..425d9ce60b
--- /dev/null
+++ b/common/src/main/java/org/openecomp/mso/client/aai/AAIQueryObjectMapperProvider.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.openecomp.mso.client.aai;
+
+import com.fasterxml.jackson.databind.AnnotationIntrospector;
+import com.fasterxml.jackson.databind.ObjectMapper;
+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));
+
+ }
+
+ @Override
+ public ObjectMapper getContext(Class<?> type) {
+ return mapper;
+ }
+}
diff --git a/common/src/main/java/org/openecomp/mso/client/aai/AAIResourcesClient.java b/common/src/main/java/org/openecomp/mso/client/aai/AAIResourcesClient.java
new file mode 100644
index 0000000000..32c61f7fd7
--- /dev/null
+++ b/common/src/main/java/org/openecomp/mso/client/aai/AAIResourcesClient.java
@@ -0,0 +1,244 @@
+/*-
+ * ============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.openecomp.mso.client.aai;
+
+import java.util.Map;
+import java.util.Optional;
+import java.util.UUID;
+
+import javax.ws.rs.NotFoundException;
+import javax.ws.rs.client.ResponseProcessingException;
+import javax.ws.rs.core.GenericType;
+
+import org.onap.aai.domain.yang.Relationship;
+import org.openecomp.mso.client.aai.entities.AAIResultWrapper;
+import org.openecomp.mso.client.aai.entities.uri.AAIResourceUri;
+import org.openecomp.mso.client.aai.entities.uri.AAIUri;
+import org.openecomp.mso.client.aai.entities.uri.Depth;
+import org.openecomp.mso.client.policy.RestClient;
+
+public class AAIResourcesClient extends AAIClient {
+
+ private final AAIVersion version;
+
+ public AAIResourcesClient() {
+ super(UUID.randomUUID());
+ this.version = super.getVersion();
+ }
+
+ public AAIResourcesClient(AAIVersion version) {
+ super(UUID.randomUUID());
+ this.version = version;
+ }
+
+ public AAIResourcesClient(AAIVersion version, UUID requestId) {
+ super(requestId);
+ 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);
+ try{
+ aaiRC.get();
+ } catch(ResponseProcessingException e) {
+ if (e.getCause() instanceof NotFoundException) {
+ return false;
+ } else {
+ throw e;
+ }
+ }
+ return true;
+ }
+
+ /**
+ * 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>>(){});
+ 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> T get(Class<T> clazz, AAIResourceUri uri) {
+ return this.createClient(uri).get(clazz);
+ }
+
+ /**
+ * Retrieves an object from A&AI and automatically unmarshalls it into a Map or List
+ * @param resultClass
+ * @param uri
+ * @return
+ */
+ public <T> 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);
+
+ 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.version, this.requestId);
+ }
+
+ @Override
+ protected AAIVersion getVersion() {
+ return this.version;
+ }
+
+ @Override
+ protected RestClient createClient(AAIUri uri) {
+ return super.createClient(uri);
+ }
+
+ 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;
+ }
+}
diff --git a/common/src/main/java/org/openecomp/mso/client/aai/AAIResourcesObjectMapperProvider.java b/common/src/main/java/org/openecomp/mso/client/aai/AAIResourcesObjectMapperProvider.java
new file mode 100644
index 0000000000..ada1939951
--- /dev/null
+++ b/common/src/main/java/org/openecomp/mso/client/aai/AAIResourcesObjectMapperProvider.java
@@ -0,0 +1,35 @@
+/*-
+ * ============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.openecomp.mso.client.aai;
+
+import com.fasterxml.jackson.databind.ObjectMapper;
+
+public class AAIResourcesObjectMapperProvider extends AAICommonObjectMapperProvider {
+
+ public AAIResourcesObjectMapperProvider() {
+ super();
+ }
+
+ @Override
+ public ObjectMapper getContext(Class<?> type) {
+ return mapper;
+ }
+}
diff --git a/common/src/main/java/org/openecomp/mso/client/aai/AAIRestClient.java b/common/src/main/java/org/openecomp/mso/client/aai/AAIRestClient.java
new file mode 100644
index 0000000000..9348beb02a
--- /dev/null
+++ b/common/src/main/java/org/openecomp/mso/client/aai/AAIRestClient.java
@@ -0,0 +1,67 @@
+/*-
+ * ============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.openecomp.mso.client.aai;
+
+import java.net.URI;
+import java.util.Map;
+import java.util.Optional;
+import java.util.UUID;
+
+import javax.ws.rs.client.ClientResponseFilter;
+import javax.ws.rs.ext.ContextResolver;
+
+import org.openecomp.mso.client.RestProperties;
+import org.openecomp.mso.client.policy.RestClient;
+import org.openecomp.mso.client.policy.RestClientSSL;
+
+import com.fasterxml.jackson.databind.ObjectMapper;
+
+public class AAIRestClient extends RestClientSSL {
+
+ protected AAIRestClient(RestProperties props, UUID requestId, URI uri) {
+ super(props, requestId, Optional.of(uri));
+ headerMap.put("X-TransactionId", requestId.toString());
+ }
+
+ @Override
+ protected void initializeHeaderMap(Map<String, String> headerMap) {
+ headerMap.put("X-FromAppId", "MSO");
+ }
+
+ @Override
+ protected Optional<ClientResponseFilter> addResponseFilter() {
+
+ return Optional.of(new AAIClientResponseExceptionMapper(this.getRequestId()));
+ }
+
+ @Override
+ public RestClient addRequestId(UUID requestId) {
+ headerMap.put("X-TransactionId", requestId.toString());
+ this.requestId = requestId;
+ return this;
+ }
+
+ @Override
+ protected ContextResolver<ObjectMapper> getMapper() {
+ return new AAICommonObjectMapperProvider();
+ }
+
+}
diff --git a/common/src/main/java/org/openecomp/mso/client/aai/AAIRestClientI.java b/common/src/main/java/org/openecomp/mso/client/aai/AAIRestClientI.java
new file mode 100644
index 0000000000..801c0f91d4
--- /dev/null
+++ b/common/src/main/java/org/openecomp/mso/client/aai/AAIRestClientI.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.openecomp.mso.client.aai;
+import java.io.IOException;
+import java.io.UnsupportedEncodingException;
+import java.util.List;
+
+import org.onap.aai.domain.yang.GenericVnf;
+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;
+}
diff --git a/common/src/main/java/org/openecomp/mso/client/aai/AAIRestClientImpl.java b/common/src/main/java/org/openecomp/mso/client/aai/AAIRestClientImpl.java
new file mode 100644
index 0000000000..e27075d9dd
--- /dev/null
+++ b/common/src/main/java/org/openecomp/mso/client/aai/AAIRestClientImpl.java
@@ -0,0 +1,165 @@
+/*-
+ * ============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.openecomp.mso.client.aai;
+
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+import java.util.UUID;
+
+import org.onap.aai.domain.yang.GenericVnf;
+import org.onap.aai.domain.yang.GenericVnfs;
+import org.onap.aai.domain.yang.Pserver;
+import org.onap.aai.domain.yang.Pservers;
+import org.openecomp.mso.client.aai.entities.CustomQuery;
+import org.openecomp.mso.client.aai.entities.Results;
+import org.openecomp.mso.client.aai.entities.uri.AAIResourceUri;
+import org.openecomp.mso.client.aai.entities.uri.AAIUriFactory;
+import org.springframework.stereotype.Service;
+
+import com.att.eelf.configuration.EELFLogger;
+import com.att.eelf.configuration.EELFManager;
+import com.fasterxml.jackson.core.JsonParseException;
+import com.fasterxml.jackson.core.type.TypeReference;
+import com.fasterxml.jackson.databind.JsonMappingException;
+import com.fasterxml.jackson.databind.ObjectMapper;
+
+
+@Service
+public class AAIRestClientImpl implements AAIRestClientI {
+
+ private static final EELFLogger logger = EELFManager.getInstance().getMetricsLogger();
+ 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() {
+
+
+ }
+
+ public AAIRestClientImpl(final String host) {
+
+
+ }
+
+ @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, requestId).get(Pservers.class, AAIUriFactory.createResourceUri(AAIObjectPlurals.PSERVER));
+ }
+
+ @Override
+ public List<Pserver> getPhysicalServerByVnfId(String vnfId, String transactionLoggingUuid)
+ throws JsonParseException, JsonMappingException, 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, requestId).query(Format.RESOURCE, new CustomQuery(startNodes,PSERVER_VNF_QUERY));
+
+ return this.getListOfPservers(jsonInput);
+
+ }
+
+ protected List<Pserver> getListOfPservers(String jsonInput) throws JsonParseException, JsonMappingException, IOException {
+ ObjectMapper mapper = new AAICommonObjectMapperProvider().getContext(Object.class);
+ 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 JsonParseException, JsonMappingException, 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, requestId).get(GenericVnfs.class, AAIUriFactory.createResourceUri(AAIObjectPlurals.GENERIC_VNF).queryParam("vnf-name", vnfName));
+ 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 JsonParseException, JsonMappingException, 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, requestId).update(AAIUriFactory.createResourceUri(AAIObjectType.GENERIC_VNF, vnfId), genericVnf);
+
+ }
+
+ @Override
+ public GenericVnf getVnfByName(String vnfId, String transactionLoggingUuid) throws JsonParseException, JsonMappingException, 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, requestId).get(GenericVnf.class, AAIUriFactory.createResourceUri(AAIObjectType.GENERIC_VNF, vnfId));
+ }
+
+}
diff --git a/common/src/main/java/org/openecomp/mso/client/aai/AAISubgraphType.java b/common/src/main/java/org/openecomp/mso/client/aai/AAISubgraphType.java
new file mode 100644
index 0000000000..917949967f
--- /dev/null
+++ b/common/src/main/java/org/openecomp/mso/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.openecomp.mso.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;
+ }
+} \ No newline at end of file
diff --git a/common/src/main/java/org/openecomp/mso/client/aai/AAITransactionalClient.java b/common/src/main/java/org/openecomp/mso/client/aai/AAITransactionalClient.java
new file mode 100644
index 0000000000..547862708a
--- /dev/null
+++ b/common/src/main/java/org/openecomp/mso/client/aai/AAITransactionalClient.java
@@ -0,0 +1,263 @@
+/*-
+ * ============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.openecomp.mso.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 java.util.UUID;
+
+import javax.ws.rs.core.GenericType;
+import javax.ws.rs.core.Response;
+
+import org.onap.aai.domain.yang.Relationship;
+import org.openecomp.mso.client.aai.entities.AAIError;
+import org.openecomp.mso.client.aai.entities.bulkprocess.OperationBody;
+import org.openecomp.mso.client.aai.entities.bulkprocess.Transaction;
+import org.openecomp.mso.client.aai.entities.bulkprocess.Transactions;
+import org.openecomp.mso.client.aai.entities.uri.AAIResourceUri;
+import org.openecomp.mso.client.aai.entities.uri.AAIUri;
+import org.openecomp.mso.client.aai.entities.uri.AAIUriFactory;
+import org.openecomp.mso.client.aai.exceptions.BulkProcessFailed;
+import org.openecomp.mso.client.policy.RestClient;
+import org.openecomp.mso.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, UUID requestId) {
+ super(requestId);
+ 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);
+ 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. Request-id=" + this.getRequestId() + ". 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) {
+ metricsLogger.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) {
+ metricsLogger.error("could not parse error object from A&AI", e);
+ error = new AAIError();
+ }
+ AAIErrorFormatter formatter = new AAIErrorFormatter(error);
+ String outputMessage = formatter.getMessage();
+ metricsLogger.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/openecomp/mso/client/aai/AAIUpdator.java b/common/src/main/java/org/openecomp/mso/client/aai/AAIUpdator.java
new file mode 100644
index 0000000000..3bdcdc56a3
--- /dev/null
+++ b/common/src/main/java/org/openecomp/mso/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.openecomp.mso.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/openecomp/mso/client/aai/AAIUpdatorImpl.java b/common/src/main/java/org/openecomp/mso/client/aai/AAIUpdatorImpl.java
new file mode 100644
index 0000000000..c808761040
--- /dev/null
+++ b/common/src/main/java/org/openecomp/mso/client/aai/AAIUpdatorImpl.java
@@ -0,0 +1,49 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.mso.client.aai;
+
+import org.springframework.beans.factory.annotation.Autowired;
+
+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/openecomp/mso/client/aai/AAIValidator.java b/common/src/main/java/org/openecomp/mso/client/aai/AAIValidator.java
new file mode 100644
index 0000000000..117ec42a36
--- /dev/null
+++ b/common/src/main/java/org/openecomp/mso/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.openecomp.mso.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/openecomp/mso/client/aai/AAIValidatorImpl.java b/common/src/main/java/org/openecomp/mso/client/aai/AAIValidatorImpl.java
new file mode 100644
index 0000000000..c84d2f41bd
--- /dev/null
+++ b/common/src/main/java/org/openecomp/mso/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.openecomp.mso.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;
+
+
+
+@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/openecomp/mso/client/aai/AAIVersion.java b/common/src/main/java/org/openecomp/mso/client/aai/AAIVersion.java
new file mode 100644
index 0000000000..20117fb98b
--- /dev/null
+++ b/common/src/main/java/org/openecomp/mso/client/aai/AAIVersion.java
@@ -0,0 +1,41 @@
+/*-
+ * ============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.openecomp.mso.client.aai;
+
+public enum AAIVersion {
+ V8("v8"),
+ V9("v9"),
+ V10("v10"),
+ V11("v11"),
+ V12("v12");
+
+ 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/openecomp/mso/client/aai/Format.java b/common/src/main/java/org/openecomp/mso/client/aai/Format.java
new file mode 100644
index 0000000000..e4008151ef
--- /dev/null
+++ b/common/src/main/java/org/openecomp/mso/client/aai/Format.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.openecomp.mso.client.aai;
+
+public enum Format {
+
+ RESOURCE("resource"),
+ SIMPLE("simple"),
+ RAW("raw"),
+ CONSOLE("console"),
+ PATHED("pathed"),
+ GRAPHSON("graphson"),
+ ID("id");
+
+ private final String name;
+
+ private Format(String name) {
+ this.name = name;
+ }
+
+ @Override
+ public String toString() {
+ return name;
+ }
+}
diff --git a/common/src/main/java/org/openecomp/mso/client/aai/entities/AAIEntity.java b/common/src/main/java/org/openecomp/mso/client/aai/entities/AAIEntity.java
new file mode 100644
index 0000000000..3f0c4f3439
--- /dev/null
+++ b/common/src/main/java/org/openecomp/mso/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.openecomp.mso.client.aai.entities;
+
+public class AAIEntity{
+
+}
diff --git a/common/src/main/java/org/openecomp/mso/client/aai/entities/AAIEntityObject.java b/common/src/main/java/org/openecomp/mso/client/aai/entities/AAIEntityObject.java
new file mode 100644
index 0000000000..e4a64c4161
--- /dev/null
+++ b/common/src/main/java/org/openecomp/mso/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.openecomp.mso.client.aai.entities;
+
+import org.openecomp.mso.client.aai.entities.uri.AAIResourceUri;
+
+public interface AAIEntityObject {
+
+ public AAIResourceUri getUri();
+
+}
diff --git a/common/src/main/java/org/openecomp/mso/client/aai/entities/AAIError.java b/common/src/main/java/org/openecomp/mso/client/aai/entities/AAIError.java
new file mode 100644
index 0000000000..5f895ef862
--- /dev/null
+++ b/common/src/main/java/org/openecomp/mso/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.openecomp.mso.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/openecomp/mso/client/aai/entities/AAIResultWrapper.java b/common/src/main/java/org/openecomp/mso/client/aai/entities/AAIResultWrapper.java
new file mode 100644
index 0000000000..9898f04844
--- /dev/null
+++ b/common/src/main/java/org/openecomp/mso/client/aai/entities/AAIResultWrapper.java
@@ -0,0 +1,78 @@
+/*-
+ * ============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.openecomp.mso.client.aai.entities;
+
+import java.io.IOException;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Optional;
+
+import org.openecomp.mso.client.aai.AAICommonObjectMapperProvider;
+import org.openecomp.mso.jsonpath.JsonPathUtil;
+
+import com.fasterxml.jackson.core.type.TypeReference;
+import com.fasterxml.jackson.databind.ObjectMapper;
+
+public class AAIResultWrapper {
+
+ private final String jsonBody;
+ private final ObjectMapper mapper;
+ public AAIResultWrapper(String json) {
+ this.jsonBody = json;
+ this.mapper = new AAICommonObjectMapperProvider().getMapper();
+ }
+
+ public Optional<Relationships> getRelationships() {
+ final String path = "$.relationship-list";
+ Optional<String> result = JsonPathUtil.getInstance().locateResult(jsonBody, path);
+ if (result.isPresent()) {
+ return Optional.of(new Relationships(result.get()));
+ } else {
+ return Optional.empty();
+ }
+ }
+
+ public String getJson() {
+ return jsonBody;
+ }
+
+ public Map<String, Object> asMap() {
+ try {
+ return mapper.readValue(this.jsonBody, new TypeReference<Map<String, Object>>(){});
+ } catch (IOException e) {
+ return new HashMap<>();
+ }
+ }
+
+ public <T> Optional<T> asBean(Class<T> clazz) {
+ try {
+ return Optional.of(mapper.readValue(this.jsonBody, clazz));
+ } catch (IOException e) {
+ return Optional.empty();
+ }
+ }
+
+ @Override
+ public String toString() {
+ return this.getJson();
+ }
+
+}
diff --git a/common/src/main/java/org/openecomp/mso/client/aai/entities/Configuration.java b/common/src/main/java/org/openecomp/mso/client/aai/entities/Configuration.java
new file mode 100644
index 0000000000..a2d0fb3604
--- /dev/null
+++ b/common/src/main/java/org/openecomp/mso/client/aai/entities/Configuration.java
@@ -0,0 +1,162 @@
+/*-
+ * ============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.openecomp.mso.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/openecomp/mso/client/aai/entities/CustomQuery.java b/common/src/main/java/org/openecomp/mso/client/aai/entities/CustomQuery.java
new file mode 100644
index 0000000000..3d014b8f67
--- /dev/null
+++ b/common/src/main/java/org/openecomp/mso/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.openecomp.mso.client.aai.entities;
+
+import java.io.UnsupportedEncodingException;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.openecomp.mso.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/openecomp/mso/client/aai/entities/Relationships.java b/common/src/main/java/org/openecomp/mso/client/aai/entities/Relationships.java
new file mode 100644
index 0000000000..cca2fb3744
--- /dev/null
+++ b/common/src/main/java/org/openecomp/mso/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.openecomp.mso.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.openecomp.mso.client.aai.AAICommonObjectMapperProvider;
+import org.openecomp.mso.client.aai.AAIObjectName;
+import org.openecomp.mso.client.aai.AAIObjectType;
+import org.openecomp.mso.client.aai.AAIResourcesClient;
+import org.openecomp.mso.client.aai.entities.uri.AAIResourceUri;
+import org.openecomp.mso.client.aai.entities.uri.AAIUriFactory;
+import org.openecomp.mso.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(AAIObjectName 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(AAIObjectName type) {
+ return this.getRelatedLinks(Optional.of(type));
+ }
+
+ public List<AAIResourceUri> getRelatedAAIUris() {
+ return this.getRelatedAAIUris(x -> true);
+ }
+
+ public List<AAIResourceUri> getRelatedAAIUris(AAIObjectName 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<AAIObjectName> 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<AAIObjectName> 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/openecomp/mso/client/aai/entities/RequestError.java b/common/src/main/java/org/openecomp/mso/client/aai/entities/RequestError.java
new file mode 100644
index 0000000000..2fd3572401
--- /dev/null
+++ b/common/src/main/java/org/openecomp/mso/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.openecomp.mso.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/openecomp/mso/client/aai/entities/Results.java b/common/src/main/java/org/openecomp/mso/client/aai/entities/Results.java
new file mode 100644
index 0000000000..e91823a348
--- /dev/null
+++ b/common/src/main/java/org/openecomp/mso/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.openecomp.mso.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/openecomp/mso/client/aai/entities/ServiceException.java b/common/src/main/java/org/openecomp/mso/client/aai/entities/ServiceException.java
new file mode 100644
index 0000000000..66ca10d06b
--- /dev/null
+++ b/common/src/main/java/org/openecomp/mso/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.openecomp.mso.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/openecomp/mso/client/aai/entities/bulkprocess/OperationBody.java b/common/src/main/java/org/openecomp/mso/client/aai/entities/bulkprocess/OperationBody.java
new file mode 100644
index 0000000000..ddd9a454f8
--- /dev/null
+++ b/common/src/main/java/org/openecomp/mso/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.openecomp.mso.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/openecomp/mso/client/aai/entities/bulkprocess/Transaction.java b/common/src/main/java/org/openecomp/mso/client/aai/entities/bulkprocess/Transaction.java
new file mode 100644
index 0000000000..8c4d54dc16
--- /dev/null
+++ b/common/src/main/java/org/openecomp/mso/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.openecomp.mso.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/openecomp/mso/client/aai/entities/bulkprocess/Transactions.java b/common/src/main/java/org/openecomp/mso/client/aai/entities/bulkprocess/Transactions.java
new file mode 100644
index 0000000000..f6ce3c5d2c
--- /dev/null
+++ b/common/src/main/java/org/openecomp/mso/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.openecomp.mso.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;
+}
+
+} \ No newline at end of file
diff --git a/common/src/main/java/org/openecomp/mso/client/aai/entities/uri/AAIResourceUri.java b/common/src/main/java/org/openecomp/mso/client/aai/entities/uri/AAIResourceUri.java
new file mode 100644
index 0000000000..36e3d008ae
--- /dev/null
+++ b/common/src/main/java/org/openecomp/mso/client/aai/entities/uri/AAIResourceUri.java
@@ -0,0 +1,36 @@
+/*-
+ * ============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.openecomp.mso.client.aai.entities.uri;
+
+import org.openecomp.mso.client.aai.AAIObjectPlurals;
+import org.openecomp.mso.client.aai.AAIObjectType;
+
+public interface AAIResourceUri extends AAIUri {
+
+ public AAIResourceUri relationshipAPI();
+ public AAIResourceUri relatedTo(AAIObjectPlurals plural);
+ public AAIResourceUri relatedTo(AAIObjectType type, String... values);
+ public AAIResourceUri resourceVersion(String version);
+ public AAIResourceUri depth(Depth depth);
+ public AAIResourceUri nodesOnly(boolean nodesOnly);
+ public AAIResourceUri queryParam(String name, String... values);
+ public AAIResourceUri clone();
+}
diff --git a/common/src/main/java/org/openecomp/mso/client/aai/entities/uri/AAIUri.java b/common/src/main/java/org/openecomp/mso/client/aai/entities/uri/AAIUri.java
new file mode 100644
index 0000000000..1617bcddea
--- /dev/null
+++ b/common/src/main/java/org/openecomp/mso/client/aai/entities/uri/AAIUri.java
@@ -0,0 +1,58 @@
+/*-
+ * ============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.openecomp.mso.client.aai.entities.uri;
+
+import java.net.URI;
+import java.util.Map;
+
+import org.openecomp.mso.client.aai.AAIObjectPlurals;
+import org.openecomp.mso.client.aai.AAIObjectType;
+
+public interface AAIUri {
+
+ public URI build();
+ /**
+ * 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
+ */
+ public AAIUri depth(Depth depth);
+ /**
+ * Makes client only return object fields, no relationships
+ *
+ * @return
+ */
+ public AAIUri nodesOnly(boolean nodesOnly);
+ public AAIUri queryParam(String name, String... values);
+ public AAIUri clone();
+
+ /**
+ * returns all key values of the URI as a map. Key names can be found in {@link AAIObjectType}
+ * @return
+ */
+ public Map<String, String> getURIKeys();
+ public AAIObjectType getObjectType();
+ public boolean equals(Object o);
+} \ No newline at end of file
diff --git a/common/src/main/java/org/openecomp/mso/client/aai/entities/uri/AAIUriFactory.java b/common/src/main/java/org/openecomp/mso/client/aai/entities/uri/AAIUriFactory.java
new file mode 100644
index 0000000000..cb33435c69
--- /dev/null
+++ b/common/src/main/java/org/openecomp/mso/client/aai/entities/uri/AAIUriFactory.java
@@ -0,0 +1,73 @@
+/*-
+ * ============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.openecomp.mso.client.aai.entities.uri;
+
+import java.net.URI;
+
+import org.openecomp.mso.client.aai.AAIObjectPlurals;
+import org.openecomp.mso.client.aai.AAIObjectType;
+
+
+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 SimpleUri(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 SimpleUri(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 SimpleUri(type);
+
+ }
+}
diff --git a/common/src/main/java/org/openecomp/mso/client/aai/entities/uri/Depth.java b/common/src/main/java/org/openecomp/mso/client/aai/entities/uri/Depth.java
new file mode 100644
index 0000000000..7522ea33d1
--- /dev/null
+++ b/common/src/main/java/org/openecomp/mso/client/aai/entities/uri/Depth.java
@@ -0,0 +1,45 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.mso.client.aai.entities.uri;
+
+public enum Depth {
+ ZERO("0"),
+ ONE("1"),
+ TWO("2"),
+ THREE("3"),
+ FOUR("4"),
+ FIVE("5"),
+ SIX("6"),
+ ALL("all");
+
+ private final String depth;
+ private Depth(String s) {
+
+ this.depth = s;
+ }
+
+
+ @Override
+ public String toString() {
+ return this.depth;
+ }
+
+}
diff --git a/common/src/main/java/org/openecomp/mso/client/aai/entities/uri/NodesUri.java b/common/src/main/java/org/openecomp/mso/client/aai/entities/uri/NodesUri.java
new file mode 100644
index 0000000000..407e0ecc9e
--- /dev/null
+++ b/common/src/main/java/org/openecomp/mso/client/aai/entities/uri/NodesUri.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.openecomp.mso.client.aai.entities.uri;
+
+import javax.ws.rs.core.UriBuilder;
+
+import org.openecomp.mso.client.aai.AAIObjectPlurals;
+import org.openecomp.mso.client.aai.AAIObjectType;
+
+public class NodesUri extends SimpleUri {
+
+ protected NodesUri(AAIObjectType type, Object... values) {
+ super(type, values);
+ }
+
+
+ @Override
+ protected String getTemplate(AAIObjectType type) {
+ return "/nodes" + type.partialUri();
+ }
+
+ @Override
+ protected String getTemplate(AAIObjectPlurals type) {
+ return "/nodes" + type.partialUri();
+ }
+}
diff --git a/common/src/main/java/org/openecomp/mso/client/aai/entities/uri/ServiceInstanceUri.java b/common/src/main/java/org/openecomp/mso/client/aai/entities/uri/ServiceInstanceUri.java
new file mode 100644
index 0000000000..cdaecedfa9
--- /dev/null
+++ b/common/src/main/java/org/openecomp/mso/client/aai/entities/uri/ServiceInstanceUri.java
@@ -0,0 +1,129 @@
+/*-
+ * ============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.openecomp.mso.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.client.ResponseProcessingException;
+import javax.ws.rs.core.UriBuilder;
+
+import org.openecomp.mso.client.aai.AAIObjectType;
+import org.openecomp.mso.client.aai.AAIQueryClient;
+import org.openecomp.mso.client.aai.Format;
+import org.openecomp.mso.client.aai.entities.CustomQuery;
+import org.openecomp.mso.client.aai.entities.Results;
+import org.openecomp.mso.client.aai.exceptions.AAIPayloadException;
+import org.openecomp.mso.client.aai.exceptions.AAIUriComputationException;
+import org.openecomp.mso.client.aai.exceptions.AAIUriNotFoundException;
+
+import com.fasterxml.jackson.core.type.TypeReference;
+import com.fasterxml.jackson.databind.ObjectMapper;
+
+public class ServiceInstanceUri extends SimpleUri {
+
+ 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 AAIUriNotFoundException, AAIPayloadException {
+ 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 (ResponseProcessingException e) {
+ if (e.getCause() instanceof BadRequestException) {
+ throw new AAIUriNotFoundException("Service instance " + id + " not found at: " + serviceInstanceUri.build());
+ } else {
+ throw e;
+ }
+ }
+ try {
+ cachedValue = extractRelatedLink(resultJson);
+ if (!cachedValue.isPresent()) {
+ throw new AAIUriNotFoundException("Service instance " + id + " not found at: " + serviceInstanceUri.build());
+ }
+ } catch (IOException e) {
+ throw new AAIPayloadException("could not map payload: " + resultJson, e);
+ }
+
+ }
+
+ return this.getCachedValue().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 (AAIUriNotFoundException | AAIPayloadException e) {
+ throw new AAIUriComputationException(e);
+ }
+ return super.build();
+ }
+
+ @Override
+ public ServiceInstanceUri clone() {
+ return new ServiceInstanceUri(this.internalURI.clone(), this.getCachedValue(), values);
+ }
+
+ protected AAIQueryClient getQueryClient() {
+ return new AAIQueryClient();
+ }
+} \ No newline at end of file
diff --git a/common/src/main/java/org/openecomp/mso/client/aai/entities/uri/SimpleUri.java b/common/src/main/java/org/openecomp/mso/client/aai/entities/uri/SimpleUri.java
new file mode 100644
index 0000000000..f3e6fad48b
--- /dev/null
+++ b/common/src/main/java/org/openecomp/mso/client/aai/entities/uri/SimpleUri.java
@@ -0,0 +1,187 @@
+/*-
+ * ============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.openecomp.mso.client.aai.entities.uri;
+
+import java.io.UnsupportedEncodingException;
+import java.net.URI;
+import java.nio.charset.StandardCharsets;
+import java.util.HashMap;
+import java.util.Map;
+
+import javax.ws.rs.core.UriBuilder;
+
+import org.openecomp.mso.client.aai.AAIObjectPlurals;
+import org.openecomp.mso.client.aai.AAIObjectType;
+import org.openecomp.mso.client.aai.entities.uri.parsers.UriParser;
+import org.openecomp.mso.client.aai.entities.uri.parsers.UriParserSpringImpl;
+import org.springframework.web.util.UriUtils;
+
+public class SimpleUri implements AAIResourceUri {
+
+ protected UriBuilder internalURI;
+ protected final static String relationshipAPI = "/relationship-list/relationship";
+ protected final static String relatedTo = "/related-to";
+ protected final Object[] values;
+ protected final AAIObjectType type;
+ protected final AAIObjectPlurals pluralType;
+ protected SimpleUri(AAIObjectType type, Object... values) {
+ this.type = type;
+ this.pluralType = null;
+ this.internalURI = UriBuilder.fromPath(this.getTemplate(type));
+ this.values = values;
+ }
+ protected SimpleUri(AAIObjectType type, URI uri) {
+ this.type = type;
+ this.pluralType = null;
+ this.internalURI = UriBuilder.fromPath(uri.getRawPath().replaceAll("/aai/v\\d+", ""));
+ this.values = new Object[0];
+ }
+ protected SimpleUri(AAIObjectType type, UriBuilder builder, Object... values) {
+ this.internalURI = builder;
+ this.values = values;
+ this.type = type;
+ this.pluralType = null;
+ }
+ protected SimpleUri(AAIObjectPlurals type, UriBuilder builder, Object... values) {
+ this.internalURI = builder;
+ this.values = values;
+ this.type = null;
+ this.pluralType = type;
+ }
+ protected SimpleUri(AAIObjectPlurals type) {
+ this.type = null;
+ this.pluralType = type;
+ this.internalURI = UriBuilder.fromPath(this.getTemplate(type));
+ this.values = new Object[0];
+ }
+
+ @Override
+ public SimpleUri relationshipAPI() {
+ this.internalURI = internalURI.path(relationshipAPI);
+ return this;
+ }
+
+ @Override
+ public SimpleUri relatedTo(AAIObjectPlurals plural) {
+
+ this.internalURI = internalURI.path(relatedTo).path(plural.partialUri());
+ return this;
+ }
+ @Override
+ public SimpleUri relatedTo(AAIObjectType type, String... values) {
+ this.internalURI = internalURI.path(relatedTo).path(UriBuilder.fromPath(type.partialUri()).build(values).toString());
+ return this;
+ }
+
+ @Override
+ public SimpleUri resourceVersion(String version) {
+ this.internalURI = internalURI.queryParam("resource-version", version);
+ return this;
+ }
+
+ @Override
+ public SimpleUri queryParam(String name, String... values) {
+ this.internalURI = internalURI.queryParam(name, values);
+ return this;
+ }
+
+ @Override
+ public URI build() {
+ return build(this.values);
+ }
+
+ protected URI build(Object... values) {
+ //This is a workaround because resteasy does not encode URIs correctly
+ final String[] encoded = new String[values.length];
+ for (int i = 0; i < values.length; i++) {
+ try {
+ encoded[i] = UriUtils.encode(values[i].toString(), StandardCharsets.UTF_8.toString());
+ } catch (UnsupportedEncodingException e) {
+ encoded[i] = values[i].toString();
+ }
+ }
+ return internalURI.buildFromEncoded(encoded);
+ }
+
+ @Override
+ public Map<String, String> getURIKeys() {
+ return this.getURIKeys(this.build().toString());
+ }
+
+ protected Map<String, String> getURIKeys(String uri) {
+ UriParser parser;
+ if (this.type != null) {
+ if (!("".equals(this.getTemplate(type)))) {
+ parser = new UriParserSpringImpl(this.getTemplate(type));
+ } else {
+ return new HashMap<>();
+ }
+ } else {
+ parser = new UriParserSpringImpl(this.getTemplate(pluralType));
+ }
+
+
+ return parser.parse(uri);
+ }
+
+ @Override
+ public SimpleUri clone() {
+ if (this.type != null) {
+ return new SimpleUri(this.type, this.internalURI.clone(), values);
+ } else {
+ return new SimpleUri(this.pluralType, this.internalURI.clone(), values);
+ }
+ }
+
+ @Override
+ public AAIObjectType getObjectType() {
+ return this.type;
+ }
+
+ @Override
+ public boolean equals(Object o) {
+ if (o instanceof AAIUri) {
+ return this.build().equals(((AAIUri)o).build());
+ }
+ return false;
+ }
+ @Override
+ public SimpleUri depth(Depth depth) {
+ this.internalURI.queryParam("depth", depth.toString());
+ return this;
+ }
+ @Override
+ public SimpleUri nodesOnly(boolean nodesOnly) {
+ if (nodesOnly) {
+ this.internalURI.queryParam("nodes-only", "");
+ }
+ return this;
+ }
+
+ protected String getTemplate(AAIObjectType type) {
+ return type.uriTemplate();
+ }
+
+ protected String getTemplate(AAIObjectPlurals type) {
+ return type.uriTemplate();
+ }
+
+}
diff --git a/common/src/main/java/org/openecomp/mso/client/aai/entities/uri/parsers/UriParser.java b/common/src/main/java/org/openecomp/mso/client/aai/entities/uri/parsers/UriParser.java
new file mode 100644
index 0000000000..8e37d595b0
--- /dev/null
+++ b/common/src/main/java/org/openecomp/mso/client/aai/entities/uri/parsers/UriParser.java
@@ -0,0 +1,29 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.mso.client.aai.entities.uri.parsers;
+
+import java.util.Map;
+import java.util.Set;
+
+public interface UriParser {
+ public Set<String> getVariables();
+ public Map<String, String> parse(final String uri);
+} \ No newline at end of file
diff --git a/common/src/main/java/org/openecomp/mso/client/aai/entities/uri/parsers/UriParserSpringImpl.java b/common/src/main/java/org/openecomp/mso/client/aai/entities/uri/parsers/UriParserSpringImpl.java
new file mode 100644
index 0000000000..75f9005125
--- /dev/null
+++ b/common/src/main/java/org/openecomp/mso/client/aai/entities/uri/parsers/UriParserSpringImpl.java
@@ -0,0 +1,68 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.mso.client.aai.entities.uri.parsers;
+import java.io.UnsupportedEncodingException;
+import java.util.Collections;
+import java.util.LinkedHashMap;
+import java.util.LinkedHashSet;
+import java.util.Map;
+import java.util.Map.Entry;
+import java.util.Set;
+
+import org.springframework.web.util.UriTemplate;
+import org.springframework.web.util.UriUtils;
+
+public class UriParserSpringImpl implements UriParser {
+
+ private final UriTemplate uriTemplate;
+
+ public UriParserSpringImpl(final String template) {
+ this.uriTemplate = new UriTemplate(template);
+ }
+
+ @Override
+ public Map<String, String> parse(final String uri) {
+ final boolean match = this.uriTemplate.matches(uri);
+ if (!match) {
+ return new LinkedHashMap<>();
+ }
+ return Collections.unmodifiableMap(decodeParams(this.uriTemplate.match(uri)));
+ }
+
+ @Override
+ public Set<String> getVariables() {
+ return Collections.unmodifiableSet(new LinkedHashSet<String>(this.uriTemplate.getVariableNames()));
+ }
+
+ protected Map<String, String> decodeParams(Map<String, String> map) {
+ final Map<String, String> result = new LinkedHashMap<>();
+
+ for (Entry<String, String> entry : map.entrySet()) {
+ try {
+ result.put(entry.getKey(), UriUtils.decode(entry.getValue(), "UTF-8"));
+ } catch (UnsupportedEncodingException e) {
+ result.put(entry.getKey(), "");
+ }
+ }
+
+ return result;
+ }
+} \ No newline at end of file
diff --git a/common/src/main/java/org/openecomp/mso/client/aai/exceptions/AAIPayloadException.java b/common/src/main/java/org/openecomp/mso/client/aai/exceptions/AAIPayloadException.java
new file mode 100644
index 0000000000..35842204ac
--- /dev/null
+++ b/common/src/main/java/org/openecomp/mso/client/aai/exceptions/AAIPayloadException.java
@@ -0,0 +1,40 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.mso.client.aai.exceptions;
+
+public class AAIPayloadException extends Exception {
+
+ private static final long serialVersionUID = -5712783905947711065L;
+
+ public AAIPayloadException(Throwable t) {
+ super(t);
+ }
+
+ public AAIPayloadException(String s, Throwable t) {
+ super(s, t);
+ }
+
+ public AAIPayloadException(String s) {
+ super(s);
+ }
+
+
+}
diff --git a/common/src/main/java/org/openecomp/mso/client/aai/exceptions/AAIUriComputationException.java b/common/src/main/java/org/openecomp/mso/client/aai/exceptions/AAIUriComputationException.java
new file mode 100644
index 0000000000..4d9f320cc8
--- /dev/null
+++ b/common/src/main/java/org/openecomp/mso/client/aai/exceptions/AAIUriComputationException.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.openecomp.mso.client.aai.exceptions;
+
+public class AAIUriComputationException extends RuntimeException {
+
+ private static final long serialVersionUID = 5187931752227522034L;
+
+ public AAIUriComputationException(String s) {
+ super(s);
+ }
+
+ public AAIUriComputationException(Throwable t) {
+ super(t);
+ }
+}
diff --git a/common/src/main/java/org/openecomp/mso/client/aai/exceptions/AAIUriNotFoundException.java b/common/src/main/java/org/openecomp/mso/client/aai/exceptions/AAIUriNotFoundException.java
new file mode 100644
index 0000000000..3e373946ce
--- /dev/null
+++ b/common/src/main/java/org/openecomp/mso/client/aai/exceptions/AAIUriNotFoundException.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.openecomp.mso.client.aai.exceptions;
+
+public class AAIUriNotFoundException extends Exception {
+ private static final long serialVersionUID = 2789643165122257833L;
+
+ public AAIUriNotFoundException(String message) {
+ super(message);
+ }
+}
diff --git a/common/src/main/java/org/openecomp/mso/client/aai/exceptions/BulkProcessFailed.java b/common/src/main/java/org/openecomp/mso/client/aai/exceptions/BulkProcessFailed.java
new file mode 100644
index 0000000000..ea64f54c33
--- /dev/null
+++ b/common/src/main/java/org/openecomp/mso/client/aai/exceptions/BulkProcessFailed.java
@@ -0,0 +1,28 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.mso.client.aai.exceptions;
+
+public class BulkProcessFailed extends Exception {
+
+ public BulkProcessFailed(String message) {
+ super(message);
+ }
+}
diff --git a/common/src/main/java/org/openecomp/mso/client/aai/objects/AAIOperationalEnvironment.java b/common/src/main/java/org/openecomp/mso/client/aai/objects/AAIOperationalEnvironment.java
new file mode 100644
index 0000000000..f044e2a237
--- /dev/null
+++ b/common/src/main/java/org/openecomp/mso/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.openecomp.mso.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/openecomp/mso/client/aai/objects/AAIOwningEntity.java b/common/src/main/java/org/openecomp/mso/client/aai/objects/AAIOwningEntity.java
new file mode 100644
index 0000000000..b0b3d06669
--- /dev/null
+++ b/common/src/main/java/org/openecomp/mso/client/aai/objects/AAIOwningEntity.java
@@ -0,0 +1,67 @@
+/*-
+ * ============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.openecomp.mso.client.aai.objects;
+
+import org.openecomp.mso.client.aai.AAIObjectType;
+import org.openecomp.mso.client.aai.entities.AAIEntityObject;
+import org.openecomp.mso.client.aai.entities.uri.AAIResourceUri;
+import org.openecomp.mso.client.aai.entities.uri.AAIUriFactory;
+
+import com.fasterxml.jackson.annotation.JsonProperty;
+
+public class AAIOwningEntity implements AAIEntityObject {
+
+ @JsonProperty("owning-entity-name")
+ private String owningEntityName;
+
+ @JsonProperty("owning-entity-id")
+ private String owningEntityId;
+
+ public String getOwningEntityName() {
+ return owningEntityName;
+ }
+
+ public void setOwningEntityName(String owningEntityName) {
+ this.owningEntityName = owningEntityName;
+ }
+
+ public String getOwningEntityId() {
+ return owningEntityId;
+ }
+
+ public void setOwningEntityId(String owningEntityId) {
+ this.owningEntityId = owningEntityId;
+ }
+
+ public AAIOwningEntity withOwningEntity(String owningEntityName, String owningEntityId) {
+ this.setOwningEntityName(owningEntityName);
+ this.setOwningEntityId(owningEntityId);
+ return this;
+ }
+
+ @Override
+ public AAIResourceUri getUri() {
+ final AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.OWNING_ENTITY, this.owningEntityId);
+ return uri;
+ }
+
+
+}
diff --git a/common/src/main/java/org/openecomp/mso/client/aai/objects/AAIProject.java b/common/src/main/java/org/openecomp/mso/client/aai/objects/AAIProject.java
new file mode 100644
index 0000000000..34f715d98a
--- /dev/null
+++ b/common/src/main/java/org/openecomp/mso/client/aai/objects/AAIProject.java
@@ -0,0 +1,55 @@
+/*-
+ * ============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.openecomp.mso.client.aai.objects;
+
+import org.openecomp.mso.client.aai.AAIObjectType;
+import org.openecomp.mso.client.aai.entities.AAIEntityObject;
+import org.openecomp.mso.client.aai.entities.uri.AAIResourceUri;
+import org.openecomp.mso.client.aai.entities.uri.AAIUriFactory;
+
+import com.fasterxml.jackson.annotation.JsonProperty;
+
+public class AAIProject implements AAIEntityObject {
+
+ @JsonProperty("project-name")
+ private String projectName;
+
+ public String getProjectName() {
+ return projectName;
+ }
+
+ public void setProjectName(String projectName) {
+ this.projectName = projectName;
+ }
+
+ public AAIProject withProjectName(String projectName) {
+ this.setProjectName(projectName);
+ return this;
+ }
+
+ @Override
+ public AAIResourceUri getUri() {
+ final AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.PROJECT, this.projectName);
+ return uri;
+ }
+
+
+}
diff --git a/common/src/main/java/org/openecomp/mso/client/aai/objects/AAIServiceInstance.java b/common/src/main/java/org/openecomp/mso/client/aai/objects/AAIServiceInstance.java
new file mode 100644
index 0000000000..dbb34fcd44
--- /dev/null
+++ b/common/src/main/java/org/openecomp/mso/client/aai/objects/AAIServiceInstance.java
@@ -0,0 +1,135 @@
+/*-
+ * ============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.openecomp.mso.client.aai.objects;
+
+import org.openecomp.mso.client.aai.AAIObjectType;
+import org.openecomp.mso.client.aai.entities.AAIEntityObject;
+import org.openecomp.mso.client.aai.entities.uri.AAIResourceUri;
+import org.openecomp.mso.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() {
+ final AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE, this.serviceInstanceId);
+ return uri;
+ }
+
+
+}