diff options
3 files changed, 117 insertions, 108 deletions
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 2f688dbf48..5645759b02 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 @@ -6,6 +6,7 @@ * Copyright (C) 2017 Huawei Technologies Co., Ltd. All rights reserved. * ================================================================================ * Modifications Copyright (C) 2018 IBM. + * Modifications Copyright (c) 2019 Samsung * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -23,6 +24,11 @@ package org.onap.so.adapters.valet; +import com.fasterxml.jackson.databind.ObjectMapper; +import java.net.URI; +import javax.annotation.PostConstruct; +import javax.ws.rs.core.MediaType; +import javax.ws.rs.core.UriBuilder; import org.onap.so.adapters.valet.beans.HeatRequest; import org.onap.so.adapters.valet.beans.ValetConfirmRequest; import org.onap.so.adapters.valet.beans.ValetConfirmResponse; @@ -34,16 +40,8 @@ import org.onap.so.adapters.valet.beans.ValetRollbackRequest; import org.onap.so.adapters.valet.beans.ValetRollbackResponse; import org.onap.so.adapters.valet.beans.ValetUpdateRequest; import org.onap.so.adapters.valet.beans.ValetUpdateResponse; - -import java.net.URI; - -import javax.annotation.PostConstruct; -import javax.ws.rs.core.MediaType; -import javax.ws.rs.core.UriBuilder; - -import org.onap.so.adapters.valet.GenericValetResponse; - -import org.onap.so.logger.MsoLogger; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.core.env.Environment; import org.springframework.http.HttpEntity; @@ -52,14 +50,13 @@ import org.springframework.http.HttpMethod; import org.springframework.http.ResponseEntity; import org.springframework.http.client.BufferingClientHttpRequestFactory; import org.springframework.http.client.HttpComponentsClientHttpRequestFactory; -import org.springframework.web.client.RestTemplate; import org.springframework.stereotype.Component; - -import com.fasterxml.jackson.databind.ObjectMapper; +import org.springframework.web.client.RestTemplate; @Component public class ValetClient { - private static MsoLogger LOGGER = MsoLogger.getMsoLogger(MsoLogger.Catalog.RA, ValetClient.class); + + private static Logger logger = LoggerFactory.getLogger(ValetClient.class); @Autowired private Environment environment; @@ -93,8 +90,8 @@ public class ValetClient { this.basePath = this.environment.getProperty(ValetClient.VALET_BASE_PATH, ValetClient.DEFAULT_BASE_PATH); this.authString = this.environment.getProperty(ValetClient.VALET_AUTH, ValetClient.DEFAULT_AUTH_STRING); } catch (Exception e) { - LOGGER.debug("Error retrieving valet properties. " + e.getMessage()); - } + logger.debug("Error retrieving valet properties. {}", e.getMessage()); + } } /* @@ -117,8 +114,8 @@ public class ValetClient { response = getRestTemplate().exchange(uri, HttpMethod.POST, entity, ValetCreateResponse.class); gvr = this.getGVRFromResponse(response); } catch (Exception e) { - LOGGER.error("An exception occurred in callValetCreateRequest", e); - throw e; + logger.error("An exception occurred in callValetCreateRequest", e); + throw e; } return gvr; } @@ -150,8 +147,8 @@ public class ValetClient { response = getRestTemplate().exchange(uri, HttpMethod.PUT, entity, ValetUpdateResponse.class); gvr = this.getGVRFromResponse(response); } catch (Exception e) { - LOGGER.error("An exception occurred in callValetUpdateRequest", e); - throw e; + logger.error("An exception occurred in callValetUpdateRequest", e); + throw e; } return gvr; } @@ -177,8 +174,8 @@ public class ValetClient { response = getRestTemplate().exchange(uri, HttpMethod.DELETE, entity, ValetDeleteResponse.class); gvr = this.getGVRFromResponse(response); } catch (Exception e) { - LOGGER.error("An exception occurred in callValetDeleteRequest", e); - throw e; + logger.error("An exception occurred in callValetDeleteRequest", e); + throw e; } return gvr; } @@ -199,12 +196,12 @@ 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, HEADERS, headers, BODY, body); + response = getRestTemplate().exchange(uri, HttpMethod.PUT, entity, ValetConfirmResponse.class); gvr = this.getGVRFromResponse(response); } catch (Exception e) { - LOGGER.error("An exception occurred in callValetConfirmRequest", e); + logger.error("An exception occurred in callValetConfirmRequest", e); throw e; } return gvr; @@ -231,7 +228,7 @@ public class ValetClient { response = getRestTemplate().exchange(uri, HttpMethod.PUT, entity, ValetRollbackResponse.class); gvr = this.getGVRFromResponse(response); } catch (Exception e) { - LOGGER.error("An exception occurred in callValetRollbackRequest", e); + logger.error("An exception occurred in callValetRollbackRequest", e); throw e; } return gvr; diff --git a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/vnf/VolumeAdapterRest.java b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/vnf/VolumeAdapterRest.java index cbdd29d83c..7913a6d827 100644 --- a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/vnf/VolumeAdapterRest.java +++ b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/vnf/VolumeAdapterRest.java @@ -6,6 +6,7 @@ * Copyright (C) 2017 Huawei Technologies Co., Ltd. All rights reserved. * ================================================================================ * Modifications Copyright (C) 2018 IBM. + * Modifications Copyright (c) 2019 Samsung * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -24,9 +25,13 @@ package org.onap.so.adapters.vnf; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import io.swagger.annotations.ApiParam; +import io.swagger.annotations.ApiResponse; +import io.swagger.annotations.ApiResponses; import java.util.HashMap; import java.util.Map; - import javax.inject.Provider; import javax.ws.rs.Consumes; import javax.ws.rs.DELETE; @@ -41,7 +46,6 @@ import javax.ws.rs.core.GenericEntity; import javax.ws.rs.core.MediaType; import javax.ws.rs.core.Response; import javax.xml.ws.Holder; - import org.apache.http.HttpStatus; import org.onap.so.adapters.vnf.exceptions.VnfException; import org.onap.so.adapters.vnfrest.CreateVolumeGroupRequest; @@ -61,16 +65,12 @@ import org.onap.so.logger.MsoLogger; import org.onap.so.openstack.beans.VnfRollback; import org.onap.so.openstack.beans.VnfStatus; import org.onap.so.openstack.exceptions.MsoExceptionCategory; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Qualifier; import org.springframework.stereotype.Component; -import io.swagger.annotations.Api; -import io.swagger.annotations.ApiOperation; -import io.swagger.annotations.ApiParam; -import io.swagger.annotations.ApiResponse; -import io.swagger.annotations.ApiResponses; - /** * This class services calls to the REST interface for VNF Volumes (http://host:port/vnfs/rest/v1/volume-groups) * Both XML and JSON can be produced/consumed. Set Accept: and Content-Type: headers appropriately. XML is the default. @@ -81,7 +81,8 @@ import io.swagger.annotations.ApiResponses; @Api(value = "/v1/volume-groups", description = "root of volume-groups adapters restful web service") @Component public class VolumeAdapterRest { - private static final MsoLogger LOGGER = MsoLogger.getMsoLogger(MsoLogger.Catalog.RA, VolumeAdapterRest.class); + + private static final Logger logger = LoggerFactory.getLogger(VolumeAdapterRest.class); private static final String TESTING_KEYWORD = "___TESTING___"; private static final String EXCEPTION="Exception :"; private static final String RESP=", resp="; @@ -108,7 +109,7 @@ public class VolumeAdapterRest { @ApiParam(value = "CreateVolumeGroupRequest", required = true) final CreateVolumeGroupRequest req ) { - LOGGER.debug("createVNFVolumes enter: " + req.toJsonString()); + logger.debug("createVNFVolumes enter: {}", req.toJsonString()); CreateVNFVolumesTask task = new CreateVNFVolumesTask(req); if (req.isSynchronous()) { // This is a synchronous request @@ -124,11 +125,12 @@ public class VolumeAdapterRest { t1.start(); } catch (Exception e) { // problem handling create, send generic failure as sync resp to caller - LOGGER.error (MessageEnum.RA_CREATE_VNF_ERR, "", "createVNFVolumes", MsoLogger.ErrorCode.BusinessProcesssError, "Exception - createVNFVolumes", e); + logger.error("{} {} Exception - createVNFVolumes: ", MessageEnum.RA_CREATE_VNF_ERR, + MsoLogger.ErrorCode.BusinessProcesssError.getValue(), e); return Response.serverError().build(); } // send sync response (ACK) to caller - LOGGER.debug ("createVNFVolumes exit"); + logger.debug("createVNFVolumes exit"); return Response.status(HttpStatus.SC_ACCEPTED).build(); } } @@ -160,14 +162,14 @@ public class VolumeAdapterRest { } @Override public void run() { - LOGGER.debug ("CreateVFModule VolumesTask start"); + logger.debug("CreateVFModule VolumesTask start"); try { // Synchronous Web Service Outputs Holder<String> stackId = new Holder<>(); Holder<Map<String, String>> outputs = new Holder<>(); Holder<VnfRollback> vnfRollback = new Holder<>(); String completeVnfVfModuleType = req.getVnfType() + "::" + req.getVfModuleType(); - LOGGER.debug("in createVfModuleVolumes - completeVnfVfModuleType=" + completeVnfVfModuleType); + logger.debug("in createVfModuleVolumes - completeVnfVfModuleType={}", completeVnfVfModuleType); String cloudsite = req.getCloudSiteId(); if (cloudsite != null && cloudsite.equals(TESTING_KEYWORD)) { @@ -231,7 +233,7 @@ public class VolumeAdapterRest { rb, req.getMessageId()); } catch (VnfException e) { - LOGGER.debug(EXCEPTION,e); + logger.debug(EXCEPTION, e); eresp = new VolumeGroupExceptionResponse( e.getMessage(), MsoExceptionCategory.INTERNAL, true, req.getMessageId()); } @@ -240,7 +242,7 @@ public class VolumeAdapterRest { BpelRestClient bpelClient = bpelRestClientProvider.get(); bpelClient.bpelPost(getResponse(), req.getNotificationUrl(), sendxml); } - LOGGER.debug ("CreateVFModule VolumesTask exit: code=" + getStatusCode() + RESP+ getResponse()); + logger.debug("CreateVFModule VolumesTask exit: code={} {} {}", getStatusCode(), RESP, getResponse()); } } @@ -262,7 +264,7 @@ public class VolumeAdapterRest { final DeleteVolumeGroupRequest req ) { - LOGGER.debug("deleteVNFVolumes enter: " + req.toJsonString()); + logger.debug("deleteVNFVolumes enter: {}", req.toJsonString()); if (aaiVolumeGroupId == null || !aaiVolumeGroupId.equals(req.getVolumeGroupId())) { return Response .status(HttpStatus.SC_BAD_REQUEST) @@ -285,11 +287,12 @@ public class VolumeAdapterRest { t1.start(); } catch (Exception e) { // problem handling create, send generic failure as sync resp to caller - LOGGER.error (MessageEnum.RA_DELETE_VNF_ERR, "", "deleteVNFVolumes", MsoLogger.ErrorCode.BusinessProcesssError, "Exception - deleteVNFVolumes", e); + logger.error("{} {} Exception - deleteVNFVolumes: ", MessageEnum.RA_DELETE_VNF_ERR, + MsoLogger.ErrorCode.BusinessProcesssError.getValue(), e); return Response.serverError().build(); } // send sync response (ACK) to caller - LOGGER.debug ("deleteVNFVolumes exit"); + logger.debug("deleteVNFVolumes exit"); return Response.status(HttpStatus.SC_ACCEPTED).build(); } } @@ -321,14 +324,14 @@ public class VolumeAdapterRest { } @Override public void run() { - LOGGER.debug("DeleteVNFVolumesTask start"); + logger.debug("DeleteVNFVolumesTask start"); try { if (!req.getCloudSiteId().equals(TESTING_KEYWORD)) { vnfAdapter.deleteVnf(req.getCloudSiteId(), req.getTenantId(), req.getVolumeGroupStackId(), req.getMsoRequest()); } response = new DeleteVolumeGroupResponse(true, req.getMessageId()); } catch (VnfException e) { - LOGGER.debug(EXCEPTION,e); + logger.debug(EXCEPTION, e); eresp = new VolumeGroupExceptionResponse(e.getMessage(), MsoExceptionCategory.INTERNAL, true, req.getMessageId()); } if (!req.isSynchronous()) { @@ -336,7 +339,7 @@ public class VolumeAdapterRest { BpelRestClient bpelClient = bpelRestClientProvider.get(); bpelClient.bpelPost(getResponse(), req.getNotificationUrl(), sendxml); } - LOGGER.debug("DeleteVNFVolumesTask exit: code=" + getStatusCode() + RESP+ getResponse()); + logger.debug("DeleteVNFVolumesTask exit: code={} {} {}", getStatusCode(), RESP, getResponse()); } } @@ -358,7 +361,7 @@ public class VolumeAdapterRest { final RollbackVolumeGroupRequest req ) { - LOGGER.debug("rollbackVNFVolumes enter: " + req.toJsonString()); + logger.debug("rollbackVNFVolumes enter: {}", req.toJsonString()); if (aaiVolumeGroupId == null || req.getVolumeGroupRollback() == null || !aaiVolumeGroupId.equals(req.getVolumeGroupRollback().getVolumeGroupId())) { return Response .status(HttpStatus.SC_BAD_REQUEST) @@ -381,11 +384,12 @@ public class VolumeAdapterRest { t1.start(); } catch (Exception e) { // problem handling create, send generic failure as sync resp to caller - LOGGER.error (MessageEnum.RA_ROLLBACK_VNF_ERR, "", "rollbackVNFVolumes", MsoLogger.ErrorCode.BusinessProcesssError, "Exception - rollbackVNFVolumes", e); + logger.error("{} {} Exception - rollbackVNFVolumes: ", MessageEnum.RA_ROLLBACK_VNF_ERR, + MsoLogger.ErrorCode.BusinessProcesssError.getValue(), e); return Response.serverError().build(); } // send sync response (ACK) to caller - LOGGER.debug("rollbackVNFVolumes exit"); + logger.debug("rollbackVNFVolumes exit"); return Response.status(HttpStatus.SC_ACCEPTED).build(); } } @@ -417,7 +421,7 @@ public class VolumeAdapterRest { } @Override public void run() { - LOGGER.debug("DeleteVNFVolumesTask start"); + logger.debug("DeleteVNFVolumesTask start"); try { VolumeGroupRollback vgr = req.getVolumeGroupRollback(); VnfRollback vrb = new VnfRollback( @@ -426,7 +430,7 @@ public class VolumeAdapterRest { vnfAdapter.rollbackVnf(vrb); response = new RollbackVolumeGroupResponse(true, req.getMessageId()); } catch (VnfException e) { - LOGGER.debug(EXCEPTION,e); + logger.debug(EXCEPTION, e); eresp = new VolumeGroupExceptionResponse(e.getMessage(), MsoExceptionCategory.INTERNAL, true, req.getMessageId()); } if (!req.isSynchronous()) { @@ -434,7 +438,7 @@ public class VolumeAdapterRest { BpelRestClient bpelClient = bpelRestClientProvider.get(); bpelClient.bpelPost(getResponse(), req.getNotificationUrl(), sendxml); } - LOGGER.debug("DeleteVNFVolumesTask exit: code=" + getStatusCode() + RESP+ getResponse()); + logger.debug("DeleteVNFVolumesTask exit: code={} {} {}", getStatusCode(), RESP, getResponse()); } } @@ -457,7 +461,7 @@ public class VolumeAdapterRest { final UpdateVolumeGroupRequest req ) { - LOGGER.debug("updateVNFVolumes enter: " + req.toJsonString()); + logger.debug("updateVNFVolumes enter: {}", req.toJsonString()); if (aaiVolumeGroupId == null || !aaiVolumeGroupId.equals(req.getVolumeGroupId())) { return Response .status(HttpStatus.SC_BAD_REQUEST) @@ -480,11 +484,12 @@ public class VolumeAdapterRest { t1.start(); } catch (Exception e) { // problem handling create, send generic failure as sync resp to caller - LOGGER.error (MessageEnum.RA_UPDATE_VNF_ERR, "", "updateVNFVolumes", MsoLogger.ErrorCode.BusinessProcesssError, "Exception - updateVNFVolumes", e); + logger.error("{} {} Exception - updateVNFVolumes: ", MessageEnum.RA_UPDATE_VNF_ERR, + MsoLogger.ErrorCode.BusinessProcesssError.getValue(), e); return Response.serverError().build(); } // send sync response (ACK) to caller - LOGGER.debug ("updateVNFVolumes exit"); + logger.debug("updateVNFVolumes exit"); return Response.status(HttpStatus.SC_ACCEPTED).build(); } } @@ -516,12 +521,12 @@ public class VolumeAdapterRest { } @Override public void run() { - LOGGER.debug("UpdateVNFVolumesTask start"); + logger.debug("UpdateVNFVolumesTask start"); try { Holder<Map<String, String>> outputs = new Holder<> (); Holder<VnfRollback> vnfRollback = new Holder<> (); String completeVnfVfModuleType = req.getVnfType() + "::" + req.getVfModuleType(); - LOGGER.debug("in updateVfModuleVolume - completeVnfVfModuleType=" + completeVnfVfModuleType); + logger.debug("in updateVfModuleVolume - completeVnfVfModuleType={}", completeVnfVfModuleType); if (req.getCloudSiteId().equals(TESTING_KEYWORD)) { outputs.value = testMap(); @@ -558,7 +563,7 @@ public class VolumeAdapterRest { req.getVolumeGroupId(), req.getVolumeGroupStackId(), outputs.value, req.getMessageId()); } catch (VnfException e) { - LOGGER.debug(EXCEPTION,e); + logger.debug(EXCEPTION, e); eresp = new VolumeGroupExceptionResponse(e.getMessage(), MsoExceptionCategory.INTERNAL, true, req.getMessageId()); } if (!req.isSynchronous()) { @@ -566,7 +571,7 @@ public class VolumeAdapterRest { BpelRestClient bpelClient = bpelRestClientProvider.get(); bpelClient.bpelPost(getResponse(), req.getNotificationUrl(), sendxml); } - LOGGER.debug("UpdateVNFVolumesTask exit: code=" + getStatusCode() + RESP+ getResponse()); + logger.debug("UpdateVNFVolumesTask exit: code={} {} {}", getStatusCode(), RESP, getResponse()); } } @@ -597,7 +602,7 @@ public class VolumeAdapterRest { ) { //This request responds synchronously only - LOGGER.debug ("queryVNFVolumes enter:" + aaiVolumeGroupId + " " + volumeGroupStackId); + logger.debug("queryVNFVolumes enter: {} {}", aaiVolumeGroupId, volumeGroupStackId); MsoRequest msoRequest = new MsoRequest(requestId, serviceInstanceId); try { @@ -619,23 +624,24 @@ public class VolumeAdapterRest { vnfAdapter.queryVnf(cloudSiteId, tenantId, volumeGroupStackId, msoRequest, vnfExists, vfModuleId, status, outputs); } if (!vnfExists.value) { - LOGGER.debug ("VNFVolumes not found"); + logger.debug("VNFVolumes not found"); qryResp.setVolumeGroupStatus(status.value); respStatus = HttpStatus.SC_NOT_FOUND; } else { - LOGGER.debug ("VNFVolumes found " + vfModuleId.value + ", status=" + status.value); + logger.debug("VNFVolumes found {}, status={}", vfModuleId.value, status.value); qryResp.setVolumeGroupStatus(status.value); qryResp.setVolumeGroupOutputs(outputs.value); } - LOGGER.debug("Query queryVNFVolumes exit"); + logger.debug("Query queryVNFVolumes exit"); return Response .status(respStatus) .entity(new GenericEntity<QueryVolumeGroupResponse>(qryResp) {}) .build(); } catch (VnfException e) { - LOGGER.error(MessageEnum.RA_QUERY_VNF_ERR, aaiVolumeGroupId, "", "queryVNFVolumes", MsoLogger.ErrorCode.BusinessProcesssError, "VnfException - queryVNFVolumes", e); + logger.error("{} {} AaiVolumeGroupId: {} VnfException - queryVNFVolumes", MessageEnum.RA_QUERY_VNF_ERR, + MsoLogger.ErrorCode.BusinessProcesssError.getValue(), aaiVolumeGroupId, e); VolumeGroupExceptionResponse excResp = new VolumeGroupExceptionResponse(e.getMessage(), MsoExceptionCategory.INTERNAL, Boolean.FALSE, null); - LOGGER.debug("Query queryVNFVolumes exit"); + logger.debug("Query queryVNFVolumes exit"); return Response .status(HttpStatus.SC_INTERNAL_SERVER_ERROR) .entity(new GenericEntity<VolumeGroupExceptionResponse>(excResp) {}) diff --git a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/vnf/VolumeAdapterRestV2.java b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/vnf/VolumeAdapterRestV2.java index 445f0071a7..3dc223f5c7 100644 --- a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/vnf/VolumeAdapterRestV2.java +++ b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/vnf/VolumeAdapterRestV2.java @@ -5,6 +5,7 @@ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. * ================================================================================ * Modifications Copyright (C) 2018 IBM. + * Modifications Copyright (c) 2019 Samsung * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -23,9 +24,13 @@ package org.onap.so.adapters.vnf; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import io.swagger.annotations.ApiParam; +import io.swagger.annotations.ApiResponse; +import io.swagger.annotations.ApiResponses; import java.util.HashMap; import java.util.Map; - import javax.inject.Provider; import javax.ws.rs.Consumes; import javax.ws.rs.DELETE; @@ -40,7 +45,6 @@ import javax.ws.rs.core.GenericEntity; import javax.ws.rs.core.MediaType; import javax.ws.rs.core.Response; import javax.xml.ws.Holder; - import org.apache.http.HttpStatus; import org.onap.so.adapters.vnf.exceptions.VnfException; import org.onap.so.adapters.vnfrest.CreateVolumeGroupRequest; @@ -60,16 +64,12 @@ import org.onap.so.logger.MsoLogger; import org.onap.so.openstack.beans.VnfRollback; import org.onap.so.openstack.beans.VnfStatus; import org.onap.so.openstack.exceptions.MsoExceptionCategory; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Qualifier; import org.springframework.stereotype.Component; -import io.swagger.annotations.Api; -import io.swagger.annotations.ApiOperation; -import io.swagger.annotations.ApiParam; -import io.swagger.annotations.ApiResponse; -import io.swagger.annotations.ApiResponses; - /** * This class services calls to the REST interface for VNF Volumes (http://host:port/vnfs/rest/v1/volume-groups) * Both XML and JSON can be produced/consumed. Set Accept: and Content-Type: headers appropriately. XML is the default. @@ -83,7 +83,8 @@ import io.swagger.annotations.ApiResponses; @Api(value = "/v2/volume-groups", description = "root of volume-groups adapters restful web service v2") @Component public class VolumeAdapterRestV2 { - private static final MsoLogger LOGGER = MsoLogger.getMsoLogger(MsoLogger.Catalog.RA, VolumeAdapterRestV2.class); + + private static final Logger logger = LoggerFactory.getLogger(VolumeAdapterRestV2.class); private static final String TESTING_KEYWORD = "___TESTING___"; private static final String RESP=", resp="; private static final String EXCEPTION="Exception :"; @@ -113,7 +114,7 @@ public class VolumeAdapterRestV2 { @ApiParam(value = "CreateVolumeGroupRequest", required = true) final CreateVolumeGroupRequest req) { - LOGGER.debug("createVNFVolumes enter: " + req.toJsonString()); + logger.debug("createVNFVolumes enter: {}", req.toJsonString()); CreateVNFVolumesTask task = new CreateVNFVolumesTask(req, mode); if (req.isSynchronous()) { // This is a synchronous request @@ -129,11 +130,12 @@ public class VolumeAdapterRestV2 { t1.start(); } catch (Exception e) { // problem handling create, send generic failure as sync resp to caller - LOGGER.error (MessageEnum.RA_CREATE_VNF_ERR, "", "createVNFVolumes", MsoLogger.ErrorCode.BusinessProcesssError, "Exception - createVNFVolumes", e); + logger.error("{} {} Exception - createVNFVolumes: ", MessageEnum.RA_CREATE_VNF_ERR, + MsoLogger.ErrorCode.BusinessProcesssError.getValue(), e); return Response.serverError().build(); } // send sync response (ACK) to caller - LOGGER.debug ("createVNFVolumes exit"); + logger.debug("createVNFVolumes exit"); return Response.status(HttpStatus.SC_ACCEPTED).build(); } } @@ -167,14 +169,14 @@ public class VolumeAdapterRestV2 { } @Override public void run() { - LOGGER.debug ("CreateVFModule VolumesTask start"); + logger.debug("CreateVFModule VolumesTask start"); try { // Synchronous Web Service Outputs Holder<String> stackId = new Holder<>(); Holder<Map<String, String>> outputs = new Holder<>(); Holder<VnfRollback> vnfRollback = new Holder<>(); String completeVnfVfModuleType = req.getVnfType() + "::" + req.getVfModuleType(); - LOGGER.debug("in createVfModuleVolumes - completeVnfVfModuleType=" + completeVnfVfModuleType); + logger.debug("in createVfModuleVolumes - completeVnfVfModuleType={}", completeVnfVfModuleType); String cloudsiteId = req.getCloudSiteId(); if (cloudsiteId != null && cloudsiteId.equals(TESTING_KEYWORD)) { @@ -226,7 +228,7 @@ public class VolumeAdapterRestV2 { rb, req.getMessageId()); } catch (VnfException e) { - LOGGER.debug(EXCEPTION,e); + logger.debug(EXCEPTION, e); eresp = new VolumeGroupExceptionResponse( e.getMessage(), MsoExceptionCategory.INTERNAL, true, req.getMessageId()); } @@ -235,7 +237,7 @@ public class VolumeAdapterRestV2 { BpelRestClient bpelClient = bpelRestClientProvider.get(); bpelClient.bpelPost(getResponse(), req.getNotificationUrl(), sendxml); } - LOGGER.debug ("CreateVFModule VolumesTask exit: code=" + getStatusCode() + RESP+ getResponse()); + logger.debug("CreateVFModule VolumesTask exit: code= {} {} {}", getStatusCode(), RESP, getResponse()); } } @@ -259,7 +261,7 @@ public class VolumeAdapterRestV2 { final DeleteVolumeGroupRequest req ) { - LOGGER.debug("deleteVNFVolumes enter: " + req.toJsonString()); + logger.debug("deleteVNFVolumes enter: {}", req.toJsonString()); if (aaiVolumeGroupId == null || !aaiVolumeGroupId.equals(req.getVolumeGroupId())) { return Response .status(HttpStatus.SC_BAD_REQUEST) @@ -282,11 +284,12 @@ public class VolumeAdapterRestV2 { t1.start(); } catch (Exception e) { // problem handling create, send generic failure as sync resp to caller - LOGGER.error (MessageEnum.RA_DELETE_VNF_ERR, "", "deleteVNFVolumes", MsoLogger.ErrorCode.BusinessProcesssError, "Exception - deleteVNFVolumes", e); + logger.error("{} {} Exception - deleteVNFVolumes: ", MessageEnum.RA_DELETE_VNF_ERR, + MsoLogger.ErrorCode.BusinessProcesssError.getValue(), e); return Response.serverError().build(); } // send sync response (ACK) to caller - LOGGER.debug ("deleteVNFVolumes exit"); + logger.debug("deleteVNFVolumes exit"); return Response.status(HttpStatus.SC_ACCEPTED).build(); } } @@ -320,7 +323,7 @@ public class VolumeAdapterRestV2 { } @Override public void run() { - LOGGER.debug("DeleteVNFVolumesTask start"); + logger.debug("DeleteVNFVolumesTask start"); String cloudSiteId = req.getCloudSiteId(); try { if (! cloudSiteId.equals(TESTING_KEYWORD)) { @@ -330,7 +333,7 @@ public class VolumeAdapterRestV2 { } response = new DeleteVolumeGroupResponse(true, req.getMessageId()); } catch (VnfException e) { - LOGGER.debug(EXCEPTION,e); + logger.debug(EXCEPTION, e); eresp = new VolumeGroupExceptionResponse(e.getMessage(), MsoExceptionCategory.INTERNAL, true, req.getMessageId()); } if (!req.isSynchronous()) { @@ -338,7 +341,7 @@ public class VolumeAdapterRestV2 { BpelRestClient bpelClient = bpelRestClientProvider.get(); bpelClient.bpelPost(getResponse(), req.getNotificationUrl(), sendxml); } - LOGGER.debug("DeleteVNFVolumesTask exit: code=" + getStatusCode() + RESP+ getResponse()); + logger.debug("DeleteVNFVolumesTask exit: code= {} {} {}", getStatusCode(), RESP, getResponse()); } } @@ -360,7 +363,7 @@ public class VolumeAdapterRestV2 { final RollbackVolumeGroupRequest req ) { - LOGGER.debug("rollbackVNFVolumes enter: " + req.toJsonString()); + logger.debug("rollbackVNFVolumes enter: {}", req.toJsonString()); if (aaiVolumeGroupId == null || req.getVolumeGroupRollback() == null || !aaiVolumeGroupId.equals(req.getVolumeGroupRollback().getVolumeGroupId())) { return Response .status(HttpStatus.SC_BAD_REQUEST) @@ -383,11 +386,12 @@ public class VolumeAdapterRestV2 { t1.start(); } catch (Exception e) { // problem handling create, send generic failure as sync resp to caller - LOGGER.error (MessageEnum.RA_ROLLBACK_VNF_ERR, "", "rollbackVNFVolumes", MsoLogger.ErrorCode.BusinessProcesssError, "Exception - rollbackVNFVolumes", e); + logger.error("{} {} Exception - rollbackVNFVolumes: ", MessageEnum.RA_ROLLBACK_VNF_ERR, + MsoLogger.ErrorCode.BusinessProcesssError.getValue(), e); return Response.serverError().build(); } // send sync response (ACK) to caller - LOGGER.debug("rollbackVNFVolumes exit"); + logger.debug("rollbackVNFVolumes exit"); return Response.status(HttpStatus.SC_ACCEPTED).build(); } } @@ -419,7 +423,7 @@ public class VolumeAdapterRestV2 { } @Override public void run() { - LOGGER.debug("RollbackVNFVolumesTask start"); + logger.debug("RollbackVNFVolumesTask start"); try { VolumeGroupRollback vgr = req.getVolumeGroupRollback(); VnfRollback vrb = new VnfRollback( @@ -431,7 +435,7 @@ public class VolumeAdapterRestV2 { vnfAdapter.rollbackVnf(vrb); response = new RollbackVolumeGroupResponse(true, req.getMessageId()); } catch (VnfException e) { - LOGGER.debug(EXCEPTION,e); + logger.debug(EXCEPTION, e); eresp = new VolumeGroupExceptionResponse(e.getMessage(), MsoExceptionCategory.INTERNAL, true, req.getMessageId()); } if (!req.isSynchronous()) { @@ -439,7 +443,7 @@ public class VolumeAdapterRestV2 { BpelRestClient bpelClient = bpelRestClientProvider.get(); bpelClient.bpelPost(getResponse(), req.getNotificationUrl(), sendxml); } - LOGGER.debug("RollbackVNFVolumesTask exit: code=" + getStatusCode() + RESP+ getResponse()); + logger.debug("RollbackVNFVolumesTask exit: code= {} {} {}", getStatusCode(), RESP, getResponse()); } } @@ -464,7 +468,7 @@ public class VolumeAdapterRestV2 { final UpdateVolumeGroupRequest req ) { - LOGGER.debug("updateVNFVolumes enter: " + req.toJsonString()); + logger.debug("updateVNFVolumes enter: {}", req.toJsonString()); if (aaiVolumeGroupId == null || !aaiVolumeGroupId.equals(req.getVolumeGroupId())) { return Response .status(HttpStatus.SC_BAD_REQUEST) @@ -487,11 +491,12 @@ public class VolumeAdapterRestV2 { t1.start(); } catch (Exception e) { // problem handling create, send generic failure as sync resp to caller - LOGGER.error (MessageEnum.RA_UPDATE_VNF_ERR, "", "updateVNFVolumes", MsoLogger.ErrorCode.BusinessProcesssError, "Exception - updateVNFVolumes", e); + logger.error("{} {} Exception - updateVNFVolumes: ", MessageEnum.RA_UPDATE_VNF_ERR, + MsoLogger.ErrorCode.BusinessProcesssError.getValue(), e); return Response.serverError().build(); } // send sync response (ACK) to caller - LOGGER.debug ("updateVNFVolumes exit"); + logger.debug("updateVNFVolumes exit"); return Response.status(HttpStatus.SC_ACCEPTED).build(); } } @@ -525,12 +530,12 @@ public class VolumeAdapterRestV2 { } @Override public void run() { - LOGGER.debug("UpdateVNFVolumesTask start"); + logger.debug("UpdateVNFVolumesTask start"); try { Holder<Map<String, String>> outputs = new Holder<> (); Holder<VnfRollback> vnfRollback = new Holder<> (); String completeVnfVfModuleType = req.getVnfType() + "::" + req.getVfModuleType(); - LOGGER.debug("in updateVfModuleVolume - completeVnfVfModuleType=" + completeVnfVfModuleType); + logger.debug("in updateVfModuleVolume - completeVnfVfModuleType={}", completeVnfVfModuleType); if (req.getCloudSiteId().equals(TESTING_KEYWORD)) { outputs.value = testMap(); @@ -557,7 +562,7 @@ public class VolumeAdapterRestV2 { req.getVolumeGroupId(), req.getVolumeGroupStackId(), outputs.value, req.getMessageId()); } catch (VnfException e) { - LOGGER.debug(EXCEPTION,e); + logger.debug(EXCEPTION, e); eresp = new VolumeGroupExceptionResponse(e.getMessage(), MsoExceptionCategory.INTERNAL, true, req.getMessageId()); } if (!req.isSynchronous()) { @@ -565,7 +570,7 @@ public class VolumeAdapterRestV2 { BpelRestClient bpelClient = bpelRestClientProvider.get(); bpelClient.bpelPost(getResponse(), req.getNotificationUrl(), sendxml); } - LOGGER.debug("UpdateVNFVolumesTask exit: code=" + getStatusCode() + RESP+ getResponse()); + logger.debug("UpdateVNFVolumesTask exit: code= {} {} {}", getStatusCode(), RESP, getResponse()); } } @@ -598,7 +603,7 @@ public class VolumeAdapterRestV2 { ) { //This request responds synchronously only - LOGGER.debug ("queryVNFVolumes enter:" + aaiVolumeGroupId + " " + volumeGroupStackId); + logger.debug("queryVNFVolumes enter: {} {}", aaiVolumeGroupId, volumeGroupStackId); MsoRequest msoRequest = new MsoRequest(requestId, serviceInstanceId); try { @@ -622,23 +627,24 @@ public class VolumeAdapterRestV2 { vnfAdapter.queryVnf(cloudSiteId, tenantId, volumeGroupStackId, msoRequest, vnfExists, vfModuleId, status, outputs); } if (!vnfExists.value) { - LOGGER.debug ("VNFVolumes not found"); + logger.debug("VNFVolumes not found"); qryResp.setVolumeGroupStatus(status.value); respStatus = HttpStatus.SC_NOT_FOUND; } else { - LOGGER.debug ("VNFVolumes found " + vfModuleId.value + ", status=" + status.value); + logger.debug("VNFVolumes found {}, status={}", vfModuleId.value, status.value); qryResp.setVolumeGroupStatus(status.value); qryResp.setVolumeGroupOutputs(outputs.value); } - LOGGER.debug("Query queryVNFVolumes exit"); + logger.debug("Query queryVNFVolumes exit"); return Response .status(respStatus) .entity(new GenericEntity<QueryVolumeGroupResponse>(qryResp) {}) .build(); } catch (VnfException e) { - LOGGER.error(MessageEnum.RA_QUERY_VNF_ERR, aaiVolumeGroupId, "", "queryVNFVolumes", MsoLogger.ErrorCode.BusinessProcesssError, "VnfException - queryVNFVolumes", e); + logger.error("{} {} AaiVolumeGroupId: {} VnfException - queryVNFVolumes: ", MessageEnum.RA_QUERY_VNF_ERR, + MsoLogger.ErrorCode.BusinessProcesssError.getValue(), aaiVolumeGroupId, e); VolumeGroupExceptionResponse excResp = new VolumeGroupExceptionResponse(e.getMessage(), MsoExceptionCategory.INTERNAL, Boolean.FALSE, null); - LOGGER.debug("Query queryVNFVolumes exit"); + logger.debug("Query queryVNFVolumes exit"); return Response .status(HttpStatus.SC_INTERNAL_SERVER_ERROR) .entity(new GenericEntity<VolumeGroupExceptionResponse>(excResp) {}) |