aboutsummaryrefslogtreecommitdiffstats
path: root/vnfmarket-be/vnf-sdk-marketplace/src
diff options
context:
space:
mode:
authorHarry Huang <huangxiangyu5@huawei.com>2017-09-20 14:25:47 +0800
committerHarry Huang <huangxiangyu5@huawei.com>2017-09-20 15:43:22 +0800
commitf38eafa03133b30a208c6d8c5382afe0be6d4c7b (patch)
tree926fbd5af7e3b46cc5e2e27222a2d2264f11db74 /vnfmarket-be/vnf-sdk-marketplace/src
parentd4678af330009bcea6559874219bf3945a4cda3e (diff)
handler NullPointException
blocker: 154 Change-Id: I5aaf01ec555f9f846608eb36e578ff6960f3d6b6 Signed-off-by: Harry Huang <huangxiangyu5@huawei.com> Issue-Id: VNFSDK-85
Diffstat (limited to 'vnfmarket-be/vnf-sdk-marketplace/src')
-rw-r--r--vnfmarket-be/vnf-sdk-marketplace/src/main/java/org/onap/vnfsdk/marketplace/onboarding/hooks/validatelifecycle/LifecycleTestExceutor.java56
1 files changed, 32 insertions, 24 deletions
diff --git a/vnfmarket-be/vnf-sdk-marketplace/src/main/java/org/onap/vnfsdk/marketplace/onboarding/hooks/validatelifecycle/LifecycleTestExceutor.java b/vnfmarket-be/vnf-sdk-marketplace/src/main/java/org/onap/vnfsdk/marketplace/onboarding/hooks/validatelifecycle/LifecycleTestExceutor.java
index 38ca5794..21a61add 100644
--- a/vnfmarket-be/vnf-sdk-marketplace/src/main/java/org/onap/vnfsdk/marketplace/onboarding/hooks/validatelifecycle/LifecycleTestExceutor.java
+++ b/vnfmarket-be/vnf-sdk-marketplace/src/main/java/org/onap/vnfsdk/marketplace/onboarding/hooks/validatelifecycle/LifecycleTestExceutor.java
@@ -37,38 +37,38 @@ import com.fasterxml.jackson.databind.DeserializationFeature;
import com.fasterxml.jackson.databind.JsonMappingException;
import com.fasterxml.jackson.databind.ObjectMapper;
-public class LifecycleTestExceutor
+public class LifecycleTestExceutor
{
- private static final Logger logger = LoggerFactory.getLogger(LifecycleTestExceutor.class);
+ private static final Logger logger = LoggerFactory.getLogger(LifecycleTestExceutor.class);
public static final String CATALOUGE_UPLOAD_URL_IN = "{0}:{1}/openoapi/catalog/v1/csars";
private LifecycleTestExceutor()
{}
/**
- * Interface to Send Request to Start Function test
+ * Interface to Send Request to Start Function test
* @param onBoradFuncTestReq
* @return
*/
@SuppressWarnings("unchecked")
public static String uploadPackageToCatalouge(OnBoradingRequest onBoradFuncTestReq)
- {
+ {
String packagePath = onBoradFuncTestReq.getPackagePath() + File.separator + onBoradFuncTestReq.getPackageName();
logger.info("Package file path uploadPackageToCatalouge:" + packagePath);
- String catalougeCsarId = null;
+ String catalougeCsarId = null;
MsbDetails oMsbDetails = MsbDetailsHolder.getMsbDetails();
if(null == oMsbDetails)
{
logger.error("Failed to get MSB details during uploadPackageToCatalouge !!!");
return catalougeCsarId;
}
-
+
File fileData = new File (packagePath);
-
- MultipartEntityBuilder builder = MultipartEntityBuilder.create();
+
+ MultipartEntityBuilder builder = MultipartEntityBuilder.create();
builder.addBinaryBody("file", fileData, ContentType.MULTIPART_FORM_DATA, onBoradFuncTestReq.getPackageName());
-
+
//IP and Port needs to be configured !!!
RestResponse rsp = RestfulClient.post(oMsbDetails.getDefaultServer().getHost(),Integer.parseInt(oMsbDetails.getDefaultServer().getPort()),CommonConstant.CATALOUGE_UPLOAD_URL,builder.build());
if(!checkValidResponse(rsp))
@@ -79,16 +79,16 @@ public class LifecycleTestExceutor
logger.info("Response for uploadPackageToCatalouge :" + rsp.getResult());
catalougeCsarId = getCsarIdValue(rsp.getResult());
-
+
logger.info("CSARID for uploadPackageToCatalouge :" + catalougeCsarId);
- return catalougeCsarId;
+ return catalougeCsarId;
}
public static String execlifecycleTest(OnBoradingRequest onBoradFuncTestReq, LifeCycleTestReq oLifeCycleTestReq)
- {
+ {
String packagePath = onBoradFuncTestReq.getPackagePath() + File.separator + onBoradFuncTestReq.getPackageName();
logger.info("Package file path Function test:" + packagePath);
@@ -108,12 +108,12 @@ public class LifecycleTestExceutor
oMsbDetails.getDefaultServer().getPort(),
CommonConstant.LifeCycleTest.LIFECYCLE_TEST_URL, rawDataJson);
- if(!checkValidResponse(oResponse)) {
+ if(!checkValidResponse(oResponse)) {
logger.error("execlifecycleTest response is faliure :"+ oResponse.getStatusCode());
return null;
}
logger.info("Response execlifecycleTest :"+ oResponse.getResult());
- return oResponse.getResult();
+ return oResponse.getResult();
}
/**
@@ -121,29 +121,29 @@ public class LifecycleTestExceutor
* @param rsp
* @return
*/
- private static boolean checkValidResponse(RestResponse rsp)
+ private static boolean checkValidResponse(RestResponse rsp)
{
- if (rsp.getStatusCode() == null || rsp.getResult() == null
+ if (rsp.getStatusCode() == null || rsp.getResult() == null
|| (RestConstant.RESPONSE_CODE_200 != rsp.getStatusCode() && RestConstant.RESPONSE_CODE_201 != rsp.getStatusCode()))
{
return false;
}
return true;
- }
-
+ }
+
/**
- *
+ *
* @param strJsonData
* @return
*/
- private static String getCsarIdValue(String strJsonData)
+ private static String getCsarIdValue(String strJsonData)
{
ObjectMapper mapper = new ObjectMapper();
mapper.disable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES);
Map<String, String> dataMap = null;
- try
+ try
{
- dataMap = (Map<String, String>)mapper.readValue(strJsonData, Map.class);
+ dataMap = mapper.readValue(strJsonData, Map.class);
} catch(JsonParseException e) {
logger.error("JsonParseException:Failed to upload package to catalouge:", e);
} catch(JsonMappingException e) {
@@ -151,9 +151,17 @@ public class LifecycleTestExceutor
} catch(IOException e) {
logger.error("IOException:Failed to upload package to catalouge:", e);
}
- if(dataMap.get("csarId") != null){
- return dataMap.get("csarId");
+ try
+ {
+ if(dataMap != null) {
+ return dataMap.get("csarId");
+ }
+ }
+ catch (NullPointerException e)
+ {
+ logger.error("NullPointerException:Failed to get csarId", e);
}
return "";
}
}
+