summaryrefslogtreecommitdiffstats
path: root/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/cbam/impl/CbamMgmrImpl.java
blob: 3f3ae57b90f5df3e620fa0eea12e16b5c077fa36 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
/*
 * Copyright 2016-2017, Nokia Corporation
 *
 * 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.
 */

package org.onap.vfc.nfvo.driver.vnfm.svnfm.cbam.impl;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.HashMap;
import java.util.List;

import org.apache.http.client.ClientProtocolException;
import org.json.JSONException;
import org.json.JSONObject;
import org.onap.vfc.nfvo.driver.vnfm.svnfm.cbam.bo.CBAMCreateSubscriptionRequest;
import org.onap.vfc.nfvo.driver.vnfm.svnfm.cbam.bo.CBAMCreateSubscriptionResponse;
import org.onap.vfc.nfvo.driver.vnfm.svnfm.cbam.bo.CBAMCreateVnfRequest;
import org.onap.vfc.nfvo.driver.vnfm.svnfm.cbam.bo.CBAMCreateVnfResponse;
import org.onap.vfc.nfvo.driver.vnfm.svnfm.cbam.bo.CBAMHealVnfRequest;
import org.onap.vfc.nfvo.driver.vnfm.svnfm.cbam.bo.CBAMHealVnfResponse;
import org.onap.vfc.nfvo.driver.vnfm.svnfm.cbam.bo.CBAMInstantiateVnfRequest;
import org.onap.vfc.nfvo.driver.vnfm.svnfm.cbam.bo.CBAMInstantiateVnfResponse;
import org.onap.vfc.nfvo.driver.vnfm.svnfm.cbam.bo.CBAMModifyVnfRequest;
import org.onap.vfc.nfvo.driver.vnfm.svnfm.cbam.bo.CBAMModifyVnfResponse;
import org.onap.vfc.nfvo.driver.vnfm.svnfm.cbam.bo.CBAMQueryOperExecutionResponse;
import org.onap.vfc.nfvo.driver.vnfm.svnfm.cbam.bo.CBAMQueryVnfResponse;
import org.onap.vfc.nfvo.driver.vnfm.svnfm.cbam.bo.CBAMScaleVnfRequest;
import org.onap.vfc.nfvo.driver.vnfm.svnfm.cbam.bo.CBAMScaleVnfResponse;
import org.onap.vfc.nfvo.driver.vnfm.svnfm.cbam.bo.CBAMTerminateVnfRequest;
import org.onap.vfc.nfvo.driver.vnfm.svnfm.cbam.bo.CBAMTerminateVnfResponse;
import org.onap.vfc.nfvo.driver.vnfm.svnfm.cbam.bo.CBAMVnfNotificationRequest;
import org.onap.vfc.nfvo.driver.vnfm.svnfm.cbam.bo.CBAMVnfNotificationResponse;
import org.onap.vfc.nfvo.driver.vnfm.svnfm.cbam.bo.entity.Subscription;
import org.onap.vfc.nfvo.driver.vnfm.svnfm.cbam.bo.entity.VnfcResourceInfo;
import org.onap.vfc.nfvo.driver.vnfm.svnfm.cbam.inf.CbamMgmrInf;
import org.onap.vfc.nfvo.driver.vnfm.svnfm.common.bo.AdaptorEnv;
import org.onap.vfc.nfvo.driver.vnfm.svnfm.constant.CommonConstants;
import org.onap.vfc.nfvo.driver.vnfm.svnfm.http.client.HttpClientProcessorInf;
import org.onap.vfc.nfvo.driver.vnfm.svnfm.http.client.HttpResult;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.stereotype.Component;
import org.springframework.web.bind.annotation.RequestMethod;

import com.google.common.reflect.TypeToken;
import com.google.gson.Gson;

@Component
public class CbamMgmrImpl implements CbamMgmrInf {
	private static final Logger logger = LoggerFactory.getLogger(CbamMgmrImpl.class);
	private Gson gson = new Gson();

