001: /*
002: * The contents of this file are subject to the
003: * Mozilla Public License Version 1.1 (the "License");
004: * you may not use this file except in compliance with the License.
005: * You may obtain a copy of the License at http://www.mozilla.org/MPL/
006: *
007: * Software distributed under the License is distributed on an "AS IS"
008: * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied.
009: * See the License for the specific language governing rights and
010: * limitations under the License.
011: *
012: * The Initial Developer of the Original Code is Simulacra Media Ltd.
013: * Portions created by Simulacra Media Ltd are Copyright (C) Simulacra Media Ltd, 2004.
014: *
015: * All Rights Reserved.
016: *
017: * Contributor(s):
018: */
019: package org.openharmonise.webdav.client;
020:
021: import java.util.HashMap;
022:
023: import org.openharmonise.vfs.status.*;
024:
025: /**
026: *
027: * @author Matthew Large
028: * @version $Revision: 1.1 $
029: *
030: */
031: public class VFSStatusWebDAV extends AbstractStatusData implements
032: StatusData {
033:
034: private static HashMap m_statusMappings = new HashMap();
035:
036: static {
037: for (int i = 100; i < 400; i++) {
038: m_statusMappings.put(new Integer(i), new StatusMapping(i,
039: StatusData.LEVEL_CONFIRM, StatusData.STATUS_OK));
040: }
041:
042: m_statusMappings.put(new Integer(400), new StatusMapping(400,
043: StatusData.LEVEL_ERROR,
044: StatusData.STATUS_INVALID_REQUEST));
045: m_statusMappings.put(new Integer(401), new StatusMapping(401,
046: StatusData.LEVEL_ERROR,
047: StatusData.STATUS_INVALID_PERMISSIONS));
048: m_statusMappings.put(new Integer(402), new StatusMapping(402,
049: StatusData.LEVEL_ERROR,
050: StatusData.STATUS_INVALID_REQUEST));
051: m_statusMappings.put(new Integer(403), new StatusMapping(403,
052: StatusData.LEVEL_ERROR,
053: StatusData.STATUS_INVALID_PERMISSIONS));
054: m_statusMappings.put(new Integer(404), new StatusMapping(404,
055: StatusData.LEVEL_ERROR,
056: StatusData.STATUS_RESOURCE_NOT_FOUND));
057: m_statusMappings.put(new Integer(405), new StatusMapping(405,
058: StatusData.LEVEL_ERROR,
059: StatusData.STATUS_INVALID_REQUEST));
060: m_statusMappings.put(new Integer(406), new StatusMapping(406,
061: StatusData.LEVEL_ERROR,
062: StatusData.STATUS_INVALID_REQUEST));
063: m_statusMappings.put(new Integer(407), new StatusMapping(407,
064: StatusData.LEVEL_ERROR,
065: StatusData.STATUS_INVALID_PERMISSIONS));
066: m_statusMappings.put(new Integer(408), new StatusMapping(408,
067: StatusData.LEVEL_ERROR, StatusData.STATUS_TIMEOUT));
068: m_statusMappings.put(new Integer(409), new StatusMapping(409,
069: StatusData.LEVEL_ERROR,
070: StatusData.STATUS_INVALID_RESOURCE_STATE));
071: m_statusMappings.put(new Integer(410), new StatusMapping(410,
072: StatusData.LEVEL_ERROR,
073: StatusData.STATUS_RESOURCE_NOT_FOUND));
074: m_statusMappings.put(new Integer(411), new StatusMapping(411,
075: StatusData.LEVEL_ERROR,
076: StatusData.STATUS_INVALID_REQUEST));
077: m_statusMappings.put(new Integer(412), new StatusMapping(412,
078: StatusData.LEVEL_ERROR,
079: StatusData.STATUS_REQUEST_CONDITIONS_NOT_MET));
080: m_statusMappings.put(new Integer(413), new StatusMapping(413,
081: StatusData.LEVEL_ERROR,
082: StatusData.STATUS_INVALID_REQUEST));
083: m_statusMappings.put(new Integer(414), new StatusMapping(414,
084: StatusData.LEVEL_ERROR,
085: StatusData.STATUS_INVALID_REQUEST));
086: m_statusMappings.put(new Integer(415), new StatusMapping(415,
087: StatusData.LEVEL_ERROR,
088: StatusData.STATUS_INVALID_REQUEST));
089: m_statusMappings.put(new Integer(416), new StatusMapping(416,
090: StatusData.LEVEL_ERROR,
091: StatusData.STATUS_INVALID_REQUEST));
092: m_statusMappings.put(new Integer(417), new StatusMapping(417,
093: StatusData.LEVEL_ERROR,
094: StatusData.STATUS_INVALID_REQUEST));
095: for (int i = 418; i < 423; i++) {
096: m_statusMappings.put(new Integer(i), new StatusMapping(i,
097: StatusData.LEVEL_ERROR,
098: StatusData.STATUS_SERVER_ERROR));
099: }
100: m_statusMappings.put(new Integer(423), new StatusMapping(423,
101: StatusData.LEVEL_ERROR,
102: StatusData.STATUS_RESOURCE_LOCKED));
103: for (int i = 424; i < 500; i++) {
104: m_statusMappings.put(new Integer(i), new StatusMapping(i,
105: StatusData.LEVEL_ERROR,
106: StatusData.STATUS_SERVER_ERROR));
107: }
108: for (int i = 500; i < 600; i++) {
109: m_statusMappings.put(new Integer(i), new StatusMapping(i,
110: StatusData.LEVEL_ERROR,
111: StatusData.STATUS_SERVER_ERROR));
112: }
113: }
114:
115: /**
116: *
117: */
118: public VFSStatusWebDAV(int nHTTPStatus) {
119: super ();
120: StatusMapping stMap = (StatusMapping) m_statusMappings
121: .get(new Integer(nHTTPStatus));
122: super .setStatusCode(stMap.getStatus());
123: super .setStatusLevel(stMap.getLevel());
124: }
125:
126: public VFSStatusWebDAV() {
127: super ();
128: }
129:
130: public void setHTTPStatus(int nHTTPStatus) {
131: StatusMapping stMap = (StatusMapping) m_statusMappings
132: .get(new Integer(nHTTPStatus));
133: super .setStatusCode(stMap.getStatus());
134: super .setStatusLevel(stMap.getLevel());
135: }
136:
137: /* (non-Javadoc)
138: * @see com.simulacramedia.vfs.status.AbstractStatusData#setStatusCode(int)
139: */
140: public void setStatusCode(int nStatus) {
141: super .setStatusCode(nStatus);
142: }
143:
144: /* (non-Javadoc)
145: * @see com.simulacramedia.vfs.status.AbstractStatusData#setStatusLevel(int)
146: */
147: public void setStatusLevel(int nLevel) {
148: super.setStatusLevel(nLevel);
149: }
150: }
|