Source Code Cross Referenced for MoveMethod.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.util.*;
019:        import java.util.logging.*;
020:
021:        import javax.servlet.http.*;
022:        import javax.xml.parsers.*;
023:
024:        import org.w3c.dom.*;
025:
026:        import com.ibm.webdav.*;
027:        import com.ibm.webdav.Collection;
028:        import com.ibm.webdav.impl.*;
029:
030:        /** Executes the WebDAV MOVE method.
031:         * @author Jim Amsden <jamsden@us.ibm.com>
032:         */
033:        public class MoveMethod extends WebDAVMethod {
034:            private static Logger m_logger = Logger.getLogger(MoveMethod.class
035:                    .getName());
036:
037:            /** Construct a MoveMethod.
038:             * @param request the servlet request
039:             * @param response the servlet response
040:             * @exception com.ibm.webdav.WebDAVException
041:             */
042:            public MoveMethod(HttpServletRequest request,
043:                    HttpServletResponse response) throws WebDAVException {
044:                super (request, response);
045:                methodName = "MOVE";
046:                context.setMethodName("MOVE");
047:            }
048:
049:            /** Execute the method.
050:             * @return the result status code
051:             */
052:            public WebDAVStatus execute() {
053:                setStatusCode(WebDAVStatus.SC_CREATED); // the default status code
054:                MultiStatus multiStatus = null;
055:                try {
056:                    // get any arguments out of the headers
057:                    String destination = context.getRequestContext()
058:                            .destination();
059:                    String overwriteString = context.getRequestContext()
060:                            .overwrite();
061:                    boolean overwrite = overwriteString != null
062:                            && overwriteString.equals("T");
063:                    String depth = context.getRequestContext().depth();
064:                    if (depth == null) {
065:                        depth = Collection.deep;
066:                    }
067:                    if (!depth.equals(Collection.deep)) {
068:                        throw new WebDAVException(WebDAVStatus.SC_BAD_REQUEST,
069:                                "Depth header must be infinity if present");
070:                    }
071:
072:                    // get the request entity body and parse it. This will contain the rules
073:                    // for moving properties
074:                    Vector propertiesToMove = null;
075:                    if (request.getContentLength() > 0) {
076:                        WebDAVErrorHandler errorHandler = new WebDAVErrorHandler(
077:                                resource.getURL().toString());
078:                        /*Parser xmlParser = new Parser(resource.getURL().toString(), errorListener, null);
079:                        xmlParser.setWarningNoDoctypeDecl(false);
080:                        xmlParser.setProcessNamespace(true);
081:                        Document document = xmlParser.readStream(request.getReader());*/
082:                        DocumentBuilderFactory factory = DocumentBuilderFactory
083:                                .newInstance();
084:                        factory.setNamespaceAware(true);
085:                        DocumentBuilder docbuilder = factory
086:                                .newDocumentBuilder();
087:                        docbuilder.setErrorHandler(errorHandler);
088:                        Document document = docbuilder
089:                                .parse(new org.xml.sax.InputSource(request
090:                                        .getReader()));
091:                        if (errorHandler.getErrorCount() > 0) {
092:                            throw new WebDAVException(
093:                                    WebDAVStatus.SC_BAD_REQUEST,
094:                                    "Syntax error in MOVE request entity body");
095:                        }
096:                        Element propertybehavior = (Element) document
097:                                .getDocumentElement();
098:                        Element keepalive = (Element) propertybehavior
099:                                .getElementsByTagNameNS("DAV:", "keepalive")
100:                                .item(0);
101:                        if (keepalive != null) {
102:                            propertiesToMove = new Vector();
103:                            NodeList hrefs = keepalive.getElementsByTagNameNS(
104:                                    "DAV:", "href");
105:                            Element href = null;
106:                            for (int i = 0; i < hrefs.getLength(); i++) {
107:                                href = (Element) hrefs.item(i);
108:                                String propertyURI = ((Text) href
109:                                        .getFirstChild()).getData();
110:                                propertiesToMove.addElement(propertyURI);
111:                            }
112:                        }
113:                    } // endif (request has body)
114:                    context.setMethodName("MOVE");
115:                    multiStatus = resource.move(context, destination,
116:                            overwrite, propertiesToMove);
117:                    Enumeration responses = multiStatus.getResponses();
118:                    if (responses.hasMoreElements()) {
119:                        MethodResponse methodResponse = (MethodResponse) responses
120:                                .nextElement();
121:                        if (responses.hasMoreElements()) {
122:                            // there's more than one response, so return a multistatus
123:                            context.getResponseContext()
124:                                    .contentType("text/xml");
125:                            setStatusCode(WebDAVStatus.SC_MULTI_STATUS);
126:                            setResponseHeaders();
127:
128:                            // output the results as an XML document
129:                            Document results = multiStatus.asXML();
130:                            //((Document) results).setEncoding(getResponseCharset());
131:                            if (ResourceImpl.debug) {
132:                                System.err.println("move results:");
133:                                PrintWriter pout = new PrintWriter(System.err);
134:                                pout.print(XMLUtility.printNode(results
135:                                        .getDocumentElement()));
136:                                //((Document) results).printWithFormat(pout);
137:                            }
138:                            PrintWriter pout = new PrintWriter(response
139:                                    .getWriter(), false);
140:                            pout.print(XMLUtility.printNode(results
141:                                    .getDocumentElement()));
142:                            //((Document) results).print(pout);
143:                            pout.close();
144:                        } else {
145:                            // there was just one MethodResponse, so return it directly instead
146:                            // of wrapped in a multistatus
147:                            setStatusCode(methodResponse.getStatus());
148:                            setResponseHeaders();
149:                        }
150:                    } else {
151:                        setResponseHeaders();
152:                    }
153:                } catch (WebDAVException exc) {
154:                    m_logger.log(Level.INFO, exc.getLocalizedMessage() + " - "
155:                            + request.getQueryString());
156:                    setStatusCode(exc.getStatusCode());
157:
158:                } catch (Exception exc) {
159:                    m_logger.log(Level.WARNING, exc.getMessage(), exc);
160:                    setStatusCode(WebDAVStatus.SC_INTERNAL_SERVER_ERROR);
161:                }
162:                return context.getStatusCode();
163:            }
164:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.