	@Autowired
	private AdaptorEnv adaptorEnv;

	@Autowired
	HttpClientProcessorInf httpClientProcessor;

	public String retrieveToken() throws ClientProtocolException, IOException, JSONException {
		String result = null;
		String url = adaptorEnv.getCbamApiUriFront() + CommonConstants.CbamRetrieveTokenPath;
		HashMap<String, String> map = new HashMap<>();
		map.put(CommonConstants.ACCEPT, "*/*");
		map.put(CommonConstants.CONTENT_TYPE, MediaType.APPLICATION_FORM_URLENCODED_VALUE);

		String bodyPostStr = String.format(CommonConstants.CbamRetrieveTokenPostStr, adaptorEnv.getClientId(),
				adaptorEnv.getClientSecret(), adaptorEnv.getCbamUserName(), adaptorEnv.getCbamPassword());

		logger.debug("CbamMgmrImpl -> retrieveToken, url is " + url);
		logger.debug("CbamMgmrImpl -> retrieveToken, bodyPostStr is " + bodyPostStr);

		String responseStr = httpClientProcessor.process(url, RequestMethod.POST, map, bodyPostStr).getContent();

		logger.info("CbamMgmrImpl -> retrieveToken, responseStr is " + responseStr);

		JSONObject tokenJsonObject = new JSONObject(responseStr);

		result = tokenJsonObject.getString(CommonConstants.CBAM_TOKEN_KEY);

		return result;
	}

	public CBAMCreateVnfResponse createVnf(CBAMCreateVnfRequest cbamRequest)
			throws ClientProtocolException, IOException {
		String httpPath = CommonConstants.CbamCreateVnfPath;
		RequestMethod method = RequestMethod.POST;

		HttpResult httpResult = operateCbamHttpTask(cbamRequest, httpPath, method);
		String responseStr = httpResult.getContent();

		logger.info("CbamMgmrImpl -> createVnf, responseStr is " + responseStr);
		int code = httpResult.getStatusCode();
		if (code == 201) {
			logger.info("CbamMgmrImpl -> createVnf success");
		} else {
			logger.error("CbamMgmrImpl -> createVnf error ");
		}
		CBAMCreateVnfResponse response = gson.fromJson(responseStr, CBAMCreateVnfResponse.class);

		return response;
	}

	public CBAMModifyVnfResponse modifyVnf(CBAMModifyVnfRequest cbamRequest, String vnfInstanceId)
			throws ClientProtocolException, IOException {
		String httpPath = String.format(CommonConstants.CbamModifyVnfPath, vnfInstanceId);

		RequestMethod method = RequestMethod.PATCH;

		HttpResult httpResult = operateCbamHttpTask(cbamRequest, httpPath, method);
		String responseStr = httpResult.getContent();

		logger.info("CbamMgmrImpl -> modifyVnf, responseStr is " + responseStr);
		int code = httpResult.getStatusCode();

		if(code == 202) {
			logger.info("CbamMgmrImpl -> modifyVnf success");
		} else {
			logger.error("CbamMgmrImpl -> modifyVnf error, statusCode = " + code);
		}
		CBAMModifyVnfResponse response = gson.fromJson(responseStr, CBAMModifyVnfResponse.class);
		return response;
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see com.nokia.vfcadaptor.cbam.impl.CbamMgmrInf#instantiateVnf(com.nokia.
	 * vfcadaptor.cbam.bo.CBAMInstantiateVnfRequest, java.lang.String)
	 */
	public CBAMInstantiateVnfResponse instantiateVnf(CBAMInstantiateVnfRequest cbamRequest, String vnfInstanceId)
			throws ClientProtocolException, IOException {
		String httpPath = String.format(CommonConstants.CbamInstantiateVnfPath, vnfInstanceId);
		RequestMethod method = RequestMethod.POST;

		HttpResult httpResult = operateCbamHttpTask(cbamRequest, httpPath, method);
		String responseStr = httpResult.getContent();

		logger.info("CbamMgmrImpl -> instantiateVnf, responseStr is " + responseStr);
		int code = httpResult.getStatusCode();
		if (code == 202) {
			logger.info("CbamMgmrImpl -> instantiateVnf success ");
		} else {
			logger.error("CbamMgmrImpl -> instantiateVnf error ");
		}
		CBAMInstantiateVnfResponse response = gson.fromJson(responseStr, CBAMInstantiateVnfResponse.class);

		return response;
	}

