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 HEAD method.
24: * @author Jim Amsden <jamsden@us.ibm.com>
25: */
26: public class HeadMethod extends WebDAVMethod {
27:
28: private static Logger m_logger = Logger.getLogger(HeadMethod.class
29: .getName());
30:
31: /** Construct a HeadMethod.
32: * @param request the servlet request
33: * @param response the servlet response
34: * @exception com.ibm.webdav.WebDAVException
35: */
36: public HeadMethod(HttpServletRequest request,
37: HttpServletResponse response) throws WebDAVException {
38: super (request, response);
39: methodName = "HEAD";
40: }
41:
42: /** Execute the method.
43: * @return the result status code
44: */
45: public WebDAVStatus execute() {
46: try {
47: resource.getMetaInformation(context);
48: // fill in any response headers here
49:
50: // set the response headers and status code. This must
51: // be done before a byte is written to the output stream
52: // or the headers and status code will be lost
53: setStatusCode(WebDAVStatus.SC_OK);
54: setResponseHeaders();
55: } catch (WebDAVException exc) {
56: setStatusCode(exc.getStatusCode());
57: } catch (Exception exc) {
58: m_logger.log(Level.WARNING, exc.getMessage(), exc);
59: setStatusCode(WebDAVStatus.SC_INTERNAL_SERVER_ERROR);
60: }
61: return context.getStatusCode();
62: }
63: }
|