Add query job status from vnfm 47/30447/1
authorluxin <luxin7@huawei.com>
Tue, 6 Feb 2018 11:48:30 +0000 (19:48 +0800)
committerluxin <luxin7@huawei.com>
Tue, 6 Feb 2018 11:48:30 +0000 (19:48 +0800)
Change-Id: Ie66a58061ac25e0b1d0713aab7855f2f6ec2ac23
Issue-ID: VFC-749
Signed-off-by: luxin <luxin7@huawei.com>
huawei/vnfmadapter/VnfmadapterService/service/src/main/java/org/onap/vfc/nfvo/vnfm/svnfm/vnfmadapter/service/csm/vnf/VnfMgrVnfm.java

index d1508ba..fae1e98 100644 (file)
@@ -19,6 +19,7 @@ package org.onap.vfc.nfvo.vnfm.svnfm.vnfmadapter.service.csm.vnf;
 import org.onap.vfc.nfvo.vnfm.svnfm.vnfmadapter.common.ResultRequestUtil;
 import org.onap.vfc.nfvo.vnfm.svnfm.vnfmadapter.service.constant.Constant;
 import org.onap.vfc.nfvo.vnfm.svnfm.vnfmadapter.service.constant.ParamConstants;
+import org.onap.vfc.nfvo.vnfm.svnfm.vnfmadapter.service.constant.UrlConstant;
 import org.onap.vfc.nfvo.vnfm.svnfm.vnfmadapter.service.csm.inf.InterfaceVnfMgr;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -265,4 +266,27 @@ public class VnfMgrVnfm implements InterfaceVnfMgr {
 
         return restJson;
     }
+
+    public JSONObject getJobFromVnfm(JSONObject vnfmObjcet, String jobId) {
+        LOG.warn("function=getJobFromVnfm, jobId: {}", jobId);
+        JSONObject restJson = new JSONObject();
+        restJson.put(Constant.RETCODE, Constant.REST_FAIL);
+
+        JSONObject queryResult = ResultRequestUtil.call(vnfmObjcet, String.format(UrlConstant.URL_JOBSTATUS_GET, jobId),
+                Constant.GET, null, Constant.CERTIFICATE);
+
+        int statusCode = queryResult.getInt(Constant.RETCODE);
+        if(statusCode == Constant.HTTP_OK || statusCode == Constant.HTTP_CREATED) {
+            if((queryResult.get("data")) == null) {
+                LOG.warn("function=getJobFromVnfm, msg=query is null {}", queryResult.get("data"));
+                return restJson;
+            }
+            restJson.put(Constant.RETCODE, Constant.REST_SUCCESS);
+            restJson.put("data", JSONObject.fromObject(queryResult.getString("data")));
+        } else {
+            LOG.error("function=getJobFromVnfm, msg=query job from vnfm wrong status: {}", statusCode);
+        }
+
+        return restJson;
+    }
 }