From 941712fe497afb6dda9291784743e36aadb22b95 Mon Sep 17 00:00:00 2001 From: NITIN KAWA Date: Fri, 26 Apr 2019 06:07:05 +0000 Subject: Removed imports and defined a constant. Removed imports and defined constant and combined exception in single catch block. Issue-ID: SO-1490 Change-Id: Iefeb59de5b5e32b06908e62ba24a1bc00892ce1d Signed-off-by: NITIN KAWA --- .../onap/so/bpmn/core/domain/HomingSolution.java | 1 - .../org/onap/so/bpmn/core/domain/JsonWrapper.java | 23 +++++++++------------- 2 files changed, 9 insertions(+), 15 deletions(-) (limited to 'bpmn/MSOCoreBPMN/src') diff --git a/bpmn/MSOCoreBPMN/src/main/java/org/onap/so/bpmn/core/domain/HomingSolution.java b/bpmn/MSOCoreBPMN/src/main/java/org/onap/so/bpmn/core/domain/HomingSolution.java index 897cbe3573..309b053589 100644 --- a/bpmn/MSOCoreBPMN/src/main/java/org/onap/so/bpmn/core/domain/HomingSolution.java +++ b/bpmn/MSOCoreBPMN/src/main/java/org/onap/so/bpmn/core/domain/HomingSolution.java @@ -21,7 +21,6 @@ package org.onap.so.bpmn.core.domain; import java.io.Serializable; -import java.util.List; import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonRootName; diff --git a/bpmn/MSOCoreBPMN/src/main/java/org/onap/so/bpmn/core/domain/JsonWrapper.java b/bpmn/MSOCoreBPMN/src/main/java/org/onap/so/bpmn/core/domain/JsonWrapper.java index 602172f8a4..bf53c880e9 100644 --- a/bpmn/MSOCoreBPMN/src/main/java/org/onap/so/bpmn/core/domain/JsonWrapper.java +++ b/bpmn/MSOCoreBPMN/src/main/java/org/onap/so/bpmn/core/domain/JsonWrapper.java @@ -45,6 +45,7 @@ import org.slf4j.LoggerFactory; */ @JsonInclude(Include.NON_NULL) public abstract class JsonWrapper implements Serializable { + private static final String EXCEPTION = "Exception :"; private static final Logger logger = LoggerFactory.getLogger(JsonWrapper.class); @@ -63,7 +64,7 @@ public abstract class JsonWrapper implements Serializable { jsonString = ow.writeValueAsString(this); } catch (Exception e) { - logger.debug("Exception :", e); + logger.debug(EXCEPTION, e); } return jsonString; } @@ -76,14 +77,10 @@ public abstract class JsonWrapper implements Serializable { JSONObject json = new JSONObject(); try { json = new JSONObject(mapper.writeValueAsString(this)); - } catch (JsonGenerationException e) { - logger.debug("Exception :", e); - } catch (JsonMappingException e) { - logger.debug("Exception :", e); - } catch (JSONException e) { - logger.debug("Exception :", e); + } catch (JsonGenerationException | JsonMappingException | JSONException e) { + logger.debug(EXCEPTION, e); } catch (IOException e) { - logger.debug("Exception :", e); + logger.debug(EXCEPTION, e); } return json; } @@ -95,12 +92,10 @@ public abstract class JsonWrapper implements Serializable { String jsonString = ""; try { jsonString = mapper.writeValueAsString(list); - } catch (JsonGenerationException e) { - logger.debug("Exception :", e); - } catch (JsonMappingException e) { - logger.debug("Exception :", e); + } catch (JsonGenerationException | JsonMappingException e) { + logger.debug(EXCEPTION, e); } catch (IOException e) { - logger.debug("Exception :", e); + logger.debug(EXCEPTION, e); } return jsonString; } @@ -118,7 +113,7 @@ public abstract class JsonWrapper implements Serializable { jsonString = ow.writeValueAsString(this); } catch (Exception e) { - logger.debug("Exception :", e); + logger.debug(EXCEPTION, e); } return jsonString; } -- cgit 1.2.3-korg