Source Code Cross Referenced for WebDAVResponse.java in  » Content-Management-System » harmonise » org » openharmonise » webdav » client » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Content Management System » harmonise » org.openharmonise.webdav.client 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * The contents of this file are subject to the 
003:         * Mozilla Public License Version 1.1 (the "License"); 
004:         * you may not use this file except in compliance with the License. 
005:         * You may obtain a copy of the License at http://www.mozilla.org/MPL/
006:         *
007:         * Software distributed under the License is distributed on an "AS IS"
008:         * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. 
009:         * See the License for the specific language governing rights and 
010:         * limitations under the License.
011:         *
012:         * The Initial Developer of the Original Code is Simulacra Media Ltd.
013:         * Portions created by Simulacra Media Ltd are Copyright (C) Simulacra Media Ltd, 2004.
014:         *
015:         * All Rights Reserved.
016:         *
017:         * Contributor(s):
018:         */
019:        package org.openharmonise.webdav.client;
020:
021:        import java.io.*;
022:        import java.util.*;
023:
024:        import javax.xml.parsers.*;
025:
026:        import org.w3c.dom.*;
027:        import org.xml.sax.*;
028:
029:        import HTTPClient.*;
030:
031:        /**
032:         * Wraps up all the data and methods for dealing with
033:         * WebDAV Responses.
034:         * 
035:         * @author Matthew Large
036:         * @version $Revision: 1.1 $
037:         *
038:         */
039:        public class WebDAVResponse {
040:
041:            /**
042:             * HTTP connection.
043:             */
044:            private HTTPResponse m_response = null;
045:
046:            /**
047:             * List of WebDAV multi-status response root elements.
048:             */
049:            private List m_aMultiStatusResponses = new ArrayList();
050:
051:            /**
052:             * URL of request.
053:             */
054:            private String m_sURL = null;
055:
056:            /**
057:             * Creates a new WebDAV repsonse.
058:             * 
059:             * @param response HTTPResponse used to create this WebDAVResponse
060:             * @throws IOException
061:             * @throws ModuleException
062:             */
063:            public WebDAVResponse(HTTPResponse response) throws IOException,
064:                    ModuleException {
065:                super ();
066:                this .m_response = response;
067:                this .processResponse();
068:            }
069:
070:            /**
071:             * Returns the overall status code for the response. If the overall status code
072:             * is 207 (MultiStatus) then there will be more detailed status codes in each
073:             * of the MultiStatusResponse objects.
074:             * 
075:             * @return int, status code for overall response
076:             * @throws IOException
077:             * @throws ModuleException
078:             */
079:            public int getStatusCode() throws IOException, ModuleException {
080:                return this .m_response.getStatusCode();
081:            }
082:
083:            /**
084:             * Returns the WebDAV response body.
085:             * 
086:             * @return byte array of the response body
087:             * @throws IOException
088:             * @throws ModuleException
089:             */
090:            public byte[] getResponseData() throws IOException, ModuleException {
091:                return this .m_response.getData();
092:            }
093:
094:            /**
095:             * XML of the response body.
096:             * 
097:             * @return XML
098:             */
099:            public Document getResponseXML() throws IOException {
100:                Document document = null;
101:                try {
102:                    DocumentBuilderFactory factory = DocumentBuilderFactory
103:                            .newInstance();
104:                    factory.setNamespaceAware(true);
105:                    document = factory.newDocumentBuilder().parse(
106:                            new InputSource(new InputStreamReader(
107:                                    new ByteArrayInputStream(this .m_response
108:                                            .getData()), "UTF-8")));
109:                } catch (SAXException e) {
110:                    e.printStackTrace(System.out);
111:                } catch (ParserConfigurationException e) {
112:                    e.printStackTrace(System.out);
113:                } catch (FactoryConfigurationError e) {
114:                    e.printStackTrace(System.out);
115:                } catch (ModuleException e) {
116:                    e.printStackTrace();
117:                }
118:
119:                return document;
120:            }
121:
122:            /**
123:             * Internal method to check if the response is MultiStatus, if so create all the
124:             * MultiStatusResponse objects.
125:             * 
126:             * @throws IOException
127:             * @throws ModuleException
128:             */
129:            private void processResponse() throws IOException, ModuleException {
130:                if (this .getStatusCode() == 207) {
131:                    this .processMultiStatusResponse();
132:                }
133:            }
134:
135:            /**
136:             * Returns list of MultiStatusResponse objects.
137:             * 
138:             * @return List of MultiStatusResponse objects, empty list if there aren't any
139:             */
140:            public List getMultiStatusResponses() {
141:                return this .m_aMultiStatusResponses;
142:            }
143:
144:            /**
145:             * Processes the WebDAV response XML to collect the
146:             * multi-status response elements.
147:             * 
148:             * @throws IOException
149:             */
150:            private void processMultiStatusResponse() throws IOException {
151:                Document xml = this .getResponseXML();
152:                if (xml != null) {
153:                    Element elMultiStatus = xml.getDocumentElement();
154:
155:                    NodeList nl = elMultiStatus.getChildNodes();
156:                    for (int i = 0; i < nl.getLength(); i++) {
157:                        if (nl.item(i).getNodeType() == Node.ELEMENT_NODE) {
158:                            Element elTemp = (Element) nl.item(i);
159:                            MultiStatusResponse multi = new MultiStatusResponse();
160:                            multi.populate(elTemp);
161:                            this .m_aMultiStatusResponses.add(multi);
162:                        }
163:                    }
164:                }
165:
166:            }
167:
168:            /**
169:             * Returns the URL of the request.
170:             * 
171:             * @return URL
172:             */
173:            public String getURL() {
174:                return this .m_sURL;
175:            }
176:
177:            /**
178:             * Sets the URL of the request.
179:             * 
180:             * @param sURL URL
181:             */
182:            protected void setURL(String sURL) {
183:                this .m_sURL = sURL;
184:            }
185:
186:            /**
187:             * Retrieves the value for a given header.
188:             * 
189:             * @param sName Header to return
190:             * @return the value for the header, or null if non-existent
191:             */
192:            public String getHeader(String sName) {
193:                String sReturn = null;
194:                try {
195:                    sReturn = this .m_response.getHeader(sName);
196:                } catch (IOException e) {
197:                    e.printStackTrace();
198:                } catch (ModuleException e) {
199:                    e.printStackTrace();
200:                }
201:                return sReturn;
202:            }
203:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.