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;
@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);
}
}
*/
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;
OperationProgressInformation queryOperationProgress(String serviceId, String operationId);
- ServiceOperation terminateService(String serviceId);
+ DeleteOperationRsp terminateService(String serviceId);
}
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;
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);
}
--- /dev/null
+/**
+ * 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;
+ }
+}
--- /dev/null
+/**
+ * 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;
+ }
+}
--- /dev/null
+/**
+ * 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;
+ }
+}
*/
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;
+ }
}
@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;
}
}
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;
}
@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 {
--- /dev/null
+/**
+ * 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("/**");
+ }
+}
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;
@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();
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)