Auth and prefix for GENERIC-RESOURCE-API 95/21495/6
authorZhuoyao Huang <10112215@zte.com.cn>
Tue, 31 Oct 2017 13:06:31 +0000 (21:06 +0800)
committerZhuoyao Huang <10112215@zte.com.cn>
Wed, 1 Nov 2017 13:39:28 +0000 (21:39 +0800)
Change-Id: I48e861937fa72a379fb350bcfb70520484f06432
Issue-ID:SO-181
Signed-off-by: Zhuoyao Huang <10112215@zte.com.cn>
27 files changed:
bpmn/MSOInfrastructureBPMN/src/main/java/org/openecomp/mso/bpmn/infrastructure/workflow/serviceTask/AbstractSdncOperationTask.java
bpmn/MSOInfrastructureBPMN/src/main/java/org/openecomp/mso/bpmn/infrastructure/workflow/serviceTask/SdncNetworkTopologyOperationTask.java
bpmn/MSOInfrastructureBPMN/src/main/java/org/openecomp/mso/bpmn/infrastructure/workflow/serviceTask/SdncServiceTopologyOperationTask.java
bpmn/MSOInfrastructureBPMN/src/main/java/org/openecomp/mso/bpmn/infrastructure/workflow/serviceTask/SdncUnderlayVpnOperationClient.java
bpmn/MSOInfrastructureBPMN/src/main/java/org/openecomp/mso/bpmn/infrastructure/workflow/serviceTask/client/GenericResourceApi.java
bpmn/MSOInfrastructureBPMN/src/main/java/org/openecomp/mso/bpmn/infrastructure/workflow/serviceTask/client/HeaderUtil.java [new file with mode: 0644]
bpmn/MSOInfrastructureBPMN/src/main/java/org/openecomp/mso/bpmn/infrastructure/workflow/serviceTask/client/builder/AbstractBuilder.java
bpmn/MSOInfrastructureBPMN/src/main/java/org/openecomp/mso/bpmn/infrastructure/workflow/serviceTask/client/entity/NetworkInformationEntity.java
bpmn/MSOInfrastructureBPMN/src/main/java/org/openecomp/mso/bpmn/infrastructure/workflow/serviceTask/client/entity/NetworkInputPaarametersEntity.java
bpmn/MSOInfrastructureBPMN/src/main/java/org/openecomp/mso/bpmn/infrastructure/workflow/serviceTask/client/entity/NetworkRequestInputEntity.java
bpmn/MSOInfrastructureBPMN/src/main/java/org/openecomp/mso/bpmn/infrastructure/workflow/serviceTask/client/entity/NetworkResponseInformationEntity.java
bpmn/MSOInfrastructureBPMN/src/main/java/org/openecomp/mso/bpmn/infrastructure/workflow/serviceTask/client/entity/NetworkTopologyOperationInputEntity.java
bpmn/MSOInfrastructureBPMN/src/main/java/org/openecomp/mso/bpmn/infrastructure/workflow/serviceTask/client/entity/NetworkTopologyOperationOutputEntity.java
bpmn/MSOInfrastructureBPMN/src/main/java/org/openecomp/mso/bpmn/infrastructure/workflow/serviceTask/client/entity/OnapModelInformationEntity.java
bpmn/MSOInfrastructureBPMN/src/main/java/org/openecomp/mso/bpmn/infrastructure/workflow/serviceTask/client/entity/ParamEntity.java
bpmn/MSOInfrastructureBPMN/src/main/java/org/openecomp/mso/bpmn/infrastructure/workflow/serviceTask/client/entity/RequestInformationEntity.java
bpmn/MSOInfrastructureBPMN/src/main/java/org/openecomp/mso/bpmn/infrastructure/workflow/serviceTask/client/entity/RpcNetworkTopologyOperationInputEntity.java
bpmn/MSOInfrastructureBPMN/src/main/java/org/openecomp/mso/bpmn/infrastructure/workflow/serviceTask/client/entity/RpcNetworkTopologyOperationOutputEntity.java
bpmn/MSOInfrastructureBPMN/src/main/java/org/openecomp/mso/bpmn/infrastructure/workflow/serviceTask/client/entity/RpcServiceTopologyOperationInputEntity.java
bpmn/MSOInfrastructureBPMN/src/main/java/org/openecomp/mso/bpmn/infrastructure/workflow/serviceTask/client/entity/RpcServiceTopologyOperationOutputEntity.java
bpmn/MSOInfrastructureBPMN/src/main/java/org/openecomp/mso/bpmn/infrastructure/workflow/serviceTask/client/entity/SdncRequestHeaderEntity.java
bpmn/MSOInfrastructureBPMN/src/main/java/org/openecomp/mso/bpmn/infrastructure/workflow/serviceTask/client/entity/ServiceInformationEntity.java
bpmn/MSOInfrastructureBPMN/src/main/java/org/openecomp/mso/bpmn/infrastructure/workflow/serviceTask/client/entity/ServiceInputParametersEntity.java
bpmn/MSOInfrastructureBPMN/src/main/java/org/openecomp/mso/bpmn/infrastructure/workflow/serviceTask/client/entity/ServiceRequestInputEntity.java
bpmn/MSOInfrastructureBPMN/src/main/java/org/openecomp/mso/bpmn/infrastructure/workflow/serviceTask/client/entity/ServiceResponseInformationEntity.java
bpmn/MSOInfrastructureBPMN/src/main/java/org/openecomp/mso/bpmn/infrastructure/workflow/serviceTask/client/entity/ServiceTopologyOperationInputEntity.java
bpmn/MSOInfrastructureBPMN/src/main/java/org/openecomp/mso/bpmn/infrastructure/workflow/serviceTask/client/entity/ServiceTopologyOperationOutputEntity.java

