diff options
author | romaingimbert <romain.gimbert@orange.com> | 2018-05-04 13:55:38 +0200 |
---|---|---|
committer | romaingimbert <romain.gimbert@orange.com> | 2018-05-04 13:59:14 +0200 |
commit | f73c501dc6347ea78ff9da629e02200db1dd7297 (patch) | |
tree | b894cf206e4ed8d092fdb92909c593ecfc11ee2d /src/main | |
parent | 10684b3740dfd38323f617ef2046695e09dbcd30 (diff) |
Sonar clean code
- fix log messages
- fix 2 sonar bugs
- replace LinkedHashMap by Map
Change-Id: I0b7953f09ffa706b5357ac45c7c4290a56bba236
Issue-ID: EXTAPI-81
Signed-off-by: romaingimbert <romain.gimbert@orange.com>
Diffstat (limited to 'src/main')
18 files changed, 91 insertions, 79 deletions
diff --git a/src/main/java/org/onap/nbi/apis/servicecatalog/SdcClient.java b/src/main/java/org/onap/nbi/apis/servicecatalog/SdcClient.java index e190cf0..109edbe 100644 --- a/src/main/java/org/onap/nbi/apis/servicecatalog/SdcClient.java +++ b/src/main/java/org/onap/nbi/apis/servicecatalog/SdcClient.java @@ -63,7 +63,7 @@ public class SdcClient { private static final Logger LOGGER = LoggerFactory.getLogger(SdcClient.class); - public LinkedHashMap callGet(String id) { + public Map callGet(String id) { StringBuilder urlBuilder = new StringBuilder().append(sdcHost).append(OnapComponentsUrlPaths.SDC_ROOT_URL) .append("/").append(id).append(OnapComponentsUrlPaths.SDC_GET_PATH); @@ -140,8 +140,7 @@ public class SdcClient { restTemplate.exchange(callURI, HttpMethod.GET, buildRequestHeader(), byte[].class); LOGGER.info("response status : " + response.getStatusCodeValue()); if (!response.getStatusCode().equals(HttpStatus.OK)) { - LOGGER.error(HTTP_CALL_SDC_ON + callURI.toString() + " returns " + response.getStatusCodeValue() + ", " - + response.getBody().toString()); + LOGGER.warn(HTTP_CALL_SDC_ON + callURI.toString() + " returns " + response.getStatusCodeValue() + ", "); } return response; diff --git a/src/main/java/org/onap/nbi/apis/servicecatalog/ServiceSpecificationResource.java b/src/main/java/org/onap/nbi/apis/servicecatalog/ServiceSpecificationResource.java index 2d1b35f..262871a 100644 --- a/src/main/java/org/onap/nbi/apis/servicecatalog/ServiceSpecificationResource.java +++ b/src/main/java/org/onap/nbi/apis/servicecatalog/ServiceSpecificationResource.java @@ -17,6 +17,7 @@ package org.onap.nbi.apis.servicecatalog; import java.util.LinkedHashMap; import java.util.List; +import java.util.Map; import org.onap.nbi.commons.JsonRepresentation; import org.onap.nbi.commons.Resource; import org.onap.nbi.commons.ResourceManagement; @@ -41,7 +42,7 @@ public class ServiceSpecificationResource extends ResourceManagement<Resource> { @GetMapping(value = "/{serviceSpecId}", produces = MediaType.APPLICATION_JSON_VALUE) public ResponseEntity<Object> getServiceSpecification(@PathVariable String serviceSpecId, @RequestParam MultiValueMap<String, String> params) { - LinkedHashMap response = serviceSpecificationService.get(serviceSpecId); + Map response = serviceSpecificationService.get(serviceSpecId); JsonRepresentation filter = new JsonRepresentation(params); if (response.get("serviceSpecCharacteristic") != null) { return this.getResponse(response, filter); diff --git a/src/main/java/org/onap/nbi/apis/servicecatalog/ServiceSpecificationService.java b/src/main/java/org/onap/nbi/apis/servicecatalog/ServiceSpecificationService.java index f34f965..bec7575 100644 --- a/src/main/java/org/onap/nbi/apis/servicecatalog/ServiceSpecificationService.java +++ b/src/main/java/org/onap/nbi/apis/servicecatalog/ServiceSpecificationService.java @@ -18,6 +18,7 @@ package org.onap.nbi.apis.servicecatalog; import java.util.ArrayList; import java.util.LinkedHashMap; import java.util.List; +import java.util.Map; import org.apache.commons.collections.CollectionUtils; import org.onap.nbi.apis.servicecatalog.jolt.FindServiceSpecJsonTransformer; import org.onap.nbi.apis.servicecatalog.jolt.GetServiceSpecJsonTransformer; @@ -45,10 +46,10 @@ public class ServiceSpecificationService { private static final Logger LOGGER = LoggerFactory.getLogger(ServiceSpecificationService.class); - public LinkedHashMap get(String serviceSpecId) { - LinkedHashMap sdcResponse = sdcClient.callGet(serviceSpecId); + public Map get(String serviceSpecId) { + Map sdcResponse = sdcClient.callGet(serviceSpecId); LinkedHashMap serviceCatalogResponse = (LinkedHashMap) getServiceSpecJsonTransformer.transform(sdcResponse); - LinkedHashMap toscaInfosTopologyTemplate = toscaInfosProcessor.getToscaInfos(serviceCatalogResponse); + Map toscaInfosTopologyTemplate = toscaInfosProcessor.getToscaInfos(serviceCatalogResponse); if (toscaInfosTopologyTemplate != null) { LOGGER.debug("tosca file found, retrieving informations"); toscaInfosProcessor.buildResponseWithToscaInfos(toscaInfosTopologyTemplate, serviceCatalogResponse); diff --git a/src/main/java/org/onap/nbi/apis/servicecatalog/ToscaInfosProcessor.java b/src/main/java/org/onap/nbi/apis/servicecatalog/ToscaInfosProcessor.java index 0503e34..b76e697 100644 --- a/src/main/java/org/onap/nbi/apis/servicecatalog/ToscaInfosProcessor.java +++ b/src/main/java/org/onap/nbi/apis/servicecatalog/ToscaInfosProcessor.java @@ -46,8 +46,8 @@ public class ToscaInfosProcessor { private static final Logger LOGGER = LoggerFactory.getLogger(ToscaInfosProcessor.class); - public void buildResponseWithToscaInfos(LinkedHashMap toscaInfosTopologyTemplate, - LinkedHashMap serviceCatalogResponse) { + public void buildResponseWithToscaInfos(Map toscaInfosTopologyTemplate, + Map serviceCatalogResponse) { if (toscaInfosTopologyTemplate.get("inputs") != null) { ArrayList serviceSpecCharacteristic = new ArrayList(); LinkedHashMap toscaInfos = (LinkedHashMap) toscaInfosTopologyTemplate.get("inputs"); @@ -80,7 +80,7 @@ public class ToscaInfosProcessor { for (LinkedHashMap resourceSpecification : resourceSpecifications) { if(resourceSpecification.get("id")!=null){ String id = (String) resourceSpecification.get("id"); - LOGGER.debug("get tosca infos for service id: {0}", id); + LOGGER.debug("get tosca infos for service id: {}", id); LinkedHashMap toscaInfosFromResourceId = getToscaInfosFromResourceUUID(nodeTemplate, id); if (toscaInfosFromResourceId != null && toscaInfosFromResourceId.get("customizationUUID")!=null) { resourceSpecification.put("modelCustomizationId", toscaInfosFromResourceId.get("customizationUUID")); @@ -92,7 +92,7 @@ public class ToscaInfosProcessor { private List<LinkedHashMap> buildServiceSpecCharacteristicsValues(LinkedHashMap parameter, String parameterType) { List<LinkedHashMap> serviceSpecCharacteristicValues = new ArrayList<>(); if (!"map".equalsIgnoreCase(parameterType) && !"list".equalsIgnoreCase(parameterType)) { - LOGGER.debug("get tosca infos for serviceSpecCharacteristicValues of type map or string : {0}", parameter); + LOGGER.debug("get tosca infos for serviceSpecCharacteristicValues of type map or string : {}", parameter); Object aDefault = parameter.get("default"); if (parameter.get("entry_schema") != null) { ArrayList entrySchema = (ArrayList) parameter.get("entry_schema"); @@ -147,7 +147,7 @@ public class ToscaInfosProcessor { } - public LinkedHashMap getToscaInfos(LinkedHashMap sdcResponse) { + public Map getToscaInfos(Map sdcResponse) { LinkedHashMap topologyTemplate = null; diff --git a/src/main/java/org/onap/nbi/apis/serviceinventory/AaiClient.java b/src/main/java/org/onap/nbi/apis/serviceinventory/AaiClient.java index 273e287..5cd4c35 100644 --- a/src/main/java/org/onap/nbi/apis/serviceinventory/AaiClient.java +++ b/src/main/java/org/onap/nbi/apis/serviceinventory/AaiClient.java @@ -16,6 +16,7 @@ package org.onap.nbi.apis.serviceinventory; import java.util.LinkedHashMap; +import java.util.Map; import org.onap.nbi.OnapComponentsUrlPaths; import org.onap.nbi.exceptions.BackendFunctionalException; import org.slf4j.Logger; @@ -55,7 +56,7 @@ public class AaiClient extends BaseClient { } - public LinkedHashMap getCatalogService(String customerId, String serviceSpecName, String serviceId) { + public Map getCatalogService(String customerId, String serviceSpecName, String serviceId) { StringBuilder callURL = new StringBuilder().append(aaiHost).append(OnapComponentsUrlPaths.AAI_GET_SERVICE_FOR_CUSTOMER_PATH); @@ -71,7 +72,7 @@ public class AaiClient extends BaseClient { } - public LinkedHashMap getVNF(String relatedLink) { + public Map getVNF(String relatedLink) { StringBuilder callURL = new StringBuilder().append(aaiHost).append(relatedLink); @@ -80,7 +81,7 @@ public class AaiClient extends BaseClient { } - public LinkedHashMap getServicesInAaiForCustomer(String customerId) { + public Map getServicesInAaiForCustomer(String customerId) { StringBuilder callURL = new StringBuilder().append(aaiHost).append(OnapComponentsUrlPaths.AAI_GET_SERVICES_FOR_CUSTOMER_PATH); String callUrlFormated = callURL.toString().replace(CUSTOMER_ID, customerId); @@ -88,12 +89,12 @@ public class AaiClient extends BaseClient { ResponseEntity<Object> response = callApiGet(callUrlFormated, buildRequestHeaderForAAI()); return (LinkedHashMap) response.getBody(); } catch (BackendFunctionalException e) { - LOGGER.error("error on calling {0} , {1}" , callUrlFormated, e); + LOGGER.error("error on calling {} , {}" , callUrlFormated, e); return null; } } - public LinkedHashMap getServiceInstancesInAaiForCustomer(String customerId, String serviceType) { + public Map getServiceInstancesInAaiForCustomer(String customerId, String serviceType) { StringBuilder callURL = new StringBuilder().append(aaiHost).append(OnapComponentsUrlPaths.AAI_GET_SERVICE_INSTANCES_PATH); String callUrlFormated = callURL.toString().replace(CUSTOMER_ID, customerId); @@ -103,7 +104,7 @@ public class AaiClient extends BaseClient { ResponseEntity<Object> response = callApiGet(callUrlFormated, buildRequestHeaderForAAI()); return (LinkedHashMap) response.getBody(); } catch (BackendFunctionalException e) { - LOGGER.error("error on calling {0} , {1}" , callUrlFormated, e); + LOGGER.error("error on calling {} , {}" , callUrlFormated, e); return null; } } diff --git a/src/main/java/org/onap/nbi/apis/serviceinventory/BaseClient.java b/src/main/java/org/onap/nbi/apis/serviceinventory/BaseClient.java index 33baa5b..c973f32 100644 --- a/src/main/java/org/onap/nbi/apis/serviceinventory/BaseClient.java +++ b/src/main/java/org/onap/nbi/apis/serviceinventory/BaseClient.java @@ -39,7 +39,7 @@ public abstract class BaseClient { LOGGER.debug("response body : " + response.getBody().toString()); LOGGER.info("response status : " + response.getStatusCodeValue()); if (!response.getStatusCode().equals(HttpStatus.OK)) { - LOGGER.error("HTTP call on " + callURL + " returns " + response.getStatusCodeValue() + ", " + LOGGER.warn("HTTP call on " + callURL + " returns " + response.getStatusCodeValue() + ", " + response.getBody().toString()); } return response; diff --git a/src/main/java/org/onap/nbi/apis/serviceinventory/NbiClient.java b/src/main/java/org/onap/nbi/apis/serviceinventory/NbiClient.java index 509bb7f..7da073d 100644 --- a/src/main/java/org/onap/nbi/apis/serviceinventory/NbiClient.java +++ b/src/main/java/org/onap/nbi/apis/serviceinventory/NbiClient.java @@ -16,6 +16,7 @@ package org.onap.nbi.apis.serviceinventory; import java.util.LinkedHashMap; +import java.util.Map; import org.springframework.beans.factory.annotation.Value; import org.springframework.http.HttpHeaders; import org.springframework.http.ResponseEntity; @@ -27,7 +28,7 @@ public class NbiClient extends BaseClient { @Value("${nbi.url}") private String nbiUrl; - public LinkedHashMap getServiceSpecification(String id) { + public Map getServiceSpecification(String id) { StringBuilder callURL = new StringBuilder().append(nbiUrl).append("/serviceSpecification/").append(id); ResponseEntity<Object> response = callApiGet(callURL.toString(), new HttpHeaders()); return (LinkedHashMap) response.getBody(); diff --git a/src/main/java/org/onap/nbi/apis/serviceinventory/ServiceInventoryResource.java b/src/main/java/org/onap/nbi/apis/serviceinventory/ServiceInventoryResource.java index 26c9d98..cd46d74 100644 --- a/src/main/java/org/onap/nbi/apis/serviceinventory/ServiceInventoryResource.java +++ b/src/main/java/org/onap/nbi/apis/serviceinventory/ServiceInventoryResource.java @@ -17,6 +17,7 @@ package org.onap.nbi.apis.serviceinventory; import java.util.LinkedHashMap; import java.util.List; +import java.util.Map; import org.onap.nbi.commons.JsonRepresentation; import org.onap.nbi.commons.ResourceManagement; import org.springframework.beans.factory.annotation.Autowired; @@ -40,7 +41,7 @@ public class ServiceInventoryResource extends ResourceManagement { public ResponseEntity<Object> getServiceInventory(@PathVariable String serviceId, @RequestParam MultiValueMap<String, String> params) { - LinkedHashMap response = serviceInventoryService.get(serviceId, params); + Map response = serviceInventoryService.get(serviceId, params); JsonRepresentation filter = new JsonRepresentation(params); return this.getResponse(response, filter); diff --git a/src/main/java/org/onap/nbi/apis/serviceinventory/ServiceInventoryService.java b/src/main/java/org/onap/nbi/apis/serviceinventory/ServiceInventoryService.java index df7ab74..393236f 100644 --- a/src/main/java/org/onap/nbi/apis/serviceinventory/ServiceInventoryService.java +++ b/src/main/java/org/onap/nbi/apis/serviceinventory/ServiceInventoryService.java @@ -15,10 +15,13 @@ package org.onap.nbi.apis.serviceinventory; import java.util.ArrayList; import java.util.LinkedHashMap; import java.util.List; +import java.util.Map; import org.apache.commons.collections.CollectionUtils; import org.onap.nbi.apis.serviceinventory.jolt.FindServiceInventoryJsonTransformer; import org.onap.nbi.apis.serviceinventory.jolt.GetServiceInventoryJsonTransformer; import org.onap.nbi.exceptions.BackendFunctionalException; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.HttpStatus; import org.springframework.stereotype.Service; @@ -40,7 +43,10 @@ public class ServiceInventoryService { @Autowired FindServiceInventoryJsonTransformer findServiceInventoryJsonTransformer; - public LinkedHashMap get(String serviceId, MultiValueMap<String, String> params) { + private static final Logger LOGGER = LoggerFactory.getLogger(ServiceInventoryService.class); + + + public Map get(String serviceId, MultiValueMap<String, String> params) { String clientId = params.getFirst("relatedParty.id"); String serviceSpecId = params.getFirst("serviceSpecification.id"); @@ -53,7 +59,7 @@ public class ServiceInventoryService { String customerId = getCustomerId(clientId); String serviceName = getServiceName(serviceSpecName, serviceSpecId); - LinkedHashMap serviceResponse = aaiClient.getCatalogService(customerId, serviceName, serviceId); + Map serviceResponse = aaiClient.getCatalogService(customerId, serviceName, serviceId); if (serviceResponse != null) { addVnfsToResponse(serviceResponse); @@ -81,7 +87,7 @@ public class ServiceInventoryService { private String getServiceName(String serviceSpecificationName, String serviceSpecificationId) { if (StringUtils.isEmpty(serviceSpecificationName)) { - LinkedHashMap serviceSpecification = nbiClient.getServiceSpecification(serviceSpecificationId); + Map serviceSpecification = nbiClient.getServiceSpecification(serviceSpecificationId); return (String) serviceSpecification.get("name"); } else { return serviceSpecificationName; @@ -96,16 +102,16 @@ public class ServiceInventoryService { } - private void addVnfsToResponse(LinkedHashMap serviceResponse) { + private void addVnfsToResponse(Map serviceResponse) { - List<LinkedHashMap> vnfs = new ArrayList<>(); + List<Map> vnfs = new ArrayList<>(); LinkedHashMap relationShip = (LinkedHashMap) serviceResponse.get("relationship-list"); if (relationShip != null) { List<LinkedHashMap> relationsList = (List<LinkedHashMap>) relationShip.get("relationship"); if (relationsList != null) { for (LinkedHashMap relation : relationsList) { String relatedLink = (String) relation.get("related-link"); - LinkedHashMap vnf = aaiClient.getVNF(relatedLink); + Map vnf = aaiClient.getVNF(relatedLink); if (vnf != null) { vnfs.add(vnf); } @@ -138,6 +144,8 @@ public class ServiceInventoryService { LinkedHashMap party = (LinkedHashMap) serviceInventory.get("relatedParty"); party.put("id", customerId); } + }else { + LOGGER.warn("no service instance found for customer {} ",customerId); } return serviceInventoryResponse; @@ -145,7 +153,7 @@ public class ServiceInventoryService { } private void handleFindWithNoServiceParam(String customerId, List<LinkedHashMap> serviceInstances) { - LinkedHashMap servicesInAaiForCustomer = aaiClient.getServicesInAaiForCustomer(customerId); + Map servicesInAaiForCustomer = aaiClient.getServicesInAaiForCustomer(customerId); if(servicesInAaiForCustomer!=null){ List<LinkedHashMap> servicesInAAI = (List<LinkedHashMap>) servicesInAaiForCustomer.get("service-subscription"); @@ -153,12 +161,14 @@ public class ServiceInventoryService { String serviceType = (String) service.get("service-type"); buildServiceInstances(serviceInstances, customerId, serviceType); } + }else { + LOGGER.warn("no service instance found for customer {} ",customerId); } } private void buildServiceInstances(List<LinkedHashMap> serviceInstances, String customerId, String serviceType) { - LinkedHashMap serviceInstancesInAaiForCustomer = + Map serviceInstancesInAaiForCustomer = aaiClient.getServiceInstancesInAaiForCustomer(customerId, serviceType); if (serviceInstancesInAaiForCustomer != null) { List<LinkedHashMap> serviceInstancesForServiceType = @@ -170,7 +180,11 @@ public class ServiceInventoryService { serviceInstanceForServiceType.put("service-type", serviceType); } serviceInstances.addAll(serviceInstancesForServiceType); + } else { + LOGGER.warn("no service instance found for customer {} and service type {}",customerId,serviceType); } + } else { + LOGGER.warn("no service instance found for customer {} and service type {}",customerId,serviceType); } diff --git a/src/main/java/org/onap/nbi/apis/serviceorder/MultiClient.java b/src/main/java/org/onap/nbi/apis/serviceorder/MultiClient.java index 9b777d8..a09587c 100644 --- a/src/main/java/org/onap/nbi/apis/serviceorder/MultiClient.java +++ b/src/main/java/org/onap/nbi/apis/serviceorder/MultiClient.java @@ -144,7 +144,7 @@ public class MultiClient { } - public LinkedHashMap getServicesInAaiForCustomer(String customerId) { + public Map getServicesInAaiForCustomer(String customerId) { StringBuilder callURL = new StringBuilder().append(aaiHost).append(OnapComponentsUrlPaths.AAI_GET_SERVICES_FOR_CUSTOMER_PATH); String callUrlFormated = callURL.toString().replace("$customerId", customerId); @@ -204,7 +204,7 @@ public class MultiClient { LOGGER.debug("response body : " + response.getBody().toString()); LOGGER.info("response status : " + response.getStatusCodeValue()); if (!response.getStatusCode().equals(HttpStatus.OK)) { - LOGGER.error("HTTP call on " + callURL + " returns " + response.getStatusCodeValue() + ", " + LOGGER.warn("HTTP call on " + callURL + " returns " + response.getStatusCodeValue() + ", " + response.getBody().toString()); } return response; diff --git a/src/main/java/org/onap/nbi/apis/serviceorder/MultiCriteriaRequestBuilder.java b/src/main/java/org/onap/nbi/apis/serviceorder/MultiCriteriaRequestBuilder.java index 635be7c..4a5ad92 100644 --- a/src/main/java/org/onap/nbi/apis/serviceorder/MultiCriteriaRequestBuilder.java +++ b/src/main/java/org/onap/nbi/apis/serviceorder/MultiCriteriaRequestBuilder.java @@ -42,21 +42,21 @@ public class MultiCriteriaRequestBuilder { List<String> externalIds = params.get("externalId"); if (!CollectionUtils.isEmpty(externalIds)) { String externalId = externalIds.get(0); - LOGGER.debug("add criterion externalId {0}", externalId); + LOGGER.debug("add criterion externalId {}", externalId); query.addCriteria(Criteria.where("externalId").is(externalId)); } List<String> states = params.get("state"); if (!CollectionUtils.isEmpty(states)) { String state = states.get(0); - LOGGER.debug("add criterion state {0}", state); + LOGGER.debug("add criterion state {}", state); query.addCriteria(Criteria.where("state").is(StateType.fromValue(state))); } List<String> descriptions = params.get("description"); if (!CollectionUtils.isEmpty(descriptions)) { String description = descriptions.get(0); - LOGGER.debug("add criterion description {0}", description); + LOGGER.debug("add criterion description {}", description); query.addCriteria(Criteria.where("description").is(description)); } @@ -76,12 +76,12 @@ public class MultiCriteriaRequestBuilder { if (!CollectionUtils.isEmpty(orderDateLts)) { String orderDateLt = orderDateLts.get(0); - LOGGER.debug("add criterion orderDate.lt {0}", orderDateLt); + LOGGER.debug("add criterion orderDate.lt {}", orderDateLt); orderDateCriteria.lt(convertDate(orderDateLt)); } if (!CollectionUtils.isEmpty(orderDateGts)) { String orderDateGt = orderDateGts.get(0); - LOGGER.debug("add criterion orderDate.gt {0}", orderDateGt); + LOGGER.debug("add criterion orderDate.gt {}", orderDateGt); orderDateCriteria.gt(convertDate(orderDateGt)); } query.addCriteria(orderDateCriteria); diff --git a/src/main/java/org/onap/nbi/apis/serviceorder/model/orchestrator/ServiceOrderItemInfo.java b/src/main/java/org/onap/nbi/apis/serviceorder/model/orchestrator/ServiceOrderItemInfo.java index a6f3c84..71f36a6 100644 --- a/src/main/java/org/onap/nbi/apis/serviceorder/model/orchestrator/ServiceOrderItemInfo.java +++ b/src/main/java/org/onap/nbi/apis/serviceorder/model/orchestrator/ServiceOrderItemInfo.java @@ -16,13 +16,13 @@ package org.onap.nbi.apis.serviceorder.model.orchestrator; -import java.util.LinkedHashMap; +import java.util.Map; public class ServiceOrderItemInfo { private String id; - private LinkedHashMap catalogResponse; + private Map catalogResponse; public String getId() { return id; @@ -32,11 +32,11 @@ public class ServiceOrderItemInfo { this.id = id; } - public LinkedHashMap getCatalogResponse() { + public Map getCatalogResponse() { return catalogResponse; } - public void setCatalogResponse(LinkedHashMap catalogResponse) { + public void setCatalogResponse(Map catalogResponse) { this.catalogResponse = catalogResponse; } } diff --git a/src/main/java/org/onap/nbi/apis/serviceorder/workflow/CheckOrderConsistenceManager.java b/src/main/java/org/onap/nbi/apis/serviceorder/workflow/CheckOrderConsistenceManager.java index b3179c5..580a606 100644 --- a/src/main/java/org/onap/nbi/apis/serviceorder/workflow/CheckOrderConsistenceManager.java +++ b/src/main/java/org/onap/nbi/apis/serviceorder/workflow/CheckOrderConsistenceManager.java @@ -46,8 +46,8 @@ public class CheckOrderConsistenceManager { if (!existServiceInCatalog(serviceOrderItemInfo)) { serviceOrderInfo.setIsServiceOrderRejected(true); serviceOrderItem.setState(StateType.REJECTED); - LOGGER.error( - "service order item {0} of service order {1} rejected cause no service catalog found for id {2}", + LOGGER.warn( + "service order item {} of service order {} rejected cause no service catalog found for id {}", serviceOrderItem.getId(), serviceOrder.getId(), serviceOrderItem.getService().getServiceSpecification().getId()); } else { @@ -105,11 +105,11 @@ public class CheckOrderConsistenceManager { String serviceOrderId) { if (!StringUtils.isEmpty(serviceOrderItem.getService().getId())) { LOGGER - .error("serviceOrderItem {0} for serviceorder {1} rejected cause service.id must be empty in add action", + .warn("serviceOrderItem {} for serviceorder {} rejected cause service.id must be empty in add action", serviceOrderItem.getId(), serviceOrderId); return false; } else if (!serviceOrderConsumerService.isTenantIdPresentInAAI()) { - LOGGER.error("serviceOrderItem {0} for serviceOrder {1} rejected cause tenantId not found in AAI", + LOGGER.warn("serviceOrderItem {} for serviceOrder {} rejected cause tenantId not found in AAI", serviceOrderItem.getId(), serviceOrderId); return false; } @@ -121,19 +121,19 @@ public class CheckOrderConsistenceManager { ServiceOrderItemInfo serviceOrderItemInfo) { if (StringUtils.isEmpty(serviceOrderItem.getService().getId())) { - LOGGER.error( - "serviceOrderItem {0} for serviceOrder {1} rejected cause service.id is mandatory in delete/change action", + LOGGER.warn( + "serviceOrderItem {} for serviceOrder {} rejected cause service.id is mandatory in delete/change action", serviceOrderItem.getId(), serviceOrderInfo.getServiceOrderId()); return false; } else if (!isCustomerFromServiceOrderPresentInInventory(serviceOrderInfo)) { LOGGER - .error("serviceOrderItem {0} for serviceOrder {1} rejected cause customer not found in inventory", + .warn("serviceOrderItem {} for serviceOrder {} rejected cause customer not found in inventory", serviceOrderItem.getId(), serviceOrderInfo.getServiceOrderId()); return false; } else if (!existServiceInInventory(serviceOrderItem, serviceOrderItemInfo, serviceOrderInfo.getSubscriberInfo().getGlobalSubscriberId())) { LOGGER - .error("serviceOrderItem {0} for serviceOrder {1} rejected cause service id {2} not found in inventory", + .warn("serviceOrderItem {} for serviceOrder {} rejected cause service id {} not found in inventory", serviceOrderItem.getId(), serviceOrderInfo.getServiceOrderId(), serviceOrderItem.getService().getId()); return false; @@ -198,7 +198,7 @@ public class CheckOrderConsistenceManager { LinkedHashMap body = (LinkedHashMap) response.getBody(); serviceOrderItemInfo.setCatalogResponse(body); } else { - LOGGER.error("unable to retrieve catalog information for service {0}", + LOGGER.warn("unable to retrieve catalog information for service {}", serviceOrderItem.getService().getServiceSpecification().getId()); } } diff --git a/src/main/java/org/onap/nbi/apis/serviceorder/workflow/CreateAAICustomerManager.java b/src/main/java/org/onap/nbi/apis/serviceorder/workflow/CreateAAICustomerManager.java index efc7e46..f3c77d6 100644 --- a/src/main/java/org/onap/nbi/apis/serviceorder/workflow/CreateAAICustomerManager.java +++ b/src/main/java/org/onap/nbi/apis/serviceorder/workflow/CreateAAICustomerManager.java @@ -35,6 +35,8 @@ public class CreateAAICustomerManager { private static final Logger LOGGER = LoggerFactory.getLogger(CreateAAICustomerManager.class); + + public void createAAICustomer(ServiceOrder serviceOrder, ServiceOrderInfo serviceOrderInfo) { @@ -47,7 +49,7 @@ public class CreateAAICustomerManager { serviceOrder.setState(StateType.REJECTED); serviceOrder.setCompletionDateTime(new Date()); serviceOrderRepository.save(serviceOrder); - LOGGER.error("serviceOrder {0} rejected : cannot create customer", serviceOrder.getId()); + LOGGER.warn("serviceOrder {} rejected : cannot create customer", serviceOrder.getId()); } } } diff --git a/src/main/java/org/onap/nbi/apis/serviceorder/workflow/CreateAAIServiceTypeManager.java b/src/main/java/org/onap/nbi/apis/serviceorder/workflow/CreateAAIServiceTypeManager.java index fb0c2bc..9ae0550 100644 --- a/src/main/java/org/onap/nbi/apis/serviceorder/workflow/CreateAAIServiceTypeManager.java +++ b/src/main/java/org/onap/nbi/apis/serviceorder/workflow/CreateAAIServiceTypeManager.java @@ -13,6 +13,7 @@ package org.onap.nbi.apis.serviceorder.workflow; import java.util.Date; +import java.util.Map; import org.onap.nbi.apis.serviceorder.MultiClient; import org.onap.nbi.apis.serviceorder.model.ActionType; import org.onap.nbi.apis.serviceorder.model.ServiceOrder; @@ -41,7 +42,7 @@ public class CreateAAIServiceTypeManager { public void createAAIServiceType(ServiceOrder serviceOrder, ServiceOrderInfo serviceOrderInfo) { - LinkedHashMap servicesInAaiForCustomer = serviceOrderConsumerService + Map servicesInAaiForCustomer = serviceOrderConsumerService .getServicesInAaiForCustomer(serviceOrderInfo.getSubscriberInfo().getGlobalSubscriberId()); for (ServiceOrderItem serviceOrderItem : serviceOrder.getOrderItem()) { @@ -56,7 +57,9 @@ public class CreateAAIServiceTypeManager { serviceOrder.setState(StateType.REJECTED); serviceOrder.setCompletionDateTime(new Date()); serviceOrderRepository.save(serviceOrder); - LOGGER.error("serviceOrder {0} rejected : cannot create customer", serviceOrder.getId()); + LOGGER.warn("serviceOrder {} rejected : cannot create service type {} for customer {}", + serviceOrder.getId(), sdcServiceName, + serviceOrderInfo.getSubscriberInfo().getGlobalSubscriberId()); } } } @@ -64,7 +67,7 @@ public class CreateAAIServiceTypeManager { } - private boolean serviceNameExistsInAAI(LinkedHashMap servicesInAaiForCustomer, String sdcServiceName) { + private boolean serviceNameExistsInAAI(Map servicesInAaiForCustomer, String sdcServiceName) { if (servicesInAaiForCustomer != null && servicesInAaiForCustomer.get("service-subscription") != null) { List<LinkedHashMap> servicesInAAI = @@ -77,7 +80,6 @@ public class CreateAAIServiceTypeManager { } } - return false; } diff --git a/src/main/java/org/onap/nbi/apis/serviceorder/workflow/SOTaskManager.java b/src/main/java/org/onap/nbi/apis/serviceorder/workflow/SOTaskManager.java index 0aa26b1..42b9fac 100644 --- a/src/main/java/org/onap/nbi/apis/serviceorder/workflow/SOTaskManager.java +++ b/src/main/java/org/onap/nbi/apis/serviceorder/workflow/SOTaskManager.java @@ -64,6 +64,7 @@ public class SOTaskManager { task.setServiceOrderInfoJson(serviceOrderInfoJson); ExecutionTask savedTask = executionTaskRepository.save(task); executionTasksSaved.add(savedTask); + internalIdOrderItemsMap.put(savedTask.getOrderItemId(), savedTask.getInternalId()); } // then we replace all orderitem ids in reliedtasks field with internalid of the tasks @@ -73,6 +74,8 @@ public class SOTaskManager { String.valueOf(internalIdOrderItemsMap.get(key))); executionTask.setReliedTasks(replace); } + LOGGER.debug("saving task with id {} , orderItemId {} , reliedtasks ", executionTask.getInternalId(), + executionTask.getOrderItemId(), executionTask.getReliedTasks()); executionTaskRepository.save(executionTask); } } diff --git a/src/main/java/org/onap/nbi/apis/serviceorder/workflow/SOTaskProcessor.java b/src/main/java/org/onap/nbi/apis/serviceorder/workflow/SOTaskProcessor.java index 4b36f98..d63de11 100644 --- a/src/main/java/org/onap/nbi/apis/serviceorder/workflow/SOTaskProcessor.java +++ b/src/main/java/org/onap/nbi/apis/serviceorder/workflow/SOTaskProcessor.java @@ -67,15 +67,12 @@ public class SOTaskProcessor { */ public void processOrderItem(ExecutionTask executionTask) throws InterruptedException { - ServiceOrderInfo serviceOrderInfo = getServiceOrderInfo(executionTask); - ServiceOrder serviceOrder = serviceOrderRepository.findOne(serviceOrderInfo.getServiceOrderId()); ServiceOrderItem serviceOrderItem = getServiceOrderItem(executionTask, serviceOrder); - - if (serviceOrderItem != null && StateType.ACKNOWLEDGED == serviceOrderItem.getState()) { + if (StateType.ACKNOWLEDGED == serviceOrderItem.getState()) { ResponseEntity<CreateServiceInstanceResponse> response = postServiceOrderItem(serviceOrderInfo, serviceOrderItem); @@ -85,8 +82,6 @@ public class SOTaskProcessor { serviceOrderItem.setState(StateType.FAILED); } else { updateServiceOrderItem(response, serviceOrderItem); - - } } @@ -115,20 +110,20 @@ public class SOTaskProcessor { try { response = postSORequest(serviceOrderItem, serviceOrderInfo); } catch (NullPointerException e) { - LOGGER.warn("Enable to create service instance for serviceOrderItem.id=" + serviceOrderItem.getId(), e); + LOGGER.error("Unable to create service instance for serviceOrderItem.id=" + serviceOrderItem.getId(), e); response = null; } return response; } private ServiceOrderItem getServiceOrderItem(ExecutionTask executionTask, ServiceOrder serviceOrder) { - ServiceOrderItem serviceOrderItem = null; for (ServiceOrderItem item : serviceOrder.getOrderItem()) { if (item.getId().equals(executionTask.getOrderItemId())) { - serviceOrderItem = item; + return item; } } - return serviceOrderItem; + throw new TechnicalException( + "Unable to retrieve serviceOrderItem forexecutionTaskId " + executionTask.getInternalId()); } private ServiceOrderInfo getServiceOrderInfo(ExecutionTask executionTask) { @@ -138,8 +133,10 @@ public class SOTaskProcessor { serviceOrderInfo = JsonEntityConverter.convertJsonToServiceOrderInfo(serviceOrderInfoJson); } catch (IOException e) { - LOGGER.error("Unable to read ServiceOrderInfo Json for executionTaskId " + executionTask.getInternalId(), e); - throw new TechnicalException("Unable to read ServiceOrderInfo Json for executionTaskId " + executionTask.getInternalId()); + LOGGER + .error("Unable to read ServiceOrderInfo Json for executionTaskId " + executionTask.getInternalId(), e); + throw new TechnicalException( + "Unable to read ServiceOrderInfo Json for executionTaskId " + executionTask.getInternalId()); } return serviceOrderInfo; } @@ -208,8 +205,6 @@ public class SOTaskProcessor { /** * * @param orderItem - * - * @throws InterruptedException */ private void pollSoRequestStatus(ServiceOrderItem orderItem) throws InterruptedException { boolean stopPolling = false; @@ -249,7 +244,7 @@ public class SOTaskProcessor { * @param subscriberInfo * @return */ - private RequestDetails buildSoRequest(ServiceOrderItem orderItem, LinkedHashMap<String, Object> sdcInfos, + private RequestDetails buildSoRequest(ServiceOrderItem orderItem, Map<String, Object> sdcInfos, SubscriberInfo subscriberInfo) { RequestDetails requestDetails = new RequestDetails(); @@ -284,11 +279,7 @@ public class SOTaskProcessor { } /** - * Build a list of UserParams for the SO request by browsing a list of ServiceCharacteristics from - * SDC - * - * @param characteristics - * @return + * Build a list of UserParams for the SO request by browsing a list of ServiceCharacteristics from SDC */ private List<UserParams> retrieveUserParamsFromServiceCharacteristics(List<ServiceCharacteristic> characteristics) { List<UserParams> userParams = new ArrayList<UserParams>(); @@ -314,7 +305,7 @@ public class SOTaskProcessor { private void updateServiceOrderItem(ResponseEntity<CreateServiceInstanceResponse> response, ServiceOrderItem orderItem) { - CreateServiceInstanceResponse createServiceInstanceResponse=response.getBody(); + CreateServiceInstanceResponse createServiceInstanceResponse = response.getBody(); if (createServiceInstanceResponse != null && !orderItem.getState().equals(StateType.FAILED)) { orderItem.getService().setId(createServiceInstanceResponse.getRequestReferences().getInstanceId()); orderItem.setRequestId(createServiceInstanceResponse.getRequestReferences().getRequestId()); diff --git a/src/main/java/org/onap/nbi/exceptions/ApiExceptionHandler.java b/src/main/java/org/onap/nbi/exceptions/ApiExceptionHandler.java index acc556e..dbdae6a 100644 --- a/src/main/java/org/onap/nbi/exceptions/ApiExceptionHandler.java +++ b/src/main/java/org/onap/nbi/exceptions/ApiExceptionHandler.java @@ -15,8 +15,6 @@ */ package org.onap.nbi.exceptions; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.ControllerAdvice; @@ -27,8 +25,6 @@ import org.springframework.web.client.RestClientException; @ControllerAdvice public class ApiExceptionHandler { - private static final Logger LOGGER = LoggerFactory.getLogger(ApiExceptionHandler.class); - @ExceptionHandler(BackendFunctionalException.class) @ResponseBody |