KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > alfresco > repo > webdav > WebDAVServerException


1 /*
2  * Copyright (C) 2005 Alfresco, Inc.
3  *
4  * Licensed under the Mozilla Public License version 1.1
5  * with a permitted attribution clause. You may obtain a
6  * copy of the License at
7  *
8  * http://www.alfresco.org/legal/license.txt
9  *
10  * Unless required by applicable law or agreed to in writing,
11  * software distributed under the License is distributed on an
12  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
13  * either express or implied. See the License for the specific
14  * language governing permissions and limitations under the
15  * License.
16  */

17 package org.alfresco.repo.webdav;
18
19 import javax.servlet.http.HttpServletResponse JavaDoc;
20
21 /**
22  * Exception class that represents an error in the WebDAV protocol layer
23  *
24  * @author gavinc
25  */

26 public class WebDAVServerException extends Exception JavaDoc
27 {
28     private static final long serialVersionUID = -2949418282738082368L;
29
30     private int m_httpStatusCode = HttpServletResponse.SC_INTERNAL_SERVER_ERROR;
31     private Throwable JavaDoc m_cause = null;
32
33     /**
34      * Constructs a WebDAVException
35      *
36      * @param httpStatusCode The HTTP status code
37      */

38     public WebDAVServerException(int httpStatusCode)
39     {
40         this(httpStatusCode, null);
41     }
42
43     /**
44      * Constructs a WebDAVException
45      *
46      * @param httpStatusCode The HTTP status code
47      * @param cause The cause of this exception
48      */

49     public WebDAVServerException(int httpStatusCode, Throwable JavaDoc cause)
50     {
51         super(Integer.toString(httpStatusCode));
52
53         m_httpStatusCode = httpStatusCode;
54         m_cause = cause;
55     }
56
57     /**
58      * Returns the HTTP status code
59      *
60      * @return The HTTP status code
61      */

62     public int getHttpStatusCode()
63     {
64         return m_httpStatusCode;
65     }
66
67     /**
68      * Returns the cause of this exception
69      *
70      * @return The cause of this exception
71      */

72     public Throwable JavaDoc getCause()
73     {
74         return m_cause;
75     }
76
77     /**
78      * @see java.lang.Object#toString()
79      */

80     public String JavaDoc toString()
81     {
82         String JavaDoc strErrorMsg = "HTTP Status Code: " + m_httpStatusCode;
83
84         if (m_cause != null)
85         {
86             strErrorMsg = strErrorMsg + " caused by: " + m_cause.toString();
87         }
88
89         return strErrorMsg;
90     }
91 }
92
Popular Tags