	public CBAMTerminateVnfResponse terminateVnf(CBAMTerminateVnfRequest cbamRequest, String vnfInstanceId)
			throws ClientProtocolException, IOException {
		String httpPath = String.format(CommonConstants.CbamTerminateVnfPath, vnfInstanceId);
		RequestMethod method = RequestMethod.POST;

		HttpResult httpResult = operateCbamHttpTask(cbamRequest, httpPath, method);
		String responseStr = httpResult.getContent();

		logger.info("CbamMgmrImpl -> terminateVnf, responseStr is " + responseStr);
		int code = httpResult.getStatusCode();
		if (code == 202) {
			logger.info("CbamMgmrImpl -> terminateVnf  sucess ");
		} else {
			logger.error("CbamMgmrImpl -> terminateVnf error ");
		}
		CBAMTerminateVnfResponse response = gson.fromJson(responseStr, CBAMTerminateVnfResponse.class);

		return response;
	}

	public void deleteVnf(String vnfInstanceId) throws ClientProtocolException, IOException {
		String httpPath = String.format(CommonConstants.CbamDeleteVnfPath, vnfInstanceId);
		RequestMethod method = RequestMethod.DELETE;
		HttpResult httpResult = operateCbamHttpTask(null, httpPath, method);

		int code = httpResult.getStatusCode();
		if (code == 204) {
			logger.info("CbamMgmrImpl -> deleteVnf success.");
		} else {
			logger.error("CbamMgmrImpl -> deleteVnf error. detail info is " + httpResult.getContent());
		}

	}

	public CBAMScaleVnfResponse scaleVnf(CBAMScaleVnfRequest cbamRequest, String vnfInstanceId)
			throws ClientProtocolException, IOException {
		String httpPath = String.format(CommonConstants.CbamScaleVnfPath, vnfInstanceId);
		RequestMethod method = RequestMethod.POST;

		HttpResult httpResult = operateCbamHttpTask(cbamRequest, httpPath, method);
		String responseStr = httpResult.getContent();
		int code = httpResult.getStatusCode();
		if (code == 202) {
			logger.info("CbamMgmrImpl -> scaleVnf success.");
		} else {
			logger.error("CbamMgmrImpl -> scaleVnf error. ");
		}
		CBAMScaleVnfResponse response = gson.fromJson(responseStr, CBAMScaleVnfResponse.class);

		return response;
	}

	public CBAMHealVnfResponse healVnf(CBAMHealVnfRequest cbamRequest, String vnfInstanceId)
			throws ClientProtocolException, IOException {
		String httpPath = String.format(CommonConstants.CbamHealVnfPath, vnfInstanceId);
		RequestMethod method = RequestMethod.POST;

		HttpResult httpResult = operateCbamHttpTask(cbamRequest, httpPath, method);
		String responseStr = httpResult.getContent();

		logger.info("CbamMgmrImpl -> healVnf, responseStr is " + responseStr);
		int code = httpResult.getStatusCode();
		if (code == 202) {
			logger.info("CbamMgmrImpl -> healVnf success.");
		} else {
			logger.error("CbamMgmrImpl -> healVnf error. ");
		}
		CBAMHealVnfResponse response = gson.fromJson(responseStr, CBAMHealVnfResponse.class);

		return response;
	}

