Fix query operation progress issue. 97/20297/1
authorLuji7 <lu.ji3@zte.com.cn>
Tue, 24 Oct 2017 07:59:43 +0000 (15:59 +0800)
committerLuji7 <lu.ji3@zte.com.cn>
Tue, 24 Oct 2017 07:59:50 +0000 (15:59 +0800)
Change-Id: I0e2739ade583b3c6177dee4c8da5ebe06f591868
Issue-id: USECASEUI-53
Signed-off-by: Luji7 <lu.ji3@zte.com.cn>
server/src/main/java/org/onap/usecaseui/server/controller/lcm/ServiceLcmController.java
server/src/main/java/org/onap/usecaseui/server/service/lcm/ServiceLcmService.java
server/src/main/java/org/onap/usecaseui/server/service/lcm/domain/so/SOService.java
server/src/main/java/org/onap/usecaseui/server/service/lcm/domain/so/bean/DeleteOperationRsp.java [new file with mode: 0644]
server/src/main/java/org/onap/usecaseui/server/service/lcm/domain/so/bean/Operation.java [new file with mode: 0644]
server/src/main/java/org/onap/usecaseui/server/service/lcm/domain/so/bean/OperationProgress.java [new file with mode: 0644]
server/src/main/java/org/onap/usecaseui/server/service/lcm/domain/so/bean/OperationProgressInformation.java
server/src/main/java/org/onap/usecaseui/server/service/lcm/domain/so/bean/ServiceOperation.java
server/src/main/java/org/onap/usecaseui/server/service/lcm/impl/DefaultServiceLcmService.java
server/src/main/java/org/onap/usecaseui/server/wrapper/WebConfig.java [new file with mode: 0644]
server/src/test/java/org/onap/usecaseui/server/service/lcm/impl/DefaultServiceLcmServiceTest.java

index af6e1a4..2ef1c54 100644 (file)
@@ -16,6 +16,7 @@
 package org.onap.usecaseui.server.controller.lcm;
 
 import org.onap.usecaseui.server.service.lcm.ServiceLcmService;
+import org.onap.usecaseui.server.service.lcm.domain.so.bean.DeleteOperationRsp;
 import org.onap.usecaseui.server.service.lcm.domain.so.bean.OperationProgressInformation;
 import org.onap.usecaseui.server.service.lcm.domain.so.bean.ServiceOperation;
 import org.slf4j.Logger;
