Source Code Cross Referenced for FxDavEntry.java in  » J2EE » fleXive » com » flexive » war » webdav » 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 » J2EE » fleXive » com.flexive.war.webdav 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /***************************************************************
002:         *  This file is part of the [fleXive](R) project.
003:         *
004:         *  Copyright (c) 1999-2007
005:         *  UCS - unique computing solutions gmbh (http://www.ucs.at)
006:         *  All rights reserved
007:         *
008:         *  The [fleXive](R) project is free software; you can redistribute
009:         *  it and/or modify it under the terms of the GNU General Public
010:         *  License as published by the Free Software Foundation;
011:         *  either version 2 of the License, or (at your option) any
012:         *  later version.
013:         *
014:         *  The GNU General Public License can be found at
015:         *  http://www.gnu.org/copyleft/gpl.html.
016:         *  A copy is found in the textfile GPL.txt and important notices to the
017:         *  license from the author are found in LICENSE.txt distributed with
018:         *  these libraries.
019:         *
020:         *  This library is distributed in the hope that it will be useful,
021:         *  but WITHOUT ANY WARRANTY; without even the implied warranty of
022:         *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
023:         *  GNU General Public License for more details.
024:         *
025:         *  For further information about UCS - unique computing solutions gmbh,
026:         *  please see the company website: http://www.ucs.at
027:         *
028:         *  For further information about [fleXive](R), please see the
029:         *  project website: http://www.flexive.org
030:         *
031:         *
032:         *  This copyright notice MUST APPEAR in all copies of the file!
033:         ***************************************************************/package com.flexive.war.webdav;
034:
035:        import com.flexive.war.webdav.catalina.FastHttpDateFormat;
036:        import com.flexive.war.webdav.catalina.URLEncoder;
037:        import com.flexive.war.webdav.catalina.XMLWriter;
038:
039:        import java.text.SimpleDateFormat;
040:        import java.util.Date;
041:        import java.util.Vector;
042:
043:        public class FxDavEntry {
044:
045:            private Date creationdate;
046:            private String displayname;
047:            private Date lastmodified;
048:            protected long contentlength;
049:            private boolean isCollection;
050:
051:            protected static final String ALL_PROPS[] = { "creationdate",
052:                    "displayname", "getlastmodified", "getcontentlength",
053:                    "getcontenttype", "getetag", "resourcetype",
054:                    "supportedlock" };
055:
056:            // Simple date format for the creation date ISO representation (partial).
057:            protected static final SimpleDateFormat creationDateFormat = new SimpleDateFormat(
058:                    "yyyy-MM-dd'T'HH:mm:ss'Z'");
059:
060:            protected static URLEncoder urlEncoder;
061:
062:            protected FxDavEntry(boolean collection, Date creationdate,
063:                    String displayname, Date lastmodified, long contentlength) {
064:                this .isCollection = collection;
065:                this .creationdate = creationdate;
066:                this .displayname = displayname;
067:                this .lastmodified = lastmodified;
068:                this .contentlength = contentlength;
069:
070:            }
071:
072:            public void writeProperties(XMLWriter generatedXML, String path,
073:                    String[] properties) {
074:
075:                generatedXML.writeElement(null, "response", XMLWriter.OPENING);
076:
077:                // Generating href element
078:                writeElement(generatedXML, "href", FxWebDavServlet
079:                        .rewriteUrl(path));
080:
081:                // Write the properties
082:                String[] propertiesNotFound = _writeProperties(generatedXML,
083:                        properties, path);
084:
085:                // Write the property not found list
086:                if (propertiesNotFound.length > 0) {
087:                    generatedXML.writeElement(null, "propstat",
088:                            XMLWriter.OPENING);
089:                    generatedXML.writeElement(null, "prop", XMLWriter.OPENING);
090:                    for (String prop : propertiesNotFound) {
091:                        generatedXML.writeElement(null, prop,
092:                                XMLWriter.NO_CONTENT);
093:                    }
094:                    generatedXML.writeElement(null, "prop", XMLWriter.CLOSING);
095:                    writeStatus(generatedXML, FxWebDavStatus.SC_NOT_FOUND);
096:                    generatedXML.writeElement(null, "propstat",
097:                            XMLWriter.CLOSING);
098:                }
099:
100:                generatedXML.writeElement(null, "response", XMLWriter.CLOSING);
101:            }
102:
103:            /**
104:             * @param generatedXML
105:             * @param properties
106:             * @return a vector with all properties that could not be resolved
107:             */
108:            private String[] _writeProperties(XMLWriter generatedXML,
109:                    String[] properties, String path) {
110:
111:                Vector<String> propertiesNotFound = new Vector<String>();
112:                generatedXML.writeElement(null, "propstat", XMLWriter.OPENING);
113:                generatedXML.writeElement(null, "prop", XMLWriter.OPENING);
114:                for (String property : properties) {
115:                    if (property.equals("creationdate")) {
116:                        generatedXML
117:                                .writeProperty(null, "creationdate",
118:                                        getISOCreationDate(this .creationdate
119:                                                .getTime()));
120:                    } else if (property.equals("displayname")) {
121:                        writeElement(generatedXML, "displayname",
122:                                this .displayname);
123:                    } else if (property.equals("getcontentlanguage")) {
124:                        if (this .isCollection) {
125:                            propertiesNotFound.addElement(property);
126:                        } else {
127:                            generatedXML.writeElement(null,
128:                                    "getcontentlanguage", XMLWriter.NO_CONTENT); // TODO
129:                        }
130:                    } else if (property.equals("getcontentlength")) {
131:                        if (this .isCollection) {
132:                            propertiesNotFound.addElement(property);
133:                        } else {
134:                            generatedXML.writeProperty(null,
135:                                    "getcontentlength", (String
136:                                            .valueOf(this .contentlength)));
137:                        }
138:                    } else if (property.equals("getcontenttype")) {
139:                        if (this .isCollection) {
140:                            generatedXML.writeProperty(null, "getcontenttype",
141:                                    "httpd/unix-directory");
142:                        } else {
143:                            generatedXML.writeProperty(null, "getcontenttype",
144:                                    FxWebDavServletBase
145:                                            .getMimeType(this .displayname));
146:                        }
147:                    } else if (property.equals("getetag")) {
148:                        if (this .isCollection) {
149:                            propertiesNotFound.addElement(property);
150:                        } else {
151:                            //generatedXML.writeProperty(null, "getetag", getETag(cacheEntry.attributes));
152:                            generatedXML.writeProperty(null, "getetag", "fx3");
153:                        }
154:                    } else if (property.equals("getlastmodified")) {
155:                        if (this .isCollection) {
156:                            propertiesNotFound.addElement(property);
157:                        } else {
158:                            generatedXML.writeProperty(null, "getlastmodified",
159:                                    FastHttpDateFormat.formatDate(lastmodified
160:                                            .getTime(), null));
161:                        }
162:                    } else if (property.equals("resourcetype")) {
163:                        if (this .isCollection) {
164:                            generatedXML.writeElement(null, "resourcetype",
165:                                    XMLWriter.OPENING);
166:                            generatedXML.writeElement(null, "collection",
167:                                    XMLWriter.NO_CONTENT);
168:                            generatedXML.writeElement(null, "resourcetype",
169:                                    XMLWriter.CLOSING);
170:                        } else {
171:                            generatedXML.writeElement(null, "resourcetype",
172:                                    XMLWriter.NO_CONTENT);
173:                        }
174:                    } else if (property.equals("href")) {
175:
176:                        generatedXML.writeProperty(null, "href",
177:                                FxWebDavServlet.rewriteUrl(path));
178:                    } else if (property.equals("supportedlock")) {
179:                        String supportedLocks = "<lockentry><lockscope><exclusive/></lockscope><locktype><write/></locktype></lockentry>"
180:                                + "<lockentry><lockscope><shared/></lockscope><locktype><write/></locktype></lockentry>";
181:                        writeElement(generatedXML, "supportedlock",
182:                                supportedLocks);
183:                    } else if (property.equals("lockdiscovery")) {
184:                        // TODO!!
185:                        //if (!generateLockDiscovery(path, generatedXML))
186:                        //    propertiesNotFound.addElement(property);
187:                    } else {
188:                        // IE: name, parentname, ishidden, iscollection, isreadonly, contentclass, lastaccessed,
189:                        // isstructureddocument, defaultdocument, isroot
190:                        propertiesNotFound.addElement(property);
191:                    }
192:                }
193:
194:                // ALL_PROP only?
195:                //generateLockDiscovery(path, generatedXML);
196:
197:                generatedXML.writeElement(null, "prop", XMLWriter.CLOSING);
198:                writeStatus(generatedXML, FxWebDavStatus.SC_OK);
199:                generatedXML.writeElement(null, "propstat", XMLWriter.CLOSING);
200:
201:                return propertiesNotFound.toArray(new String[propertiesNotFound
202:                        .size()]);
203:            }
204:
205:            /**
206:             * @param generatedXML
207:             */
208:            protected void writePropertyNames(XMLWriter generatedXML,
209:                    String path) {
210:                generatedXML.writeElement(null, "response", XMLWriter.OPENING);
211:
212:                // Generating href element
213:                writeElement(generatedXML, "href", FxWebDavServlet
214:                        .rewriteUrl(path));
215:
216:                generatedXML.writeElement(null, "propstat", XMLWriter.OPENING);
217:
218:                // Write all available properties
219:                generatedXML.writeElement(null, "prop", XMLWriter.OPENING);
220:                generatedXML.writeElement(null, "creationdate",
221:                        XMLWriter.NO_CONTENT);
222:                generatedXML.writeElement(null, "displayname",
223:                        XMLWriter.NO_CONTENT);
224:                generatedXML.writeElement(null, "resourcetype",
225:                        XMLWriter.NO_CONTENT);
226:                generatedXML.writeElement(null, "source", XMLWriter.NO_CONTENT);
227:                generatedXML.writeElement(null, "lockdiscovery",
228:                        XMLWriter.NO_CONTENT);
229:                if (!isCollection) {
230:                    generatedXML.writeElement(null, "getcontentlanguage",
231:                            XMLWriter.NO_CONTENT);
232:                    generatedXML.writeElement(null, "getcontentlength",
233:                            XMLWriter.NO_CONTENT);
234:                    generatedXML.writeElement(null, "getcontenttype",
235:                            XMLWriter.NO_CONTENT);
236:                    generatedXML.writeElement(null, "getetag",
237:                            XMLWriter.NO_CONTENT);
238:                    generatedXML.writeElement(null, "getlastmodified",
239:                            XMLWriter.NO_CONTENT);
240:                }
241:                generatedXML.writeElement(null, "prop", XMLWriter.CLOSING);
242:
243:                // Write the status
244:                writeStatus(generatedXML, FxWebDavStatus.SC_OK);
245:                generatedXML.writeElement(null, "propstat", XMLWriter.CLOSING);
246:
247:                generatedXML.writeElement(null, "response", XMLWriter.CLOSING);
248:            }
249:
250:            /**
251:             * Get creation date in ISO format.
252:             */
253:            private String getISOCreationDate(long creationDate) {
254:                StringBuffer creationDateValue = new StringBuffer(
255:                        creationDateFormat.format(new Date(creationDate)));
256:                return creationDateValue.toString();
257:            }
258:
259:            /**
260:             * @param generatedXML
261:             * @param status
262:             */
263:            private void writeStatus(XMLWriter generatedXML, int status) {
264:                String sStatus = "HTTP/1.1 " + status + " "
265:                        + FxWebDavStatus.getStatusText(status);
266:                generatedXML.writeElement(null, "status", XMLWriter.OPENING);
267:                generatedXML.writeText(sStatus);
268:                generatedXML.writeElement(null, "status", XMLWriter.CLOSING);
269:
270:            }
271:
272:            /**
273:             * Writes a text element to the xml stream.
274:             *
275:             * @param generatedXML the xml stream
276:             * @param text         the text
277:             */
278:            private void writeElement(XMLWriter generatedXML, String name,
279:                    String text) {
280:                generatedXML.writeElement(null, name, XMLWriter.OPENING);
281:                generatedXML.writeText(text);
282:                generatedXML.writeElement(null, name, XMLWriter.CLOSING);
283:            }
284:
285:            public Date getCreationdate() {
286:                return creationdate;
287:            }
288:
289:            public String getDisplayname() {
290:                return displayname;
291:            }
292:
293:            public Date getLastmodified() {
294:                return lastmodified;
295:            }
296:
297:            public boolean isCollection() {
298:                return isCollection;
299:            }
300:
301:            public String toString() {
302:                return this .displayname
303:                        + (isCollection ? ";Folder" : ";File;Size:"
304:                                + contentlength);
305:            }
306:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.