diff options
Diffstat (limited to 'adapters')
13 files changed, 113 insertions, 95 deletions
diff --git a/adapters/mso-catalog-db-adapter/src/main/resources/db/migration/V4.4__CreateTableControllerSelectionRefence.sql b/adapters/mso-catalog-db-adapter/src/main/resources/db/migration/V4.7__CreateTableControllerSelectionRefence.sql index dbeba53acc..dbeba53acc 100644 --- a/adapters/mso-catalog-db-adapter/src/main/resources/db/migration/V4.4__CreateTableControllerSelectionRefence.sql +++ b/adapters/mso-catalog-db-adapter/src/main/resources/db/migration/V4.7__CreateTableControllerSelectionRefence.sql diff --git a/adapters/mso-catalog-db-adapter/src/main/resources/db/migration/V4.8__AutoScaleOutReferenceData.sql b/adapters/mso-catalog-db-adapter/src/main/resources/db/migration/V4.8__AutoScaleOutReferenceData.sql new file mode 100644 index 0000000000..c5a8dcf806 --- /dev/null +++ b/adapters/mso-catalog-db-adapter/src/main/resources/db/migration/V4.8__AutoScaleOutReferenceData.sql @@ -0,0 +1,22 @@ +use catalogdb; + +INSERT INTO building_block_detail (BUILDING_BLOCK_NAME, RESOURCE_TYPE, TARGET_ACTION) +VALUES +('ConfigurationScaleOutBB', 'VF_MODULE', 'CREATE'), +('GenericVnfHealthCheckBB', 'VF_MODULE', 'CREATE'); + +INSERT INTO northbound_request_ref_lookup(MACRO_ACTION, ACTION, REQUEST_SCOPE, IS_ALACARTE, IS_TOPLEVELFLOW, MIN_API_VERSION, MAX_API_VERSION) VALUES +('VFModule-ScaleOut', 'createInstance', 'VfModule', true, true, '7','7'); + +INSERT INTO orchestration_flow_reference(COMPOSITE_ACTION, SEQ_NO, FLOW_NAME, FLOW_VERSION, NB_REQ_REF_LOOKUP_ID) VALUES +('VFModule-ScaleOut', '1', 'GenericVnfHealthCheckBB', 1.0,(SELECT id from northbound_request_ref_lookup WHERE MACRO_ACTION = 'VFModule-ScaleOut')), +('VFModule-ScaleOut', '2', 'AssignVfModuleBB', 1.0,(SELECT id from northbound_request_ref_lookup WHERE MACRO_ACTION = 'VFModule-ScaleOut')), +('VFModule-ScaleOut', '3', 'CreateVfModuleBB', 1.0,(SELECT id from northbound_request_ref_lookup WHERE MACRO_ACTION = 'VFModule-ScaleOut')), +('VFModule-ScaleOut', '4', 'ActivateVfModuleBB', 1.0,(SELECT id from northbound_request_ref_lookup WHERE MACRO_ACTION = 'VFModule-ScaleOut')), +('VFModule-ScaleOut', '5', 'ConfigurationScaleOutBB', 1.0,(SELECT id from northbound_request_ref_lookup WHERE MACRO_ACTION = 'VFModule-ScaleOut')), +('VFModule-ScaleOut', '6', 'GenericVnfHealthCheckBB', 1.0,(SELECT id from northbound_request_ref_lookup WHERE MACRO_ACTION = 'VFModule-ScaleOut')); + +INSERT INTO rainy_day_handler_macro (FLOW_NAME, SERVICE_TYPE, VNF_TYPE, ERROR_CODE, WORK_STEP, POLICY) +VALUES +('GenericVnfHealthCheckBB', '*', '*', '*', "*" , 'Retry'), +('ConfigurationScaleOutBB', '*', '*', '*', "*" , 'Retry'); diff --git a/adapters/mso-openstack-adapters/src/main/java/db/migration/R__CloudConfigMigration.java b/adapters/mso-openstack-adapters/src/main/java/db/migration/R__CloudConfigMigration.java index fbafdd052e..ee89edbda8 100644 --- a/adapters/mso-openstack-adapters/src/main/java/db/migration/R__CloudConfigMigration.java +++ b/adapters/mso-openstack-adapters/src/main/java/db/migration/R__CloudConfigMigration.java @@ -2,8 +2,6 @@ package db.migration; import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.core.JsonParseException; -import com.fasterxml.jackson.databind.JsonMappingException; import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.dataformat.yaml.YAMLFactory; import org.flywaydb.core.api.MigrationVersion; @@ -78,7 +76,7 @@ public class R__CloudConfigMigration implements JdbcMigration , MigrationInfoPro this.cloudConfig = cloudConfig; } - private CloudConfig loadCloudConfig(InputStream stream) throws JsonMappingException, IOException { + private CloudConfig loadCloudConfig(InputStream stream) throws IOException { ObjectMapper mapper = new ObjectMapper(new YAMLFactory()); R__CloudConfigMigration cloudConfigMigration = mapper.readValue(stream, R__CloudConfigMigration.class); diff --git a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/tenant/MsoTenantAdapterImpl.java b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/tenant/MsoTenantAdapterImpl.java index f58382f53c..b86681ebfc 100644 --- a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/tenant/MsoTenantAdapterImpl.java +++ b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/tenant/MsoTenantAdapterImpl.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 @@ -45,12 +47,13 @@ import org.springframework.stereotype.Component; @WebService(serviceName = "TenantAdapter", endpointInterface = "org.onap.so.adapters.tenant.MsoTenantAdapter", targetNamespace = "http://org.onap.so/tenant") @Component public class MsoTenantAdapterImpl implements MsoTenantAdapter { - public static final String CREATE_TENANT = "CreateTenant"; + public static final String CREATE_TENANT = "createTenant"; public static final String OPENSTACK = "OpenStack"; public static final String QUERY_TENANT = "QueryTenant"; public static final String DELETE_TENANT = "DeleteTenant"; public static final String ROLLBACK_TENANT = "RollbackTenant"; - + private static final String SUCCESS_RESPONSE_OPENSTACK="Successfully received response from Open Stack"; + private static final String OPENSTACK_COMMUNICATE_EXCEPTION_MSG="Exception while communicate with Open Stack"; @Resource private WebServiceContext wsContext; @@ -84,7 +87,7 @@ public class MsoTenantAdapterImpl implements MsoTenantAdapter { Boolean backout, MsoRequest msoRequest, Holder <String> tenantId, - Holder <TenantRollback> rollback) throws TenantException, TenantAlreadyExists { + Holder <TenantRollback> rollback) throws TenantException { MsoLogger.setLogContext (msoRequest); MsoLogger.setServiceName (CREATE_TENANT); @@ -104,7 +107,7 @@ public class MsoTenantAdapterImpl implements MsoTenantAdapter { try { tUtils = tFactory.getTenantUtils (cloudSiteId); } catch (MsoCloudSiteNotFound me) { - logger.error (MessageEnum.RA_CREATE_TENANT_ERR, me.getMessage(), OPENSTACK, "createTenant", MsoLogger.ErrorCode.DataError, "no implementation found for " + cloudSiteId, me); + logger.error (MessageEnum.RA_CREATE_TENANT_ERR, me.getMessage(), OPENSTACK, CREATE_TENANT, MsoLogger.ErrorCode.DataError, "no implementation found for " + cloudSiteId, me); throw new TenantException (me); } @@ -113,11 +116,11 @@ public class MsoTenantAdapterImpl implements MsoTenantAdapter { long queryTenantStartTime = System.currentTimeMillis (); try { newTenant = tUtils.queryTenantByName (tenantName, cloudSiteId); - logger.recordMetricEvent (queryTenantStartTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully received response from Open Stack", OPENSTACK, QUERY_TENANT, null); + logger.recordMetricEvent (queryTenantStartTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, SUCCESS_RESPONSE_OPENSTACK, OPENSTACK, QUERY_TENANT, null); } catch (MsoException me) { - logger.recordMetricEvent (queryTenantStartTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.CommunicationError, "Exception while communicate with Open Stack", OPENSTACK, QUERY_TENANT, null); + logger.recordMetricEvent (queryTenantStartTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.CommunicationError, OPENSTACK_COMMUNICATE_EXCEPTION_MSG, OPENSTACK, QUERY_TENANT, null); String error = "Create Tenant " + tenantName + ": " + me; - logger.error (MessageEnum.RA_CREATE_TENANT_ERR, me.getMessage(), OPENSTACK, "createTenant", MsoLogger.ErrorCode.DataError, "Exception while communicate with Open Stack", me); + logger.error (MessageEnum.RA_CREATE_TENANT_ERR, me.getMessage(), OPENSTACK, CREATE_TENANT, MsoLogger.ErrorCode.DataError, OPENSTACK_COMMUNICATE_EXCEPTION_MSG, me); logger.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.CommunicationError, error); throw new TenantException (me); } @@ -127,11 +130,11 @@ public class MsoTenantAdapterImpl implements MsoTenantAdapter { long createTenantStartTime = System.currentTimeMillis (); try { newTenantId = tUtils.createTenant (tenantName, cloudSiteId, metadata, backout.booleanValue ()); - logger.recordMetricEvent (createTenantStartTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully received response from Open Stack", OPENSTACK, CREATE_TENANT, null); + logger.recordMetricEvent (createTenantStartTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, SUCCESS_RESPONSE_OPENSTACK, OPENSTACK, CREATE_TENANT, null); } catch (MsoException me) { - logger.recordMetricEvent (createTenantStartTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.CommunicationError, "Exception while communicate with Open Stack", OPENSTACK, CREATE_TENANT, null); + logger.recordMetricEvent (createTenantStartTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.CommunicationError, OPENSTACK_COMMUNICATE_EXCEPTION_MSG, OPENSTACK, CREATE_TENANT, null); String error = "Create Tenant " + tenantName + ": " + me; - logger.error (MessageEnum.RA_CREATE_TENANT_ERR, me.getMessage(), OPENSTACK, "createTenant", MsoLogger.ErrorCode.DataError, "Exception while communicate with Open Stack", me); + logger.error (MessageEnum.RA_CREATE_TENANT_ERR, me.getMessage(), OPENSTACK, CREATE_TENANT, MsoLogger.ErrorCode.DataError, OPENSTACK_COMMUNICATE_EXCEPTION_MSG, me); logger.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.CommunicationError, error); throw new TenantException (me); } @@ -176,7 +179,7 @@ public class MsoTenantAdapterImpl implements MsoTenantAdapter { try { tUtils = tFactory.getTenantUtils (cloudSiteId); } catch (MsoCloudSiteNotFound me) { - logger.error (MessageEnum.RA_CREATE_TENANT_ERR, me.getMessage(), OPENSTACK, "createTenant", MsoLogger.ErrorCode.DataError, "no implementation found for " + cloudSiteId, me); + logger.error (MessageEnum.RA_CREATE_TENANT_ERR, me.getMessage(), OPENSTACK, CREATE_TENANT, MsoLogger.ErrorCode.DataError, "no implementation found for " + cloudSiteId, me); throw new TenantException (me); } @@ -184,7 +187,7 @@ public class MsoTenantAdapterImpl implements MsoTenantAdapter { long subStartTime = System.currentTimeMillis (); try { qTenant = tUtils.queryTenant (tenantNameOrId, cloudSiteId); - logger.recordMetricEvent (subStartTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully received response from Open Stack", OPENSTACK, QUERY_TENANT, null); + logger.recordMetricEvent (subStartTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, SUCCESS_RESPONSE_OPENSTACK, OPENSTACK, QUERY_TENANT, null); if (qTenant == null) { // Not found by ID, Try by name. qTenant = tUtils.queryTenantByName (tenantNameOrId, cloudSiteId); diff --git a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/valet/ValetClient.java b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/valet/ValetClient.java index f4bda4aaa0..3e3c6754dc 100644 --- a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/valet/ValetClient.java +++ b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/valet/ValetClient.java @@ -5,6 +5,8 @@ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. * Copyright (C) 2017 Huawei Technologies Co., Ltd. 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 @@ -69,7 +71,9 @@ public class ValetClient { private static final String DEFAULT_BASE_URL = "http://localhost:8080/"; private static final String DEFAULT_BASE_PATH = "api/valet/placement/v1"; private static final String DEFAULT_AUTH_STRING = ""; - + private static final String REQUEST_ID="requestId"; + private static final String HEADERS=", headers="; + private static final String BODY=", body="; @Autowired private ObjectMapper mapper; @@ -100,7 +104,7 @@ public class ValetClient { GenericValetResponse<ValetCreateResponse> gvr = null; try { - UriBuilder builder = UriBuilder.fromPath(baseUrl).path(basePath).queryParam("requestId", requestId); + UriBuilder builder = UriBuilder.fromPath(baseUrl).path(basePath).queryParam(REQUEST_ID, requestId); URI uri = builder.build(); ValetCreateRequest vcr = this.createValetCreateRequest(regionId, tenantId, serviceInstanceId, vnfId, vnfName, vfModuleId, vfModuleName, keystoneUrl, heatRequest); @@ -108,7 +112,7 @@ public class ValetClient { String body = mapper.writeValueAsString(vcr); HttpHeaders headers = generateHeaders(requestId); HttpEntity<String> entity = new HttpEntity<>(body, headers); - LOGGER.debug("valet create req: " + uri.toString() + ", headers=" + headers.toString() + ", body=" + body.toString()); + LOGGER.debug("valet create req: " + uri.toString() + HEADERS + headers.toString() + BODY + body.toString()); response = restTemplate.exchange(uri, HttpMethod.POST, entity, ValetCreateResponse.class); gvr = this.getGVRFromResponse(response); @@ -128,7 +132,7 @@ public class ValetClient { GenericValetResponse<ValetUpdateResponse> gvr = null; try { - UriBuilder builder = UriBuilder.fromPath(baseUrl).path(basePath).queryParam("requestId", requestId); + UriBuilder builder = UriBuilder.fromPath(baseUrl).path(basePath).queryParam(REQUEST_ID, requestId); URI uri = builder.build(); ValetUpdateRequest vur = this.createValetUpdateRequest(regionId, tenantId, serviceInstanceId, vnfId, vnfName, vfModuleId, vfModuleName, keystoneUrl, heatRequest); @@ -136,7 +140,7 @@ public class ValetClient { String body = mapper.writeValueAsString(vur); HttpHeaders headers = generateHeaders(requestId); HttpEntity<String> entity = new HttpEntity<>(body, headers); - LOGGER.debug("valet update req: " + uri.toString() + ", headers=" + headers.toString() + ", body=" + body.toString()); + LOGGER.debug("valet update req: " + uri.toString() + HEADERS + headers.toString() + ", body=" + body.toString()); response = restTemplate.exchange(uri, HttpMethod.PUT, entity, ValetUpdateResponse.class); gvr = this.getGVRFromResponse(response); @@ -155,7 +159,7 @@ public class ValetClient { GenericValetResponse<ValetDeleteResponse> gvr = null; try { - UriBuilder builder = UriBuilder.fromPath(baseUrl).path(basePath).queryParam("requestId", requestId); + UriBuilder builder = UriBuilder.fromPath(baseUrl).path(basePath).queryParam(REQUEST_ID, requestId); URI uri = builder.build(); ValetDeleteRequest vdr = this.createValetDeleteRequest(regionId, tenantId, vfModuleId, vfModuleName); @@ -163,7 +167,7 @@ public class ValetClient { String body = mapper.writeValueAsString(vdr); HttpHeaders headers = generateHeaders(requestId); HttpEntity<String> entity = new HttpEntity<>(body, headers); - LOGGER.debug("valet delete req: " + uri.toString() + ", headers=" + headers.toString() + ", body=" + body.toString()); + LOGGER.debug("valet delete req: " + uri.toString() + HEADERS + headers.toString() + ", body=" + body.toString()); response = restTemplate.exchange(uri, HttpMethod.DELETE, entity, ValetDeleteResponse.class); gvr = this.getGVRFromResponse(response); @@ -190,7 +194,7 @@ public class ValetClient { String body = mapper.writeValueAsString(vcr); HttpHeaders headers = generateHeaders(requestId); HttpEntity<String> entity = new HttpEntity<>(body, headers); - LOGGER.debug("valet confirm req: " + uri.toString() + ", headers=" + headers.toString() + ", body=" + body); + LOGGER.debug("valet confirm req: " + uri.toString() + HEADERS + headers.toString() + BODY + body); response = restTemplate.exchange(uri, HttpMethod.PUT, entity, ValetConfirmResponse.class); gvr = this.getGVRFromResponse(response); @@ -217,7 +221,7 @@ public class ValetClient { String body = mapper.writeValueAsString(vrr); HttpHeaders headers = generateHeaders(requestId); HttpEntity<String> entity = new HttpEntity<>(body, headers); - LOGGER.debug("valet rollback req: " + uri.toString() + ", headers=" + headers.toString() + ", body=" + body.toString()); + LOGGER.debug("valet rollback req: " + uri.toString() + HEADERS + headers.toString() + BODY + body.toString()); response = restTemplate.exchange(uri, HttpMethod.PUT, entity, ValetRollbackResponse.class); gvr = this.getGVRFromResponse(response); diff --git a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/valet/beans/HeatRequest.java b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/valet/beans/HeatRequest.java index dfd257b06b..4f7afa2d5c 100644 --- a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/valet/beans/HeatRequest.java +++ b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/valet/beans/HeatRequest.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 @@ -26,7 +28,6 @@ import java.util.Map; import java.util.Objects; import com.fasterxml.jackson.annotation.JsonProperty; -import com.woorea.openstack.heat.model.CreateStackParam; /* * This class represents the heat request as sent to OpenStack as defined in the diff --git a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/vnf/MsoVnfAdapterImpl.java b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/vnf/MsoVnfAdapterImpl.java index 29d8f297bf..0d7a739d36 100644 --- a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/vnf/MsoVnfAdapterImpl.java +++ b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/vnf/MsoVnfAdapterImpl.java @@ -947,19 +947,6 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter { LOGGER.debug ("Got Heat Environment from DB: " + heatEnvironment.getEnvironment()); } } - // Replace flavors in environment with those returned by OOF - if (!oldWay) { - Map<String, Object> returnMap = updateFlavorsFromOof(heatEnvironment.getEnvironment(), inputs); - String heatEnvironmentString = returnMap.get("heatEnvironmentString").toString(); - LOGGER.debug("After OOF Update Heat Env String is: " + heatEnvironmentString); - if (returnMap.get("inputs") instanceof Map) { - inputs = (Map<String, String>) returnMap.get("inputs"); - LOGGER.debug("After OOF Update inputs are: " + inputs.toString()); - } else { - LOGGER.debug("inputs is not an instance of a Map: " + returnMap.get("inputs")); - throw new VnfException("Updating inputs using OOF info failed.", MsoExceptionCategory.INTERNAL); - } - } LOGGER.debug ("In MsoVnfAdapterImpl, about to call db.getNestedTemplates avec templateId=" + heatTemplate.getArtifactUuid ()); @@ -2043,19 +2030,6 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter { return vfModuleName; } - private Map<String, Object> updateFlavorsFromOof(String heatEnvironmentString, Map<String, String> inputs) { - Map<String, Object> returnMap = new HashMap<>(); - for (Map.Entry<String, String> input : inputs.entrySet()){ - if (heatEnvironmentString.contains("label_" + input.getKey())){ - heatEnvironmentString = heatEnvironmentString.replace("label_" + input.getKey(), - input.getValue()); - inputs.remove("label_" + input.getKey()); - } - } - returnMap.put("heatEnvironmentString", heatEnvironmentString); - returnMap.put("inputs", inputs); - return returnMap; - } /* * Helper method to check a boolean property value - on error return provided default */ diff --git a/adapters/mso-sdnc-adapter/src/main/java/org/onap/so/adapters/sdnc/SDNCAdapterService.java b/adapters/mso-sdnc-adapter/src/main/java/org/onap/so/adapters/sdnc/SDNCAdapterService.java index fba1d25a76..e74dd64bb3 100644 --- a/adapters/mso-sdnc-adapter/src/main/java/org/onap/so/adapters/sdnc/SDNCAdapterService.java +++ b/adapters/mso-sdnc-adapter/src/main/java/org/onap/so/adapters/sdnc/SDNCAdapterService.java @@ -66,7 +66,7 @@ public class SDNCAdapterService extends Service { try { logger.info(MessageEnum.RA_PRINT_URL, SDNC_ADAPTER_WSDL, wsdlUrl.toURI().toString(), ""); } catch (Exception e) { - logger.error(MessageEnum.RA_WSDL_URL_CONVENTION_EXC, "SDNCAdapter.wsdl", "", "", MsoLogger.ErrorCode.DataError, "Exception - print URL", e); + logger.error(MessageEnum.RA_WSDL_URL_CONVENTION_EXC, SDNC_ADAPTER_WSDL, "", "", MsoLogger.ErrorCode.DataError, "Exception - print URL", e); } } WSDL_LOCATION = wsdlUrl; diff --git a/adapters/mso-sdnc-adapter/src/main/java/org/onap/so/adapters/sdnc/client/SDNCCallbackAdapterService.java b/adapters/mso-sdnc-adapter/src/main/java/org/onap/so/adapters/sdnc/client/SDNCCallbackAdapterService.java index e68bac4178..e4882090bf 100644 --- a/adapters/mso-sdnc-adapter/src/main/java/org/onap/so/adapters/sdnc/client/SDNCCallbackAdapterService.java +++ b/adapters/mso-sdnc-adapter/src/main/java/org/onap/so/adapters/sdnc/client/SDNCCallbackAdapterService.java @@ -45,7 +45,7 @@ import org.onap.so.logger.MsoLogger; public class SDNCCallbackAdapterService extends Service { private static MsoLogger msoLogger = MsoLogger.getMsoLogger(MsoLogger.Catalog.RA, SDNCCallbackAdapterService.class); - + private static final String SDNC_CALLBACK_ADAPTER_WSDL="SDNCCallbackAdapter.wsdl"; public static final URL WSDL_LOCATION; public static final QName SERVICE = new QName("http://org.onap/workflow/sdnc/adapter/callback/wsdl/v1", "SDNCCallbackAdapterService"); public static final QName SDNCCallbackAdapterSoapHttpPort = new QName("http://org.onap/workflow/sdnc/adapter/callback/wsdl/v1", "SDNCCallbackAdapterSoapHttpPort"); @@ -54,15 +54,15 @@ public class SDNCCallbackAdapterService extends Service { try { wsdlUrl = Thread.currentThread().getContextClassLoader().getResource("main/resources/SDNCCallbackAdapter.wsdl"); } catch (Exception e) { - msoLogger.error(MessageEnum.RA_WSDL_NOT_FOUND, "SDNCCallbackAdapter.wsdl", "SDNC", "", MsoLogger.ErrorCode.DataError, "Exception - WSDL not found", e); + msoLogger.error(MessageEnum.RA_WSDL_NOT_FOUND, SDNC_CALLBACK_ADAPTER_WSDL, "SDNC", "", MsoLogger.ErrorCode.DataError, "Exception - WSDL not found", e); } if(wsdlUrl == null) { - msoLogger.error(MessageEnum.RA_WSDL_NOT_FOUND, "SDNCCallbackAdapter.wsdl", "SDNC", "", MsoLogger.ErrorCode.DataError, "WSDL not found"); + msoLogger.error(MessageEnum.RA_WSDL_NOT_FOUND, SDNC_CALLBACK_ADAPTER_WSDL, "SDNC", "", MsoLogger.ErrorCode.DataError, "WSDL not found"); } else { try { - msoLogger.info(MessageEnum.RA_PRINT_URL, "SDNCCallbackAdapter.wsdl", wsdlUrl.toURI().toString(), "SDNC"); + msoLogger.info(MessageEnum.RA_PRINT_URL, SDNC_CALLBACK_ADAPTER_WSDL, wsdlUrl.toURI().toString(), "SDNC"); } catch (Exception e) { - msoLogger.error(MessageEnum.RA_WSDL_URL_CONVENTION_EXC, "SDNCCallbackAdapter.wsdl", "SDNC", "", MsoLogger.ErrorCode.DataError, "Exception - URL convention problem", e); + msoLogger.error(MessageEnum.RA_WSDL_URL_CONVENTION_EXC, SDNC_CALLBACK_ADAPTER_WSDL, "SDNC", "", MsoLogger.ErrorCode.DataError, "Exception - URL convention problem", e); } } WSDL_LOCATION = wsdlUrl; diff --git a/adapters/mso-sdnc-adapter/src/main/java/org/onap/so/adapters/sdnc/impl/SDNCRestClient.java b/adapters/mso-sdnc-adapter/src/main/java/org/onap/so/adapters/sdnc/impl/SDNCRestClient.java index 58feaac0e7..71937245bc 100644 --- a/adapters/mso-sdnc-adapter/src/main/java/org/onap/so/adapters/sdnc/impl/SDNCRestClient.java +++ b/adapters/mso-sdnc-adapter/src/main/java/org/onap/so/adapters/sdnc/impl/SDNCRestClient.java @@ -5,6 +5,8 @@ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. * Copyright (C) 2017 Huawei Technologies Co., Ltd. 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 @@ -73,7 +75,9 @@ public class SDNCRestClient{ private static MsoLogger msoLogger = MsoLogger.getMsoLogger(MsoLogger.Catalog.RA,SDNCRestClient.class); private static MsoAlarmLogger alarmLogger = new MsoAlarmLogger(); - + private static final String EXCEPTION_MSG="Exception while evaluate xpath"; + private static final String MSO_INTERNAL_ERROR="MsoInternalError"; + private static final String CAMUNDA="Camunda"; @Async public void executeRequest(SDNCAdapterRequest bpelRequest) { @@ -217,7 +221,7 @@ public class SDNCRestClient{ eType = xpath.evaluate("error-type", error); sdncErrMsg = new StringBuilder(". SDNC Returned-[error-type:" + eType); } catch (Exception e3) { - msoLogger.error (MessageEnum.RA_EVALUATE_XPATH_ERROR, "error-type", error.toString(), "SDNC", "", MsoLogger.ErrorCode.DataError, "Exception while evaluate xpath", e3); + msoLogger.error (MessageEnum.RA_EVALUATE_XPATH_ERROR, "error-type", error.toString(), "SDNC", "", MsoLogger.ErrorCode.DataError, EXCEPTION_MSG, e3); } String eTag = null; @@ -225,7 +229,7 @@ public class SDNCRestClient{ eTag = xpath.evaluate( "error-tag", error); sdncErrMsg.append(", error-tag:").append(eTag); } catch (Exception e3) { - msoLogger.error (MessageEnum.RA_EVALUATE_XPATH_ERROR, "error-tag", error.toString(), "SDNC", "", MsoLogger.ErrorCode.DataError, "Exception while evaluate xpath", e3); + msoLogger.error (MessageEnum.RA_EVALUATE_XPATH_ERROR, "error-tag", error.toString(), "SDNC", "", MsoLogger.ErrorCode.DataError, EXCEPTION_MSG, e3); } String eMsg = null; @@ -233,7 +237,7 @@ public class SDNCRestClient{ eMsg = xpath.evaluate("error-message", error); sdncErrMsg.append(", error-message:").append(eMsg).append("]"); } catch (Exception e3) { - msoLogger.error (MessageEnum.RA_EVALUATE_XPATH_ERROR, "error-message", error.toString(), "SDNC", "", MsoLogger.ErrorCode.DataError, "Exception while evaluate xpath", e3); + msoLogger.error (MessageEnum.RA_EVALUATE_XPATH_ERROR, "error-message", error.toString(), "SDNC", "", MsoLogger.ErrorCode.DataError, EXCEPTION_MSG, e3); } } } catch (Exception e2) { @@ -253,7 +257,7 @@ public class SDNCRestClient{ sdncResp.setRespMsg(respMsg); msoLogger.error(MessageEnum.RA_EXCEPTION_COMMUNICATE_SDNC, "SDNC", "", MsoLogger.ErrorCode.AvailabilityError, "Exception while communicate with SDNC", e); - alarmLogger.sendAlarm("MsoInternalError", MsoAlarmLogger.CRITICAL, respMsg); + alarmLogger.sendAlarm(MSO_INTERNAL_ERROR, MsoAlarmLogger.CRITICAL, respMsg); return sdncResp; } finally @@ -275,15 +279,15 @@ public class SDNCRestClient{ { cbReq.setRequestData(sdncResp.getSdncRespXml()); } - msoLogger.info(MessageEnum.RA_CALLBACK_BPEL.name() + ":\n" + cbReq.toString(), "Camunda", ""); + msoLogger.info(MessageEnum.RA_CALLBACK_BPEL.name() + ":\n" + cbReq.toString(), CAMUNDA, ""); URL wsdlUrl = null; try { wsdlUrl = new URL (bpelUrl); } catch (MalformedURLException e1) { error = "Caught exception initializing Callback wsdl " + e1.getMessage(); - msoLogger.error(MessageEnum.RA_INIT_CALLBACK_WSDL_ERR, "Camunda", "", MsoLogger.ErrorCode.DataError, "Exception initializing Callback wsdl", e1); - alarmLogger.sendAlarm("MsoInternalError", MsoAlarmLogger.CRITICAL, error); + msoLogger.error(MessageEnum.RA_INIT_CALLBACK_WSDL_ERR, CAMUNDA, "", MsoLogger.ErrorCode.DataError, "Exception initializing Callback wsdl", e1); + alarmLogger.sendAlarm(MSO_INTERNAL_ERROR, MsoAlarmLogger.CRITICAL, error); } SDNCCallbackAdapterService cbSvc = new SDNCCallbackAdapterService(); @@ -312,8 +316,8 @@ public class SDNCRestClient{ } catch (Exception e2) { error = "Unable to set authorization in callback request " + e2.getMessage(); - msoLogger.error(MessageEnum.RA_SET_CALLBACK_AUTH_EXC, "Camunda", "", MsoLogger.ErrorCode.BusinessProcesssError, "Exception - Unable to set authorization in callback request", e2); - alarmLogger.sendAlarm("MsoInternalError", MsoAlarmLogger.CRITICAL, error); + msoLogger.error(MessageEnum.RA_SET_CALLBACK_AUTH_EXC, CAMUNDA, "", MsoLogger.ErrorCode.BusinessProcesssError, "Exception - Unable to set authorization in callback request", e2); + alarmLogger.sendAlarm(MSO_INTERNAL_ERROR, MsoAlarmLogger.CRITICAL, error); } msoLogger.debug("Invoking Bpel Callback. BpelCallbackUrl:" + bpelUrl); @@ -324,9 +328,9 @@ public class SDNCRestClient{ { error = "Error sending BpelCallback request" + e.getMessage(); msoLogger.error("Error " + MsoLogger.ErrorCode.BusinessProcesssError + " - " + MessageEnum.RA_CALLBACK_BPEL_EXC + " - " + error, e); - alarmLogger.sendAlarm("MsoInternalError", MsoAlarmLogger.CRITICAL, error); + alarmLogger.sendAlarm(MSO_INTERNAL_ERROR, MsoAlarmLogger.CRITICAL, error); } - msoLogger.info(MessageEnum.RA_CALLBACK_BPEL_COMPLETE.name(), "Camunda", ""); + msoLogger.info(MessageEnum.RA_CALLBACK_BPEL_COMPLETE.name(), CAMUNDA, ""); return; } diff --git a/adapters/mso-sdnc-adapter/src/main/java/org/onap/so/adapters/sdnc/sdncrest/BPRestCallback.java b/adapters/mso-sdnc-adapter/src/main/java/org/onap/so/adapters/sdnc/sdncrest/BPRestCallback.java index 576d7846cd..d5ce96ea5a 100644 --- a/adapters/mso-sdnc-adapter/src/main/java/org/onap/so/adapters/sdnc/sdncrest/BPRestCallback.java +++ b/adapters/mso-sdnc-adapter/src/main/java/org/onap/so/adapters/sdnc/sdncrest/BPRestCallback.java @@ -5,6 +5,8 @@ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. * Copyright (C) 2017 Huawei Technologies Co., Ltd. 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 @@ -47,7 +49,8 @@ import org.springframework.core.env.Environment; public class BPRestCallback { private static final MsoLogger LOGGER = MsoLogger.getMsoLogger(MsoLogger.Catalog.RA,BPRestCallback.class); private static final MsoAlarmLogger ALARMLOGGER = new MsoAlarmLogger(); - + private static final String CAMUNDA="Camunda"; + private static final String MSO_INTERNAL_ERROR="MsoInternalError"; @Autowired private Environment env; @@ -91,7 +94,7 @@ public class BPRestCallback { + " message=" + message + ")"); - LOGGER.info(MessageEnum.RA_CALLBACK_BPEL, message == null ? "[no content]" : message, "Camunda", ""); + LOGGER.info(MessageEnum.RA_CALLBACK_BPEL, message == null ? "[no content]" : message, CAMUNDA, ""); HttpPost method = null; HttpResponse httpResponse = null; @@ -121,9 +124,9 @@ public class BPRestCallback { String authorization = "Basic " + DatatypeConverter.printBase64Binary(userCredentials.getBytes()); method.setHeader("Authorization", authorization); } catch (Exception e) { - LOGGER.error(MessageEnum.RA_SET_CALLBACK_AUTH_EXC, "Camunda", "", MsoLogger.ErrorCode.BusinessProcesssError, + LOGGER.error(MessageEnum.RA_SET_CALLBACK_AUTH_EXC, CAMUNDA, "", MsoLogger.ErrorCode.BusinessProcesssError, "Unable to set authorization in callback request", e); - ALARMLOGGER.sendAlarm("MsoInternalError", MsoAlarmLogger.CRITICAL, + ALARMLOGGER.sendAlarm(MSO_INTERNAL_ERROR, MsoAlarmLogger.CRITICAL, "Unable to set authorization in callback request: " + e.getMessage()); error = true; } @@ -140,15 +143,15 @@ public class BPRestCallback { if (httpResponse.getStatusLine().getStatusCode() >= 300) { String msg = "Received error response to callback request: " + httpResponse.getStatusLine(); - LOGGER.error(MessageEnum.RA_CALLBACK_BPEL_EXC, "Camunda", "", MsoLogger.ErrorCode.BusinessProcesssError, msg); - ALARMLOGGER.sendAlarm("MsoInternalError", MsoAlarmLogger.CRITICAL, msg); + LOGGER.error(MessageEnum.RA_CALLBACK_BPEL_EXC, CAMUNDA, "", MsoLogger.ErrorCode.BusinessProcesssError, msg); + ALARMLOGGER.sendAlarm(MSO_INTERNAL_ERROR, MsoAlarmLogger.CRITICAL, msg); } } return true; } catch (Exception e) { - LOGGER.error(MessageEnum.RA_CALLBACK_BPEL_EXC, "Camunda", "", MsoLogger.ErrorCode.BusinessProcesssError, + LOGGER.error(MessageEnum.RA_CALLBACK_BPEL_EXC, CAMUNDA, "", MsoLogger.ErrorCode.BusinessProcesssError, "Error sending callback request", e); - ALARMLOGGER.sendAlarm("MsoInternalError", MsoAlarmLogger.CRITICAL, + ALARMLOGGER.sendAlarm(MSO_INTERNAL_ERROR, MsoAlarmLogger.CRITICAL, "Error sending callback request: " + e.getMessage()); return false; } finally { @@ -168,7 +171,7 @@ public class BPRestCallback { LOGGER.debug("Exception:", e); } } - LOGGER.info(MessageEnum.RA_CALLBACK_BPEL_COMPLETE, "Camunda", "",""); + LOGGER.info(MessageEnum.RA_CALLBACK_BPEL_COMPLETE, CAMUNDA, "",""); } } }
\ No newline at end of file diff --git a/adapters/mso-sdnc-adapter/src/main/java/org/onap/so/adapters/sdnc/sdncrest/MapTypedRequestTunablesData.java b/adapters/mso-sdnc-adapter/src/main/java/org/onap/so/adapters/sdnc/sdncrest/MapTypedRequestTunablesData.java index 8541889d8e..da00a6fafa 100644 --- a/adapters/mso-sdnc-adapter/src/main/java/org/onap/so/adapters/sdnc/sdncrest/MapTypedRequestTunablesData.java +++ b/adapters/mso-sdnc-adapter/src/main/java/org/onap/so/adapters/sdnc/sdncrest/MapTypedRequestTunablesData.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 @@ -35,6 +37,10 @@ public class MapTypedRequestTunablesData { private static MsoLogger msoLogger = MsoLogger.getMsoLogger(MsoLogger.Catalog.RA,MapTypedRequestTunablesData.class); private static final MsoAlarmLogger alarmLogger = new MsoAlarmLogger(); + + private static final String MISSING_CONFIGURATION_ERROR_MSG= "Missing configuration for: "; + private static final String MISSING_CONFIG_PARAM_ERROR_MSG="Missing config param"; + private static final String MSO_INTERNAL_ERROR="MsoInternalError"; @Autowired private Environment env; @@ -47,9 +53,9 @@ public class MapTypedRequestTunablesData { String value = env.getProperty(reqTunable.getKey().toLowerCase(), ""); if ("".equals(value)) { - error= "Missing configuration for: " + reqTunable.getKey(); - msoLogger.error(MessageEnum.RA_SDNC_MISS_CONFIG_PARAM, reqTunable.getKey(), "SDNC", "", MsoLogger.ErrorCode.DataError, "Missing config param"); - alarmLogger.sendAlarm("MsoInternalError", MsoAlarmLogger.CRITICAL, reqTunable.getError()); + error= MISSING_CONFIGURATION_ERROR_MSG + reqTunable.getKey(); + msoLogger.error(MessageEnum.RA_SDNC_MISS_CONFIG_PARAM, reqTunable.getKey(), "SDNC", "", MsoLogger.ErrorCode.DataError, MISSING_CONFIG_PARAM_ERROR_MSG); + alarmLogger.sendAlarm(MSO_INTERNAL_ERROR, MsoAlarmLogger.CRITICAL, reqTunable.getError()); throw new SDNCAdapterException(error); } @@ -58,7 +64,7 @@ public class MapTypedRequestTunablesData { if (parts.length != 5) { error="Invalid configuration for: " + reqTunable.getKey(); msoLogger.error(MessageEnum.RA_SDNC_INVALID_CONFIG, reqTunable.getKey(), value, "SDNC", "", MsoLogger.ErrorCode.DataError, "Invalid config"); - alarmLogger.sendAlarm("MsoInternalError", MsoAlarmLogger.CRITICAL, reqTunable.getError()); + alarmLogger.sendAlarm(MSO_INTERNAL_ERROR, MsoAlarmLogger.CRITICAL, reqTunable.getError()); throw new SDNCAdapterException(error); } @@ -72,9 +78,9 @@ public class MapTypedRequestTunablesData { reqTunable.setSdncUrl(env.getProperty(urlPropKey, "")); if ("".equals(reqTunable.getSdncUrl())) { - error="Missing configuration for: " + urlPropKey; - msoLogger.error(MessageEnum.RA_SDNC_MISS_CONFIG_PARAM, urlPropKey, "SDNC", "", MsoLogger.ErrorCode.DataError, "Missing config param"); - alarmLogger.sendAlarm("MsoInternalError", MsoAlarmLogger.CRITICAL, reqTunable.getError()); + error=MISSING_CONFIGURATION_ERROR_MSG + urlPropKey; + msoLogger.error(MessageEnum.RA_SDNC_MISS_CONFIG_PARAM, urlPropKey, "SDNC", "", MsoLogger.ErrorCode.DataError, MISSING_CONFIG_PARAM_ERROR_MSG); + alarmLogger.sendAlarm(MSO_INTERNAL_ERROR, MsoAlarmLogger.CRITICAL, reqTunable.getError()); throw new SDNCAdapterException(error); } @@ -89,10 +95,10 @@ public class MapTypedRequestTunablesData { reqTunable.setMyUrl(env.getProperty(Constants.MY_URL_PROP, "")); if ("".equals(reqTunable.getMyUrl())) { - error="Missing configuration for: " + Constants.MY_URL_PROP; + error=MISSING_CONFIGURATION_ERROR_MSG + Constants.MY_URL_PROP; msoLogger.error(MessageEnum.RA_SDNC_MISS_CONFIG_PARAM, Constants.MY_URL_PROP, "SDNC", "", - MsoLogger.ErrorCode.DataError, "Missing config param"); - alarmLogger.sendAlarm("MsoInternalError", MsoAlarmLogger.CRITICAL, reqTunable.getError()); + MsoLogger.ErrorCode.DataError, MISSING_CONFIG_PARAM_ERROR_MSG); + alarmLogger.sendAlarm(MSO_INTERNAL_ERROR, MsoAlarmLogger.CRITICAL, reqTunable.getError()); throw new SDNCAdapterException(error); } diff --git a/adapters/mso-sdnc-adapter/src/main/java/org/onap/so/adapters/sdnc/sdncrest/SDNCConnector.java b/adapters/mso-sdnc-adapter/src/main/java/org/onap/so/adapters/sdnc/sdncrest/SDNCConnector.java index 6bd7037ca1..6e4fbd830e 100644 --- a/adapters/mso-sdnc-adapter/src/main/java/org/onap/so/adapters/sdnc/sdncrest/SDNCConnector.java +++ b/adapters/mso-sdnc-adapter/src/main/java/org/onap/so/adapters/sdnc/sdncrest/SDNCConnector.java @@ -5,6 +5,8 @@ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. * Copyright (C) 2017 Huawei Technologies Co., Ltd. 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 @@ -68,7 +70,8 @@ import org.springframework.core.env.Environment; public abstract class SDNCConnector { private static final MsoLogger LOGGER = MsoLogger.getMsoLogger(MsoLogger.Catalog.RA,SDNCConnector.class); private static final MsoAlarmLogger ALARMLOGGER = new MsoAlarmLogger(); - + private static final String MSO_INTERNAL_ERROR="MsoInternalError"; + private static final String XPATH_EXCEPTION="XPath Exception"; @Autowired private Environment env; @@ -146,7 +149,7 @@ public abstract class SDNCConnector { } logError(errMsg); - ALARMLOGGER.sendAlarm("MsoInternalError", MsoAlarmLogger.CRITICAL, errMsg); + ALARMLOGGER.sendAlarm(MSO_INTERNAL_ERROR, MsoAlarmLogger.CRITICAL, errMsg); return createErrorResponse(statusCode, errMsg, rt); } @@ -196,13 +199,13 @@ public abstract class SDNCConnector { protected void logError(String errMsg) { LOGGER.error(MessageEnum.RA_EXCEPTION_COMMUNICATE_SDNC, "SDNC", "", MsoLogger.ErrorCode.AvailabilityError, errMsg); - ALARMLOGGER.sendAlarm("MsoInternalError", MsoAlarmLogger.CRITICAL, errMsg); + ALARMLOGGER.sendAlarm(MSO_INTERNAL_ERROR, MsoAlarmLogger.CRITICAL, errMsg); } protected void logError(String errMsg, Throwable t) { LOGGER.error(MessageEnum.RA_EXCEPTION_COMMUNICATE_SDNC, "SDNC", "", MsoLogger.ErrorCode.AvailabilityError, errMsg, t); - ALARMLOGGER.sendAlarm("MsoInternalError", MsoAlarmLogger.CRITICAL, errMsg); + ALARMLOGGER.sendAlarm(MSO_INTERNAL_ERROR, MsoAlarmLogger.CRITICAL, errMsg); } /** @@ -286,7 +289,7 @@ public abstract class SDNCConnector { info += "error-type:" + errorType; } catch (XPathExpressionException e) { LOGGER.error(MessageEnum.RA_EVALUATE_XPATH_ERROR, "error-type", error.toString(), "SDNC", "", - MsoLogger.ErrorCode.DataError, "XPath Exception", e); + MsoLogger.ErrorCode.DataError, XPATH_EXCEPTION, e); } try { @@ -297,7 +300,7 @@ public abstract class SDNCConnector { info += "error-tag:" + errorTag; } catch (XPathExpressionException e) { LOGGER.error(MessageEnum.RA_EVALUATE_XPATH_ERROR, "error-tag", error.toString(), "SDNC", "", - MsoLogger.ErrorCode.DataError, "XPath Exception", e); + MsoLogger.ErrorCode.DataError, XPATH_EXCEPTION, e); } try { @@ -308,7 +311,7 @@ public abstract class SDNCConnector { info += "error-message:" + errorMessage; } catch (Exception e) { LOGGER.error(MessageEnum.RA_EVALUATE_XPATH_ERROR, "error-message", error.toString(), "SDNC", "", - MsoLogger.ErrorCode.DataError, "XPath Exception", e); + MsoLogger.ErrorCode.DataError, XPATH_EXCEPTION, e); } if (!info.isEmpty()) { |