summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--server/src/main/java/org/onap/usecaseui/server/controller/lcm/PackageDistributionController.java24
-rw-r--r--server/src/main/java/org/onap/usecaseui/server/service/lcm/PackageDistributionService.java2
-rw-r--r--server/src/main/java/org/onap/usecaseui/server/service/lcm/impl/DefaultPackageDistributionService.java22
-rw-r--r--server/src/test/java/org/onap/usecaseui/server/controller/lcm/PackageDistributionControllerTest.java7
-rw-r--r--server/src/test/java/org/onap/usecaseui/server/service/lcm/impl/DefaultPackageDistributionServiceTest.java12
5 files changed, 40 insertions, 27 deletions
diff --git a/server/src/main/java/org/onap/usecaseui/server/controller/lcm/PackageDistributionController.java b/server/src/main/java/org/onap/usecaseui/server/controller/lcm/PackageDistributionController.java
index f9654d84..3e314407 100644
--- a/server/src/main/java/org/onap/usecaseui/server/controller/lcm/PackageDistributionController.java
+++ b/server/src/main/java/org/onap/usecaseui/server/controller/lcm/PackageDistributionController.java
@@ -15,6 +15,7 @@
*/
package org.onap.usecaseui.server.controller.lcm;
+import java.text.ParseException;
import java.util.ArrayList;
import java.util.List;
@@ -22,7 +23,9 @@ import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import org.onap.usecaseui.server.bean.ServiceBean;
+import org.onap.usecaseui.server.bean.ServiceInstanceOperations;
import org.onap.usecaseui.server.bean.lcm.VfNsPackageInfo;
+import org.onap.usecaseui.server.constant.Constant;
import org.onap.usecaseui.server.service.lcm.PackageDistributionService;
import org.onap.usecaseui.server.service.lcm.ServiceLcmService;
import org.onap.usecaseui.server.service.lcm.domain.sdc.bean.SDCServiceTemplate;
@@ -31,6 +34,7 @@ import org.onap.usecaseui.server.service.lcm.domain.vfc.beans.Csar;
import org.onap.usecaseui.server.service.lcm.domain.vfc.beans.DistributionResult;
import org.onap.usecaseui.server.service.lcm.domain.vfc.beans.Job;
import org.onap.usecaseui.server.service.lcm.domain.vfc.beans.JobStatus;
+import org.onap.usecaseui.server.util.DateUtils;
import org.onap.usecaseui.server.util.UuiCommonUtil;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -117,20 +121,20 @@ public class PackageDistributionController {
public JobStatus getNsLcmJobStatus(@PathVariable(value="jobId") String jobId, HttpServletRequest request){
String responseId = request.getParameter("responseId");
String serviceInstanceId = request.getParameter("serviceInstanceId");
- JobStatus jobStatus = packageDistributionService.getNsLcmJobStatus(jobId, responseId);
+ String operationType = request.getParameter("operationType");
+ JobStatus jobStatus = packageDistributionService.getNsLcmJobStatus(serviceInstanceId,jobId, responseId,operationType);
if(UuiCommonUtil.isNotNullOrEmpty(jobStatus)&&UuiCommonUtil.isNotNullOrEmpty(jobStatus.getResponseDescriptor())&&UuiCommonUtil.isNotNullOrEmpty(jobStatus.getResponseDescriptor().getProgress())){
String processNum = jobStatus.getResponseDescriptor().getProgress();
- String status="processing";
+ String operationResult = Constant.IN_PROGRESS_CODE;
if(Integer.parseInt(processNum)==100){
- status = "finished";
+ operationResult = Constant.SUCCESS_CODE;
}else if(Integer.parseInt(processNum)>100){
- status="error";
- }else{
- status="processing";
+ operationResult=Constant.FAIL_CODE;
}
- serviceLcmService.updateServiceInstanceStatusById(status,serviceInstanceId);
+ serviceLcmService.updateServiceInstanceOperation(serviceInstanceId,operationType,processNum,operationResult);
}
return jobStatus;
+
}
@ResponseBody
@@ -240,7 +244,7 @@ public class PackageDistributionController {
}
@RequestMapping(value = {"/uui-lcm/instantiateNetworkServiceInstance"}, method = RequestMethod.POST , produces = "application/json")
- public String instantiateNetworkServiceInstance(HttpServletRequest request){
+ public String instantiateNetworkServiceInstance(HttpServletRequest request) throws ParseException{
String customerId = request.getParameter("customerId");
String serviceType = request.getParameter("serviceType");
String serviceDomain = request.getParameter("serviceDomain");
@@ -248,7 +252,9 @@ public class PackageDistributionController {
String object = packageDistributionService.instantiateNetworkServiceInstance(request,ns_instance_id);
JSONObject jobObject = JSONObject.parseObject(object);
String jobId = jobObject.getString("jobId");
- ServiceBean serviceBean = new ServiceBean(UuiCommonUtil.getUUID(),ns_instance_id,customerId,serviceType,serviceDomain,jobId,null,null);
+ ServiceBean serviceBean = new ServiceBean(UuiCommonUtil.getUUID(),ns_instance_id,customerId,serviceType,serviceDomain,null,null,null);
+ ServiceInstanceOperations serviceOpera = new ServiceInstanceOperations(ns_instance_id,jobId,Constant.CREATING_CODE,"0",Constant.IN_PROGRESS_CODE,DateUtils.dateToString(DateUtils.now()),null);
+ serviceLcmService.saveOrUpdateServiceInstanceOperation(serviceOpera);
serviceLcmService.saveOrUpdateServiceBean(serviceBean);
return object;
}
diff --git a/server/src/main/java/org/onap/usecaseui/server/service/lcm/PackageDistributionService.java b/server/src/main/java/org/onap/usecaseui/server/service/lcm/PackageDistributionService.java
index 2c89dadd..a4497f16 100644
--- a/server/src/main/java/org/onap/usecaseui/server/service/lcm/PackageDistributionService.java
+++ b/server/src/main/java/org/onap/usecaseui/server/service/lcm/PackageDistributionService.java
@@ -42,7 +42,7 @@ public interface PackageDistributionService {
JobStatus getJobStatus(String jobId, String responseId);
- JobStatus getNsLcmJobStatus(String jobId, String responseId);
+ JobStatus getNsLcmJobStatus(String serviceInstanceId,String jobId, String responseId,String operationType);
DistributionResult deleteNsPackage(String csarId);
diff --git a/server/src/main/java/org/onap/usecaseui/server/service/lcm/impl/DefaultPackageDistributionService.java b/server/src/main/java/org/onap/usecaseui/server/service/lcm/impl/DefaultPackageDistributionService.java
index 14ca9ed6..b5350d29 100644
--- a/server/src/main/java/org/onap/usecaseui/server/service/lcm/impl/DefaultPackageDistributionService.java
+++ b/server/src/main/java/org/onap/usecaseui/server/service/lcm/impl/DefaultPackageDistributionService.java
@@ -168,19 +168,17 @@ public class DefaultPackageDistributionService implements PackageDistributionSer
}
@Override
- public JobStatus getNsLcmJobStatus(String jobId, String responseId) {
- try {
- Response<JobStatus> response = vfcService.getNsLcmJobStatus(jobId, responseId).execute();
- if (response.isSuccessful()) {
- return response.body();
- } else {
- logger.info(String.format("Can not get Job status[code=%s, message=%s]", response.code(), response.message()));
- throw new VfcException("VFC service getNsLcmJobStatus is not available!");
- }
- } catch (IOException e) {
- throw new VfcException("VFC service getNsLcmJobStatus is not available!", e);
+ public JobStatus getNsLcmJobStatus(String serviceInstanceId,String jobId, String responseId,String operationType) { try {
+ Response<JobStatus> response = vfcService.getNsLcmJobStatus(jobId, responseId).execute();
+ if (response.isSuccessful()) {
+ return response.body();
+ } else {
+ logger.info(String.format("Can not get Job status[code=%s, message=%s]", response.code(), response.message()));
+ throw new VfcException("VFC service getNsLcmJobStatus is not available!");
}
- }
+ } catch (IOException e) {
+ throw new VfcException("VFC service getNsLcmJobStatus is not available!", e);
+ }}
@Override
public DistributionResult deleteNsPackage(String csarId) {
diff --git a/server/src/test/java/org/onap/usecaseui/server/controller/lcm/PackageDistributionControllerTest.java b/server/src/test/java/org/onap/usecaseui/server/controller/lcm/PackageDistributionControllerTest.java
index 1f19216f..11e670ba 100644
--- a/server/src/test/java/org/onap/usecaseui/server/controller/lcm/PackageDistributionControllerTest.java
+++ b/server/src/test/java/org/onap/usecaseui/server/controller/lcm/PackageDistributionControllerTest.java
@@ -27,6 +27,7 @@ import javax.servlet.http.HttpServletRequest;
import static org.mockito.Mockito.*;
import java.io.IOException;
+import java.text.ParseException;
public class PackageDistributionControllerTest {
@@ -121,10 +122,12 @@ public class PackageDistributionControllerTest {
public void testGetNsLcmJobStatus() throws IOException {
String csarId = "1";
String responseId="1";
+ String operationType="1";
+ String jobId="1";
HttpServletRequest request = mockRequest();
controller.getNsLcmJobStatus(csarId,request);
- verify(service, times(1)).getNsLcmJobStatus(csarId,responseId);
+ verify(service, times(1)).getNsLcmJobStatus(csarId,responseId,operationType,jobId);
}
@Test
@@ -294,7 +297,7 @@ public class PackageDistributionControllerTest {
}
@Test
- public void testInstantiateNetworkServiceInstance() throws IOException {
+ public void testInstantiateNetworkServiceInstance() throws IOException, ParseException {
String ns_instance_id="1";
HttpServletRequest request = mockRequest();
controller.instantiateNetworkServiceInstance(request);
diff --git a/server/src/test/java/org/onap/usecaseui/server/service/lcm/impl/DefaultPackageDistributionServiceTest.java b/server/src/test/java/org/onap/usecaseui/server/service/lcm/impl/DefaultPackageDistributionServiceTest.java
index 2e378e64..5a5f2b6f 100644
--- a/server/src/test/java/org/onap/usecaseui/server/service/lcm/impl/DefaultPackageDistributionServiceTest.java
+++ b/server/src/test/java/org/onap/usecaseui/server/service/lcm/impl/DefaultPackageDistributionServiceTest.java
@@ -250,11 +250,13 @@ public class DefaultPackageDistributionServiceTest {
VfcService vfcService = mock(VfcService.class);
String jobId = "1";
String responseId = "1";
+ String serviceId= "1";
+ String operationType= "1";
JobStatus jobStatus = new JobStatus();
when(vfcService.getNsLcmJobStatus(jobId, responseId)).thenReturn(successfulCall(jobStatus));
PackageDistributionService service = new DefaultPackageDistributionService(null, vfcService);
- Assert.assertSame(jobStatus, service.getNsLcmJobStatus(jobId, responseId));
+ Assert.assertSame(jobStatus, service.getNsLcmJobStatus(serviceId,jobId, responseId,operationType));
}
@Test(expected = VfcException.class)
@@ -262,9 +264,11 @@ public class DefaultPackageDistributionServiceTest {
VfcService vfcService = mock(VfcService.class);
String jobId = "1";
String responseId = "1";
+ String serviceId= "1";
+ String operationType= "1";
when(vfcService.getNsLcmJobStatus(jobId, responseId)).thenReturn(failedCall("VFC is not available!"));
PackageDistributionService service = new DefaultPackageDistributionService(null, vfcService);
- service.getNsLcmJobStatus(jobId, responseId);
+ service.getNsLcmJobStatus(serviceId,jobId, responseId,operationType);
}
@Test(expected = VfcException.class)
@@ -272,9 +276,11 @@ public class DefaultPackageDistributionServiceTest {
VfcService vfcService = mock(VfcService.class);
String jobId = "1";
String responseId = "1";
+ String serviceId= "1";
+ String operationType= "1";
when(vfcService.getNsLcmJobStatus(jobId, responseId)).thenReturn(emptyBodyCall());
PackageDistributionService service = new DefaultPackageDistributionService(null, vfcService);
- service.getNsLcmJobStatus(jobId, responseId);
+ service.getNsLcmJobStatus(serviceId,jobId, responseId,operationType);
}
@Test