index f6f8fd2..09dec43 100644 (file)
@@ -20,6 +20,9 @@
 
 package org.openecomp.mso.bpmn.infrastructure.workflow.serviceTask;
 
+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;
@@ -41,7 +44,6 @@ import org.openecomp.mso.bpmn.infrastructure.workflow.serviceTask.client.Generic
 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 java.io.IOException;
@@ -74,13 +76,31 @@ public abstract class AbstractSdncOperationTask extends BaseTask {
 
 
     private void updateResOperStatus(ResourceOperationStatus resourceOperationStatus) throws RouteException {
-        CloseableHttpClient httpClient = HttpClients.createDefault();
         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);
         httpPost.setEntity(new StringEntity(postBody, ContentType.APPLICATION_XML));
+        httpPost(url, httpPost);
+
+        //requestsDB.updateResOperStatus(resourceOperationStatus);
+    }
+
+    protected String getPostbody(Object inputEntity) {
+        ObjectMapper objectMapper = new ObjectMapper();
+        String postBody = null;
+        try {
+            objectMapper.setSerializationInclusion(JsonInclude.Include.NON_EMPTY);
+            postBody = objectMapper.writeValueAsString(inputEntity);
+        } catch (JsonProcessingException e) {
+            e.printStackTrace();
+        }
+        return postBody;
+    }
+
+    protected void httpPost(String url, HttpPost httpPost) throws RouteException {
+        CloseableHttpClient httpClient = HttpClients.createDefault();
         String result;
         boolean var15 = false;
 
@@ -90,6 +110,7 @@ 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", "");
                 if(closeableHttpResponse.getStatusLine().getStatusCode() != 200) {
                     throw new RouteException(result, "SERVICE_GET_ERR");
                 }
@@ -127,8 +148,6 @@ public abstract class AbstractSdncOperationTask extends BaseTask {
             errorMsg = url + ":close  httpClient faild";
             throwsRouteException(errorMsg, var18, "CLOSE_CONNECT_FAILD");
         }
-
-        //requestsDB.updateResOperStatus(resourceOperationStatus);
     }
 
     private static void throwsRouteException(String errorMsg, Exception e, String errorCode) throws RouteException {
@@ -151,12 +170,21 @@ public abstract class AbstractSdncOperationTask extends BaseTask {
     }
 
     private ResourceOperationStatus getResourceOperationStatus(String serviceId, String operationId, String resourceTemplateUUID) throws RouteException {
-        CloseableHttpClient httpClient = HttpClients.createDefault();
         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);
+        ResourceOperationStatus resourceOperationStatus = getResourceOperationStatusFromXmlString(result);
+
+        return resourceOperationStatus;
+
+        //return requestsDB.getResourceOperationStatus(serviceId, operationId, resourceTemplateUUID);
+    }
+
+    private String httpGet(String url, HttpGet httpGet) throws RouteException {
         boolean var16 = false;
+        CloseableHttpClient httpClient = HttpClients.createDefault();
         String result="";
         String errorMsg;
         label109: {
@@ -217,12 +245,7 @@ public abstract class AbstractSdncOperationTask extends BaseTask {
             errorMsg = url + ":close  httpClient faild";
             throwsRouteException(errorMsg, var18, "CLOSE_CONNECT_FAILD");
         }
-
-        ResourceOperationStatus resourceOperationStatus = getResourceOperationStatusFromXmlString(result);
-
-        return resourceOperationStatus;
-
-        //return requestsDB.getResourceOperationStatus(serviceId, operationId, resourceTemplateUUID);
+        return result;
     }
 
     private ResourceOperationStatus getResourceOperationStatusFromXmlString(String result) {
@@ -245,7 +268,7 @@ public abstract class AbstractSdncOperationTask extends BaseTask {
         return xml.substring(xml.indexOf(start), xml.indexOf(end)).replace(start, "");
     }
 
-    private static MsoLogger logger = MsoLogger.getMsoLogger(MsoLogger.Catalog.GENERAL);
+    protected static MsoLogger LOGGER = MsoLogger.getMsoLogger(MsoLogger.Catalog.RA);
 
     @Override
     public void execute(DelegateExecution execution) {
@@ -268,7 +291,14 @@ public abstract class AbstractSdncOperationTask extends BaseTask {
         String json = (String) execution.getVariable(SDCADAPTOR_INPUTS);
         JSONObject jsonObject = new JSONObject(json);
         JSONObject paras = jsonObject.getJSONObject("additionalParamForNs");
-        paras.keySet().stream().forEach(key -> inputs.put(key, paras.getString((String) key)));
+
+        while (paras.keys().hasNext()) {
+            String key = paras.keys().next();
+            inputs.put(key, paras.getString(key));
+        }
+/*        if (paras.keys().hasNext()) {
+            paras.keySet().stream().forEach(key -> inputs.put(key, paras.getString((String) key)));
+        }*/
         return inputs;
     }
 
@@ -301,15 +331,46 @@ public abstract class AbstractSdncOperationTask extends BaseTask {
             updateResOperStatus(resourceOperationStatus);
         } catch (Exception exception) {
             System.out.println(exception);
-            logger.error(MessageEnum.GENERAL_EXCEPTION, " updateProgress catch exception: ", "", this.getTaskName(), MsoLogger.ErrorCode.UnknownError, exception.getClass().toString());
+            LOGGER.error(MessageEnum.GENERAL_EXCEPTION, " updateProgress catch exception: ", "", this.getTaskName(), MsoLogger.ErrorCode.UnknownError, exception.getClass().toString());
+        }
+    }
+
+
+    protected boolean isSend2SdncDirectly() {
+        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)) {
+                return true;
+            }
+        }
+        return false;
+    }
+
+    protected String getSdncIp() {
+        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;
+    }
+
+    protected String getSdncPort() {
+        String sdncIp = null;
+        Map<String, String> properties = PropertyConfiguration.getInstance().getProperties("topology.properties");
+        if (properties != null) {
+            sdncIp = properties.get("sdnc-port");
         }
+        return StringUtils.isBlank(sdncIp) ? null : sdncIp;
     }
 
     private GenericResourceApi getGenericResourceApiClient(DelegateExecution execution) {
 //        updateProgress(execution, null, null, "20", "getGenericResourceApiClient begin!");
         String msbIp = System.getenv().get(ONAP_IP);
         int msbPort = DEFAULT_MSB_Port;
-        Map<String, String> properties = PropertyConfiguration.getInstance().getProperties("mso.bpmn.urn.properties");
+        Map<String, String> properties = PropertyConfiguration.getInstance().getProperties("topology.properties");
         if (properties != null) {
             if (StringUtils.isBlank(msbIp) || !isIp(msbIp)) {
                 msbIp = properties.get("msb-ip");
@@ -340,7 +401,7 @@ public abstract class AbstractSdncOperationTask extends BaseTask {
             }
         } catch (Exception e) {
             System.out.println(e);
-            logger.error(MessageEnum.GENERAL_EXCEPTION, " getMsbIp catch exception: ", "", this.getTaskName(), MsoLogger.ErrorCode.UnknownError, e.getClass().toString());
+            LOGGER.error(MessageEnum.GENERAL_EXCEPTION, " getMsbIp catch exception: ", "", this.getTaskName(), MsoLogger.ErrorCode.UnknownError, e.getClass().toString());
         }
         return defaultValue;
     }
@@ -353,7 +414,7 @@ public abstract class AbstractSdncOperationTask extends BaseTask {
             }
         } catch (Exception e) {
             System.out.println(e);
-            logger.error(MessageEnum.GENERAL_EXCEPTION, " getMsbIp catch exception: ", "", this.getTaskName(), MsoLogger.ErrorCode.UnknownError, e.getClass().toString());
+            LOGGER.error(MessageEnum.GENERAL_EXCEPTION, " getMsbIp catch exception: ", "", this.getTaskName(), MsoLogger.ErrorCode.UnknownError, e.getClass().toString());
         }
         return defaultValue;
     }
