KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > ofbiz > service > GeneralServiceException


1 /*
2  * $Id: GeneralServiceException.java 5462 2005-08-05 18:35:48Z jonesde $
3  *
4  * Copyright (c) 2004 The Open For Business Project - www.ofbiz.org
5  *
6  * Permission is hereby granted, free of charge, to any person obtaining a
7  * copy of this software and associated documentation files (the "Software"),
8  * to deal in the Software without restriction, including without limitation
9  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
10  * and/or sell copies of the Software, and to permit persons to whom the
11  * Software is furnished to do so, subject to the following conditions:
12  *
13  * The above copyright notice and this permission notice shall be included
14  * in all copies or substantial portions of the Software.
15  *
16  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
17  * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
19  * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
20  * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT
21  * OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR
22  * THE USE OR OTHER DEALINGS IN THE SOFTWARE.
23  *
24  */

25 package org.ofbiz.service;
26
27 import java.util.LinkedList JavaDoc;
28 import java.util.List JavaDoc;
29 import java.util.Map JavaDoc;
30
31 import org.ofbiz.base.util.Debug;
32
33 /**
34  * General Service Exception - base Exception for in-Service Errors
35  *
36  * @author <a HREF="mailto:jonesde@ofbiz.org">David E. Jones</a>
37  * @version $Rev: 5462 $
38  * @since 3.2
39  */

40 public class GeneralServiceException extends org.ofbiz.base.util.GeneralException {
41
42     protected List JavaDoc errorMsgList = null;
43     protected Map JavaDoc errorMsgMap = null;
44     protected Map JavaDoc nestedServiceResult = null;
45
46     public GeneralServiceException() {
47         super();
48     }
49
50     public GeneralServiceException(String JavaDoc str) {
51         super(str);
52     }
53
54     public GeneralServiceException(String JavaDoc str, Throwable JavaDoc nested) {
55         super(str, nested);
56     }
57
58     public GeneralServiceException(Throwable JavaDoc nested) {
59         super(nested);
60     }
61
62     public GeneralServiceException(String JavaDoc str, List JavaDoc errorMsgList, Map JavaDoc errorMsgMap, Map JavaDoc nestedServiceResult, Throwable JavaDoc nested) {
63         super(str, nested);
64         this.errorMsgList = errorMsgList;
65         this.errorMsgMap = errorMsgMap;
66         this.nestedServiceResult = nestedServiceResult;
67     }
68
69     public Map JavaDoc returnError(String JavaDoc module) {
70         String JavaDoc errMsg = this.getMessage() == null ? "Error in Service" : this.getMessage();
71         if (this.getNested() != null) {
72             Debug.logError(this.getNested(), errMsg, module);
73         }
74         return ServiceUtil.returnError(errMsg, this.errorMsgList, this.errorMsgMap, this.nestedServiceResult);
75     }
76
77     public void addErrorMessages(List JavaDoc errMsgs) {
78         if (this.errorMsgList == null) {
79             this.errorMsgList = new LinkedList JavaDoc();
80         }
81         this.errorMsgList.addAll(errMsgs);
82     }
83 }
84
Popular Tags