From 4265d41340ed22b6f5c7acdea7dd22e97abea972 Mon Sep 17 00:00:00 2001 From: Parshad Patel Date: Wed, 11 Sep 2019 13:47:56 +0900 Subject: Fix sonar issues Either log or rethrow this exception Make "attributeValue" transient or serializable "attributeName" is already a string, there's no need to call "toString()" Issue-ID: SO-2226 Change-Id: If6ae623202f2c243d73839d0aaefba5ba5c50dd4 Signed-off-by: Parshad Patel --- .../onap/so/client/adapter/vnf/VnfAdapterClientImpl.java | 14 ++++++++++++-- .../so/client/adapter/vnf/VnfVolumeAdapterClientImpl.java | 13 +++++++++++-- .../so/client/adapter/vnf/mapper/AttributeNameValue.java | 6 +++--- .../adapter/vnf/mapper/VnfAdapterVfModuleObjectMapper.java | 12 ++++++------ 4 files changed, 32 insertions(+), 13 deletions(-) (limited to 'bpmn') diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/adapter/vnf/VnfAdapterClientImpl.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/adapter/vnf/VnfAdapterClientImpl.java index e24e86285c..9af2128f63 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/adapter/vnf/VnfAdapterClientImpl.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/adapter/vnf/VnfAdapterClientImpl.java @@ -7,9 +7,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -33,11 +33,16 @@ import org.onap.so.adapters.vnfrest.RollbackVfModuleResponse; import org.onap.so.adapters.vnfrest.UpdateVfModuleRequest; import org.onap.so.adapters.vnfrest.UpdateVfModuleResponse; import org.onap.so.client.adapter.rest.AdapterRestClient; +import org.onap.so.client.adapter.vnf.mapper.VnfAdapterVfModuleObjectMapper; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import org.springframework.stereotype.Component; @Component public class VnfAdapterClientImpl implements VnfAdapterClient { + private static final Logger logger = LoggerFactory.getLogger(VnfAdapterClientImpl.class); + private static final String VF_MODULES = "/vf-modules/"; private VnfAdapterRestProperties props; @@ -57,6 +62,7 @@ public class VnfAdapterClientImpl implements VnfAdapterClient { return new AdapterRestClient(this.props, this.getUri("/" + aaiVnfId + "/vf-modules").build()).post(req, CreateVfModuleResponse.class); } catch (InternalServerErrorException e) { + logger.error("InternalServerErrorException in createVfModule", e); throw new VnfAdapterClientException(e.getMessage()); } } @@ -69,6 +75,7 @@ public class VnfAdapterClientImpl implements VnfAdapterClient { this.getUri("/" + aaiVnfId + VF_MODULES + aaiVfModuleId + "/rollback").build()).delete(req, RollbackVfModuleResponse.class); } catch (InternalServerErrorException e) { + logger.error("InternalServerErrorException in rollbackVfModule", e); throw new VnfAdapterClientException(e.getMessage()); } } @@ -80,6 +87,7 @@ public class VnfAdapterClientImpl implements VnfAdapterClient { return new AdapterRestClient(this.props, this.getUri("/" + aaiVnfId + VF_MODULES + aaiVfModuleId).build()) .delete(req, DeleteVfModuleResponse.class); } catch (InternalServerErrorException e) { + logger.error("InternalServerErrorException in deleteVfModule", e); throw new VnfAdapterClientException(e.getMessage()); } } @@ -91,6 +99,7 @@ public class VnfAdapterClientImpl implements VnfAdapterClient { return new AdapterRestClient(this.props, this.getUri("/" + aaiVnfId + VF_MODULES + aaiVfModuleId).build()) .put(req, UpdateVfModuleResponse.class); } catch (InternalServerErrorException e) { + logger.error("InternalServerErrorException in updateVfModule", e); throw new VnfAdapterClientException(e.getMessage()); } } @@ -122,6 +131,7 @@ public class VnfAdapterClientImpl implements VnfAdapterClient { return new AdapterRestClient(this.props, builder.build(), MediaType.APPLICATION_JSON, MediaType.APPLICATION_JSON).get(QueryVfModuleResponse.class).get(); } catch (InternalServerErrorException e) { + logger.error("InternalServerErrorException in queryVfModule", e); throw new VnfAdapterClientException(e.getMessage()); } } diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/adapter/vnf/VnfVolumeAdapterClientImpl.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/adapter/vnf/VnfVolumeAdapterClientImpl.java index 2af4d5f1fa..c5e8bf7416 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/adapter/vnf/VnfVolumeAdapterClientImpl.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/adapter/vnf/VnfVolumeAdapterClientImpl.java @@ -7,9 +7,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -34,11 +34,15 @@ import org.onap.so.adapters.vnfrest.UpdateVolumeGroupRequest; import org.onap.so.adapters.vnfrest.UpdateVolumeGroupResponse; import org.onap.so.client.RestClient; import org.onap.so.client.adapter.rest.AdapterRestClient; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import org.springframework.stereotype.Component; @Component public class VnfVolumeAdapterClientImpl implements VnfVolumeAdapterClient { + private static final Logger logger = LoggerFactory.getLogger(VnfVolumeAdapterClientImpl.class); + private final VnfVolumeAdapterRestProperties props; public VnfVolumeAdapterClientImpl() { @@ -50,6 +54,7 @@ public class VnfVolumeAdapterClientImpl implements VnfVolumeAdapterClient { try { return this.getAdapterRestClient("").post(req, CreateVolumeGroupResponse.class); } catch (InternalServerErrorException e) { + logger.error("InternalServerErrorException in createVNFVolumes", e); throw new VnfAdapterClientException(e.getMessage()); } } @@ -60,6 +65,7 @@ public class VnfVolumeAdapterClientImpl implements VnfVolumeAdapterClient { try { return this.getAdapterRestClient("/" + aaiVolumeGroupId).delete(req, DeleteVolumeGroupResponse.class); } catch (InternalServerErrorException e) { + logger.error("InternalServerErrorException in deleteVNFVolumes", e); throw new VnfAdapterClientException(e.getMessage()); } } @@ -71,6 +77,7 @@ public class VnfVolumeAdapterClientImpl implements VnfVolumeAdapterClient { return this.getAdapterRestClient("/" + aaiVolumeGroupId + "/rollback").delete(req, RollbackVolumeGroupResponse.class); } catch (InternalServerErrorException e) { + logger.error("InternalServerErrorException in rollbackVNFVolumes", e); throw new VnfAdapterClientException(e.getMessage()); } } @@ -81,6 +88,7 @@ public class VnfVolumeAdapterClientImpl implements VnfVolumeAdapterClient { try { return this.getAdapterRestClient("/" + aaiVolumeGroupId).put(req, UpdateVolumeGroupResponse.class); } catch (InternalServerErrorException e) { + logger.error("InternalServerErrorException in updateVNFVolumes", e); throw new VnfAdapterClientException(e.getMessage()); } } @@ -94,6 +102,7 @@ public class VnfVolumeAdapterClientImpl implements VnfVolumeAdapterClient { requestId, serviceInstanceId); return this.getAdapterRestClient(path).get(QueryVolumeGroupResponse.class).get(); } catch (InternalServerErrorException e) { + logger.error("InternalServerErrorException in queryVNFVolumes", e); throw new VnfAdapterClientException(e.getMessage()); } } diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/adapter/vnf/mapper/AttributeNameValue.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/adapter/vnf/mapper/AttributeNameValue.java index 6daed56675..6278d48e03 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/adapter/vnf/mapper/AttributeNameValue.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/adapter/vnf/mapper/AttributeNameValue.java @@ -23,10 +23,10 @@ package org.onap.so.client.adapter.vnf.mapper; import java.io.Serializable; public class AttributeNameValue implements Serializable { - private final static long serialVersionUID = -5215028275587848311L; + private static final long serialVersionUID = -5215028275587848311L; private String attributeName; - private Object attributeValue; + private transient Object attributeValue; public AttributeNameValue(String attributeName, Object attributeValue) { this.attributeName = attributeName; @@ -51,7 +51,7 @@ public class AttributeNameValue implements Serializable { @Override public String toString() { - return new StringBuilder().append("{\"attribute_name\": \"").append(attributeName.toString()) + return new StringBuilder().append("{\"attribute_name\": \"").append(attributeName) .append("\", \"attribute_value\": \"").append(attributeValue.toString()).append("\"}").toString(); } } diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/adapter/vnf/mapper/VnfAdapterVfModuleObjectMapper.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/adapter/vnf/mapper/VnfAdapterVfModuleObjectMapper.java index 5c69987a54..8c13c9be97 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/adapter/vnf/mapper/VnfAdapterVfModuleObjectMapper.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/adapter/vnf/mapper/VnfAdapterVfModuleObjectMapper.java @@ -33,7 +33,6 @@ import java.util.HashMap; import java.util.HashSet; import java.util.List; import java.util.Map; -import java.util.Map.Entry; import java.util.Optional; import javax.annotation.PostConstruct; import org.apache.commons.lang3.StringUtils; @@ -76,10 +75,10 @@ import org.onap.so.bpmn.servicedecomposition.bbobjects.VfModule; import org.onap.so.bpmn.servicedecomposition.bbobjects.VolumeGroup; import org.onap.so.bpmn.servicedecomposition.generalobjects.OrchestrationContext; import org.onap.so.bpmn.servicedecomposition.generalobjects.RequestContext; +import org.onap.so.client.adapter.vnf.mapper.exceptions.MissingValueTagException; import org.onap.so.entity.MsoRequest; import org.onap.so.jsonpath.JsonPathUtil; import org.onap.so.openstack.utils.MsoMulticloudUtils; -import org.onap.so.client.adapter.vnf.mapper.exceptions.MissingValueTagException; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; @@ -481,7 +480,7 @@ public class VnfAdapterVfModuleObjectMapper { } } sbInterfaceRoutePrefixes.append("]"); - if (interfaceRoutePrefixesList.size() > 0) { + if (!interfaceRoutePrefixesList.isEmpty()) { paramsMap.put(key + UNDERSCORE + networkKey + "_route_prefixes", sbInterfaceRoutePrefixes.toString()); } @@ -508,7 +507,7 @@ public class VnfAdapterVfModuleObjectMapper { sriovFilterBuf.append(heatVlanFilterValue); } } - if (heatVlanFiltersList.size() > 0) { + if (!heatVlanFiltersList.isEmpty()) { paramsMap.put(networkKey + "_ATT_VF_VLAN_FILTER", sriovFilterBuf.toString()); } } @@ -540,7 +539,7 @@ public class VnfAdapterVfModuleObjectMapper { String ipVersion = ipAddress.getIpVersion(); for (int b = 0; b < ipsList.size(); b++) { String ipAddressValue = ipsList.get(b); - if (ipVersion.equals("ipv4")) { + if ("ipv4".equals(ipVersion)) { if (b != ipsList.size() - 1) { sbIpv4Ips.append(ipAddressValue + ","); } else { @@ -548,7 +547,7 @@ public class VnfAdapterVfModuleObjectMapper { } paramsMap.put(key + UNDERSCORE + networkKey + IP + UNDERSCORE + b, ipAddressValue); - } else if (ipVersion.equals("ipv6")) { + } else if ("ipv6".equals(ipVersion)) { if (b != ipsList.size() - 1) { sbIpv6Ips.append(ipAddressValue + ","); } else { @@ -897,6 +896,7 @@ public class VnfAdapterVfModuleObjectMapper { try { json = mapper.writeValueAsString(obj); } catch (JsonProcessingException e) { + logger.error("JsonProcessingException in convertToString", e); json = "{}"; } -- cgit 1.2.3-korg