diff options
Diffstat (limited to 'mso-api-handlers/mso-api-handler-infra/src/main')
19 files changed, 258 insertions, 416 deletions
diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/Action.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/Action.java index 5b08cc1b17..6013677684 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/Action.java +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/Action.java @@ -43,5 +43,6 @@ public enum Action implements Actions{ compareModel, scaleInstance, deactivateAndCloudDelete, - scaleOut + scaleOut, + recreateInstance } diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/E2EServiceInstances.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/E2EServiceInstances.java index e8a6beb278..1a95aa0e09 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/E2EServiceInstances.java +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/E2EServiceInstances.java @@ -58,6 +58,7 @@ import org.onap.so.db.catalog.beans.Service; import org.onap.so.db.catalog.beans.ServiceRecipe; import org.onap.so.db.catalog.client.CatalogDbClient; import org.onap.so.db.request.beans.OperationStatus; +import org.onap.so.db.request.client.RequestsDbClient; import org.onap.so.logger.MessageEnum; import org.onap.so.logger.MsoAlarmLogger; import org.onap.so.logger.MsoLogger; @@ -73,8 +74,10 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; import com.fasterxml.jackson.databind.ObjectMapper; -import com.wordnik.swagger.annotations.Api; -import com.wordnik.swagger.annotations.ApiOperation; + +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; + @Component @Path("/e2eServiceInstances") diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/JerseyConfiguration.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/JerseyConfiguration.java index 1700e121f0..e6bbc4de4a 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/JerseyConfiguration.java +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/JerseyConfiguration.java @@ -29,7 +29,7 @@ import org.onap.so.apihandler.filters.RequestUriFilter; import org.onap.so.apihandlerinfra.exceptions.ApiExceptionMapper; import org.onap.so.apihandlerinfra.tenantisolation.CloudOrchestration; import org.onap.so.apihandlerinfra.tenantisolation.CloudResourcesOrchestration; -import org.onap.so.logging.jaxrs.filter.jersey.JaxRsFilterLogging; +import org.onap.so.logging.jaxrs.filter.JaxRsFilterLogging; import org.onap.so.web.exceptions.RuntimeExceptionMapper; import org.springframework.context.annotation.Configuration; diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/ManualTasks.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/ManualTasks.java index 4d8c4ffbd8..dcfe40aa51 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/ManualTasks.java +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/ManualTasks.java @@ -61,7 +61,8 @@ import org.springframework.stereotype.Component; import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.SerializationFeature; -import com.wordnik.swagger.annotations.ApiOperation; + +import io.swagger.annotations.ApiOperation; @Path("/tasks") diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/MsoRequest.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/MsoRequest.java index 66afcf3738..753e712d71 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/MsoRequest.java +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/MsoRequest.java @@ -62,6 +62,7 @@ import org.onap.so.apihandlerinfra.vnfbeans.RequestStatusType; import org.onap.so.apihandlerinfra.vnfbeans.VnfInputs; import org.onap.so.apihandlerinfra.vnfbeans.VnfRequest; import org.onap.so.db.request.beans.InfraActiveRequests; +import org.onap.so.db.request.client.RequestsDbClient; import org.onap.so.db.request.data.repository.InfraActiveRequestsRepository; import org.onap.so.exceptions.ValidationException; import org.onap.so.logger.MessageEnum; @@ -741,4 +742,4 @@ public class MsoRequest { return vnfType; } -}
\ No newline at end of file +} diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/OrchestrationRequests.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/OrchestrationRequests.java index 014739d581..50d2639b2d 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/OrchestrationRequests.java +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/OrchestrationRequests.java @@ -23,6 +23,7 @@ package org.onap.so.apihandlerinfra; import java.io.IOException; import java.text.SimpleDateFormat; import java.util.ArrayList; +import java.util.HashMap; import java.util.List; import java.util.Map; @@ -48,6 +49,8 @@ import org.onap.so.apihandlerinfra.exceptions.ValidateException; import org.onap.so.apihandlerinfra.logging.AlarmLoggerInfo; import org.onap.so.apihandlerinfra.logging.ErrorLoggerInfo; import org.onap.so.db.request.beans.InfraActiveRequests; +import org.onap.so.db.request.beans.RequestProcessingData; +import org.onap.so.db.request.client.RequestsDbClient; import org.onap.so.exceptions.ValidationException; import org.onap.so.logger.MessageEnum; import org.onap.so.logger.MsoAlarmLogger; @@ -96,10 +99,11 @@ public class OrchestrationRequests { GetOrchestrationResponse orchestrationResponse = new GetOrchestrationResponse(); - InfraActiveRequests requestDB = null; - + InfraActiveRequests infraActiveRequest = null; + List<org.onap.so.db.request.beans.RequestProcessingData> requestProcessingData = null; try { - requestDB = requestsDbClient.getInfraActiveRequestbyRequestId(requestId); + infraActiveRequest = requestsDbClient.getInfraActiveRequestbyRequestId(requestId); + requestProcessingData = requestsDbClient.getRequestProcessingDataBySoRequestId(requestId); } catch (Exception e) { msoLogger.error(e); @@ -114,8 +118,8 @@ public class OrchestrationRequests { throw validateException; } - - if(requestDB == null) { + + if(infraActiveRequest == null) { ErrorLoggerInfo errorLoggerInfo = new ErrorLoggerInfo.Builder(MessageEnum.APIH_BPEL_COMMUNICATE_ERROR, MsoLogger.ErrorCode.BusinessProcesssError).build(); @@ -125,8 +129,11 @@ public class OrchestrationRequests { throw validateException; } - - Request request = mapInfraActiveRequestToRequest(requestDB); + + Request request = mapInfraActiveRequestToRequest(infraActiveRequest); + if(!requestProcessingData.isEmpty()){ + request.setRequestProcessingData(mapRequestProcessingData(requestProcessingData)); + } request.setRequestId(requestId); orchestrationResponse.setRequest(request); @@ -170,8 +177,12 @@ public class OrchestrationRequests { List<RequestList> requestLists = new ArrayList<>(); for(InfraActiveRequests infraActive : activeRequests){ + List<RequestProcessingData> requestProcessingData = requestsDbClient.getRequestProcessingDataBySoRequestId(infraActive.getRequestId()); RequestList requestList = new RequestList(); Request request = mapInfraActiveRequestToRequest(infraActive); + if(!requestProcessingData.isEmpty()){ + request.setRequestProcessingData(mapRequestProcessingData(requestProcessingData)); + } requestList.setRequest(request); requestLists.add(requestList); } @@ -336,4 +347,46 @@ public class OrchestrationRequests { return request; } + + public List<org.onap.so.serviceinstancebeans.RequestProcessingData> mapRequestProcessingData(List<org.onap.so.db.request.beans.RequestProcessingData> processingData){ + List<org.onap.so.serviceinstancebeans.RequestProcessingData> addedRequestProcessingData = new ArrayList<>(); + org.onap.so.serviceinstancebeans.RequestProcessingData finalProcessingData = new org.onap.so.serviceinstancebeans.RequestProcessingData(); + String currentGroupingId = null; + HashMap<String, String> tempMap = new HashMap<>(); + List<HashMap<String, String>> tempList = new ArrayList<>(); + for(RequestProcessingData data : processingData){ + String groupingId = data.getGroupingId(); + String tag = data.getTag(); + if(currentGroupingId == null || !currentGroupingId.equals(groupingId)){ + if(!tempMap.isEmpty()){ + tempList.add(tempMap); + finalProcessingData.setDataPairs(tempList); + addedRequestProcessingData.add(finalProcessingData); + } + finalProcessingData = new org.onap.so.serviceinstancebeans.RequestProcessingData(); + if(groupingId != null){ + finalProcessingData.setGroupingId(groupingId); + } + if(tag != null){ + finalProcessingData.setTag(tag); + } + currentGroupingId = groupingId; + tempMap = new HashMap<>(); + tempList = new ArrayList<>(); + if(data.getName() != null && data.getValue() != null){ + tempMap.put(data.getName(), data.getValue()); + } + }else{ + if(data.getName() != null && data.getValue() != null){ + tempMap.put(data.getName(), data.getValue()); + } + } + } + if(tempMap.size() > 0){ + tempList.add(tempMap); + finalProcessingData.setDataPairs(tempList); + } + addedRequestProcessingData.add(finalProcessingData); + return addedRequestProcessingData; + } } diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/RequestsDbClient.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/RequestsDbClient.java deleted file mode 100644 index 380ee2c6ad..0000000000 --- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/RequestsDbClient.java +++ /dev/null @@ -1,176 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.onap.so.apihandlerinfra; - -import org.apache.http.HttpStatus; -import org.onap.so.db.request.beans.InfraActiveRequests; -import org.onap.so.db.request.beans.OperationStatus; -import org.onap.so.db.request.data.controller.InstanceNameDuplicateCheckRequest; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.beans.factory.annotation.Value; -import org.springframework.context.annotation.Bean; -import org.springframework.core.ParameterizedTypeReference; -import org.springframework.http.HttpEntity; -import org.springframework.http.HttpHeaders; -import org.springframework.http.HttpMethod; -import org.springframework.http.client.HttpComponentsClientHttpRequestFactory; -import org.springframework.stereotype.Component; -import org.springframework.web.client.HttpClientErrorException; -import org.springframework.web.client.RestTemplate; -import uk.co.blackpepper.bowman.Client; -import uk.co.blackpepper.bowman.ClientFactory; -import uk.co.blackpepper.bowman.Configuration; - -import javax.annotation.PostConstruct; -import javax.ws.rs.core.UriBuilder; -import java.net.URI; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -@Component("RequestDbClient") -public class RequestsDbClient { - - private static final String SERVICE_ID = "SERVICE_ID"; - private static final String OPERATION_ID = "OPERATION_ID"; - - private Client<InfraActiveRequests> infraActiveRequestClient; - private Client<OperationStatus> operationStatusClient; - - @Value("${mso.adapters.requestDb.endpoint}") - private String endpoint; - - @Value("${mso.adapters.requestDb.auth}") - private String msoAdaptersAuth; - - private String getOrchestrationFilterURI = "/infraActiveRequests/getOrchestrationFiltersFromInfraActive/"; - private static final String OPERATION_STATUS_REPOSITORY_SEARCH = "/operationStatusRepository/search"; - - private String checkVnfIdStatus = "/infraActiveRequests/checkVnfIdStatus/"; - - private String infraActiveRequestURI = "/infraActiveRequests/"; - - private String checkInstanceNameDuplicate = "/infraActiveRequests/checkInstanceNameDuplicate"; - - private String findOneByServiceIdAndOperationIdURI = "/findOneByServiceIdAndOperationId"; - - private String cloudOrchestrationFiltersFromInfraActive = "/infraActiveRequests/getCloudOrchestrationFiltersFromInfraActive"; - - private HttpHeaders headers; - - @Autowired - private RestTemplate restTemplate; - - @PostConstruct - public void init() { - getOrchestrationFilterURI = endpoint + getOrchestrationFilterURI; - infraActiveRequestURI = endpoint + infraActiveRequestURI; - checkVnfIdStatus = endpoint + checkVnfIdStatus; - checkInstanceNameDuplicate = endpoint + checkInstanceNameDuplicate; - cloudOrchestrationFiltersFromInfraActive = endpoint + cloudOrchestrationFiltersFromInfraActive; - findOneByServiceIdAndOperationIdURI = endpoint + OPERATION_STATUS_REPOSITORY_SEARCH + findOneByServiceIdAndOperationIdURI; - headers = new HttpHeaders(); - headers.set("Authorization", msoAdaptersAuth); - } - - public RequestsDbClient() { - ClientFactory clientFactory = Configuration.builder().setRestTemplateConfigurer(restTemplate -> restTemplate.getInterceptors().add((request, body, execution) -> { - request.getHeaders().add("Authorization", msoAdaptersAuth); - return execution.execute(request, body); - })).build().buildClientFactory(); - infraActiveRequestClient = clientFactory.create(InfraActiveRequests.class); - operationStatusClient = clientFactory.create(OperationStatus.class); - - } - public List<InfraActiveRequests> getCloudOrchestrationFiltersFromInfraActive(Map<String, String> orchestrationMap){ - URI uri = getUri(cloudOrchestrationFiltersFromInfraActive); - HttpEntity<Map> entity = new HttpEntity<>(orchestrationMap, headers); - try{ - return restTemplate.exchange(uri, HttpMethod.POST, entity, new ParameterizedTypeReference<List<InfraActiveRequests>>() {}).getBody(); - }catch(HttpClientErrorException e){ - if(HttpStatus.SC_NOT_FOUND == e.getStatusCode().value()){ - return null; - } - throw e; - } - } - public InfraActiveRequests getInfraActiveRequestbyRequestId(String requestId) { - return this.getSingleInfraActiveRequests(this.getUri(endpoint + "/infraActiveRequests/" + requestId)); - } - - public List<InfraActiveRequests> getOrchestrationFiltersFromInfraActive(Map<String, List<String>> orchestrationMap) { - URI uri = getUri(getOrchestrationFilterURI); - HttpEntity<Map<String, List<String>>> entity = new HttpEntity<>(orchestrationMap, headers); - return restTemplate.exchange(uri, HttpMethod.POST, entity, new ParameterizedTypeReference<List<InfraActiveRequests>>() {}).getBody(); - } - - public InfraActiveRequests checkVnfIdStatus(String operationalEnvironmentId) { - URI uri = getUri(checkVnfIdStatus + operationalEnvironmentId); - return restTemplate.exchange(uri, HttpMethod.GET, HttpEntity.EMPTY, InfraActiveRequests.class).getBody(); - } - public InfraActiveRequests checkInstanceNameDuplicate(HashMap<String, String> instanceIdMap, String instanceName, String requestScope) { - URI uri = getUri(checkInstanceNameDuplicate); - HttpEntity<InstanceNameDuplicateCheckRequest> entity = new HttpEntity<>(new InstanceNameDuplicateCheckRequest(instanceIdMap, instanceName, requestScope), headers); - try{ - return restTemplate.exchange(uri, HttpMethod.POST, entity, InfraActiveRequests.class).getBody(); - }catch(HttpClientErrorException e){ - if(HttpStatus.SC_NOT_FOUND == e.getStatusCode().value()){ - return null; - } - throw e; - } - - } - - public OperationStatus getOneByServiceIdAndOperationId(String serviceId, String operationId){ - return this.getSingleOperationStatus(UriBuilder.fromUri(findOneByServiceIdAndOperationIdURI) - .queryParam(SERVICE_ID,serviceId) - .queryParam(OPERATION_ID,operationId) - .build()); - } - - public void save(InfraActiveRequests infraActiveRequests) { - URI uri = getUri(infraActiveRequestURI); - HttpEntity<InfraActiveRequests> entity = new HttpEntity<>(infraActiveRequests, headers); - restTemplate.postForLocation(uri, entity); - } - - protected InfraActiveRequests getSingleInfraActiveRequests(URI uri) { - return infraActiveRequestClient.get(uri); - } - - public void updateInfraActiveRequests(InfraActiveRequests request) { - infraActiveRequestClient.put(request); - } - - public OperationStatus getSingleOperationStatus(URI uri){ - return operationStatusClient.get(uri); - } - - protected URI getUri(String uri) { - return URI.create(uri); - } - - @Bean - public RestTemplate restTemplate() { - return new RestTemplate( new HttpComponentsClientHttpRequestFactory()); - } -} diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/ServiceInstances.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/ServiceInstances.java index ced69df55c..bb7df4b7be 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/ServiceInstances.java +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/ServiceInstances.java @@ -22,27 +22,13 @@ package org.onap.so.apihandlerinfra; -import java.io.IOException; -import java.sql.Timestamp; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Optional; - -import javax.transaction.Transactional; -import javax.ws.rs.Consumes; -import javax.ws.rs.DELETE; -import javax.ws.rs.POST; -import javax.ws.rs.PUT; -import javax.ws.rs.Path; -import javax.ws.rs.PathParam; -import javax.ws.rs.Produces; -import javax.ws.rs.container.ContainerRequestContext; -import javax.ws.rs.core.Context; -import javax.ws.rs.core.MediaType; -import javax.ws.rs.core.Response; - +import com.fasterxml.jackson.annotation.JsonInclude.Include; +import com.fasterxml.jackson.core.JsonParseException; +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.JsonMappingException; +import com.fasterxml.jackson.databind.ObjectMapper; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; import org.apache.commons.lang.StringUtils; import org.apache.http.HttpResponse; import org.apache.http.HttpStatus; @@ -70,18 +56,9 @@ import org.onap.so.db.catalog.beans.VfModuleCustomization; import org.onap.so.db.catalog.beans.VnfRecipe; import org.onap.so.db.catalog.beans.VnfResource; import org.onap.so.db.catalog.beans.VnfResourceCustomization; -import org.onap.so.db.catalog.data.repository.NetworkRecipeRepository; -import org.onap.so.db.catalog.data.repository.NetworkResourceCustomizationRepository; -import org.onap.so.db.catalog.data.repository.ServiceRecipeRepository; -import org.onap.so.db.catalog.data.repository.ServiceRepository; -import org.onap.so.db.catalog.data.repository.VFModuleCustomizationRepository; -import org.onap.so.db.catalog.data.repository.VFModuleRepository; -import org.onap.so.db.catalog.data.repository.VnfComponentRecipeRepository; -import org.onap.so.db.catalog.data.repository.VnfCustomizationRepository; -import org.onap.so.db.catalog.data.repository.VnfRecipeRepository; -import org.onap.so.db.catalog.data.repository.VnfResourceRepository; +import org.onap.so.db.catalog.client.CatalogDbClient; import org.onap.so.db.request.beans.InfraActiveRequests; -import org.onap.so.db.request.data.repository.InfraActiveRequestsRepository; +import org.onap.so.db.request.client.RequestsDbClient; import org.onap.so.exceptions.ValidationException; import org.onap.so.logger.MessageEnum; import org.onap.so.logger.MsoLogger; @@ -104,14 +81,25 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.core.env.Environment; import org.springframework.stereotype.Component; -import com.fasterxml.jackson.annotation.JsonInclude.Include; -import com.fasterxml.jackson.core.JsonParseException; -import com.fasterxml.jackson.core.JsonProcessingException; -import com.fasterxml.jackson.databind.JsonMappingException; -import com.fasterxml.jackson.databind.ObjectMapper; - -import io.swagger.annotations.Api; -import io.swagger.annotations.ApiOperation; +import javax.transaction.Transactional; +import javax.ws.rs.Consumes; +import javax.ws.rs.DELETE; +import javax.ws.rs.POST; +import javax.ws.rs.PUT; +import javax.ws.rs.Path; +import javax.ws.rs.PathParam; +import javax.ws.rs.Produces; +import javax.ws.rs.container.ContainerRequestContext; +import javax.ws.rs.core.Context; +import javax.ws.rs.core.MediaType; +import javax.ws.rs.core.Response; +import java.io.IOException; +import java.sql.Timestamp; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Optional; @Component @Path("/onap/so/infra/serviceInstantiation") @@ -129,37 +117,10 @@ public class ServiceInstances { private RequestClientFactory reqClientFactory; @Autowired - private ServiceRepository serviceRepo; - - @Autowired - private ServiceRecipeRepository serviceRecipeRepo; - - @Autowired - private NetworkRecipeRepository networkRecipeRepo; - - @Autowired - private NetworkResourceCustomizationRepository networkCustomizationRepo; - - @Autowired - private VnfResourceRepository vnfRepo; - - @Autowired - private VnfCustomizationRepository vnfCustomRepo; - - @Autowired - private VnfRecipeRepository vnfRecipeRepo; - - @Autowired - private VFModuleCustomizationRepository vfModuleCustomRepo; - - @Autowired - private VFModuleRepository vfModuleRepo; - - @Autowired - private VnfComponentRecipeRepository vnfComponentRecipeRepo; - + private CatalogDbClient catalogDbClient; + @Autowired - private InfraActiveRequestsRepository iar; + private RequestsDbClient infraActiveRequestsClient; @Autowired private ResponseBuilder builder; @@ -411,6 +372,20 @@ public class ServiceInstances { instanceIdMap.put("vnfInstanceId", vnfInstanceId); return serviceInstances(request, Action.applyUpdatedConfig, instanceIdMap, version, requestId, getRequestUri(requestContext)); } + + @POST + @Path("/{version:[vV][7]}/serviceInstances/{serviceInstanceId}/vnfs/{vnfInstanceId}/recreate") + @Consumes(MediaType.APPLICATION_JSON) + @Produces(MediaType.APPLICATION_JSON) + @ApiOperation(value="Recreate VNF Instance",response=Response.class) + public Response recreateVnfInstance(String request, @PathParam("version") String version, @PathParam("serviceInstanceId") String serviceInstanceId, + @PathParam("vnfInstanceId") String vnfInstanceId, @Context ContainerRequestContext requestContext) throws ApiException { + String requestId = getRequestId(requestContext); + HashMap<String, String> instanceIdMap = new HashMap<>(); + instanceIdMap.put("serviceInstanceId", serviceInstanceId); + instanceIdMap.put("vnfInstanceId", vnfInstanceId); + return serviceInstances(request, Action.recreateInstance, instanceIdMap, version, requestId, getRequestUri(requestContext)); + } @DELETE @@ -702,14 +677,14 @@ public class ServiceInstances { // Get VF Module-specific base module indicator - VfModule vfm; + VfModule vfm = null; String modelVersionId = modelInfo.getModelVersionId(); if(modelVersionId != null) { - vfm = vfModuleRepo.findByModelUUID(modelVersionId); - } else { - vfm = vfModuleRepo.findByModelInvariantUUIDAndModelVersion(modelInfo.getModelInvariantId(), modelInfo.getModelVersion()); + vfm = catalogDbClient.getVfModuleByModelUUID(modelVersionId); + } else if(modelInfo.getModelInvariantId() != null && modelInfo.getModelVersion() != null){ + vfm = catalogDbClient.getVfModuleByModelInvariantUUIDAndModelVersion(modelInfo.getModelInvariantId(), modelInfo.getModelVersion()); } if (vfm != null) { @@ -765,7 +740,7 @@ public class ServiceInstances { if (sir.getCorrelationId() != null) { correlationId = sir.getCorrelationId(); } - iar.save(currentActiveReq); + infraActiveRequestsClient.save(currentActiveReq); if(!requestScope.equalsIgnoreCase(ModelType.service.name())){ aLaCarte = true; @@ -870,9 +845,8 @@ public class ServiceInstances { ErrorLoggerInfo errorLoggerInfo = new ErrorLoggerInfo.Builder(MessageEnum.APIH_BPEL_RESPONSE_ERROR, MsoLogger.ErrorCode.SchemaError).errorSource(Constants.MSO_PROP_APIHANDLER_INFRA).build(); ValidateException validateException = new ValidateException.Builder("Exception caught mapping Camunda JSON response to object", HttpStatus.SC_INTERNAL_SERVER_ERROR, ErrorNumbers.SVC_BAD_PARAMETER).cause(e) .errorInfo(errorLoggerInfo).build(); - currentActiveReq.setRequestStatus(Status.FAILED.name()); - currentActiveReq.setStatusMessage(validateException.getMessage()); - throw validateException; + updateStatus(currentActiveReq, Status.FAILED, validateException.getMessage()); + throw validateException; } // BPEL accepted the request, the request is in progress @@ -889,15 +863,14 @@ public class ServiceInstances { ErrorLoggerInfo errorLoggerInfo = new ErrorLoggerInfo.Builder(MessageEnum.APIH_BPEL_RESPONSE_ERROR, MsoLogger.ErrorCode.SchemaError).errorSource(Constants.MSO_PROP_APIHANDLER_INFRA).build(); ValidateException validateException = new ValidateException.Builder("Exception caught mapping Camunda JSON response to object", HttpStatus.SC_NOT_ACCEPTABLE, ErrorNumbers.SVC_BAD_PARAMETER).cause(e) .errorInfo(errorLoggerInfo).build(); - currentActiveReq.setRequestStatus(Status.FAILED.name()); - currentActiveReq.setStatusMessage(validateException.getMessage()); + updateStatus(currentActiveReq, Status.FAILED, validateException.getMessage()); throw validateException; } currentActiveReq.setRequestStatus(Status.IN_PROGRESS.name()); setInstanceId(currentActiveReq, requestScope, jsonResponse.getRequestReferences().getInstanceId(), new HashMap<>()); - iar.save(currentActiveReq); + infraActiveRequestsClient.save(currentActiveReq); return builder.buildResponse(HttpStatus.SC_ACCEPTED, requestId, jsonResponse, apiVersion); } } @@ -1006,7 +979,7 @@ public class ServiceInstances { InfraActiveRequests dup = null; try { if(!(instanceName==null && requestScope.equals("service") && (action == Action.createInstance || action == Action.activateInstance || action == Action.assignInstance))){ - dup = iar.checkInstanceNameDuplicate (instanceIdMap, instanceName, requestScope); + dup = infraActiveRequestsClient.checkInstanceNameDuplicate (instanceIdMap, instanceName, requestScope); } } catch (Exception e) { ErrorLoggerInfo errorLoggerInfo = new ErrorLoggerInfo.Builder(MessageEnum.APIH_DUPLICATE_CHECK_EXC, MsoLogger.ErrorCode.DataError).errorSource(Constants.MSO_PROP_APIHANDLER_INFRA).build(); @@ -1036,32 +1009,12 @@ public class ServiceInstances { .errorInfo(errorLoggerInfo).build(); String requestScope = requestScopeFromUri(requestUri); - createErrorRequestRecord(Status.FAILED, requestId, validateException.getMessage(), action, requestScope, requestJSON); + msoRequest.createErrorRequestRecord(Status.FAILED, requestId, validateException.getMessage(), action, requestScope, requestJSON); throw validateException; } } - //TODO MSO-4177 -- remove this and call the msoRequest instead - public void createErrorRequestRecord (Status status, String requestId, String errorMessage, Actions action, String requestScope, String requestJSON) { - try { - InfraActiveRequests request = new InfraActiveRequests(requestId); - Timestamp startTimeStamp = new Timestamp (System.currentTimeMillis()); - request.setStartTime (startTimeStamp); - request.setRequestStatus(status.toString()); - request.setStatusMessage(errorMessage); - request.setProgress((long) 100); - request.setLastModifiedBy(Constants.MODIFIED_BY_APIHANDLER); - request.setRequestAction(action.toString()); - request.setRequestScope(requestScope); - request.setRequestBody(requestJSON); - Timestamp endTimeStamp = new Timestamp(System.currentTimeMillis()); - request.setEndTime(endTimeStamp); - iar.save(request); - } catch (Exception e) { - msoLogger.error(MessageEnum.APIH_DB_UPDATE_EXC, e.getMessage(), "", "", MsoLogger.ErrorCode.DataError, "Exception when updating record in DB"); - msoLogger.debug ("Exception: ", e); - } - } + private void parseRequest(ServiceInstancesRequest sir, HashMap<String, String> instanceIdMap, Actions action, String version, String requestJSON, Boolean aLaCarte, String requestId, InfraActiveRequests currentActiveReq) throws ValidateException { int reqVersion = Integer.parseInt(version.substring(1)); @@ -1144,8 +1097,7 @@ public class ServiceInstances { } return recipeLookupResult; } - - + private RecipeLookupResult getServiceURI(ServiceInstancesRequest servInstReq, Actions action, boolean alaCarteFlag) throws IOException { // SERVICE REQUEST // Construct the default service name @@ -1158,18 +1110,18 @@ public class ServiceInstances { ServiceRecipe recipe = null; if(alaCarteFlag){ - serviceRecord = serviceRepo.findByModelNameOrderByModelVersionDesc(defaultServiceModelName); - if(serviceRecord !=null){ - recipe = serviceRecord.getRecipes().get(action.toString()); + serviceRecord = catalogDbClient.getFirstByModelNameOrderByModelVersionDesc(defaultServiceModelName); + if(serviceRecord !=null){ + recipe =catalogDbClient.getFirstByServiceModelUUIDAndAction(serviceRecord.getModelUUID(),action.toString()); } }else{ - serviceRecord = serviceRepo.findOneByModelUUID(modelInfo.getModelVersionId()); - recipe = serviceRecipeRepo.findFirstByServiceModelUUIDAndAction(modelInfo.getModelVersionId(), action.toString()); + serviceRecord = catalogDbClient.getServiceByID(modelInfo.getModelVersionId()); + recipe = catalogDbClient.getFirstByServiceModelUUIDAndAction(modelInfo.getModelVersionId(), action.toString()); if (recipe == null){ - serviceRecordList = serviceRepo.findByModelInvariantUUIDOrderByModelVersionDesc(modelInfo.getModelInvariantId()); + serviceRecordList = catalogDbClient.getServiceByModelInvariantUUIDOrderByModelVersionDesc(modelInfo.getModelInvariantId()); if(!serviceRecordList.isEmpty()){ for(org.onap.so.db.catalog.beans.Service record : serviceRecordList){ - recipe = record.getRecipes().get(action.toString()); + recipe = catalogDbClient.getFirstByServiceModelUUIDAndAction(record.getModelUUID(),action.toString()); if(recipe != null){ break; } @@ -1185,8 +1137,8 @@ public class ServiceInstances { } else if(!alaCarteFlag && recipe != null && Action.createInstance.equals(action)) { mapToLegacyRequest(requestDetails); }else if (recipe == null) { //aLaCarte wasn't sent, so we'll try the default - serviceRecord = serviceRepo.findByModelNameOrderByModelVersionDesc(defaultServiceModelName); - recipe = serviceRecord.getRecipes().get( action.toString()); + serviceRecord = catalogDbClient.getFirstByModelNameOrderByModelVersionDesc(defaultServiceModelName); + recipe = catalogDbClient.getFirstByServiceModelUUIDAndAction(serviceRecord.getModelUUID(),action.toString()); } if(modelInfo.getModelVersionId() == null) { modelInfo.setModelVersionId(serviceRecord.getModelUUID()); @@ -1381,14 +1333,14 @@ public class ServiceInstances { // Validation for vnfResource if(modelCustomizationId!=null) { - vrc = vnfCustomRepo.findOneByModelCustomizationUUID(modelCustomizationId); + vrc = catalogDbClient.getVnfResourceCustomizationByModelCustomizationUUID(modelCustomizationId); if(vrc != null){ vnfResource = vrc.getVnfResources(); } } else { - org.onap.so.db.catalog.beans.Service service = serviceRepo.findOneByModelUUID(relatedInstanceModelVersionId); + org.onap.so.db.catalog.beans.Service service = catalogDbClient.getServiceByID(relatedInstanceModelVersionId); if(service == null) { - service = serviceRepo.findByModelVersionAndModelInvariantUUID(relatedInstanceVersion, relatedInstanceModelInvariantId); + service = catalogDbClient.getServiceByModelVersionAndModelInvariantUUID(relatedInstanceVersion, relatedInstanceModelInvariantId); } if(service == null) { @@ -1420,12 +1372,12 @@ public class ServiceInstances { if(vrc != null) { String nfRole = vrc.getNfRole(); if(nfRole != null) { - vnfRecipe = vnfRecipeRepo.findVnfRecipeByNfRoleAndAction(vrc.getNfRole(), action.toString()); + vnfRecipe = catalogDbClient.getFirstVnfRecipeByNfRoleAndAction(vrc.getNfRole(), action.toString()); } } if(vnfRecipe == null) { - vnfRecipe = vnfRecipeRepo.findVnfRecipeByNfRoleAndAction(defaultSource, action.toString()); + vnfRecipe = catalogDbClient.getFirstVnfRecipeByNfRoleAndAction(defaultSource, action.toString()); } if (vnfRecipe == null) { @@ -1449,13 +1401,13 @@ public class ServiceInstances { VfModule vfModule = null; if(modelInfo.getModelCustomizationId() != null) { - vfmc = vfModuleCustomRepo.findByModelCustomizationUUID(modelInfo.getModelCustomizationId()); + vfmc = catalogDbClient.getVfModuleCustomizationByModelCuztomizationUUID(modelInfo.getModelCustomizationId()); } else { - vnfr = vnfRepo.findResourceByModelUUID(relatedInstanceModelVersionId); + vnfr = catalogDbClient.getVnfResourceByModelUUID(relatedInstanceModelVersionId); if(vnfr == null){ - vnfr = vnfRepo.findResourceByModelInvariantUUIDAndModelVersion(relatedInstanceModelInvariantId, relatedInstanceVersion); + vnfr = catalogDbClient.getFirstVnfResourceByModelInvariantUUIDAndModelVersion(relatedInstanceModelInvariantId, relatedInstanceVersion); } - vnfrc = vnfCustomRepo.findByModelInstanceNameAndVnfResources(relatedInstanceModelCustomizationName, vnfr); + vnfrc = catalogDbClient.getFirstVnfResourceCustomizationByModelInstanceNameAndVnfResources(relatedInstanceModelCustomizationName, vnfr); List<VfModuleCustomization> list = vnfrc.getVfModuleCustomizations(); @@ -1463,16 +1415,16 @@ public class ServiceInstances { for(VfModuleCustomization vf : list) { VfModuleCustomization vfmCustom; if(vfModuleModelUUID != null){ - vfmCustom = vfModuleCustomRepo.findByModelCustomizationUUIDAndVfModuleModelUUID(vf.getModelCustomizationUUID(), vfModuleModelUUID); + vfmCustom = catalogDbClient.getVfModuleCustomizationByModelCustomizationUUIDAndVfModuleModelUUID(vf.getModelCustomizationUUID(), vfModuleModelUUID); if(vfmCustom != null){ vfModule = vfmCustom.getVfModule(); } }else{ - vfmCustom = vfModuleCustomRepo.findByModelCustomizationUUID(vf.getModelCustomizationUUID()); + vfmCustom = catalogDbClient.getVfModuleCustomizationByModelCuztomizationUUID(vf.getModelCustomizationUUID()); if(vfmCustom != null){ vfModule = vfmCustom.getVfModule(); }else{ - vfModule = vfModuleRepo.findByModelInvariantUUIDAndModelVersion(relatedInstanceModelInvariantId, relatedInstanceVersion); + vfModule = catalogDbClient.getVfModuleByModelInvariantUUIDAndModelVersion(relatedInstanceModelInvariantId, relatedInstanceVersion); } } @@ -1495,12 +1447,12 @@ public class ServiceInstances { } - recipe = vnfComponentRecipeRepo.findVnfComponentsRecipeByVfModuleModelUUIDAndVnfComponentTypeAndAction(vfModule.getModelUUID(), vnfComponentType, action.toString()); + recipe = catalogDbClient.getFirstVnfComponentsRecipeByVfModuleModelUUIDAndVnfComponentTypeAndAction(vfModule.getModelUUID(), vnfComponentType, action.toString()); if(recipe == null){ - List<VfModule> vfModuleRecords= vfModuleRepo.findByModelInvariantUUIDOrderByModelVersionDesc(vfModule.getModelInvariantUUID()); + List<VfModule> vfModuleRecords= catalogDbClient.getVfModuleByModelInvariantUUIDOrderByModelVersionDesc(vfModule.getModelInvariantUUID()); if(!vfModuleRecords.isEmpty()){ for(VfModule record : vfModuleRecords){ - recipe = vnfComponentRecipeRepo.findVnfComponentsRecipeByVfModuleModelUUIDAndVnfComponentTypeAndAction(record.getModelUUID(), vnfComponentType, action.toString()); + recipe = catalogDbClient.getFirstVnfComponentsRecipeByVfModuleModelUUIDAndVnfComponentTypeAndAction(record.getModelUUID(), vnfComponentType, action.toString()); if(recipe != null){ break; } @@ -1508,9 +1460,9 @@ public class ServiceInstances { } } if(recipe == null) { - recipe = vnfComponentRecipeRepo.findVnfComponentsRecipeByVfModuleModelUUIDAndVnfComponentTypeAndAction(defaultSource, vnfComponentType, action.toString()); + recipe = catalogDbClient.getFirstVnfComponentsRecipeByVfModuleModelUUIDAndVnfComponentTypeAndAction(defaultSource, vnfComponentType, action.toString()); if (recipe == null) { - recipe = vnfComponentRecipeRepo.findVnfComponentsRecipeByVnfComponentTypeAndAction(vnfComponentType, action.toString()); + recipe = catalogDbClient.getFirstVnfComponentsRecipeByVnfComponentTypeAndAction(vnfComponentType, action.toString()); } if(recipe == null) { @@ -1521,12 +1473,12 @@ public class ServiceInstances { } else { if(modelInfo.getModelType().equals(ModelType.vnf)) { - recipe = vnfRecipeRepo.findVnfRecipeByNfRoleAndAction(defaultSource, action.toString()); + recipe = catalogDbClient.getFirstVnfRecipeByNfRoleAndAction(defaultSource, action.toString()); if (recipe == null) { return null; } } else { - recipe = vnfComponentRecipeRepo.findVnfComponentsRecipeByVfModuleModelUUIDAndVnfComponentTypeAndAction(defaultSource, vnfComponentType, action.toString()); + recipe = catalogDbClient.getFirstVnfComponentsRecipeByVfModuleModelUUIDAndVnfComponentTypeAndAction(defaultSource, vnfComponentType, action.toString()); if (recipe == null) { return null; @@ -1541,7 +1493,7 @@ public class ServiceInstances { String defaultSource = getDefaultModel(sir); - VnfRecipe vnfRecipe = vnfRecipeRepo.findVnfRecipeByNfRoleAndAction(defaultSource, action.toString()); + VnfRecipe vnfRecipe = catalogDbClient.getFirstVnfRecipeByNfRoleAndAction(defaultSource, action.toString()); if (vnfRecipe == null) { return null; @@ -1560,22 +1512,24 @@ public class ServiceInstances { Recipe recipe = null; if(modelInfo.getModelCustomizationId()!=null){ - NetworkResource networkResource = networkCustomizationRepo.findOneByModelCustomizationUUID(modelInfo.getModelCustomizationId()).getNetworkResource(); + NetworkResource networkResource = catalogDbClient.getNetworkResourceCustomizationByModelCustomizationUUID(modelInfo.getModelCustomizationId()).getNetworkResource(); if(networkResource!=null){ if(modelInfo.getModelVersionId() == null) { modelInfo.setModelVersionId(networkResource.getModelUUID()); } - recipe = networkRecipeRepo.findByModelNameAndAction(networkResource.getModelName(), action.toString()); + recipe = catalogDbClient.getFirstNetworkRecipeByModelNameAndAction(networkResource.getModelName(), action.toString()); }else{ throw new ValidationException("no catalog entry found"); } }else{ //ok for version < 3 and action delete - recipe = networkRecipeRepo.findByModelNameAndAction(modelName, action.toString()); + if(modelName != null){ + recipe = catalogDbClient.getFirstNetworkRecipeByModelNameAndAction(modelName, action.toString()); + } } if(recipe == null){ - recipe = networkRecipeRepo.findByModelNameAndAction(defaultNetworkType, action.toString()); + recipe = catalogDbClient.getFirstNetworkRecipeByModelNameAndAction(defaultNetworkType, action.toString()); } return recipe !=null ? new RecipeLookupResult(recipe.getOrchestrationUri(), recipe.getRecipeTimeout()) : null; @@ -1679,7 +1633,7 @@ public class ServiceInstances { if (sir.getCorrelationId() != null) { correlationId = sir.getCorrelationId(); } - iar.save(currentActiveReq); + infraActiveRequestsClient.save(currentActiveReq); if(!requestScope.equalsIgnoreCase(ModelType.service.name())){ aLaCarte = true; @@ -1706,7 +1660,6 @@ public class ServiceInstances { throw validateException; } } - //TODO MSO-4177 -- remove this and call the msoRequest instead public void updateStatus(InfraActiveRequests aq, Status status, String errorMessage){ if ((status == Status.FAILED) || (status == Status.COMPLETE)) { aq.setStatusMessage (errorMessage); @@ -1714,7 +1667,7 @@ public class ServiceInstances { aq.setRequestStatus(status.toString()); Timestamp endTimeStamp = new Timestamp (System.currentTimeMillis()); aq.setEndTime (endTimeStamp); - iar.save(aq); + infraActiveRequestsClient.save(aq); } } -}
\ No newline at end of file +} diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/SpringContextHelper.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/SpringContextHelper.java index 0a996dc3dc..6d61d3bb34 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/SpringContextHelper.java +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/SpringContextHelper.java @@ -4,6 +4,8 @@ * ================================================================================ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. * ================================================================================ + * Modifications Copyright (C) 2018 IBM. + * ================================================================================ * 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 @@ -20,7 +22,6 @@ package org.onap.so.apihandlerinfra; -import org.springframework.beans.BeansException; import org.springframework.context.ApplicationContext; import org.springframework.context.ApplicationContextAware; import org.springframework.stereotype.Component; @@ -31,7 +32,7 @@ public class SpringContextHelper implements ApplicationContextAware { private static ApplicationContext context; @Override - public void setApplicationContext(ApplicationContext applicationContext) throws BeansException { + public void setApplicationContext(ApplicationContext applicationContext) { context = applicationContext; } diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/CloudOrchestration.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/CloudOrchestration.java index 910b9f70cb..d743c440e7 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/CloudOrchestration.java +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/CloudOrchestration.java @@ -40,7 +40,6 @@ import javax.ws.rs.core.Response; import org.apache.http.HttpStatus; import org.onap.so.apihandler.common.ErrorNumbers; import org.onap.so.apihandlerinfra.Constants; -import org.onap.so.apihandlerinfra.RequestsDbClient; import org.onap.so.apihandlerinfra.Status; import org.onap.so.apihandlerinfra.exceptions.ApiException; import org.onap.so.apihandlerinfra.exceptions.DuplicateRequestException; @@ -51,7 +50,7 @@ import org.onap.so.apihandlerinfra.tenantisolationbeans.OperationalEnvironment; import org.onap.so.apihandlerinfra.tenantisolationbeans.RequestReferences; import org.onap.so.apihandlerinfra.tenantisolationbeans.TenantSyncResponse; import org.onap.so.db.request.beans.InfraActiveRequests; -import org.onap.so.db.request.data.repository.InfraActiveRequestsRepository; +import org.onap.so.db.request.client.RequestsDbClient; import org.onap.so.exceptions.ValidationException; import org.onap.so.logger.MessageEnum; import org.onap.so.logger.MsoLogger; @@ -238,4 +237,4 @@ public class CloudOrchestration { private String getRequestId(ContainerRequestContext requestContext) { return requestContext.getProperty("requestId").toString(); } -}
\ No newline at end of file +} diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/CloudResourcesOrchestration.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/CloudResourcesOrchestration.java index a9cf35796b..a35f40baf6 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/CloudResourcesOrchestration.java +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/CloudResourcesOrchestration.java @@ -20,22 +20,42 @@ package org.onap.so.apihandlerinfra.tenantisolation; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.wordnik.swagger.annotations.Api; -import com.wordnik.swagger.annotations.ApiOperation; +import java.io.IOException; +import java.text.SimpleDateFormat; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; + +import javax.transaction.Transactional; +import javax.ws.rs.Consumes; +import javax.ws.rs.GET; +import javax.ws.rs.POST; +import javax.ws.rs.Path; +import javax.ws.rs.PathParam; +import javax.ws.rs.Produces; +import javax.ws.rs.core.Context; +import javax.ws.rs.core.MediaType; +import javax.ws.rs.core.MultivaluedMap; +import javax.ws.rs.core.Response; +import javax.ws.rs.core.UriInfo; + import org.apache.http.HttpStatus; import org.onap.so.apihandler.common.ErrorNumbers; import org.onap.so.apihandler.common.ResponseBuilder; import org.onap.so.apihandlerinfra.Constants; import org.onap.so.apihandlerinfra.Messages; -import org.onap.so.apihandlerinfra.RequestsDbClient; import org.onap.so.apihandlerinfra.exceptions.ApiException; import org.onap.so.apihandlerinfra.exceptions.ValidateException; import org.onap.so.apihandlerinfra.logging.AlarmLoggerInfo; import org.onap.so.apihandlerinfra.logging.ErrorLoggerInfo; -import org.onap.so.apihandlerinfra.tenantisolationbeans.*; +import org.onap.so.apihandlerinfra.tenantisolationbeans.CloudOrchestrationRequestList; +import org.onap.so.apihandlerinfra.tenantisolationbeans.CloudOrchestrationResponse; +import org.onap.so.apihandlerinfra.tenantisolationbeans.InstanceReferences; import org.onap.so.apihandlerinfra.tenantisolationbeans.Request; +import org.onap.so.apihandlerinfra.tenantisolationbeans.RequestDetails; +import org.onap.so.apihandlerinfra.tenantisolationbeans.RequestStatus; import org.onap.so.db.request.beans.InfraActiveRequests; +import org.onap.so.db.request.client.RequestsDbClient; import org.onap.so.exceptions.ValidationException; import org.onap.so.logger.MessageEnum; import org.onap.so.logger.MsoAlarmLogger; @@ -44,15 +64,10 @@ import org.onap.so.utils.UUIDChecker; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; -import javax.transaction.Transactional; -import javax.ws.rs.*; -import javax.ws.rs.core.*; +import com.fasterxml.jackson.databind.ObjectMapper; -import java.io.IOException; -import java.text.SimpleDateFormat; -import java.util.ArrayList; -import java.util.List; -import java.util.Map; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; @Component @Path("onap/so/infra/cloudResourcesRequests") @@ -279,4 +294,4 @@ public class CloudResourcesOrchestration { return request; } -}
\ No newline at end of file +} diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/TenantIsolationRequest.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/TenantIsolationRequest.java index b35b669208..855a5433f3 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/TenantIsolationRequest.java +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/TenantIsolationRequest.java @@ -30,7 +30,6 @@ import javax.ws.rs.core.MultivaluedMap; import org.apache.commons.lang3.StringUtils; import org.onap.so.apihandlerinfra.Constants; -import org.onap.so.apihandlerinfra.RequestsDbClient; import org.onap.so.apihandlerinfra.Status; import org.onap.so.apihandlerinfra.tenantisolationbeans.Action; import org.onap.so.apihandlerinfra.tenantisolationbeans.Manifest; @@ -44,6 +43,7 @@ import org.onap.so.apihandlerinfra.tenantisolationbeans.ResourceType; import org.onap.so.apihandlerinfra.tenantisolationbeans.ServiceModelList; import org.onap.so.apihandlerinfra.vnfbeans.RequestStatusType; import org.onap.so.db.request.beans.InfraActiveRequests; +import org.onap.so.db.request.client.RequestsDbClient; import org.onap.so.exceptions.ValidationException; import org.onap.so.logger.MessageEnum; import org.onap.so.logger.MsoLogger; @@ -384,4 +384,4 @@ public class TenantIsolationRequest { public void setOperationalEnvironmentId(String operationalEnvironmentId) { this.operationalEnvironmentId = operationalEnvironmentId; } -}
\ No newline at end of file +} diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/TenantIsolationRunnable.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/TenantIsolationRunnable.java index 461acab96d..2427dd2734 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/TenantIsolationRunnable.java +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/TenantIsolationRunnable.java @@ -32,8 +32,6 @@ import org.onap.so.apihandlerinfra.tenantisolation.process.CreateVnfOperationalE import org.onap.so.apihandlerinfra.tenantisolation.process.DeactivateVnfOperationalEnvironment; import org.onap.so.apihandlerinfra.tenantisolationbeans.Action; import org.onap.so.apihandlerinfra.tenantisolationbeans.OperationalEnvironment; -import org.onap.so.db.request.data.repository.OperationalEnvDistributionStatusRepository; -import org.onap.so.db.request.data.repository.OperationalEnvServiceModelStatusRepository; import org.onap.so.logger.MessageEnum; import org.onap.so.logger.MsoLogger; import org.onap.so.requestsdb.RequestsDBHelper; @@ -46,7 +44,7 @@ import org.springframework.stereotype.Component; @Scope("prototype") public class TenantIsolationRunnable { - private static MsoLogger msoLogger = MsoLogger.getMsoLogger (MsoLogger.Catalog.APIH, TenantIsolationRunnable.class); + private static final MsoLogger msoLogger = MsoLogger.getMsoLogger (MsoLogger.Catalog.APIH, TenantIsolationRunnable.class); @Autowired private RequestsDBHelper requestDb; @@ -60,10 +58,6 @@ public class TenantIsolationRunnable { private DeactivateVnfOperationalEnvironment deactivateVnfOpEnv; @Autowired private ActivateVnfStatusOperationalEnvironment activateVnfStatusOpEnv; - @Autowired - private OperationalEnvDistributionStatusRepository distributionStatusRepository; - @Autowired - private OperationalEnvServiceModelStatusRepository modelStatusRepository; @Async public void run(Action action, String operationalEnvType, CloudOrchestrationRequest cor, String requestId) throws ApiException { @@ -83,11 +77,11 @@ public class TenantIsolationRunnable { throw validateException; } } else if(Action.activate.equals(action)) { - activateVnfOpEnv.execute(requestId, cor, distributionStatusRepository, modelStatusRepository); + activateVnfOpEnv.execute(requestId, cor); } else if(Action.deactivate.equals(action)) { deactivateVnfOpEnv.execute(requestId, cor); } else if(Action.distributionStatus.equals(action)) { - activateVnfStatusOpEnv.execute(requestId, cor, distributionStatusRepository, modelStatusRepository); + activateVnfStatusOpEnv.execute(requestId, cor); } else { ErrorLoggerInfo errorLoggerInfo = new ErrorLoggerInfo.Builder(MessageEnum.APIH_GENERAL_EXCEPTION, MsoLogger.ErrorCode.DataError).build(); ValidateException validateException = new ValidateException.Builder("Invalid Action specified: " + action, diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/process/ActivateVnfOperationalEnvironment.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/process/ActivateVnfOperationalEnvironment.java index 903639c8f5..ac9a000d3b 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/process/ActivateVnfOperationalEnvironment.java +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/process/ActivateVnfOperationalEnvironment.java @@ -21,13 +21,13 @@ package org.onap.so.apihandlerinfra.tenantisolation.process; import java.util.List; -import java.util.Optional; import javax.ws.rs.core.Response; import org.apache.http.HttpStatus; import org.json.JSONObject; import org.onap.so.apihandler.common.ErrorNumbers; +import org.onap.so.db.request.client.RequestsDbClient; import org.onap.so.apihandlerinfra.exceptions.ApiException; import org.onap.so.apihandlerinfra.exceptions.ValidateException; import org.onap.so.apihandlerinfra.logging.ErrorLoggerInfo; @@ -40,8 +40,6 @@ import org.onap.so.client.aai.entities.AAIResultWrapper; import org.onap.so.client.aai.objects.AAIOperationalEnvironment; import org.onap.so.db.request.beans.OperationalEnvDistributionStatus; import org.onap.so.db.request.beans.OperationalEnvServiceModelStatus; -import org.onap.so.db.request.data.repository.OperationalEnvDistributionStatusRepository; -import org.onap.so.db.request.data.repository.OperationalEnvServiceModelStatusRepository; import org.onap.so.logger.MessageEnum; import org.onap.so.logger.MsoLogger; import org.onap.so.requestsdb.RequestsDBHelper; @@ -53,7 +51,7 @@ import org.springframework.stereotype.Component; @Component public class ActivateVnfOperationalEnvironment { - private static MsoLogger msoLogger = MsoLogger.getMsoLogger(MsoLogger.Catalog.APIH, ActivateVnfOperationalEnvironment.class); + private static final MsoLogger msoLogger = MsoLogger.getMsoLogger(MsoLogger.Catalog.APIH, ActivateVnfOperationalEnvironment.class); private static final int DEFAULT_ACTIVATE_RETRY_COUNT = 3; private static final String DISTRIBUTION_STATUS_SENT = "SENT"; @@ -69,16 +67,16 @@ public class ActivateVnfOperationalEnvironment { @Value("${mso.tenant.isolation.retry.count}") private String sdcRetryCount; + @Autowired + RequestsDbClient client; + /** * The Point-Of-Entry from APIH with VID request to send activate request * @param requestId - String * @param request - CloudOrchestrationRequest object - * @param distributionStatusRepository - OperationalEnvDistributionStatusRepository object - * @param modelStatusRepository - OperationalEnvServiceModelStatusRepository object * @return void - nothing */ - public void execute(String requestId, CloudOrchestrationRequest request, OperationalEnvDistributionStatusRepository distributionStatusRepository, - OperationalEnvServiceModelStatusRepository modelStatusRepository) throws ApiException{ + public void execute(String requestId, CloudOrchestrationRequest request) throws ApiException{ String operationalEnvironmentId = request.getOperationalEnvironmentId(); String vidWorkloadContext = request.getRequestDetails().getRequestParameters().getWorkloadContext(); @@ -96,7 +94,7 @@ public class ActivateVnfOperationalEnvironment { HttpStatus.SC_BAD_REQUEST, ErrorNumbers.SVC_DETAILED_SERVICE_ERROR).errorInfo(errorLoggerInfo).build(); } - processActivateSDCRequest(requestId, operationalEnvironmentId, serviceModelVersionIdList, workloadContext, distributionStatusRepository, modelStatusRepository); + processActivateSDCRequest(requestId, operationalEnvironmentId, serviceModelVersionIdList, workloadContext); } @@ -107,13 +105,11 @@ public class ActivateVnfOperationalEnvironment { * @param operationalEnvironmentId - String * @param serviceModelVersionIdList - List<ServiceModelList> list * @param workloadContext - String - * @param distributionStatusRepository - OperationalEnvDistributionStatusRepository object - * @param modelStatusRepository - OperationalEnvServiceModelStatusRepository object * @return jsonResponse - JSONObject object */ - public void processActivateSDCRequest(String requestId, String operationalEnvironmentId, List<ServiceModelList> serviceModelVersionIdList, - String workloadContext, OperationalEnvDistributionStatusRepository distributionStatusRepository, - OperationalEnvServiceModelStatusRepository modelStatusRepository) throws ApiException { + public void processActivateSDCRequest(String requestId, String operationalEnvironmentId, + List<ServiceModelList> serviceModelVersionIdList, + String workloadContext) throws ApiException { JSONObject jsonResponse = null; int retryCount = 0; @@ -137,7 +133,7 @@ public class ActivateVnfOperationalEnvironment { recoveryAction, retryCount, workloadContext); - modelStatusRepository.save(serviceModelStatus); + client.save(serviceModelStatus); String distributionId = ""; @@ -154,7 +150,7 @@ public class ActivateVnfOperationalEnvironment { requestId, DISTRIBUTION_STATUS_SENT, ""); - distributionStatusRepository.save(distStatus); + client.save(distStatus); } else { ErrorLoggerInfo errorLoggerInfo = new ErrorLoggerInfo.Builder(MessageEnum.APIH_GENERAL_EXCEPTION, MsoLogger.ErrorCode.BusinessProcesssError).build(); diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/process/ActivateVnfStatusOperationalEnvironment.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/process/ActivateVnfStatusOperationalEnvironment.java index 6a9bec5abb..66cfd349df 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/process/ActivateVnfStatusOperationalEnvironment.java +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/process/ActivateVnfStatusOperationalEnvironment.java @@ -28,6 +28,7 @@ import javax.ws.rs.core.Response; import org.apache.http.HttpStatus; import org.json.JSONObject; import org.onap.so.apihandler.common.ErrorNumbers; +import org.onap.so.db.request.client.RequestsDbClient; import org.onap.so.apihandlerinfra.exceptions.ApiException; import org.onap.so.apihandlerinfra.exceptions.ValidateException; import org.onap.so.apihandlerinfra.logging.ErrorLoggerInfo; @@ -38,8 +39,6 @@ import org.onap.so.apihandlerinfra.tenantisolationbeans.Distribution; import org.onap.so.apihandlerinfra.tenantisolationbeans.DistributionStatus; import org.onap.so.db.request.beans.OperationalEnvDistributionStatus; import org.onap.so.db.request.beans.OperationalEnvServiceModelStatus; -import org.onap.so.db.request.data.repository.OperationalEnvDistributionStatusRepository; -import org.onap.so.db.request.data.repository.OperationalEnvServiceModelStatusRepository; import org.onap.so.logger.MessageEnum; import org.onap.so.logger.MsoLogger; import org.onap.so.requestsdb.RequestsDBHelper; @@ -72,17 +71,16 @@ public class ActivateVnfStatusOperationalEnvironment { private RequestsDBHelper requestDb; @Autowired private SDCClientHelper sdcClientHelper; + @Autowired + private RequestsDbClient client; /** * The Point-Of-Entry from APIH with activate status from SDC * @param requestId - String * @param request - CloudOrchestrationRequest - object - * @param distributionStatusRepository - OperationalEnvDistributionStatusRepository - object - * @param modelStatusRepository - OperationalEnvServiceModelStatusRepository - object * @return void - nothing */ - public void execute(String requestId, CloudOrchestrationRequest request, OperationalEnvDistributionStatusRepository distributionStatusRepository, - OperationalEnvServiceModelStatusRepository modelStatusRepository) throws ApiException { + public void execute(String requestId, CloudOrchestrationRequest request) throws ApiException { String operationalEnvironmentId = ""; @@ -91,18 +89,18 @@ public class ActivateVnfStatusOperationalEnvironment { Distribution sdcStatus = request.getDistribution(); // Distribution, Query for operationalEnvironmentId, serviceModelVersionId - this.queryDistributionDbResponse = distributionStatusRepository.findOne(sdcDistributionId); + this.queryDistributionDbResponse = client.getDistributionStatusById(sdcDistributionId); operationalEnvironmentId = this.queryDistributionDbResponse.getOperationalEnvId(); // ServiceModel, Query for dbRequestId, recoveryAction, retryCountString - this.queryServiceModelResponse = modelStatusRepository.findOneByOperationalEnvIdAndServiceModelVersionId(operationalEnvironmentId, queryDistributionDbResponse.getServiceModelVersionId()); + this.queryServiceModelResponse = client.findOneByOperationalEnvIdAndServiceModelVersionId(operationalEnvironmentId, queryDistributionDbResponse.getServiceModelVersionId()); this.origRequestId = this.queryServiceModelResponse.getRequestId(); - processActivateSDCStatus(sdcDistributionId, sdcStatus, this.queryDistributionDbResponse, this.queryServiceModelResponse, distributionStatusRepository, modelStatusRepository); + processActivateSDCStatus(sdcDistributionId, sdcStatus, this.queryDistributionDbResponse, this.queryServiceModelResponse); // After EVERY status processed, need to query the status of all service modelId // to determine the OVERALL status if "COMPLETE" or "FAILURE": - checkOrUpdateOverallStatus(operationalEnvironmentId, this.origRequestId, modelStatusRepository); + checkOrUpdateOverallStatus(operationalEnvironmentId, this.origRequestId); } @@ -112,13 +110,10 @@ public class ActivateVnfStatusOperationalEnvironment { * @param sdcStatus - Distribution object * @param queryDistributionDbResponse - OperationalEnvDistributionStatus object * @param queryServiceModelResponse - OperationalEnvServiceModelStatus object - * @param distributionStatusRepository - OperationalEnvDistributionStatusRepository object - * @param modelStatusRepository - OperationalEnvServiceModelStatusRepository object * @return void - nothing */ public void processActivateSDCStatus(String sdcDistributionId, Distribution sdcStatus, OperationalEnvDistributionStatus queryDistributionDbResponse, - OperationalEnvServiceModelStatus queryServiceModelResponse, OperationalEnvDistributionStatusRepository distributionStatusRepository, - OperationalEnvServiceModelStatusRepository modelStatusRepository) throws ApiException { + OperationalEnvServiceModelStatus queryServiceModelResponse) throws ApiException { String sdcStatusValue = sdcStatus.getStatus().toString(); String recoveryAction = queryServiceModelResponse.getRecoveryAction(); @@ -131,13 +126,13 @@ public class ActivateVnfStatusOperationalEnvironment { dbHelper.updateStatusInOperationalEnvDistributionStatus(queryDistributionDbResponse, sdcStatusValue, ""); - distributionStatusRepository.save(updateDistStatusOk); + client.save(updateDistStatusOk); // should update 1 row, update status and retryCount = 0 (ie, serviceModelVersionId is DONE!) OperationalEnvServiceModelStatus updateRetryCountZeroAndStatusOk = dbHelper.updateRetryCountAndStatusInOperationalEnvServiceModelStatus(queryServiceModelResponse, sdcStatusValue, RETRY_COUNT_ZERO); - modelStatusRepository.save(updateRetryCountZeroAndStatusOk); + client.save(updateRetryCountZeroAndStatusOk); } else { // "DISTRIBUTION_COMPLETE_ERROR", Check if recoveryAction is "RETRY" @@ -145,8 +140,7 @@ public class ActivateVnfStatusOperationalEnvironment { // RESEND / RETRY serviceModelVersionId to SDC - JSONObject jsonResponse = callSDClientForRetry(queryDistributionDbResponse, queryServiceModelResponse, sdcStatus, - distributionStatusRepository, modelStatusRepository); + JSONObject jsonResponse = callSDClientForRetry(queryDistributionDbResponse, queryServiceModelResponse, sdcStatus); } else { // either RETRY & Count = 0, or 'ABORT', or 'SKIP' @@ -168,13 +162,13 @@ public class ActivateVnfStatusOperationalEnvironment { dbHelper.updateRetryCountAndStatusInOperationalEnvServiceModelStatus(queryServiceModelResponse, modifiedStatus, RETRY_COUNT_ZERO); - modelStatusRepository.save(updateRetryCountZeroAndStatus); + client.save(updateRetryCountZeroAndStatus); // should update 1 row, modified status OperationalEnvDistributionStatus updateDistStatus = dbHelper.updateStatusInOperationalEnvDistributionStatus(queryDistributionDbResponse, modifiedStatus, errorReason); - distributionStatusRepository.save(updateDistStatus); + client.save(updateDistStatus); } else { // RETRY & Count = 0 (do nothing!) } @@ -187,15 +181,11 @@ public class ActivateVnfStatusOperationalEnvironment { * @param queryDistributionDbResponse - OperationalEnvDistributionStatus object * @param queryServiceModelResponse - OperationalEnvServiceModelStatus object * @param sdcStatus - Distribution object - * @param distributionStatusRepository - OperationalEnvDistributionStatusRepository object - * @param modelStatusRepository - OperationalEnvServiceModelStatusRepository object * @return JSONObject object */ public JSONObject callSDClientForRetry(OperationalEnvDistributionStatus queryDistributionDbResponse, OperationalEnvServiceModelStatus queryServiceModelResponse, - Distribution sdcStatus, - OperationalEnvDistributionStatusRepository distributionStatusRepository, - OperationalEnvServiceModelStatusRepository modelStatusRepository) throws ApiException { + Distribution sdcStatus) throws ApiException { JSONObject jsonResponse = null; @@ -218,7 +208,7 @@ public class ActivateVnfStatusOperationalEnvironment { originalRequestId, DISTRIBUTION_STATUS_SENT, ""); - distributionStatusRepository.save(insertNewDistributionId); + client.save(insertNewDistributionId); // update retryCount (less 1) for the serviceModelServiceId retryCount = retryCount - 1; @@ -227,14 +217,14 @@ public class ActivateVnfStatusOperationalEnvironment { dbHelper.updateRetryCountAndStatusInOperationalEnvServiceModelStatus(queryServiceModelResponse, DISTRIBUTION_STATUS_SENT, retryCount); - modelStatusRepository.save(updateRetryCountAndStatus); + client.save(updateRetryCountAndStatus); // should update 1 row, OLD distributionId set to status error (ie, old distributionId is DONE!). OperationalEnvDistributionStatus updateStatus = dbHelper.updateStatusInOperationalEnvDistributionStatus(queryDistributionDbResponse, DISTRIBUTION_STATUS_ERROR, sdcStatus.getErrorReason()); - distributionStatusRepository.save(updateStatus); + client.save(updateStatus); } else { String dbErrorMessage = "Failure calling SDC: statusCode: " + statusCode + "; messageId: " + jsonResponse.get("messageId") + @@ -255,12 +245,11 @@ public class ActivateVnfStatusOperationalEnvironment { * The Method to check the overall status of the Activation for an operationalEnvironmentId * @param operationalEnvironmentId - string * @param origRequestId - string - * @param modelStatusRepository - OperationalEnvServiceModelStatusRepository object * @return void - nothing */ - public void checkOrUpdateOverallStatus(String operationalEnvironmentId, String origRequestId, OperationalEnvServiceModelStatusRepository modelStatusRepository) throws ApiException{ + public void checkOrUpdateOverallStatus(String operationalEnvironmentId, String origRequestId) throws ApiException{ - List<OperationalEnvServiceModelStatus> queryServiceModelResponseList = modelStatusRepository.findAllByOperationalEnvIdAndRequestId(operationalEnvironmentId, origRequestId); + List<OperationalEnvServiceModelStatus> queryServiceModelResponseList = client.getAllByOperationalEnvIdAndRequestId(operationalEnvironmentId, origRequestId); String status = "Waiting"; int count = 0; diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/process/CreateEcompOperationalEnvironment.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/process/CreateEcompOperationalEnvironment.java index c16f7bb9ef..b09bbae0ad 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/process/CreateEcompOperationalEnvironment.java +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/process/CreateEcompOperationalEnvironment.java @@ -76,8 +76,8 @@ public class CreateEcompOperationalEnvironment { requestDb.updateInfraFailureCompletion(e.getMessage(), requestId, request.getOperationalEnvironmentId()); throw validateException; } - //Update request database - requestDb.updateInfraSuccessCompletion("SUCCESSFULLY Created ECOMP OperationalEnvironment.", requestId, request.getOperationalEnvironmentId()); + //Update request database + requestDb.updateInfraSuccessCompletion("SUCCESSFULLY Created ECOMP OperationalEnvironment.", requestId, request.getOperationalEnvironmentId()); } } diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/validation/CloudConfigurationValidation.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/validation/CloudConfigurationValidation.java index f366c7e74b..b0ea85779c 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/validation/CloudConfigurationValidation.java +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/validation/CloudConfigurationValidation.java @@ -56,6 +56,9 @@ public class CloudConfigurationValidation implements ValidationRule{ if(requestScope.equalsIgnoreCase(ModelType.vfModule.name()) && (action == Action.deactivateAndCloudDelete || action == Action.scaleOut)){ throw new ValidationException("cloudConfiguration"); } + if(requestScope.equals(ModelType.vnf.name()) && action == Action.recreateInstance){ + throw new ValidationException("cloudConfiguration", true); + } } if (cloudConfiguration == null && ((aLaCarteFlag != null && !aLaCarteFlag) && requestScope.equalsIgnoreCase (ModelType.service.name ()) && reqVersion < 5)) { diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/validation/ConfigurationParametersValidation.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/validation/ConfigurationParametersValidation.java index edd1b1a10e..8fdb43f20c 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/validation/ConfigurationParametersValidation.java +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/validation/ConfigurationParametersValidation.java @@ -41,7 +41,7 @@ public class ConfigurationParametersValidation implements ValidationRule{ String requestScope = info.getRequestScope(); Actions action = info.getAction(); - if(requestScope.equalsIgnoreCase(ModelType.vfModule.name()) && action == Action.scaleOut && configParams.isEmpty()){ + if(configParams.isEmpty() && requestScope.equalsIgnoreCase(ModelType.vfModule.name()) && action == Action.scaleOut){ throw new ValidationException("configuration parameters"); } return info; diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/validation/ModelInfoValidation.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/validation/ModelInfoValidation.java index aa98d2abf2..c6fae6e872 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/validation/ModelInfoValidation.java +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/validation/ModelInfoValidation.java @@ -60,7 +60,7 @@ public class ModelInfoValidation implements ValidationRule{ } // modelCustomizationId or modelCustomizationName are required for VNF Replace - if(requestParameters != null && reqVersion > 4 && requestScope.equalsIgnoreCase(ModelType.vnf.name()) && action == Action.replaceInstance) { + if(requestParameters != null && reqVersion > 4 && requestScope.equalsIgnoreCase(ModelType.vnf.name()) && action == Action.replaceInstance || action == Action.recreateInstance) { if(!UUIDChecker.isValidUUID(modelInfo.getModelCustomizationId()) && modelInfo.getModelCustomizationName() == null) { throw new ValidationException("modelCustomizationId or modelCustomizationName"); } @@ -77,14 +77,16 @@ public class ModelInfoValidation implements ValidationRule{ if(empty(modelInfo.getModelInvariantId()) && (requestScope.equalsIgnoreCase(ModelType.vfModule.name()) && action == Action.scaleOut)){ throw new ValidationException("modelInvariantId"); } - + if(empty(modelInfo.getModelInvariantId()) && (requestScope.equalsIgnoreCase(ModelType.vnf.name()) && action == Action.recreateInstance)){ + throw new ValidationException("modelInvariantId", true); + } if (!empty (modelInfo.getModelInvariantId ()) && !UUIDChecker.isValidUUID (modelInfo.getModelInvariantId ())) { throw new ValidationException ("modelInvariantId format"); } if(reqVersion >= 4 && !(requestScope.equalsIgnoreCase(ModelType.configuration.name())) && empty (modelInfo.getModelName ()) && (action == Action.createInstance || action == Action.updateInstance || - action == Action.addRelationships || action == Action.removeRelationships || ((action == Action.deleteInstance || action == Action.scaleOut) && (requestScope.equalsIgnoreCase (ModelType.vfModule.name ()))))){ - throw new ValidationException ("modelName"); + action == Action.addRelationships || action == Action.removeRelationships || action == Action.recreateInstance || ((action == Action.deleteInstance || action == Action.scaleOut) && (requestScope.equalsIgnoreCase (ModelType.vfModule.name ()))))){ + throw new ValidationException ("modelName", true); } if (empty (modelInfo.getModelVersion ()) && !(requestScope.equalsIgnoreCase(ModelType.configuration.name())) && @@ -92,6 +94,10 @@ public class ModelInfoValidation implements ValidationRule{ && (action == Action.createInstance || action == Action.updateInstance || action == Action.addRelationships || action == Action.removeRelationships || action == Action.scaleOut))) { throw new ValidationException ("modelVersion"); } + + if(empty(modelInfo.getModelVersion()) && (requestScope.equalsIgnoreCase(ModelType.vnf.name()) && action == Action.recreateInstance)){ + throw new ValidationException("modelVersion", true); + } // is required for serviceInstance delete macro when aLaCarte=false in v4 if (reqVersion >= 4 && empty (modelInfo.getModelVersionId()) && (((aLaCarteFlag != null && !aLaCarteFlag) && requestScope.equalsIgnoreCase(ModelType.service.name()) && action == Action.deleteInstance) || @@ -99,6 +105,9 @@ public class ModelInfoValidation implements ValidationRule{ (requestScope.equalsIgnoreCase(ModelType.configuration.name()) && (action == Action.activateInstance || action == Action.deactivateInstance))))) { throw new ValidationException ("modelVersionId"); } + if(empty(modelInfo.getModelVersionId()) && (requestScope.equalsIgnoreCase(ModelType.vnf.name()) && action == Action.recreateInstance)){ + throw new ValidationException("modelVersionId", true); + } if(empty(modelInfo.getModelVersionId()) && (requestScope.equalsIgnoreCase(ModelType.vfModule.name()) && action == Action.scaleOut)){ throw new ValidationException("modelVersionId"); } |