	public CBAMQueryVnfResponse queryVnf(String vnfInstanceId) throws ClientProtocolException, IOException {
		String httpPath = String.format(CommonConstants.CbamQueryVnfPath, vnfInstanceId);
		RequestMethod method = RequestMethod.GET;

		HttpResult httpResult = operateCbamHttpTask(null, httpPath, method);
		String responseStr = httpResult.getContent();

		logger.info("CbamMgmrImpl -> queryVnf, responseStr is " + responseStr);
		int code = httpResult.getStatusCode();
		if (code == 200) {
			logger.info("CbamMgmrImpl -> queryVnf success.");
		} else {
			logger.error("CbamMgmrImpl -> queryVnf error. ");
		}

		CBAMQueryVnfResponse response = gson.fromJson(responseStr, CBAMQueryVnfResponse.class);

		return response;
	}

	public List<VnfcResourceInfo> queryVnfcResource(String vnfInstanceId) throws ClientProtocolException, IOException {
		String httpPath = String.format(CommonConstants.CbamQueryVnfcResourcePath, vnfInstanceId);
		RequestMethod method = RequestMethod.GET;

		HttpResult httpResult = operateCbamHttpTask(null, httpPath, method);
		String responseStr = httpResult.getContent();

		logger.info("CbamMgmrImpl -> queryVnfcResource, responseStr is " + responseStr);
		int code = httpResult.getStatusCode();
		if (code == 200) {
			logger.info("CbamMgmrImpl -> queryVnfcResource success.");
		} else {
			logger.error("CbamMgmrImpl -> queryVnfcResource error. ");
		}
		List<VnfcResourceInfo> response = gson.fromJson(responseStr, new TypeToken<List<VnfcResourceInfo>>() {
		}.getType());
		;

		return response;
	}

	public HttpResult operateCbamHttpTask(Object httpBodyObj, String httpPath, RequestMethod method)
			throws ClientProtocolException, IOException {
		String token = null;
		try {
			token = retrieveToken();
		} catch (JSONException e) {
			logger.error("retrieveTokenError ", e);
		}

		String url = adaptorEnv.getCbamApiUriFront() + httpPath;

		HashMap<String, String> map = new HashMap<>();
		map.put(CommonConstants.AUTHORIZATION, "bearer " + token);
		map.put(CommonConstants.CONTENT_TYPE, MediaType.APPLICATION_JSON_VALUE);
       
		return httpClientProcessor.process(url, method, map, gson.toJson(httpBodyObj));
	}

	public CBAMQueryOperExecutionResponse queryOperExecution(String execId)
			throws ClientProtocolException, IOException {
		String httpPath = String.format(CommonConstants.CbamGetOperStatusPath, execId);
		RequestMethod method = RequestMethod.GET;

		HttpResult httpResult = operateCbamHttpTask(null, httpPath, method);
		String responseStr = httpResult.getContent();

		logger.info("CbamMgmrImpl -> CBAMQueryOperExecutionResponse, responseStr is " + responseStr);

		int code = httpResult.getStatusCode();
		if (code == 200) {
			logger.info("CbamMgmrImpl -> CBAMQueryOperExecutionResponse, success");
		} else if (code == 202) {
			logger.info("CbamMgmrImpl -> CBAMQueryOperExecutionResponse, ongoing");
		} else {
			logger.error("CbamMgmrImpl -> CBAMQueryOperExecutionResponse, error");
		}

		CBAMQueryOperExecutionResponse response = gson.fromJson(responseStr, CBAMQueryOperExecutionResponse.class);

		return response;
	}

	public void setAdaptorEnv(AdaptorEnv adaptorEnv) {
		this.adaptorEnv = adaptorEnv;
	}

	@Override
	public void uploadVnfPackage(String cbamPackageFilePath) throws ClientProtocolException, IOException {
		String httpPath = CommonConstants.CbamUploadVnfPackagePath;
		RequestMethod method = RequestMethod.POST;

		HttpResult httpResult = operateCbamHttpUploadTask(cbamPackageFilePath, httpPath, method);
		String responseStr = httpResult.getContent();

		logger.info("CbamMgmrImpl -> uploadVnfPackage, statusCode is " + httpResult.getStatusCode() + ", cause is "
				+ httpResult.getStatusCause() + ". responseStr is " + responseStr);

		int code = httpResult.getStatusCode();
		if (code == 200) {
			logger.info("CbamMgmrImpl -> uploadVnfPackage, success");
			logger.info("Upload vnf package " + cbamPackageFilePath + " to CBAM is successful.");
		} else {
			logger.error("CbamMgmrImpl -> uploadVnfPackage, error");
		}
	}

