01: /*
02: * (C) Copyright Simulacra Media Ltd, 2004. All rights reserved.
03: *
04: * The program is provided "AS IS" without any warranty express or
05: * implied, including the warranty of non-infringement and the implied
06: * warranties of merchantibility and fitness for a particular purpose.
07: * Simulacra Media Ltd will not be liable for any damages suffered by you as a result
08: * of using the Program. In no event will Simulacra Media Ltd be liable for any
09: * special, indirect or consequential damages or lost profits even if
10: * Simulacra Media Ltd has been advised of the possibility of their occurrence.
11: * Simulacra Media Ltd will not be liable for any third party claims against you.
12: */
13:
14: package com.ibm.webdav;
15:
16: import java.util.logging.*;
17: import java.util.logging.Logger;
18:
19: import org.w3c.dom.Element;
20:
21: import javax.xml.parsers.*;
22: import org.w3c.dom.*;
23:
24: /**
25: *
26: * @author Michael Bell
27: * @version $Revision: 1.1 $
28: *
29: */
30: public class SchemaResponse extends Response {
31: private SearchSchema m_schema = null;
32:
33: /**
34: * Logger for this class
35: */
36: private static final Logger m_logger = Logger
37: .getLogger(SchemaResponse.class.getName());
38:
39: public SchemaResponse(Document document, SearchSchema schema,
40: String resourceURL) throws ServerException {
41: super (document);
42: m_schema = schema;
43: this .setResource(resourceURL);
44: }
45:
46: public boolean isOK() {
47: boolean isOk = true;
48:
49: return isOk;
50: }
51:
52: public Element asXML() {
53: Element response = document.createElementNS("DAV:",
54: "D:response");
55:
56: Element href = document.createElementNS("DAV:", "D:href");
57:
58: href.appendChild(document.createTextNode(getResource()));
59: response.appendChild(href);
60:
61: Element query_schema = document.createElementNS("DAV:",
62: "D:query-schema");
63:
64: query_schema.appendChild(document.importNode(m_schema.asXML(),
65: true));
66:
67: response.appendChild(query_schema);
68:
69: return response;
70: }
71:
72: public PropertyResponse toPropertyResponse() {
73: PropertyResponse response = new PropertyResponse(this
74: .getResource());
75: response.setDescription(getDescription());
76: try {
77: response.setDocument(DocumentBuilderFactory.newInstance()
78: .newDocumentBuilder().newDocument());
79: } catch (Exception e) {
80: m_logger.log(Level.WARNING, e.getLocalizedMessage(), e);
81: }
82: return response;
83: }
84: }
|