@@ -58,7 +59,7 @@ public class ServiceLcmController {
 
     @ResponseBody
     @RequestMapping(value = {"/uui-lcm/services/{serviceId}"}, method = RequestMethod.DELETE , produces = "application/json")
-    public ServiceOperation terminateService(@PathVariable(value = "serviceId") String serviceId){
+    public DeleteOperationRsp terminateService(@PathVariable(value = "serviceId") String serviceId){
         return serviceLcmService.terminateService(serviceId);
     }
 }
index 6ca22be..60efbbb 100644 (file)
@@ -15,6 +15,7 @@
  */
 package org.onap.usecaseui.server.service.lcm;
 
+import org.onap.usecaseui.server.service.lcm.domain.so.bean.DeleteOperationRsp;
 import org.onap.usecaseui.server.service.lcm.domain.so.bean.OperationProgressInformation;
 import org.onap.usecaseui.server.service.lcm.domain.so.bean.ServiceOperation;
 
@@ -26,5 +27,5 @@ public interface ServiceLcmService {
 
     OperationProgressInformation queryOperationProgress(String serviceId, String operationId);
 
-    ServiceOperation terminateService(String serviceId);
+    DeleteOperationRsp terminateService(String serviceId);
 }
index 917ec3f..6e06e01 100644 (file)
@@ -16,6 +16,7 @@
 package org.onap.usecaseui.server.service.lcm.domain.so;
 
 import okhttp3.RequestBody;
+import org.onap.usecaseui.server.service.lcm.domain.so.bean.DeleteOperationRsp;
 import org.onap.usecaseui.server.service.lcm.domain.so.bean.OperationProgressInformation;
 import org.onap.usecaseui.server.service.lcm.domain.so.bean.ServiceOperation;
 import retrofit2.Call;
@@ -23,12 +24,12 @@ import retrofit2.http.*;
 
 public interface SOService {
 
-    @POST("/api/so-e2eServiceInstances/v2")
+    @POST("/api/e2eServiceInstances/v3")
     Call<ServiceOperation> instantiateService(@Body RequestBody body);
 
-    @GET("/api/so-e2eServiceInstances/v2/{serviceId}/operations/{operationId}")
+    @GET("/api/e2eServiceInstances/v3/{serviceId}/operations/{operationId}")
     Call<OperationProgressInformation> queryOperationProgress(@Path("serviceId") String serviceId, @Path("operationId") String operationId);
 
-    @DELETE("/api/so-e2eServiceInstances/v2/{serviceId}")
-    Call<ServiceOperation> terminateService(@Path("serviceId") String serviceId);
+    @DELETE("/api/e2eServiceInstances/v3/{serviceId}")
+    Call<DeleteOperationRsp> terminateService(@Path("serviceId") String serviceId);
 }
diff --git a/server/src/main/java/org/onap/usecaseui/server/service/lcm/domain/so/bean/DeleteOperationRsp.java b/server/src/main/java/org/onap/usecaseui/server/service/lcm/domain/so/bean/DeleteOperationRsp.java
new file mode 100644 (file)
index 0000000..2c7cc11
--- /dev/null
@@ -0,0 +1,32 @@
+/**
+ * Copyright 2016-2017 ZTE Corporation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.onap.usecaseui.server.service.lcm.domain.so.bean;
+
+import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
+
+@JsonIgnoreProperties(ignoreUnknown=true)
+public class DeleteOperationRsp {
+
+    private String operationId;
+
+    public String getOperationId() {
+        return operationId;
+    }
+
+    public void setOperationId(String operationId) {
+        this.operationId = operationId;
+    }
+}
diff --git a/server/src/main/java/org/onap/usecaseui/server/service/lcm/domain/so/bean/Operation.java b/server/src/main/java/org/onap/usecaseui/server/service/lcm/domain/so/bean/Operation.java
new file mode 100644 (file)
index 0000000..93b1421
--- /dev/null
@@ -0,0 +1,42 @@
+/**
+ * Copyright 2016-2017 ZTE Corporation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.onap.usecaseui.server.service.lcm.domain.so.bean;
+
+import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
+
+@JsonIgnoreProperties(ignoreUnknown=true)
+public class Operation {
+
+    private String serviceId;
+
+    private String operationId;
+
+    public String getServiceId() {
+        return serviceId;
+    }
+
+    public void setServiceId(String serviceId) {
+        this.serviceId = serviceId;
+    }
+
+    public String getOperationId() {
+        return operationId;
+    }
+
+    public void setOperationId(String operationId) {
+        this.operationId = operationId;
+    }
+}
diff --git a/server/src/main/java/org/onap/usecaseui/server/service/lcm/domain/so/bean/OperationProgress.java b/server/src/main/java/org/onap/usecaseui/server/service/lcm/domain/so/bean/OperationProgress.java
new file mode 100644 (file)
index 0000000..12e8e11
--- /dev/null
@@ -0,0 +1,112 @@
+/**
+ * Copyright 2016-2017 ZTE Corporation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.onap.usecaseui.server.service.lcm.domain.so.bean;
+
+import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
+
+@JsonIgnoreProperties(ignoreUnknown=true)
+public class OperationProgress {
+
+    private String operationId;
+
+    private String operation;
+
+    private String result;
+
+    private String reason;
+
+    private String userId;
+
+    private String operationContent;
+
+    private int progress;
+
+    private String operateAt;
+
+    private String finishedAt;
+
+    public String getOperationId() {
+        return operationId;
+    }
+
+    public void setOperationId(String operationId) {
+        this.operationId = operationId;
+    }
+
+    public String getOperation() {
+        return operation;
+    }
+
+    public void setOperation(String operation) {
+        this.operation = operation;
+    }
+
+    public String getResult() {
+        return result;
+    }
+
+    public void setResult(String result) {
+        this.result = result;
+    }
+
+    public String getReason() {
+        return reason;
+    }
+
+    public void setReason(String reason) {
+        this.reason = reason;
+    }
+
+    public String getUserId() {
+        return userId;
+    }
+
+    public void setUserId(String userId) {
+        this.userId = userId;
+    }
+
+    public String getOperationContent() {
+        return operationContent;
+    }
+
+    public void setOperationContent(String operationContent) {
+        this.operationContent = operationContent;
+    }
+
+    public int getProgress() {
+        return progress;
+    }
+
+    public void setProgress(int progress) {
+        this.progress = progress;
+    }
+
+    public String getOperateAt() {
+        return operateAt;
+    }
+
+    public void setOperateAt(String operateAt) {
+        this.operateAt = operateAt;
+    }
+
+    public String getFinishedAt() {
+        return finishedAt;
+    }
+
+    public void setFinishedAt(String finishedAt) {
+        this.finishedAt = finishedAt;
+    }
+}
index 3c70452..2cf20ad 100644 (file)
  */
 package org.onap.usecaseui.server.service.lcm.domain.so.bean;
 
+import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
+
+@JsonIgnoreProperties(ignoreUnknown=true)
 public class OperationProgressInformation {
+
+    private OperationProgress operation;
+
+    public OperationProgress getOperation() {
+        return operation;
+    }
+
+    public void setOperation(OperationProgress operation) {
+        this.operation = operation;
+    }
 }
index 0a52341..8602040 100644 (file)
@@ -20,20 +20,13 @@ import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
 @JsonIgnoreProperties(ignoreUnknown=true)
 public class ServiceOperation {
 
-    private String serviceId;
+    private Operation service;
 
-    private String operationId;
-
-    public ServiceOperation(String serviceId, String operationId) {
-        this.serviceId = serviceId;
-        this.operationId = operationId;
-    }
-
-    public String getServiceId() {
-        return serviceId;
+    public Operation getService() {
+        return service;
     }
 
-    public String getOperationId() {
-        return operationId;
+    public void setService(Operation service) {
+        this.service = service;
     }
 }
index d55712a..eef13e8 100644 (file)
@@ -18,6 +18,7 @@ package org.onap.usecaseui.server.service.lcm.impl;
 import okhttp3.RequestBody;
 import org.onap.usecaseui.server.service.lcm.ServiceLcmService;
 import org.onap.usecaseui.server.service.lcm.domain.so.SOService;
+import org.onap.usecaseui.server.service.lcm.domain.so.bean.DeleteOperationRsp;
 import org.onap.usecaseui.server.service.lcm.domain.so.bean.OperationProgressInformation;
 import org.onap.usecaseui.server.service.lcm.domain.so.bean.ServiceOperation;
 import org.onap.usecaseui.server.service.lcm.domain.so.exceptions.SOException;
@@ -83,9 +84,9 @@ public class DefaultServiceLcmService implements ServiceLcmService {
     }
 
     @Override
-    public ServiceOperation terminateService(String serviceId) {
+    public DeleteOperationRsp terminateService(String serviceId) {
         try {
-            Response<ServiceOperation> response = soService.terminateService(serviceId).execute();
+            Response<DeleteOperationRsp> response = soService.terminateService(serviceId).execute();
             if (response.isSuccessful()) {
                 return response.body();
             } else {
diff --git a/server/src/main/java/org/onap/usecaseui/server/wrapper/WebConfig.java b/server/src/main/java/org/onap/usecaseui/server/wrapper/WebConfig.java
new file mode 100644 (file)
index 0000000..f6475cc
--- /dev/null
@@ -0,0 +1,31 @@
+/**
+ * Copyright 2016-2017 ZTE Corporation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.onap.usecaseui.server.wrapper;
+
+import org.springframework.context.annotation.Configuration;
+import org.springframework.web.servlet.config.annotation.CorsRegistry;
+import org.springframework.web.servlet.config.annotation.EnableWebMvc;
+import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;
+
+@Configuration
+@EnableWebMvc
+public class WebConfig extends WebMvcConfigurerAdapter {
+
+    @Override
+    public void addCorsMappings(CorsRegistry registry) {
+        registry.addMapping("/**");
+    }
+}
index e086dd4..5031d24 100644 (file)
@@ -19,6 +19,8 @@ import org.junit.Assert;
 import org.junit.Test;
 import org.onap.usecaseui.server.service.lcm.ServiceLcmService;
 import org.onap.usecaseui.server.service.lcm.domain.so.SOService;
+import org.onap.usecaseui.server.service.lcm.domain.so.bean.DeleteOperationRsp;
+import org.onap.usecaseui.server.service.lcm.domain.so.bean.Operation;
 import org.onap.usecaseui.server.service.lcm.domain.so.bean.OperationProgressInformation;
 import org.onap.usecaseui.server.service.lcm.domain.so.bean.ServiceOperation;
 import org.onap.usecaseui.server.service.lcm.domain.so.exceptions.SOException;
@@ -39,7 +41,11 @@ public class DefaultServiceLcmServiceTest {
     @Test
     public void itCanInstantiateService() throws IOException {
         SOService soService = mock(SOService.class);
-        ServiceOperation operation = new ServiceOperation("1", "1");
+        Operation op = new Operation();
+        op.setOperationId("1");
+        op.setServiceId("1");
+        ServiceOperation operation = new ServiceOperation();
+        operation.setService(op);
         when(soService.instantiateService(anyObject())).thenReturn(successfulCall(operation));
 
         HttpServletRequest request = mockRequest();
@@ -92,12 +98,13 @@ public class DefaultServiceLcmServiceTest {
     public void itCanTerminateService() {
         SOService soService = mock(SOService.class);
         String serviceId = "1";
-        ServiceOperation operation = new ServiceOperation("1", "1");
-        when(soService.terminateService(serviceId)).thenReturn(successfulCall(operation));
+        DeleteOperationRsp rsp = new DeleteOperationRsp();
+        rsp.setOperationId("1");
+        when(soService.terminateService(serviceId)).thenReturn(successfulCall(rsp));
 
         ServiceLcmService service = new DefaultServiceLcmService(soService);
 
-        Assert.assertSame(operation, service.terminateService(serviceId));
+        Assert.assertSame(rsp, service.terminateService(serviceId));
     }
 
     @Test(expected = SOException.class)