View Javadoc

1   /**
2    * Copyright 2005-2013 The Kuali Foundation
3    *
4    * Licensed under the Educational Community License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    *
8    * http://www.opensource.org/licenses/ecl2.php
9    *
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
15   */
16  package org.kuali.rice.kew.exception;
17  
18  import java.util.ArrayList;
19  import java.util.Collection;
20  
21  /**
22   * RuntimeException thrown from Service level classes when business rule validation
23   * fails.  This exception is caught by StrutsExceptionHandler.  If any service errors
24   * have been set on in the serviceErrors collection these are stripped off of the 
25   * exception put into ActionMessages in the Error que and the request is directed back to 
26   * the original ActionMapping input page.
27   */
28  public class WorkflowServiceErrorException extends RuntimeException {
29  
30  
31  	private static final long serialVersionUID = 2457592489303923040L;
32  	private Collection serviceErrors;
33      
34      public WorkflowServiceErrorException(String message) {
35          this(message, (Throwable)null);
36      }
37      
38      public WorkflowServiceErrorException(String message, Throwable throwable) {
39          super(message, throwable);
40          serviceErrors = new ArrayList();
41      }
42      
43      public WorkflowServiceErrorException(String msg, WorkflowServiceError error) {
44          super(msg);
45          serviceErrors = new ArrayList();
46          serviceErrors.add(error);
47      }
48  
49          public WorkflowServiceErrorException(String msg, Throwable t, WorkflowServiceError error) {
50          super(msg, t);
51          serviceErrors = new ArrayList();
52          serviceErrors.add(error);
53      }
54      
55      
56      public WorkflowServiceErrorException(String msg, Collection errors) {
57          super(msg);
58          setServiceErrors(errors);
59      }
60      
61      public Collection getServiceErrors() {
62          return serviceErrors;
63      }
64  
65      public void setServiceErrors(Collection serviceErrors) {
66          this.serviceErrors = serviceErrors;
67      }
68  
69      public String toString() {
70          if (serviceErrors != null) {
71              return super.toString() + " " + serviceErrors;    
72          } else {
73              return super.toString() + " (no service errors)";
74          }
75      }
76  }