diff options
author | Shashank Kumar Shankar <shashank.kumar.shankar@intel.com> | 2018-03-05 14:35:40 -0800 |
---|---|---|
committer | Shashank Kumar Shankar <shashank.kumar.shankar@intel.com> | 2018-03-08 11:05:00 -0800 |
commit | 5022c4de929d010b2dadca087acd85a2a8eba8d6 (patch) | |
tree | c9edd46ed6de16c37cf6cb22b7468dab174a8f0e /bpmn | |
parent | 61b1d1cdd962f95015add112c54c25a7f998079c (diff) |
Fix some Sonar Blockers in workflow/serviceTask
Some files in which the sonar code fixes are done:
https://sonar.onap.org/code?id=org.onap.so%3Aso&selected=org.onap.so%3AMSOInfrastructureBPMN%3Asrc%2Fmain%2Fjava%2Forg%2Fopenecomp%2Fmso%2Fbpmn%2Finfrastructure%2Fworkflow%2FserviceTask
Change-Id: I6c25c6553008c8cea53b11a71dbe89c28b3bb441
Issue-ID: SO-455
Signed-off-by: Shashank Kumar Shankar <shashank.kumar.shankar@intel.com>
Diffstat (limited to 'bpmn')
4 files changed, 70 insertions, 128 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 38a44ab1f6..0749c789b4 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 @@ -24,9 +24,7 @@ import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.databind.ObjectMapper; import org.apache.commons.lang3.StringUtils; -import org.apache.http.client.ClientProtocolException; import org.apache.http.client.methods.CloseableHttpResponse; -import org.apache.http.client.methods.HttpGet; import org.apache.http.client.methods.HttpPost; import org.apache.http.entity.ContentType; import org.apache.http.entity.StringEntity; @@ -43,7 +41,6 @@ import org.openecomp.mso.bpmn.core.PropertyConfiguration; import org.openecomp.mso.bpmn.infrastructure.workflow.serviceTask.client.GenericResourceApi; import org.openecomp.mso.logger.MessageEnum; import org.openecomp.mso.logger.MsoLogger; -import org.openecomp.mso.requestsdb.RequestsDatabase; import org.openecomp.mso.requestsdb.RequestsDbConstant; import org.openecomp.mso.requestsdb.ResourceOperationStatus; import org.slf4j.Logger; @@ -62,12 +59,12 @@ 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 int DEFAULT_MSB_PORT = 80; private static final String SDCADAPTOR_INPUTS = "resourceParameters"; + private static final String TOPOLOGY_PROPERTIES = "topology.properties"; public static final String ONAP_IP = "ONAP_IP"; - private RequestsDatabase requestsDB = RequestsDatabase.getInstance(); - private static final String postBodyTemplate = "<soapenv:Envelope xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:ns=\"http://org.openecomp.mso/requestsdb\"><soapenv:Header/><soapenv:Body>\n"+ + private static final String POST_BODY_TEMPLATE = "<soapenv:Envelope xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:ns=\"http://org.openecomp.mso/requestsdb\"><soapenv:Header/><soapenv:Body>\n"+ " <ns:updateResourceOperationStatus>\n"+ " <errorCode>$errorCode</errorCode>\n"+ " <jobId>$jobId</jobId>\n"+ @@ -80,7 +77,7 @@ 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" + + private static final String GET_BODY_TEMPLATE = " <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" + @@ -98,7 +95,6 @@ public abstract class AbstractSdncOperationTask extends BaseTask { httpPost.setEntity(new StringEntity(postBody, ContentType.APPLICATION_XML)); httpPost(url, httpPost); logger.info("AbstractSdncOperationTask.updateResOperStatus end!"); - //requestsDB.updateResOperStatus(resourceOperationStatus); } protected String getPostbody(Object inputEntity) { @@ -108,7 +104,7 @@ public abstract class AbstractSdncOperationTask extends BaseTask { objectMapper.setSerializationInclusion(JsonInclude.Include.NON_EMPTY); postBody = objectMapper.writeValueAsString(inputEntity); } catch (JsonProcessingException e) { - e.printStackTrace(); + logger.error(e.getStackTrace().toString()); } return postBody; } @@ -118,24 +114,20 @@ public abstract class AbstractSdncOperationTask extends BaseTask { String result = null; String errorMsg; - label91: { - try(CloseableHttpClient httpClient = HttpClients.createDefault()) { - CloseableHttpResponse closeableHttpResponse = httpClient.execute(httpPost); - result = EntityUtils.toString(closeableHttpResponse.getEntity()); - 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"); - } - - closeableHttpResponse.close(); - break label91; - } catch (IOException e) { - errorMsg = url + ":httpPostWithJSON connect faild"; - logger.info("exception: POST_CONNECT_FAILD : {}", errorMsg); - throwsRouteException(errorMsg, e, "POST_CONNECT_FAILD"); + try(CloseableHttpClient httpClient = HttpClients.createDefault()) { + CloseableHttpResponse closeableHttpResponse = httpClient.execute(httpPost); + result = EntityUtils.toString(closeableHttpResponse.getEntity()); + logger.info("result = {}", result); + if(closeableHttpResponse.getStatusLine().getStatusCode() != 200) { + logger.info("exception: fail for status code = {}", closeableHttpResponse.getStatusLine().getStatusCode()); + throw new RouteException(result, "SERVICE_GET_ERR"); } + + closeableHttpResponse.close(); + } catch (IOException e) { + errorMsg = url + ":httpPostWithJSON connect faild"; + logger.info("exception: POST_CONNECT_FAILD : {}", errorMsg); + throwsRouteException(errorMsg, e, "POST_CONNECT_FAILD"); } logger.info("AbstractSdncOperationTask.httpPost end!"); @@ -150,7 +142,7 @@ public abstract class AbstractSdncOperationTask extends BaseTask { private String getPostStringBody(ResourceOperationStatus resourceOperationStatus) { logger.info("AbstractSdncOperationTask.getPostStringBody begin!"); - String postBody = postBodyTemplate; + String postBody = POST_BODY_TEMPLATE; postBody = postBody.replace("$errorCode", resourceOperationStatus.getErrorCode()); postBody = postBody.replace("$jobId", resourceOperationStatus.getJobId()); postBody = postBody.replace("$operType", resourceOperationStatus.getOperType()); @@ -166,7 +158,7 @@ public abstract class AbstractSdncOperationTask extends BaseTask { private String getGetStringBody(String serviceId, String operationId, String resourceTemplateUUID) { logger.info("AbstractSdncOperationTask.getGetStringBody begin!"); - String getBody = getBodyTemplate; + String getBody = GET_BODY_TEMPLATE; getBody = getBody.replace("$operationId", operationId); getBody = getBody.replace("$resourceTemplateUUID", resourceTemplateUUID); getBody = getBody.replace("$serviceId", serviceId); @@ -186,35 +178,6 @@ public abstract class AbstractSdncOperationTask extends BaseTask { 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!"); - String result = ""; - String errorMsg; - try(CloseableHttpClient httpClient = HttpClients.createDefault()) { - CloseableHttpResponse e = httpClient.execute(httpGet); - result = EntityUtils.toString(e.getEntity()); - 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"); - } - e.close(); - } catch (ClientProtocolException e) { - errorMsg = url + ":httpGetWithJSON connect faild"; - logger.info("exception: GET_CONNECT_FAILD {}", errorMsg); - throwsRouteException(errorMsg, e, "GET_CONNECT_FAILD"); - } catch (IOException e) { - errorMsg = url + ":httpGetWithJSON connect faild"; - logger.info("exception: GET_CONNECT_FAILD {}", errorMsg); - throwsRouteException(errorMsg, e, "GET_CONNECT_FAILD"); - } - - logger.info("AbstractSdncOperationTask.httpGet end!"); - return result; } private ResourceOperationStatus getResourceOperationStatusFromXmlString(String result) { @@ -233,33 +196,30 @@ public abstract class AbstractSdncOperationTask extends BaseTask { return resourceOperationStatus; } - private String getValueByName(String Name, String xml) { - if (!StringUtils.isBlank(xml) && xml.contains(Name)) { - String start = "<" + Name + ">"; - String end = "</" + Name + ">"; + private String getValueByName(String name, String xml) { + 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); + protected static MsoLogger msoLogger = 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!"); + GenericResourceApi genericResourceApiClient = getGenericResourceApiClient(); try { Map<String, String> inputs = getInputs(execution); -// updateProgress(execution, null, null, "30", "getGenericResourceApiClient finished!"); sendRestrequestAndHandleResponse(execution, inputs, genericResourceApiClient); 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(); + logger.error(e.getStackTrace().toString()); execution.setVariable("SDNCA_SuccessIndicator", false); updateProgress(execution, RequestsDbConstant.Status.ERROR, null, "100", "sendRestrequestAndHandleResponse finished!"); @@ -279,9 +239,6 @@ public abstract class AbstractSdncOperationTask extends BaseTask { 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; @@ -321,14 +278,14 @@ public abstract class AbstractSdncOperationTask extends BaseTask { } catch (Exception 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()); + msoLogger.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"); + Map<String, String> properties = PropertyConfiguration.getInstance().getProperties(TOPOLOGY_PROPERTIES); if (properties != null) { String sdncIp = properties.get("sdnc-ip"); String sdncPort = properties.get("sdnc-port"); @@ -365,11 +322,10 @@ public abstract class AbstractSdncOperationTask extends BaseTask { return returnPort; } - private GenericResourceApi getGenericResourceApiClient(DelegateExecution execution) { + private GenericResourceApi getGenericResourceApiClient() { logger.info("AbstractSdncOperationTask.getGenericResourceApiClient begin!"); -// updateProgress(execution, null, null, "20", "getGenericResourceApiClient begin!"); String msbIp = System.getenv().get(ONAP_IP); - int msbPort = DEFAULT_MSB_Port; + int msbPort = DEFAULT_MSB_PORT; Map<String, String> properties = PropertyConfiguration.getInstance().getProperties("topology.properties"); if (properties != null) { if (StringUtils.isBlank(msbIp) || !isIp(msbIp)) { @@ -380,7 +336,7 @@ public abstract class AbstractSdncOperationTask extends BaseTask { } String strMsbPort = properties.get("msb-port"); if (StringUtils.isBlank(strMsbPort)) { - strMsbPort = getString(properties, "msb.port", String.valueOf(DEFAULT_MSB_Port)); + strMsbPort = getString(properties, "msb.port", String.valueOf(DEFAULT_MSB_PORT)); } msbPort = Integer.valueOf(strMsbPort); } @@ -402,19 +358,7 @@ public abstract class AbstractSdncOperationTask extends BaseTask { return vlaue; } } catch (Exception e) { - LOGGER.error(MessageEnum.GENERAL_EXCEPTION, " getMsbIp catch exception: ", "", this.getTaskName(), MsoLogger.ErrorCode.UnknownError, e.getClass().toString()); - } - return defaultValue; - } - - private Integer getInteger(DelegateExecution execution, String name, Integer defaultValue) { - Integer vlaue = (Integer) execution.getVariable(name); - try { - if (vlaue != null) { - return vlaue; - } - } catch (Exception e) { - LOGGER.error(MessageEnum.GENERAL_EXCEPTION, " getMsbIp catch exception: ", "", this.getTaskName(), MsoLogger.ErrorCode.UnknownError, e.getClass().toString()); + msoLogger.error(MessageEnum.GENERAL_EXCEPTION, " getMsbIp catch exception: ", "", this.getTaskName(), MsoLogger.ErrorCode.UnknownError, e.getClass().toString()); } return defaultValue; } 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 60bc83b0ea..25c85f7394 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 @@ -42,7 +42,7 @@ 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 Logger sdncLogger = LoggerFactory.getLogger(SdncNetworkTopologyOperationTask.class); private static final String URL = "/restconf/operations/GENERIC-RESOURCE-API:network-topology-operation"; @@ -51,7 +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!"); + sdncLogger.info("SdncNetworkTopologyOperationTask.sendRestrequestAndHandleResponse begin!"); updateProgress(execution, RequestsDbConstant.Status.PROCESSING, null, "40", "sendRestrequestAndHandleResponse begin!"); NetworkRpcInputEntityBuilder builder = new NetworkRpcInputEntityBuilder(); RpcNetworkTopologyOperationInputEntity inputEntity = builder.build(execution, inputs); @@ -63,41 +63,41 @@ public class SdncNetworkTopologyOperationTask extends AbstractSdncOperationTask updateProgress(execution, null, null, "90", "sendRestrequestAndHandleResponse finished!"); saveOutput(execution, outputEntity); } else { - Send2SdncDirectly(HeaderUtil.DefaulAuth, inputEntity); + send2SdncDirectly(HeaderUtil.DefaulAuth, inputEntity); } updateProgress(execution, RequestsDbConstant.Status.FINISHED, null, RequestsDbConstant.Progress.ONE_HUNDRED, "execute finished!"); - logger.info("SdncNetworkTopologyOperationTask.sendRestrequestAndHandleResponse end!"); + sdncLogger.info("SdncNetworkTopologyOperationTask.sendRestrequestAndHandleResponse end!"); } - private void Send2SdncDirectly(String defaulAuth, + private void send2SdncDirectly(String defaulAuth, RpcNetworkTopologyOperationInputEntity inputEntity) throws RouteException { - logger.info("SdncNetworkTopologyOperationTask.Send2SdncDirectly begin!"); + sdncLogger.info("SdncNetworkTopologyOperationTask.send2SdncDirectly begin!"); String url = "http://" + getSdncIp() + ":" + getSdncPort() + URL; HttpPost httpPost = new HttpPost(url); httpPost.addHeader("Authorization", defaulAuth); httpPost.addHeader("Content-type", "application/json"); String postBody = getPostbody(inputEntity); - LOGGER.info(MessageEnum.RA_SEND_REQUEST_SDNC, postBody, "SDNC", ""); + msoLogger.info(MessageEnum.RA_SEND_REQUEST_SDNC, postBody, "SDNC", ""); httpPost.setEntity(new StringEntity(postBody, ContentType.APPLICATION_XML)); httpPost(url, httpPost); - logger.info("SdncNetworkTopologyOperationTask.Send2SdncDirectly end!"); + sdncLogger.info("SdncNetworkTopologyOperationTask.send2SdncDirectly end!"); } - private void saveOutput(DelegateExecution execution, RpcNetworkTopologyOperationOutputEntity output) throws Exception { - logger.info("SdncNetworkTopologyOperationTask.saveOutput begin!"); + private void saveOutput(DelegateExecution execution, RpcNetworkTopologyOperationOutputEntity output) throws RouteException { + sdncLogger.info("SdncNetworkTopologyOperationTask.saveOutput begin!"); String responseCode = output.getOutput().getResponseCode(); if (!"200".equals(responseCode)) { String processKey = getProcessKey(execution); - int errorCode = Integer.valueOf(responseCode); + int errorCode = Integer.parseInt(responseCode); String errorMessage = output.getOutput().getResponseMessage(); WorkflowException workflowException = new WorkflowException(processKey, errorCode, errorMessage); execution.setVariable("SDNCA_SuccessIndicator", workflowException); updateProgress(execution, RequestsDbConstant.Status.ERROR, String.valueOf(errorCode), "100", errorMessage); - logger.info("exception: SdncNetworkTopologyOperationTask.saveOutput fail!"); - throw new Exception(""); + sdncLogger.info("exception: SdncNetworkTopologyOperationTask.saveOutput fail!"); + throw new RouteException(); } - - logger.info("SdncNetworkTopologyOperationTask.saveOutput end!"); + + sdncLogger.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 602894475c..130c97e273 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 @@ -42,7 +42,7 @@ 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 Logger sdncLogger = LoggerFactory.getLogger(SdncServiceTopologyOperationTask.class); private static final String URL = "/restconf/operations/GENERIC-RESOURCE-API:service-topology-operation"; @@ -51,7 +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!"); + sdncLogger.info("SdncServiceTopologyOperationTask.sendRestrequestAndHandleResponse begin!"); // updateProgress(execution, null, null, "40", "sendRestrequestAndHandleResponse begin!"); ServiceRpcInputEntityBuilder builder = new ServiceRpcInputEntityBuilder(); RpcServiceTopologyOperationInputEntity inputEntity = builder.build(execution, inputs); @@ -63,39 +63,39 @@ public class SdncServiceTopologyOperationTask extends AbstractSdncOperationTask // updateProgress(execution, null, null, "90", "sendRestrequestAndHandleResponse finished!"); saveOutput(execution, outputEntity); } else { - Send2SdncDirectly(HeaderUtil.DefaulAuth, inputEntity); + send2SdncDirectly(HeaderUtil.DefaulAuth, inputEntity); } - logger.info("SdncServiceTopologyOperationTask.sendRestrequestAndHandleResponse end!"); + sdncLogger.info("SdncServiceTopologyOperationTask.sendRestrequestAndHandleResponse end!"); } - private void Send2SdncDirectly(String defaulAuth, + private void send2SdncDirectly(String defaulAuth, RpcServiceTopologyOperationInputEntity inputEntity) throws RouteException { - logger.info("SdncServiceTopologyOperationTask.Send2SdncDirectly begin!"); + sdncLogger.info("SdncServiceTopologyOperationTask.send2SdncDirectly begin!"); String url = "http://" + getSdncIp() + ":" + getSdncPort() + URL; HttpPost httpPost = new HttpPost(url); httpPost.addHeader("Authorization", defaulAuth); httpPost.addHeader("Content-type", "application/json"); String postBody = getPostbody(inputEntity); - LOGGER.info(MessageEnum.RA_SEND_REQUEST_SDNC, postBody, "SDNC", ""); + msoLogger.info(MessageEnum.RA_SEND_REQUEST_SDNC, postBody, "SDNC", ""); httpPost.setEntity(new StringEntity(postBody, ContentType.APPLICATION_XML)); httpPost(url, httpPost); - logger.info("SdncServiceTopologyOperationTask.Send2SdncDirectly end!"); + sdncLogger.info("SdncServiceTopologyOperationTask.send2SdncDirectly end!"); } private void saveOutput(DelegateExecution execution, RpcServiceTopologyOperationOutputEntity output) throws Exception { - logger.info("SdncServiceTopologyOperationTask.saveOutput begin!"); + sdncLogger.info("SdncServiceTopologyOperationTask.saveOutput begin!"); String responseCode = output.getOutput().getResponseCode(); if (!"200".equals(responseCode)) { String processKey = getProcessKey(execution); - int errorCode = Integer.valueOf(responseCode); + int errorCode = Integer.parseInt(responseCode); String errorMessage = output.getOutput().getResponseMessage(); 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(""); + sdncLogger.info("exception: SdncServiceTopologyOperationTask.saveOutput fail!"); + throw new RouteException(); } - logger.info("SdncServiceTopologyOperationTask.saveOutput end!"); + sdncLogger.info("SdncServiceTopologyOperationTask.saveOutput end!"); } } diff --git a/bpmn/MSOInfrastructureBPMN/src/main/java/org/openecomp/mso/bpmn/infrastructure/workflow/serviceTask/SdncUnderlayVpnOperationClient.java b/bpmn/MSOInfrastructureBPMN/src/main/java/org/openecomp/mso/bpmn/infrastructure/workflow/serviceTask/SdncUnderlayVpnOperationClient.java index 49d702d1ee..add87b131e 100644 --- a/bpmn/MSOInfrastructureBPMN/src/main/java/org/openecomp/mso/bpmn/infrastructure/workflow/serviceTask/SdncUnderlayVpnOperationClient.java +++ b/bpmn/MSOInfrastructureBPMN/src/main/java/org/openecomp/mso/bpmn/infrastructure/workflow/serviceTask/SdncUnderlayVpnOperationClient.java @@ -41,7 +41,7 @@ import java.util.Map; public class SdncUnderlayVpnOperationClient { private static final String DEFAULT_MSB_IP = "127.0.0.1"; - private static final int DEFAULT_MSB_Port = 10081; + private static final int DEFAULT_MSB_PORT = 10081; private RequestsDatabase requestsDB = RequestsDatabase.getInstance(); private String serviceId; @@ -54,11 +54,11 @@ public class SdncUnderlayVpnOperationClient { public boolean excute(String msbIp, int msbPort, Map<String, String> inputs, - String serviceId_i, - String operationId_i, + String iServiceID, + String iOperationID, String resourceTemplateUUID_i){ - serviceId = serviceId_i; - operationId = operationId_i; + serviceId = iServiceID; + operationId = iOperationID; resourceTemplateUUID = resourceTemplateUUID_i; GenericResourceApi genericResourceApiClient = getGenericResourceApiClient(msbIp, msbPort); updateProgress(RequestsDbConstant.Status.PROCESSING, null, "10", "execute begin!"); @@ -72,15 +72,13 @@ public class SdncUnderlayVpnOperationClient { updateProgress(null, null, "50", "RequestBody build finished!"); RpcNetworkTopologyOperationOutputEntity networkRpcOutputEntiy = null; try { - networkRpcOutputEntiy = genericResourceApiClient.postNetworkTopologyOperation - (HeaderUtil.DefaulAuth ,body).execute().body(); + genericResourceApiClient.postNetworkTopologyOperation(HeaderUtil.DefaulAuth ,body).execute().body(); } catch (Exception e) { logger.debug("Exception: ", e); updateProgress(RequestsDbConstant.Status.ERROR, null, null, "sendRestrequestAndHandleResponse exception:" + e.getMessage()); return false; } updateProgress(null, null, "90", "sendRestrequestAndHandleResponse finished!"); - saveOutput(networkRpcOutputEntiy); updateProgress(RequestsDbConstant.Status.FINISHED, null, RequestsDbConstant.Progress.ONE_HUNDRED, "execute finished!"); return true; } @@ -90,7 +88,7 @@ public class SdncUnderlayVpnOperationClient { msbIp = DEFAULT_MSB_IP; } if (msbPort <= 0) { - msbPort = DEFAULT_MSB_Port; + msbPort = DEFAULT_MSB_PORT; } MSBServiceClient msbClient = new MSBServiceClient(msbIp, msbPort); RestServiceCreater restServiceCreater = new RestServiceCreater(msbClient); @@ -117,7 +115,7 @@ public class SdncUnderlayVpnOperationClient { requestsDB.updateResOperStatus(resourceOperationStatus); } - private void saveOutput(RpcNetworkTopologyOperationOutputEntity output) { - + private void saveOutput() { + // Not implemented. } } |