aboutsummaryrefslogtreecommitdiffstats
path: root/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/VolumeMsoInfraRequest.java
blob: 911ac48d03f359f29a8e6f3743747003e44f1a0b (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
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
/*-
 * ============LICENSE_START=======================================================
 * OPENECOMP - MSO
 * ================================================================================
 * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
 * ================================================================================
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * ============LICENSE_END=========================================================
 */

package org.openecomp.mso.apihandlerinfra;

import java.io.StringReader;
import java.io.StringWriter;
import java.sql.Timestamp;
import java.text.SimpleDateFormat;
import java.util.Date;

import javax.ws.rs.core.Response;
import javax.xml.bind.JAXBContext;
import javax.xml.bind.JAXBException;
import javax.xml.bind.Marshaller;
import javax.xml.bind.Unmarshaller;
import javax.xml.transform.OutputKeys;
import javax.xml.transform.Transformer;
import javax.xml.transform.TransformerFactory;
import javax.xml.transform.dom.DOMSource;
import javax.xml.transform.sax.SAXSource;
import javax.xml.transform.stream.StreamResult;

import org.hibernate.Query;
import org.hibernate.Session;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
import org.xml.sax.InputSource;

import org.openecomp.mso.apihandler.common.ErrorNumbers;
import org.openecomp.mso.apihandler.common.ValidationException;
import org.openecomp.mso.apihandlerinfra.volumebeans.ActionType;
import org.openecomp.mso.apihandlerinfra.volumebeans.VolumeInputs;
import org.openecomp.mso.apihandlerinfra.volumebeans.ObjectFactory;
import org.openecomp.mso.apihandlerinfra.volumebeans.RequestInfo;
import org.openecomp.mso.apihandlerinfra.volumebeans.RequestStatusType;
import org.openecomp.mso.apihandlerinfra.volumebeans.VolumeRequest;
import org.openecomp.mso.db.HibernateUtils;
import org.openecomp.mso.logger.MsoLogger;
import org.openecomp.mso.logger.MessageEnum;
import org.openecomp.mso.properties.MsoJavaProperties;
import org.openecomp.mso.requestsdb.HibernateUtilsRequestsDb;
import org.openecomp.mso.requestsdb.InfraActiveRequests;
import org.openecomp.mso.requestsdb.RequestsDatabase;

public class VolumeMsoInfraRequest {

    private String requestId;
    private String requestXML;
    private String requestUri;
    private RequestInfo rinfo;
    private VolumeInputs volumeInputs;
    private String volumeParams;
    private ActionType action;
    private String errorMessage;
    private String httpResponse;
    private String responseBody;
    private RequestStatusType status;
    private long startTime;
    private long progress = Constants.PROGRESS_REQUEST_RECEIVED;

    protected HibernateUtils hibernateUtils = new HibernateUtilsRequestsDb ();

    private static MsoLogger msoLogger = MsoLogger.getMsoLogger (MsoLogger.Catalog.APIH);
    private static final String NOT_PROVIDED = "not provided";

    VolumeMsoInfraRequest (String requestId) {
        this.requestId = requestId;
        this.startTime = System.currentTimeMillis();
        MsoLogger.setLogContext (requestId, null);

    }

    // Parse request XML
    void parse (String reqXML, String version, MsoJavaProperties props) throws ValidationException {

        msoLogger.debug ("Validating the request");

        this.requestXML = reqXML;

        VolumeRequest volumeReq = null;
        boolean isWrongRootElement = false;

        try {
            JAXBContext jaxbContext = JAXBContext.newInstance (VolumeRequest.class);
            Unmarshaller jaxbUnmarshaller = jaxbContext.createUnmarshaller ();

            InputSource inputSource = new InputSource (new StringReader (reqXML));
            SAXSource source = new SAXSource (inputSource);

            if (reqXML.contains ("volume-request") && !reqXML.contains("vnf-request")) {
                volumeReq = jaxbUnmarshaller.unmarshal (source, VolumeRequest.class).getValue ();
            } else {
                isWrongRootElement = true;
            }

        } catch (Exception e) {
        	msoLogger.error (MessageEnum.APIH_VNFREQUEST_VALIDATION_ERROR, "", "", MsoLogger.ErrorCode.DataError, "Exception when parsing reqXML", e);
            throw new ValidationException ("format for volume request");
        }

        if (isWrongRootElement) {
        	msoLogger.error (MessageEnum.APIH_REQUEST_VALIDATION_ERROR_REASON, "root element is not correct", "", "", MsoLogger.ErrorCode.SchemaError, "root element <volume-request> expected");
            throw new ValidationException ("root element <volume-request> expected");
        }

        if (volumeReq == null) {
            throw new ValidationException ("volume-request");
        }

        this.rinfo = volumeReq.getRequestInfo ();

        if (this.rinfo == null) {
            throw new ValidationException ("request-info");
        }

        action = this.rinfo.getAction ();
        if (action == null) {
            throw new ValidationException ("action");
        }
        this.volumeInputs = volumeReq.getVolumeInputs ();
        if (this.volumeInputs == null) {
            throw new ValidationException ("volume-inputs");
        }

        // Verify that the elements correspond to the version

        if (version.equals(Constants.SCHEMA_VERSION_V1)) {
    		if (this.volumeInputs.getBackoutOnFailure() != null || this.volumeInputs.getAicCloudRegion() != null ||
    				this.volumeInputs.getVfModuleModelName () != null || this.volumeInputs.getAsdcServiceModelVersion () != null ||
    				this.volumeInputs.getServiceInstanceId () != null || this.volumeInputs.getVnfId () != null) {
    			throw new ValidationException ("format for v1 version of volume request");
    		}
    }
    else if (version.equals(Constants.SCHEMA_VERSION_V2)) {
    		if (this.volumeInputs.getServiceType() != null || this.volumeInputs.getAicNodeClli() != null ||
    				this.volumeInputs.getServiceInstanceId () != null || this.volumeInputs.getVnfId () != null) {
    			throw new ValidationException ("format for v2 version of volume request");
    		}
    }
    else if (version.equals(Constants.SCHEMA_VERSION_V3)) {
		if (this.volumeInputs.getServiceType() != null || this.volumeInputs.getAicNodeClli() != null) {
			throw new ValidationException ("format for v3 version of volume request");
		}
    }


        if (!InfraUtils.isActionAllowed (props, "volume", version, action.value ())) {
        	throw new ValidationException ("action allowable for version " + version + " of volume request");
        }

        switch (action) {
            case UPDATE:
            case DELETE:
            case UPDATE_VF_MODULE_VOL:
            case DELETE_VF_MODULE_VOL:
                if (this.volumeInputs.getVolumeGroupId () == null) {
                    throw new ValidationException ("volume-group-id");
                }
                break;
            default:
                break;
        }

        if (ActionType.CREATE.equals (action) || ActionType.CREATE_VF_MODULE_VOL.equals(action)) {
        	if (this.volumeInputs.getVolumeGroupName () == null) {
        		throw new ValidationException ("volume-group-name");
        	}
        	if (!InfraUtils.isValidHeatName(this.volumeInputs.getVolumeGroupName ())) {
        		throw new ValidationException ("volume-group-name: no value meeting heat stack name syntax requirements");
        	}
        }


        if (this.volumeInputs.getVnfType () == null) {
               throw new ValidationException ("vnf-type");
        }


        switch (action) {
        case CREATE_VF_MODULE_VOL:
        case UPDATE_VF_MODULE_VOL:
        case DELETE_VF_MODULE_VOL:
            if (this.volumeInputs.getVfModuleModelName () == null) {
                throw new ValidationException ("vf-module-model-name");
            }
            break;
        default:
            break;
        }

        if (!version.equals(Constants.SCHEMA_VERSION_V1) && this.volumeInputs.getServiceId () == null) {
        	throw new ValidationException ("service-id ");
        }

        if (version.equals(Constants.SCHEMA_VERSION_V1) && this.volumeInputs.getServiceType () != null && this.volumeInputs.getServiceId () != null) {
        	throw new ValidationException ("service-type or service-id ");
        }

        if (version.equals(Constants.SCHEMA_VERSION_V1) && this.volumeInputs.getAicNodeClli () == null) {
        	throw new ValidationException ("aic-node-clli");
        }

        if ((version.equals(Constants.SCHEMA_VERSION_V2) || version.equals(Constants.SCHEMA_VERSION_V3)) && (this.volumeInputs.getAicCloudRegion () == null || this.volumeInputs.getAicCloudRegion ().isEmpty())) {
        	throw new ValidationException ("aic-cloud-region");
        }

        if (version.equals(Constants.SCHEMA_VERSION_V3) && this.volumeInputs.getServiceInstanceId () == null) {
        	throw new ValidationException ("service-instance-id");
        }

        if (version.equals(Constants.SCHEMA_VERSION_V3) && this.volumeInputs.getVnfId () == null && ActionType.CREATE_VF_MODULE_VOL.equals(action)) {
        	throw new ValidationException ("vnf-id");
        }

        if (ActionType.CREATE.equals (action) || ActionType.CREATE_VF_MODULE_VOL.equals(action)) {
            if (this.volumeInputs.getTenantId () == null) {
                throw new ValidationException ("tenant-id");
            }
        }


                Object vpN = volumeReq.getVolumeParams ();

                if (vpN != null) {
                    Node node = (Node) vpN;
                    Document doc = node.getOwnerDocument ();
                    this.volumeParams = domToStr (doc);
                }

                msoLogger.debug ("VolumeParams: " + this.volumeParams);


        msoLogger.debug ("Request valid");

        // Rebuild the request string for BPEL to include request-id
        rinfo.setRequestId (this.requestId);
        volumeReq.setRequestInfo (rinfo);

        StringWriter stringWriter = new StringWriter ();
        try {
            JAXBContext jaxbContext = JAXBContext.newInstance (VolumeRequest.class);
            Marshaller jaxbMarshaller = jaxbContext.createMarshaller ();

            // output pretty printed
            jaxbMarshaller.setProperty (Marshaller.JAXB_FORMATTED_OUTPUT, true);

            jaxbMarshaller.marshal (volumeReq, stringWriter);

        } catch (JAXBException e) {
            msoLogger.debug ("Exception: ", e);
        }

        this.requestXML = stringWriter.toString ().replace("http://org.openecomp/mso/infra/volume-request",
        		"http://org.openecomp/mso/infra/vnf-request");

        msoLogger.debug("REQUEST XML to BPEL: " + this.requestXML);

    }

    public void createRequestRecord (Status status) {

        Session session = null;
        try {

            session = hibernateUtils.getSessionFactory ().openSession ();
            session.beginTransaction ();

            InfraActiveRequests aq = new InfraActiveRequests ();
            aq.setRequestId (requestId);

            Timestamp startTimeStamp = new Timestamp (System.currentTimeMillis());
            if (rinfo != null) {
                if (rinfo.getAction () != null) {
                    aq.setAction (rinfo.getAction ().value ());
                    aq.setRequestAction (RequestActionMap.getMappedRequestAction (rinfo.getAction ().value ()));
                }
                aq.setSource (rinfo.getSource ());
            } else {
                // Set up mandatory parameters
                aq.setAction (NOT_PROVIDED);
                aq.setRequestAction (NOT_PROVIDED);
            }

            aq.setRequestBody (this.requestXML);
            aq.setRequestScope (ModelType.volumeGroup.name ());

             if (volumeInputs != null) {
                if (volumeInputs.getVolumeGroupId () != null) {
                    aq.setVolumeGroupId (volumeInputs.getVolumeGroupId ());
                }
                if (volumeInputs.getVolumeGroupName () != null) {
                    aq.setVolumeGroupName (volumeInputs.getVolumeGroupName ());
                }
                if (volumeInputs.getVnfType () != null) {
                    aq.setVnfType (volumeInputs.getVnfType ());
                }
                if (volumeInputs.getVnfId () != null) {
                    aq.setVnfId (volumeInputs.getVnfId ());
                }
                if (volumeInputs.getServiceInstanceId () != null) {
                    aq.setServiceInstanceId (volumeInputs.getServiceInstanceId ());
                }
                if (volumeInputs.getServiceType () != null) {
                    aq.setServiceType (volumeInputs.getServiceType ());
                }
                if (volumeInputs.getServiceId () != null) {
                    aq.setAaiServiceId (volumeInputs.getServiceId ());
                }
                if (volumeInputs.getAicNodeClli () != null) {
                    aq.setAicNodeClli (volumeInputs.getAicNodeClli ());
                }
                if (volumeInputs.getAicCloudRegion () != null) {
                    aq.setAicCloudRegion (volumeInputs.getAicCloudRegion ());
                }
                if (volumeInputs.getTenantId () != null) {
                    aq.setTenantId (volumeInputs.getTenantId ());
                }

            }
            aq.setStartTime (startTimeStamp);
            aq.setRequestStatus (status.toString ());
            aq.setLastModifiedBy (Constants.MODIFIED_BY_APIHANDLER);
            aq.setRequestType ("VOLUME");

            if (volumeParams != null) {
                msoLogger.debug ("Storing volumeParams: " + volumeParams);
                aq.setVnfParams (this.volumeParams);
            }

            if ((status == Status.FAILED) || (status == Status.COMPLETE)) {
                aq.setStatusMessage (this.errorMessage);
                aq.setResponseBody (this.responseBody);

                Timestamp endTimeStamp = new Timestamp (System.currentTimeMillis());
                aq.setEndTime (endTimeStamp);
            }
            aq.setProgress (this.progress);


            msoLogger.debug ("About to insert a record");

            session.save (aq);
            session.getTransaction ().commit ();
            session.close ();
        } catch (Exception e) {
        	msoLogger.error (MessageEnum.APIH_DB_INSERT_EXC, "", "", MsoLogger.ErrorCode.DataError, "Exception in createRequestRecord", e);
            if (session != null) {
                session.close ();
            }
            if (!status.equals (Status.FAILED)) {
                throw e;
            }
        }
    }

    public void updateFinalStatus (Status status) {
    	int result = 0;
        try {
        	result = RequestsDatabase.updateInfraFinalStatus(requestId, status.toString (),
        		 this.errorMessage, this.progress, this.responseBody, Constants.MODIFIED_BY_APIHANDLER);
        } catch (Exception e) {
        	msoLogger.error(MessageEnum.APIH_DB_UPDATE_EXC, e.getMessage(), "", "", MsoLogger.ErrorCode.DataError, "Exception in updateFinalStatus");
        	msoLogger.debug("Exception: ", e);
        }
    }

    public Response buildResponse (int httpResponseCode, String errorCode, InfraActiveRequests inProgress) {
        return buildResponseWithError (httpResponseCode, errorCode, inProgress, null);
    }

    public Response buildResponseWithError (int httpResponseCode,
                                            String errorCode,
                                            InfraActiveRequests inProgress,
                                            String errorString) {

        ObjectFactory beansObjectFactory = new ObjectFactory ();

        VolumeRequest vr = beansObjectFactory.createVolumeRequest ();

        RequestInfo ri = beansObjectFactory.createRequestInfo ();

        ri.setRequestId (requestId);
        ri.setRequestStatus (this.status);
        ri.setAction (this.rinfo.getAction ());
        ri.setSource (this.rinfo.getSource ());

        String errorMsg = null;
        if (errorCode != null) {
            // If error code is actually an XML error response from BPEL, treat it specially:
            if (!Messages.errors.containsKey (errorCode)) {
                if (errorCode.length () > 300) {
                    errorMsg = errorCode.substring (0, 299);
                } else {
                    errorMsg = errorCode;
                }

            } else {

                if (inProgress == null) {
                	if (errorCode.equals(ErrorNumbers.RECIPE_DOES_NOT_EXIST)) {
                		errorMsg = String.format (Messages.errors.get (errorCode), "volume", errorString);
                	}
                	else {
                		errorMsg = String.format (Messages.errors.get (errorCode), errorString);
                	}
                } else if (errorCode.equals (ErrorNumbers.LOCKED_CREATE_ON_THE_SAME_VNF_NAME_IN_PROGRESS)) {
                    errorMsg = String.format (Messages.errors.get (errorCode),
                    						  "volume",
                                              inProgress.getVnfName (),
                                              inProgress.getRequestStatus (),
                                              "volume");
                } else if (errorCode.equals (ErrorNumbers.LOCKED_SAME_ACTION_AND_VNF_ID)) {
                    errorMsg = String.format (Messages.errors.get (errorCode),
                    					 	  "volume",
                                              inProgress.getVnfId (),
                                              inProgress.getRequestStatus (),
                                              inProgress.getAction (),
                                              "volume");
                }
            }

            ri.setStatusMessage (errorMsg);
            this.errorMessage = errorMsg;
        }
        ri.setProgress ((int) this.progress);

        Date startDate = new Date (this.startTime);
        SimpleDateFormat sdf = new SimpleDateFormat ("yyyy-MM-dd HH:mm:ss.SSS");
        String startTimeString = sdf.format (startDate);

        ri.setStartTime (startTimeString);

        vr.setRequestInfo (ri);
        vr.setVolumeInputs (this.volumeInputs);

        StringWriter stringWriter = new StringWriter ();
        try {
            JAXBContext jaxbContext = JAXBContext.newInstance (VolumeRequest.class);
            Marshaller jaxbMarshaller = jaxbContext.createMarshaller ();
            jaxbMarshaller.setProperty (Marshaller.JAXB_FORMATTED_OUTPUT, true);

            jaxbMarshaller.marshal (vr, stringWriter);

        } catch (JAXBException e) {
            msoLogger.debug ("Exception: ", e);
        }

        String response = stringWriter.toString ();

        this.httpResponse = Integer.toString (httpResponseCode);
        this.responseBody = response;

        // Log the failed request into the MSO Requests database

        return Response.status (httpResponseCode).entity (response).build ();

    }

    public Response buildResponseFailedValidation (int httpResponseCode, String exceptionMessage) {

        ObjectFactory beansObjectFactory = new ObjectFactory ();
        VolumeRequest vr = beansObjectFactory.createVolumeRequest ();

        RequestInfo ri = beansObjectFactory.createRequestInfo ();
        ri.setRequestId (requestId);

        if (this.rinfo != null) {
            if (this.rinfo.getAction () != null) {
                ri.setAction (this.rinfo.getAction ());
            } else {
                ri.setAction (ActionType.NOT_PROVIDED);
            }
            if (this.rinfo.getSource () != null) {
                ri.setSource (this.rinfo.getSource ());
            }
        } else {
            ri.setAction (ActionType.NOT_PROVIDED);
        }

        // Nothing more is expected for this request

        String errorMsg = String.format (Messages.errors.get (ErrorNumbers.REQUEST_FAILED_SCHEMA_VALIDATION
                                                              + "_service"),
                                         exceptionMessage);
        ri.setStatusMessage (errorMsg);
        this.errorMessage = errorMsg;

        ri.setProgress ((int) this.progress);
        ri.setRequestStatus (RequestStatusType.FAILED);
        Date startDate = new Date (this.startTime);
        SimpleDateFormat sdf = new SimpleDateFormat ("yyyy-MM-dd HH:mm:ss.SSS");
        String startTimeString = sdf.format (startDate);

        ri.setStartTime (startTimeString);

        vr.setRequestInfo (ri);
        vr.setVolumeInputs (this.volumeInputs);

        StringWriter stringWriter = new StringWriter ();
        try {
            JAXBContext jaxbContext = JAXBContext.newInstance (VolumeRequest.class);
            Marshaller jaxbMarshaller = jaxbContext.createMarshaller ();

            // output pretty printed
            jaxbMarshaller.setProperty (Marshaller.JAXB_FORMATTED_OUTPUT, true);

            jaxbMarshaller.marshal (vr, stringWriter);

        } catch (JAXBException e) {
            msoLogger.debug ("Error marshalling", e);
        }

        String response = stringWriter.toString ();

        this.httpResponse = Integer.toString (httpResponseCode);
        this.responseBody = response;

        return Response.status (httpResponseCode).entity (response).build ();
    }

    public String getRequestUri () {
        return requestUri;
    }

    public void setRequestUri (String requestUri) {
        this.requestUri = requestUri;
    }

    public VolumeInputs getVolumeInputs () {
        return volumeInputs;
    }

    public RequestInfo getRequestInfo () {
        return rinfo;
    }

    public String getResponseBody () {
        return responseBody;
    }

    public void setResponseBody (String responseBody) {
        this.responseBody = responseBody;
    }

    public String getHttpResponse () {
        return httpResponse;
    }

    public void setHttpResponse (String httpResponse) {
        this.httpResponse = httpResponse;
    }

    public String getRequestId () {
        return requestId;
    }

    public String getRequestXML () {
        return requestXML;
    }

    public void setRequestXML (String requestXML) {
        this.requestXML = requestXML;
    }

    public RequestStatusType getStatus () {
        return status;
    }

    public void setStatus (RequestStatusType status) {
        this.status = status;
        switch (status) {
        case FAILED:
        case COMPLETE:
        	this.progress = Constants.PROGRESS_REQUEST_COMPLETED;
        	break;
        case IN_PROGRESS:
        	this.progress = Constants.PROGRESS_REQUEST_IN_PROGRESS;
        	break;
        }
    }

    public String getServiceType () {
    	if (this.volumeInputs.getServiceType () != null)
    		return this.volumeInputs.getServiceType ();
    	if (this.volumeInputs.getServiceId () != null)
    		return this.volumeInputs.getServiceId ();
    	return null;
    }

    public static String domToStr (Document doc) {
        if (doc == null) {
            return null;
        }

        try {
            StringWriter sw = new StringWriter ();
            StreamResult sr = new StreamResult (sw);
            TransformerFactory tf = TransformerFactory.newInstance ();
            Transformer t = tf.newTransformer ();
            t.setOutputProperty (OutputKeys.STANDALONE, "yes");
            NodeList nl = doc.getDocumentElement ().getChildNodes ();
            DOMSource source = null;
            for (int x = 0; x < nl.getLength (); x++) {
                Node e = nl.item (x);
                if (e instanceof Element) {
                    source = new DOMSource (e);
                    break;
                }
            }
            if (source != null) {
                t.transform (source, sr);

                	String s = sw.toString ();
                	return s;
            }

               	return null;

            } catch (Exception e) {
            	msoLogger.error (MessageEnum.APIH_DOM2STR_ERROR, "", "", MsoLogger.ErrorCode.AvailabilityError, "Exception in domToStr", e);
            }
        return null;
    }
}