Source Code Cross Referenced for WebDAVURLConnection.java in  » Content-Management-System » harmonise » com » ibm » webdav » protocol » http » 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 » com.ibm.webdav.protocol.http 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        package com.ibm.webdav.protocol.http;
002:
003:        /*
004:         * (C) Copyright IBM Corp. 2000  All rights reserved.
005:         *
006:         * The program is provided "AS IS" without any warranty express or
007:         * implied, including the warranty of non-infringement and the implied
008:         * warranties of merchantibility and fitness for a particular purpose.
009:         * IBM will not be liable for any damages suffered by you as a result
010:         * of using the Program. In no event will IBM be liable for any
011:         * special, indirect or consequential damages or lost profits even if
012:         * IBM has been advised of the possibility of their occurrence. IBM
013:         * will not be liable for any third party claims against you.
014:         * 
015:         * Portions Copyright (C) Simulacra Media Ltd, 2004.
016:         */
017:        import java.io.*;
018:        import java.net.*;
019:
020:        /**
021:         * A class to represent a WebDAV HTTP connection to a remote object.
022:         * WebDAVURLConnection is a subclass of sun.net.www.protocol.http.HttpURLConnection
023:         * that overrides methods as required to support the additional WebDAV methods.
024:         * HttpURLConnection was not developed to be
025:         * subclassed as it contains private data that needs to be available in the
026:         * subclasses. So some of the method overrides may seem a little strange. See the
027:         * individual methods for details. The changes to HttpURLConnection are to allow
028:         * WebDAV methods, and to handle errors differently so that clients can receive
029:         * more specific exceptions.
030:         *
031:         * @author  Jim Amsden
032:         */
033:        public class WebDAVURLConnection extends
034:                sun.net.www.protocol.http.HttpURLConnection {
035:
036:            private static final String[] methods = { "GET", "POST", "HEAD",
037:                    "OPTIONS", "PUT",
038:                    "DELETE", // from HTTP/1.1
039:                    "MKCOL", "COPY", "MOVE", "PROPFIND", "PROPPATCH", "LOCK",
040:                    "UNLOCK", "SEARCH" };
041:            /* We only have a single static authenticator for now.
042:             */
043:            private static WebDAVAuthenticator defaultAuth;
044:
045:            protected WebDAVURLConnection(URL u, Handler handler)
046:                    throws IOException {
047:                super (u, handler);
048:            }
049:
050:            public WebDAVURLConnection(URL u, String host, int port)
051:                    throws IOException {
052:                super (u, host, port);
053:            }
054:
055:            /*
056:             * Catch the IOException the superclass raises when it gets a status code
057:             * greater than 400 and the file is not some text or HTML file that might
058:             * contain additional error information. Without this, the DAV4J client
059:             * API doesn't get a chance to convert the status code to a WebDAVException.
060:             */
061:
062:            public synchronized InputStream getInputStream() throws IOException {
063:                InputStream is = null;
064:                try {
065:                    is = super .getInputStream();
066:                } catch (IOException exc) {
067:                    // just ignore it, the DAV4J client API will translate the
068:                    // status code to the proper WebDAVException
069:                }
070:                return is;
071:            }
072:
073:            /*
074:             *
075:             * Overridden to support additional WebDAV methods.
076:             */
077:
078:            public synchronized OutputStream getOutputStream()
079:                    throws IOException {
080:                OutputStream os = null;
081:                String savedMethod = method;
082:                // see if the method supports output
083:                if (method.equals("GET") || method.equals("PUT")
084:                        || method.equals("POST") || method.equals("PROPFIND")
085:                        || method.equals("PROPPATCH") || method.equals("MKCOL")
086:                        || method.equals("MOVE") || method.equals("COPY")
087:                        || method.equals("LOCK")) {
088:                    // fake the method so the superclass method sets its instance variables
089:                    method = "PUT";
090:                } else {
091:                    // use any method that doesn't support output, an exception will be
092:                    // raised by the superclass
093:                    method = "DELETE";
094:                }
095:                os = super .getOutputStream();
096:                method = savedMethod;
097:                return os;
098:            }
099:
100:            /**
101:             * Set the method for the URL request, one of:
102:             * <UL>
103:             *  <LI>GET
104:             *  <LI>POST
105:             *  <LI>HEAD
106:             *  <LI>OPTIONS
107:             *  <LI>PUT
108:             *  <LI>DELETE
109:             *  <LI>PROPFIND
110:             *  <LI>PROPPATCH
111:             *  <LI>MKCOL
112:             *  <LI>MOVE
113:             *  <LI>COPY
114:             *  <LI>LOCK
115:             *  <LI>UNLOCK
116:             *  <LI>TRACE
117:             *
118:             * @exception ProtocolException if the method cannot be reset or if
119:             *              the requested method isn't valid for HTTP.
120:             */
121:            public void setRequestMethod(String method)
122:                    throws ProtocolException {
123:                if (connected) {
124:                    throw new ProtocolException(
125:                            "Cannot reset method once connected");
126:                }
127:                // prevent clients from specifying invalid methods. This prevents experimenting
128:                // with new methods without editing this code, but should be included for
129:                // security reasons.
130:                for (int i = 0; i < methods.length; i++) {
131:                    if (methods[i].equals(method)) {
132:                        this .method = method;
133:                        return;
134:                    }
135:                }
136:                throw new ProtocolException("Invalid WebDAV method: " + method);
137:            }
138:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.