diff options
author | Benjamin, Max (mb388a) <mb388a@us.att.com> | 2018-08-24 09:23:29 -0400 |
---|---|---|
committer | Benjamin, Max (mb388a) <mb388a@us.att.com> | 2018-08-24 09:23:40 -0400 |
commit | 22c813992a18915f8874976d371ffb55d63930bf (patch) | |
tree | eb0c01a1f54208c6537848f14bcf71a0363f2053 /mso-api-handlers/mso-api-handler-infra/src/main/java/org | |
parent | 969cde43a1c52fc5a0131cd94713a3c4ba3d1564 (diff) |
request db access converted to rest
[MSO-5031]_updated_JUnits_to_assert_request_body_for_requestDb_client
Marking JPARepositories as Remote Rest repositories for
TenantIsolationRunnable class | Minor refactoring
Add request DB Config to ATT specific ASDC controller test yaml
Adding requestDB Endpoint to yaml so as to pass the tests of asdc
controller
Adding requestDB Endpoint to yaml so as to pass the tests
Adding requestDB Endpoint to yaml so as to pass the tests
Handling the build failure due to mock mismatch
Handling the build failure due to conflicting beans and additional
minor refactoring
Handling the build failure due to conflicting beans
Adding RequestDB endpoint to yaml files for running tests
Removing non-entity classes from ClassURLMapper class
Marking JPARepositories as Remote Rest repositories for
TenantIsolationRunnable class | Fixing minor Bug
Marking JPARepositories as Remote Rest repositories for
TenantIsolationRunnable class | Fixing junits
Marking JPARepositories as Remote Rest repositories for
TenantIsolationRunnable class | Fixing
getMultipleOperationalEnvServiceModelStatus
Marking JPARepositories as Remote Rest repositories for
TenantIsolationRunnable class | Fixing Junits
Marking JPARepositories as Remote Rest repositories for RequestsDBHelper
Marking JPARepositories as Remote Rest repositories for
TenantIsolationRunnable class | Moving RequestsDbClient to requestdb
package
Marking JPARepositories as Remote Rest repositories for
TenantIsolationRunnable class | Fixing Junits
Marking JPARepositories as Remote Rest repositories for
TenantIsolationRunnable class | Initial Checkin
Change-Id: I4053919e98afb8db962511be0a3318b1bf8af88a
Issue-ID: SO-903
Signed-off-by: Benjamin, Max (mb388a) <mb388a@us.att.com>
Diffstat (limited to 'mso-api-handlers/mso-api-handler-infra/src/main/java/org')
10 files changed, 41 insertions, 237 deletions
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 923909e39b..8f8cf0898d 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 @@ -61,6 +61,7 @@ import org.onap.so.db.request.beans.OperationStatus; import org.onap.so.logger.MessageEnum; import org.onap.so.logger.MsoAlarmLogger; import org.onap.so.logger.MsoLogger; +import org.onap.so.requestsdb.client.RequestsDbClient; import org.onap.so.serviceinstancebeans.ModelInfo; import org.onap.so.serviceinstancebeans.ModelType; import org.onap.so.serviceinstancebeans.RequestDetails; 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..1a1b45ac8e 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,10 +62,10 @@ 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.data.repository.InfraActiveRequestsRepository; import org.onap.so.exceptions.ValidationException; import org.onap.so.logger.MessageEnum; import org.onap.so.logger.MsoLogger; +import org.onap.so.requestsdb.client.RequestsDbClient; import org.onap.so.serviceinstancebeans.CloudConfiguration; import org.onap.so.serviceinstancebeans.InstanceDirection; import org.onap.so.serviceinstancebeans.ModelInfo; 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..753b4c48d4 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 @@ -52,6 +52,7 @@ import org.onap.so.exceptions.ValidationException; import org.onap.so.logger.MessageEnum; import org.onap.so.logger.MsoAlarmLogger; import org.onap.so.logger.MsoLogger; +import org.onap.so.requestsdb.client.RequestsDbClient; import org.onap.so.serviceinstancebeans.GetOrchestrationListResponse; import org.onap.so.serviceinstancebeans.GetOrchestrationResponse; import org.onap.so.serviceinstancebeans.InstanceReferences; 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/tenantisolation/CloudOrchestration.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/CloudOrchestration.java index 910b9f70cb..cfe32a3833 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,7 @@ 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.requestsdb.client.RequestsDbClient; import org.onap.so.apihandlerinfra.Status; import org.onap.so.apihandlerinfra.exceptions.ApiException; import org.onap.so.apihandlerinfra.exceptions.DuplicateRequestException; @@ -51,7 +51,6 @@ 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.exceptions.ValidationException; import org.onap.so.logger.MessageEnum; import org.onap.so.logger.MsoLogger; 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 a14554c8a1..3b7a326f3e 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 @@ -44,7 +44,7 @@ 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.requestsdb.client.RequestsDbClient; import org.onap.so.apihandlerinfra.exceptions.ApiException; import org.onap.so.apihandlerinfra.exceptions.ValidateException; import org.onap.so.apihandlerinfra.logging.AlarmLoggerInfo; 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..b13008b3d3 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,7 @@ 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.requestsdb.client.RequestsDbClient; import org.onap.so.apihandlerinfra.Status; import org.onap.so.apihandlerinfra.tenantisolationbeans.Action; import org.onap.so.apihandlerinfra.tenantisolationbeans.Manifest; 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..e89b5c8d42 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.requestsdb.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..6eb5157568 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.requestsdb.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; |