	public HttpResult operateCbamHttpUploadTask(String filePath, String httpPath, RequestMethod method)
			throws ClientProtocolException, IOException {
		String token = null;
		try {
			token = retrieveToken();
		} catch (JSONException e) {
			logger.error("retrieveTokenError ", e);
		}
		String url = adaptorEnv.getCbamApiUriFront() + httpPath;
		logger.info("start to upload file.");
		String command = "/usr/bin/curl --insecure -X POST -H \"Authorization: bearer " + token + "\" --form content=@"
				+ filePath + " " + url;
		StringBuffer respStr = execCommand(command);

		// HashMap<String, String> map = new HashMap<>();
		// map.put(CommonConstants.AUTHORIZATION, "bearer " + token);
		// map.put(CommonConstants.CONTENT_TYPE, "multipart/form-data,
		// boundary=---CFSGSSGGSGdssdfsdhd---");
		// byte[] fileBytes = CommonUtil.getBytes(filePath);
		// logger.info("CbamMgmrImpl -> operateCbamHttpUploadTask, url is " + url);
		// logger.info("CbamMgmrImpl -> operateCbamHttpUploadTask, token is " + token);
		// logger.info("CbamMgmrImpl -> operateCbamHttpUploadTask, bodyPostStr byte
		// lenth is " + fileBytes.length);

		// return httpClientProcessor.processBytes(url, method, map, fileBytes);

		HttpResult hResult = new HttpResult();
		hResult.setStatusCause(respStr.toString());
		hResult.setContent(respStr.toString());
		hResult.setStatusCode(200);
		return hResult;

		// String charset = "UTF-8";
		// File uploadFile1 = new File(filePath);
		// String requestURL = url;
		// HttpResult result = new HttpResult();
		//
		// try {
		// MultipartUtility multipart = new MultipartUtility(requestURL, charset);
		//
		// multipart.addHeaderField("User-Agent", "CodeJava");
		// multipart.addHeaderField(CommonConstants.AUTHORIZATION, "bearer " + token);
		//
		// multipart.addFilePart("fileUpload", uploadFile1);
		//
		// List<String> response = multipart.finish();
		//
		// result.setContent(Arrays.deepToString(response.toArray(new String[0])));
		// result.setStatusCode(200);
		// } catch (Exception ex) {
		// logger.error("CbamMgmrImpl -> operateCbamHttpUploadTask, error ", ex);
		// result.setStatusCode(500);
		// }
		//
		// return result;
	}

	private StringBuffer execCommand(String command) {
		logger.info("CbamMgmrImpl -> execCommand, command is " + command);
		StringBuffer respStr = new StringBuffer("\r\n");
		try {
			String os = System.getProperty("os.name");
			String[] cmd = { "cmd", "/c", command };
			if (!os.toLowerCase().startsWith("win")) {
				cmd = new String[] { "/bin/sh", "-c", command };
			}
			Process process = Runtime.getRuntime().exec(cmd);
			Thread t = new Thread(new InputStreamRunnable(process.getErrorStream(), "ErrorStream"));
			t.start();
			Thread.sleep(3000);
			InputStream fis = process.getInputStream();
			InputStreamReader isr = new InputStreamReader(fis);

			BufferedReader br = new BufferedReader(isr);
			String line = null;
			while ((line = br.readLine()) != null) {
				respStr.append(line + "\r\n");
			}
			respStr.append("\r\n");
			process.waitFor();
			fis.close();
			isr.close();
			process.destroy();
			logger.info("operateCbamHttpUploadTask respStr is: " + respStr);
		} catch (Exception e) {
			logger.error("operateCbamHttpUploadTask error", e);
		}
		return respStr;
	}

