KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > openharmonise > webdav > client > VFSStatusWebDAV


1 /*
2  * The contents of this file are subject to the
3  * Mozilla Public License Version 1.1 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at http://www.mozilla.org/MPL/
6  *
7  * Software distributed under the License is distributed on an "AS IS"
8  * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied.
9  * See the License for the specific language governing rights and
10  * limitations under the License.
11  *
12  * The Initial Developer of the Original Code is Simulacra Media Ltd.
13  * Portions created by Simulacra Media Ltd are Copyright (C) Simulacra Media Ltd, 2004.
14  *
15  * All Rights Reserved.
16  *
17  * Contributor(s):
18  */

19 package org.openharmonise.webdav.client;
20
21 import java.util.HashMap JavaDoc;
22
23 import org.openharmonise.vfs.status.*;
24
25
26 /**
27  *
28  * @author Matthew Large
29  * @version $Revision: 1.1 $
30  *
31  */

32 public class VFSStatusWebDAV extends AbstractStatusData implements StatusData {
33
34     private static HashMap JavaDoc m_statusMappings = new HashMap JavaDoc();
35     
36     static {
37         for(int i=100; i<400; i++) {
38             m_statusMappings.put(new Integer JavaDoc(i), new StatusMapping(i, StatusData.LEVEL_CONFIRM, StatusData.STATUS_OK));
39         }
40         
41         m_statusMappings.put(new Integer JavaDoc(400), new StatusMapping(400, StatusData.LEVEL_ERROR, StatusData.STATUS_INVALID_REQUEST));
42         m_statusMappings.put(new Integer JavaDoc(401), new StatusMapping(401, StatusData.LEVEL_ERROR, StatusData.STATUS_INVALID_PERMISSIONS));
43         m_statusMappings.put(new Integer JavaDoc(402), new StatusMapping(402, StatusData.LEVEL_ERROR, StatusData.STATUS_INVALID_REQUEST));
44         m_statusMappings.put(new Integer JavaDoc(403), new StatusMapping(403, StatusData.LEVEL_ERROR, StatusData.STATUS_INVALID_PERMISSIONS));
45         m_statusMappings.put(new Integer JavaDoc(404), new StatusMapping(404, StatusData.LEVEL_ERROR, StatusData.STATUS_RESOURCE_NOT_FOUND));
46         m_statusMappings.put(new Integer JavaDoc(405), new StatusMapping(405, StatusData.LEVEL_ERROR, StatusData.STATUS_INVALID_REQUEST));
47         m_statusMappings.put(new Integer JavaDoc(406), new StatusMapping(406, StatusData.LEVEL_ERROR, StatusData.STATUS_INVALID_REQUEST));
48         m_statusMappings.put(new Integer JavaDoc(407), new StatusMapping(407, StatusData.LEVEL_ERROR, StatusData.STATUS_INVALID_PERMISSIONS));
49         m_statusMappings.put(new Integer JavaDoc(408), new StatusMapping(408, StatusData.LEVEL_ERROR, StatusData.STATUS_TIMEOUT));
50         m_statusMappings.put(new Integer JavaDoc(409), new StatusMapping(409, StatusData.LEVEL_ERROR, StatusData.STATUS_INVALID_RESOURCE_STATE));
51         m_statusMappings.put(new Integer JavaDoc(410), new StatusMapping(410, StatusData.LEVEL_ERROR, StatusData.STATUS_RESOURCE_NOT_FOUND));
52         m_statusMappings.put(new Integer JavaDoc(411), new StatusMapping(411, StatusData.LEVEL_ERROR, StatusData.STATUS_INVALID_REQUEST));
53         m_statusMappings.put(new Integer JavaDoc(412), new StatusMapping(412, StatusData.LEVEL_ERROR, StatusData.STATUS_REQUEST_CONDITIONS_NOT_MET));
54         m_statusMappings.put(new Integer JavaDoc(413), new StatusMapping(413, StatusData.LEVEL_ERROR, StatusData.STATUS_INVALID_REQUEST));
55         m_statusMappings.put(new Integer JavaDoc(414), new StatusMapping(414, StatusData.LEVEL_ERROR, StatusData.STATUS_INVALID_REQUEST));
56         m_statusMappings.put(new Integer JavaDoc(415), new StatusMapping(415, StatusData.LEVEL_ERROR, StatusData.STATUS_INVALID_REQUEST));
57         m_statusMappings.put(new Integer JavaDoc(416), new StatusMapping(416, StatusData.LEVEL_ERROR, StatusData.STATUS_INVALID_REQUEST));
58         m_statusMappings.put(new Integer JavaDoc(417), new StatusMapping(417, StatusData.LEVEL_ERROR, StatusData.STATUS_INVALID_REQUEST));
59         for(int i=418; i<423; i++) {
60             m_statusMappings.put(new Integer JavaDoc(i), new StatusMapping(i, StatusData.LEVEL_ERROR, StatusData.STATUS_SERVER_ERROR));
61         }
62         m_statusMappings.put(new Integer JavaDoc(423), new StatusMapping(423, StatusData.LEVEL_ERROR, StatusData.STATUS_RESOURCE_LOCKED));
63         for(int i=424; i<500; i++) {
64             m_statusMappings.put(new Integer JavaDoc(i), new StatusMapping(i, StatusData.LEVEL_ERROR, StatusData.STATUS_SERVER_ERROR));
65         }
66         for(int i=500; i<600; i++) {
67             m_statusMappings.put(new Integer JavaDoc(i), new StatusMapping(i, StatusData.LEVEL_ERROR, StatusData.STATUS_SERVER_ERROR));
68         }
69     }
70     
71     /**
72      *
73      */

74     public VFSStatusWebDAV(int nHTTPStatus) {
75         super();
76         StatusMapping stMap = (StatusMapping) m_statusMappings.get(new Integer JavaDoc(nHTTPStatus));
77         super.setStatusCode(stMap.getStatus());
78         super.setStatusLevel(stMap.getLevel());
79     }
80     
81     public VFSStatusWebDAV() {
82         super();
83     }
84     
85     public void setHTTPStatus(int nHTTPStatus) {
86         StatusMapping stMap = (StatusMapping) m_statusMappings.get(new Integer JavaDoc(nHTTPStatus));
87         super.setStatusCode(stMap.getStatus());
88         super.setStatusLevel(stMap.getLevel());
89     }
90     
91     /* (non-Javadoc)
92      * @see com.simulacramedia.vfs.status.AbstractStatusData#setStatusCode(int)
93      */

94     public void setStatusCode(int nStatus) {
95         super.setStatusCode(nStatus);
96     }
97     /* (non-Javadoc)
98      * @see com.simulacramedia.vfs.status.AbstractStatusData#setStatusLevel(int)
99      */

100     public void setStatusLevel(int nLevel) {
101         super.setStatusLevel(nLevel);
102     }
103 }
104
Popular Tags