KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > openharmonise > webdav > client > WebDAVFileSystemView


1 /*
2  * The contents of this file are subject to the
3  * Mozilla Public License Version 1.1 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at http://www.mozilla.org/MPL/
6  *
7  * Software distributed under the License is distributed on an "AS IS"
8  * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied.
9  * See the License for the specific language governing rights and
10  * limitations under the License.
11  *
12  * The Initial Developer of the Original Code is Simulacra Media Ltd.
13  * Portions created by Simulacra Media Ltd are Copyright (C) Simulacra Media Ltd, 2004.
14  *
15  * All Rights Reserved.
16  *
17  * Contributor(s):
18  */

19 package org.openharmonise.webdav.client;
20
21 import java.text.*;
22
23 import javax.swing.*;
24
25 import org.openharmonise.commons.xml.namespace.*;
26 import org.openharmonise.him.harmonise.*;
27 import org.openharmonise.vfs.*;
28 import org.openharmonise.vfs.gui.*;
29 import org.openharmonise.vfs.metadata.*;
30 import org.openharmonise.vfs.metadata.value.*;
31 import org.openharmonise.webdav.client.methods.*;
32 import org.openharmonise.webdav.client.value.*;
33 import org.openharmonise.webdav.date.*;
34
35
36 /**
37  * WebDAV implementation of the VirtualFileSystemView.
38  *
39  * @author Matthew Large
40  * @version $Revision: 1.2 $
41  *
42  */

