KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > ibm > webdav > protocol > http > PostMethod


1 package com.ibm.webdav.protocol.http;
2
3 /*
4  * (C) Copyright IBM Corp. 2000 All rights reserved.
5  *
6  * The program is provided "AS IS" without any warranty express or
7  * implied, including the warranty of non-infringement and the implied
8  * warranties of merchantibility and fitness for a particular purpose.
9  * 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.getName());
28
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, HttpServletResponse response) throws WebDAVException {
36     super(request, response);
37     methodName = "POST";
38 }
39 /** Execute the method.
40 * @return the result status code
41 */

42 public WebDAVStatus execute() {
43     try {
44         if (!resource.exists()) {
45             setStatusCode( WebDAVStatus.SC_NOT_FOUND );
46             return context.getStatusCode();
47         }
48
49         // Submit the request entity to the requested resource and
50
// allow it to process it in some resource-specific way.
51

52         setResponseHeaders();
53         setStatusCode(WebDAVStatus.SC_OK);
54     } catch (Exception JavaDoc exc) {
55         m_logger.log(Level.WARNING, exc.getMessage(), exc);
56         setStatusCode(WebDAVStatus.SC_INTERNAL_SERVER_ERROR);
57     }
58     return context.getStatusCode();
59 }
60 }
61
Popular Tags