Source Code Cross Referenced for ReportMethod.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:        /*
002:         * (C) Copyright SimulacraMedia 2003.  All rights reserved.
003:         * 
004:         * Created on Nov 13, 2003
005:         *
006:         */
007:        package com.ibm.webdav.protocol.http;
008:
009:        import java.io.*;
010:        import java.util.*;
011:        import java.util.logging.*;
012:
013:        import javax.servlet.http.*;
014:        import javax.xml.parsers.*;
015:
016:        import org.w3c.dom.*;
017:
018:        import com.ibm.webdav.*;
019:        import com.ibm.webdav.impl.*;
020:
021:        /**
022:         * Executes the WebDAV Delta-V Report method.
023:         * 
024:         * @author Michael Bell
025:         * @version $Revision: 1.1 $
026:         *
027:         */
028:        public class ReportMethod extends WebDAVMethod {
029:            private static Logger m_logger = Logger
030:                    .getLogger(ReportMethod.class.getName());
031:
032:            public static final String METHOD_NAME = "REPORT";
033:
034:            /**
035:             * @param request
036:             * @param response
037:             * @throws WebDAVException
038:             */
039:            public ReportMethod(HttpServletRequest request,
040:                    HttpServletResponse response) throws WebDAVException {
041:                super (request, response);
042:                methodName = METHOD_NAME;
043:            }
044:
045:            /* (non-Javadoc)
046:             * @see com.ibm.webdav.protocol.http.WebDAVMethod#execute()
047:             */
048:            public WebDAVStatus execute() throws WebDAVException {
049:                MultiStatus multiStatus = null;
050:
051:                try {
052:                    // get any arguments out of the headers
053:                    String depth = context.getRequestContext().depth();
054:
055:                    Document contents = null;
056:
057:                    if (context.getRequestContext().contentLength() > 0) {
058:                        // get the request entity body and parse it
059:                        WebDAVErrorHandler errorHandler = new WebDAVErrorHandler(
060:                                resource.getURL().toString());
061:
062:                        DocumentBuilderFactory factory = DocumentBuilderFactory
063:                                .newInstance();
064:                        factory.setNamespaceAware(true);
065:
066:                        DocumentBuilder docbuilder = factory
067:                                .newDocumentBuilder();
068:                        docbuilder.setErrorHandler(errorHandler);
069:                        contents = docbuilder
070:                                .parse(new org.xml.sax.InputSource(request
071:                                        .getReader()));
072:
073:                        if (errorHandler.getErrorCount() > 0) {
074:                            throw new WebDAVException(
075:                                    WebDAVStatus.SC_BAD_REQUEST,
076:                                    "Syntax error in PROPFIND request entity body");
077:                        }
078:                    }
079:
080:                    // get the arguments for the getProperties() method, and figure
081:                    // out which method variant to call.
082:                    if (ResourceImpl.debug) {
083:                        System.err.println("property request entity:");
084:
085:                        PrintWriter pout = new PrintWriter(System.err);
086:                        pout.print(XMLUtility.printNode(contents
087:                                .getDocumentElement()));
088:
089:                        //((Document) contents).printWithFormat(pout);
090:                    }
091:
092:                    Element versionTree = (Element) ((contents == null) ? null
093:                            : contents.getDocumentElement());
094:
095:                    if (versionTree == null
096:                            || versionTree.getElementsByTagNameNS("DAV:",
097:                                    "version-tree").getLength() == 0) {
098:                        throw new WebDAVException(WebDAVStatus.SC_BAD_REQUEST,
099:                                "Invalid request body");
100:                    } else if (versionTree.getElementsByTagNameNS("DAV:",
101:                            "allprop").getLength() > 0) {
102:
103:                        multiStatus = resource.getVersionTreeReport(context);
104:
105:                    } else {
106:                        Vector tempNames = new Vector();
107:                        Node prop = versionTree.getElementsByTagNameNS("DAV:",
108:                                "prop").item(0);
109:                        NodeList propnames = prop.getChildNodes();
110:                        String sss = "bleh";
111:                        Element propname = null;
112:
113:                        for (int i = 0; i < propnames.getLength(); i++) {
114:                            //propname = (Element) propnames.item(i);
115:                            Object objj = (Object) propnames.item(i);
116:
117:                            if (objj instanceof  Text) {
118:                                // skip.  Probably just a CRLF or something
119:                                Text tt = (Text) objj;
120:                                sss = "x" + tt.getNodeValue() + "y";
121:                            } else {
122:                                propname = (Element) objj;
123:
124:                                Element tx = (Element) propname;
125:
126:                                //tempNames.addElement(propname.getTagName());
127:                                tempNames.addElement(new PropertyName(tx));
128:                            }
129:                        }
130:
131:                        PropertyName[] names = new PropertyName[tempNames
132:                                .size()];
133:                        Enumeration nameEnumerator = tempNames.elements();
134:                        int i = 0;
135:
136:                        while (nameEnumerator.hasMoreElements()) {
137:                            names[i] = (PropertyName) nameEnumerator
138:                                    .nextElement();
139:                            i++;
140:                        }
141:
142:                        if (resource.exists() == true) {
143:                            multiStatus = resource.getVersionTreeReport(
144:                                    context, names);
145:                        }
146:                    }
147:
148:                    context.getResponseContext().contentType("text/xml");
149:                    setResponseHeaders();
150:                    setStatusCode(WebDAVStatus.SC_MULTI_STATUS);
151:
152:                    // output the results as an XML document
153:                    Document results = multiStatus.asXML();
154:
155:                    // set the character encoding for the document to that specified by
156:                    // the client in the Accept header
157:                    //((Document) results).setEncoding(getResponseCharset());
158:                    if (ResourceImpl.debug) {
159:                        System.err.println("property results:");
160:
161:                        PrintWriter pout = new PrintWriter(System.err);
162:                        pout.print(XMLUtility.printNode(results
163:                                .getDocumentElement()));
164:
165:                        //((Document) results).printWithFormat(pout);
166:                    }
167:
168:                    PrintWriter pout = new PrintWriter(response.getWriter(),
169:                            false);
170:                    pout.print(XMLUtility.printNode(results
171:                            .getDocumentElement()));
172:
173:                    //((Document) results).print(pout);
174:                    //pout.print(multiStatus.toString());
175:                    pout.close();
176:                } catch (WebDAVException exc) {
177:                    setStatusCode(exc.getStatusCode());
178:                } catch (Exception exc) {
179:                    m_logger.log(Level.WARNING, exc.getMessage(), exc);
180:                    setStatusCode(WebDAVStatus.SC_INTERNAL_SERVER_ERROR);
181:                }
182:
183:                return context.getStatusCode();
184:            }
185:
186:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.