Replaced all tabs with spaces in java and pom.xml
[so.git] / adapters / mso-adapter-utils / src / main / java / org / onap / so / cloudify / exceptions / MsoCloudifyException.java
1 /*-
2  * ============LICENSE_START=======================================================
3  * ONAP - SO
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
10  * 
11  *      http://www.apache.org/licenses/LICENSE-2.0
12  * 
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=========================================================
19  */
20
21 package org.onap.so.cloudify.exceptions;
22
23 import org.onap.so.openstack.exceptions.MsoException;
24 import org.onap.so.openstack.exceptions.MsoExceptionCategory;
25
26 /**
27  * OpenStack exception.
28  */
29 public class MsoCloudifyException extends MsoException {
30
31     /**
32      * Serialization id.
33      */
34     private static final long serialVersionUID = 3313636124141766495L;
35
36     private int statusCode;
37     private String statusMessage;
38     private String errorDetail;
39     private boolean pendingWorkflow;
40
41     /**
42      * Constructor to create a new MsoOpenstackException instance
43      * 
44      * @param code the error code
45      * @param message the error message
46      * @param detail error details
47      */
48     public MsoCloudifyException(int code, String message, String detail) {
49         // Set the detailed error as the Exception 'message'
50         super(detail);
51         super.category = MsoExceptionCategory.OPENSTACK;
52
53         this.statusCode = code;
54         this.statusMessage = message;
55         this.errorDetail = detail;
56         this.pendingWorkflow = false;
57     }
58
59     /**
60      * Constructor to propagate the caught exception (mostly for stack trace)
61      * 
62      * @param code the error code
63      * @param message the error message
64      * @param detail error details
65      * @param e the cause
66      */
67     public MsoCloudifyException(int code, String message, String detail, Exception e) {
68         // Set the detailed error as the Exception 'message'
69         super(detail, e);
70         super.category = MsoExceptionCategory.OPENSTACK;
71
72         this.statusCode = code;
73         this.statusMessage = message;
74         this.errorDetail = detail;
75         this.pendingWorkflow = false;
76     }
77
78     public void setPendingWorkflow(boolean pendingWorkflow) {
79         this.pendingWorkflow = pendingWorkflow;
80     }
81
82     @Override
83     public String toString() {
84         String error = "" + statusCode + " " + statusMessage + ": " + errorDetail
85                 + (pendingWorkflow ? " [workflow pending]" : "");
86         return error;
87     }
88 }