KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > ibm > webdav > SchemaResponse


1 /*
2  * (C) Copyright Simulacra Media Ltd, 2004. All rights reserved.
3  *
4  * The program is provided "AS IS" without any warranty express or
5  * implied, including the warranty of non-infringement and the implied
6  * warranties of merchantibility and fitness for a particular purpose.
7  * Simulacra Media Ltd will not be liable for any damages suffered by you as a result
8  * of using the Program. In no event will Simulacra Media Ltd be liable for any
9  * 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 JavaDoc;
18
19 import org.w3c.dom.Element JavaDoc;
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 JavaDoc m_logger = Logger
37             .getLogger(SchemaResponse.class.getName());
38
39     public SchemaResponse(Document document, SearchSchema schema,
40             String JavaDoc 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 JavaDoc asXML() {
53         Element JavaDoc response = document.createElementNS("DAV:", "D:response");
54
55         Element JavaDoc href = document.createElementNS("DAV:", "D:href");
56
57         href.appendChild(document.createTextNode(getResource()));
58         response.appendChild(href);
59
60         Element JavaDoc query_schema = document.createElementNS("DAV:",
61                 "D:query-schema");
62
63         query_schema.appendChild(document.importNode(m_schema.asXML(), true));
64
65         response.appendChild(query_schema);
66
67         return response;
68     }
69
70     public PropertyResponse toPropertyResponse() {
71         PropertyResponse response = new PropertyResponse(this.getResource());
72         response.setDescription(getDescription());
73         try {
74             response.setDocument(DocumentBuilderFactory.newInstance()
75                     .newDocumentBuilder().newDocument());
76         } catch (Exception JavaDoc e) {
77             m_logger.log(Level.WARNING, e.getLocalizedMessage(), e);
78         }
79         return response;
80     }
81 }
Popular Tags