This project has retired. For details please refer to its Attic page.
CmisBaseException xref

1   /*
2    * Licensed to the Apache Software Foundation (ASF) under one
3    * or more contributor license agreements.  See the NOTICE file
4    * distributed with this work for additional information
5    * regarding copyright ownership.  The ASF licenses this file
6    * to you under the Apache License, Version 2.0 (the
7    * "License"); you may not use this file except in compliance
8    * with the License.  You may obtain a copy of the License at
9    *
10   * http://www.apache.org/licenses/LICENSE-2.0
11   *
12   * Unless required by applicable law or agreed to in writing,
13   * software distributed under the License is distributed on an
14   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15   * KIND, either express or implied.  See the License for the
16   * specific language governing permissions and limitations
17   * under the License.
18   */
19  package org.apache.chemistry.opencmis.commons.exceptions;
20  
21  import java.math.BigInteger;
22  
23  /**
24   * Base exception class for all CMIS client exceptions.
25   */
26  public abstract class CmisBaseException extends RuntimeException {
27  
28      private static final long serialVersionUID = 1L;
29  
30      /** Error code used by the Web Services binding. */
31      private BigInteger code = BigInteger.ZERO;
32  
33      /** Content the of the error page returned by the AtomPub server. */
34      private String errorContent;
35  
36      /**
37       * Default constructor.
38       */
39      protected CmisBaseException() {
40          super();
41      }
42  
43      /**
44       * Constructor.
45       * 
46       * @param message
47       *            error message
48       * @param code
49       *            error code
50       * @param cause
51       *            the cause
52       */
53      protected CmisBaseException(String message, BigInteger code, Throwable cause) {
54          super(message, cause);
55          this.code = code;
56      }
57  
58      /**
59       * Constructor.
60       * 
61       * @param message
62       *            error message
63       * @param errorContent
64       *            error page content
65       * @param cause
66       *            the cause
67       */
68      protected CmisBaseException(String message, String errorContent, Throwable cause) {
69          super(message, cause);
70          this.errorContent = errorContent;
71      }
72  
73      /**
74       * Constructor.
75       * 
76       * @param message
77       *            error message
78       * @param code
79       *            error code
80       */
81      protected CmisBaseException(String message, BigInteger code) {
82          super(message);
83          this.code = code;
84      }
85  
86      /**
87       * Constructor.
88       * 
89       * @param message
90       *            error message
91       * @param code
92       *            error code
93       * @param errorContent
94       *            error page content
95       */
96      protected CmisBaseException(String message, BigInteger code, String errorContent) {
97          super(message);
98          this.code = code;
99          this.errorContent = errorContent;
100     }
101 
102     /**
103      * Constructor.
104      * 
105      * @param message
106      *            error message
107      * @param errorContent
108      *            error page content
109      */
110     protected CmisBaseException(String message, String errorContent) {
111         super(message);
112         this.errorContent = errorContent;
113     }
114 
115     /**
116      * Constructor.
117      * 
118      * @param message
119      *            error message
120      * @param cause
121      *            the cause
122      */
123     protected CmisBaseException(String message, Throwable cause) {
124         this(message, (BigInteger) null, cause);
125     }
126 
127     /**
128      * Constructor.
129      * 
130      * @param message
131      *            error message
132      */
133     protected CmisBaseException(String message) {
134         this(message, (BigInteger) null);
135     }
136 
137     /**
138      * Returns the error code sent by the CMIS repository (Web Services binding
139      * only).
140      * 
141      * @return error code or <code>null</code> if the CMIS repository didn't
142      *         send an error code or the binding doesn't support error codes.
143      */
144     public BigInteger getCode() {
145         return code;
146     }
147 
148     /**
149      * Returns the content of the error page sent by the web server (AtomPub
150      * binding only).
151      * 
152      * @return the content of the error page or <code>null</code> if the server
153      *         didn't send text content.
154      */
155     public String getErrorContent() {
156         return errorContent;
157     }
158 
159     /**
160      * Returns the name of the exception as defined in the CMIS specification.
161      */
162     public abstract String getExceptionName();
163 }