85510077953ec75443ae71fb4c8edb05b155a1f7
[so.git] / bpmn / MSOCoreBPMN / src / main / java / org / onap / so / bpmn / core / WorkflowException.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.bpmn.core;
22
23 import java.io.Serializable;
24
25 /**
26  * An object that represents a workflow exception.
27  */
28 public class WorkflowException implements Serializable {
29         private static final long serialVersionUID = 1L;
30
31         private final String processKey;
32         private final int errorCode;
33         private final String errorMessage;
34         private final String workStep;
35
36         /**
37          * Constructor
38          * @param processKey the process key for the process that generated the exception
39          * @param errorCode the numeric error code (normally 1xxx or greater)
40          * @param errorMessage a short error message
41          */
42         public WorkflowException(String processKey, int errorCode,
43                         String errorMessage) {
44                 this.processKey = processKey;
45                 this.errorCode = errorCode;
46                 this.errorMessage = errorMessage;
47                 workStep = "*";
48         }
49         
50         public WorkflowException(String processKey, int errorCode,
51                         String errorMessage, String workStep) {
52                 this.processKey = processKey;
53                 this.errorCode = errorCode;
54                 this.errorMessage = errorMessage;
55                 this.workStep = workStep;
56         }
57
58         /**
59          * Returns the process key.
60          */
61         public String getProcessKey() {
62                 return processKey;
63         }
64
65         /**
66          * Returns the error code.
67          */
68         public int getErrorCode() {
69                 return errorCode;
70         }
71
72         /**
73          * Returns the error message.
74          */
75         public String getErrorMessage() {
76                 return errorMessage;
77         }
78         
79         /**
80          * Returns the error message.
81          */
82         public String getWorkStep() {
83                 return workStep;
84         }
85
86         /**
87          * Returns a string representation of this object.
88          */
89     @Override
90         public String toString() {
91                 return getClass().getSimpleName() + "[processKey=" + getProcessKey() + ",errorCode=" + getErrorCode()
92                         + ",errorMessage=" + getErrorMessage() + ",workStep=" + getWorkStep() + "]";
93         }
94 }