From f276f1c4215010b956ab2c7131358f9b5bfb5f92 Mon Sep 17 00:00:00 2001 From: 黄卓垚10112215 Date: Sat, 30 Sep 2017 09:45:45 +0800 Subject: remove odl dependence temporary Change-Id: I2d4348974badf6b4ecb255adb3ffa3b5c399d7e2 Issue-ID: SO-88 Signed-off-by: Zhuoyao Huang <10112215@zte.com.cn> description: Remove odl dependence temporary for docker deployment, utill the issue is be solved. Before that time, yang decoder is unavailable. --- bpmn/MSOInfrastructureBPMN/pom.xml | 4 +- .../SdncOperationTaskYangToolsImpl.java | 68 ---------- .../client/builder/AbstractBuilder.java | 80 +++++++++-- .../builder/NetworkTopologyRequestBodyBuilder.java | 147 --------------------- 4 files changed, 74 insertions(+), 225 deletions(-) delete mode 100644 bpmn/MSOInfrastructureBPMN/src/main/java/org/openecomp/mso/bpmn/infrastructure/workflow/serviceTask/SdncOperationTaskYangToolsImpl.java delete mode 100644 bpmn/MSOInfrastructureBPMN/src/main/java/org/openecomp/mso/bpmn/infrastructure/workflow/serviceTask/client/builder/NetworkTopologyRequestBodyBuilder.java (limited to 'bpmn') diff --git a/bpmn/MSOInfrastructureBPMN/pom.xml b/bpmn/MSOInfrastructureBPMN/pom.xml index be03cb44f5..3ca9c636a3 100644 --- a/bpmn/MSOInfrastructureBPMN/pom.xml +++ b/bpmn/MSOInfrastructureBPMN/pom.xml @@ -414,7 +414,7 @@ - + diff --git a/bpmn/MSOInfrastructureBPMN/src/main/java/org/openecomp/mso/bpmn/infrastructure/workflow/serviceTask/SdncOperationTaskYangToolsImpl.java b/bpmn/MSOInfrastructureBPMN/src/main/java/org/openecomp/mso/bpmn/infrastructure/workflow/serviceTask/SdncOperationTaskYangToolsImpl.java deleted file mode 100644 index 25727bdcd0..0000000000 --- a/bpmn/MSOInfrastructureBPMN/src/main/java/org/openecomp/mso/bpmn/infrastructure/workflow/serviceTask/SdncOperationTaskYangToolsImpl.java +++ /dev/null @@ -1,68 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * 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. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.mso.bpmn.infrastructure.workflow.serviceTask; - -import okhttp3.RequestBody; -import okhttp3.ResponseBody; -import org.camunda.bpm.engine.delegate.DelegateExecution; -import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.NetworkTopologyOperationOutput; -import org.openecomp.mso.bpmn.core.WorkflowException; -import org.openecomp.mso.bpmn.infrastructure.workflow.serviceTask.client.GenericResourceApi; -import org.openecomp.mso.bpmn.infrastructure.workflow.serviceTask.client.builder.NetworkTopologyRequestBodyBuilder; -import org.openecomp.mso.requestsdb.RequestsDbConstant; -import org.openecomp.mso.yangDecoder.transform.api.ITransformJava2StringService; -import org.openecomp.mso.yangDecoder.transform.impl.TransfromJava2StringFactory; - -import java.util.Map; - -/** - * Created by 10112215 on 2017/9/20. - */ -public class SdncOperationTaskYangToolsImpl extends AbstractSdncOperationTask { - - public void sendRestrequestAndHandleResponse(DelegateExecution execution, - Map inputs, - GenericResourceApi genericResourceApiClient) throws Exception { - updateProgress(execution, null, null, "40", "sendRestrequestAndHandleResponse begin!"); - NetworkTopologyRequestBodyBuilder builder = new NetworkTopologyRequestBodyBuilder(); - RequestBody body = builder.build(execution, inputs); - updateProgress(execution, null, null, "50", "RequestBody build finished!"); - ResponseBody responseBody = genericResourceApiClient.postNetworkTopologyOperation(body).execute().body(); - updateProgress(execution, null, null, "90", "sendRestrequestAndHandleResponse finished!"); - saveResponse(execution, responseBody); - } - - private void saveResponse(DelegateExecution execution, ResponseBody responseBody) throws Exception { - ITransformJava2StringService java2jsonService = TransfromJava2StringFactory.getJava2jsonService(); - NetworkTopologyOperationOutput output = (NetworkTopologyOperationOutput) java2jsonService. - transformRpcDataObjectFromString(NetworkTopologyRequestBodyBuilder.URI_PATH, responseBody.string()); - String responseCode = output.getResponseCode(); - if (!"200".equals(responseCode)) { - String processKey = getProcessKey(execution); - int errorCode = Integer.valueOf(responseCode); - String errorMessage = output.getResponseMessage(); - WorkflowException workflowException = new WorkflowException(processKey, errorCode, errorMessage); - execution.setVariable("SDNCA_SuccessIndicator", workflowException); - updateProgress(execution, RequestsDbConstant.Status.ERROR, String.valueOf(errorCode), null, errorMessage); - throw new Exception(""); - } - } -} diff --git a/bpmn/MSOInfrastructureBPMN/src/main/java/org/openecomp/mso/bpmn/infrastructure/workflow/serviceTask/client/builder/AbstractBuilder.java b/bpmn/MSOInfrastructureBPMN/src/main/java/org/openecomp/mso/bpmn/infrastructure/workflow/serviceTask/client/builder/AbstractBuilder.java index 91b95df1b2..41fa8f250a 100644 --- a/bpmn/MSOInfrastructureBPMN/src/main/java/org/openecomp/mso/bpmn/infrastructure/workflow/serviceTask/client/builder/AbstractBuilder.java +++ b/bpmn/MSOInfrastructureBPMN/src/main/java/org/openecomp/mso/bpmn/infrastructure/workflow/serviceTask/client/builder/AbstractBuilder.java @@ -22,8 +22,6 @@ package org.openecomp.mso.bpmn.infrastructure.workflow.serviceTask.client.builde import org.apache.commons.lang3.StringUtils; import org.camunda.bpm.engine.delegate.DelegateExecution; -import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.request.information.RequestInformation; -import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.sdnc.request.header.SdncRequestHeader; import org.openecomp.mso.bpmn.infrastructure.workflow.serviceTask.SdncUnderlayVpnPreprocessTask; import org.openecomp.mso.bpmn.infrastructure.workflow.serviceTask.client.entity.OnapModelInformationEntity; import org.openecomp.mso.bpmn.infrastructure.workflow.serviceTask.client.entity.ParamEntity; @@ -36,35 +34,101 @@ import java.util.List; import java.util.Map; import java.util.UUID; +//import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.request.information.RequestInformation; +//import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.sdnc.request.header.SdncRequestHeader; + /** * Created by 10112215 on 2017/9/20. */ public abstract class AbstractBuilder { + public static enum RequestAction { + CreateNetworkInstance(0, "CreateNetworkInstance"), + ActivateNetworkInstance(1, "ActivateNetworkInstance"), + CreateServiceInstance(2, "CreateServiceInstance"), + DeleteServiceInstance(3, "DeleteServiceInstance"), + DeleteNetworkInstance(4, "DeleteNetworkInstance"), + CreateVnfInstance(5, "CreateVnfInstance"), + ActivateVnfInstance(6, "ActivateVnfInstance"), + DeleteVnfInstance(7, "DeleteVnfInstance"), + CreateVfModuleInstance(8, "CreateVfModuleInstance"), + ActivateVfModuleInstance(9, "ActivateVfModuleInstance"), + DeleteVfModuleInstance(10, "DeleteVfModuleInstance"), + CreateContrailRouteInstance(11, "CreateContrailRouteInstance"), + DeleteContrailRouteInstance(12, "DeleteContrailRouteInstance"), + CreateSecurityZoneInstance(13, "CreateSecurityZoneInstance"), + DeleteSecurityZoneInstance(14, "DeleteSecurityZoneInstance"); + + String name; + int value; + + private RequestAction(int value, String name) { + this.value = value; + this.name = name; + } + + public String getName() { + return this.name; + } + + public int getIntValue() { + return this.value; + } + } + + public enum SvcAction { + Reserve(0, "reserve"), + Assign(1, "assign"), + Activate(2, "activate"), + Delete(3, "delete"), + Changeassign(4, "changeassign"), + Changedelete(5, "changedelete"), + Rollback(6, "rollback"), + Deactivate(7, "deactivate"), + Unassign(8, "unassign"), + Create(9, "create"); + + String name; + int value; + + private SvcAction(int value, String name) { + this.value = value; + this.name = name; + } + + public String getName() { + return this.name; + } + + public int getIntValue() { + return this.value; + } + } + protected String requestId = null; abstract OUT build(DelegateExecution execution, IN input) throws Exception; protected String getRequestActoin(DelegateExecution execution) { - String action = RequestInformation.RequestAction.CreateNetworkInstance.name(); + String action = /*RequestInformation.*/RequestAction.CreateNetworkInstance.name(); String operType = getOperType(execution); if (!StringUtils.isBlank(operType)) { if (RequestsDbConstant.OperationType.DELETE.equals(operType)) { - action = RequestInformation.RequestAction.DeleteNetworkInstance.name(); + action = /*RequestInformation.*/RequestAction.DeleteNetworkInstance.name(); } else if (RequestsDbConstant.OperationType.CREATE.equals(operType)) { - action = RequestInformation.RequestAction.CreateNetworkInstance.name(); + action = /*RequestInformation.*/RequestAction.CreateNetworkInstance.name(); } } return action; } protected String getOperationType(DelegateExecution execution) { - String action = SdncRequestHeader.SvcAction.Create.name(); + String action = /*SdncRequestHeader.*/SvcAction.Create.name(); String operType = getOperType(execution); if (!StringUtils.isBlank(operType)) { if (RequestsDbConstant.OperationType.DELETE.equals(operType)) { - action = SdncRequestHeader.SvcAction.Delete.name(); + action = /*SdncRequestHeader.*/SvcAction.Delete.name(); } else if (RequestsDbConstant.OperationType.CREATE.equals(operType)) { - action = SdncRequestHeader.SvcAction.Create.name(); + action = /*SdncRequestHeader.*/SvcAction.Create.name(); } } return action; diff --git a/bpmn/MSOInfrastructureBPMN/src/main/java/org/openecomp/mso/bpmn/infrastructure/workflow/serviceTask/client/builder/NetworkTopologyRequestBodyBuilder.java b/bpmn/MSOInfrastructureBPMN/src/main/java/org/openecomp/mso/bpmn/infrastructure/workflow/serviceTask/client/builder/NetworkTopologyRequestBodyBuilder.java deleted file mode 100644 index d5ba528911..0000000000 --- a/bpmn/MSOInfrastructureBPMN/src/main/java/org/openecomp/mso/bpmn/infrastructure/workflow/serviceTask/client/builder/NetworkTopologyRequestBodyBuilder.java +++ /dev/null @@ -1,147 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * 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. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.mso.bpmn.infrastructure.workflow.serviceTask.client.builder; - -import okhttp3.RequestBody; -import org.apache.commons.lang3.StringUtils; -import org.camunda.bpm.engine.delegate.DelegateExecution; -import org.json.JSONObject; -import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.NetworkTopologyOperationInput; -import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.NetworkTopologyOperationInputBuilder; -import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.network.request.input.NetworkRequestInputBuilder; -import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.network.request.input.network.request.input.NetworkInputParametersBuilder; -import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.param.Param; -import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.param.ParamBuilder; -import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.param.ParamKey; -import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.request.information.RequestInformation; -import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.request.information.RequestInformationBuilder; -import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.sdnc.request.header.SdncRequestHeader; -import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.sdnc.request.header.SdncRequestHeaderBuilder; -import org.openecomp.mso.yangDecoder.transform.api.ITransformJava2StringService; -import org.openecomp.mso.yangDecoder.transform.impl.TransfromJava2StringFactory; - -import java.util.ArrayList; -import java.util.List; -import java.util.Map; - -/** - * Created by 10112215 on 2017/9/20. - */ -public class NetworkTopologyRequestBodyBuilder extends AbstractBuilder, RequestBody> { - - public static final String URI_PATH = "GENERIC-RESOURCE-API:network-topology-operation"; - public static final SdncRequestHeader.SvcAction SVC_DEFAULT_ACTION = SdncRequestHeader.SvcAction.Create; - public static final String SVC_REQUEST_ID = "MSO"; - public static final String SDC_ACTION = "SDC_ACTION"; - public static final RequestInformation.RequestAction REQUEST_ACTION = RequestInformation.RequestAction.CreateNetworkInstance; - protected static ITransformJava2StringService java2jsonService; - - static - { - try { - java2jsonService = TransfromJava2StringFactory.getJava2jsonService(); - } catch (Exception e) { - e.printStackTrace(); - java2jsonService = null; - } - } - - @Override - public RequestBody build(DelegateExecution execution, Map input) throws Exception { - NetworkTopologyOperationInput sdncInput = getSdncInput(input); - RequestBody body = getRequestBody(sdncInput); - return body; - } - - protected String getJsonInput(NetworkTopologyOperationInput sdncInput) throws Exception { - return java2jsonService.transformRpcDataObjectToString(URI_PATH, sdncInput); - } - - private RequestBody getRequestBody(NetworkTopologyOperationInput sdncInput) throws Exception { - String jsonString = getJsonInput(sdncInput); - String json = (new JSONObject(jsonString)).toString(); - return RequestBody.create(okhttp3.MediaType.parse("application/json; charset=utf-8"),json); - } - - protected NetworkTopologyOperationInput getSdncInput(Map inputs) { - NetworkTopologyOperationInputBuilder networkTopologyOperationInputBuilder = new NetworkTopologyOperationInputBuilder(); - { - loadSdncRequestHeader(inputs, networkTopologyOperationInputBuilder); - loadRequestInformation(networkTopologyOperationInputBuilder); - loadNetworkInputParameters(inputs, networkTopologyOperationInputBuilder); - } - return networkTopologyOperationInputBuilder.build(); - } - - private void loadNetworkInputParameters(Map inputs, NetworkTopologyOperationInputBuilder networkTopologyOperationInputBuilder) { - NetworkRequestInputBuilder networkRequestInputBuilder = new NetworkRequestInputBuilder(); - { - NetworkInputParametersBuilder networkInputParametersBuilder = new NetworkInputParametersBuilder(); - { - List paramList = getParamList(inputs); - networkInputParametersBuilder.setParam(paramList); - } - networkRequestInputBuilder.setNetworkInputParameters(networkInputParametersBuilder.build()); - } - networkTopologyOperationInputBuilder.setNetworkRequestInput(networkRequestInputBuilder.build()); - } - - private void loadRequestInformation(NetworkTopologyOperationInputBuilder networkTopologyOperationInputBuilder) { - RequestInformationBuilder requestInformationBuilder = new RequestInformationBuilder(); - { - requestInformationBuilder.setRequestId(SVC_REQUEST_ID); - requestInformationBuilder.setRequestAction(REQUEST_ACTION); - } - networkTopologyOperationInputBuilder.setRequestInformation(requestInformationBuilder.build()); - } - - private void loadSdncRequestHeader(Map inputs, NetworkTopologyOperationInputBuilder networkTopologyOperationInputBuilder) { - SdncRequestHeaderBuilder sdncRequestHeaderBuilder = new SdncRequestHeaderBuilder(); - { - sdncRequestHeaderBuilder.setSvcRequestId(SVC_REQUEST_ID); - SdncRequestHeader.SvcAction svcAction = SVC_DEFAULT_ACTION; - String action = inputs.get(SDC_ACTION); - if (!StringUtils.isBlank(action)) { - if (action.toLowerCase().contains("delete")) { - svcAction = SdncRequestHeader.SvcAction.Delete; - } else if (action.toLowerCase().contains("create")) { - svcAction = SdncRequestHeader.SvcAction.Create; - } - } - sdncRequestHeaderBuilder.setSvcAction(svcAction); - } - networkTopologyOperationInputBuilder.setSdncRequestHeader(sdncRequestHeaderBuilder.build()); - } - - private List getParamList(Map inputs) { - List paramList = new ArrayList<>(); - if (inputs != null && !inputs.isEmpty()) { - inputs.keySet().forEach(key -> { - ParamBuilder paramBuilder = new ParamBuilder(); - paramBuilder.setName(key); - paramBuilder.setValue(inputs.get(key)); - paramBuilder.setKey(new ParamKey(key)); - paramList.add(paramBuilder.build()); - }); - } - return paramList; - } -} -- cgit 1.2.3-korg