KickJava   Java API By Example, From Geeks To Geeks.

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


1 /*
2  * $Id: ServiceValidationException.java 5462 2005-08-05 18:35:48Z jonesde $
3  *
4  * Copyright (c) 2001, 2002 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.List JavaDoc;
28 import java.util.ArrayList JavaDoc;
29 import java.util.Iterator JavaDoc;
30
31 /**
32  * ServiceValidationException
33  *
34  * @author <a HREF="mailto:jaz@ofbiz.org">Andy Zeneski</a>
35  * @version $Rev: 5462 $
36  * @since 2.0
37  */

38 public class ServiceValidationException extends GenericServiceException {
39
40     protected List JavaDoc messages = new ArrayList JavaDoc();
41     protected List JavaDoc missingFields = new ArrayList JavaDoc();
42     protected List JavaDoc extraFields = new ArrayList JavaDoc();
43     protected String JavaDoc errorMode = null;
44     protected ModelService service = null;
45     
46     public ServiceValidationException(ModelService service, List JavaDoc missingFields, List JavaDoc extraFields, String JavaDoc errorMode) {
47         super();
48         this.service = service;
49         this.errorMode = errorMode;
50         if (missingFields != null) {
51             this.missingFields = missingFields;
52         }
53         if (extraFields != null) {
54             this.extraFields = extraFields;
55         }
56     }
57
58     public ServiceValidationException(String JavaDoc str, ModelService service) {
59         super(str);
60         this.service = service;
61     }
62
63     public ServiceValidationException(String JavaDoc str, ModelService service, List JavaDoc missingFields, List JavaDoc extraFields, String JavaDoc errorMode) {
64         super(str);
65         this.service = service;
66         this.errorMode = errorMode;
67         if (missingFields != null) {
68             this.missingFields = missingFields;
69         }
70         if (extraFields != null) {
71             this.extraFields = extraFields;
72         }
73     }
74
75     public ServiceValidationException(String JavaDoc str, Throwable JavaDoc nested, ModelService service) {
76         super(str, nested);
77         this.service = service;
78     }
79
80     public ServiceValidationException(String JavaDoc str, Throwable JavaDoc nested, ModelService service, List JavaDoc missingFields, List JavaDoc extraFields, String JavaDoc errorMode) {
81         super(str, nested);
82         this.service = service;
83         this.errorMode = errorMode;
84         if (missingFields != null) {
85             this.missingFields = missingFields;
86         }
87         if (extraFields != null) {
88             this.extraFields = extraFields;
89         }
90     }
91
92     public ServiceValidationException(List JavaDoc messages, ModelService service, List JavaDoc missingFields, List JavaDoc extraFields, String JavaDoc errorMode) {
93         super();
94         this.messages = messages;
95         this.service = service;
96         this.errorMode = errorMode;
97         if (missingFields != null) {
98             this.missingFields = missingFields;
99         }
100         if (extraFields != null) {
101             this.extraFields = extraFields;
102         }
103     }
104
105     public ServiceValidationException(List JavaDoc messages, ModelService service, String JavaDoc errorMode) {
106         this(messages, service, null, null, errorMode);
107     }
108
109     public List JavaDoc getExtraFields() {
110         return extraFields;
111     }
112
113     public List JavaDoc getMissingFields() {
114         return missingFields;
115     }
116
117     public List JavaDoc getMessageList() {
118         if (this.messages == null || this.messages.size() == 0) {
119             return null;
120         }
121         return this.messages;
122     }
123
124     public ModelService getModelService() {
125         return service;
126     }
127
128     public String JavaDoc getMode() {
129         return errorMode;
130     }
131
132     public String JavaDoc getServiceName() {
133         if (service != null) {
134             return service.name;
135         } else {
136             return null;
137         }
138     }
139
140     public String JavaDoc getMessage() {
141         String JavaDoc msg = super.getMessage();
142         if (this.messages != null && this.messages.size() > 0) {
143             if (msg != null) {
144                 msg += "\n";
145             } else {
146                 msg = "";
147             }
148             Iterator JavaDoc i = this.messages.iterator();
149             while (i.hasNext()) {
150                 msg += i.next();
151             }
152         }
153         return msg;
154     }
155 }
156
157
Popular Tags