001: /*
002: JSPWiki - a JSP-based WikiWiki clone.
003:
004: Copyright (C) 2001-2002 Janne Jalkanen (Janne.Jalkanen@iki.fi)
005:
006: This program is free software; you can redistribute it and/or modify
007: it under the terms of the GNU Lesser General Public License as published by
008: the Free Software Foundation; either version 2.1 of the License, or
009: (at your option) any later version.
010:
011: This program is distributed in the hope that it will be useful,
012: but WITHOUT ANY WARRANTY; without even the implied warranty of
013: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
014: GNU Lesser General Public License for more details.
015:
016: You should have received a copy of the GNU Lesser General Public License
017: along with this program; if not, write to the Free Software
018: Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
019: */
020: package com.ecyrd.jspwiki.dav;
021:
022: import java.io.IOException;
023:
024: import javax.servlet.ServletException;
025: import javax.servlet.http.HttpServlet;
026: import javax.servlet.http.HttpServletRequest;
027: import javax.servlet.http.HttpServletResponse;
028:
029: /**
030: * @author jalkanen
031: *
032: * @since
033: */
034: public class WebdavServlet extends HttpServlet {
035: private static final long serialVersionUID = 1L;
036:
037: private static final String METHOD_PROPPATCH = "PROPPATCH";
038: private static final String METHOD_PROPFIND = "PROPFIND";
039: private static final String METHOD_MKCOL = "MKCOL";
040: private static final String METHOD_COPY = "COPY";
041: private static final String METHOD_MOVE = "MOVE";
042: private static final String METHOD_LOCK = "LOCK";
043: private static final String METHOD_UNLOCK = "UNLOCK";
044:
045: public static final int SC_PROCESSING = 102;
046: public static final int SC_MULTISTATUS = 207;
047: public static final int SC_UNPROCESSABLE = 422;
048: public static final int SC_LOCKED = 423;
049: public static final int SC_FAILED_DEPENDENCY = 424;
050: public static final int SC_INSUFFICIENT_STORAGE = 507;
051:
052: /**
053: *
054: */
055: public WebdavServlet() {
056: super ();
057: // TODO Auto-generated constructor stub
058: }
059:
060: public void doPropFind(HttpServletRequest request,
061: HttpServletResponse response) throws ServletException,
062: IOException {
063:
064: }
065:
066: public void doPropPatch(HttpServletRequest request,
067: HttpServletResponse response) throws ServletException,
068: IOException {
069:
070: }
071:
072: public void doMkCol(HttpServletRequest request,
073: HttpServletResponse response) throws ServletException,
074: IOException {
075:
076: }
077:
078: public void doCopy(HttpServletRequest request,
079: HttpServletResponse response) throws ServletException,
080: IOException {
081:
082: }
083:
084: public void doMove(HttpServletRequest request,
085: HttpServletResponse response) throws ServletException,
086: IOException {
087:
088: }
089:
090: /**
091: * The default implementation of this class just returns an error code.
092: *
093: * @param request
094: * @param response
095: */
096: public void doLock(HttpServletRequest request,
097: HttpServletResponse response) throws ServletException,
098: IOException {
099: try {
100: response.sendError(HttpServletResponse.SC_NOT_IMPLEMENTED,
101: "Sorry");
102: } catch (IOException e) {
103: }
104: }
105:
106: /**
107: * The default implementation of this class just returns an error code.
108: *
109: * @param request
110: * @param response
111: */
112:
113: public void doUnlock(HttpServletRequest request,
114: HttpServletResponse response) throws ServletException,
115: IOException {
116: try {
117: response.sendError(HttpServletResponse.SC_NOT_IMPLEMENTED,
118: "Sorry");
119: } catch (IOException e) {
120: }
121: }
122:
123: protected void service(HttpServletRequest request,
124: HttpServletResponse response) throws ServletException,
125: IOException {
126: String method = request.getMethod();
127:
128: // System.out.println("METHOD="+method+"; request="+request.getPathInfo() );
129:
130: try {
131: if (METHOD_PROPPATCH.equals(method)) {
132: doPropPatch(request, response);
133: } else if (METHOD_PROPFIND.equals(method)) {
134: doPropFind(request, response);
135: } else if (METHOD_MKCOL.equals(method)) {
136: doMkCol(request, response);
137: } else if (METHOD_COPY.equals(method)) {
138: doCopy(request, response);
139: } else if (METHOD_MOVE.equals(method)) {
140: doMove(request, response);
141: } else if (METHOD_LOCK.equals(method)) {
142: doLock(request, response);
143: } else if (METHOD_UNLOCK.equals(method)) {
144: doUnlock(request, response);
145: } else if ("OPTIONS".equals(method)) {
146: doOptions(request, response);
147: } else {
148: super .service(request, response);
149: }
150: } catch (Throwable t) {
151: t.printStackTrace(System.out);
152:
153: throw new ServletException(t);
154: }
155: }
156: }
|