From 24ca0c1ac3a84de0bfe0a35d0db9883439bb5777 Mon Sep 17 00:00:00 2001 From: luxin Date: Tue, 26 Sep 2017 10:32:35 +0800 Subject: Add constant instead of duplicating literal Change-Id: I333527f8f71517a941e145a2d83a36e9046a1972 Issue-Id:VFC-391 Signed-off-by: luxin --- .../vnfmadapter/service/constant/Constant.java | 2 ++ .../service/csm/connect/ConnectMgrVnfm.java | 36 +++++++++++++--------- 2 files changed, 24 insertions(+), 14 deletions(-) diff --git a/huawei/vnfmadapter/VnfmadapterService/service/src/main/java/org/onap/vfc/nfvo/vnfm/svnfm/vnfmadapter/service/constant/Constant.java b/huawei/vnfmadapter/VnfmadapterService/service/src/main/java/org/onap/vfc/nfvo/vnfm/svnfm/vnfmadapter/service/constant/Constant.java index 77c0fcc3..936be09c 100644 --- a/huawei/vnfmadapter/VnfmadapterService/service/src/main/java/org/onap/vfc/nfvo/vnfm/svnfm/vnfmadapter/service/constant/Constant.java +++ b/huawei/vnfmadapter/VnfmadapterService/service/src/main/java/org/onap/vfc/nfvo/vnfm/svnfm/vnfmadapter/service/constant/Constant.java @@ -63,6 +63,8 @@ public class Constant { public static final String HEADER_AUTH_TOKEN = "accessSession"; + public static final String X_AUTH_TOKEN = "X-Auth-Token"; + public static final String DOWNLOADCSAR_SUCCESS = "Success"; public static final int UNZIP_SUCCESS = 0; diff --git a/huawei/vnfmadapter/VnfmadapterService/service/src/main/java/org/onap/vfc/nfvo/vnfm/svnfm/vnfmadapter/service/csm/connect/ConnectMgrVnfm.java b/huawei/vnfmadapter/VnfmadapterService/service/src/main/java/org/onap/vfc/nfvo/vnfm/svnfm/vnfmadapter/service/csm/connect/ConnectMgrVnfm.java index c2c6d5c0..c86e65d2 100644 --- a/huawei/vnfmadapter/VnfmadapterService/service/src/main/java/org/onap/vfc/nfvo/vnfm/svnfm/vnfmadapter/service/csm/connect/ConnectMgrVnfm.java +++ b/huawei/vnfmadapter/VnfmadapterService/service/src/main/java/org/onap/vfc/nfvo/vnfm/svnfm/vnfmadapter/service/csm/connect/ConnectMgrVnfm.java @@ -42,6 +42,14 @@ public class ConnectMgrVnfm { private static final Logger LOG = LoggerFactory.getLogger(ConnectMgrVnfm.class); + private static final String CONNECT_FAIL = "connect fail, code:"; + + private static final String CONNECT_JSONEXCEPTION = "function=connect, msg=connect JSONException e={}."; + + private static final String CONNECT_VNFMEXCEPTION = "function=connect, msg=connect VnfmException e={}."; + + private static final String CONNECT_IOEXCEPTION = "function=connect, msg=connect IOException e={}."; + private String accessSession; private String roaRand; @@ -63,10 +71,10 @@ public class ConnectMgrVnfm { } /** - * Make connection *
- * + * * @param vnfmObj + * @param authModel * @return * @since VFC 1.0 */ @@ -95,15 +103,15 @@ public class ConnectMgrVnfm { setRoaRand(tokenObj.getString("roa_rand")); statusCode = HttpStatus.SC_OK; } else { - LOG.error("connect fail, code:" + statusCode + " re:" + result); + LOG.error(CONNECT_FAIL + statusCode + " re:" + result); } } catch(JSONException e) { - LOG.error("function=connect, msg=connect JSONException e={}.", e); + LOG.error(CONNECT_JSONEXCEPTION, e); } catch(VnfmException e) { - LOG.error("function=connect, msg=connect VnfmException e={}.", e); + LOG.error(CONNECT_VNFMEXCEPTION, e); } catch(IOException e) { - LOG.error("function=connect, msg=connect IOException e={}.", e); + LOG.error(CONNECT_IOEXCEPTION, e); } finally { clearCSMPwd(info); if(httpMethod != null) { @@ -149,15 +157,15 @@ public class ConnectMgrVnfm { setAccessSession(header.getValue()); statusCode = HttpStatus.SC_OK; } else { - LOG.error("connect fail, code:" + statusCode + " re:" + result); + LOG.error(CONNECT_FAIL + statusCode + " re:" + result); } } catch(JSONException e) { - LOG.error("function=connect, msg=connect JSONException e={}.", e); + LOG.error(CONNECT_JSONEXCEPTION, e); } catch(VnfmException e) { - LOG.error("function=connect, msg=connect VnfmException e={}.", e); + LOG.error(CONNECT_VNFMEXCEPTION, e); } catch(IOException e) { - LOG.error("function=connect, msg=connect IOException e={}.", e); + LOG.error(CONNECT_IOEXCEPTION, e); } finally { clearCSMPwd(info); if(httpMethod != null) { @@ -201,15 +209,15 @@ public class ConnectMgrVnfm { setRoaRand(tokenObj.getString("roa_rand")); statusCode = HttpStatus.SC_OK; } else { - LOG.error("connect fail, code:" + statusCode + " re:" + result); + LOG.error(CONNECT_FAIL + statusCode + " re:" + result); } } catch(JSONException e) { - LOG.error("function=connect, msg=connect JSONException e={}.", e); + LOG.error(CONNECT_JSONEXCEPTION, e); } catch(VnfmException e) { - LOG.error("function=connect, msg=connect VnfmException e={}.", e); + LOG.error(CONNECT_VNFMEXCEPTION, e); } catch(IOException e) { - LOG.error("function=connect, msg=connect IOException e={}.", e); + LOG.error(CONNECT_IOEXCEPTION, e); } finally { clearCSMPwd(info); if(httpMethod != null) { -- cgit 1.2.3-korg