43 public class WebDAVFileSystemView implements VirtualFileSystemView {
44
45     private String JavaDoc DISPLAY_DATE_FORMAT = "yyyy-MM-dd HH:mm";
46     
47     public WebDAVFileSystemView() {
48         super();
49     }
50
51     /* (non-Javadoc)
52      * @see com.simulacramedia.vfs.VirtualFileView#getIcon(com.simulacramedia.vfs.VirtualFile)
53      */

54     public Icon getIcon(VirtualFile vfFile) {
55         if((vfFile.getState()==VirtualFile.STATE_HISTORICAL || vfFile.getState()==VirtualFile.STATE_PENDING) && ((VersionedVirtualFile)vfFile).getLiveVersionPath()!=null ) {
56             vfFile = ((VersionedVirtualFile)vfFile).getVFS().getVirtualFile(((VersionedVirtualFile)vfFile).getLiveVersionPath()).getResource();
57         }
58         return this.getIcon(vfFile, false);
59     }
60
61     /* (non-Javadoc)
62      * @see com.simulacramedia.vfs.VirtualFileView#getIcon(com.simulacramedia.vfs.VirtualFile, boolean)
63      */

64     public Icon getIcon(VirtualFile vfFile, boolean bIsDirectoryOpen) {
65         if((vfFile.getState()==VirtualFile.STATE_HISTORICAL || vfFile.getState()==VirtualFile.STATE_PENDING) && ((VersionedVirtualFile)vfFile).getLiveVersionPath()!=null ) {
66             vfFile = ((VersionedVirtualFile)vfFile).getVFS().getVirtualFile(((VersionedVirtualFile)vfFile).getLiveVersionPath()).getResource();
67         }
68         return this.getIcon(vfFile.getFullPath(), vfFile.isDirectory(), bIsDirectoryOpen);
69     }
70
71     /* (non-Javadoc)
72      * @see com.simulacramedia.vfs.VirtualFileView#getIcon(com.simulacramedia.vfs.VirtualFile, boolean)
73      */

74     private Icon getIcon(String JavaDoc sFullPath, boolean bIsDirectory, boolean bIsDirectoryOpen) {
75
76         if (bIsDirectory) {
77             if (sFullPath.startsWith( HarmonisePaths.PATH_PROPERTIES ) || sFullPath.startsWith( HarmonisePaths.PATH_RBS_PROPS )) {
78                 return IconManager.getInstance().getIcon("16-property-container.gif");
79             } else if (sFullPath.startsWith( HarmonisePaths.PATH_VALUES ) || sFullPath.startsWith( HarmonisePaths.PATH_RBS_VALS )) {
80                 return IconManager.getInstance().getIcon("16-value-container.gif");
81             } else if (sFullPath.startsWith( HarmonisePaths.PATH_FLASH )) {
82                 if (bIsDirectoryOpen) {
83                     return IconManager.getInstance().getIcon("16-flash-folder-open.gif");
84                 } else {
85                     return IconManager.getInstance().getIcon("16-flash-folder.gif");
86                 }
87             } else if (sFullPath.startsWith( HarmonisePaths.PATH_IMAGES )) {
88                 if (bIsDirectoryOpen) {
89                     return IconManager.getInstance().getIcon("16-image-folder-open.gif");
90                 } else {
91                     return IconManager.getInstance().getIcon("16-image-folder.gif");
92                 }
93             } else if (sFullPath.startsWith( HarmonisePaths.PATH_EMAIL )) {
94                 if (bIsDirectoryOpen) {
95                     return IconManager.getInstance().getIcon("16-email-folder-open.gif");
96                 } else {
97                     return IconManager.getInstance().getIcon("16-email-folder.gif");
98                 }
99             } else if (sFullPath.startsWith( HarmonisePaths.PATH_LINKS )) {
100                 if (bIsDirectoryOpen) {
101                     return IconManager.getInstance().getIcon("16-link-folder-open.gif");
102                 } else {
103                     return IconManager.getInstance().getIcon("16-link-folder.gif");
104                 }
105             } else if (sFullPath.startsWith( HarmonisePaths.PATH_PDF )) {
106                 if (bIsDirectoryOpen) {
107                     return IconManager.getInstance().getIcon("16-pdf-folder-open.gif");
108                 } else {
109                     return IconManager.getInstance().getIcon("16-pdf-folder.gif");
110                 }
111             } else if (sFullPath.startsWith( HarmonisePaths.PATH_MOVIES )) {
112                 if (bIsDirectoryOpen) {
113                     return IconManager.getInstance().getIcon("16-movie-folder-open.gif");
114                 } else {
115                     return IconManager.getInstance().getIcon("16-movie-folder.gif");
116                 }
117             } else if (sFullPath.startsWith( HarmonisePaths.PATH_NEWSLETTER_DRAFT )) {
118                 return IconManager.getInstance().getIcon("16-newsletter-draft.gif");
119             } else if (sFullPath.startsWith( HarmonisePaths.PATH_NEWSLETTER_SENT )) {
120                 return IconManager.getInstance().getIcon("16-newsletter-sent.gif");
121             } else if (sFullPath.startsWith( HarmonisePaths.PATH_NEWSLETTER_OUTBOX )) {
122                 return IconManager.getInstance().getIcon("16-newsletter-outbox.gif");
123             } else if (sFullPath.startsWith( HarmonisePaths.PATH_USERS )) {
124                 return IconManager.getInstance().getIcon("16-user-container.gif");
125             } else if (sFullPath.startsWith( HarmonisePaths.PATH_ASSETS )) {
126                 if (bIsDirectoryOpen) {
127                     return IconManager.getInstance().getIcon("16-assets-folder-open.gif");
128                 } else {
129                     return IconManager.getInstance().getIcon("16-assets-folder.gif");
130                 }
131             } else if (sFullPath.startsWith( HarmonisePaths.PATH_INCLUDES )) {
132                 if (bIsDirectoryOpen) {
133                     return IconManager.getInstance().getIcon("16-includes-folder-open.gif");
134                 } else {
135                     return IconManager.getInstance().getIcon("16-includes-folder.gif");
136                 }
137             } else if (sFullPath.startsWith( HarmonisePaths.PATH_OBJECT_TEMPLATES )) {
138                 if (bIsDirectoryOpen) {
139                     return IconManager.getInstance().getIcon("16-object-template-folder-open.gif");
140                 } else {
141                     return IconManager.getInstance().getIcon("16-object-template-folder.gif");
142                 }
143             } else if (sFullPath.startsWith( HarmonisePaths.PATH_PAGE_DEFINITION )) {
144                 if (bIsDirectoryOpen) {
145                     return IconManager.getInstance().getIcon("16-page-definition-folder-open.gif");
146                 } else {
147                     return IconManager.getInstance().getIcon("16-page-definition-folder.gif");
148                 }
149             } else if (sFullPath.startsWith( HarmonisePaths.PATH_SITE_ASSETS_FLASH )) {
150                 if (bIsDirectoryOpen) {
151                     return IconManager.getInstance().getIcon("16-flash-folder-open.gif");
152                 } else {
153                     return IconManager.getInstance().getIcon("16-flash-folder.gif");
154                 }
155             } else if (sFullPath.startsWith( HarmonisePaths.PATH_SITE_ASSETS )) {
156                 if (bIsDirectoryOpen) {
157                     return IconManager.getInstance().getIcon("16-assets-folder-open.gif");
158                 } else {
159                     return IconManager.getInstance().getIcon("16-assets-folder.gif");
160                 }
161             } else if (sFullPath.startsWith( HarmonisePaths.PATH_REPORTS_QUERIES )) {
162                 if (bIsDirectoryOpen) {
163                     return IconManager.getInstance().getIcon("16-query-folder-open.gif");
164                 } else {
165                     return IconManager.getInstance().getIcon("16-query-folder.gif");
166                 }
167             } else if (sFullPath.startsWith( HarmonisePaths.PATH_REPORTS )) {
168                 if (bIsDirectoryOpen) {
169                     return IconManager.getInstance().getIcon("16-report-folder-open.gif");
170                 } else {
171                     return IconManager.getInstance().getIcon("16-report-folder.gif");
172                 }
173             } else if (sFullPath.startsWith( HarmonisePaths.PATH_PAGE_TEMPLATES )) {
174                 if (bIsDirectoryOpen) {
175                     return IconManager.getInstance().getIcon("16-template-folder-open.gif");
176                 } else {
177                     return IconManager.getInstance().getIcon("16-template-folder.gif");
178                 }
179             } else if (sFullPath.startsWith( HarmonisePaths.PATH_XSLT )) {
180                 if (bIsDirectoryOpen) {
181                     return IconManager.getInstance().getIcon("16-xslt-folder-open.gif");
182                 } else {
183                     return IconManager.getInstance().getIcon("16-xslt-folder.gif");
184                 }
185             } else if (sFullPath.startsWith( HarmonisePaths.PATH_DISPLAY )) {
186                 if (bIsDirectoryOpen) {
187                     return IconManager.getInstance().getIcon("16-template-container.gif");
188                 } else {
189                     return IconManager.getInstance().getIcon("16-template-container.gif");
190                 }
191             } else if (sFullPath.startsWith( HarmonisePaths.PATH_CONTENT )) {
192                 if (bIsDirectoryOpen) {
193                     return IconManager.getInstance().getIcon("16-section-open.gif");
194                 } else {
195                     return IconManager.getInstance().getIcon("16-section.gif");
196                 }
197             } else if (sFullPath.startsWith( HarmonisePaths.PATH_WORKFLOW_DEFINITIONS )) {
198                 if (bIsDirectoryOpen) {
199                     return IconManager.getInstance().getIcon("16-folder-open.gif");
200                 } else {
201                     return IconManager.getInstance().getIcon("16-folder.gif");
202                 }
203             } else if (sFullPath.startsWith( HarmonisePaths.PATH_WORKFLOW_PROPS )) {
204                 if (bIsDirectoryOpen) {
205                     return IconManager.getInstance().getIcon("16-folder-open.gif");
206                 } else {
207                     return IconManager.getInstance().getIcon("16-folder.gif");
208                 }
209             } else if (sFullPath.startsWith( HarmonisePaths.PATH_WORKFLOW_STAGES )) {
210                 if (bIsDirectoryOpen) {
211                     return IconManager.getInstance().getIcon("16-folder-open.gif");
212                 } else {
213                     return IconManager.getInstance().getIcon("16-folder.gif");
214                 }
215             } else if (sFullPath.equals( HarmonisePaths.PATH_ARCHIVE )) {
216                 return IconManager.getInstance().getIcon("16-archive-container.gif");
217             } else if (sFullPath.equals( HarmonisePaths.PATH_COMPOSITION )) {
218                 return IconManager.getInstance().getIcon("16-composition-container.gif");
219             } else if (sFullPath.startsWith( HarmonisePaths.PATH_METADATA )) {
220                 return IconManager.getInstance().getIcon("16-property-container.gif");
221             } else if (sFullPath.startsWith( HarmonisePaths.PATH_NEWSLETTER )) {
222                 return IconManager.getInstance().getIcon("16-newsletter.gif");
223             } else if (sFullPath.startsWith( HarmonisePaths.PATH_REPORTS )) {
224                 return IconManager.getInstance().getIcon("16-report.gif");
225             } else if (sFullPath.startsWith( HarmonisePaths.PATH_USERS )) {
226                 return IconManager.getInstance().getIcon("16-user-container.gif");
227             } else if (sFullPath.startsWith( HarmonisePaths.PATH_WEBSITE )) {
228                 return IconManager.getInstance().getIcon("16-website-container.gif");
229             } else if(sFullPath.startsWith( HarmonisePaths.PATH_ARCHIVE )) {
230                 return this.getIcon(sFullPath.replaceAll("/Archive", ""), bIsDirectory, bIsDirectoryOpen);
231             } else if (bIsDirectoryOpen) {
232                 return IconManager.getInstance().getIcon("16-section-open.gif");
233             } else {
234                 return IconManager.getInstance().getIcon("16-section.gif");
235             }
236         } else {
237             if (sFullPath.startsWith( HarmonisePaths.PATH_USERS )) {
238                 return IconManager.getInstance().getIcon("16-user.gif");
239             } else if (sFullPath.startsWith( HarmonisePaths.PATH_FLASH )) {
240                 return IconManager.getInstance().getIcon("16-movie.gif");
241             } else if (sFullPath.startsWith( HarmonisePaths.PATH_PDF )) {
242                 return IconManager.getInstance().getIcon("16-pdf.gif");
243             } else if (sFullPath.startsWith( HarmonisePaths.PATH_MOVIES )) {
244                 return IconManager.getInstance().getIcon("16-movie.gif");
245             } else if (sFullPath.startsWith( HarmonisePaths.PATH_LINKS )) {
246                 return IconManager.getInstance().getIcon("16-link.gif");
247             } else if (sFullPath.startsWith( HarmonisePaths.PATH_LINKS )) {
248                 return IconManager.getInstance().getIcon("16-link.gif");
249             } else if (sFullPath.startsWith( HarmonisePaths.PATH_EMAIL )) {
250                 return IconManager.getInstance().getIcon("16-email.gif");
251             } else if (sFullPath.startsWith( HarmonisePaths.PATH_IMAGES )) {
252                 return IconManager.getInstance().getIcon("16-image.gif");
253             } else if (sFullPath.startsWith( HarmonisePaths.PATH_PROPERTIES )) {
254                 return IconManager.getInstance().getIcon("16-property.gif");
255             } else if (sFullPath.startsWith( HarmonisePaths.PATH_VALUES ) || sFullPath.startsWith( HarmonisePaths.PATH_RBS_VALS )) {
256                 return IconManager.getInstance().getIcon("16-value.gif");
257             } else if (sFullPath.startsWith( HarmonisePaths.PATH_NEWSLETTER )) {
258                 return IconManager.getInstance().getIcon("16-newsletter.gif");
259             } else if (sFullPath.startsWith( HarmonisePaths.PATH_PAGE_TEMPLATES )) {
260                 return IconManager.getInstance().getIcon("16-template.gif");
261             } else if (sFullPath.startsWith( HarmonisePaths.PATH_INCLUDES )) {
262                 return IconManager.getInstance().getIcon("16-includes.gif");
263             } else if (sFullPath.startsWith( HarmonisePaths.PATH_OBJECT_TEMPLATES )) {
264                 return IconManager.getInstance().getIcon("16-object-template.gif");
265             } else if (sFullPath.startsWith( HarmonisePaths.PATH_PAGE_DEFINITION )) {
266                 return IconManager.getInstance().getIcon("16-page-definition.gif");
267             } else if (sFullPath.startsWith( HarmonisePaths.PATH_REPORTS_QUERIES )) {
268                 return IconManager.getInstance().getIcon("16-query.gif");
269             } else if (sFullPath.startsWith( HarmonisePaths.PATH_SITE_ASSETS_FLASH )) {
270                 return IconManager.getInstance().getIcon("16-movie.gif");
271             } else if (sFullPath.startsWith( HarmonisePaths.PATH_REPORTS_OUTPUT )) {
272                 return IconManager.getInstance().getIcon("16-report.gif");
273             } else if (sFullPath.startsWith( HarmonisePaths.PATH_XSLT )) {
274                 return IconManager.getInstance().getIcon("16-xslt.gif");
275             } else if (sFullPath.startsWith( HarmonisePaths.PATH_DISPLAY )) {
276                 return IconManager.getInstance().getIcon("16-xslt.gif");
277             } else if(sFullPath.startsWith( HarmonisePaths.PATH_WORKFLOW_DEFINITIONS )) {
278                 return IconManager.getInstance().getIcon("16-workflow-container.gif");
279             } else if(sFullPath.startsWith( HarmonisePaths.PATH_WORKFLOW_PROPS )) {
280                 return IconManager.getInstance().getIcon("16-command-change-status.gif");
281             } else if(sFullPath.startsWith( HarmonisePaths.PATH_WORKFLOW_STAGES )) {
282                 return IconManager.getInstance().getIcon("16-workflow-container.gif");
283             } else if(sFullPath.startsWith( HarmonisePaths.PATH_ARCHIVE )) {
284                 return this.getIcon(sFullPath.replaceAll("/Archive", ""), bIsDirectory, bIsDirectoryOpen);
285             } else {
286                 return IconManager.getInstance().getIcon("16-document.gif");
287             }
288         }
289     }
290
291     /* (non-Javadoc)
292      * @see com.simulacramedia.vfs.VirtualFileView#getDisplayName(com.simulacramedia.vfs.VirtualFile)
293      */

294     public String JavaDoc getDisplayName(VirtualFile vfFile) {
295         try {
296             VersionedVirtualFile vvfFile = (VersionedVirtualFile) vfFile;
297             PropertyInstance titleProp = vfFile.getProperty(NamespaceType.OHRM.getURI(), "title");
298             if(titleProp!=null && titleProp.getValues().size()>0 && !((StringValue)titleProp.getValues().get(0)).getValue().equals("")) {
299                 return ((StringValue)titleProp.getValues().get(0)).getValue();
300             } else {
301                 if(vvfFile.getLiveVersionPath()!=null) {
302                     VirtualFile vfLive = vvfFile.getVFS().getVirtualFile(vvfFile.getLiveVersionPath()).getResource();
303                     return vfLive.getFileName();
304                 } else {
305                     return vvfFile.getFileName();
306                 }
307             }
308         } catch (Exception JavaDoc e) {
309             e.printStackTrace(System.err);
310             return vfFile.getFileName();
311         }
312     }
313
314     /* (non-Javadoc)
315      * @see com.simulacramedia.vfs.VirtualFileSystemView#getFileSystemIcon()
316      */

317     public Icon getFileSystemIcon() {
318         return null;
319     }
320
321     /* (non-Javadoc)
322      * @see com.simulacramedia.vfs.VirtualFileSystemView#getFileSystemDisplayName()
323      */

324     public String JavaDoc getFileSystemDisplayName() {
325         return null;
326     }
327
328     /* (non-Javadoc)
329      * @see com.simulacramedia.vfs.VirtualFileSystemView#getVFSIndependantProperty(java.lang.String)
330      */

331     public PropertyInstance getVFSIndependantProperty(String JavaDoc sIndependantPropName) {
332         return null;
333     }
334
335     /* (non-Javadoc)
336      * @see com.simulacramedia.vfs.VirtualFileSystemView#getModificationDate()
337      */

338     public String JavaDoc getModificationDate(VirtualFile vfFile) {
339         PropertyInstance prop =vfFile.getProperty(PropFind.WEBDAV_NAMESPACE, "getlastmodified");
340         if (prop != null && prop.getValues().size() > 0) {
341             String JavaDoc sDate = ((StringValue) prop.getValues().get(0)).getValue();
342             String JavaDoc sFormattedDate = null;
343             
344             if(sDate != null && sDate.length()>0){
345                 try {
346                     sFormattedDate = DateFormatter.format(sDate,DISPLAY_DATE_FORMAT);
347                 } catch (ParseException e) {
348                     // just return the original
349
sFormattedDate = sDate;
350                 }
351             } else {
352                 sFormattedDate = "";
353             }
354             return sFormattedDate;
355         } else {
356             return "";
357         }
358     }
359
360     /* (non-Javadoc)
361      * @see com.simulacramedia.vfs.VirtualFileSystemView#getContentType(com.simulacramedia.vfs.VirtualFile)
362      */

363     public String JavaDoc getContentType(VirtualFile vfFile) {
364         PropertyInstance prop = vfFile.getProperty("DAV:", "getcontenttype");
365         if (prop != null && prop.getValues().size() > 0) {
366             return ((StringValue) prop.getValues().get(0)).getValue();
367         } else {
368             return "";
369         }
370     }
371
372     /* (non-Javadoc)
373      * @see com.simulacramedia.vfs.VirtualFileSystemView#setContentType(com.simulacramedia.vfs.VirtualFile, java.lang.String)
374      */

375     public void setContentType(VirtualFile vfFile, String JavaDoc sContentType) {
376         PropertyInstance propInst = new PropertyInstance(NamespaceType.DAV.getURI(), "getcontenttype");
377         propInst.setVirtualFile(vfFile);
378         StringValue val = (StringValue) propInst.getNewValueInstance();
379         val.setValue(sContentType);
380         propInst.addValueWithoutFiringVirtualFileEvent(val);
381         vfFile.addProperty(propInst);
382     }
383
384     /* (non-Javadoc)
385      * @see com.simulacramedia.vfs.VirtualFileSystemView#getSummary(com.simulacramedia.vfs.VirtualFile)
386      */

387     public String JavaDoc getSummary(VirtualFile vfFile) {
388         try {
389             VersionedVirtualFile vvfFile = (VersionedVirtualFile) vfFile;
390             if(vvfFile.getLiveVersionPath()!=null) {
391                 VirtualFile vfLive = vvfFile.getVFS().getVirtualFile(vvfFile.getLiveVersionPath()).getResource();
392                 PropertyInstance titleProp = vfLive.getProperty(NamespaceType.OHRM.getURI(), "description");
393                 if(titleProp!=null && titleProp.getValues().size()>0 && !((StringValue)titleProp.getValues().get(0)).getValue().equals("")) {
394                     return ((StringValue)titleProp.getValues().get(0)).getValue();
395                 } else {
396                     return "";
397                 }
398             } else {
399                 PropertyInstance titleProp = vfFile.getProperty(NamespaceType.OHRM.getURI(), "description");
400                 if(titleProp!=null && titleProp.getValues().size()>0 && !((StringValue)titleProp.getValues().get(0)).getValue().equals("")) {
401                     return ((StringValue)titleProp.getValues().get(0)).getValue();
402                 } else {
403                     return "";
404                 }
405             }
406         } catch (Exception JavaDoc e) {
407             e.printStackTrace(System.err);
408             return "";
409         }
410     }
411
412     /* (non-Javadoc)
413      * @see com.simulacramedia.vfs.VirtualFileSystemView#getLogicalFileName(com.simulacramedia.vfs.VirtualFile)
414      */

415     public String JavaDoc getLogicalFileName(VirtualFile vfFile) {
416         try {
417             VersionedVirtualFile vvfFile = (VersionedVirtualFile) vfFile;
418             if(vvfFile.getLiveVersionPath()!=null) {
419                 VirtualFile vfLive = vvfFile.getVFS().getVirtualFile(vvfFile.getLiveVersionPath()).getResource();
420                 return vfLive.getFileName();
421             } else {
422                 return vfFile.getFileName();
423             }
424         } catch (Exception JavaDoc e) {
425             e.printStackTrace(System.err);
426             return vfFile.getFileName();
427         }
428     }
429
430     /* (non-Javadoc)
431      * @see com.simulacramedia.vfs.VirtualFileSystemView#getPublicationDate(com.simulacramedia.vfs.VirtualFile)
432      */

433     public String JavaDoc getPublicationDate(VirtualFile vfFile) {
434         PropertyInstance prop =vfFile.getProperty(NamespaceType.OHRM.getURI(), "START");
435         if (prop != null && prop.getValues().size() > 0) {
436             String JavaDoc sDate = null;
437             String JavaDoc sFormattedDate = null;
438             try {
439                 sDate = ((DAVDateTimeValue) prop.getValues().get(0)).getValue();
440             } catch(ClassCastException JavaDoc cce) {
441                 cce.printStackTrace();
442             }
443             if(sDate != null && sDate.length()>0){
444                 try {
445                     sFormattedDate = DateFormatter.format(sDate,DISPLAY_DATE_FORMAT);
446                 } catch (ParseException e) {
447                     // just return the original
448
sFormattedDate = sDate;
449                 }
450             } else {
451                 sFormattedDate = "none";
452             }
453             return sFormattedDate;
454         } else {
455             return "none";
456         }
457     }
458
459     /* (non-Javadoc)
460      * @see com.simulacramedia.vfs.VirtualFileSystemView#getArchiveDate(com.simulacramedia.vfs.VirtualFile)
461      */

462     public String JavaDoc getArchiveDate(VirtualFile vfFile) {
463         PropertyInstance prop =vfFile.getProperty(NamespaceType.OHRM.getURI(), "archivedate");
464         if (prop != null && prop.getValues().size() > 0) {
465             String JavaDoc sDate = ((StringValue) prop.getValues().get(0)).getValue();
466             String JavaDoc sFormattedDate = null;
467             if(sDate != null && sDate.length()>0){
468                 try {
469                     sFormattedDate = DateFormatter.format(sDate,DISPLAY_DATE_FORMAT);
470                 } catch (ParseException e) {
471                     // just return the original
472
sFormattedDate = sDate;
473                 }
474             } else {
475                 sFormattedDate = "none";
476             }
477             return sFormattedDate;
478         } else {
479             return "none";
480         }
481     }
482     public static void main(String JavaDoc args[]){
483         String JavaDoc temp = null;
484         String JavaDoc sFormattedDate = null;
485         try {
486             temp = DateFormatter.format("Thu, 15 Apr 2004 16:51:29 GMT","yyyy-MM-dd HH:mm");
487         } catch (ParseException e) {
488             e.printStackTrace();
489         }
490         System.out.println(temp);
491     }
492
493 }
494
Popular Tags