index e72bf8a..95abd27 100644 (file)
 
 package org.openecomp.mso.bpmn.infrastructure.workflow.serviceTask;
 
+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;
+import org.openecomp.mso.bpmn.infrastructure.workflow.serviceTask.client.HeaderUtil;
 import org.openecomp.mso.bpmn.infrastructure.workflow.serviceTask.client.builder.NetworkRpcInputEntityBuilder;
 import org.openecomp.mso.bpmn.infrastructure.workflow.serviceTask.client.entity.RpcNetworkTopologyOperationInputEntity;
 import org.openecomp.mso.bpmn.infrastructure.workflow.serviceTask.client.entity.RpcNetworkTopologyOperationOutputEntity;
+import org.openecomp.mso.logger.MessageEnum;
 import org.openecomp.mso.requestsdb.RequestsDbConstant;
 
 import java.util.Map;
@@ -34,6 +41,9 @@ import java.util.Map;
  * Created by 10112215 on 2017/9/20.
  */
 public class SdncNetworkTopologyOperationTask extends AbstractSdncOperationTask {
+
+    private static final String URL = "/restconf/operations/GENERIC-RESOURCE-API:network-topology-operation";
+
     @Override
     public void sendRestrequestAndHandleResponse(DelegateExecution execution,
                                                  Map<String, String> inputs,
@@ -42,9 +52,27 @@ public class SdncNetworkTopologyOperationTask extends AbstractSdncOperationTask
         NetworkRpcInputEntityBuilder builder = new NetworkRpcInputEntityBuilder();
         RpcNetworkTopologyOperationInputEntity inputEntity = builder.build(execution, inputs);
         updateProgress(execution, null, null, "50", "RequestBody build finished!");
-        RpcNetworkTopologyOperationOutputEntity outputEntity = genericResourceApiClient.postNetworkTopologyOperation(inputEntity).execute().body();
-        updateProgress(execution, null, null, "90", "sendRestrequestAndHandleResponse finished!");
-        saveOutput(execution, outputEntity);
+        RpcNetworkTopologyOperationOutputEntity outputEntity;
+        if (!isSend2SdncDirectly()) {
+            outputEntity = genericResourceApiClient.postNetworkTopologyOperation
+                    (HeaderUtil.DefaulAuth, inputEntity).execute().body();
+            updateProgress(execution, null, null, "90", "sendRestrequestAndHandleResponse finished!");
+            saveOutput(execution, outputEntity);
+        } else {
+            Send2SdncDirectly(HeaderUtil.DefaulAuth, inputEntity);
+        }
+    }
+
+    private void Send2SdncDirectly(String defaulAuth,
+                                   RpcNetworkTopologyOperationInputEntity inputEntity) throws RouteException {
+        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.toString(), "SDNC", "");
+        httpPost.setEntity(new StringEntity(postBody, ContentType.APPLICATION_XML));
+        httpPost(url, httpPost);
     }
 
     private void saveOutput(DelegateExecution execution, RpcNetworkTopologyOperationOutputEntity output) throws Exception {
index bea7a12..ed2411a 100644 (file)
 package org.openecomp.mso.bpmn.infrastructure.workflow.serviceTask;
 
 
+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.onap.msb.sdk.discovery.common.RouteException;
 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.HeaderUtil;
 import org.openecomp.mso.bpmn.infrastructure.workflow.serviceTask.client.builder.ServiceRpcInputEntityBuilder;
 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.bpmn.infrastructure.workflow.serviceTask.client.entity.ServiceTopologyOperationOutputEntity;
-import org.openecomp.mso.requestsdb.RequestsDbConstant;
+import org.openecomp.mso.logger.MessageEnum;
 
 import java.util.Map;
 
@@ -36,6 +40,9 @@ import java.util.Map;
  * Created by 10112215 on 2017/9/26.
  */
 public class SdncServiceTopologyOperationTask extends AbstractSdncOperationTask {
+
+    private static final String URL = "/restconf/operations/GENERIC-RESOURCE-API:service-topology-operation";
+
     @Override
     public void sendRestrequestAndHandleResponse(DelegateExecution execution,
                                                  Map<String, String> inputs,
@@ -44,9 +51,27 @@ public class SdncServiceTopologyOperationTask extends AbstractSdncOperationTask
         ServiceRpcInputEntityBuilder builder = new ServiceRpcInputEntityBuilder();
         RpcServiceTopologyOperationInputEntity inputEntity = builder.build(execution, inputs);
 //        updateProgress(execution, null, null, "50", "RequestBody build finished!");
-        RpcServiceTopologyOperationOutputEntity outputEntity = genericResourceApiClient.postServiceTopologyOperation(inputEntity).execute().body();
+        RpcServiceTopologyOperationOutputEntity outputEntity;
+        if (!isSend2SdncDirectly()) {
+            outputEntity = genericResourceApiClient.postServiceTopologyOperation
+                    (HeaderUtil.DefaulAuth, inputEntity).execute().body();
 //        updateProgress(execution, null, null, "90", "sendRestrequestAndHandleResponse finished!");
-        saveOutput(execution, outputEntity);
+            saveOutput(execution, outputEntity);
+        } else {
+            Send2SdncDirectly(HeaderUtil.DefaulAuth, inputEntity);
+        }
+    }
+
+    private void Send2SdncDirectly(String defaulAuth,
+                                   RpcServiceTopologyOperationInputEntity inputEntity) throws RouteException {
+        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.toString(), "SDNC", "");
+        httpPost.setEntity(new StringEntity(postBody, ContentType.APPLICATION_XML));
+        httpPost(url, httpPost);
     }
 
     private void saveOutput(DelegateExecution execution, RpcServiceTopologyOperationOutputEntity output) throws Exception {
index 8d2cb1e..49d702d 100644 (file)
@@ -24,6 +24,7 @@ import org.apache.commons.lang3.StringUtils;
 import org.onap.msb.sdk.httpclient.RestServiceCreater;
 import org.onap.msb.sdk.httpclient.msb.MSBServiceClient;
 import org.openecomp.mso.bpmn.infrastructure.workflow.serviceTask.client.GenericResourceApi;
+import org.openecomp.mso.bpmn.infrastructure.workflow.serviceTask.client.HeaderUtil;
 import org.openecomp.mso.bpmn.infrastructure.workflow.serviceTask.client.builder.NetworkRpcInputEntityBuilder;
 import org.openecomp.mso.bpmn.infrastructure.workflow.serviceTask.client.entity.RpcNetworkTopologyOperationInputEntity;
 import org.openecomp.mso.bpmn.infrastructure.workflow.serviceTask.client.entity.RpcNetworkTopologyOperationOutputEntity;
@@ -71,7 +72,8 @@ public class SdncUnderlayVpnOperationClient {
         updateProgress(null, null, "50", "RequestBody build finished!");
         RpcNetworkTopologyOperationOutputEntity networkRpcOutputEntiy = null;
         try {
-            networkRpcOutputEntiy = genericResourceApiClient.postNetworkTopologyOperation(body).execute().body();
+            networkRpcOutputEntiy = genericResourceApiClient.postNetworkTopologyOperation
+                    (HeaderUtil.DefaulAuth ,body).execute().body();
         } catch (Exception e) {
             logger.debug("Exception: ", e);
             updateProgress(RequestsDbConstant.Status.ERROR, null, null, "sendRestrequestAndHandleResponse exception:" + e.getMessage());
index 62375af..23ad422 100644 (file)
@@ -26,6 +26,7 @@ import org.onap.msb.sdk.httpclient.annotaion.ServiceHttpEndPoint;
 import org.openecomp.mso.bpmn.infrastructure.workflow.serviceTask.client.entity.*;
 import retrofit2.Call;
 import retrofit2.http.Body;
+import retrofit2.http.Header;
 import retrofit2.http.POST;
 
 /**
@@ -35,13 +36,16 @@ import retrofit2.http.POST;
 public interface GenericResourceApi {
 
     @POST("/restconf/operations/GENERIC-RESOURCE-API:network-topology-operation")
-    Call<ResponseBody> postNetworkTopologyOperation(@Body RequestBody input);
+    Call<ResponseBody> postNetworkTopologyOperation(@Header("Authorization") String authorization,
+                                                    @Body RequestBody input);
 
     @POST("/restconf/operations/GENERIC-RESOURCE-API:network-topology-operation")
-    Call<RpcNetworkTopologyOperationOutputEntity> postNetworkTopologyOperation(@Body RpcNetworkTopologyOperationInputEntity input);
+    Call<RpcNetworkTopologyOperationOutputEntity> postNetworkTopologyOperation(@Header("Authorization") String authorization,
+                                                                               @Body RpcNetworkTopologyOperationInputEntity input);
 
     @POST("/restconf/operations/GENERIC-RESOURCE-API:service-topology-operation")
-    Call<RpcServiceTopologyOperationOutputEntity> postServiceTopologyOperation(@Body RpcServiceTopologyOperationInputEntity input);
+    Call<RpcServiceTopologyOperationOutputEntity> postServiceTopologyOperation(@Header("Authorization") String authorization,
+                                                                               @Body RpcServiceTopologyOperationInputEntity input);
 
 }
 
diff --git a/bpmn/MSOInfrastructureBPMN/src/main/java/org/openecomp/mso/bpmn/infrastructure/workflow/serviceTask/client/HeaderUtil.java b/bpmn/MSOInfrastructureBPMN/src/main/java/org/openecomp/mso/bpmn/infrastructure/workflow/serviceTask/client/HeaderUtil.java
new file mode 100644 (file)
index 0000000..a43eb52
--- /dev/null
@@ -0,0 +1,45 @@
+/*-
+ * ============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;
+
+import java.util.Base64;
+
+public class HeaderUtil {
+
+    public static final String USER = "admin";
+    public static final String PASS = "Kp8bJ4SXszM0WXlhak3eHlcse2gAw84vaoGGmJvUy2U";
+    public static final String DefaulAuth = getAuthorization(USER, PASS);
+
+    public static String getAuthorization(String usr, String pwd) {
+
+        return "Basic " + base64Encode(usr + ":" + pwd);
+    }
+
+    private static String base64Encode(String str) {
+        String base64 = str;
+        try {
+            base64 = Base64.getEncoder()
+                .encodeToString(str.getBytes("utf-8"));
+        } catch (Exception ex) {
+        }
+        return base64;
+    }
+}
index 0634da7..36961de 100644 (file)
@@ -114,25 +114,25 @@ public abstract class AbstractBuilder<IN, OUT> {
      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.getName();
           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 (isOverlay(resourceType)) {
-                         action = /*RequestInformation.*/RequestAction.DeActivateDCINetworkInstance.name();
+                         action = /*RequestInformation.*/RequestAction.DeActivateDCINetworkInstance.getName();
                     } else if (isUnderlay(resourceType)) {
-                         action = /*RequestInformation.*/RequestAction.DeleteNetworkInstance.name();
+                         action = /*RequestInformation.*/RequestAction.DeleteNetworkInstance.getName();
                     } else {
-                         action = /*RequestInformation.*/RequestAction.DeleteServiceInstance.name();
+                         action = /*RequestInformation.*/RequestAction.DeleteServiceInstance.getName();
                     }
                } else if (RequestsDbConstant.OperationType.CREATE.equals(operType)) {
                     if (isOverlay(resourceType)) {
-                         action = /*RequestInformation.*/RequestAction.ActivateDCINetworkInstance.name();
+                         action = /*RequestInformation.*/RequestAction.ActivateDCINetworkInstance.getName();
                     } else if (isUnderlay(resourceType)) {
-                         action = /*RequestInformation.*/RequestAction.CreateNetworkInstance.name();
+                         action = /*RequestInformation.*/RequestAction.CreateNetworkInstance.getName();
                     } else {
-                         action = /*RequestInformation.*/RequestAction.CreateServiceInstance.name();
+                         action = /*RequestInformation.*/RequestAction.CreateServiceInstance.getName();
                     }
                }
           }
@@ -148,21 +148,25 @@ public abstract class AbstractBuilder<IN, OUT> {
      }
 
      protected String getSvcAction(DelegateExecution execution) {
-          String action = /*SdncRequestHeader.*/SvcAction.Create.name();
+          String action = /*SdncRequestHeader.*/SvcAction.Create.getName();
           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 (isOverlay(resourceType)) {
-                         action = /*SdncRequestHeader.*/SvcAction.Deactivate.name();
+                         action = /*SdncRequestHeader.*/SvcAction.Deactivate.getName();
+                    } else if (isUnderlay(resourceType)) {
+                         action = /*SdncRequestHeader.*/SvcAction.Delete.getName();
                     } else {
-                         action = /*SdncRequestHeader.*/SvcAction.Delete.name();
+                         action = /*SdncRequestHeader.*/SvcAction.Unassign.getName();
                     }
                } else if (RequestsDbConstant.OperationType.CREATE.equals(operType)) {
                     if (isOverlay(resourceType)) {
-                         action = /*SdncRequestHeader.*/SvcAction.Activate.name();
+                         action = /*SdncRequestHeader.*/SvcAction.Activate.getName();
+                    } else if (isUnderlay(resourceType)) {
+                         action = /*SdncRequestHeader.*/SvcAction.Create.getName();
                     } else {
-                         action = /*SdncRequestHeader.*/SvcAction.Create.name();
+                         action = /*SdncRequestHeader.*/SvcAction.Assign.getName();
                     }
                }
           }
