summaryrefslogtreecommitdiffstats
path: root/huawei
diff options
context:
space:
mode:
Diffstat (limited to 'huawei')
-rw-r--r--huawei/vnfmadapter/VnfmadapterService/service/src/main/java/org/onap/vfc/nfvo/vnfm/svnfm/vnfmadapter/common/ResultRequestUtil.java63
-rw-r--r--huawei/vnfmadapter/VnfmadapterService/service/src/main/java/org/onap/vfc/nfvo/vnfm/svnfm/vnfmadapter/common/restclient/RestHttpContentExchange.java8
-rw-r--r--huawei/vnfmadapter/VnfmadapterService/service/src/main/java/org/onap/vfc/nfvo/vnfm/svnfm/vnfmadapter/common/servicetoken/VNFRestfulUtil.java18
3 files changed, 54 insertions, 35 deletions
diff --git a/huawei/vnfmadapter/VnfmadapterService/service/src/main/java/org/onap/vfc/nfvo/vnfm/svnfm/vnfmadapter/common/ResultRequestUtil.java b/huawei/vnfmadapter/VnfmadapterService/service/src/main/java/org/onap/vfc/nfvo/vnfm/svnfm/vnfmadapter/common/ResultRequestUtil.java
index 6ee1ff28..cbf8f39c 100644
--- a/huawei/vnfmadapter/VnfmadapterService/service/src/main/java/org/onap/vfc/nfvo/vnfm/svnfm/vnfmadapter/common/ResultRequestUtil.java
+++ b/huawei/vnfmadapter/VnfmadapterService/service/src/main/java/org/onap/vfc/nfvo/vnfm/svnfm/vnfmadapter/common/ResultRequestUtil.java
@@ -43,6 +43,19 @@ public final class ResultRequestUtil {
private static final Logger LOG = LoggerFactory.getLogger(ResultRequestUtil.class);
+ private static final String CONNECT_FAIL = "connect fail.";
+
+ private static final String RESPONSE_STATUS = "function=call, msg=response status is {}. result is {}";
+
+ private static final String IOEXCEPTION = "function=call, msg=IOException, e is {}";
+
+ private static final String REFLECTIVEOPERATIONEXCEPTION =
+ "function=call, msg=ReflectiveOperationException, e is {}";
+
+ private static final String THROWABLE = "function=call, msg=Throwable, e is {}";
+
+ private static final String CONNECTION_ERROR = "get connection error";
+
private ResultRequestUtil() throws VnfmException {
throw new VnfmException("can't be instanced.");
}
@@ -69,7 +82,7 @@ public final class ResultRequestUtil {
if(Constant.HTTP_OK != mgrVcmm.connect(vnfmObject)) {
resultJson.put(Constant.RETCODE, Constant.HTTP_INNERERROR);
- resultJson.put("data", "connect fail.");
+ resultJson.put("data", CONNECT_FAIL);
return resultJson;
}
@@ -90,15 +103,15 @@ public final class ResultRequestUtil {
builder = (HttpRequests.Builder)mt.invoke();
httpMethod = builder.execute();
result = httpMethod.getResponseBodyAsString();
- LOG.warn("function=call, msg=response status is {}. result is {}", httpMethod.getStatusCode(), result);
+ LOG.warn(RESPONSE_STATUS, httpMethod.getStatusCode(), result);
resultJson.put(Constant.RETCODE, httpMethod.getStatusCode());
resultJson.put("data", result);
} catch(IOException e) {
- LOG.info("function=call, msg=IOException, e is {}", e);
+ LOG.info(IOEXCEPTION, e);
} catch(ReflectiveOperationException e) {
- LOG.info("function=call, msg=ReflectiveOperationException, e is {}", e);
+ LOG.info(REFLECTIVEOPERATIONEXCEPTION, e);
} catch(Throwable e) {
- LOG.info("function=call, msg=Throwable, e is {}", e);
+ LOG.info(THROWABLE, e);
} finally {
if(httpMethod != null) {
httpMethod.releaseConnection();
@@ -107,7 +120,7 @@ public final class ResultRequestUtil {
if(httpMethod == null) {
resultJson.put(Constant.RETCODE, Constant.HTTP_INNERERROR);
- resultJson.put("data", "get connection error");
+ resultJson.put("data", CONNECTION_ERROR);
}
return resultJson;
@@ -138,7 +151,7 @@ public final class ResultRequestUtil {
if(Constant.HTTP_OK != mgrVcmm.connect(vnfmObject, authModel)) {
resultJson.put(Constant.RETCODE, Constant.HTTP_INNERERROR);
- resultJson.put("data", "connect fail.");
+ resultJson.put("data", CONNECT_FAIL);
return resultJson;
}
@@ -159,7 +172,7 @@ public final class ResultRequestUtil {
builder = (HttpRequests.Builder)mt.invoke();
httpMethod = builder.execute();
result = httpMethod.getResponseBodyAsString();
- LOG.warn("function=call, msg=response status is {}. result is {}", httpMethod.getStatusCode(), result);
+ LOG.warn(RESPONSE_STATUS, httpMethod.getStatusCode(), result);
resultJson.put(Constant.RETCODE, httpMethod.getStatusCode());
resultJson.put("data", result);
@@ -170,11 +183,11 @@ public final class ResultRequestUtil {
String user = vnfmObject.getString(Constant.USERNAME);
removeTokens(vnfmUrl, token, roaRand, user);
} catch(IOException e) {
- LOG.info("function=call, msg=IOException, e is {}", e);
+ LOG.info(IOEXCEPTION, e);
} catch(ReflectiveOperationException e) {
- LOG.info("function=call, msg=ReflectiveOperationException, e is {}", e);
+ LOG.info(REFLECTIVEOPERATIONEXCEPTION, e);
} catch(Throwable e) {
- LOG.info("function=call, msg=Throwable, e is {}", e);
+ LOG.info(THROWABLE, e);
} finally {
if(httpMethod != null) {
httpMethod.releaseConnection();
@@ -183,7 +196,7 @@ public final class ResultRequestUtil {
if(httpMethod == null) {
resultJson.put(Constant.RETCODE, Constant.HTTP_INNERERROR);
- resultJson.put("data", "get connection error");
+ resultJson.put("data", CONNECTION_ERROR);
}
return resultJson;
@@ -200,14 +213,14 @@ public final class ResultRequestUtil {
LOG.info("removeTokens tokenUrl=" + tokenUrl);
try {
httpMethodToken = new HttpRequests.Builder(Constant.CERTIFICATE).setUrl(vnfmUrl.trim(), tokenUrl)
- .setParams("").addHeader("X-Auth-Token", token).delete().execute();
+ .setParams("").addHeader(Constant.X_AUTH_TOKEN, token).delete().execute();
int statusCode = httpMethodToken.getStatusCode();
String result = httpMethodToken.getResponseBodyAsString();
LOG.info("removeTokens int=" + statusCode + ", result=" + result);
} catch(IOException e) {
- LOG.info("function=call, msg=IOException, e is {}", e);
+ LOG.info(IOEXCEPTION, e);
} catch(Throwable e) {
- LOG.info("function=call, msg=Throwable, e is {}", e);
+ LOG.info(THROWABLE, e);
} finally {
if(httpMethodToken != null) {
httpMethodToken.releaseConnection();
@@ -236,7 +249,7 @@ public final class ResultRequestUtil {
if(Constant.HTTP_OK != mgrVcmm.connectSouth(vnfmObject, authModel)) {
resultJson.put(Constant.RETCODE, Constant.HTTP_INNERERROR);
- resultJson.put("data", "connect fail.");
+ resultJson.put("data", CONNECT_FAIL);
return resultJson;
}
@@ -251,7 +264,7 @@ public final class ResultRequestUtil {
LOG.info("function=callSouth, paramsJson is {}", paramsJson);
HttpRequests.Builder builder =
- new HttpRequests.Builder(authModel).addHeader("X-Auth-Token", mgrVcmm.getAccessSession())
+ new HttpRequests.Builder(authModel).addHeader(Constant.X_AUTH_TOKEN, mgrVcmm.getAccessSession())
.setUrl(newUrl, vnfPath).setParams(paramsJson);
MethodType methodType = MethodType.methodType(HttpRequests.Builder.class, new Class[0]);
MethodHandle mt =
@@ -260,7 +273,7 @@ public final class ResultRequestUtil {
builder = (HttpRequests.Builder)mt.invoke();
httpMethod = builder.execute();
result = httpMethod.getResponseBodyAsString();
- LOG.warn("function=call, msg=response status is {}. result is {}", httpMethod.getStatusCode(), result);
+ LOG.warn(RESPONSE_STATUS, httpMethod.getStatusCode(), result);
resultJson.put(Constant.RETCODE, httpMethod.getStatusCode());
resultJson.put("data", result);
@@ -269,11 +282,11 @@ public final class ResultRequestUtil {
String user = vnfmObject.getString(Constant.USERNAME);
removeV3Tokens(newUrl, token, user);
} catch(IOException e) {
- LOG.info("function=call, msg=IOException, e is {}", e);
+ LOG.info(IOEXCEPTION, e);
} catch(ReflectiveOperationException e) {
- LOG.info("function=call, msg=ReflectiveOperationException, e is {}", e);
+ LOG.info(REFLECTIVEOPERATIONEXCEPTION, e);
} catch(Throwable e) {
- LOG.info("function=call, msg=Throwable, e is {}", e);
+ LOG.info(THROWABLE, e);
} finally {
if(httpMethod != null) {
httpMethod.releaseConnection();
@@ -282,7 +295,7 @@ public final class ResultRequestUtil {
if(httpMethod == null) {
resultJson.put(Constant.RETCODE, Constant.HTTP_INNERERROR);
- resultJson.put("data", "get connection error");
+ resultJson.put("data", CONNECTION_ERROR);
}
return resultJson;
@@ -302,14 +315,14 @@ public final class ResultRequestUtil {
LOG.info("removeTokens tokenUrl=" + tokenUrl);
try {
httpMethodToken = new HttpRequests.Builder(Constant.CERTIFICATE).setUrl(vnfmUrl.trim(), tokenUrl)
- .setParams("").addHeader("X-Auth-Token", token).delete().execute();
+ .setParams("").addHeader(Constant.X_AUTH_TOKEN, token).delete().execute();
int statusCode = httpMethodToken.getStatusCode();
String result = httpMethodToken.getResponseBodyAsString();
LOG.info("removeTokens int=" + statusCode + ", result=" + result);
} catch(IOException e) {
- LOG.info("function=call, msg=IOException, e is {}", e);
+ LOG.info(IOEXCEPTION, e);
} catch(Throwable e) {
- LOG.info("function=call, msg=Throwable, e is {}", e);
+ LOG.info(THROWABLE, e);
} finally {
if(httpMethodToken != null) {
httpMethodToken.releaseConnection();
diff --git a/huawei/vnfmadapter/VnfmadapterService/service/src/main/java/org/onap/vfc/nfvo/vnfm/svnfm/vnfmadapter/common/restclient/RestHttpContentExchange.java b/huawei/vnfmadapter/VnfmadapterService/service/src/main/java/org/onap/vfc/nfvo/vnfm/svnfm/vnfmadapter/common/restclient/RestHttpContentExchange.java
index 076b5793..26d2ad57 100644
--- a/huawei/vnfmadapter/VnfmadapterService/service/src/main/java/org/onap/vfc/nfvo/vnfm/svnfm/vnfmadapter/common/restclient/RestHttpContentExchange.java
+++ b/huawei/vnfmadapter/VnfmadapterService/service/src/main/java/org/onap/vfc/nfvo/vnfm/svnfm/vnfmadapter/common/restclient/RestHttpContentExchange.java
@@ -48,6 +48,8 @@ public class RestHttpContentExchange extends ContentExchange {
private static final Logger LOGGER = LoggerFactory.getLogger(RestHttpContentExchange.class);
+ private static final String PATH = "path:";
+
private boolean gzip = false;
private RestfulAsyncCallback callback = null;
@@ -140,7 +142,7 @@ public class RestHttpContentExchange extends ContentExchange {
@Override
protected void onResponseComplete() throws IOException {
if(LOGGER.isInfoEnabled()) {
- LOGGER.info("Response has Complete:" + "path:" + this.getRequestURI().replace("\n", "0x0A"));
+ LOGGER.info("Response has Complete:" + PATH + this.getRequestURI().replace("\n", "0x0A"));
}
super.onResponseComplete();
if(callback != null) {
@@ -152,7 +154,7 @@ public class RestHttpContentExchange extends ContentExchange {
@Override
protected void onRequestCommitted() throws IOException {
if(LOGGER.isInfoEnabled()) {
- LOGGER.info("Request Header has been send:" + "path:" + this.getRequestURI().replace("\n", "0x0A"));
+ LOGGER.info("Request Header has been send:" + PATH + this.getRequestURI().replace("\n", "0x0A"));
}
super.onRequestCommitted();
}
@@ -160,7 +162,7 @@ public class RestHttpContentExchange extends ContentExchange {
@Override
protected void onRequestComplete() throws IOException {
if(LOGGER.isInfoEnabled()) {
- LOGGER.info("Request has bend send complete:" + "path:" + this.getRequestURI().replace("\n", "0x0A"));
+ LOGGER.info("Request has bend send complete:" + PATH + this.getRequestURI().replace("\n", "0x0A"));
}
super.onRequestComplete();
}
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 44f643f9..c3c1a5cc 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
@@ -61,6 +61,10 @@ public final class VNFRestfulUtil {
public static final String APPLICATION = "application/json";
+ public static final String METHODTYPE = "methodType";
+
+ public static final String AUTHMODE = "authMode";
+
private static final Logger LOG = LoggerFactory.getLogger(VNFRestfulUtil.class);
private VNFRestfulUtil() {
@@ -293,9 +297,9 @@ public final class VNFRestfulUtil {
public static RestfulResponse getRemoteResponse(Map<String, String> paramsMap, String params, String domainTokens,
boolean isNfvoApp) {
String utilUrl = paramsMap.get("url");
- String utilMethodType = paramsMap.get("methodType");
+ String utilMethodType = paramsMap.get(METHODTYPE);
String utilPath = paramsMap.get("path");
- String authMode = paramsMap.get("authMode");
+ String authMode = paramsMap.get(AUTHMODE);
RestfulResponse rsp = null;
Restful rest = null;
@@ -357,7 +361,7 @@ public final class VNFRestfulUtil {
return null;
}
String url = paramsMap.get("url");
- String methodType = paramsMap.get("methodType");
+ String methodType = paramsMap.get(METHODTYPE);
RestfulResponse rsp = null;
Restful rest = RestfulFactory.getRestInstance(RestfulFactory.PROTO_HTTP);
@@ -400,9 +404,9 @@ public final class VNFRestfulUtil {
public static Map<String, String> generateParamsMap(String url, String methodType, String path, String authMode) {
Map<String, String> utilParamsMap = new HashMap<>(6);
utilParamsMap.put("url", url);
- utilParamsMap.put("methodType", methodType);
+ utilParamsMap.put(METHODTYPE, methodType);
utilParamsMap.put("path", path);
- utilParamsMap.put("authMode", authMode);
+ utilParamsMap.put(AUTHMODE, authMode);
return utilParamsMap;
}
@@ -418,9 +422,9 @@ public final class VNFRestfulUtil {
public static Map<String, String> generateParamsMap(String url, String methodType, String path) {
Map<String, String> paramsMap = new HashMap<>(6);
paramsMap.put("url", url);
- paramsMap.put("methodType", methodType);
+ paramsMap.put(METHODTYPE, methodType);
paramsMap.put("path", path);
- paramsMap.put("authMode", "Certificate");
+ paramsMap.put(AUTHMODE, "Certificate");
return paramsMap;
}