01: package com.ibm.webdav.protocol.http;
02:
03: /*
04: * (C) Copyright IBM Corp. 2000 All rights reserved.
05: *
06: * The program is provided "AS IS" without any warranty express or
07: * implied, including the warranty of non-infringement and the implied
08: * warranties of merchantibility and fitness for a particular purpose.
09: * IBM will not be liable for any damages suffered by you as a result
10: * of using the Program. In no event will IBM be liable for any
11: * special, indirect or consequential damages or lost profits even if
12: * IBM has been advised of the possibility of their occurrence. IBM
13: * will not be liable for any third party claims against you.
14: *
15: * Portions Copyright (C) Simulacra Media Ltd, 2004.
16: */
17: import java.util.logging.*;
18:
19: import javax.servlet.http.*;
20:
21: import com.ibm.webdav.*;
22:
23: /** Executes the WebDAV POST method.
24: * @author Jim Amsden <jamsden@us.ibm.com>
25: */
26: public class PostMethod extends WebDAVMethod {
27: private static Logger m_logger = Logger.getLogger(PostMethod.class
28: .getName());
29:
30: /** Construct a PostMethod.
31: * @param request the servlet request
32: * @param response the servlet response
33: * @exception com.ibm.webdav.WebDAVException
34: */
35: public PostMethod(HttpServletRequest request,
36: HttpServletResponse response) throws WebDAVException {
37: super (request, response);
38: methodName = "POST";
39: }
40:
41: /** Execute the method.
42: * @return the result status code
43: */
44: public WebDAVStatus execute() {
45: try {
46: if (!resource.exists()) {
47: setStatusCode(WebDAVStatus.SC_NOT_FOUND);
48: return context.getStatusCode();
49: }
50:
51: // Submit the request entity to the requested resource and
52: // allow it to process it in some resource-specific way.
53:
54: setResponseHeaders();
55: setStatusCode(WebDAVStatus.SC_OK);
56: } catch (Exception exc) {
57: m_logger.log(Level.WARNING, exc.getMessage(), exc);
58: setStatusCode(WebDAVStatus.SC_INTERNAL_SERVER_ERROR);
59: }
60: return context.getStatusCode();
61: }
62: }
|