Add unit test cases
[vfc/nfvo/driver/vnfm/svnfm.git] / nokia / vnfmdriver / vfcadaptorservice / vfcadaptor / src / main / java / org / onap / vfc / nfvo / driver / vnfm / svnfm / cbam / impl / CbamMgmrImpl.java
1 /*
2  * Copyright 2016-2017, Nokia Corporation
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *     http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16
17 package org.onap.vfc.nfvo.driver.vnfm.svnfm.cbam.impl;
18
19 import java.io.BufferedReader;
20 import java.io.IOException;
21 import java.io.InputStream;
22 import java.io.InputStreamReader;
23 import java.util.HashMap;
24 import java.util.List;
25
26 import org.apache.http.client.ClientProtocolException;
27 import org.json.JSONException;
28 import org.json.JSONObject;
29 import org.onap.vfc.nfvo.driver.vnfm.svnfm.cbam.bo.CBAMCreateSubscriptionRequest;
30 import org.onap.vfc.nfvo.driver.vnfm.svnfm.cbam.bo.CBAMCreateSubscriptionResponse;
31 import org.onap.vfc.nfvo.driver.vnfm.svnfm.cbam.bo.CBAMCreateVnfRequest;
32 import org.onap.vfc.nfvo.driver.vnfm.svnfm.cbam.bo.CBAMCreateVnfResponse;
33 import org.onap.vfc.nfvo.driver.vnfm.svnfm.cbam.bo.CBAMHealVnfRequest;
34 import org.onap.vfc.nfvo.driver.vnfm.svnfm.cbam.bo.CBAMHealVnfResponse;
35 import org.onap.vfc.nfvo.driver.vnfm.svnfm.cbam.bo.CBAMInstantiateVnfRequest;
36 import org.onap.vfc.nfvo.driver.vnfm.svnfm.cbam.bo.CBAMInstantiateVnfResponse;
37 import org.onap.vfc.nfvo.driver.vnfm.svnfm.cbam.bo.CBAMModifyVnfRequest;
38 import org.onap.vfc.nfvo.driver.vnfm.svnfm.cbam.bo.CBAMModifyVnfResponse;
39 import org.onap.vfc.nfvo.driver.vnfm.svnfm.cbam.bo.CBAMQueryOperExecutionResponse;
40 import org.onap.vfc.nfvo.driver.vnfm.svnfm.cbam.bo.CBAMQueryVnfResponse;
41 import org.onap.vfc.nfvo.driver.vnfm.svnfm.cbam.bo.CBAMScaleVnfRequest;
42 import org.onap.vfc.nfvo.driver.vnfm.svnfm.cbam.bo.CBAMScaleVnfResponse;
43 import org.onap.vfc.nfvo.driver.vnfm.svnfm.cbam.bo.CBAMTerminateVnfRequest;
44 import org.onap.vfc.nfvo.driver.vnfm.svnfm.cbam.bo.CBAMTerminateVnfResponse;
45 import org.onap.vfc.nfvo.driver.vnfm.svnfm.cbam.bo.CBAMVnfNotificationRequest;
46 import org.onap.vfc.nfvo.driver.vnfm.svnfm.cbam.bo.CBAMVnfNotificationResponse;
47 import org.onap.vfc.nfvo.driver.vnfm.svnfm.cbam.bo.entity.SubscriptionResponse;
48 import org.onap.vfc.nfvo.driver.vnfm.svnfm.cbam.bo.entity.VnfcResourceInfo;
49 import org.onap.vfc.nfvo.driver.vnfm.svnfm.cbam.inf.CbamMgmrInf;
50 import org.onap.vfc.nfvo.driver.vnfm.svnfm.common.bo.AdaptorEnv;
51 import org.onap.vfc.nfvo.driver.vnfm.svnfm.constant.CommonConstants;
52 import org.onap.vfc.nfvo.driver.vnfm.svnfm.http.client.HttpClientProcessorInf;
53 import org.onap.vfc.nfvo.driver.vnfm.svnfm.http.client.HttpResult;
54 import org.slf4j.Logger;
55 import org.slf4j.LoggerFactory;
56 import org.springframework.beans.factory.annotation.Autowired;
57 import org.springframework.http.MediaType;
58 import org.springframework.stereotype.Component;
59 import org.springframework.web.bind.annotation.RequestMethod;
60
61 import com.google.common.reflect.TypeToken;
62 import com.google.gson.Gson;
63
64 @Component
65 public class CbamMgmrImpl implements CbamMgmrInf {
66         private static final Logger logger = LoggerFactory.getLogger(CbamMgmrImpl.class);
67         private Gson gson = new Gson();
68
69         @Autowired
70         private AdaptorEnv adaptorEnv;
71
72         @Autowired
73         HttpClientProcessorInf httpClientProcessor;
74
75         public String retrieveToken() throws ClientProtocolException, IOException, JSONException {
76                 String result = null;
77                 String url = adaptorEnv.getCbamApiUriFront() + CommonConstants.CbamRetrieveTokenPath;
78                 HashMap<String, String> map = new HashMap<>();
79                 map.put(CommonConstants.ACCEPT, "*/*");
80                 map.put(CommonConstants.CONTENT_TYPE, MediaType.APPLICATION_FORM_URLENCODED_VALUE);
81
82                 String bodyPostStr = String.format(CommonConstants.CbamRetrieveTokenPostStr, adaptorEnv.getClientId(),
83                                 adaptorEnv.getClientSecret(), adaptorEnv.getCbamUserName(), adaptorEnv.getCbamPassword());
84
85                 logger.debug("CbamMgmrImpl -> retrieveToken, url is " + url);
86                 logger.debug("CbamMgmrImpl -> retrieveToken, bodyPostStr is " + bodyPostStr);
87
88                 String responseStr = httpClientProcessor.process(url, RequestMethod.POST, map, bodyPostStr).getContent();
89
90                 logger.info("CbamMgmrImpl -> retrieveToken, responseStr is " + responseStr);
91
92                 JSONObject tokenJsonObject = new JSONObject(responseStr);
93
94                 result = tokenJsonObject.getString(CommonConstants.CBAM_TOKEN_KEY);
95
96                 return result;
97         }
98
99         public CBAMCreateVnfResponse createVnf(CBAMCreateVnfRequest cbamRequest)
100                         throws ClientProtocolException, IOException {
101                 String httpPath = CommonConstants.CbamCreateVnfPath;
102                 RequestMethod method = RequestMethod.POST;
103
104                 HttpResult httpResult = operateCbamHttpTask(cbamRequest, httpPath, method);
105                 String responseStr = httpResult.getContent();
106
107                 logger.info("CbamMgmrImpl -> createVnf, responseStr is " + responseStr);
108                 int code = httpResult.getStatusCode();
109                 if (code == 201) {
110                         logger.info("CbamMgmrImpl -> createVnf success");
111                 } else {
112                         logger.error("CbamMgmrImpl -> createVnf error ");
113                 }
114                 CBAMCreateVnfResponse response = gson.fromJson(responseStr, CBAMCreateVnfResponse.class);
115
116                 return response;
117         }
118
119         public CBAMModifyVnfResponse modifyVnf(CBAMModifyVnfRequest cbamRequest, String vnfInstanceId)
120                         throws ClientProtocolException, IOException {
121                 String httpPath = String.format(CommonConstants.CbamModifyVnfPath, vnfInstanceId);
122
123                 RequestMethod method = RequestMethod.PATCH;
124
125                 HttpResult httpResult = operateCbamHttpTask(cbamRequest, httpPath, method);
126                 String responseStr = httpResult.getContent();
127
128                 logger.info("CbamMgmrImpl -> modifyVnf, responseStr is " + responseStr);
129                 int code = httpResult.getStatusCode();
130
131                 if(code == 202) {
132                         logger.info("CbamMgmrImpl -> modifyVnf success");
133                 } else {
134                         logger.error("CbamMgmrImpl -> modifyVnf error, statusCode = " + code);
135                 }
136                 CBAMModifyVnfResponse response = gson.fromJson(responseStr, CBAMModifyVnfResponse.class);
137                 return response;
138         }
139
140         /*
141          * (non-Javadoc)
142          * 
143          * @see com.nokia.vfcadaptor.cbam.impl.CbamMgmrInf#instantiateVnf(com.nokia.
144          * vfcadaptor.cbam.bo.CBAMInstantiateVnfRequest, java.lang.String)
145          */
146         public CBAMInstantiateVnfResponse instantiateVnf(CBAMInstantiateVnfRequest cbamRequest, String vnfInstanceId)
147                         throws ClientProtocolException, IOException {
148                 String httpPath = String.format(CommonConstants.CbamInstantiateVnfPath, vnfInstanceId);
149                 RequestMethod method = RequestMethod.POST;
150
151                 HttpResult httpResult = operateCbamHttpTask(cbamRequest, httpPath, method);
152                 String responseStr = httpResult.getContent();
153
154                 logger.info("CbamMgmrImpl -> instantiateVnf, responseStr is " + responseStr);
155                 int code = httpResult.getStatusCode();
156                 if (code == 202) {
157                         logger.info("CbamMgmrImpl -> instantiateVnf success ");
158                 } else {
159                         logger.error("CbamMgmrImpl -> instantiateVnf error ");
160                 }
161                 CBAMInstantiateVnfResponse response = gson.fromJson(responseStr, CBAMInstantiateVnfResponse.class);
162
163                 return response;
164         }
165
166         public CBAMTerminateVnfResponse terminateVnf(CBAMTerminateVnfRequest cbamRequest, String vnfInstanceId)
167                         throws ClientProtocolException, IOException {
168                 String httpPath = String.format(CommonConstants.CbamTerminateVnfPath, vnfInstanceId);
169                 RequestMethod method = RequestMethod.POST;
170
171                 HttpResult httpResult = operateCbamHttpTask(cbamRequest, httpPath, method);
172                 String responseStr = httpResult.getContent();
173
174                 logger.info("CbamMgmrImpl -> terminateVnf, responseStr is " + responseStr);
175                 int code = httpResult.getStatusCode();
176                 if (code == 202) {
177                         logger.info("CbamMgmrImpl -> terminateVnf  sucess ");
178                 } else {
179                         logger.error("CbamMgmrImpl -> terminateVnf error ");
180                 }
181                 CBAMTerminateVnfResponse response = gson.fromJson(responseStr, CBAMTerminateVnfResponse.class);
182
183                 return response;
184         }
185
186         public void deleteVnf(String vnfInstanceId) throws ClientProtocolException, IOException {
187                 String httpPath = String.format(CommonConstants.CbamDeleteVnfPath, vnfInstanceId);
188                 RequestMethod method = RequestMethod.DELETE;
189                 HttpResult httpResult = operateCbamHttpTask(null, httpPath, method);
190
191                 int code = httpResult.getStatusCode();
192                 if (code == 204) {
193                         logger.info("CbamMgmrImpl -> deleteVnf success.");
194                 } else {
195                         logger.error("CbamMgmrImpl -> deleteVnf error. detail info is " + httpResult.getContent());
196                 }
197
198         }
199
200         public CBAMScaleVnfResponse scaleVnf(CBAMScaleVnfRequest cbamRequest, String vnfInstanceId)
201                         throws ClientProtocolException, IOException {
202                 String httpPath = String.format(CommonConstants.CbamScaleVnfPath, vnfInstanceId);
203                 RequestMethod method = RequestMethod.POST;
204
205                 HttpResult httpResult = operateCbamHttpTask(cbamRequest, httpPath, method);
206                 String responseStr = httpResult.getContent();
207                 int code = httpResult.getStatusCode();
208                 if (code == 202) {
209                         logger.info("CbamMgmrImpl -> scaleVnf success.");
210                 } else {
211                         logger.error("CbamMgmrImpl -> scaleVnf error. detail info is " + httpResult.getContent());
212                 }
213                 CBAMScaleVnfResponse response = gson.fromJson(responseStr, CBAMScaleVnfResponse.class);
214
215                 return response;
216         }
217
218         public CBAMHealVnfResponse healVnf(CBAMHealVnfRequest cbamRequest, String vnfInstanceId)
219                         throws ClientProtocolException, IOException {
220                 String httpPath = String.format(CommonConstants.CbamHealVnfPath, vnfInstanceId);
221                 RequestMethod method = RequestMethod.POST;
222
223                 HttpResult httpResult = operateCbamHttpTask(cbamRequest, httpPath, method);
224                 String responseStr = httpResult.getContent();
225
226                 logger.info("CbamMgmrImpl -> healVnf, responseStr is " + responseStr);
227                 int code = httpResult.getStatusCode();
228                 if (code == 202) {
229                         logger.info("CbamMgmrImpl -> healVnf success.");
230                 } else {
231                         logger.error("CbamMgmrImpl -> healVnf error. " + httpResult.getContent());
232                 }
233                 CBAMHealVnfResponse response = gson.fromJson(responseStr, CBAMHealVnfResponse.class);
234
235                 return response;
236         }
237
238         public CBAMQueryVnfResponse queryVnf(String vnfInstanceId) throws ClientProtocolException, IOException {
239                 String httpPath = String.format(CommonConstants.CbamQueryVnfPath, vnfInstanceId);
240                 RequestMethod method = RequestMethod.GET;
241
242                 HttpResult httpResult = operateCbamHttpTask(null, httpPath, method);
243                 String responseStr = httpResult.getContent();
244
245                 logger.info("CbamMgmrImpl -> queryVnf, responseStr is " + responseStr);
246                 int code = httpResult.getStatusCode();
247                 if (code == 200) {
248                         logger.info("CbamMgmrImpl -> queryVnf success.");
249                 } else {
250                         logger.error("CbamMgmrImpl -> queryVnf error. " + httpResult.getContent());
251                 }
252
253                 CBAMQueryVnfResponse response = gson.fromJson(responseStr, CBAMQueryVnfResponse.class);
254
255                 return response;
256         }
257
258         public List<VnfcResourceInfo> queryVnfcResource(String vnfInstanceId) throws ClientProtocolException, IOException {
259                 String httpPath = String.format(CommonConstants.CbamQueryVnfcResourcePath, vnfInstanceId);
260                 RequestMethod method = RequestMethod.GET;
261
262                 HttpResult httpResult = operateCbamHttpTask(null, httpPath, method);
263                 String responseStr = httpResult.getContent();
264
265                 logger.info("CbamMgmrImpl -> queryVnfcResource, responseStr is " + responseStr);
266                 int code = httpResult.getStatusCode();
267                 if (code == 200) {
268                         logger.info("CbamMgmrImpl -> queryVnfcResource success.");
269                 } else {
270                         logger.error("CbamMgmrImpl -> queryVnfcResource error. ");
271                 }
272                 List<VnfcResourceInfo> response = gson.fromJson(responseStr, new TypeToken<List<VnfcResourceInfo>>() {
273                 }.getType());
274                 ;
275
276                 return response;
277         }
278
279         public HttpResult operateCbamHttpTask(Object httpBodyObj, String httpPath, RequestMethod method)
280                         throws ClientProtocolException, IOException {
281                 String token = null;
282                 try {
283                         token = retrieveToken();
284                 } catch (JSONException e) {
285                         logger.error("retrieveTokenError ", e);
286                 }
287
288                 String url = adaptorEnv.getCbamApiUriFront() + httpPath;
289
290                 HashMap<String, String> map = new HashMap<>();
291                 map.put(CommonConstants.AUTHORIZATION, "bearer " + token);
292                 map.put(CommonConstants.CONTENT_TYPE, MediaType.APPLICATION_JSON_VALUE);
293        
294                 return httpClientProcessor.process(url, method, map, gson.toJson(httpBodyObj));
295         }
296
297         public CBAMQueryOperExecutionResponse queryOperExecution(String execId)
298                         throws ClientProtocolException, IOException {
299                 String httpPath = String.format(CommonConstants.CbamGetOperStatusPath, execId);
300                 RequestMethod method = RequestMethod.GET;
301
302                 HttpResult httpResult = operateCbamHttpTask(null, httpPath, method);
303                 String responseStr = httpResult.getContent();
304
305                 logger.info("CbamMgmrImpl -> CBAMQueryOperExecutionResponse, responseStr is " + responseStr);
306
307                 int code = httpResult.getStatusCode();
308                 if (code == 200) {
309                         logger.info("CbamMgmrImpl -> CBAMQueryOperExecutionResponse, success");
310                 } else if (code == 202) {
311                         logger.info("CbamMgmrImpl -> CBAMQueryOperExecutionResponse, ongoing");
312                 } else {
313                         logger.error("CbamMgmrImpl -> CBAMQueryOperExecutionResponse, error");
314                 }
315
316                 CBAMQueryOperExecutionResponse response = gson.fromJson(responseStr, CBAMQueryOperExecutionResponse.class);
317
318                 return response;
319         }
320
321         public void setAdaptorEnv(AdaptorEnv adaptorEnv) {
322                 this.adaptorEnv = adaptorEnv;
323         }
324
325         @Override
326         public void uploadVnfPackage(String cbamPackageFilePath) throws ClientProtocolException, IOException {
327                 String httpPath = CommonConstants.CbamUploadVnfPackagePath;
328                 RequestMethod method = RequestMethod.POST;
329
330                 HttpResult httpResult = operateCbamHttpUploadTask(cbamPackageFilePath, httpPath, method);
331                 String responseStr = httpResult.getContent();
332
333                 logger.info("CbamMgmrImpl -> uploadVnfPackage, statusCode is " + httpResult.getStatusCode() + ", cause is "
334                                 + httpResult.getStatusCause() + ". responseStr is " + responseStr);
335
336                 int code = httpResult.getStatusCode();
337                 if (code == 200) {
338                         logger.info("CbamMgmrImpl -> uploadVnfPackage, success");
339                         logger.info("Upload vnf package " + cbamPackageFilePath + " to CBAM is successful.");
340                 } else {
341                         logger.error("CbamMgmrImpl -> uploadVnfPackage, error");
342                 }
343         }
344
345         public HttpResult operateCbamHttpUploadTask(String filePath, String httpPath, RequestMethod method)
346                         throws ClientProtocolException, IOException {
347                 String token = null;
348                 try {
349                         token = retrieveToken();
350                 } catch (JSONException e) {
351                         logger.error("retrieveTokenError ", e);
352                 }
353                 String url = adaptorEnv.getCbamApiUriFront() + httpPath;
354                 logger.info("start to upload file.");
355                 String command = "/usr/bin/curl --insecure -X POST -H \"Authorization: bearer " + token + "\" --form content=@"
356                                 + filePath + " " + url;
357                 StringBuffer respStr = execCommand(command);
358
359                 // HashMap<String, String> map = new HashMap<>();
360                 // map.put(CommonConstants.AUTHORIZATION, "bearer " + token);
361                 // map.put(CommonConstants.CONTENT_TYPE, "multipart/form-data,
362                 // boundary=---CFSGSSGGSGdssdfsdhd---");
363                 // byte[] fileBytes = CommonUtil.getBytes(filePath);
364                 // logger.info("CbamMgmrImpl -> operateCbamHttpUploadTask, url is " + url);
365                 // logger.info("CbamMgmrImpl -> operateCbamHttpUploadTask, token is " + token);
366                 // logger.info("CbamMgmrImpl -> operateCbamHttpUploadTask, bodyPostStr byte
367                 // lenth is " + fileBytes.length);
368
369                 // return httpClientProcessor.processBytes(url, method, map, fileBytes);
370
371                 HttpResult hResult = new HttpResult();
372                 hResult.setStatusCause(respStr.toString());
373                 hResult.setContent(respStr.toString());
374                 hResult.setStatusCode(200);
375                 return hResult;
376
377                 // String charset = "UTF-8";
378                 // File uploadFile1 = new File(filePath);
379                 // String requestURL = url;
380                 // HttpResult result = new HttpResult();
381                 //
382                 // try {
383                 // MultipartUtility multipart = new MultipartUtility(requestURL, charset);
384                 //
385                 // multipart.addHeaderField("User-Agent", "CodeJava");
386                 // multipart.addHeaderField(CommonConstants.AUTHORIZATION, "bearer " + token);
387                 //
388                 // multipart.addFilePart("fileUpload", uploadFile1);
389                 //
390                 // List<String> response = multipart.finish();
391                 //
392                 // result.setContent(Arrays.deepToString(response.toArray(new String[0])));
393                 // result.setStatusCode(200);
394                 // } catch (Exception ex) {
395                 // logger.error("CbamMgmrImpl -> operateCbamHttpUploadTask, error ", ex);
396                 // result.setStatusCode(500);
397                 // }
398                 //
399                 // return result;
400         }
401
402         private StringBuffer execCommand(String command) {
403                 logger.info("CbamMgmrImpl -> execCommand, command is " + command);
404                 StringBuffer respStr = new StringBuffer("\r\n");
405                 try {
406                         String os = System.getProperty("os.name");
407                         String[] cmd = { "cmd", "/c", command };
408                         if (!os.toLowerCase().startsWith("win")) {
409                                 cmd = new String[] { "/bin/sh", "-c", command };
410                         }
411                         Process process = Runtime.getRuntime().exec(cmd);
412                         Thread t = new Thread(new InputStreamRunnable(process.getErrorStream(), "ErrorStream"));
413                         t.start();
414                         Thread.sleep(3000);
415                         InputStream fis = process.getInputStream();
416                         InputStreamReader isr = new InputStreamReader(fis);
417
418                         BufferedReader br = new BufferedReader(isr);
419                         String line = null;
420                         while ((line = br.readLine()) != null) {
421                                 respStr.append(line + "\r\n");
422                         }
423                         respStr.append("\r\n");
424                         process.waitFor();
425                         fis.close();
426                         isr.close();
427                         process.destroy();
428                         logger.info("operateCbamHttpUploadTask respStr is: " + respStr);
429                 } catch (Exception e) {
430                         logger.error("operateCbamHttpUploadTask error", e);
431                 }
432                 return respStr;
433         }
434
435         // public static String postByHttps(String url, String body, Object contentType)
436         // {
437         // String result = "";
438         // Protocol https = new Protocol("https", new
439         // HTTPSSecureProtocolSocketFactory(), 443);
440         // Protocol.registerProtocol("https", https);
441         // PostMethod post = new PostMethod(url);
442         // HttpClient client = new HttpClient();
443         // try {
444         // post.setRequestHeader("Content-Type", contentType);
445         // post.setRequestBody(body);
446         // client.executeMethod(post);
447         // result = post.getResponseBodyAsString();
448         // Protocol.unregisterProtocol("https");
449         // return result;
450         // } catch (HttpException e) {
451         // e.printStackTrace();
452         // } catch (IOException e) {
453         // e.printStackTrace();
454         // } catch(Exception e) {
455         // e.printStackTrace();
456         // }
457         //
458         // return "error";
459         // }
460
461         public HttpClientProcessorInf getHttpClientProcessor() {
462                 return httpClientProcessor;
463         }
464
465         public void setHttpClientProcessor(HttpClientProcessorInf httpClientProcessor) {
466                 this.httpClientProcessor = httpClientProcessor;
467         }
468
469         @Override
470         public CBAMCreateSubscriptionResponse createSubscription(CBAMCreateSubscriptionRequest subscriptionRequest)
471                         throws ClientProtocolException, IOException {
472                 String httpPath = String.format(CommonConstants.CbamCreateSubscriptionPath);
473                 RequestMethod method = RequestMethod.POST;
474                 logger.info("CbamMgmrImpl -> createSubscription, requestStr is " + gson.toJson(subscriptionRequest));
475                 HttpResult httpResult = operateCbamHttpTask(subscriptionRequest, httpPath, method);
476                 String responseStr = httpResult.getContent();
477                 
478                 CBAMCreateSubscriptionResponse response = null;
479
480                 logger.info("CbamMgmrImpl -> createSubscription, responseStr is " + responseStr);
481                 int code = httpResult.getStatusCode();
482                 if (code == 201) {
483                         logger.info("CbamMgmrImpl -> createSubscription success ");
484                         response = gson.fromJson(responseStr, CBAMCreateSubscriptionResponse.class);
485                 } else {
486                         logger.error("CbamMgmrImpl -> createSubscription error , statusCode = " + code);
487                 }
488
489                 return response;
490         }
491
492         @Override
493         public SubscriptionResponse getSubscription(String subscriptionId) throws ClientProtocolException, IOException {
494                 String httpPath = String.format(CommonConstants.CbamGetSubscriptionPath, subscriptionId);
495                 RequestMethod method = RequestMethod.GET;
496
497                 HttpResult httpResult = operateCbamHttpTask(null, httpPath, method);
498                 String responseStr = httpResult.getContent();
499
500                 logger.info("CbamMgmrImpl -> getSubscription, responseStr is " + responseStr);
501                 int code = httpResult.getStatusCode();
502                 if (code == 200) {
503                         logger.info("CbamMgmrImpl -> getSubscription success ");
504                 } else {
505                         logger.error("CbamMgmrImpl -> getSubscription error , statusCode = " + code);
506                 }
507                 SubscriptionResponse response = gson.fromJson(responseStr, SubscriptionResponse.class);
508
509                 return response;
510         }
511
512         @Override
513         public CBAMVnfNotificationResponse getNotification(CBAMVnfNotificationRequest getNotificationRequest)
514                         throws ClientProtocolException, IOException {
515                 String httpPath = String.format(CommonConstants.CbamGetNotificationPath);
516                 RequestMethod method = RequestMethod.GET;
517
518                 HttpResult httpResult = operateCbamHttpTask(getNotificationRequest, httpPath, method);
519                 String responseStr = httpResult.getContent();
520
521                 logger.info("CbamMgmrImpl -> getNotification, responseStr is " + responseStr);
522                 int code = httpResult.getStatusCode();
523                 if (code == 200) {
524                         logger.info("CbamMgmrImpl -> getNotification success ");
525                 } else {
526                         logger.error("CbamMgmrImpl -> getNotification error , statusCode = " + code);
527                 }
528                 CBAMVnfNotificationResponse  response = gson.fromJson(responseStr, CBAMVnfNotificationResponse.class);
529                 return response;
530         }
531
532 }