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.apihandlerinfra;
 
  24 import java.io.StringReader;
 
  25 import java.io.StringWriter;
 
  26 import java.sql.Timestamp;
 
  27 import java.text.SimpleDateFormat;
 
  28 import java.util.Calendar;
 
  29 import java.util.Date;
 
  30 import java.util.List;
 
  32 import javax.ws.rs.core.Response;
 
  33 import javax.xml.bind.JAXBContext;
 
  34 import javax.xml.bind.JAXBException;
 
  35 import javax.xml.bind.Marshaller;
 
  36 import javax.xml.bind.Unmarshaller;
 
  37 import javax.xml.transform.OutputKeys;
 
  38 import javax.xml.transform.Transformer;
 
  39 import javax.xml.transform.TransformerFactory;
 
  40 import javax.xml.transform.dom.DOMSource;
 
  41 import javax.xml.transform.sax.SAXSource;
 
  42 import javax.xml.transform.stream.StreamResult;
 
  44 import org.hibernate.Session;
 
  46 import org.w3c.dom.Document;
 
  47 import org.w3c.dom.Element;
 
  48 import org.w3c.dom.Node;
 
  49 import org.w3c.dom.NodeList;
 
  50 import org.xml.sax.InputSource;
 
  52 import org.openecomp.mso.apihandler.common.ErrorNumbers;
 
  53 import org.openecomp.mso.apihandler.common.ValidationException;
 
  54 import org.openecomp.mso.apihandlerinfra.vnfbeans.ActionType;
 
  55 import org.openecomp.mso.apihandlerinfra.vnfbeans.ObjectFactory;
 
  56 import org.openecomp.mso.apihandlerinfra.vnfbeans.RequestInfo;
 
  57 import org.openecomp.mso.apihandlerinfra.vnfbeans.RequestStatusType;
 
  58 import org.openecomp.mso.apihandlerinfra.vnfbeans.VnfInputs;
 
  59 import org.openecomp.mso.apihandlerinfra.vnfbeans.VnfRequest;
 
  60 import org.openecomp.mso.logger.MsoLogger;
 
  61 import org.openecomp.mso.logger.MessageEnum;
 
  62 import org.openecomp.mso.properties.MsoJavaProperties;
 
  63 import org.openecomp.mso.requestsdb.HibernateUtil;
 
  64 import org.openecomp.mso.requestsdb.InfraActiveRequests;
 
  65 import org.openecomp.mso.requestsdb.RequestsDatabase;
 
  67 public class VnfMsoInfraRequest {
 
  69     private String requestId;
 
  70     private String requestXML;
 
  71     private String requestUri;
 
  72     private VnfRequest vnfReq;
 
  73     private RequestInfo rinfo;
 
  74     private VnfInputs vnfInputs;
 
  75     private String vnfParams;
 
  76     private ActionType action;
 
  77     private String errorMessage;
 
  78     private String httpResponse;
 
  79     private String responseBody;
 
  80     private RequestStatusType status;
 
  81     private long startTime;
 
  82     private long progress = Constants.PROGRESS_REQUEST_RECEIVED;
 
  84     private static MsoLogger msoLogger = MsoLogger.getMsoLogger (MsoLogger.Catalog.APIH);
 
  85     private static final String NOT_PROVIDED = "not provided";
 
  87     VnfMsoInfraRequest (String requestId) {
 
  88         this.requestId = requestId;
 
  89         Calendar startTimeCalendar = Calendar.getInstance ();
 
  90         this.startTime = startTimeCalendar.getTimeInMillis ();
 
  91         MsoLogger.setLogContext (requestId, null);
 
  96     void parse (String reqXML, String version, MsoJavaProperties props) throws ValidationException {
 
  98         msoLogger.debug ("Validating the request");
 
 100         this.requestXML = reqXML;
 
 102         VnfRequest vnfReq = null;
 
 103         boolean isWrongRootElement = false;
 
 106             JAXBContext jaxbContext = JAXBContext.newInstance (VnfRequest.class);
 
 107             Unmarshaller jaxbUnmarshaller = jaxbContext.createUnmarshaller ();
 
 109             InputSource inputSource = new InputSource (new StringReader (reqXML));
 
 110             SAXSource source = new SAXSource (inputSource);
 
 112             if (reqXML.contains ("vnf-request") && !reqXML.contains ("network-request")) {
 
 113                 vnfReq = jaxbUnmarshaller.unmarshal (source, VnfRequest.class).getValue ();
 
 115                 isWrongRootElement = true;
 
 118         } catch (Exception e) {
 
 119                 msoLogger.error (MessageEnum.APIH_VNFREQUEST_VALIDATION_ERROR, "", "", MsoLogger.ErrorCode.DataError, "Exception in format for vnf request ", e);
 
 120             throw new ValidationException ("format for vnf request");
 
 123         if (isWrongRootElement) {
 
 124                 msoLogger.error (MessageEnum.APIH_REQUEST_VALIDATION_ERROR_REASON, "root element is not correct", "", "", MsoLogger.ErrorCode.DataError, "root element is not correct");
 
 125             throw new ValidationException ("root element <vnf-request> expected");
 
 128         if (vnfReq == null) {
 
 129             throw new ValidationException ("vnf-request");
 
 131         this.vnfReq = vnfReq;
 
 133         this.rinfo = vnfReq.getRequestInfo ();
 
 135         if (this.rinfo == null) {
 
 136             throw new ValidationException ("request-info");
 
 138         if (this.rinfo.getRequestId () != null) {
 
 139             msoLogger.info (MessageEnum.APIH_GENERATED_REQUEST_ID, requestId, this.rinfo.getRequestId ());
 
 142         action = this.rinfo.getAction ();
 
 143         if (action == null) {
 
 144             throw new ValidationException ("action");
 
 147         this.vnfInputs = vnfReq.getVnfInputs ();
 
 148         if (this.vnfInputs == null) {
 
 149             throw new ValidationException ("vnf-inputs");
 
 152         // Verify that BPMN-specific elements are not in the APIH incoming request
 
 153         if (this.vnfInputs.getPersonaModelId () != null || this.vnfInputs.getPersonaModelVersion () != null ||
 
 154                         this.vnfInputs.getIsBaseVfModule () != null || this.vnfInputs.getVnfPersonaModelId () != null ||
 
 155                         this.vnfInputs.getVnfPersonaModelVersion () != null) {
 
 156                  throw new ValidationException ("format for vnf request");              
 
 158         // Verify that the elements correspond to the version
 
 161         if (version.equals(Constants.SCHEMA_VERSION_V1)) {
 
 162                         if (this.vnfInputs.getVfModuleName () != null || this.vnfInputs.getVfModuleId () != null ||
 
 163                                         this.vnfInputs.getVfModuleModelName () != null || this.vnfInputs.getAsdcServiceModelVersion () != null ||
 
 164                                         this.vnfInputs.getBackoutOnFailure() != null || this.vnfInputs.getAicCloudRegion() != null ||
 
 165                                         this.vnfInputs.getServiceInstanceId  () != null) {
 
 166                                 throw new ValidationException ("format for v1 version of vnf request");
 
 169         else if (version.equals(Constants.SCHEMA_VERSION_V2)) {
 
 170                         if (this.vnfInputs.getServiceType() != null || this.vnfInputs.getAicNodeClli() != null || this.vnfInputs.getServiceInstanceId  () != null) {
 
 171                                 throw new ValidationException ("format for v2 version of vnf request");
 
 174         else if (version.equals(Constants.SCHEMA_VERSION_V3)) {
 
 175                 if (this.vnfInputs.getServiceType() != null || this.vnfInputs.getAicNodeClli() != null) {
 
 176                         throw new ValidationException ("format for v3 version of vnf request");
 
 181         if (!InfraUtils.isActionAllowed (props, "vnf", version, action.value ())) {
 
 182                 throw new ValidationException ("action allowable for version " + version + " of vnf request");          
 
 185         if ((ActionType.UPDATE.equals(action) || ActionType.DELETE.equals(action)) && this.vnfInputs.getVnfId () == null) {
 
 186                 throw new ValidationException("vnf-id");                
 
 189         if ((ActionType.UPDATE_VF_MODULE.equals (action) || ActionType.DELETE_VF_MODULE.equals (action)) && this.vnfInputs.getVfModuleId () == null) {
 
 190             throw new ValidationException ("vf-module-id");
 
 193         if (ActionType.CREATE.equals (action) && this.vnfInputs.getVnfName () == null) {
 
 194             throw new ValidationException ("vnf-name");
 
 197         if (ActionType.CREATE_VF_MODULE.equals (action)) {
 
 198                 if (this.vnfInputs.getVfModuleName () == null) {
 
 199                         throw new ValidationException ("vf-module-name");
 
 201                 if (!InfraUtils.isValidHeatName(this.vnfInputs.getVfModuleName ())) {
 
 202                         throw new ValidationException ("vf-module-name: no value meeting heat stack name syntax requirements");
 
 206         if (this.vnfInputs.getVnfType () == null) {
 
 207             throw new ValidationException ("vnf-type");
 
 210         if ((ActionType.CREATE_VF_MODULE.equals (action) || ActionType.UPDATE_VF_MODULE.equals (action) || ActionType.DELETE_VF_MODULE.equals (action)) && this.vnfInputs.getVfModuleModelName () == null) {
 
 211             throw new ValidationException ("vf-module-model-name");
 
 214         if (!version.equals(Constants.SCHEMA_VERSION_V1) && this.vnfInputs.getServiceId () == null) {
 
 215                 throw new ValidationException ("service-id ");
 
 218         if (this.vnfInputs.getServiceType () != null && this.vnfInputs.getServiceId () != null) {
 
 219                 throw new ValidationException ("service-type or service-id ");
 
 222         if (version.equals(Constants.SCHEMA_VERSION_V1) && this.vnfInputs.getAicNodeClli () == null) {
 
 223                 throw new ValidationException ("aic-node-clli");
 
 226         if ((version.equals(Constants.SCHEMA_VERSION_V2) || version.equals(Constants.SCHEMA_VERSION_V3)) && (this.vnfInputs.getAicCloudRegion () == null || this.vnfInputs.getAicCloudRegion ().isEmpty())) {
 
 227                 throw new ValidationException ("aic-cloud-region");
 
 230         if (version.equals(Constants.SCHEMA_VERSION_V3) && this.vnfInputs.getServiceInstanceId () == null) {
 
 231                 throw new ValidationException ("service-instance-id");
 
 235         if (this.vnfInputs.getTenantId () == null) {
 
 236                 throw new ValidationException ("tenant-id");            
 
 239         Object vp = vnfReq.getVnfParams ();
 
 242             msoLogger.debug ("This object is not null");
 
 244             Node node = (Node) vp;
 
 245             Document doc = node.getOwnerDocument ();
 
 246             this.vnfParams = domToStr (doc);
 
 249         msoLogger.debug ("VNFParams: " + this.vnfParams);
 
 251         msoLogger.debug ("Request valid");
 
 253         // Rebuild the request string for BPEL to include request-id 
 
 254         rinfo.setRequestId (this.requestId);        
 
 255         this.vnfReq.setRequestInfo (rinfo);        
 
 257         StringWriter stringWriter = new StringWriter ();
 
 259             JAXBContext jaxbContext = JAXBContext.newInstance (VnfRequest.class);
 
 260             Marshaller jaxbMarshaller = jaxbContext.createMarshaller ();
 
 262             // output pretty printed
 
 263             jaxbMarshaller.setProperty (Marshaller.JAXB_FORMATTED_OUTPUT, true);
 
 265             jaxbMarshaller.marshal (this.vnfReq, stringWriter);
 
 267         } catch (JAXBException e) {
 
 268             msoLogger.debug ("Exception: ", e);
 
 271         this.requestXML = stringWriter.toString ();
 
 272         msoLogger.debug("REQUEST XML to BPEL: " + this.requestXML);
 
 276     public void createRequestRecord (Status status) {
 
 278         Session session = null;
 
 281             session = HibernateUtil.getSessionFactory ().openSession ();
 
 282             session.beginTransaction ();
 
 284             InfraActiveRequests aq = new InfraActiveRequests ();
 
 285             aq.setRequestId (requestId);
 
 286             aq.setClientRequestId(rinfo.getRequestId());
 
 288             Timestamp startTimeStamp = new Timestamp (Calendar.getInstance ().getTimeInMillis ());
 
 290                 if (rinfo.getAction () != null) {
 
 291                     aq.setAction (rinfo.getAction ().value ());
 
 292                     aq.setRequestAction (RequestActionMap.getMappedRequestAction (rinfo.getAction ().value ()));
 
 294                 aq.setSource (rinfo.getSource ());
 
 296                 // Set up mandatory parameters
 
 297                 aq.setAction (NOT_PROVIDED);
 
 298                 aq.setRequestAction (NOT_PROVIDED);
 
 301             aq.setRequestBody (this.requestXML);
 
 302             aq.setRequestScope ("");
 
 304             if (vnfInputs != null) {
 
 305                 if (vnfInputs.getVnfId () != null) {
 
 306                     aq.setVnfId (vnfInputs.getVnfId ());
 
 308                 if (vnfInputs.getVnfName () != null) {
 
 309                     aq.setVnfName (vnfInputs.getVnfName ());
 
 311                 if (vnfInputs.getVnfType () != null) {
 
 312                     aq.setVnfType (vnfInputs.getVnfType ());
 
 314                 if (vnfInputs.getServiceInstanceId () != null) {
 
 315                     aq.setServiceInstanceId (vnfInputs.getServiceInstanceId ());
 
 317                 if (vnfInputs.getServiceType () != null) {
 
 318                     aq.setServiceType (vnfInputs.getServiceType ());
 
 320                 if (vnfInputs.getServiceId () != null) {
 
 321                     aq.setAaiServiceId (vnfInputs.getServiceId ());
 
 323                 if (vnfInputs.getAicNodeClli () != null) {
 
 324                     aq.setAicNodeClli (vnfInputs.getAicNodeClli ());
 
 326                 if (vnfInputs.getAicCloudRegion () != null) {
 
 327                     aq.setAicCloudRegion (vnfInputs.getAicCloudRegion ());
 
 329                 if (vnfInputs.getTenantId () != null) {
 
 330                     aq.setTenantId (vnfInputs.getTenantId ());
 
 332                 if (vnfInputs.getProvStatus () != null) {
 
 333                     aq.setProvStatus (vnfInputs.getProvStatus ());
 
 335                 if (vnfInputs.getVolumeGroupName () != null) {
 
 336                     aq.setVolumeGroupName (vnfInputs.getVolumeGroupName ());
 
 338                 if (vnfInputs.getVolumeGroupId () != null) {
 
 339                     aq.setVolumeGroupId (vnfInputs.getVolumeGroupId ());
 
 341                 if (vnfInputs.getVfModuleId () != null) {
 
 342                     aq.setVfModuleId (vnfInputs.getVfModuleId ());
 
 344                 if (vnfInputs.getVfModuleName () != null) {
 
 345                     aq.setVfModuleName (vnfInputs.getVfModuleName ());
 
 347                 if (vnfInputs.getVfModuleModelName () != null) {
 
 348                     aq.setVfModuleModelName (vnfInputs.getVfModuleModelName ());
 
 351                 if (vnfInputs.getVfModuleName () != null || vnfInputs.getVfModuleId () != null) {
 
 352                         aq.setRequestScope (ModelType.vfModule.name ());
 
 355                         aq.setRequestScope (ModelType.vnf.name ());
 
 361             aq.setStartTime (startTimeStamp);
 
 362             aq.setRequestStatus (status.toString ());
 
 363             aq.setLastModifiedBy (Constants.MODIFIED_BY_APIHANDLER);
 
 364             aq.setRequestType ("VNF");
 
 366             if (vnfParams != null) {
 
 367                 msoLogger.debug ("Storing vnfParams: " + vnfParams);
 
 368                 aq.setVnfParams (this.vnfParams);
 
 371             if ((status == Status.FAILED) || (status == Status.COMPLETE)) {
 
 372                 aq.setStatusMessage (this.errorMessage);
 
 373                 aq.setResponseBody (this.responseBody);
 
 375                 Calendar endTime = Calendar.getInstance ();
 
 376                 Timestamp endTimeStamp = new Timestamp (endTime.getTimeInMillis ());
 
 377                 aq.setEndTime (endTimeStamp);
 
 380             aq.setProgress (this.progress);
 
 383             msoLogger.debug ("About to insert a record");
 
 386             session.getTransaction ().commit ();
 
 388         } catch (Exception e) {
 
 389                 msoLogger.error (MessageEnum.APIH_DB_INSERT_EXC, "", "", MsoLogger.ErrorCode.AvailabilityError, "Exception in createRequestRecord", e);
 
 390             if (session != null) {
 
 393             if (!status.equals (Status.FAILED)) {
 
 399     public void updateFinalStatus (Status status) {
 
 402             result = RequestsDatabase.updateInfraFinalStatus (requestId,
 
 407                                                               Constants.MODIFIED_BY_APIHANDLER);
 
 408         } catch (Exception e) {
 
 409                 msoLogger.error (MessageEnum.APIH_DB_UPDATE_EXC, e.getMessage (), "", "", MsoLogger.ErrorCode.AvailabilityError, "Exception in updateFinalStatus");
 
 410             msoLogger.debug ("Exception: ", e);
 
 414     public Response buildResponse (int httpResponseCode, String errorCode, InfraActiveRequests inProgress) {
 
 415         return buildResponseWithError (httpResponseCode, errorCode, inProgress, null);
 
 418     public Response buildResponseWithError (int httpResponseCode,
 
 420                                             InfraActiveRequests inProgress,
 
 421                                             String errorString) {
 
 423         ObjectFactory beansObjectFactory = new ObjectFactory ();
 
 425         VnfRequest vr = beansObjectFactory.createVnfRequest ();
 
 427         RequestInfo ri = beansObjectFactory.createRequestInfo ();
 
 429         ri.setRequestId (requestId);
 
 430         ri.setRequestStatus (this.status);
 
 431         ri.setAction (this.rinfo.getAction ());
 
 432         ri.setSource (this.rinfo.getSource ());
 
 434         String errorMsg = null;
 
 435         if (errorCode != null) {
 
 436             // If error code is actually an XML error response from BPEL, treat it specially:
 
 437             if (!Messages.errors.containsKey (errorCode)) {
 
 438                 if (errorCode.length () > 300) {
 
 439                     errorMsg = errorCode.substring (0, 299);
 
 441                     errorMsg = errorCode;
 
 446                 if (inProgress == null) {
 
 447                     if (errorCode.equals (ErrorNumbers.RECIPE_DOES_NOT_EXIST)) {
 
 448                         errorMsg = String.format (Messages.errors.get (errorCode), "vnf", errorString);
 
 450                         errorMsg = String.format (Messages.errors.get (errorCode), errorString);
 
 452                 } else if (errorCode.equals (ErrorNumbers.LOCKED_CREATE_ON_THE_SAME_VNF_NAME_IN_PROGRESS)) {
 
 453                     errorMsg = String.format (Messages.errors.get (errorCode),
 
 455                                               inProgress.getVnfName (),
 
 456                                               inProgress.getRequestStatus (),
 
 458                 } else if (errorCode.equals (ErrorNumbers.LOCKED_SAME_ACTION_AND_VNF_ID)) {
 
 459                     errorMsg = String.format (Messages.errors.get (errorCode),
 
 461                                               inProgress.getVnfId (),
 
 462                                               inProgress.getRequestStatus (),
 
 463                                               inProgress.getAction (),
 
 468             ri.setStatusMessage (errorMsg);
 
 469             this.errorMessage = errorMsg;
 
 471         ri.setProgress ((int) this.progress);
 
 473         Date startDate = new Date (this.startTime);
 
 474         SimpleDateFormat sdf = new SimpleDateFormat ("yyyy-MM-dd HH:mm:ss.SSS");
 
 475         String startTimeString = sdf.format (startDate);
 
 477         ri.setStartTime (startTimeString);
 
 479         if (this.progress == Constants.PROGRESS_REQUEST_COMPLETED) {
 
 480                 ri.setEndTime(startTimeString);
 
 483         vr.setRequestInfo (ri);
 
 485         this.vnfInputs.setIsBaseVfModule(null);
 
 486         this.vnfInputs.setPersonaModelId(null);
 
 487         this.vnfInputs.setPersonaModelVersion(null);
 
 488         this.vnfInputs.setVnfPersonaModelId(null);
 
 489         this.vnfInputs.setVnfPersonaModelVersion(null);
 
 491         vr.setVnfInputs (this.vnfInputs);
 
 493         StringWriter stringWriter = new StringWriter ();
 
 495             JAXBContext jaxbContext = JAXBContext.newInstance (VnfRequest.class);
 
 496             Marshaller jaxbMarshaller = jaxbContext.createMarshaller ();
 
 497             jaxbMarshaller.setProperty (Marshaller.JAXB_FORMATTED_OUTPUT, true);
 
 499             jaxbMarshaller.marshal (vr, stringWriter);
 
 501         } catch (JAXBException e) {
 
 502             msoLogger.debug ("Exception: ", e);
 
 505         String response = stringWriter.toString ();
 
 507         this.httpResponse = Integer.toString (httpResponseCode);
 
 508         this.responseBody = response;
 
 511         // Log the failed request into the MSO Requests database
 
 513         return Response.status (httpResponseCode).entity (response).build ();
 
 517     public Response buildResponseFailedValidation (int httpResponseCode, String exceptionMessage) {
 
 519         ObjectFactory beansObjectFactory = new ObjectFactory ();
 
 520         VnfRequest vr = beansObjectFactory.createVnfRequest ();
 
 522         RequestInfo ri = beansObjectFactory.createRequestInfo ();
 
 523         ri.setRequestId (requestId);
 
 525         if (this.rinfo != null) {
 
 526             if (this.rinfo.getAction () != null) {
 
 527                 ri.setAction (this.rinfo.getAction ());
 
 529                 ri.setAction (ActionType.NOT_PROVIDED);
 
 531             if (this.rinfo.getSource () != null) {
 
 532                 ri.setSource (this.rinfo.getSource ());
 
 535             ri.setAction (ActionType.NOT_PROVIDED);
 
 538         // Nothing more is expected for this request
 
 540         String errorMsg = String.format (Messages.errors.get (ErrorNumbers.REQUEST_FAILED_SCHEMA_VALIDATION
 
 543         ri.setStatusMessage (errorMsg);
 
 544         this.errorMessage = errorMsg;
 
 546         ri.setProgress ((int) this.progress);
 
 547         ri.setRequestStatus (RequestStatusType.FAILED);
 
 548         Date startDate = new Date (this.startTime);
 
 549         SimpleDateFormat sdf = new SimpleDateFormat ("yyyy-MM-dd HH:mm:ss.SSS");
 
 550         String startTimeString = sdf.format (startDate);
 
 552         ri.setStartTime (startTimeString);
 
 553         ri.setEndTime(startTimeString);
 
 555         vr.setRequestInfo (ri);
 
 557         vr.setVnfInputs (this.vnfInputs);
 
 559         StringWriter stringWriter = new StringWriter ();
 
 561             JAXBContext jaxbContext = JAXBContext.newInstance (VnfRequest.class);
 
 562             Marshaller jaxbMarshaller = jaxbContext.createMarshaller ();
 
 564             // output pretty printed
 
 565             jaxbMarshaller.setProperty (Marshaller.JAXB_FORMATTED_OUTPUT, true);
 
 567             jaxbMarshaller.marshal (vr, stringWriter);
 
 569         } catch (JAXBException e) {
 
 570             msoLogger.debug ("Error marshalling", e);
 
 573         String response = stringWriter.toString ();
 
 575         this.httpResponse = Integer.toString (httpResponseCode);
 
 576         this.responseBody = response;
 
 578         return Response.status (httpResponseCode).entity (response).build ();
 
 581     public String getRequestUri () {
 
 585     public void setRequestUri (String requestUri) {
 
 586         this.requestUri = requestUri;
 
 589     public VnfInputs getVnfInputs () {
 
 593     public RequestInfo getRequestInfo () {
 
 597     public String getResponseBody () {
 
 601     public void setResponseBody (String responseBody) {
 
 602         this.responseBody = responseBody;
 
 605     public String getHttpResponse () {
 
 609     public void setHttpResponse (String httpResponse) {
 
 610         this.httpResponse = httpResponse;
 
 613     public String getRequestId () {
 
 617     public String getRequestXML () {
 
 621     public void setRequestXML (String requestXML) {
 
 622         this.requestXML = requestXML;
 
 625     public RequestStatusType getStatus () {
 
 629     public String getServiceType () {
 
 630         if (this.vnfInputs.getServiceType () != null) 
 
 631                 return this.vnfInputs.getServiceType ();
 
 632         if (this.vnfInputs.getServiceId () != null) 
 
 633                 return this.vnfInputs.getServiceId ();
 
 637     public void setStatus (RequestStatusType status) {
 
 638         this.status = status;
 
 642                 this.progress = Constants.PROGRESS_REQUEST_COMPLETED;
 
 645                 this.progress = Constants.PROGRESS_REQUEST_IN_PROGRESS;
 
 650     public static String domToStr (Document doc) {
 
 656             StringWriter sw = new StringWriter ();
 
 657             StreamResult sr = new StreamResult (sw);
 
 658             TransformerFactory tf = TransformerFactory.newInstance ();
 
 659             Transformer t = tf.newTransformer ();
 
 660             t.setOutputProperty (OutputKeys.STANDALONE, "yes");
 
 661             NodeList nl = doc.getDocumentElement ().getChildNodes ();
 
 662             DOMSource source = null;
 
 663             for (int x = 0; x < nl.getLength (); x++) {
 
 664                 Node e = nl.item (x);
 
 665                 if (e instanceof Element) {
 
 666                     source = new DOMSource (e);
 
 670             if (source != null) {
 
 671                 t.transform (source, sr);
 
 673                 String s = sw.toString ();
 
 679         } catch (Exception e) {
 
 680                 msoLogger.error (MessageEnum.APIH_DOM2STR_ERROR, "", "", MsoLogger.ErrorCode.DataError, "Exception in domToStr", e);
 
 685     public void addBPMNSpecificInputs(String personaModelId, String personaModelVersion, Boolean isBaseVfModule,
 
 686                         String vnfPersonaModelId, String vnfPersonaModelVersion) {
 
 687         vnfInputs.setPersonaModelId(personaModelId);
 
 688         vnfInputs.setPersonaModelVersion(personaModelVersion);
 
 689         vnfInputs.setIsBaseVfModule(isBaseVfModule);
 
 690         vnfInputs.setVnfPersonaModelId(vnfPersonaModelId);
 
 691         vnfInputs.setVnfPersonaModelVersion(vnfPersonaModelVersion);
 
 693         this.vnfReq.setVnfInputs(vnfInputs);
 
 695           StringWriter stringWriter = new StringWriter ();
 
 697               JAXBContext jaxbContext = JAXBContext.newInstance (VnfRequest.class);
 
 698               Marshaller jaxbMarshaller = jaxbContext.createMarshaller ();
 
 700               // output pretty printed
 
 701               jaxbMarshaller.setProperty (Marshaller.JAXB_FORMATTED_OUTPUT, true);
 
 703               jaxbMarshaller.marshal (this.vnfReq, stringWriter);
 
 705           } catch (JAXBException e) {
 
 706               msoLogger.debug ("Exception: ", e);
 
 709           this.requestXML = stringWriter.toString ();
 
 710           msoLogger.debug("REQUEST XML to BPEL: " + this.requestXML);