	// public static String postByHttps(String url, String body, Object contentType)
	// {
	// String result = "";
	// Protocol https = new Protocol("https", new
	// HTTPSSecureProtocolSocketFactory(), 443);
	// Protocol.registerProtocol("https", https);
	// PostMethod post = new PostMethod(url);
	// HttpClient client = new HttpClient();
	// try {
	// post.setRequestHeader("Content-Type", contentType);
	// post.setRequestBody(body);
	// client.executeMethod(post);
	// result = post.getResponseBodyAsString();
	// Protocol.unregisterProtocol("https");
	// return result;
	// } catch (HttpException e) {
	// e.printStackTrace();
	// } catch (IOException e) {
	// e.printStackTrace();
	// } catch(Exception e) {
	// e.printStackTrace();
	// }
	//
	// return "error";
	// }

	public HttpClientProcessorInf getHttpClientProcessor() {
		return httpClientProcessor;
	}

	public void setHttpClientProcessor(HttpClientProcessorInf httpClientProcessor) {
		this.httpClientProcessor = httpClientProcessor;
	}

	@Override
	public CBAMCreateSubscriptionResponse createSubscription(CBAMCreateSubscriptionRequest subscriptionRequest)
			throws ClientProtocolException, IOException {
		String httpPath = String.format(CommonConstants.CbamCreateSubscriptionPath);
		RequestMethod method = RequestMethod.POST;
		logger.info("CbamMgmrImpl -> createSubscription, requestStr is " + gson.toJson(subscriptionRequest));
		HttpResult httpResult = operateCbamHttpTask(subscriptionRequest, httpPath, method);
		String responseStr = httpResult.getContent();
		
		CBAMCreateSubscriptionResponse response = null;

		logger.info("CbamMgmrImpl -> createSubscription, responseStr is " + responseStr);
		int code = httpResult.getStatusCode();
		if (code == 201) {
			logger.info("CbamMgmrImpl -> createSubscription success ");
			response = gson.fromJson(responseStr, CBAMCreateSubscriptionResponse.class);
		} else {
			logger.error("CbamMgmrImpl -> createSubscription error , statusCode = " + code);
		}

		return response;
	}

	@Override
	public Subscription getSubscription(String subscriptionId) throws ClientProtocolException, IOException {
		String httpPath = String.format(CommonConstants.CbamGetSubscriptionPath, subscriptionId);
		RequestMethod method = RequestMethod.GET;

		HttpResult httpResult = operateCbamHttpTask(null, httpPath, method);
		String responseStr = httpResult.getContent();

		logger.info("CbamMgmrImpl -> getSubscription, responseStr is " + responseStr);
		int code = httpResult.getStatusCode();
		if (code == 200) {
			logger.info("CbamMgmrImpl -> getSubscription success ");
		} else {
			logger.error("CbamMgmrImpl -> getSubscription error , statusCode = " + code);
		}
		Subscription response = gson.fromJson(responseStr, Subscription.class);

		return response;
	}

	@Override
	public CBAMVnfNotificationResponse getNotification(CBAMVnfNotificationRequest getNotificationRequest)
			throws ClientProtocolException, IOException {
		String httpPath = String.format(CommonConstants.CbamGetNotificationPath);
		RequestMethod method = RequestMethod.GET;

		HttpResult httpResult = operateCbamHttpTask(getNotificationRequest, httpPath, method);
		String responseStr = httpResult.getContent();

		logger.info("CbamMgmrImpl -> getNotification, responseStr is " + responseStr);
		int code = httpResult.getStatusCode();
		if (code == 200) {
			logger.info("CbamMgmrImpl -> getNotification success ");
		} else {
			logger.error("CbamMgmrImpl -> getNotification error , statusCode = " + code);
		}
		CBAMVnfNotificationResponse  response = gson.fromJson(responseStr, CBAMVnfNotificationResponse.class);
		return response;
	}

}