2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
6 * ================================================================================
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
18 * ============LICENSE_END=========================================================
21 package org.openecomp.mso.adapters.vnf;
26 import javax.ws.rs.Consumes;
27 import javax.ws.rs.DELETE;
28 import javax.ws.rs.GET;
29 import javax.ws.rs.HEAD;
30 import javax.ws.rs.POST;
31 import javax.ws.rs.PUT;
32 import javax.ws.rs.Path;
33 import javax.ws.rs.PathParam;
34 import javax.ws.rs.Produces;
35 import javax.ws.rs.QueryParam;
36 import javax.ws.rs.core.Response;
37 import javax.ws.rs.core.GenericEntity;
38 import javax.ws.rs.core.MediaType;
39 import javax.xml.ws.Holder;
41 import org.apache.http.HttpStatus;
43 import org.openecomp.mso.adapters.vnf.exceptions.VnfException;
44 import org.openecomp.mso.cloud.CloudConfigFactory;
45 import org.openecomp.mso.entity.MsoRequest;
46 import org.openecomp.mso.logger.MessageEnum;
47 import org.openecomp.mso.logger.MsoLogger;
48 import org.openecomp.mso.openstack.beans.VnfStatus;
49 import org.openecomp.mso.openstack.beans.VnfRollback;
50 import org.openecomp.mso.openstack.exceptions.MsoExceptionCategory;
51 import org.openecomp.mso.properties.MsoPropertiesFactory;
52 import org.openecomp.mso.adapters.vnfrest.*;
55 * This class services calls to the REST interface for VF Modules (http://host:port/vnfs/rest/v1/vnfs)
56 * Both XML and JSON can be produced/consumed. Set Accept: and Content-Type: headers appropriately. XML is the default.
57 * For testing, call with cloudSiteId = ___TESTING___
58 * To test exceptions, also set tenantId = ___TESTING___
61 public class VnfAdapterRest {
62 private static MsoLogger LOGGER = MsoLogger.getMsoLogger (MsoLogger.Catalog.RA);
63 private static final String TESTING_KEYWORD = "___TESTING___";
64 private final CloudConfigFactory cloudConfigFactory = new CloudConfigFactory();
65 private final MsoPropertiesFactory msoPropertiesFactory = new MsoPropertiesFactory();
66 private final MsoVnfAdapter vnfAdapter = new MsoVnfAdapterImpl (msoPropertiesFactory, cloudConfigFactory);
67 //TODO Logging, SkipAAI, CREATED flags, Integrate with BPEL, Auth,
72 @Produces(MediaType.TEXT_HTML)
73 public Response healthcheck () {
74 String CHECK_HTML = "<!DOCTYPE html><html><head><meta charset=\"ISO-8859-1\"><title>Health Check</title></head><body>Application ready</body></html>";
75 return Response.ok().entity(CHECK_HTML).build();
79 * URL:http://localhost:8080/vnfs/rest/v1/vnfs/<aaivnfid>/vf-modules/<aaimodid>
81 * {"deleteVfModuleRequest":
82 {"cloudSiteId": "DAN",
83 "tenantId": "214b428a1f554c02935e66330f6a5409",
85 "vfModuleId": "somemodid",
86 "vfModuleStackId": "4e567676-e266-4594-a3a6-131c8a2baf73",
88 "notificationUrl": "http://localhost:8089/vnfmock",
92 "serviceInstanceId": "sa1"
97 @Path("{aaiVnfId}/vf-modules/{aaiVfModuleId}")
98 @Consumes({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
99 @Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
100 public Response deleteVfModule (
101 @PathParam("aaiVnfId") String aaiVnfId,
102 @PathParam("aaiVfModuleId") String aaiVfModuleId,
103 final DeleteVfModuleRequest req)
105 LOGGER.debug("Delete VfModule enter: " + req.toJsonString());
106 if (aaiVnfId == null || !aaiVnfId.equals(req.getVnfId())) {
107 LOGGER.debug("Req rejected - aaiVnfId not provided or doesn't match URL");
109 .status(HttpStatus.SC_BAD_REQUEST)
110 .type(MediaType.TEXT_PLAIN)
111 .entity("vnfid in URL does not match content")
114 if (aaiVfModuleId == null || !aaiVfModuleId.equals(req.getVfModuleId())) {
115 LOGGER.debug("Req rejected - aaiVfModuleId not provided or doesn't match URL");
117 .status(HttpStatus.SC_BAD_REQUEST)
118 .type(MediaType.TEXT_PLAIN)
119 .entity("vfModuleId in URL does not match content")
122 DeleteVfModuleTask task = new DeleteVfModuleTask(req);
123 if (req.isSynchronous()) {
124 // This is a synchronous request
127 .status(task.getStatusCode())
128 .entity(task.getGenericEntityResponse())
131 // This is an asynchronous request
133 Thread t1 = new Thread(task);
135 } catch (Exception e) {
136 // problem handling delete, send generic failure as sync resp to caller
137 LOGGER.error (MessageEnum.RA_DELETE_VNF_ERR, "", "deleteVfModule", MsoLogger.ErrorCode.BusinessProcesssError, "Exception in deleteVfModule", e);
138 return Response.serverError().build();
140 // send sync response (ACK) to caller
141 LOGGER.debug ("deleteVNFVolumes exit");
142 return Response.status(HttpStatus.SC_ACCEPTED).build();
146 public class DeleteVfModuleTask implements Runnable {
147 private final DeleteVfModuleRequest req;
148 private DeleteVfModuleResponse response = null;
149 private VfModuleExceptionResponse eresp = null;
150 private boolean sendxml;
152 public DeleteVfModuleTask(DeleteVfModuleRequest req) {
154 this.sendxml = true; // can be set with a field or header later
156 public int getStatusCode() {
157 return (response != null) ? HttpStatus.SC_OK : HttpStatus.SC_BAD_REQUEST;
159 public Object getGenericEntityResponse() {
160 return (response != null)
161 ? new GenericEntity<DeleteVfModuleResponse>(response) {}
162 : new GenericEntity<VfModuleExceptionResponse>(eresp) {};
164 private String getResponse() {
165 if (response != null) {
166 return sendxml ? response.toXmlString() : response.toJsonString();
168 return sendxml ? eresp.toXmlString() : eresp.toJsonString();
175 String cloudsite = req.getCloudSiteId();
176 Holder<Map<String, String>> outputs = new Holder <Map <String, String>> ();
177 if (cloudsite != null && !cloudsite.equals(TESTING_KEYWORD)) {
178 //vnfAdapter.deleteVnf (req.getCloudSiteId(), req.getTenantId(), req.getVfModuleStackId(), req.getMsoRequest());
179 vnfAdapter.deleteVfModule (req.getCloudSiteId(), req.getTenantId(), req.getVfModuleStackId(), req.getMsoRequest(), outputs);
181 response = new DeleteVfModuleResponse(req.getVnfId(), req.getVfModuleId(), Boolean.TRUE, req.getMessageId(), outputs.value);
182 } catch (VnfException e) {
183 LOGGER.error (MessageEnum.RA_DELETE_VNF_ERR, "", "", MsoLogger.ErrorCode.BusinessProcesssError, "VnfException - Delete VNF Module", e);
184 eresp = new VfModuleExceptionResponse(e.getMessage(), MsoExceptionCategory.INTERNAL, Boolean.TRUE, req.getMessageId());
186 if (!req.isSynchronous()) {
187 BpelRestClient bpelClient = new BpelRestClient();
188 bpelClient.bpelPost(getResponse(), req.getNotificationUrl(), sendxml);
190 LOGGER.debug ("Delete vfModule exit: code=" + getStatusCode() + ", resp="+ getResponse());
195 * URL:http://localhost:8080/vnfs/rest/v1/vnfs/<aaiVnfId>/vf-modules/<aaiVfModuleId>?cloudSiteId=DAN&tenantId=vfModule?&skipAAI=TRUE&msoRequest.requestId=ra1&msoRequest.serviceInstanceId=si1&vfModuleName=T2N2S1
197 * {"queryVfModuleResponse": {
198 "vfModuleId": "AvfmodId",
199 "vfModuleOutputs": {"entry": {
200 "key": "server_private_ip_1",
201 "value": "10.100.1.25"
203 "vfModuleStackId": "RaaVnf1/abfa8a6d-feb1-40af-aea3-109403b1cf6b",
205 "vnfStatus": "ACTIVE"
209 @Path("{aaiVnfId}/vf-modules/{aaiVfModuleId}")
210 @Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
211 public Response queryVfModule(
212 @PathParam("aaiVnfId") String aaiVnfId,
213 @PathParam("aaiVfModuleId") String aaiVfModuleId,
214 @QueryParam("cloudSiteId") String cloudSiteId,
215 @QueryParam("tenantId") String tenantId,
216 @QueryParam("vfModuleName") String vfModuleName, //RAA? Id in doc
217 @QueryParam("skipAAI") Boolean skipAAI,
218 @QueryParam("msoRequest.requestId") String requestId,
219 @QueryParam("msoRequest.serviceInstanceId") String serviceInstanceId)
221 //This request responds synchronously only
222 LOGGER.debug ("Query vfModule enter:" + vfModuleName);
223 MsoRequest msoRequest = new MsoRequest(requestId, serviceInstanceId);
226 int respStatus = HttpStatus.SC_OK;
227 QueryVfModuleResponse qryResp = new QueryVfModuleResponse(aaiVnfId, aaiVfModuleId, null, null, null);
228 Holder<Boolean> vnfExists = new Holder<Boolean>();
229 Holder<String> vfModuleId = new Holder<String>();
230 Holder<VnfStatus> status = new Holder<VnfStatus>();
231 Holder<Map<String, String>> outputs = new Holder <Map <String, String>> ();
232 vnfAdapter.queryVnf (cloudSiteId, tenantId, vfModuleName, msoRequest, vnfExists, vfModuleId, status, outputs);
233 if (!vnfExists.value) {
234 LOGGER.debug ("vfModule not found");
235 respStatus = HttpStatus.SC_NOT_FOUND;
237 LOGGER.debug ("vfModule found" + vfModuleId.value + ", status=" + status.value);
238 qryResp.setVfModuleId(vfModuleId.value);
239 qryResp.setVnfStatus(status.value);
240 qryResp.setVfModuleOutputs(outputs.value);
242 LOGGER.debug ("Query vfModule exit");
245 .entity(new GenericEntity<QueryVfModuleResponse>(qryResp) {})
247 } catch (VnfException e) {
248 LOGGER.error (MessageEnum.RA_QUERY_VNF_ERR, vfModuleName, "", "queryVfModule", MsoLogger.ErrorCode.BusinessProcesssError, "VnfException - queryVfModule", e);
249 VfModuleExceptionResponse excResp = new VfModuleExceptionResponse(e.getMessage(), MsoExceptionCategory.INTERNAL, Boolean.FALSE, null);
251 .status(HttpStatus.SC_INTERNAL_SERVER_ERROR)
252 .entity(new GenericEntity<VfModuleExceptionResponse>(excResp) {})
257 /*URL: http://localhost:8080/vnfs/rest/v1/vnfs/<aaivnfid>/vf-modules
259 * {"createVfModuleRequest":
260 {"cloudSiteId": "DAN",
261 "tenantId": "214b428a1f554c02935e66330f6a5409",
262 "vnfId": "somevnfid",
263 "vfModuleId": "somemodid",
264 "vfModuleName": "RaaVnf1",
265 "vnfType": "ApacheVnf",
266 "vfModuleParams": {"entry": [
267 {"key": "network_id",
268 "value": "59ed7b41-2983-413f-ba93-e7d437433916"},
270 "value": "086c9298-5c57-49b7-bb2b-6fd5730c5d92"},
271 {"key": "server_name_0",
274 "failIfExists": true,
276 "notificationUrl": "http://localhost:8089/vnfmock",
280 "serviceInstanceId": "sa1"
285 @Path("{aaiVnfId}/vf-modules")
286 @Consumes({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
287 @Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
288 public Response createVfModule(
289 @PathParam("aaiVnfId") String aaiVnfId,
290 final CreateVfModuleRequest req)
292 LOGGER.debug("Create VfModule enter inside VnfAdapterRest: " + req.toJsonString());
293 if (aaiVnfId == null || !aaiVnfId.equals(req.getVnfId())) {
294 LOGGER.debug("Req rejected - aaiVnfId not provided or doesn't match URL");
296 .status(HttpStatus.SC_BAD_REQUEST)
297 .type(MediaType.TEXT_PLAIN)
298 .entity("vnfid in URL does not match content")
301 CreateVfModuleTask task = new CreateVfModuleTask(req);
302 if (req.isSynchronous()) {
303 // This is a synchronous request
306 .status(task.getStatusCode())
307 .entity(task.getGenericEntityResponse())
310 // This is an asynchronous request
312 Thread t1 = new Thread(task);
314 } catch (Exception e) {
315 // problem handling create, send generic failure as sync resp to caller
316 LOGGER.error (MessageEnum.RA_CREATE_VNF_ERR, "", "createVfModule", MsoLogger.ErrorCode.BusinessProcesssError, "Exception - createVfModule", e);
317 return Response.serverError().build();
319 // send sync response (ACK) to caller
320 LOGGER.debug ("createVfModule exit");
321 return Response.status(HttpStatus.SC_ACCEPTED).build();
325 public class CreateVfModuleTask implements Runnable {
326 private final CreateVfModuleRequest req;
327 private CreateVfModuleResponse response = null;
328 private VfModuleExceptionResponse eresp = null;
329 private boolean sendxml;
331 public CreateVfModuleTask(CreateVfModuleRequest req) {
333 this.sendxml = true; // can be set with a field or header later
335 public int getStatusCode() {
336 return (response != null) ? HttpStatus.SC_OK : HttpStatus.SC_BAD_REQUEST;
338 public Object getGenericEntityResponse() {
339 return (response != null)
340 ? new GenericEntity<CreateVfModuleResponse>(response) {}
341 : new GenericEntity<VfModuleExceptionResponse>(eresp) {};
343 private String getResponse() {
344 if (response != null) {
345 return sendxml ? response.toXmlString() : response.toJsonString();
347 return sendxml ? eresp.toXmlString() : eresp.toJsonString();
353 LOGGER.debug ("CreateVfModuleTask start");
355 // Synchronous Web Service Outputs
356 Holder <String> vfModuleStackId = new Holder <String> ();
357 Holder <Map <String, String>> outputs = new Holder <Map <String, String>> ();
358 Holder <VnfRollback> vnfRollback = new Holder <VnfRollback> ();
359 String completeVnfVfModuleType = req.getVnfType() + "::" + req.getVfModuleType();
360 LOGGER.debug("completeVnfVfModuleType=" + completeVnfVfModuleType);
361 String cloudsite = req.getCloudSiteId();
362 if (cloudsite != null && cloudsite.equals(TESTING_KEYWORD)) {
363 String tenant = req.getTenantId();
364 if (tenant != null && tenant.equals(TESTING_KEYWORD)) {
365 throw new VnfException("testing.");
367 vnfRollback.value = new VnfRollback(req.getVnfId(), tenant, cloudsite,
368 true, false, new MsoRequest("reqid", "svcid"),
369 req.getVolumeGroupId(), req.getVolumeGroupId(), req.getRequestType(), req.getModelCustomizationUuid());
370 vfModuleStackId.value = "479D3D8B-6360-47BC-AB75-21CC91981484";
371 outputs.value = VolumeAdapterRest.testMap();
373 // vnfAdapter.createVnf (createReq.getCloudSiteId(),
374 // createReq.getTenantId(),
375 // createReq.getVnfType(),
376 // createReq.getVnfVersion(),
377 // createReq.getVfModuleName(),
378 // createReq.getRequestType(),
379 // createReq.getVolumeGroupStackId(),
380 // createReq.getVfModuleParams(),
381 // createReq.getFailIfExists(),
382 // createReq.getBackout(),
383 // createReq.getMsoRequest(),
387 vnfAdapter.createVfModule(req.getCloudSiteId(),
390 completeVnfVfModuleType,
392 req.getVfModuleName(),
393 req.getRequestType(),
394 req.getVolumeGroupStackId(),
395 req.getBaseVfModuleStackId(),
396 req.getModelCustomizationUuid(),
397 req.getVfModuleParams(),
398 req.getFailIfExists(),
405 VfModuleRollback modRollback = new VfModuleRollback(vnfRollback.value, req.getVfModuleId(), vfModuleStackId.value, req.getMessageId());
406 response = new CreateVfModuleResponse(req.getVnfId(), req.getVfModuleId(),
407 vfModuleStackId.value, Boolean.TRUE, outputs.value, modRollback, req.getMessageId());
408 } catch (VnfException e) {
409 eresp = new VfModuleExceptionResponse(e.getMessage(), MsoExceptionCategory.INTERNAL, Boolean.TRUE, req.getMessageId());
411 if (!req.isSynchronous()) {
412 BpelRestClient bpelClient = new BpelRestClient();
413 bpelClient.bpelPost(getResponse(), req.getNotificationUrl(), sendxml);
415 LOGGER.debug ("CreateVfModuleTask exit: code=" + getStatusCode() + ", resp="+ getResponse());
420 @Path("{aaiVnfId}/vf-modules/{aaiVfModuleId}")
421 @Consumes({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
422 @Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
423 public Response updateVfModule(
424 @PathParam("aaiVnfId") String aaiVnfId,
425 @PathParam("aaiVfModuleId") String aaiVfModuleId,
426 final UpdateVfModuleRequest req)
428 LOGGER.debug("Update VfModule enter: " + req.toJsonString());
429 UpdateVfModulesTask task = new UpdateVfModulesTask(req);
430 if (req.isSynchronous()) {
431 // This is a synchronous request
434 .status(task.getStatusCode())
435 .entity(task.getGenericEntityResponse())
438 // This is an asynchronous request
440 Thread t1 = new Thread(task);
442 } catch (Exception e) {
443 // problem handling create, send generic failure as sync resp to caller
444 LOGGER.error (MessageEnum.RA_UPDATE_VNF_ERR, "", "updateVfModule", MsoLogger.ErrorCode.BusinessProcesssError, "Exception - updateVfModule", e);
445 return Response.serverError().build();
447 // send sync response (ACK) to caller
448 LOGGER.debug ("updateVfModules exit");
449 return Response.status(HttpStatus.SC_ACCEPTED).build();
453 public class UpdateVfModulesTask implements Runnable {
454 private final UpdateVfModuleRequest req;
455 private UpdateVfModuleResponse response = null;
456 private VfModuleExceptionResponse eresp = null;
457 private boolean sendxml;
459 public UpdateVfModulesTask(UpdateVfModuleRequest req) {
461 this.sendxml = true; // can be set with a field or header later
463 public int getStatusCode() {
464 return (response != null) ? HttpStatus.SC_OK : HttpStatus.SC_BAD_REQUEST;
466 public Object getGenericEntityResponse() {
467 return (response != null)
468 ? new GenericEntity<UpdateVfModuleResponse>(response) {}
469 : new GenericEntity<VfModuleExceptionResponse>(eresp) {};
471 private String getResponse() {
472 if (response != null) {
473 return sendxml ? response.toXmlString() : response.toJsonString();
475 return sendxml ? eresp.toXmlString() : eresp.toJsonString();
481 //MsoVnfAdapter vnfAdapter = new MsoVnfAdapterImpl (msoPropertiesFactory, cloudConfigFactory);
483 // Synchronous Web Service Outputs
484 Holder <String> vfModuleStackId = new Holder <String> ();
485 Holder <Map <String, String>> outputs = new Holder <Map <String, String>> ();
486 Holder <VnfRollback> vnfRollback = new Holder <VnfRollback> ();
487 String completeVnfVfModuleType = req.getVnfType() + "::" + req.getVfModuleType();
488 LOGGER.debug("in updateVf - completeVnfVfModuleType=" + completeVnfVfModuleType);
491 vnfAdapter.updateVnf (updateReq.getCloudSiteId(),
492 updateReq.getTenantId(),
493 updateReq.getVnfType(),
494 updateReq.getVnfVersion(),
495 updateReq.getVfModuleName(),
496 updateReq.getRequestType(),
497 updateReq.getVolumeGroupStackId(),
498 updateReq.getVfModuleParams(),
499 updateReq.getMsoRequest(),
503 vnfAdapter.updateVfModule (req.getCloudSiteId(),
506 completeVnfVfModuleType,
508 req.getVfModuleName(),
509 req.getRequestType(),
510 req.getVolumeGroupStackId(),
511 req.getBaseVfModuleId(),
512 req.getVfModuleStackId(),
513 req.getModelCustomizationUuid(),
514 req.getVfModuleParams(),
519 response = new UpdateVfModuleResponse(req.getVnfId(), req.getVfModuleId(),
520 vfModuleStackId.value, outputs.value, req.getMessageId());
521 } catch (VnfException e) {
522 eresp = new VfModuleExceptionResponse(e.getMessage(), MsoExceptionCategory.INTERNAL, Boolean.TRUE, req.getMessageId());
524 if (!req.isSynchronous()) {
525 // This is asynch, so POST response back to caller
526 BpelRestClient bpelClient = new BpelRestClient ();
527 bpelClient.bpelPost (getResponse(), req.getNotificationUrl(), sendxml);
529 LOGGER.debug ("Update VfModule exit: code=" + getStatusCode() + ", resp="+ getResponse());
533 * URL:http://localhost:8080/vnfs/rest/v1/vnfs/<aaivnfid>/vf-modules/<aaimodid>/rollback
535 * {"deleteVfModuleRequest":
536 {"cloudSiteId": "DAN",
537 "tenantId": "214b428a1f554c02935e66330f6a5409",
538 "vnfId": "somevnfid",
539 "vfModuleId": "somemodid",
540 "vfModuleStackId": "4e567676-e266-4594-a3a6-131c8a2baf73",
542 "notificationUrl": "http://localhost:8089/vnfmock",
546 "serviceInstanceId": "sa1"
551 @Path("{aaiVnfId}/vf-modules/{aaiVfModuleId}/rollback")
552 @Consumes({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
553 @Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
554 public Response rollbackVfModule (
555 @PathParam("aaiVnfId") String aaiVnfId,
556 @PathParam("aaiVfModuleId") String aaiVfModuleId,
557 //@QueryParam("rollback") String rollback,
558 final RollbackVfModuleRequest req)
560 LOGGER.debug("Rollback VfModule enter: " + req.toJsonString());
561 RollbackVfModulesTask task = new RollbackVfModulesTask(req);
562 if (req.isSynchronous()) {
563 // This is a synchronous request
566 .status(task.getStatusCode())
567 .entity(task.getGenericEntityResponse())
570 // This is an asynchronous request
572 Thread t1 = new Thread(task);
574 } catch (Exception e) {
575 // problem handling create, send generic failure as sync resp to caller
576 LOGGER.error (MessageEnum.RA_ROLLBACK_VNF_ERR, "", "rollbackVfModule", MsoLogger.ErrorCode.BusinessProcesssError, "Exception - rollbackVfModule", e);
577 return Response.serverError().build();
579 // send sync response (ACK) to caller
580 LOGGER.debug ("rollbackVfModule exit");
581 return Response.status(HttpStatus.SC_ACCEPTED).build();
585 public class RollbackVfModulesTask implements Runnable {
586 private final RollbackVfModuleRequest req;
587 private RollbackVfModuleResponse response = null;
588 private VfModuleExceptionResponse eresp = null;
589 private boolean sendxml;
591 public RollbackVfModulesTask(RollbackVfModuleRequest req) {
593 this.sendxml = true; // can be set with a field or header later
595 public int getStatusCode() {
596 return (response != null) ? HttpStatus.SC_OK : HttpStatus.SC_BAD_REQUEST;
598 public Object getGenericEntityResponse() {
599 return (response != null)
600 ? new GenericEntity<RollbackVfModuleResponse>(response) {}
601 : new GenericEntity<VfModuleExceptionResponse>(eresp) {};
603 private String getResponse() {
604 if (response != null) {
605 return sendxml ? response.toXmlString() : response.toJsonString();
607 return sendxml ? eresp.toXmlString() : eresp.toJsonString();
613 VfModuleRollback vmr = req.getVfModuleRollback();
614 VnfRollback vrb = new VnfRollback(
615 vmr.getVfModuleStackId(), vmr.getTenantId(), vmr.getCloudSiteId(), true, true,
616 vmr.getMsoRequest(), null, null, null, null);
617 vnfAdapter.rollbackVnf (vrb);
618 response = new RollbackVfModuleResponse(Boolean.TRUE, req.getMessageId());
619 } catch (VnfException e) {
620 LOGGER.error (MessageEnum.RA_ROLLBACK_VNF_ERR, "", "", MsoLogger.ErrorCode.BusinessProcesssError, "Exception - rollbackVfModule", e);
621 eresp = new VfModuleExceptionResponse(e.getMessage(), MsoExceptionCategory.INTERNAL, false, req.getMessageId());
623 if (!req.isSynchronous()) {
624 // This is asynch, so POST response back to caller
625 BpelRestClient bpelClient = new BpelRestClient ();
626 bpelClient.bpelPost (getResponse(), req.getNotificationUrl(), sendxml);
628 LOGGER.debug ("RollbackVfModulesTask exit: code=" + getStatusCode() + ", resp="+ getResponse());