diff options
author | luxin <luxin7@huawei.com> | 2017-09-22 12:02:13 +0800 |
---|---|---|
committer | luxin <luxin7@huawei.com> | 2017-09-22 12:02:13 +0800 |
commit | 161d708c81d6379c6c311c5a999dfa6c4b8fffee (patch) | |
tree | 2f9e4863f70c0dca3fd32040450dfcfa360b3fb2 /huawei | |
parent | bd358dd59eaf3c0a0daae5a5b601b97796a6ddf2 (diff) |
Define constants instead of duplicating literal
Define constants instead of reason and retCode
Change-Id: I16e6cd71e9c93ef366503a6d8d9286c2b5f1a330
Issue-Id:VFC-375
Signed-off-by: luxin <luxin7@huawei.com>
Diffstat (limited to 'huawei')
9 files changed, 150 insertions, 150 deletions
diff --git a/huawei/vnfmadapter/VnfmadapterService/service/src/main/java/org/onap/vfc/nfvo/vnfm/svnfm/vnfmadapter/common/servicetoken/VNFRestfulUtil.java b/huawei/vnfmadapter/VnfmadapterService/service/src/main/java/org/onap/vfc/nfvo/vnfm/svnfm/vnfmadapter/common/servicetoken/VNFRestfulUtil.java index c045f6ae..44f643f9 100644 --- a/huawei/vnfmadapter/VnfmadapterService/service/src/main/java/org/onap/vfc/nfvo/vnfm/svnfm/vnfmadapter/common/servicetoken/VNFRestfulUtil.java +++ b/huawei/vnfmadapter/VnfmadapterService/service/src/main/java/org/onap/vfc/nfvo/vnfm/svnfm/vnfmadapter/common/servicetoken/VNFRestfulUtil.java @@ -1,5 +1,5 @@ /* - * Copyright 2016 Huawei Technologies Co., Ltd. + * Copyright 2016-2017 Huawei Technologies Co., Ltd. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -23,14 +23,14 @@ import java.util.Iterator; import java.util.Map; import org.onap.vfc.nfvo.vnfm.svnfm.vnfmadapter.common.VnfmException; -import org.onap.vfc.nfvo.vnfm.svnfm.vnfmadapter.service.constant.Constant; -import org.onap.vfc.nfvo.vnfm.svnfm.vnfmadapter.common.restclient.ServiceException; import org.onap.vfc.nfvo.vnfm.svnfm.vnfmadapter.common.restclient.Restful; import org.onap.vfc.nfvo.vnfm.svnfm.vnfmadapter.common.restclient.RestfulAsyncCallback; import org.onap.vfc.nfvo.vnfm.svnfm.vnfmadapter.common.restclient.RestfulFactory; import org.onap.vfc.nfvo.vnfm.svnfm.vnfmadapter.common.restclient.RestfulOptions; import org.onap.vfc.nfvo.vnfm.svnfm.vnfmadapter.common.restclient.RestfulParametes; import org.onap.vfc.nfvo.vnfm.svnfm.vnfmadapter.common.restclient.RestfulResponse; +import org.onap.vfc.nfvo.vnfm.svnfm.vnfmadapter.common.restclient.ServiceException; +import org.onap.vfc.nfvo.vnfm.svnfm.vnfmadapter.service.constant.Constant; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -41,7 +41,7 @@ import net.sf.json.JSONObject; * Utility class.</br> * * @author - * @version VFC 1.0 Sep 10, 2016 + * @version VFC 1.0 Sep 10, 2016 */ public final class VNFRestfulUtil { @@ -116,7 +116,6 @@ public final class VNFRestfulUtil { return getRestRes(methodNames, path, restParametes); } - /** * encapsulate the java reflect exception * @@ -152,7 +151,7 @@ public final class VNFRestfulUtil { * @param methodName * @param objects * @return - * @since VFC 1.0 + * @since VFC 1.0 */ public static RestfulResponse getRestRes(String methodName, Object... objects) { Restful rest = RestfulFactory.getRestInstance(RestfulFactory.PROTO_HTTP); @@ -188,7 +187,7 @@ public final class VNFRestfulUtil { response.setResponseJson(e.getCause().getMessage()); return response; - } catch(Throwable e) { //NOSONAR + } catch(Throwable e) { // NOSONAR try { throw (VnfmException)new VnfmException().initCause(e.getCause()); } catch(VnfmException e1) { @@ -201,6 +200,7 @@ public final class VNFRestfulUtil { /** * Send request to manager. + * * @param path * @param methodName * @param paraJson @@ -208,7 +208,7 @@ public final class VNFRestfulUtil { */ public static JSONObject sendReqToApp(String path, String methodName, JSONObject paraJson) { JSONObject retJson = new JSONObject(); - retJson.put("retCode", Constant.REST_FAIL); + retJson.put(Constant.RETCODE, Constant.REST_FAIL); String abPath = null; String vnfmId = null; if(paraJson != null && paraJson.containsKey("vnfmInfo")) { @@ -228,12 +228,12 @@ public final class VNFRestfulUtil { if(!abPath.contains("vnfdmgr/v1")) { LOG.warn("function=sendReqToApp, msg=result from app is: " + object.toString()); } - if(object.getInt("retCode") == Constant.REST_SUCCESS) { - retJson.put("retCode", Constant.REST_SUCCESS); + if(object.getInt(Constant.RETCODE) == Constant.REST_SUCCESS) { + retJson.put(Constant.RETCODE, Constant.REST_SUCCESS); retJson.put("data", withVnfmIdSuffix(vnfmId, object.get("data"))); return retJson; } else { - retJson.put("retCode", Constant.REST_FAIL); + retJson.put(Constant.RETCODE, Constant.REST_FAIL); if(object.containsKey("msg")) { retJson.put("data", object.getString("msg")); return retJson; @@ -288,7 +288,7 @@ public final class VNFRestfulUtil { * @param domainTokens String * @param isNfvoApp Boolean * @return - * @since VFC 1.0 + * @since VFC 1.0 */ public static RestfulResponse getRemoteResponse(Map<String, String> paramsMap, String params, String domainTokens, boolean isNfvoApp) { @@ -350,10 +350,10 @@ public final class VNFRestfulUtil { * @param paramsMap * @param params * @return - * @since VFC 1.0 + * @since VFC 1.0 */ public static RestfulResponse getRemoteResponse(Map<String, String> paramsMap, String params) { - if(null == paramsMap){ + if(null == paramsMap) { return null; } String url = paramsMap.get("url"); @@ -369,24 +369,23 @@ public final class VNFRestfulUtil { restfulParametes.setHeaderMap(headerMap); restfulParametes.setRawData(params); - if (rest != null) { - if (TYPE_GET.equalsIgnoreCase(methodType)) { + if(rest != null) { + if(TYPE_GET.equalsIgnoreCase(methodType)) { rsp = rest.get(url, restfulParametes); - } else if (TYPE_POST.equalsIgnoreCase(methodType)) { + } else if(TYPE_POST.equalsIgnoreCase(methodType)) { rsp = rest.post(url, restfulParametes); - } else if (TYPE_PUT.equalsIgnoreCase(methodType)) { + } else if(TYPE_PUT.equalsIgnoreCase(methodType)) { rsp = rest.put(url, restfulParametes); - } else if (TYPE_DEL.equalsIgnoreCase(methodType)) { + } else if(TYPE_DEL.equalsIgnoreCase(methodType)) { rsp = rest.delete(url, restfulParametes); } } - } catch (ServiceException e) { + } catch(ServiceException e) { LOG.error("function=getRemoteResponse, get restful response catch exception {}", e); } return rsp; } - /** * Helps to make the parameter map. * <br> @@ -396,7 +395,7 @@ public final class VNFRestfulUtil { * @param path * @param authMode * @return - * @since VFC 1.0 + * @since VFC 1.0 */ public static Map<String, String> generateParamsMap(String url, String methodType, String path, String authMode) { Map<String, String> utilParamsMap = new HashMap<>(6); @@ -414,7 +413,7 @@ public final class VNFRestfulUtil { * @param methodType * @param path * @return - * @since VFC 1.0 + * @since VFC 1.0 */ public static Map<String, String> generateParamsMap(String url, String methodType, String path) { Map<String, String> paramsMap = new HashMap<>(6); @@ -432,23 +431,23 @@ public final class VNFRestfulUtil { * @param vnfmInfo * @param vnfmId * @return - * @since VFC 1.0 + * @since VFC 1.0 */ public static JSONObject getResultToVnfm(JSONObject vnfmInfo, String vnfmId) { JSONObject retJson = new JSONObject(); - retJson.put("retCode", Constant.REST_FAIL); + retJson.put(Constant.RETCODE, Constant.REST_FAIL); if(vnfmInfo == null) { LOG.error("function=getResultToVnfm, msg=data from vnfm is null"); retJson.put("data", "get null result"); return retJson; } - if(vnfmInfo.getInt("retCode") == Constant.REST_SUCCESS) { - retJson.put("retCode", Constant.REST_SUCCESS); + if(vnfmInfo.getInt(Constant.RETCODE) == Constant.REST_SUCCESS) { + retJson.put(Constant.RETCODE, Constant.REST_SUCCESS); retJson.put("data", withVnfmIdSuffix(vnfmId, vnfmInfo.get("data"))); return retJson; } else { - retJson.put("retCode", Constant.REST_FAIL); + retJson.put(Constant.RETCODE, Constant.REST_FAIL); if(vnfmInfo.containsKey("msg")) { retJson.put("data", vnfmInfo.getString("msg")); return retJson; diff --git a/huawei/vnfmadapter/VnfmadapterService/service/src/main/java/org/onap/vfc/nfvo/vnfm/svnfm/vnfmadapter/common/servicetoken/VnfmRestfulUtil.java b/huawei/vnfmadapter/VnfmadapterService/service/src/main/java/org/onap/vfc/nfvo/vnfm/svnfm/vnfmadapter/common/servicetoken/VnfmRestfulUtil.java index 1856985d..d3be616a 100644 --- a/huawei/vnfmadapter/VnfmadapterService/service/src/main/java/org/onap/vfc/nfvo/vnfm/svnfm/vnfmadapter/common/servicetoken/VnfmRestfulUtil.java +++ b/huawei/vnfmadapter/VnfmadapterService/service/src/main/java/org/onap/vfc/nfvo/vnfm/svnfm/vnfmadapter/common/servicetoken/VnfmRestfulUtil.java @@ -1,5 +1,5 @@ /* - * Copyright 2016 Huawei Technologies Co., Ltd. + * Copyright 2016-2017 Huawei Technologies Co., Ltd. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -23,14 +23,14 @@ import java.util.Iterator; import java.util.Map; import org.onap.vfc.nfvo.vnfm.svnfm.vnfmadapter.common.VnfmException; -import org.onap.vfc.nfvo.vnfm.svnfm.vnfmadapter.service.constant.Constant; -import org.onap.vfc.nfvo.vnfm.svnfm.vnfmadapter.common.restclient.ServiceException; import org.onap.vfc.nfvo.vnfm.svnfm.vnfmadapter.common.restclient.Restful; import org.onap.vfc.nfvo.vnfm.svnfm.vnfmadapter.common.restclient.RestfulAsyncCallback; import org.onap.vfc.nfvo.vnfm.svnfm.vnfmadapter.common.restclient.RestfulFactory; import org.onap.vfc.nfvo.vnfm.svnfm.vnfmadapter.common.restclient.RestfulOptions; import org.onap.vfc.nfvo.vnfm.svnfm.vnfmadapter.common.restclient.RestfulParametes; import org.onap.vfc.nfvo.vnfm.svnfm.vnfmadapter.common.restclient.RestfulResponse; +import org.onap.vfc.nfvo.vnfm.svnfm.vnfmadapter.common.restclient.ServiceException; +import org.onap.vfc.nfvo.vnfm.svnfm.vnfmadapter.service.constant.Constant; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -42,7 +42,7 @@ import net.sf.json.JSONObject; * .</br> * * @author - * @version VFC 1.0 Sep 10, 2016 + * @version VFC 1.0 Sep 10, 2016 */ public final class VnfmRestfulUtil { @@ -147,7 +147,7 @@ public final class VnfmRestfulUtil { * @param methodName String * @param objects String * @return - * @since VFC 1.0 + * @since VFC 1.0 */ public static RestfulResponse getRestRes(String methodName, Object... objects) { Restful rest = RestfulFactory.getRestInstance(RestfulFactory.PROTO_HTTP); @@ -183,7 +183,7 @@ public final class VnfmRestfulUtil { response.setResponseJson(e.getCause().getMessage()); return response; - } catch(Throwable e) { //NOSONAR + } catch(Throwable e) { // NOSONAR try { throw (VnfmException)new VnfmException().initCause(e.getCause()); } catch(VnfmException e1) { @@ -202,11 +202,11 @@ public final class VnfmRestfulUtil { * @param methodName String * @param paraJson JSONObject * @return - * @since VFC 1.0 + * @since VFC 1.0 */ public static JSONObject sendReqToApp(String path, String methodName, JSONObject paraJson) { JSONObject retJson = new JSONObject(); - retJson.put("retCode", Constant.REST_FAIL); + retJson.put(Constant.RETCODE, Constant.REST_FAIL); String abPath = null; String vnfmId = null; if(paraJson != null && paraJson.containsKey("vnfmInfo")) { @@ -226,12 +226,12 @@ public final class VnfmRestfulUtil { if(!abPath.contains("vnfdmgr/v1")) { LOG.warn("function=sendReqToApp, msg=result from app is: " + object.toString()); } - if(object.getInt("retCode") == Constant.REST_SUCCESS) { - retJson.put("retCode", Constant.REST_SUCCESS); + if(object.getInt(Constant.RETCODE) == Constant.REST_SUCCESS) { + retJson.put(Constant.RETCODE, Constant.REST_SUCCESS); retJson.put("data", withVnfmIdSuffix(vnfmId, object.get("data"))); return retJson; } else { - retJson.put("retCode", Constant.REST_FAIL); + retJson.put(Constant.RETCODE, Constant.REST_FAIL); if(object.containsKey("msg")) { retJson.put("data", object.getString("msg")); return retJson; @@ -287,7 +287,7 @@ public final class VnfmRestfulUtil { * @param domainTokens String * @param isNfvoApp boolean * @return - * @since VFC 1.0 + * @since VFC 1.0 */ public static RestfulResponse getRemoteResponse(Map<String, String> paramsMap, String params, String domainTokens, boolean isNfvoApp) { @@ -350,7 +350,7 @@ public final class VnfmRestfulUtil { * @param methodType String * @param params String * @return - * @since VFC 1.0 + * @since VFC 1.0 */ public static RestfulResponse getRemoteResponse(String url, String methodType, String params) { RestfulResponse rsp = null; @@ -390,7 +390,7 @@ public final class VnfmRestfulUtil { * @param path String * @param authMode String * @return - * @since VFC 1.0 + * @since VFC 1.0 */ public static Map<String, String> generateParamsMap(String url, String methodType, String path, String authMode) { Map<String, String> utilParamsMap = new HashMap<>(6); diff --git a/huawei/vnfmadapter/VnfmadapterService/service/src/main/java/org/onap/vfc/nfvo/vnfm/svnfm/vnfmadapter/service/adapter/impl/AdapterResourceManager.java b/huawei/vnfmadapter/VnfmadapterService/service/src/main/java/org/onap/vfc/nfvo/vnfm/svnfm/vnfmadapter/service/adapter/impl/AdapterResourceManager.java index 98e3fa04..b1bffc23 100644 --- a/huawei/vnfmadapter/VnfmadapterService/service/src/main/java/org/onap/vfc/nfvo/vnfm/svnfm/vnfmadapter/service/adapter/impl/AdapterResourceManager.java +++ b/huawei/vnfmadapter/VnfmadapterService/service/src/main/java/org/onap/vfc/nfvo/vnfm/svnfm/vnfmadapter/service/adapter/impl/AdapterResourceManager.java @@ -72,8 +72,8 @@ public class AdapterResourceManager implements IResourceManager { // check if parameters are null. if(paramsMap == null || paramsMap.isEmpty()) { - resultObj.put("reason", "csarid and vnfmid are null."); - resultObj.put("retCode", Constant.REST_FAIL); + resultObj.put(Constant.REASON, "csarid and vnfmid are null."); + resultObj.put(Constant.RETCODE, Constant.REST_FAIL); return resultObj; } @@ -82,26 +82,26 @@ public class AdapterResourceManager implements IResourceManager { String vnfdid = ""; if(null == csarid || "".equals(csarid)) { - resultObj.put("reason", "csarid is null."); - resultObj.put("retCode", Constant.REST_FAIL); + resultObj.put(Constant.REASON, "csarid is null."); + resultObj.put(Constant.RETCODE, Constant.REST_FAIL); return resultObj; } if(null == vnfmid || "".equals(vnfmid)) { - resultObj.put("reason", "vnfmid is null."); - resultObj.put("retCode", Constant.REST_FAIL); + resultObj.put(Constant.REASON, "vnfmid is null."); + resultObj.put(Constant.RETCODE, Constant.REST_FAIL); return resultObj; } // obtain CSAR package info JSONObject csarobj = getVnfmCsarInfo(csarid); String downloadUri = ""; - if(Integer.valueOf(csarobj.get("retCode").toString()) == Constant.HTTP_OK) { - LOG.info("get CSAR info successful.", csarobj.get("retCode")); + if(Integer.valueOf(csarobj.get(Constant.RETCODE).toString()) == Constant.HTTP_OK) { + LOG.info("get CSAR info successful.", csarobj.get(Constant.RETCODE)); downloadUri = csarobj.getString("downloadUri"); } else { - LOG.error("get CSAR info fail.", csarobj.get("retCode")); - resultObj.put("reason", csarobj.get("reason").toString()); - resultObj.put("retCode", Constant.REST_FAIL); + LOG.error("get CSAR info fail.", csarobj.get(Constant.RETCODE)); + resultObj.put(Constant.REASON, csarobj.get(Constant.REASON).toString()); + resultObj.put(Constant.RETCODE, Constant.REST_FAIL); return resultObj; } JSONObject csarTempObj = new JSONObject(); @@ -113,25 +113,25 @@ public class AdapterResourceManager implements IResourceManager { JSONObject downloadObject = downloadCsar(downloadUri, csarfilepath + System.getProperty(Constant.FILE_SEPARATOR) + csarfilename); - if(Integer.valueOf(downloadObject.get("retCode").toString()) != Constant.REST_SUCCESS) { - LOG.error("download CSAR fail.", downloadObject.get("retCode")); - resultObj.put("reason", downloadObject.get("reason").toString()); - resultObj.put("retCode", downloadObject.get("retCode").toString()); + if(Integer.valueOf(downloadObject.get(Constant.RETCODE).toString()) != Constant.REST_SUCCESS) { + LOG.error("download CSAR fail.", downloadObject.get(Constant.RETCODE)); + resultObj.put(Constant.REASON, downloadObject.get(Constant.REASON).toString()); + resultObj.put(Constant.RETCODE, downloadObject.get(Constant.RETCODE).toString()); return resultObj; } - LOG.info("download CSAR successful.", downloadObject.get("retCode")); + LOG.info("download CSAR successful.", downloadObject.get(Constant.RETCODE)); // unzip csar package to location. JSONObject unzipObject = unzipCSAR(csarfilepath + System.getProperty(Constant.FILE_SEPARATOR) + csarfilename, csarfilepath); - if(Integer.valueOf(unzipObject.get("retCode").toString()) != Constant.REST_SUCCESS) { - LOG.error("unzip CSAR fail.", unzipObject.get("retCode")); - resultObj.put("reason", unzipObject.get("reason").toString()); - resultObj.put("retCode", unzipObject.get("retCode").toString()); + if(Integer.valueOf(unzipObject.get(Constant.RETCODE).toString()) != Constant.REST_SUCCESS) { + LOG.error("unzip CSAR fail.", unzipObject.get(Constant.RETCODE)); + resultObj.put(Constant.REASON, unzipObject.get(Constant.REASON).toString()); + resultObj.put(Constant.RETCODE, unzipObject.get(Constant.RETCODE).toString()); return resultObj; } - LOG.info("unzip CSAR successful.", unzipObject.get("retCode")); + LOG.info("unzip CSAR successful.", unzipObject.get(Constant.RETCODE)); Map<String, String> vnfmMap = new HashMap<>(); vnfmMap.put("url", String.format(UrlConstant.REST_VNFMINFO_GET, vnfmid)); @@ -139,13 +139,13 @@ public class AdapterResourceManager implements IResourceManager { // get VNFM connection info JSONObject vnfmObject = getVnfmConnInfo(vnfmMap); - if(Integer.valueOf(vnfmObject.get("retCode").toString()) != Constant.HTTP_OK) { - LOG.error("get Vnfm Connection Info fail.", vnfmObject.get("retCode")); - resultObj.put("reason", vnfmObject.get("reason").toString()); - resultObj.put("retCode", vnfmObject.get("retCode").toString()); + if(Integer.valueOf(vnfmObject.get(Constant.RETCODE).toString()) != Constant.HTTP_OK) { + LOG.error("get Vnfm Connection Info fail.", vnfmObject.get(Constant.RETCODE)); + resultObj.put(Constant.REASON, vnfmObject.get(Constant.REASON).toString()); + resultObj.put(Constant.RETCODE, vnfmObject.get(Constant.RETCODE).toString()); return resultObj; } - LOG.info("get Vnfm Connection Info successful.", vnfmObject.get("retCode")); + LOG.info("get Vnfm Connection Info successful.", vnfmObject.get(Constant.RETCODE)); String vnfmUrl = vnfmObject.getString("url"); String userName = vnfmObject.getString("userName"); @@ -161,7 +161,7 @@ public class AdapterResourceManager implements IResourceManager { if(Constant.HTTP_OK != mgrVcmm.connect(vnfmObject, Constant.CERTIFICATE)) { LOG.error("get Access Session fail."); resultObj.put(Constant.RETCODE, Constant.HTTP_INNERERROR); - resultObj.put("reason", "connect fail."); + resultObj.put(Constant.REASON, "connect fail."); return resultObj; } LOG.info("get Access Session successful."); @@ -257,7 +257,7 @@ public class AdapterResourceManager implements IResourceManager { } // return values - resultObj.put("retCode", Constant.HTTP_OK); + resultObj.put(Constant.RETCODE, Constant.HTTP_OK); resultObj.put("vnfdId", vnfdid); resultObj.put("vnfdVersion", vnfdVersion); resultObj.put("planName", planName); @@ -273,8 +273,8 @@ public class AdapterResourceManager implements IResourceManager { RestfulResponse rsp = VNFRestfulUtil.getRemoteResponse(paramsMap, ""); if(null == rsp) { LOG.error("function=sendRequest, RestfulResponse is null"); - resultObj.put("reason", "RestfulResponse is null."); - resultObj.put("retCode", Constant.REST_FAIL); + resultObj.put(Constant.REASON, "RestfulResponse is null."); + resultObj.put(Constant.RETCODE, Constant.REST_FAIL); return resultObj; } String resultCreate = rsp.getResponseContent(); @@ -282,13 +282,13 @@ public class AdapterResourceManager implements IResourceManager { if(rsp.getStatus() == Constant.HTTP_OK) { LOG.warn("function=sendRequest, msg= status={}, result={}.", rsp.getStatus(), resultCreate); resultObj = JSONObject.fromObject(resultCreate); - resultObj.put("retCode", Constant.HTTP_OK); + resultObj.put(Constant.RETCODE, Constant.HTTP_OK); return resultObj; } else { LOG.error("function=sendRequest, msg=ESR return fail,status={}, result={}.", rsp.getStatus(), resultCreate); - resultObj.put("reason", "ESR return fail."); + resultObj.put(Constant.REASON, "ESR return fail."); } - resultObj.put("retCode", Constant.REST_FAIL); + resultObj.put(Constant.RETCODE, Constant.REST_FAIL); return resultObj; } @@ -297,8 +297,8 @@ public class AdapterResourceManager implements IResourceManager { JSONObject resultObj = new JSONObject(); if(null == csarid || "".equals(csarid)) { - resultObj.put("reason", "csarid is null."); - resultObj.put("retCode", Constant.REST_FAIL); + resultObj.put(Constant.REASON, "csarid is null."); + resultObj.put(Constant.RETCODE, Constant.REST_FAIL); return resultObj; } @@ -315,24 +315,24 @@ public class AdapterResourceManager implements IResourceManager { JSONObject resultObj = new JSONObject(); if(url == null || "".equals(url)) { - resultObj.put("reason", "url is null."); - resultObj.put("retCode", Constant.REST_FAIL); + resultObj.put(Constant.REASON, "url is null."); + resultObj.put(Constant.RETCODE, Constant.REST_FAIL); return resultObj; } if(filePath == null || "".equals(filePath)) { - resultObj.put("reason", "downloadUrl filePath is null."); - resultObj.put("retCode", Constant.REST_FAIL); + resultObj.put(Constant.REASON, "downloadUrl filePath is null."); + resultObj.put(Constant.RETCODE, Constant.REST_FAIL); return resultObj; } String status = DownloadCsarManager.download(url, filePath); if(Constant.DOWNLOADCSAR_SUCCESS.equals(status)) { - resultObj.put("reason", "download csar file successfully."); - resultObj.put("retCode", Constant.REST_SUCCESS); + resultObj.put(Constant.REASON, "download csar file successfully."); + resultObj.put(Constant.RETCODE, Constant.REST_SUCCESS); } else { - resultObj.put("reason", "download csar file failed."); - resultObj.put("retCode", Constant.REST_FAIL); + resultObj.put(Constant.REASON, "download csar file failed."); + resultObj.put(Constant.RETCODE, Constant.REST_FAIL); } return resultObj; } @@ -365,23 +365,23 @@ public class AdapterResourceManager implements IResourceManager { } else { LOG.error("uploadVNFPackage get allcloud failed, code:" + statusCode + " re:" + result); resultObj.put(Constant.RETCODE, statusCode); - resultObj.put("reason", "get allcloud failed. code:" + statusCode + " re:" + result); + resultObj.put(Constant.REASON, "get allcloud failed. code:" + statusCode + " re:" + result); return resultObj; } } catch(JSONException e) { LOG.error("function=uploadVNFPackage, msg=uploadVNFPackage get allcloud JSONException e={}.", e); resultObj.put(Constant.RETCODE, Constant.HTTP_INNERERROR); - resultObj.put("reason", "get allcloud failed and JSONException." + e.getMessage()); + resultObj.put(Constant.REASON, "get allcloud failed and JSONException." + e.getMessage()); return resultObj; } catch(VnfmException e) { LOG.error("function=uploadVNFPackage, msg=uploadVNFPackage get allcloud VnfmException e={}.", e); resultObj.put(Constant.RETCODE, Constant.HTTP_INNERERROR); - resultObj.put("reason", "get allcloud failed and VnfmException." + e.getMessage()); + resultObj.put(Constant.REASON, "get allcloud failed and VnfmException." + e.getMessage()); return resultObj; } catch(IOException e) { LOG.error("function=uploadVNFPackage, msg=uploadVNFPackage get allcloud IOException e={}.", e); resultObj.put(Constant.RETCODE, Constant.HTTP_INNERERROR); - resultObj.put("reason", "get allcloud failed and IOException." + e.getMessage()); + resultObj.put(Constant.REASON, "get allcloud failed and IOException." + e.getMessage()); return resultObj; } return resultObj; @@ -422,17 +422,17 @@ public class AdapterResourceManager implements IResourceManager { } catch(JSONException e) { LOG.error("function=uploadVNFPackage, msg=uploadVNFPackage upload VNF package JSONException e={}.", e); resultObj.put(Constant.RETCODE, Constant.HTTP_INNERERROR); - resultObj.put("reason", "upload VNF package failed and JSONException." + e.getMessage()); + resultObj.put(Constant.REASON, "upload VNF package failed and JSONException." + e.getMessage()); return resultObj; } catch(VnfmException e) { LOG.error("function=uploadVNFPackage, msg=uploadVNFPackage upload VNF package VnfmException e={}.", e); resultObj.put(Constant.RETCODE, Constant.HTTP_INNERERROR); - resultObj.put("reason", "upload VNF package failed and VnfmException." + e.getMessage()); + resultObj.put(Constant.REASON, "upload VNF package failed and VnfmException." + e.getMessage()); return resultObj; } catch(IOException e) { LOG.error("function=uploadVNFPackage, msg=uploadVNFPackage upload VNF package IOException e={}.", e); resultObj.put(Constant.RETCODE, Constant.HTTP_INNERERROR); - resultObj.put("reason", "upload VNF package failed and IOException." + e.getMessage()); + resultObj.put(Constant.REASON, "upload VNF package failed and IOException." + e.getMessage()); return resultObj; } return resultObj; @@ -469,17 +469,17 @@ public class AdapterResourceManager implements IResourceManager { } catch(JSONException e) { LOG.error("function=uploadVNFPackage, msg=uploadVNFPackage get vnfd version JSONException e={}.", e); resultObj.put(Constant.RETCODE, Constant.HTTP_INNERERROR); - resultObj.put("reason", "get vnfd version failed and JSONException." + e.getMessage()); + resultObj.put(Constant.REASON, "get vnfd version failed and JSONException." + e.getMessage()); return resultObj; } catch(VnfmException e) { LOG.error("function=uploadVNFPackage, msg=uploadVNFPackage get vnfd version VnfmException e={}.", e); resultObj.put(Constant.RETCODE, Constant.HTTP_INNERERROR); - resultObj.put("reason", "get vnfd version failed and VnfmException." + e.getMessage()); + resultObj.put(Constant.REASON, "get vnfd version failed and VnfmException." + e.getMessage()); return resultObj; } catch(IOException e) { LOG.error("function=uploadVNFPackage, msg=uploadVNFPackage get vnfd version IOException e={}.", e); resultObj.put(Constant.RETCODE, Constant.HTTP_INNERERROR); - resultObj.put("reason", "get vnfd version failed and IOException." + e.getMessage()); + resultObj.put(Constant.REASON, "get vnfd version failed and IOException." + e.getMessage()); return resultObj; } return resultObj; @@ -516,23 +516,23 @@ public class AdapterResourceManager implements IResourceManager { } else { LOG.error("uploadVNFPackage get VNFDPlanInfo failed, code:" + statusCode + " re:" + result); resultObj.put(Constant.RETCODE, statusCode); - resultObj.put("reason", "get VNFDPlanInfo failed. code:" + statusCode + " re:" + result); + resultObj.put(Constant.REASON, "get VNFDPlanInfo failed. code:" + statusCode + " re:" + result); return resultObj; } } catch(JSONException e) { LOG.error("function=uploadVNFPackage, msg=uploadVNFPackage get VNFDPlanInfo JSONException e={}.", e); resultObj.put(Constant.RETCODE, Constant.HTTP_INNERERROR); - resultObj.put("reason", "get VNFDPlanInfo failed and JSONException." + e.getMessage()); + resultObj.put(Constant.REASON, "get VNFDPlanInfo failed and JSONException." + e.getMessage()); return resultObj; } catch(VnfmException e) { LOG.error("function=uploadVNFPackage, msg=uploadVNFPackage get VNFDPlanInfo VnfmException e={}.", e); resultObj.put(Constant.RETCODE, Constant.HTTP_INNERERROR); - resultObj.put("reason", "get VNFDPlanInfo failed and VnfmException." + e.getMessage()); + resultObj.put(Constant.REASON, "get VNFDPlanInfo failed and VnfmException." + e.getMessage()); return resultObj; } catch(IOException e) { LOG.error("function=uploadVNFPackage, msg=uploadVNFPackage get VNFDPlanInfo IOException e={}.", e); resultObj.put(Constant.RETCODE, Constant.HTTP_INNERERROR); - resultObj.put("reason", "get VNFDPlanInfo failed and IOException." + e.getMessage()); + resultObj.put(Constant.REASON, "get VNFDPlanInfo failed and IOException." + e.getMessage()); return resultObj; } return resultObj; @@ -621,24 +621,24 @@ public class AdapterResourceManager implements IResourceManager { JSONObject resultObj = new JSONObject(); if(fileName == null || "".equals(fileName)) { - resultObj.put("reason", "fileName is null."); - resultObj.put("retCode", Constant.REST_FAIL); + resultObj.put(Constant.REASON, "fileName is null."); + resultObj.put(Constant.RETCODE, Constant.REST_FAIL); return resultObj; } if(filePath == null || "".equals(filePath)) { - resultObj.put("reason", "unzipCSAR filePath is null."); - resultObj.put("retCode", Constant.REST_FAIL); + resultObj.put(Constant.REASON, "unzipCSAR filePath is null."); + resultObj.put(Constant.RETCODE, Constant.REST_FAIL); return resultObj; } int status = DownloadCsarManager.unzipCSAR(fileName, filePath); if(Constant.UNZIP_SUCCESS == status) { - resultObj.put("reason", "unzip csar file successfully."); - resultObj.put("retCode", Constant.REST_SUCCESS); + resultObj.put(Constant.REASON, "unzip csar file successfully."); + resultObj.put(Constant.RETCODE, Constant.REST_SUCCESS); } else { - resultObj.put("reason", "unzip csar file failed."); - resultObj.put("retCode", Constant.REST_FAIL); + resultObj.put(Constant.REASON, "unzip csar file failed."); + resultObj.put(Constant.RETCODE, Constant.REST_FAIL); } return resultObj; } diff --git a/huawei/vnfmadapter/VnfmadapterService/service/src/main/java/org/onap/vfc/nfvo/vnfm/svnfm/vnfmadapter/service/adapter/impl/Driver2MSBManager.java b/huawei/vnfmadapter/VnfmadapterService/service/src/main/java/org/onap/vfc/nfvo/vnfm/svnfm/vnfmadapter/service/adapter/impl/Driver2MSBManager.java index de9bad19..12e0d8a3 100644 --- a/huawei/vnfmadapter/VnfmadapterService/service/src/main/java/org/onap/vfc/nfvo/vnfm/svnfm/vnfmadapter/service/adapter/impl/Driver2MSBManager.java +++ b/huawei/vnfmadapter/VnfmadapterService/service/src/main/java/org/onap/vfc/nfvo/vnfm/svnfm/vnfmadapter/service/adapter/impl/Driver2MSBManager.java @@ -1,5 +1,5 @@ /* - * Copyright 2016 Huawei Technologies Co., Ltd. + * Copyright 2016-2017 Huawei Technologies Co., Ltd. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -18,23 +18,22 @@ package org.onap.vfc.nfvo.vnfm.svnfm.vnfmadapter.service.adapter.impl; import java.util.Map; +import org.onap.vfc.nfvo.vnfm.svnfm.vnfmadapter.common.restclient.RestfulResponse; import org.onap.vfc.nfvo.vnfm.svnfm.vnfmadapter.common.servicetoken.VNFRestfulUtil; import org.onap.vfc.nfvo.vnfm.svnfm.vnfmadapter.service.adapter.inf.IDriver2MSBManager; import org.onap.vfc.nfvo.vnfm.svnfm.vnfmadapter.service.constant.Constant; -import org.onap.vfc.nfvo.vnfm.svnfm.vnfmadapter.common.restclient.RestfulResponse; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import net.sf.json.JSONObject; /** - * * Driver to MSB Manager Class.<br/> * <p> * </p> * * @author - * @version VFC 1.0 Aug 29, 2016 + * @version VFC 1.0 Aug 29, 2016 */ public class Driver2MSBManager implements IDriver2MSBManager { @@ -47,8 +46,8 @@ public class Driver2MSBManager implements IDriver2MSBManager { RestfulResponse rsp = VNFRestfulUtil.getRemoteResponse(paramsMap, driverInfo.toString()); if(null == rsp) { LOG.error("function=registerDriver, RestfulResponse is null"); - resultObj.put("reason", "RestfulResponse is null."); - resultObj.put("retCode", Constant.REST_FAIL); + resultObj.put(Constant.REASON, "RestfulResponse is null."); + resultObj.put(Constant.RETCODE, Constant.REST_FAIL); return resultObj; } String resultCreate = rsp.getResponseContent(); @@ -56,18 +55,18 @@ public class Driver2MSBManager implements IDriver2MSBManager { if(rsp.getStatus() == Constant.HTTP_CREATED) { LOG.warn("function=registerDriver, msg= status={}, result={}.", rsp.getStatus(), resultCreate); resultObj = JSONObject.fromObject(resultCreate); - resultObj.put("retCode", Constant.HTTP_CREATED); + resultObj.put(Constant.RETCODE, Constant.HTTP_CREATED); return resultObj; } else if(rsp.getStatus() == Constant.HTTP_INVALID_PARAMETERS) { LOG.error("function=registerDriver, msg=MSB return fail,invalid parameters,status={}, result={}.", rsp.getStatus(), resultCreate); - resultObj.put("reason", "MSB return fail,invalid parameters."); + resultObj.put(Constant.REASON, "MSB return fail,invalid parameters."); } else if(rsp.getStatus() == Constant.HTTP_INNERERROR) { LOG.error("function=registerDriver, msg=MSB return fail,internal system error,status={}, result={}.", rsp.getStatus(), resultCreate); - resultObj.put("reason", "MSB return fail,internal system error."); + resultObj.put(Constant.REASON, "MSB return fail,internal system error."); } - resultObj.put("retCode", Constant.REST_FAIL); + resultObj.put(Constant.RETCODE, Constant.REST_FAIL); return resultObj; } @@ -78,8 +77,8 @@ public class Driver2MSBManager implements IDriver2MSBManager { RestfulResponse rsp = VNFRestfulUtil.getRemoteResponse(paramsMap, ""); if(null == rsp) { LOG.error("function=unregisterDriver, RestfulResponse is null"); - resultObj.put("reason", "RestfulResponse is null."); - resultObj.put("retCode", Constant.REST_FAIL); + resultObj.put(Constant.REASON, "RestfulResponse is null."); + resultObj.put(Constant.RETCODE, Constant.REST_FAIL); return resultObj; } String resultCreate = rsp.getResponseContent(); @@ -87,23 +86,23 @@ public class Driver2MSBManager implements IDriver2MSBManager { if(rsp.getStatus() == Constant.HTTP_NOCONTENT) { LOG.warn("function=unregisterDriver, msg= status={}, result={}.", rsp.getStatus(), resultCreate); resultObj = JSONObject.fromObject(resultCreate); - resultObj.put("retCode", Constant.HTTP_NOCONTENT); + resultObj.put(Constant.RETCODE, Constant.HTTP_NOCONTENT); return resultObj; } else if(rsp.getStatus() == Constant.HTTP_NOTFOUND) { LOG.error( "function=unregisterDriver, msg=MSB return fail,can't find the service instance.status={}, result={}.", rsp.getStatus(), resultCreate); - resultObj.put("reason", "MSB return fail,can't find the service instance."); + resultObj.put(Constant.REASON, "MSB return fail,can't find the service instance."); } else if(rsp.getStatus() == Constant.HTTP_INVALID_PARAMETERS) { LOG.error("function=unregisterDriver, msg=MSB return fail,invalid parameters,status={}, result={}.", rsp.getStatus(), resultCreate); - resultObj.put("reason", "MSB return fail,invalid parameters."); + resultObj.put(Constant.REASON, "MSB return fail,invalid parameters."); } else if(rsp.getStatus() == Constant.HTTP_INNERERROR) { LOG.error("function=unregisterDriver, msg=MSB return fail,internal system error,status={}, result={}.", rsp.getStatus(), resultCreate); - resultObj.put("reason", "MSB return fail,internal system error."); + resultObj.put(Constant.REASON, "MSB return fail,internal system error."); } - resultObj.put("retCode", Constant.REST_FAIL); + resultObj.put(Constant.RETCODE, Constant.REST_FAIL); return resultObj; } diff --git a/huawei/vnfmadapter/VnfmadapterService/service/src/main/java/org/onap/vfc/nfvo/vnfm/svnfm/vnfmadapter/service/adapter/impl/VnfmAdapter2DriverManager.java b/huawei/vnfmadapter/VnfmadapterService/service/src/main/java/org/onap/vfc/nfvo/vnfm/svnfm/vnfmadapter/service/adapter/impl/VnfmAdapter2DriverManager.java index 8bd6d5a6..b8767333 100644 --- a/huawei/vnfmadapter/VnfmadapterService/service/src/main/java/org/onap/vfc/nfvo/vnfm/svnfm/vnfmadapter/service/adapter/impl/VnfmAdapter2DriverManager.java +++ b/huawei/vnfmadapter/VnfmadapterService/service/src/main/java/org/onap/vfc/nfvo/vnfm/svnfm/vnfmadapter/service/adapter/impl/VnfmAdapter2DriverManager.java @@ -18,10 +18,10 @@ package org.onap.vfc.nfvo.vnfm.svnfm.vnfmadapter.service.adapter.impl; import java.util.Map; +import org.onap.vfc.nfvo.vnfm.svnfm.vnfmadapter.common.restclient.RestfulResponse; import org.onap.vfc.nfvo.vnfm.svnfm.vnfmadapter.common.servicetoken.VNFRestfulUtil; import org.onap.vfc.nfvo.vnfm.svnfm.vnfmadapter.service.adapter.inf.IVnfmAdapter2DriverManager; import org.onap.vfc.nfvo.vnfm.svnfm.vnfmadapter.service.constant.Constant; -import org.onap.vfc.nfvo.vnfm.svnfm.vnfmadapter.common.restclient.RestfulResponse; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -46,27 +46,27 @@ public class VnfmAdapter2DriverManager implements IVnfmAdapter2DriverManager { RestfulResponse rsp = VNFRestfulUtil.getRemoteResponse(paramsMap, driverInfo.toString()); if(null == rsp) { LOG.error("function=registerDriver, RestfulResponse is null"); - resultObj.put("reason", "RestfulResponse is null."); - resultObj.put("retCode", Constant.REST_FAIL); + resultObj.put(Constant.REASON, "RestfulResponse is null."); + resultObj.put(Constant.RETCODE, Constant.REST_FAIL); return resultObj; } String resultCreate = rsp.getResponseContent(); if(rsp.getStatus() == Constant.HTTP_CREATED) { LOG.warn("function=registerDriver, msg= status={}, result={}.", rsp.getStatus(), resultCreate); - resultObj.put("retCode", Constant.HTTP_CREATED); + resultObj.put(Constant.RETCODE, Constant.HTTP_CREATED); return resultObj; } else if(rsp.getStatus() == Constant.HTTP_INVALID_PARAMETERS) { LOG.error("function=registerDriver, msg=DriverManager return fail,invalid parameters,status={}, result={}.", rsp.getStatus(), resultCreate); - resultObj.put("reason", "DriverManager return fail,invalid parameters."); + resultObj.put(Constant.REASON, "DriverManager return fail,invalid parameters."); } else if(rsp.getStatus() == Constant.HTTP_INNERERROR) { LOG.error( "function=registerDriver, msg=DriverManager return fail,internal system error,status={}, result={}.", rsp.getStatus(), resultCreate); - resultObj.put("reason", "DriverManager return fail,internal system error."); + resultObj.put(Constant.REASON, "DriverManager return fail,internal system error."); } - resultObj.put("retCode", Constant.REST_FAIL); + resultObj.put(Constant.RETCODE, Constant.REST_FAIL); return resultObj; } @@ -77,8 +77,8 @@ public class VnfmAdapter2DriverManager implements IVnfmAdapter2DriverManager { RestfulResponse rsp = VNFRestfulUtil.getRemoteResponse(paramsMap, ""); if(null == rsp) { LOG.error("function=unregisterDriver, RestfulResponse is null"); - resultObj.put("reason", "RestfulResponse is null."); - resultObj.put("retCode", Constant.REST_FAIL); + resultObj.put(Constant.REASON, "RestfulResponse is null."); + resultObj.put(Constant.RETCODE, Constant.REST_FAIL); return resultObj; } String resultCreate = rsp.getResponseContent(); @@ -86,25 +86,25 @@ public class VnfmAdapter2DriverManager implements IVnfmAdapter2DriverManager { if(rsp.getStatus() == Constant.HTTP_NOCONTENT) { LOG.warn("function=unregisterDriver, msg= status={}, result={}.", rsp.getStatus(), resultCreate); resultObj = JSONObject.fromObject(resultCreate); - resultObj.put("retCode", Constant.HTTP_NOCONTENT); + resultObj.put(Constant.RETCODE, Constant.HTTP_NOCONTENT); return resultObj; } else if(rsp.getStatus() == Constant.HTTP_NOTFOUND) { LOG.error( "function=unregisterDriver, msg=DriverManager return fail,can't find the service instance.status={}, result={}.", rsp.getStatus(), resultCreate); - resultObj.put("reason", "DriverManager return fail,can't find the service instance."); + resultObj.put(Constant.REASON, "DriverManager return fail,can't find the service instance."); } else if(rsp.getStatus() == Constant.HTTP_INVALID_PARAMETERS) { LOG.error( "function=unregisterDriver, msg=DriverManager return fail,invalid parameters,status={}, result={}.", rsp.getStatus(), resultCreate); - resultObj.put("reason", "DriverManager return fail,invalid parameters."); + resultObj.put(Constant.REASON, "DriverManager return fail,invalid parameters."); } else if(rsp.getStatus() == Constant.HTTP_INNERERROR) { LOG.error( "function=unregisterDriver, msg=DriverManager return fail,internal system error,status={}, result={}.", rsp.getStatus(), resultCreate); - resultObj.put("reason", "DriverManager return fail,internal system error."); + resultObj.put(Constant.REASON, "DriverManager return fail,internal system error."); } - resultObj.put("retCode", Constant.REST_FAIL); + resultObj.put(Constant.RETCODE, Constant.REST_FAIL); return resultObj; } diff --git a/huawei/vnfmadapter/VnfmadapterService/service/src/main/java/org/onap/vfc/nfvo/vnfm/svnfm/vnfmadapter/service/api/internalsvc/impl/VnfmAdapter2DriverMgrService.java b/huawei/vnfmadapter/VnfmadapterService/service/src/main/java/org/onap/vfc/nfvo/vnfm/svnfm/vnfmadapter/service/api/internalsvc/impl/VnfmAdapter2DriverMgrService.java index a13d57c1..fb5e5b81 100644 --- a/huawei/vnfmadapter/VnfmadapterService/service/src/main/java/org/onap/vfc/nfvo/vnfm/svnfm/vnfmadapter/service/api/internalsvc/impl/VnfmAdapter2DriverMgrService.java +++ b/huawei/vnfmadapter/VnfmadapterService/service/src/main/java/org/onap/vfc/nfvo/vnfm/svnfm/vnfmadapter/service/api/internalsvc/impl/VnfmAdapter2DriverMgrService.java @@ -153,11 +153,12 @@ public class VnfmAdapter2DriverMgrService implements IVnfmAdapter2DriverMgrServi private void sendRequest(Map<String, String> paramsMap, JSONObject driverInfo) { JSONObject resultObj = adapter2DriverMgr.registerDriver(paramsMap, driverInfo); - if(Integer.valueOf(resultObj.get("retCode").toString()) == Constant.HTTP_CREATED) { + if(Integer.valueOf(resultObj.get(Constant.RETCODE).toString()) == Constant.HTTP_CREATED) { LOG.info("Vnfmadapter has now Successfully Registered to the Driver Manager!"); } else { LOG.error("Vnfmadapter failed to Register to the Driver Manager! Reason:" - + resultObj.get("reason").toString() + " retCode:" + resultObj.get("retCode").toString()); + + resultObj.get(Constant.REASON).toString() + " retCode:" + + resultObj.get(Constant.RETCODE).toString()); // if registration fails,wait one minute and try again try { diff --git a/huawei/vnfmadapter/VnfmadapterService/service/src/main/java/org/onap/vfc/nfvo/vnfm/svnfm/vnfmadapter/service/api/internalsvc/impl/VnfmAdapterMgrService.java b/huawei/vnfmadapter/VnfmadapterService/service/src/main/java/org/onap/vfc/nfvo/vnfm/svnfm/vnfmadapter/service/api/internalsvc/impl/VnfmAdapterMgrService.java index 30f71b0b..3afdafeb 100644 --- a/huawei/vnfmadapter/VnfmadapterService/service/src/main/java/org/onap/vfc/nfvo/vnfm/svnfm/vnfmadapter/service/api/internalsvc/impl/VnfmAdapterMgrService.java +++ b/huawei/vnfmadapter/VnfmadapterService/service/src/main/java/org/onap/vfc/nfvo/vnfm/svnfm/vnfmadapter/service/api/internalsvc/impl/VnfmAdapterMgrService.java @@ -152,11 +152,12 @@ public class VnfmAdapterMgrService implements IVnfmAdapterMgrService { private void sendRequest(Map<String, String> paramsMap, JSONObject driverInfo) { JSONObject resultObj = adapter2MSBMgr.registerDriver(paramsMap, driverInfo); - if(Integer.valueOf(resultObj.get("retCode").toString()) == Constant.HTTP_CREATED) { + if(Integer.valueOf(resultObj.get(Constant.RETCODE).toString()) == Constant.HTTP_CREATED) { LOG.info("Vnfmadapter has now Successfully Registered to the Microservice BUS!"); } else { LOG.error("Vnfmadapter failed to Register to the Microservice BUS! Reason:" - + resultObj.get("reason").toString() + " retCode:" + resultObj.get("retCode").toString()); + + resultObj.get(Constant.REASON).toString() + " retCode:" + + resultObj.get(Constant.RETCODE).toString()); // if registration fails,wait one minute and try again try { diff --git a/huawei/vnfmadapter/VnfmadapterService/service/src/main/java/org/onap/vfc/nfvo/vnfm/svnfm/vnfmadapter/service/process/AuthMgr.java b/huawei/vnfmadapter/VnfmadapterService/service/src/main/java/org/onap/vfc/nfvo/vnfm/svnfm/vnfmadapter/service/process/AuthMgr.java index 545bf7a5..2a4ac49d 100644 --- a/huawei/vnfmadapter/VnfmadapterService/service/src/main/java/org/onap/vfc/nfvo/vnfm/svnfm/vnfmadapter/service/process/AuthMgr.java +++ b/huawei/vnfmadapter/VnfmadapterService/service/src/main/java/org/onap/vfc/nfvo/vnfm/svnfm/vnfmadapter/service/process/AuthMgr.java @@ -1,5 +1,5 @@ /* - * Copyright 2016 Huawei Technologies Co., Ltd. + * Copyright 2016-2017 Huawei Technologies Co., Ltd. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -67,8 +67,8 @@ public class AuthMgr { addInfo.put("expires", 10); addInfo.put("passwdStatus", "expiring"); authResult.put("additionalInfo", addInfo); - restJson.put("retCode", Constant.REST_SUCCESS); + restJson.put(Constant.RETCODE, Constant.REST_SUCCESS); restJson.put("data", authResult); return restJson; } -}
\ No newline at end of file +} diff --git a/huawei/vnfmadapter/VnfmadapterService/service/src/main/java/org/onap/vfc/nfvo/vnfm/svnfm/vnfmadapter/service/rest/AuthRoa.java b/huawei/vnfmadapter/VnfmadapterService/service/src/main/java/org/onap/vfc/nfvo/vnfm/svnfm/vnfmadapter/service/rest/AuthRoa.java index 40972053..afcf1235 100644 --- a/huawei/vnfmadapter/VnfmadapterService/service/src/main/java/org/onap/vfc/nfvo/vnfm/svnfm/vnfmadapter/service/rest/AuthRoa.java +++ b/huawei/vnfmadapter/VnfmadapterService/service/src/main/java/org/onap/vfc/nfvo/vnfm/svnfm/vnfmadapter/service/rest/AuthRoa.java @@ -1,5 +1,5 @@ /* - * Copyright 2016 Huawei Technologies Co., Ltd. + * Copyright 2016-2017 Huawei Technologies Co., Ltd. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -86,7 +86,7 @@ public class AuthRoa { JSONObject authResult = authMgr.authToken(subJsonObject); LOG.warn("authResult: {}", authResult); - if(authResult.getInt("retCode") == Constant.REST_SUCCESS) { + if(authResult.getInt(Constant.RETCODE) == Constant.REST_SUCCESS) { JSONObject data = authResult.getJSONObject("data"); resp.setStatus(Constant.HTTP_OK); @@ -94,7 +94,7 @@ public class AuthRoa { return data.toString();// String.format(ParamConstants.GET_TOKEN_SUC_RESP, // data.getString("userName"), // data.getString("userName"), data.getString("roaRand")); - } else if(authResult.getInt("retCode") == Constant.HTTP_INNERERROR) { + } else if(authResult.getInt(Constant.RETCODE) == Constant.HTTP_INNERERROR) { Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(authResult.getString("data")).build(); return String.format(ParamConstants.GET_TOKEN_FAIL_RESP, authResult.getString("data")); @@ -118,7 +118,7 @@ public class AuthRoa { @DELETE @Path("/auth/tokens/{userName}/{roarand}") public String delAuthToken(@Context HttpServletRequest context, @PathParam("userName") String userName, - @PathParam("roarand") String roarand, @Context HttpServletResponse resp) { + @PathParam("roarand") String roarand, @Context HttpServletResponse resp) { LOG.warn("function=logout, msg=enter to logout"); JSONObject resultJson = new JSONObject(); @@ -140,7 +140,7 @@ public class AuthRoa { @GET @Path("/nfvo/shakehand") public String shakehand(@Context HttpServletRequest context, @QueryParam("roattr") String roattr, - @Context HttpServletResponse resp) { + @Context HttpServletResponse resp) { JSONObject resultJson = new JSONObject(); resultJson.put("status", "running"); resultJson.put("description", "Operation success"); |