* ================================================================================
* Copyright (C) 2018 CMCC. All rights reserved.
* ================================================================================
+ * Modifications Copyright (c) 2019 Samsung
+ * ================================================================================
* 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.
package org.onap.so.bpmn.infrastructure.scripts
+import org.onap.so.logger.LoggingAnchor
import org.camunda.bpm.engine.delegate.DelegateExecution
import org.json.JSONArray
import org.json.JSONObject;
import org.onap.so.bpmn.core.json.JsonUtils
import org.camunda.bpm.engine.delegate.BpmnError
-import org.camunda.bpm.engine.runtime.Execution
import com.fasterxml.jackson.databind.ObjectMapper
+import org.onap.so.client.HttpClientFactory
+import org.onap.logging.filter.base.ErrorCode
-import org.onap.so.rest.RESTClient
-import org.onap.so.rest.RESTConfig
-import org.onap.so.rest.APIResponse;
+import javax.ws.rs.core.Response
import org.onap.so.bpmn.infrastructure.vfcmodel.ScaleResource
+import org.onap.so.client.HttpClient
import org.onap.so.bpmn.infrastructure.vfcmodel.ScaleNsByStepsData
import org.onap.so.bpmn.infrastructure.vfcmodel.ScaleNsData
import org.onap.so.bpmn.infrastructure.vfcmodel.NsParameters
import org.onap.so.bpmn.infrastructure.vfcmodel.LocationConstraint
import org.onap.so.logger.MessageEnum
-import org.onap.so.logger.MsoLogger
+import org.slf4j.Logger
+import org.slf4j.LoggerFactory
+import org.onap.logging.filter.base.ONAPComponents;
* flow for VFC Network Service Scale
*/
public class DoScaleVFCNetworkServiceInstance extends AbstractServiceTaskProcessor {
- private static final MsoLogger msoLogger = MsoLogger.getMsoLogger(MsoLogger.Catalog.BPEL, DoScaleVFCNetworkServiceInstance.class);
+ private static final Logger logger = LoggerFactory.getLogger( DoScaleVFCNetworkServiceInstance.class);
String host = "http://mso.mso.testlab.openecomp.org:8080"
* generate the nsParameters
*/
public void preProcessRequest(DelegateExecution execution) {
- msoLogger.trace("preProcessRequest() ")
+ logger.trace("preProcessRequest() ")
List<NSResourceInputParameter> nsRIPList = convertScaleNsReq2NSResInputParamList(execution)
String requestJsonStr = ""
execution.setVariable("reqBody", requestJsonStr)
- msoLogger.trace("Exit preProcessRequest ")
+ logger.trace("Exit preProcessRequest ")
}
/**
String url = host + scaleUrl.replaceAll("\\{nsInstanceId\\}", nsInstanceId)
- APIResponse apiResponse = postRequest(execution, url, reqBody)
+ Response apiResponse = postRequest(execution, url, reqBody)
- String returnCode = apiResponse.getStatusCode()
- String aaiResponseAsString = apiResponse.getResponseBodyAsString()
+ String returnCode = apiResponse.getStatus()
+ String aaiResponseAsString = apiResponse.readEntity(String.class)
String jobId = ""
if (returnCode == "200" || returnCode == "202") {
jobId = jsonUtil.getJsonValue(aaiResponseAsString, "jobId")
}
- utils.log("INFO", "scaleNetworkService get a ns scale job Id:" + jobId, isDebugEnabled)
+ logger.info( "scaleNetworkService get a ns scale job Id:" + jobId)
execution.setVariable("jobId", jobId)
execution.setVariable("nodeTemplateUUID", nodeTemplateUUID)
nsOperationKey.setOperationId(execution.getVariable("operationId"))
String queryReqBody = objectToJsonStr(nsOperationKey)
- APIResponse apiResponse = postRequest(execution,url, queryReqBody)
+ Response apiResponse = postRequest(execution,url, queryReqBody)
- String returnCode = apiResponse.getStatusCode()
- String aaiResponseAsString = apiResponse.getResponseBodyAsString()
+ String returnCode = apiResponse.getStatus()
+ String aaiResponseAsString = apiResponse.readEntity(String.class)
String operationStatus = "error"
try {
Thread.sleep(5000)
} catch (InterruptedException e) {
- msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, "Time Delay exception" + e, "BPMN", MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError, "");
+ logger.error(LoggingAnchor.FIVE, MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(),
+ "Time Delay exception" + e, "BPMN",
+ ErrorCode.UnknownError.getValue());
}
}
* url: the url of the request
* requestBody: the body of the request
*/
- private APIResponse postRequest(DelegateExecution execution, String url, String requestBody){
- msoLogger.trace("Started Execute VFC adapter Post Process ")
- msoLogger.info("url:"+url +"\nrequestBody:"+ requestBody)
- APIResponse apiResponse = null
+ private Response postRequest(DelegateExecution execution, String urlString, String requestBody){
+ logger.trace("Started Execute VFC adapter Post Process ")
+ logger.info("url:"+urlString +"\nrequestBody:"+ requestBody)
+ Response apiResponse = null
try{
- RESTConfig config = new RESTConfig(url)
- RESTClient client = new RESTClient(config).addHeader("Content-Type", "application/json").addHeader("Authorization","Basic QlBFTENsaWVudDpwYXNzd29yZDEk")
-// RESTClient client = new RESTClient(config).addHeader("Content-Type", "application/json").addHeader("Accept","application/json").addHeader("Authorization","Basic QlBFTENsaWVudDpwYXNzd29yZDEk")
- apiResponse = client.httpPost(requestBody)
- msoLogger.info("response code:"+ apiResponse.getStatusCode() +"\nresponse body:"+ apiResponse.getResponseBodyAsString())
- msoLogger.trace("Completed Execute VF-C adapter Post Process ")
+ URL url = new URL(urlString);
+
+ HttpClient httpClient = new HttpClientFactory().newJsonClient(url, ONAPComponents.VNF_ADAPTER)
+ httpClient.addAdditionalHeader("Authorization", "Basic QlBFTENsaWVudDpwYXNzd29yZDEk")
+
+ apiResponse = httpClient.post(requestBody)
+
+ logger.info("response code:"+ apiResponse.getStatus() +"\nresponse body:"+ apiResponse.readEntity(String.class))
+ logger.trace("Completed Execute VF-C adapter Post Process ")
}catch(Exception e){
- msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, "Exception occured while executing VFC Post Call.", "BPMN", MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError, e);
+ logger.error(LoggingAnchor.FIVE, MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), "Exception occured " +
+ "while executing VFC Post Call.", "BPMN", ErrorCode.UnknownError.getValue(), e);
throw new BpmnError("MSOWorkflowException")
}
return apiResponse