001: /*--
002:
003: Copyright (C) 2002 Anthony Eden.
004: All rights reserved.
005:
006: Redistribution and use in source and binary forms, with or without
007: modification, are permitted provided that the following conditions
008: are met:
009:
010: 1. Redistributions of source code must retain the above copyright
011: notice, this list of conditions, and the following disclaimer.
012:
013: 2. Redistributions in binary form must reproduce the above copyright
014: notice, this list of conditions, and the disclaimer that follows
015: these conditions in the documentation and/or other materials
016: provided with the distribution.
017:
018: 3. The names "OBE" and "Open Business Engine" must not be used to
019: endorse or promote products derived from this software without prior
020: written permission. For written permission, please contact
021: me@anthonyeden.com.
022:
023: 4. Products derived from this software may not be called "OBE" or
024: "Open Business Engine", nor may "OBE" or "Open Business Engine"
025: appear in their name, without prior written permission from
026: Anthony Eden (me@anthonyeden.com).
027:
028: In addition, I request (but do not require) that you include in the
029: end-user documentation provided with the redistribution and/or in the
030: software itself an acknowledgement equivalent to the following:
031: "This product includes software developed by
032: Anthony Eden (http://www.anthonyeden.com/)."
033:
034: THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
035: WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
036: OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
037: DISCLAIMED. IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT,
038: INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
039: (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
040: SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
041: HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
042: STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
043: IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
044: POSSIBILITY OF SUCH DAMAGE.
045:
046: For more information on OBE, please see <http://obe.sourceforge.net/>.
047:
048: */
049:
050: package org.wfmc.wapi;
051:
052: import java.io.Serializable;
053: import java.util.HashMap;
054: import java.util.Map;
055:
056: /**
057: * WfMC error codes.
058: *
059: * @author Anthony Eden, Adrian Price
060: */
061: public class WMError implements Serializable {
062: private static final long serialVersionUID = -8918399382127820849L;
063:
064: private static final String WM_SUCCESS_STR = "WM_SUCCESS";
065: private static final String WM_CONNECT_FAILED_STR = "WM_CONNECT_FAILED";
066: private static final String WM_INVALID_PROCESS_DEFINITION_STR = "WM_INVALID_PROCESS_DEFINITION";
067: private static final String WM_INVALID_ACTIVITY_NAME_STR = "WM_INVALID_ACTIVITY_NAME";
068: private static final String WM_INVALID_PROCESS_INSTANCE_STR = "WM_INVALID_PROCESS_INSTANCE";
069: private static final String WM_INVALID_ACTIVITY_INSTANCE_STR = "WM_INVALID_ACTIVITY_INSTANCE";
070: private static final String WM_INVALID_WORKITEM_STR = "WM_INVALID_WORKITEM";
071: private static final String WM_INVALID_ATTRIBUTE_STR = "WM_INVALID_ATTRIBUTE";
072: private static final String WM_ATTRIBUTE_ASSIGNMENT_FAILED_STR = "WM_INVALID_ATTRIBUTE_ASSIGNMENT_FAILED";
073: private static final String WM_TRANSITION_NOT_ALLOWED_STR = "WM_TRANSITION_NOT_ALLOWED";
074: private static final String WM_INVALID_SESSION_HANDLE_STR = "WM_INVALID_SESSION_HANDLE";
075: private static final String WM_INVALID_QUERY_HANDLE_STR = "WM_INVALID_QUERY_HANDLE";
076: private static final String WM_INVALID_SOURCE_USER_STR = "WM_INVALID_SOURCE_USER";
077: private static final String WM_INVALID_TARGET_USER_STR = "WM_INVALID_TARGET_USER";
078: private static final String WM_INVALID_FILTER_STR = "WM_INVALID_FILTER";
079: private static final String WM_LOCKED_STR = "WM_LOCKED";
080: private static final String WM_NOT_LOCKED_STR = "WM_NOT_LOCKED";
081: private static final String WM_NO_MORE_DATA_STR = "WM_NO_MORE_DATA";
082: private static final String WM_INSUFFICIENT_BUFFER_SIZE_STR = "WM_INSUFFICIENT_BUFFER_SIZE";
083: private static final String WM_EXECUTE_FAILED_STR = "WM_EXECUTE_FAILED";
084: private static final String WM_IOERROR_STR = "WM_IOERROR";
085: private static final String WM_GENERAL_ERROR_STR = "WM_GENERAL_ERROR";
086:
087: private static final Map MAIN_CODE_TO_STRING = new HashMap();
088: private static final Map SUB_CODE_TO_STRING = new HashMap();
089:
090: // These error codes are listed in wmerror.h in WFMC-TC-1013 version 1.4
091: public static final int WM_SUCCESS = 0x00000000;
092: public static final int WM_CONNECT_FAILED = 0x00100000;
093: public static final int WM_INVALID_PROCESS_DEFINITION = 0x00200000;
094: public static final int WM_INVALID_ACTIVITY_NAME = 0x00300000;
095: public static final int WM_INVALID_PROCESS_INSTANCE = 0x00400000;
096: public static final int WM_INVALID_ACTIVITY_INSTANCE = 0x00500000;
097: public static final int WM_INVALID_WORKITEM = 0x00600000;
098: public static final int WM_INVALID_ATTRIBUTE = 0x00700000;
099: public static final int WM_ATTRIBUTE_ASSIGNMENT_FAILED = 0x00800000;
100: public static final int WM_INVALID_STATE = 0x00900000;
101: public static final int WM_TRANSITION_NOT_ALLOWED = 0x00A00000;
102: public static final int WM_INVALID_SESSION_HANDLE = 0x00B00000;
103: public static final int WM_INVALID_QUERY_HANDLE = 0x00C00000;
104: public static final int WM_INVALID_SOURCE_USER = 0x00D00000;
105: public static final int WM_INVALID_TARGET_USER = 0x00E00000;
106: public static final int WM_INVALID_FILTER = 0x00F00000;
107: public static final int WM_LOCKED = 0x00F10000;
108: public static final int WM_NOT_LOCKED = 0x00F20000;
109: public static final int WM_NO_MORE_DATA = 0x00F30000;
110: public static final int WM_INSUFFICIENT_BUFFER_SIZE = 0x00F40000;
111: public static final int WM_EXECUTE_FAILED = 0x00F50000;
112:
113: // These additional error codes are referenced in WFMC-TC-1009
114: // Version 2.0e (Beta), but do not appear to be defined anywhere.
115: // public static final int WM_INSUFFICENT_BUFFER_SIZE = ;
116: // public static final int WM_APPLICATION_BUSY = ;
117: // public static final int WM_INVALID_APPLICATION = ;
118: // public static final int WM_APPLICATION_NOT_STARTED = ;
119: // public static final int WM_APPLICATION_NOT_DEFINED = ;
120: // public static final int WM_APPLICATION_NOT_STOPPED = ;
121: public static final int WM_UNSUPPORTED = 0x00F60000;
122:
123: // These error codes don't seem to be defined anywhere. Are they even WfMC?
124: public static final int WM_IOERROR = 0x01000000;
125: public static final int WM_GENERAL_ERROR = 0xffff0000;
126:
127: private int mainCode;
128: private short subCode;
129:
130: static {
131: MAIN_CODE_TO_STRING
132: .put(new Integer(WM_SUCCESS), WM_SUCCESS_STR);
133: MAIN_CODE_TO_STRING.put(new Integer(WM_CONNECT_FAILED),
134: WM_CONNECT_FAILED_STR);
135: MAIN_CODE_TO_STRING.put(new Integer(
136: WM_INVALID_PROCESS_DEFINITION),
137: WM_INVALID_PROCESS_DEFINITION_STR);
138: MAIN_CODE_TO_STRING.put(new Integer(WM_INVALID_ACTIVITY_NAME),
139: WM_INVALID_ACTIVITY_NAME_STR);
140: MAIN_CODE_TO_STRING.put(
141: new Integer(WM_INVALID_PROCESS_INSTANCE),
142: WM_INVALID_PROCESS_INSTANCE_STR);
143: MAIN_CODE_TO_STRING.put(new Integer(
144: WM_INVALID_ACTIVITY_INSTANCE),
145: WM_INVALID_ACTIVITY_INSTANCE_STR);
146: MAIN_CODE_TO_STRING.put(new Integer(WM_INVALID_WORKITEM),
147: WM_INVALID_WORKITEM_STR);
148: MAIN_CODE_TO_STRING.put(new Integer(WM_INVALID_ATTRIBUTE),
149: WM_INVALID_ATTRIBUTE_STR);
150: MAIN_CODE_TO_STRING.put(new Integer(
151: WM_ATTRIBUTE_ASSIGNMENT_FAILED),
152: WM_ATTRIBUTE_ASSIGNMENT_FAILED_STR);
153: MAIN_CODE_TO_STRING.put(new Integer(WM_TRANSITION_NOT_ALLOWED),
154: WM_TRANSITION_NOT_ALLOWED_STR);
155: MAIN_CODE_TO_STRING.put(new Integer(WM_INVALID_SESSION_HANDLE),
156: WM_INVALID_SESSION_HANDLE_STR);
157: MAIN_CODE_TO_STRING.put(new Integer(WM_INVALID_QUERY_HANDLE),
158: WM_INVALID_QUERY_HANDLE_STR);
159: MAIN_CODE_TO_STRING.put(new Integer(WM_INVALID_SOURCE_USER),
160: WM_INVALID_SOURCE_USER_STR);
161: MAIN_CODE_TO_STRING.put(new Integer(WM_INVALID_TARGET_USER),
162: WM_INVALID_TARGET_USER_STR);
163: MAIN_CODE_TO_STRING.put(new Integer(WM_INVALID_FILTER),
164: WM_INVALID_FILTER_STR);
165: MAIN_CODE_TO_STRING.put(new Integer(WM_LOCKED), WM_LOCKED_STR);
166: MAIN_CODE_TO_STRING.put(new Integer(WM_NOT_LOCKED),
167: WM_NOT_LOCKED_STR);
168: MAIN_CODE_TO_STRING.put(new Integer(WM_NO_MORE_DATA),
169: WM_NO_MORE_DATA_STR);
170: MAIN_CODE_TO_STRING.put(
171: new Integer(WM_INSUFFICIENT_BUFFER_SIZE),
172: WM_INSUFFICIENT_BUFFER_SIZE_STR);
173: MAIN_CODE_TO_STRING.put(new Integer(WM_EXECUTE_FAILED),
174: WM_EXECUTE_FAILED_STR);
175: MAIN_CODE_TO_STRING
176: .put(new Integer(WM_IOERROR), WM_IOERROR_STR);
177: MAIN_CODE_TO_STRING.put(new Integer(WM_GENERAL_ERROR),
178: WM_GENERAL_ERROR_STR);
179: }
180:
181: public WMError(int mainCode) {
182: this (mainCode, (short) 0);
183: }
184:
185: public WMError(int mainCode, short subCode) {
186: this .mainCode = mainCode;
187: this .subCode = subCode;
188: }
189:
190: public int getMainCode() {
191: return mainCode;
192: }
193:
194: public int getSubCode() {
195: return subCode;
196: }
197:
198: public String toString() {
199: return "WMError[mainCode="
200: + MAIN_CODE_TO_STRING.get(new Integer(mainCode))
201: + ", subCode="
202: + SUB_CODE_TO_STRING.get(new Integer(subCode)) + ']';
203: }
204: }
|