diff options
Diffstat (limited to 'bpmn/MSOInfrastructureBPMN/src/main/java/org/openecomp/mso')
5 files changed, 160 insertions, 47 deletions
diff --git a/bpmn/MSOInfrastructureBPMN/src/main/java/org/openecomp/mso/bpmn/infrastructure/workflow/serviceTask/AbstractSdncOperationTask.java b/bpmn/MSOInfrastructureBPMN/src/main/java/org/openecomp/mso/bpmn/infrastructure/workflow/serviceTask/AbstractSdncOperationTask.java index 09dec4389a..6ca93f7238 100644 --- a/bpmn/MSOInfrastructureBPMN/src/main/java/org/openecomp/mso/bpmn/infrastructure/workflow/serviceTask/AbstractSdncOperationTask.java +++ b/bpmn/MSOInfrastructureBPMN/src/main/java/org/openecomp/mso/bpmn/infrastructure/workflow/serviceTask/AbstractSdncOperationTask.java @@ -45,9 +45,12 @@ import org.openecomp.mso.logger.MessageEnum; import org.openecomp.mso.logger.MsoLogger; import org.openecomp.mso.requestsdb.RequestsDatabase; import org.openecomp.mso.requestsdb.ResourceOperationStatus; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import java.io.IOException; import java.util.HashMap; +import java.util.Iterator; import java.util.Map; /** @@ -55,6 +58,8 @@ import java.util.Map; */ public abstract class AbstractSdncOperationTask extends BaseTask { + private static final Logger logger = LoggerFactory.getLogger(AbstractSdncOperationTask.class); + private static final String DEFAULT_MSB_IP = "127.0.0.1"; private static final int DEFAULT_MSB_Port = 80; private static final String SDCADAPTOR_INPUTS = "resourceParameters"; @@ -74,16 +79,24 @@ public abstract class AbstractSdncOperationTask extends BaseTask { " <statusDescription>$statusDescription</statusDescription>\n"+ " </ns:updateResourceOperationStatus></soapenv:Body></soapenv:Envelope>"; + private static final String getBodyTemplate = " <soapenv:Envelope xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:ns=\"http://org.openecomp.mso/requestsdb\"><soapenv:Header/><soapenv:Body>\n" + + " <ns:getResourceOperationStatus>\n" + + " <operationId>$operationId</operationId>\n" + + " <resourceTemplateUUID>$resourceTemplateUUID</resourceTemplateUUID>\n" + + " <serviceId>$serviceId</serviceId>\n" + + " </ns:getResourceOperationStatus></soapenv:Body></soapenv:Envelope>"; + private void updateResOperStatus(ResourceOperationStatus resourceOperationStatus) throws RouteException { + logger.info("AbstractSdncOperationTask.updateResOperStatus begin!"); String url = "http://mso:8080/dbadapters/RequestsDbAdapter"; HttpPost httpPost = new HttpPost(url); httpPost.addHeader("Authorization", "Basic QlBFTENsaWVudDpwYXNzd29yZDEk"); httpPost.addHeader("Content-type", "application/soap+xml"); - String postBody = getStringBody(resourceOperationStatus); + String postBody = getPostStringBody(resourceOperationStatus); httpPost.setEntity(new StringEntity(postBody, ContentType.APPLICATION_XML)); httpPost(url, httpPost); - + logger.info("AbstractSdncOperationTask.updateResOperStatus end!"); //requestsDB.updateResOperStatus(resourceOperationStatus); } @@ -99,9 +112,10 @@ public abstract class AbstractSdncOperationTask extends BaseTask { return postBody; } - protected void httpPost(String url, HttpPost httpPost) throws RouteException { + protected String httpPost(String url, HttpPost httpPost) throws RouteException { + logger.info("AbstractSdncOperationTask.httpPost begin!"); CloseableHttpClient httpClient = HttpClients.createDefault(); - String result; + String result = null; boolean var15 = false; String errorMsg; @@ -110,8 +124,10 @@ public abstract class AbstractSdncOperationTask extends BaseTask { var15 = true; CloseableHttpResponse closeableHttpResponse = httpClient.execute(httpPost); result = EntityUtils.toString(closeableHttpResponse.getEntity()); - LOGGER.info(MessageEnum.RA_RESPONSE_FROM_SDNC, result.toString(), "SDNC", ""); + logger.info("result = {}", result); +// LOGGER.info(MessageEnum.RA_RESPONSE_FROM_SDNC, result.toString(), "SDNC", ""); if(closeableHttpResponse.getStatusLine().getStatusCode() != 200) { + logger.info("exception: fail for status code = {}", closeableHttpResponse.getStatusLine().getStatusCode()); throw new RouteException(result, "SERVICE_GET_ERR"); } @@ -120,6 +136,7 @@ public abstract class AbstractSdncOperationTask extends BaseTask { break label91; } catch (IOException var19) { errorMsg = url + ":httpPostWithJSON connect faild"; + logger.info("exception: POST_CONNECT_FAILD : {}", errorMsg); throwsRouteException(errorMsg, var19, "POST_CONNECT_FAILD"); var15 = false; } finally { @@ -128,6 +145,7 @@ public abstract class AbstractSdncOperationTask extends BaseTask { httpClient.close(); } catch (IOException var16) { String errorMsg1 = url + ":close httpClient faild"; + logger.info("exception: CLOSE_CONNECT_FAILD : {}", errorMsg1); throwsRouteException(errorMsg1, var16, "CLOSE_CONNECT_FAILD"); } @@ -138,6 +156,7 @@ public abstract class AbstractSdncOperationTask extends BaseTask { httpClient.close(); } catch (IOException var17) { errorMsg = url + ":close httpClient faild"; + logger.info("exception: CLOSE_CONNECT_FAILD : {}", errorMsg); throwsRouteException(errorMsg, var17, "CLOSE_CONNECT_FAILD"); } } @@ -146,54 +165,78 @@ public abstract class AbstractSdncOperationTask extends BaseTask { httpClient.close(); } catch (IOException var18) { errorMsg = url + ":close httpClient faild"; + logger.info("exception: CLOSE_CONNECT_FAILD : {}", errorMsg); throwsRouteException(errorMsg, var18, "CLOSE_CONNECT_FAILD"); } + logger.info("AbstractSdncOperationTask.httpPost end!"); + return result; } private static void throwsRouteException(String errorMsg, Exception e, String errorCode) throws RouteException { String msg = errorMsg + ".errorMsg:" + e.getMessage(); + logger.info("exception: {}", msg); throw new RouteException(errorMsg, errorCode); } - private String getStringBody(ResourceOperationStatus resourceOperationStatus) { + private String getPostStringBody(ResourceOperationStatus resourceOperationStatus) { + logger.info("AbstractSdncOperationTask.getPostStringBody begin!"); String postBody = new String(postBodyTemplate); - postBody.replace("$errorCode", resourceOperationStatus.getErrorCode()); - postBody.replace("$jobId", resourceOperationStatus.getJobId()); - postBody.replace("$operType", resourceOperationStatus.getOperType()); - postBody.replace("$operationId", resourceOperationStatus.getOperationId()); - postBody.replace("$progress", resourceOperationStatus.getProgress()); - postBody.replace("$resourceTemplateUUID", resourceOperationStatus.getResourceTemplateUUID()); - postBody.replace("$serviceId", resourceOperationStatus.getServiceId()); - postBody.replace("$status", resourceOperationStatus.getStatus()); - postBody.replace("$statusDescription", resourceOperationStatus.getStatusDescription()); + postBody = postBody.replace("$errorCode", resourceOperationStatus.getErrorCode()); + postBody = postBody.replace("$jobId", resourceOperationStatus.getJobId()); + postBody = postBody.replace("$operType", resourceOperationStatus.getOperType()); + postBody = postBody.replace("$operationId", resourceOperationStatus.getOperationId()); + postBody = postBody.replace("$progress", resourceOperationStatus.getProgress()); + postBody = postBody.replace("$resourceTemplateUUID", resourceOperationStatus.getResourceTemplateUUID()); + postBody = postBody.replace("$serviceId", resourceOperationStatus.getServiceId()); + postBody = postBody.replace("$status", resourceOperationStatus.getStatus()); + postBody = postBody.replace("$statusDescription", resourceOperationStatus.getStatusDescription()); + logger.info("AbstractSdncOperationTask.getPostStringBody end!"); return postBody; } + private String getGetStringBody(String serviceId, String operationId, String resourceTemplateUUID) { + logger.info("AbstractSdncOperationTask.getGetStringBody begin!"); + String getBody = new String(getBodyTemplate); + getBody = getBody.replace("$operationId", operationId); + getBody = getBody.replace("$resourceTemplateUUID", resourceTemplateUUID); + getBody = getBody.replace("$serviceId", serviceId); + logger.info("AbstractSdncOperationTask.getGetStringBody end!"); + return getBody; + } + private ResourceOperationStatus getResourceOperationStatus(String serviceId, String operationId, String resourceTemplateUUID) throws RouteException { + logger.info("AbstractSdncOperationTask.getResourceOperationStatus begin!"); String url = "http://mso:8080/dbadapters/RequestsDbAdapter"; - HttpGet httpGet = new HttpGet(url); - httpGet.setHeader("Authorization", "Basic QlBFTENsaWVudDpwYXNzd29yZDEk"); - httpGet.setHeader("Content-type", "application/soap+xml"); - String result = httpGet(url, httpGet); + HttpPost httpPost = new HttpPost(url); + httpPost.addHeader("Authorization", "Basic QlBFTENsaWVudDpwYXNzd29yZDEk"); + httpPost.addHeader("Content-type", "application/soap+xml"); + String getBody = getGetStringBody(serviceId, operationId, resourceTemplateUUID); + httpPost.setEntity(new StringEntity(getBody, ContentType.APPLICATION_XML)); + String result = httpPost(url, httpPost); ResourceOperationStatus resourceOperationStatus = getResourceOperationStatusFromXmlString(result); - + logger.info("AbstractSdncOperationTask.getResourceOperationStatus end!"); return resourceOperationStatus; //return requestsDB.getResourceOperationStatus(serviceId, operationId, resourceTemplateUUID); } private String httpGet(String url, HttpGet httpGet) throws RouteException { + logger.info("AbstractSdncOperationTask.httpGet begin!"); boolean var16 = false; CloseableHttpClient httpClient = HttpClients.createDefault(); - String result=""; + String result = ""; String errorMsg; - label109: { - label110: { + label109: + { + label110: + { try { var16 = true; CloseableHttpResponse e = httpClient.execute(httpGet); result = EntityUtils.toString(e.getEntity()); - if(e.getStatusLine().getStatusCode() != 200) { + logger.info("result = {}", result); + if (e.getStatusLine().getStatusCode() != 200) { + logger.info("exception: fail for status code = {}", e.getStatusLine().getStatusCode()); throw new RouteException(result, "SERVICE_GET_ERR"); } @@ -202,19 +245,22 @@ public abstract class AbstractSdncOperationTask extends BaseTask { break label110; } catch (ClientProtocolException var21) { errorMsg = url + ":httpGetWithJSON connect faild"; + logger.info("exception: GET_CONNECT_FAILD {}", errorMsg); throwsRouteException(errorMsg, var21, "GET_CONNECT_FAILD"); var16 = false; } catch (IOException var22) { errorMsg = url + ":httpGetWithJSON connect faild"; + logger.info("exception: GET_CONNECT_FAILD {}", errorMsg); throwsRouteException(errorMsg, var22, "GET_CONNECT_FAILD"); var16 = false; break label109; } finally { - if(var16) { + if (var16) { try { httpClient.close(); } catch (IOException var17) { String errorMsg1 = url + ":close httpClient faild"; + logger.info("exception: CLOSE_CONNECT_FAILD {}", errorMsg1); throwsRouteException(errorMsg1, var17, "CLOSE_CONNECT_FAILD"); } @@ -225,6 +271,7 @@ public abstract class AbstractSdncOperationTask extends BaseTask { httpClient.close(); } catch (IOException var19) { errorMsg = url + ":close httpClient faild"; + logger.info("exception: CLOSE_CONNECT_FAILD {}", errorMsg); throwsRouteException(errorMsg, var19, "CLOSE_CONNECT_FAILD"); } @@ -234,6 +281,7 @@ public abstract class AbstractSdncOperationTask extends BaseTask { httpClient.close(); } catch (IOException var20) { errorMsg = url + ":close httpClient faild"; + logger.info("exception: CLOSE_CONNECT_FAILD {}", errorMsg); throwsRouteException(errorMsg, var20, "CLOSE_CONNECT_FAILD"); } @@ -243,12 +291,15 @@ public abstract class AbstractSdncOperationTask extends BaseTask { httpClient.close(); } catch (IOException var18) { errorMsg = url + ":close httpClient faild"; + logger.info("exception: CLOSE_CONNECT_FAILD {}", errorMsg); throwsRouteException(errorMsg, var18, "CLOSE_CONNECT_FAILD"); } + logger.info("AbstractSdncOperationTask.httpGet end!"); return result; } private ResourceOperationStatus getResourceOperationStatusFromXmlString(String result) { + logger.info("AbstractSdncOperationTask.getResourceOperationStatusFromXmlString begin!"); ResourceOperationStatus resourceOperationStatus = new ResourceOperationStatus(); resourceOperationStatus.setErrorCode(getValueByName("errorCode", result)); resourceOperationStatus.setJobId(getValueByName("jobId", result)); @@ -259,19 +310,24 @@ public abstract class AbstractSdncOperationTask extends BaseTask { resourceOperationStatus.setServiceId(getValueByName("serviceId", result)); resourceOperationStatus.setStatus(getValueByName("status", result)); resourceOperationStatus.setStatusDescription(getValueByName("statusDescription", result)); + logger.info("AbstractSdncOperationTask.getResourceOperationStatusFromXmlString end!"); return resourceOperationStatus; } private String getValueByName(String Name, String xml) { - String start = "<" + Name + ">"; - String end = "</" + Name + ">"; - return xml.substring(xml.indexOf(start), xml.indexOf(end)).replace(start, ""); + if (!StringUtils.isBlank(xml) && xml.contains(Name)) { + String start = "<" + Name + ">"; + String end = "</" + Name + ">"; + return xml.substring(xml.indexOf(start), xml.indexOf(end)).replace(start, ""); + } + return ""; } protected static MsoLogger LOGGER = MsoLogger.getMsoLogger(MsoLogger.Catalog.RA); @Override public void execute(DelegateExecution execution) { + logger.info("AbstractSdncOperationTask.execute begin!"); GenericResourceApi genericResourceApiClient = getGenericResourceApiClient(execution); // updateProgress(execution, RequestsDbConstant.Status.PROCESSING, null, "10", "execute begin!"); Map<String, String> inputs = getInputs(execution); @@ -281,24 +337,29 @@ public abstract class AbstractSdncOperationTask extends BaseTask { execution.setVariable("SDNCA_SuccessIndicator", true); // updateProgress(execution, RequestsDbConstant.Status.FINISHED, null, RequestsDbConstant.Progress.ONE_HUNDRED, "execute finished!"); } catch (Exception e) { + logger.info("exception: AbstractSdncOperationTask.fail!"); + logger.error("exception: AbstractSdncOperationTask.fail!:", e); e.printStackTrace(); execution.setVariable("SDNCA_SuccessIndicator", false); } + logger.info("AbstractSdncOperationTask.execute end!"); } protected Map<String, String> getInputs(DelegateExecution execution) { + logger.info("AbstractSdncOperationTask.getInputs begin!"); Map<String, String> inputs = new HashMap<>(); String json = (String) execution.getVariable(SDCADAPTOR_INPUTS); JSONObject jsonObject = new JSONObject(json); JSONObject paras = jsonObject.getJSONObject("additionalParamForNs"); - - while (paras.keys().hasNext()) { - String key = paras.keys().next(); + Iterator<String> iterator = paras.keys(); + while (iterator.hasNext()) { + String key = iterator.next(); inputs.put(key, paras.getString(key)); } /* if (paras.keys().hasNext()) { paras.keySet().stream().forEach(key -> inputs.put(key, paras.getString((String) key))); }*/ + logger.info("AbstractSdncOperationTask.getInputs end!"); return inputs; } @@ -311,6 +372,7 @@ public abstract class AbstractSdncOperationTask extends BaseTask { String errorCode, String progress, String statusDescription) { + logger.info("AbstractSdncOperationTask.updateProgress begin!"); String serviceId = (String) execution.getVariable("serviceId"); String operationId = (String) execution.getVariable("operationId"); String resourceTemplateUUID = (String) execution.getVariable("resourceUUID"); @@ -329,44 +391,57 @@ public abstract class AbstractSdncOperationTask extends BaseTask { resourceOperationStatus.setStatusDescription(statusDescription); } updateResOperStatus(resourceOperationStatus); + logger.info("AbstractSdncOperationTask.updateProgress end!"); } catch (Exception exception) { System.out.println(exception); + logger.info("exception: AbstractSdncOperationTask.updateProgress fail!"); + logger.error("exception: AbstractSdncOperationTask.updateProgress fail:", exception); LOGGER.error(MessageEnum.GENERAL_EXCEPTION, " updateProgress catch exception: ", "", this.getTaskName(), MsoLogger.ErrorCode.UnknownError, exception.getClass().toString()); } } protected boolean isSend2SdncDirectly() { + logger.info("AbstractSdncOperationTask.isSend2SdncDirectly begin!"); Map<String, String> properties = PropertyConfiguration.getInstance().getProperties("topology.properties"); if (properties != null) { String sdncIp = properties.get("sdnc-ip"); String sdncPort = properties.get("sdnc-port"); if (!StringUtils.isBlank(sdncIp) && isIp(sdncIp) && !StringUtils.isBlank(sdncPort)) { + logger.info("AbstractSdncOperationTask.isSend2SdncDirectly = true."); return true; } } + logger.info("AbstractSdncOperationTask.isSend2SdncDirectly = false."); return false; } protected String getSdncIp() { + logger.info("AbstractSdncOperationTask.getSdncIp begin."); String sdncIp = null; Map<String, String> properties = PropertyConfiguration.getInstance().getProperties("topology.properties"); if (properties != null) { sdncIp = properties.get("sdnc-ip"); } - return StringUtils.isBlank(sdncIp) || !isIp(sdncIp) ? null : sdncIp; + String returnIp = StringUtils.isBlank(sdncIp) || !isIp(sdncIp) ? null : sdncIp; + logger.info("AbstractSdncOperationTask.getSdncIp: sdncIp = {}", returnIp); + return returnIp; } protected String getSdncPort() { - String sdncIp = null; + logger.info("AbstractSdncOperationTask.getSdncPort begin."); + String sdncPort = null; Map<String, String> properties = PropertyConfiguration.getInstance().getProperties("topology.properties"); if (properties != null) { - sdncIp = properties.get("sdnc-port"); + sdncPort = properties.get("sdnc-port"); } - return StringUtils.isBlank(sdncIp) ? null : sdncIp; + String returnPort = StringUtils.isBlank(sdncPort) ? null : sdncPort; + logger.info("AbstractSdncOperationTask.getSdncPort: returnPort = {}", sdncPort); + return returnPort; } private GenericResourceApi getGenericResourceApiClient(DelegateExecution execution) { + logger.info("AbstractSdncOperationTask.getGenericResourceApiClient begin!"); // updateProgress(execution, null, null, "20", "getGenericResourceApiClient begin!"); String msbIp = System.getenv().get(ONAP_IP); int msbPort = DEFAULT_MSB_Port; @@ -384,8 +459,10 @@ public abstract class AbstractSdncOperationTask extends BaseTask { } msbPort = Integer.valueOf(strMsbPort); } + logger.info("AbstractSdncOperationTask.getGenericResourceApiClient msbIp = " + msbIp + " msbPort = " + msbPort); MSBServiceClient msbClient = new MSBServiceClient(msbIp, msbPort); RestServiceCreater restServiceCreater = new RestServiceCreater(msbClient); + logger.info("AbstractSdncOperationTask.getGenericResourceApiClient end!"); return restServiceCreater.createService(GenericResourceApi.class); } diff --git a/bpmn/MSOInfrastructureBPMN/src/main/java/org/openecomp/mso/bpmn/infrastructure/workflow/serviceTask/SdncNetworkTopologyOperationTask.java b/bpmn/MSOInfrastructureBPMN/src/main/java/org/openecomp/mso/bpmn/infrastructure/workflow/serviceTask/SdncNetworkTopologyOperationTask.java index 95abd275b4..e8bfcf5caa 100644 --- a/bpmn/MSOInfrastructureBPMN/src/main/java/org/openecomp/mso/bpmn/infrastructure/workflow/serviceTask/SdncNetworkTopologyOperationTask.java +++ b/bpmn/MSOInfrastructureBPMN/src/main/java/org/openecomp/mso/bpmn/infrastructure/workflow/serviceTask/SdncNetworkTopologyOperationTask.java @@ -24,7 +24,6 @@ import org.apache.http.client.methods.HttpPost; import org.apache.http.entity.ContentType; import org.apache.http.entity.StringEntity; import org.camunda.bpm.engine.delegate.DelegateExecution; -import org.json.JSONObject; import org.onap.msb.sdk.discovery.common.RouteException; import org.openecomp.mso.bpmn.core.WorkflowException; import org.openecomp.mso.bpmn.infrastructure.workflow.serviceTask.client.GenericResourceApi; @@ -34,6 +33,8 @@ import org.openecomp.mso.bpmn.infrastructure.workflow.serviceTask.client.entity. import org.openecomp.mso.bpmn.infrastructure.workflow.serviceTask.client.entity.RpcNetworkTopologyOperationOutputEntity; import org.openecomp.mso.logger.MessageEnum; import org.openecomp.mso.requestsdb.RequestsDbConstant; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import java.util.Map; @@ -41,6 +42,8 @@ import java.util.Map; * Created by 10112215 on 2017/9/20. */ public class SdncNetworkTopologyOperationTask extends AbstractSdncOperationTask { + private static final Logger logger = LoggerFactory.getLogger(SdncNetworkTopologyOperationTask.class); + private static final String URL = "/restconf/operations/GENERIC-RESOURCE-API:network-topology-operation"; @@ -48,6 +51,7 @@ public class SdncNetworkTopologyOperationTask extends AbstractSdncOperationTask public void sendRestrequestAndHandleResponse(DelegateExecution execution, Map<String, String> inputs, GenericResourceApi genericResourceApiClient) throws Exception { + logger.info("SdncNetworkTopologyOperationTask.sendRestrequestAndHandleResponse begin!"); updateProgress(execution, null, null, "40", "sendRestrequestAndHandleResponse begin!"); NetworkRpcInputEntityBuilder builder = new NetworkRpcInputEntityBuilder(); RpcNetworkTopologyOperationInputEntity inputEntity = builder.build(execution, inputs); @@ -61,10 +65,12 @@ public class SdncNetworkTopologyOperationTask extends AbstractSdncOperationTask } else { Send2SdncDirectly(HeaderUtil.DefaulAuth, inputEntity); } + logger.info("SdncNetworkTopologyOperationTask.sendRestrequestAndHandleResponse end!"); } private void Send2SdncDirectly(String defaulAuth, RpcNetworkTopologyOperationInputEntity inputEntity) throws RouteException { + logger.info("SdncNetworkTopologyOperationTask.Send2SdncDirectly begin!"); String url = "http://" + getSdncIp() + ":" + getSdncPort() + URL; HttpPost httpPost = new HttpPost(url); httpPost.addHeader("Authorization", defaulAuth); @@ -73,9 +79,11 @@ public class SdncNetworkTopologyOperationTask extends AbstractSdncOperationTask LOGGER.info(MessageEnum.RA_SEND_REQUEST_SDNC, postBody.toString(), "SDNC", ""); httpPost.setEntity(new StringEntity(postBody, ContentType.APPLICATION_XML)); httpPost(url, httpPost); + logger.info("SdncNetworkTopologyOperationTask.Send2SdncDirectly end!"); } private void saveOutput(DelegateExecution execution, RpcNetworkTopologyOperationOutputEntity output) throws Exception { + logger.info("SdncNetworkTopologyOperationTask.saveOutput begin!"); String responseCode = output.getOutput().getResponseCode(); if (!"200".equals(responseCode)) { String processKey = getProcessKey(execution); @@ -84,10 +92,11 @@ public class SdncNetworkTopologyOperationTask extends AbstractSdncOperationTask WorkflowException workflowException = new WorkflowException(processKey, errorCode, errorMessage); execution.setVariable("SDNCA_SuccessIndicator", workflowException); updateProgress(execution, RequestsDbConstant.Status.ERROR, String.valueOf(errorCode), null, errorMessage); + logger.info("exception: SdncNetworkTopologyOperationTask.saveOutput fail!"); throw new Exception(""); } updateProgress(execution, RequestsDbConstant.Status.FINISHED, null, RequestsDbConstant.Progress.ONE_HUNDRED, "execute finished!"); - + logger.info("SdncNetworkTopologyOperationTask.saveOutput end!"); } } diff --git a/bpmn/MSOInfrastructureBPMN/src/main/java/org/openecomp/mso/bpmn/infrastructure/workflow/serviceTask/SdncServiceTopologyOperationTask.java b/bpmn/MSOInfrastructureBPMN/src/main/java/org/openecomp/mso/bpmn/infrastructure/workflow/serviceTask/SdncServiceTopologyOperationTask.java index ed2411a30e..89d0958c75 100644 --- a/bpmn/MSOInfrastructureBPMN/src/main/java/org/openecomp/mso/bpmn/infrastructure/workflow/serviceTask/SdncServiceTopologyOperationTask.java +++ b/bpmn/MSOInfrastructureBPMN/src/main/java/org/openecomp/mso/bpmn/infrastructure/workflow/serviceTask/SdncServiceTopologyOperationTask.java @@ -33,6 +33,8 @@ import org.openecomp.mso.bpmn.infrastructure.workflow.serviceTask.client.builder import org.openecomp.mso.bpmn.infrastructure.workflow.serviceTask.client.entity.RpcServiceTopologyOperationInputEntity; import org.openecomp.mso.bpmn.infrastructure.workflow.serviceTask.client.entity.RpcServiceTopologyOperationOutputEntity; import org.openecomp.mso.logger.MessageEnum; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import java.util.Map; @@ -40,6 +42,8 @@ import java.util.Map; * Created by 10112215 on 2017/9/26. */ public class SdncServiceTopologyOperationTask extends AbstractSdncOperationTask { + private static final Logger logger = LoggerFactory.getLogger(SdncServiceTopologyOperationTask.class); + private static final String URL = "/restconf/operations/GENERIC-RESOURCE-API:service-topology-operation"; @@ -47,6 +51,7 @@ public class SdncServiceTopologyOperationTask extends AbstractSdncOperationTask public void sendRestrequestAndHandleResponse(DelegateExecution execution, Map<String, String> inputs, GenericResourceApi genericResourceApiClient) throws Exception { + logger.info("SdncServiceTopologyOperationTask.sendRestrequestAndHandleResponse begin!"); // updateProgress(execution, null, null, "40", "sendRestrequestAndHandleResponse begin!"); ServiceRpcInputEntityBuilder builder = new ServiceRpcInputEntityBuilder(); RpcServiceTopologyOperationInputEntity inputEntity = builder.build(execution, inputs); @@ -60,10 +65,13 @@ public class SdncServiceTopologyOperationTask extends AbstractSdncOperationTask } else { Send2SdncDirectly(HeaderUtil.DefaulAuth, inputEntity); } + logger.info("SdncServiceTopologyOperationTask.sendRestrequestAndHandleResponse end!"); + } private void Send2SdncDirectly(String defaulAuth, RpcServiceTopologyOperationInputEntity inputEntity) throws RouteException { + logger.info("SdncServiceTopologyOperationTask.Send2SdncDirectly begin!"); String url = "http://" + getSdncIp() + ":" + getSdncPort() + URL; HttpPost httpPost = new HttpPost(url); httpPost.addHeader("Authorization", defaulAuth); @@ -72,9 +80,11 @@ public class SdncServiceTopologyOperationTask extends AbstractSdncOperationTask LOGGER.info(MessageEnum.RA_SEND_REQUEST_SDNC, postBody.toString(), "SDNC", ""); httpPost.setEntity(new StringEntity(postBody, ContentType.APPLICATION_XML)); httpPost(url, httpPost); + logger.info("SdncServiceTopologyOperationTask.Send2SdncDirectly end!"); } private void saveOutput(DelegateExecution execution, RpcServiceTopologyOperationOutputEntity output) throws Exception { + logger.info("SdncServiceTopologyOperationTask.saveOutput begin!"); String responseCode = output.getOutput().getResponseCode(); if (!"200".equals(responseCode)) { String processKey = getProcessKey(execution); @@ -83,7 +93,9 @@ public class SdncServiceTopologyOperationTask extends AbstractSdncOperationTask WorkflowException workflowException = new WorkflowException(processKey, errorCode, errorMessage); execution.setVariable("SDNCA_SuccessIndicator", workflowException); // updateProgress(execution, RequestsDbConstant.Status.ERROR, String.valueOf(errorCode), null, errorMessage); + logger.info("exception: SdncServiceTopologyOperationTask.saveOutput fail!"); throw new Exception(""); } + logger.info("SdncServiceTopologyOperationTask.saveOutput end!"); } } 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 36961de6ac..299c1c546b 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 @@ -118,7 +118,7 @@ public abstract class AbstractBuilder<IN, OUT> { String operType = (String) execution.getVariable(OPERATION_TYPE); String resourceType = ((String) execution.getVariable(RESOURCE_TYPE)).toLowerCase(); if (!StringUtils.isBlank(operType)) { - if (RequestsDbConstant.OperationType.DELETE.equals(operType)) { + if (RequestsDbConstant.OperationType.DELETE.equalsIgnoreCase(operType)) { if (isOverlay(resourceType)) { action = /*RequestInformation.*/RequestAction.DeActivateDCINetworkInstance.getName(); } else if (isUnderlay(resourceType)) { @@ -126,7 +126,7 @@ public abstract class AbstractBuilder<IN, OUT> { } else { action = /*RequestInformation.*/RequestAction.DeleteServiceInstance.getName(); } - } else if (RequestsDbConstant.OperationType.CREATE.equals(operType)) { + } else if (RequestsDbConstant.OperationType.CREATE.equalsIgnoreCase(operType)) { if (isOverlay(resourceType)) { action = /*RequestInformation.*/RequestAction.ActivateDCINetworkInstance.getName(); } else if (isUnderlay(resourceType)) { @@ -152,7 +152,7 @@ public abstract class AbstractBuilder<IN, OUT> { String operType = (String) execution.getVariable(OPERATION_TYPE); String resourceType = ((String) execution.getVariable(RESOURCE_TYPE)).toLowerCase(); if (!StringUtils.isBlank(operType)) { - if (RequestsDbConstant.OperationType.DELETE.equals(operType)) { + if (RequestsDbConstant.OperationType.DELETE.equalsIgnoreCase(operType)) { if (isOverlay(resourceType)) { action = /*SdncRequestHeader.*/SvcAction.Deactivate.getName(); } else if (isUnderlay(resourceType)) { @@ -160,7 +160,7 @@ public abstract class AbstractBuilder<IN, OUT> { } else { action = /*SdncRequestHeader.*/SvcAction.Unassign.getName(); } - } else if (RequestsDbConstant.OperationType.CREATE.equals(operType)) { + } else if (RequestsDbConstant.OperationType.CREATE.equalsIgnoreCase(operType)) { if (isOverlay(resourceType)) { action = /*SdncRequestHeader.*/SvcAction.Activate.getName(); } else if (isUnderlay(resourceType)) { @@ -183,13 +183,13 @@ public abstract class AbstractBuilder<IN, OUT> { return requestId; } - protected OnapModelInformationEntity getOnapModelInformationEntity(DelegateExecution execution) { + protected OnapModelInformationEntity getOnapServiceModelInformationEntity(DelegateExecution execution) { OnapModelInformationEntity onapModelInformationEntity = new OnapModelInformationEntity(); { String modelInvariantUuid = (String) execution.getVariable("modelInvariantUuid"); String modelVersion = (String) execution.getVariable("modelVersion"); String modelUuid = (String) execution.getVariable("modelUuid"); - String modelName = (String) execution.getVariable("modelName"); + String modelName = (String) execution.getVariable("serviceModelName"); onapModelInformationEntity.setModelInvariantUuid(modelInvariantUuid); onapModelInformationEntity.setModelVersion(modelVersion); onapModelInformationEntity.setModelUuid(modelUuid); @@ -197,6 +197,21 @@ public abstract class AbstractBuilder<IN, OUT> { } return onapModelInformationEntity; } + + protected OnapModelInformationEntity getOnapNetworkModelInformationEntity(DelegateExecution execution) { + OnapModelInformationEntity onapModelInformationEntity = new OnapModelInformationEntity(); + { + String modelInvariantUuid = (String) execution.getVariable("resourceInvariantUUID"); + String modelVersion = (String) execution.getVariable("modelVersion"); + String modelUuid = (String) execution.getVariable("resourceUUID"); + String modelName = (String) execution.getVariable("resourceType"); + onapModelInformationEntity.setModelInvariantUuid(modelInvariantUuid); + onapModelInformationEntity.setModelVersion(modelVersion); + onapModelInformationEntity.setModelUuid(modelUuid); + onapModelInformationEntity.setModelName(modelName); + } + return onapModelInformationEntity; + } protected List<ParamEntity> getParamEntities(Map<String, String> inputs) { List<ParamEntity> paramEntityList = new ArrayList<>(); @@ -222,9 +237,9 @@ public abstract class AbstractBuilder<IN, OUT> { protected ServiceInformationEntity getServiceInformationEntity(DelegateExecution execution) { ServiceInformationEntity serviceInformationEntity = new ServiceInformationEntity(); - serviceInformationEntity.setServiceId((String) execution.getVariable("productFamilyId")); - serviceInformationEntity.setSubscriptionServiceType((String) execution.getVariable("subscriptionServiceType")); - serviceInformationEntity.setOnapModelInformation(getOnapModelInformationEntity(execution)); + serviceInformationEntity.setServiceId("VOLTE_SERVICE_ID"); + serviceInformationEntity.setSubscriptionServiceType((String) execution.getVariable("serviceType")); + serviceInformationEntity.setOnapModelInformation(getOnapServiceModelInformationEntity(execution)); serviceInformationEntity.setServiceInstanceId((String) execution.getVariable("serviceInstanceId")); serviceInformationEntity.setGlobalCustomerId((String) execution.getVariable("globalSubscriberId")); return serviceInformationEntity; diff --git a/bpmn/MSOInfrastructureBPMN/src/main/java/org/openecomp/mso/bpmn/infrastructure/workflow/serviceTask/client/builder/NetworkRpcInputEntityBuilder.java b/bpmn/MSOInfrastructureBPMN/src/main/java/org/openecomp/mso/bpmn/infrastructure/workflow/serviceTask/client/builder/NetworkRpcInputEntityBuilder.java index 94838ed1ff..ac411b5598 100644 --- a/bpmn/MSOInfrastructureBPMN/src/main/java/org/openecomp/mso/bpmn/infrastructure/workflow/serviceTask/client/builder/NetworkRpcInputEntityBuilder.java +++ b/bpmn/MSOInfrastructureBPMN/src/main/java/org/openecomp/mso/bpmn/infrastructure/workflow/serviceTask/client/builder/NetworkRpcInputEntityBuilder.java @@ -85,7 +85,7 @@ public class NetworkRpcInputEntityBuilder extends AbstractBuilder<Map<String, St private void loadNetworkInformationEntity(DelegateExecution execution, NetworkTopologyOperationInputEntity networkTopologyOperationInputEntity) { NetworkInformationEntity networkInformationEntity = new NetworkInformationEntity(); { - OnapModelInformationEntity onapModelInformationEntity = getOnapModelInformationEntity(execution); + OnapModelInformationEntity onapModelInformationEntity = getOnapNetworkModelInformationEntity(execution); networkInformationEntity.setOnapModelInformation(onapModelInformationEntity); } networkTopologyOperationInputEntity.setNetworkInformation(networkInformationEntity); |