001: /*
002: * (C) Janne Jalkanen 2005
003: *
004: */
005: package com.ecyrd.jspwiki.dav;
006:
007: import java.io.IOException;
008:
009: import javax.servlet.ServletException;
010: import javax.servlet.http.HttpServlet;
011: import javax.servlet.http.HttpServletRequest;
012: import javax.servlet.http.HttpServletResponse;
013:
014: /**
015: * @author jalkanen
016: *
017: * @since
018: */
019: public class WebdavServlet extends HttpServlet {
020: private static final String METHOD_PROPPATCH = "PROPPATCH";
021: private static final String METHOD_PROPFIND = "PROPFIND";
022: private static final String METHOD_MKCOL = "MKCOL";
023: private static final String METHOD_COPY = "COPY";
024: private static final String METHOD_MOVE = "MOVE";
025: private static final String METHOD_LOCK = "LOCK";
026: private static final String METHOD_UNLOCK = "UNLOCK";
027:
028: public static final int SC_PROCESSING = 102;
029: public static final int SC_MULTISTATUS = 207;
030: public static final int SC_UNPROCESSABLE = 422;
031: public static final int SC_LOCKED = 423;
032: public static final int SC_FAILED_DEPENDENCY = 424;
033: public static final int SC_INSUFFICIENT_STORAGE = 507;
034:
035: /**
036: *
037: */
038: public WebdavServlet() {
039: super ();
040: // TODO Auto-generated constructor stub
041: }
042:
043: public void doPropFind(HttpServletRequest request,
044: HttpServletResponse response) throws ServletException,
045: IOException {
046:
047: }
048:
049: public void doPropPatch(HttpServletRequest request,
050: HttpServletResponse response) throws ServletException,
051: IOException {
052:
053: }
054:
055: public void doMkCol(HttpServletRequest request,
056: HttpServletResponse response) throws ServletException,
057: IOException {
058:
059: }
060:
061: public void doCopy(HttpServletRequest request,
062: HttpServletResponse response) throws ServletException,
063: IOException {
064:
065: }
066:
067: public void doMove(HttpServletRequest request,
068: HttpServletResponse response) throws ServletException,
069: IOException {
070:
071: }
072:
073: /**
074: * The default implementation of this class just returns an error code.
075: *
076: * @param request
077: * @param response
078: */
079: public void doLock(HttpServletRequest request,
080: HttpServletResponse response) throws ServletException,
081: IOException {
082: try {
083: response.sendError(HttpServletResponse.SC_NOT_IMPLEMENTED,
084: "Sorry");
085: } catch (IOException e) {
086: }
087: }
088:
089: /**
090: * The default implementation of this class just returns an error code.
091: *
092: * @param request
093: * @param response
094: */
095:
096: public void doUnlock(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: protected void service(HttpServletRequest request,
107: HttpServletResponse response) throws ServletException,
108: IOException {
109: String method = request.getMethod();
110:
111: //System.out.println("METHOD="+method+"; request="+request.getPathInfo() );
112:
113: try {
114: if (METHOD_PROPPATCH.equals(method)) {
115: doPropPatch(request, response);
116: } else if (METHOD_PROPFIND.equals(method)) {
117: doPropFind(request, response);
118: } else if (METHOD_MKCOL.equals(method)) {
119: doMkCol(request, response);
120: } else if (METHOD_COPY.equals(method)) {
121: doCopy(request, response);
122: } else if (METHOD_MOVE.equals(method)) {
123: doMove(request, response);
124: } else if (METHOD_LOCK.equals(method)) {
125: doLock(request, response);
126: } else if (METHOD_UNLOCK.equals(method)) {
127: doUnlock(request, response);
128: } else if ("OPTIONS".equals(method)) {
129: doOptions(request, response);
130: } else {
131: super .service(request, response);
132: }
133: } catch (Throwable t) {
134: t.printStackTrace(System.out);
135:
136: throw new ServletException(t);
137: }
138: }
139: }
|