aboutsummaryrefslogtreecommitdiffstats
path: root/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/aai
diff options
context:
space:
mode:
authorArthur Martella <amartell@research.att.com>2017-09-08 13:27:46 -0400
committerArthur Martella <amartell@research.att.com>2017-09-08 13:32:24 -0400
commit62cd6aaaf74aa91ee0037c0e155c8e7284f07567 (patch)
tree68c0c53c9156f5aa3c6b3599ac940770f986633d /bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/aai
parentfa1a211d28a912892fcd888569df033900eb01ee (diff)
1710 Rebase - Second Attempt
This commit rebases changes from openecomp-mso/internal-staging-1710 up to and including this codecloud commit: 54483fc6606ddb1591a2e9da61bff8712325f924 Wed Sep 6 18:12:56 2017 -0400 Rebasing was done on a branch on top of this commit in so/master in ONAP: 93fbdfbe46104f8859d4754040f979cb7997c157 Thu Sep 7 16:42:59 2017 +0000 Change-Id: I4ad9abf40da32bf5bdca43e868b8fa2dbcd9dc59 Issue-id: SO-107 Signed-off-by: Arthur Martella <amartell@research.att.com>
Diffstat (limited to 'bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/aai')
-rw-r--r--bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/aai/AAIClientResponseExceptionMapper.java71
-rw-r--r--bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/aai/AAICommonObjectMapperProvider.java49
-rw-r--r--bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/aai/AAIQueryObjectMapperProvider.java47
-rw-r--r--bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/aai/AAIResourcesObjectMapperProvider.java38
-rw-r--r--bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/aai/AAIRestClient.java24
-rw-r--r--bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/aai/AAIRestClientImpl.java167
-rw-r--r--bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/aai/AAIUpdator.java11
-rw-r--r--bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/aai/AAIUpdatorImpl.java29
-rw-r--r--bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/aai/AAIValidator.java12
-rw-r--r--bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/aai/AAIValidatorImpl.java51
-rw-r--r--bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/aai/entities/AAIEntity.java5
-rw-r--r--bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/aai/entities/AAIError.java27
-rw-r--r--bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/aai/entities/CustomQuery.java48
-rw-r--r--bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/aai/entities/RequestError.java27
-rw-r--r--bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/aai/entities/Results.java33
-rw-r--r--bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/aai/entities/ServiceException.java54
16 files changed, 693 insertions, 0 deletions
diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/aai/AAIClientResponseExceptionMapper.java b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/aai/AAIClientResponseExceptionMapper.java
new file mode 100644
index 0000000000..3189d4467d
--- /dev/null
+++ b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/aai/AAIClientResponseExceptionMapper.java
@@ -0,0 +1,71 @@
+package org.openecomp.mso.client.aai;
+
+import java.io.IOException;
+
+import javax.annotation.Priority;
+import javax.ws.rs.BadRequestException;
+import javax.ws.rs.ForbiddenException;
+import javax.ws.rs.InternalServerErrorException;
+import javax.ws.rs.NotAcceptableException;
+import javax.ws.rs.NotAllowedException;
+import javax.ws.rs.NotAuthorizedException;
+import javax.ws.rs.NotFoundException;
+import javax.ws.rs.NotSupportedException;
+import javax.ws.rs.WebApplicationException;
+import javax.ws.rs.client.ClientRequestContext;
+import javax.ws.rs.client.ClientResponseContext;
+import javax.ws.rs.client.ClientResponseFilter;
+import javax.ws.rs.core.Response;
+import javax.ws.rs.ext.Provider;
+
+import org.openecomp.mso.client.aai.entities.AAIError;
+
+import com.fasterxml.jackson.databind.ObjectMapper;
+
+@Provider
+@Priority(value = 1)
+public class AAIClientResponseExceptionMapper implements ClientResponseFilter {
+
+ @Override
+ public void filter(ClientRequestContext requestContext, ClientResponseContext responseContext) throws IOException {
+ if (responseContext.getStatus() != Response.Status.OK.getStatusCode() && responseContext.hasEntity()) {
+ AAIError error = new ObjectMapper().readValue(responseContext.getEntityStream(), AAIError.class);
+ String message = error.getRequestError().getServiceException().getText();
+
+ Response.Status status = Response.Status.fromStatusCode(responseContext.getStatus());
+ WebApplicationException webAppException;
+ switch (status) {
+ case BAD_REQUEST:
+ webAppException = new BadRequestException(message);
+ break;
+ case UNAUTHORIZED:
+ webAppException = new NotAuthorizedException(message);
+ break;
+ case FORBIDDEN:
+ webAppException = new ForbiddenException(message);
+ break;
+ case NOT_FOUND:
+ webAppException = new NotFoundException(message);
+ break;
+ case METHOD_NOT_ALLOWED:
+ webAppException = new NotAllowedException(message);
+ break;
+ case NOT_ACCEPTABLE:
+ webAppException = new NotAcceptableException(message);
+ break;
+ case UNSUPPORTED_MEDIA_TYPE:
+ webAppException = new NotSupportedException(message);
+ break;
+ case INTERNAL_SERVER_ERROR:
+ webAppException = new InternalServerErrorException(message);
+ break;
+ case SERVICE_UNAVAILABLE:
+ webAppException = new WebApplicationException(message);
+ break;
+ default:
+ webAppException = new WebApplicationException(message);
+ }
+ throw webAppException;
+ }
+ }
+}
diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/aai/AAICommonObjectMapperProvider.java b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/aai/AAICommonObjectMapperProvider.java
new file mode 100644
index 0000000000..83435a8c69
--- /dev/null
+++ b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/aai/AAICommonObjectMapperProvider.java
@@ -0,0 +1,49 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * OPENECOMP - MSO
+ * ================================================================================
+ * 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 javax.ws.rs.ext.Provider;
+
+import com.fasterxml.jackson.annotation.JsonInclude.Include;
+import com.fasterxml.jackson.databind.DeserializationFeature;
+import com.fasterxml.jackson.databind.MapperFeature;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.fasterxml.jackson.databind.SerializationFeature;
+
+@Provider
+public class AAICommonObjectMapperProvider implements ContextResolver<ObjectMapper> {
+
+ final ObjectMapper mapper;
+
+ public AAICommonObjectMapperProvider() {
+ mapper = new ObjectMapper();
+ mapper.setSerializationInclusion(Include.NON_NULL);
+ mapper.enable(MapperFeature.USE_ANNOTATIONS);
+ mapper.configure(SerializationFeature.WRAP_ROOT_VALUE, false);
+ mapper.configure(DeserializationFeature.UNWRAP_ROOT_VALUE, false);
+ }
+
+ @Override
+ public ObjectMapper getContext(Class<?> type) {
+ return mapper;
+ }
+}
diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/aai/AAIQueryObjectMapperProvider.java b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/aai/AAIQueryObjectMapperProvider.java
new file mode 100644
index 0000000000..a6d693b02a
--- /dev/null
+++ b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/aai/AAIQueryObjectMapperProvider.java
@@ -0,0 +1,47 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * OPENECOMP - MSO
+ * ================================================================================
+ * 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.Provider;
+
+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;
+
+@Provider
+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/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/aai/AAIResourcesObjectMapperProvider.java b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/aai/AAIResourcesObjectMapperProvider.java
new file mode 100644
index 0000000000..339fea5067
--- /dev/null
+++ b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/aai/AAIResourcesObjectMapperProvider.java
@@ -0,0 +1,38 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * OPENECOMP - MSO
+ * ================================================================================
+ * 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.Provider;
+
+import com.fasterxml.jackson.databind.ObjectMapper;
+
+@Provider
+public class AAIResourcesObjectMapperProvider extends AAICommonObjectMapperProvider {
+
+ public AAIResourcesObjectMapperProvider() {
+ super();
+ }
+
+ @Override
+ public ObjectMapper getContext(Class<?> type) {
+ return mapper;
+ }
+}
diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/aai/AAIRestClient.java b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/aai/AAIRestClient.java
new file mode 100644
index 0000000000..8d96437e68
--- /dev/null
+++ b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/aai/AAIRestClient.java
@@ -0,0 +1,24 @@
+package org.openecomp.mso.client.aai;
+import java.io.IOException;
+import java.io.UnsupportedEncodingException;
+import java.util.List;
+
+import org.openecomp.aai.domain.yang.GenericVnf;
+import org.openecomp.aai.domain.yang.Pserver;
+import org.openecomp.aai.domain.yang.Pservers;
+
+import com.fasterxml.jackson.core.JsonParseException;
+import com.fasterxml.jackson.databind.JsonMappingException;
+
+public interface AAIRestClient {
+
+ 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/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/aai/AAIRestClientImpl.java b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/aai/AAIRestClientImpl.java
new file mode 100644
index 0000000000..99024490a3
--- /dev/null
+++ b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/aai/AAIRestClientImpl.java
@@ -0,0 +1,167 @@
+package org.openecomp.mso.client.aai;
+
+import java.io.File;
+import java.io.IOException;
+import java.security.NoSuchAlgorithmException;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+import java.util.logging.Logger;
+
+import javax.net.ssl.SSLContext;
+import javax.ws.rs.client.Client;
+import javax.ws.rs.client.ClientBuilder;
+import javax.ws.rs.client.Entity;
+import javax.ws.rs.client.WebTarget;
+import javax.ws.rs.core.MediaType;
+
+import org.openecomp.aai.domain.yang.GenericVnf;
+import org.openecomp.aai.domain.yang.GenericVnfs;
+import org.openecomp.aai.domain.yang.Pserver;
+import org.openecomp.aai.domain.yang.Pservers;
+import org.openecomp.mso.bpmn.core.PropertyConfiguration;
+import org.openecomp.mso.client.aai.entities.CustomQuery;
+import org.openecomp.mso.client.aai.entities.Results;
+import org.openecomp.mso.logger.MsoLogger;
+import org.openecomp.mso.properties.MsoPropertiesFactory;
+import org.springframework.stereotype.Service;
+
+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 AAIRestClient {
+
+ private final WebTarget webTarget;
+
+ private static MsoPropertiesFactory msoPropertiesFactory = new MsoPropertiesFactory();
+
+ private static MsoLogger msoLogger = MsoLogger.getMsoLogger(MsoLogger.Catalog.GENERAL);
+
+ private static final String ENDPOINT_VERSION = "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_BY_VNF_QUERY = "g.V().has('aai-node-type', 'generic-vnf').has('vnf-name','USAUTOUFTIL2001UJDM02').out('runsOnPserver').has('aai-node-type', 'pserver')";
+ 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() throws NoSuchAlgorithmException {
+
+ Logger logger = Logger.getLogger(getClass().getName());
+ Map<String, String> properties = PropertyConfiguration.getInstance().getProperties("mso.bpmn.urn.properties");
+ Client client = this.getSSLClient();
+ webTarget = client.register(logger).register(new AAIClientResponseExceptionMapper())
+ .target(properties.get("aai.endpoint") + "/aai");
+ }
+
+ public AAIRestClientImpl(final String host) throws NoSuchAlgorithmException {
+ Logger logger = Logger.getLogger(getClass().getName());
+ Client client = this.getSSLClient();
+ Map<String, String> properties = PropertyConfiguration.getInstance().getProperties("mso.bpmn.urn.properties");
+ webTarget = client.register(logger).register(new AAIClientResponseExceptionMapper()).target(host + "/aai");
+ }
+
+ @Override
+ public Pservers getPhysicalServers(String hostName, String uuid) {
+ return webTarget.register(AAIResourcesObjectMapperProvider.class).path(ENDPOINT_GET_ALL).request()
+ .header("X-FromAppId", "MSO").header("X-TransactionId", uuid)
+ .header("Content-Type", MediaType.APPLICATION_JSON_TYPE).accept(MediaType.APPLICATION_JSON_TYPE).get()
+ .readEntity(Pservers.class);
+ }
+
+ @Override
+ public List<Pserver> getPhysicalServerByVnfId(String vnfId, String transactionLoggingUuid)
+ throws JsonParseException, JsonMappingException, IOException {
+ List<String> startNodes = new ArrayList<String>();
+ startNodes.add("network/generic-vnfs/generic-vnf/" + vnfId);
+ String jsonInput = webTarget.register(AAIQueryObjectMapperProvider.class).path(ENDPOINT_CUSTOM_QUERY)
+ .queryParam("format", "resource").request().header("X-FromAppId", "MSO")
+ .header("X-TransactionId", transactionLoggingUuid)
+ .header("Content-Type", MediaType.APPLICATION_JSON_TYPE).accept(MediaType.APPLICATION_JSON_TYPE)
+ .put(Entity.entity(new CustomQuery(startNodes, PSERVER_VNF_QUERY), MediaType.APPLICATION_JSON))
+ .readEntity(String.class);
+
+
+ return this.getListOfPservers(jsonInput);
+ }
+
+ protected List<Pserver> getListOfPservers(String jsonInput) throws JsonParseException, JsonMappingException, IOException
+ {
+ ObjectMapper mapper = new AAIQueryObjectMapperProvider().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;
+ }
+
+ protected List<Pserver> getListOfPservers(File jsonInput) throws JsonParseException, JsonMappingException, IOException
+ {
+ ObjectMapper mapper = new AAIQueryObjectMapperProvider().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 Exception {
+ GenericVnfs genericVnfs = webTarget.register(AAIResourcesObjectMapperProvider.class).path(ENDPOINT_GET_ALL_VNFS)
+ .queryParam("vnf-name", vnfName).request().header("X-FromAppId", "MSO")
+ .header("X-TransactionId", transactionLoggingUuid).header("Content-Type", "application/json")
+ .accept(MediaType.APPLICATION_JSON_TYPE).get().readEntity(GenericVnfs.class);
+
+ if (genericVnfs.getGenericVnf().size() > 1)
+ throw new Exception("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 Exception {
+ GenericVnf genericVnf = new GenericVnf();
+ genericVnf.setInMaint(inMaint);
+ webTarget.register(AAIResourcesObjectMapperProvider.class).path(GENERIC_VNF_PATH + "/" + vnfId).request()
+ .header("X-FromAppId", "MSO").header("X-TransactionId", transactionLoggingUuid)
+ .header("Content-Type", "application/merge-patch+json")
+ .header("Accept", MediaType.APPLICATION_JSON_TYPE).header("X-HTTP-Method-Override", "PATCH")
+ .put(Entity.entity(genericVnf, MediaType.valueOf("application/merge-patch+json")));
+ }
+
+ @Override
+ public GenericVnf getVnfByName(String vnfId, String transactionLoggingUuid) throws Exception {
+ return webTarget.register(AAIResourcesObjectMapperProvider.class).path(GENERIC_VNF_PATH + "/" + vnfId).request()
+ .header("X-FromAppId", "MSO").header("X-TransactionId", transactionLoggingUuid)
+ .header("Content-Type", "application/json").accept(MediaType.APPLICATION_JSON_TYPE).get()
+ .readEntity(GenericVnf.class);
+ }
+
+ protected Client getSSLClient() throws NoSuchAlgorithmException {
+ return ClientBuilder.newBuilder().sslContext(SSLContext.getDefault()).build();
+ }
+
+}
diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/aai/AAIUpdator.java b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/aai/AAIUpdator.java
new file mode 100644
index 0000000000..787158f8c6
--- /dev/null
+++ b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/aai/AAIUpdator.java
@@ -0,0 +1,11 @@
+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/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/aai/AAIUpdatorImpl.java b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/aai/AAIUpdatorImpl.java
new file mode 100644
index 0000000000..50b3e61d96
--- /dev/null
+++ b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/aai/AAIUpdatorImpl.java
@@ -0,0 +1,29 @@
+package org.openecomp.mso.client.aai;
+
+import org.springframework.beans.factory.annotation.Autowired;
+
+public class AAIUpdatorImpl implements AAIUpdator {
+
+ @Autowired
+ protected AAIRestClient client;
+
+ public AAIRestClient getClient() {
+ return client;
+ }
+
+
+ public void setClient(AAIRestClient 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/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/aai/AAIValidator.java b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/aai/AAIValidator.java
new file mode 100644
index 0000000000..5ec2dd679d
--- /dev/null
+++ b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/aai/AAIValidator.java
@@ -0,0 +1,12 @@
+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/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/aai/AAIValidatorImpl.java b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/aai/AAIValidatorImpl.java
new file mode 100644
index 0000000000..be39c5fb8b
--- /dev/null
+++ b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/aai/AAIValidatorImpl.java
@@ -0,0 +1,51 @@
+package org.openecomp.mso.client.aai;
+
+import java.io.IOException;
+import java.util.List;
+
+import org.openecomp.aai.domain.yang.GenericVnf;
+import org.openecomp.aai.domain.yang.Pserver;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+
+
+@Service
+public class AAIValidatorImpl implements AAIValidator {
+
+
+ @Autowired
+ protected AAIRestClient client;
+
+ public AAIRestClient getClient() {
+ return client;
+ }
+
+
+ public void setClient(AAIRestClient 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/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/aai/entities/AAIEntity.java b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/aai/entities/AAIEntity.java
new file mode 100644
index 0000000000..a34b96efce
--- /dev/null
+++ b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/aai/entities/AAIEntity.java
@@ -0,0 +1,5 @@
+package org.openecomp.mso.client.aai.entities;
+
+public class AAIEntity {
+
+}
diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/aai/entities/AAIError.java b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/aai/entities/AAIError.java
new file mode 100644
index 0000000000..900587224f
--- /dev/null
+++ b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/aai/entities/AAIError.java
@@ -0,0 +1,27 @@
+
+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/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/aai/entities/CustomQuery.java b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/aai/entities/CustomQuery.java
new file mode 100644
index 0000000000..fb37899e0d
--- /dev/null
+++ b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/aai/entities/CustomQuery.java
@@ -0,0 +1,48 @@
+package org.openecomp.mso.client.aai.entities;
+
+import java.io.UnsupportedEncodingException;
+import java.util.List;
+
+import com.fasterxml.jackson.annotation.JsonInclude;
+
+
+@JsonInclude(JsonInclude.Include.NON_NULL)
+public class CustomQuery {
+
+ List<String> start;
+
+ public String getGremlin() {
+ return gremlin;
+ }
+
+ public void setGremlin(String gremlin) {
+ this.gremlin = gremlin;
+ }
+ String query;
+ String gremlin;
+
+ public CustomQuery(List<String>start, String query){
+ this.start=start;
+ this.query= "query/" + query;
+ }
+
+ public CustomQuery(String gremlin) throws UnsupportedEncodingException{
+ this.gremlin=gremlin;
+ }
+
+ public List<String> getStart() {
+ return start;
+ }
+
+ public void setStart(List<String> start) {
+ this.start = start;
+ }
+
+ public String getQuery() {
+ return query;
+ }
+
+ public void setQuery(String query) {
+ this.query = query;
+ }
+}
diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/aai/entities/RequestError.java b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/aai/entities/RequestError.java
new file mode 100644
index 0000000000..525d983940
--- /dev/null
+++ b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/aai/entities/RequestError.java
@@ -0,0 +1,27 @@
+
+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/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/aai/entities/Results.java b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/aai/entities/Results.java
new file mode 100644
index 0000000000..384ac25246
--- /dev/null
+++ b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/aai/entities/Results.java
@@ -0,0 +1,33 @@
+package org.openecomp.mso.client.aai.entities;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlElement;
+import javax.xml.bind.annotation.XmlRootElement;
+import javax.xml.bind.annotation.XmlType;
+
+
+@XmlAccessorType(XmlAccessType.FIELD)
+@XmlType(name = "", propOrder = {
+ "results"
+})
+@XmlRootElement(name = "results")
+public class Results<T> {
+
+ @XmlElement(name="results")
+ protected List<T> result;
+
+ public List<T> getResult() {
+ if (result == null) {
+ result = new ArrayList<T>();
+ }
+ return this.result;
+ }
+
+ public void setResult(List<T> result) {
+ this.result=result;
+ }
+}
diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/aai/entities/ServiceException.java b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/aai/entities/ServiceException.java
new file mode 100644
index 0000000000..0ea3ebb061
--- /dev/null
+++ b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/aai/entities/ServiceException.java
@@ -0,0 +1,54 @@
+
+package org.openecomp.mso.client.aai.entities;
+
+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 = null;
+
+ @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;
+ }
+
+}