index 02ac682..3d59d3b 100644 (file)
@@ -26,13 +26,13 @@ import com.fasterxml.jackson.annotation.JsonProperty;
  * Created by 10112215 on 2017/9/20.
  */
 public class NetworkInformationEntity {
-    @JsonProperty("network-id")
+    @JsonProperty("GENERIC-RESOURCE-API:network-id")
     private String networkId;
 
-    @JsonProperty("network-type")
+    @JsonProperty("GENERIC-RESOURCE-API:network-type")
     private String networkType;
 
-    @JsonProperty("onap-model-information")
+    @JsonProperty("GENERIC-RESOURCE-API:onap-model-information")
     private OnapModelInformationEntity onapModelInformation;
 
     public String getNetworkId() {
index 1aff6e9..420d547 100644 (file)
@@ -26,19 +26,19 @@ import com.fasterxml.jackson.annotation.JsonProperty;
  * Created by 10112215 on 2017/9/20.
  */
 public class NetworkRequestInputEntity {
-    @JsonProperty("network-name")
+    @JsonProperty("GENERIC-RESOURCE-API:network-name")
     private String networkName;
 
-    @JsonProperty("tenant")
+    @JsonProperty("GENERIC-RESOURCE-API:tenant")
     private String tenant;
 
-    @JsonProperty("aic-cloud-region")
+    @JsonProperty("GENERIC-RESOURCE-API:aic-cloud-region")
     private String aicCloudRegion;
 
-    @JsonProperty("aic-clli")
+    @JsonProperty("GENERIC-RESOURCE-API:aic-clli")
     private String aicClli;
 
-    @JsonProperty("network-input-parameters")
+    @JsonProperty("GENERIC-RESOURCE-API:network-input-parameters")
     private NetworkInputPaarametersEntity networkInputPaarameters;
 
     public String getNetworkName() {
index 69ee287..aa8ea39 100644 (file)
@@ -26,10 +26,10 @@ import com.fasterxml.jackson.annotation.JsonProperty;
  * Created by 10112215 on 2017/9/22.
  */
 public class NetworkResponseInformationEntity {
-    @JsonProperty("instance-id")
+    @JsonProperty("GENERIC-RESOURCE-API:instance-id")
     private String instanceId;
 
-    @JsonProperty("object-path")
+    @JsonProperty("GENERIC-RESOURCE-API:object-path")
     private String objectPath;
 
     public String getInstanceId() {
index 2fbc23e..1ce0b45 100644 (file)
@@ -26,19 +26,19 @@ import com.fasterxml.jackson.annotation.JsonProperty;
  * Created by 10112215 on 2017/9/20.
  */
 public class NetworkTopologyOperationInputEntity {
-    @JsonProperty("sdnc-request-header")
+    @JsonProperty("GENERIC-RESOURCE-API:sdnc-request-header")
     private SdncRequestHeaderEntity sdncRequestHeader;
 
-    @JsonProperty("request-information")
+    @JsonProperty("GENERIC-RESOURCE-API:request-information")
     private RequestInformationEntity requestInformation;
 
-    @JsonProperty("service-information")
+    @JsonProperty("GENERIC-RESOURCE-API:service-information")
     private ServiceInformationEntity serviceInformation;
 
-    @JsonProperty("network-information")
+    @JsonProperty("GENERIC-RESOURCE-API:network-information")
     private NetworkInformationEntity networkInformation;
 
-    @JsonProperty("network-request-input")
+    @JsonProperty("GENERIC-RESOURCE-API:network-request-input")
     private NetworkRequestInputEntity networkRequestInput;
 
     public SdncRequestHeaderEntity getSdncRequestHeader() {
index 4be0844..c835efb 100644 (file)
@@ -26,22 +26,22 @@ import com.fasterxml.jackson.annotation.JsonProperty;
  * Created by 10112215 on 2017/9/22.
  */
 public class NetworkTopologyOperationOutputEntity {
-    @JsonProperty("svc-request-id")
+    @JsonProperty("GENERIC-RESOURCE-API:svc-request-id")
     private String svcRequestId;
 
-    @JsonProperty("response-code")
+    @JsonProperty("GENERIC-RESOURCE-API:response-code")
     private String responseCode;
 
-    @JsonProperty("response-message")
+    @JsonProperty("GENERIC-RESOURCE-API:response-message")
     private String responseMessage;
 
-    @JsonProperty("ack-final-indicator")
+    @JsonProperty("GENERIC-RESOURCE-API:ack-final-indicator")
     private String ackFinalIndicator;
 
-    @JsonProperty("network-response-information")
+    @JsonProperty("GENERIC-RESOURCE-API:network-response-information")
     private NetworkResponseInformationEntity networkResponseInformation;
 
-    @JsonProperty("service-response-information")
+    @JsonProperty("GENERIC-RESOURCE-API:service-response-information")
     private ServiceResponseInformationEntity serviceResponseInformation;
 
     public String getSvcRequestId() {
index f061c9a..eeb8eda 100644 (file)
@@ -26,19 +26,19 @@ import com.fasterxml.jackson.annotation.JsonProperty;
  * Created by 10112215 on 2017/9/20.
  */
 public class OnapModelInformationEntity {
-    @JsonProperty("model-invariant-uuid")
+    @JsonProperty("GENERIC-RESOURCE-API:model-invariant-uuid")
     private String modelInvariantUuid;
 
-    @JsonProperty("model-customization-uuid")
+    @JsonProperty("GENERIC-RESOURCE-API:model-customization-uuid")
     private String modelCustomizationUuid;
 
-    @JsonProperty("model-uuid")
+    @JsonProperty("GENERIC-RESOURCE-API:model-uuid")
     private String modelUuid;
 
-    @JsonProperty("model-version")
+    @JsonProperty("GENERIC-RESOURCE-API:model-version")
     private String modelVersion;
 
-    @JsonProperty("model-name")
+    @JsonProperty("GENERIC-RESOURCE-API:model-name")
     private String modelName;
 
     public String getModelInvariantUuid() {
index 8c2f217..b45a1c3 100644 (file)
@@ -26,10 +26,10 @@ import com.fasterxml.jackson.annotation.JsonProperty;
  * Created by 10112215 on 2017/9/20.
  */
 public class ParamEntity {
-    @JsonProperty("name")
+    @JsonProperty("GENERIC-RESOURCE-API:name")
     private String name;
 
-    @JsonProperty("value")
+    @JsonProperty("GENERIC-RESOURCE-API:value")
     private String value;
 
     public String getName() {
index 1538b64..2982e5a 100644 (file)
@@ -74,21 +74,21 @@ public class RequestInformationEntity {
         this.orerVersion = orerVersion;
     }
 
-    @JsonProperty("request-id")
+    @JsonProperty("GENERIC-RESOURCE-API:request-id")
     private String requestId;
 
-    @JsonProperty("request-action")
+    @JsonProperty("GENERIC-RESOURCE-API:request-action")
     private String requestAction;
 
-    @JsonProperty("source")
+    @JsonProperty("GENERIC-RESOURCE-API:source")
     private String source;
 
-    @JsonProperty("notification-url")
+    @JsonProperty("GENERIC-RESOURCE-API:notification-url")
     private String notificationUrl;
 
-    @JsonProperty("order-number")
+    @JsonProperty("GENERIC-RESOURCE-API:order-number")
     private String orderUnmber;
 
-    @JsonProperty("order-version")
+    @JsonProperty("GENERIC-RESOURCE-API:order-version")
     private String orerVersion;
 }
index c59cc4e..02fb111 100644 (file)
@@ -26,7 +26,7 @@ import com.fasterxml.jackson.annotation.JsonProperty;
  * Created by 10112215 on 2017/9/26.
  */
 public class RpcServiceTopologyOperationOutputEntity {
-    @JsonProperty("output")
+    @JsonProperty("GENERIC-RESOURCE-API:output")
     private ServiceTopologyOperationOutputEntity output;
 
     public ServiceTopologyOperationOutputEntity getOutput() {
index 1ea1045..7e28aa0 100644 (file)
@@ -26,13 +26,13 @@ import com.fasterxml.jackson.annotation.JsonProperty;
  * Created by 10112215 on 2017/9/20.
  */
 public class SdncRequestHeaderEntity {
-    @JsonProperty("svc-request-id")
+    @JsonProperty("GENERIC-RESOURCE-API:svc-request-id")
     private String svcRequestId;
 
-    @JsonProperty("svc-action")
+    @JsonProperty("GENERIC-RESOURCE-API:svc-action")
     private String svcAction;
 
-    @JsonProperty("svc-notification-url")
+    @JsonProperty("GENERIC-RESOURCE-API:svc-notification-url")
     private String svcNotificationUrl;
 
     public String getSvcRequestId() {
index 58d50fa..46b5390 100644 (file)
@@ -26,22 +26,22 @@ import com.fasterxml.jackson.annotation.JsonProperty;
  * Created by 10112215 on 2017/9/20.
  */
 public class ServiceInformationEntity {
-    @JsonProperty("service-id")
+    @JsonProperty("GENERIC-RESOURCE-API:service-id")
     private String serviceId;
 
-    @JsonProperty("subscription-service-type")
+    @JsonProperty("GENERIC-RESOURCE-API:subscription-service-type")
     private String subscriptionServiceType;
 
-    @JsonProperty("onap-model-information")
+    @JsonProperty("GENERIC-RESOURCE-API:onap-model-information")
     private OnapModelInformationEntity onapModelInformation;
 
-    @JsonProperty("service-instance-id")
+    @JsonProperty("GENERIC-RESOURCE-API:service-instance-id")
     private String serviceInstanceId;
 
-    @JsonProperty("global-customer-id")
+    @JsonProperty("GENERIC-RESOURCE-API:global-customer-id")
     private String globalCustomerId;
 
-    @JsonProperty("subscriber-name")
+    @JsonProperty("GENERIC-RESOURCE-API:subscriber-name")
     private String subscriberName;
 
     public String getServiceId() {
index 576995d..934a946 100644 (file)
@@ -27,10 +27,10 @@ import com.fasterxml.jackson.annotation.JsonProperty;
  */
 public class ServiceRequestInputEntity {
 
-    @JsonProperty("service-instance-name")
+    @JsonProperty("GENERIC-RESOURCE-API:service-instance-name")
     private String serviceInstanceName;
 
-    @JsonProperty("service-input-parameters")
+    @JsonProperty("GENERIC-RESOURCE-API:service-input-parameters")
     private ServiceInputParametersEntity serviceInputParametersEntity;
 
     public String getServiceInstanceName() {
index ade389b..ee0104b 100644 (file)
@@ -26,10 +26,10 @@ import com.fasterxml.jackson.annotation.JsonProperty;
  * Created by 10112215 on 2017/9/22.
  */
 public class ServiceResponseInformationEntity {
-    @JsonProperty("instance-id")
+    @JsonProperty("GENERIC-RESOURCE-API:instance-id")
     private String instanceId;
 
-    @JsonProperty("object-path")
+    @JsonProperty("GENERIC-RESOURCE-API:object-path")
     private String objectPath;
 
     public String getInstanceId() {
index d817b0c..ba46eb7 100644 (file)
@@ -26,16 +26,16 @@ import com.fasterxml.jackson.annotation.JsonProperty;
  * Created by 10112215 on 2017/9/26.
  */
 public class ServiceTopologyOperationInputEntity {
-    @JsonProperty("sdnc-request-header")
+    @JsonProperty("GENERIC-RESOURCE-API:sdnc-request-header")
     private SdncRequestHeaderEntity sdncRequestHeader;
 
-    @JsonProperty("request-information")
+    @JsonProperty("GENERIC-RESOURCE-API:request-information")
     private RequestInformationEntity requestInformation;
 
-    @JsonProperty("service-information")
+    @JsonProperty("GENERIC-RESOURCE-API:service-information")
     private ServiceInformationEntity serviceInformation;
 
-    @JsonProperty("service-request-input")
+    @JsonProperty("GENERIC-RESOURCE-API:service-request-input")
     private ServiceRequestInputEntity serviceRequestInput;
 
     public SdncRequestHeaderEntity getSdncRequestHeader() {
index ebc1ca8..216a3d4 100644 (file)
@@ -26,19 +26,19 @@ import com.fasterxml.jackson.annotation.JsonProperty;
  * Created by 10112215 on 2017/9/26.
  */
 public class ServiceTopologyOperationOutputEntity {
-    @JsonProperty("svc-request-id")
+    @JsonProperty("GENERIC-RESOURCE-API:svc-request-id")
     private String svcRequestId;
 
-    @JsonProperty("response-code")
+    @JsonProperty("GENERIC-RESOURCE-API:response-code")
     private String responseCode;
 
-    @JsonProperty("response-message")
+    @JsonProperty("GENERIC-RESOURCE-API:response-message")
     private String responseMessage;
 
-    @JsonProperty("ack-final-indicator")
+    @JsonProperty("GENERIC-RESOURCE-API:ack-final-indicator")
     private String ackFinalIndicator;
 
-    @JsonProperty("service-response-information")
+    @JsonProperty("GENERIC-RESOURCE-API:service-response-information")
     private ServiceResponseInformationEntity serviceResponseInformation;
 
     public String getSvcRequestId() {