1
22
23 package com.liferay.portlet.documentlibrary.webdav;
24
25 import com.liferay.documentlibrary.DuplicateFileException;
26 import com.liferay.lock.DuplicateLockException;
27 import com.liferay.lock.ExpiredLockException;
28 import com.liferay.lock.InvalidLockException;
29 import com.liferay.lock.NoSuchLockException;
30 import com.liferay.lock.model.Lock;
31 import com.liferay.portal.PortalException;
32 import com.liferay.portal.kernel.util.FileUtil;
33 import com.liferay.portal.kernel.util.StringPool;
34 import com.liferay.portal.kernel.util.StringUtil;
35 import com.liferay.portal.kernel.util.Validator;
36 import com.liferay.portal.security.auth.PrincipalException;
37 import com.liferay.portal.webdav.BaseResourceImpl;
38 import com.liferay.portal.webdav.BaseWebDAVStorageImpl;
39 import com.liferay.portal.webdav.LockException;
40 import com.liferay.portal.webdav.Resource;
41 import com.liferay.portal.webdav.Status;
42 import com.liferay.portal.webdav.WebDAVException;
43 import com.liferay.portal.webdav.WebDAVRequest;
44 import com.liferay.portal.webdav.WebDAVUtil;
45 import com.liferay.portlet.documentlibrary.DuplicateFolderNameException;
46 import com.liferay.portlet.documentlibrary.NoSuchFileEntryException;
47 import com.liferay.portlet.documentlibrary.NoSuchFolderException;
48 import com.liferay.portlet.documentlibrary.model.DLFileEntry;
49 import com.liferay.portlet.documentlibrary.model.DLFolder;
50 import com.liferay.portlet.documentlibrary.model.impl.DLFolderImpl;
51 import com.liferay.portlet.documentlibrary.service.DLFileEntryLocalServiceUtil;
52 import com.liferay.portlet.documentlibrary.service.DLFileEntryServiceUtil;
53 import com.liferay.portlet.documentlibrary.service.DLFolderServiceUtil;
54 import com.liferay.portlet.tags.service.TagsEntryLocalServiceUtil;
55
56 import java.io.File;
57 import java.io.InputStream;
58
59 import java.util.ArrayList;
60 import java.util.List;
61
62 import javax.servlet.http.HttpServletRequest;
63 import javax.servlet.http.HttpServletResponse;
64
65 import org.apache.commons.logging.Log;
66 import org.apache.commons.logging.LogFactory;
67
68
75 public class DLWebDAVStorageImpl extends BaseWebDAVStorageImpl {
76
77 public int copyCollectionResource(
78 WebDAVRequest webDavRequest, Resource resource, String destination,
79 boolean overwrite, long depth)
80 throws WebDAVException {
81
82 try {
83 String[] destinationArray = WebDAVUtil.getPathArray(
84 destination, true);
85
86 long parentFolderId = DLFolderImpl.DEFAULT_PARENT_FOLDER_ID;
87
88 try {
89 parentFolderId = getParentFolderId(destinationArray);
90 }
91 catch (NoSuchFolderException nsfe) {
92 return HttpServletResponse.SC_CONFLICT;
93 }
94
95 DLFolder folder = (DLFolder)resource.getModel();
96
97 long groupId = WebDAVUtil.getGroupId(destination);
98 long plid = getPlid(groupId);
99 String name = WebDAVUtil.getResourceName(destinationArray);
100 String description = folder.getDescription();
101 boolean addCommunityPermissions = true;
102 boolean addGuestPermissions = true;
103
104 int status = HttpServletResponse.SC_CREATED;
105
106 if (overwrite) {
107 if (deleteResource(
108 groupId, parentFolderId, name,
109 webDavRequest.getLockUuid())) {
110
111 status = HttpServletResponse.SC_NO_CONTENT;
112 }
113 }
114
115 if (depth == 0) {
116 DLFolderServiceUtil.addFolder(
117 plid, parentFolderId, name, description,
118 addCommunityPermissions, addGuestPermissions);
119 }
120 else {
121 DLFolderServiceUtil.copyFolder(
122 plid, folder.getFolderId(), parentFolderId, name,
123 description, addCommunityPermissions, addGuestPermissions);
124 }
125
126 return status;
127 }
128 catch (DuplicateFolderNameException dfne) {
129 return HttpServletResponse.SC_PRECONDITION_FAILED;
130 }
131 catch (PrincipalException pe) {
132 return HttpServletResponse.SC_FORBIDDEN;
133 }
134 catch (Exception e) {
135 throw new WebDAVException(e);
136 }
137 }
138
139 public int copySimpleResource(
140 WebDAVRequest webDavRequest, Resource resource, String destination,
141 boolean overwrite)
142 throws WebDAVException {
143
144 File file = null;
145
146 try {
147 String[] destinationArray = WebDAVUtil.getPathArray(
148 destination, true);
149
150 long parentFolderId = DLFolderImpl.DEFAULT_PARENT_FOLDER_ID;
151
152 try {
153 parentFolderId = getParentFolderId(destinationArray);
154 }
155 catch (NoSuchFolderException nsfe) {
156 return HttpServletResponse.SC_CONFLICT;
157 }
158
159 DLFileEntry fileEntry = (DLFileEntry)resource.getModel();
160
161 long groupId = WebDAVUtil.getGroupId(destination);
162 long userId = webDavRequest.getUserId();
163 String name = WebDAVUtil.getResourceName(destinationArray);
164 String title = WebDAVUtil.getResourceName(destinationArray);
165 String description = fileEntry.getDescription();
166 String[] tagsEntries = null;
167 String extraSettings = fileEntry.getExtraSettings();
168
169 file = FileUtil.createTempFile(
170 FileUtil.getExtension(fileEntry.getName()));
171
172 InputStream is = DLFileEntryLocalServiceUtil.getFileAsStream(
173 fileEntry.getCompanyId(), userId, fileEntry.getFolderId(),
174 fileEntry.getName());
175
176 FileUtil.write(file, is);
177
178 boolean addCommunityPermissions = true;
179 boolean addGuestPermissions = true;
180
181 int status = HttpServletResponse.SC_CREATED;
182
183 if (overwrite) {
184 if (deleteResource(
185 groupId, parentFolderId, title,
186 webDavRequest.getLockUuid())) {
187
188 status = HttpServletResponse.SC_NO_CONTENT;
189 }
190 }
191
192 DLFileEntryServiceUtil.addFileEntry(
193 parentFolderId, name, title, description, tagsEntries,
194 extraSettings, file, addCommunityPermissions,
195 addGuestPermissions);
196
197 return status;
198 }
199 catch (DuplicateFolderNameException dfne) {
200 return HttpServletResponse.SC_PRECONDITION_FAILED;
201 }
202 catch (DuplicateFileException dfe) {
203 return HttpServletResponse.SC_PRECONDITION_FAILED;
204 }
205 catch (LockException le) {
206 return WebDAVUtil.SC_LOCKED;
207 }
208 catch (PrincipalException pe) {
209 return HttpServletResponse.SC_FORBIDDEN;
210 }
211 catch (Exception e) {
212 throw new WebDAVException(e);
213 }
214 finally {
215 if (file != null) {
216 file.delete();
217 }
218 }
219 }
220
221 public int deleteResource(WebDAVRequest webDavRequest)
222 throws WebDAVException {
223
224 try {
225 Resource resource = getResource(webDavRequest);
226
227 if (resource == null) {
228 return HttpServletResponse.SC_NOT_FOUND;
229 }
230
231 Object model = resource.getModel();
232
233 if (model instanceof DLFolder) {
234 DLFolder folder = (DLFolder)model;
235
236 DLFolderServiceUtil.deleteFolder(folder.getFolderId());
237 }
238 else {
239 DLFileEntry fileEntry = (DLFileEntry)model;
240
241 if (isLocked(fileEntry, webDavRequest.getLockUuid())) {
242 return WebDAVUtil.SC_LOCKED;
243 }
244
245 DLFileEntryServiceUtil.deleteFileEntry(
246 fileEntry.getFolderId(), fileEntry.getName());
247 }
248
249 return HttpServletResponse.SC_NO_CONTENT;
250 }
251 catch (PrincipalException pe) {
252 return HttpServletResponse.SC_FORBIDDEN;
253 }
254 catch (Exception e) {
255 throw new WebDAVException(e);
256 }
257 }
258
259 public Resource getResource(WebDAVRequest webDavRequest)
260 throws WebDAVException {
261
262 try {
263 String[] pathArray = webDavRequest.getPathArray();
264
265 long parentFolderId = getParentFolderId(pathArray);
266 String name = WebDAVUtil.getResourceName(pathArray);
267
268 if (Validator.isNull(name)) {
269 String path = getRootPath() + webDavRequest.getPath();
270
271 return new BaseResourceImpl(path, StringPool.BLANK, getToken());
272 }
273
274 try {
275 DLFolder folder = DLFolderServiceUtil.getFolder(
276 webDavRequest.getGroupId(), parentFolderId, name);
277
278 if ((folder.getParentFolderId() != parentFolderId) ||
279 (webDavRequest.getGroupId() != folder.getGroupId())) {
280
281 throw new NoSuchFolderException();
282 }
283
284 return toResource(webDavRequest, folder, false);
285 }
286 catch (NoSuchFolderException nsfe) {
287 try {
288 String titleWithExtension = name;
289
290 DLFileEntry fileEntry =
291 DLFileEntryServiceUtil.getFileEntryByTitle(
292 parentFolderId, titleWithExtension);
293
294 return toResource(webDavRequest, fileEntry, false);
295 }
296 catch (NoSuchFileEntryException nsfee) {
297 return null;
298 }
299 }
300 }
301 catch (Exception e) {
302 throw new WebDAVException(e);
303 }
304 }
305
306 public List<Resource> getResources(WebDAVRequest webDavRequest)
307 throws WebDAVException {
308
309 try {
310 long folderId = getFolderId(webDavRequest.getPathArray());
311
312 List<Resource> folders = getFolders(webDavRequest, folderId);
313 List<Resource> fileEntries = getFileEntries(
314 webDavRequest, folderId);
315
316 List<Resource> resources = new ArrayList<Resource>(
317 folders.size() + fileEntries.size());
318
319 resources.addAll(folders);
320 resources.addAll(fileEntries);
321
322 return resources;
323 }
324 catch (Exception e) {
325 throw new WebDAVException(e);
326 }
327 }
328
329 public boolean isSupportsClassTwo() {
330 return true;
331 }
332
333 public Status lockResource(
334 WebDAVRequest webDavRequest, String owner, long timeout)
335 throws WebDAVException {
336
337 Resource resource = getResource(webDavRequest);
338
339 Lock lock = null;
340 int status = HttpServletResponse.SC_OK;
341
342 try {
343 if (resource == null) {
344 status = HttpServletResponse.SC_CREATED;
345
346 String[] pathArray = webDavRequest.getPathArray();
347
348 long parentFolderId = getParentFolderId(pathArray);
349 String name = WebDAVUtil.getResourceName(pathArray);
350
351 String title = name;
352 String description = StringPool.BLANK;
353 String[] tagsEntries = null;
354 String extraSettings = StringPool.BLANK;
355 boolean addCommunityPermissions = true;
356 boolean addGuestPermissions = true;
357
358 File file = FileUtil.createTempFile(
359 FileUtil.getExtension(name));
360
361 file.createNewFile();
362
363 DLFileEntry fileEntry = DLFileEntryServiceUtil.addFileEntry(
364 parentFolderId, name, title, description, tagsEntries,
365 extraSettings, file, addCommunityPermissions,
366 addGuestPermissions);
367
368 resource = toResource(webDavRequest, fileEntry, false);
369 }
370
371 if (resource instanceof DLFileEntryResourceImpl) {
372 DLFileEntry fileEntry = (DLFileEntry)resource.getModel();
373
374 lock = DLFileEntryServiceUtil.lockFileEntry(
375 fileEntry.getFolderId(), fileEntry.getName(), owner,
376 timeout);
377 }
378 }
379 catch (Exception e) {
380
381
383 if (!(e instanceof DuplicateLockException)) {
384 throw new WebDAVException(e);
385 }
386
387 status = WebDAVUtil.SC_LOCKED;
388 }
389
390 return new Status(lock, status);
391 }
392
393 public Status makeCollection(WebDAVRequest webDavRequest)
394 throws WebDAVException {
395
396 try {
397 HttpServletRequest request = webDavRequest.getHttpServletRequest();
398
399 if (request.getContentLength() > 0) {
400 return new Status(
401 HttpServletResponse.SC_UNSUPPORTED_MEDIA_TYPE);
402 }
403
404 String[] pathArray = webDavRequest.getPathArray();
405
406 long plid = getPlid(webDavRequest.getGroupId());
407 long parentFolderId = getParentFolderId(pathArray);
408 String name = WebDAVUtil.getResourceName(pathArray);
409 String description = StringPool.BLANK;
410 boolean addCommunityPermissions = true;
411 boolean addGuestPermissions = true;
412
413 DLFolderServiceUtil.addFolder(
414 plid, parentFolderId, name, description,
415 addCommunityPermissions, addGuestPermissions);
416
417 String location = StringUtil.merge(pathArray, StringPool.SLASH);
418
419 return new Status(location, HttpServletResponse.SC_CREATED);
420 }
421 catch (DuplicateFolderNameException dfne) {
422 return new Status(HttpServletResponse.SC_METHOD_NOT_ALLOWED);
423 }
424 catch (NoSuchFolderException nsfe) {
425 return new Status(HttpServletResponse.SC_CONFLICT);
426 }
427 catch (PrincipalException pe) {
428 return new Status(HttpServletResponse.SC_FORBIDDEN);
429 }
430 catch (Exception e) {
431 throw new WebDAVException(e);
432 }
433 }
434
435 public int moveCollectionResource(
436 WebDAVRequest webDavRequest, Resource resource, String destination,
437 boolean overwrite)
438 throws WebDAVException {
439
440 try {
441 String[] destinationArray = WebDAVUtil.getPathArray(
442 destination, true);
443
444 DLFolder folder = (DLFolder)resource.getModel();
445
446 long groupId = WebDAVUtil.getGroupId(destinationArray);
447 long folderId = folder.getFolderId();
448 long parentFolderId = getParentFolderId(destinationArray);
449 String name = WebDAVUtil.getResourceName(destinationArray);
450 String description = folder.getDescription();
451
452 int status = HttpServletResponse.SC_CREATED;
453
454 if (overwrite) {
455 if (deleteResource(
456 groupId, parentFolderId, name,
457 webDavRequest.getLockUuid())) {
458
459 status = HttpServletResponse.SC_NO_CONTENT;
460 }
461 }
462
463 DLFolderServiceUtil.updateFolder(
464 folderId, parentFolderId, name, description);
465
466 return status;
467 }
468 catch (PrincipalException pe) {
469 return HttpServletResponse.SC_FORBIDDEN;
470 }
471 catch (DuplicateFolderNameException dfne) {
472 return HttpServletResponse.SC_PRECONDITION_FAILED;
473 }
474 catch (Exception e) {
475 throw new WebDAVException(e);
476 }
477 }
478
479 public int moveSimpleResource(
480 WebDAVRequest webDavRequest, Resource resource, String destination,
481 boolean overwrite)
482 throws WebDAVException {
483
484 try {
485 String[] destinationArray = WebDAVUtil.getPathArray(
486 destination, true);
487
488 DLFileEntry fileEntry = (DLFileEntry)resource.getModel();
489
490 if (isLocked(fileEntry, webDavRequest.getLockUuid())) {
491 return WebDAVUtil.SC_LOCKED;
492 }
493
494 long groupId = WebDAVUtil.getGroupId(destinationArray);
495 long parentFolderId = getParentFolderId(destinationArray);
496 String name = fileEntry.getName();
497 String sourceFileName = null;
498 String title = WebDAVUtil.getResourceName(destinationArray);
499 String description = fileEntry.getDescription();
500 String[] tagsEntries = null;
501 String extraSettings = fileEntry.getExtraSettings();
502 byte[] bytes = null;
503
504 int status = HttpServletResponse.SC_CREATED;
505
506 if (overwrite) {
507 if (deleteResource(
508 groupId, parentFolderId, title,
509 webDavRequest.getLockUuid())) {
510
511 status = HttpServletResponse.SC_NO_CONTENT;
512 }
513 }
514
515 DLFileEntryServiceUtil.updateFileEntry(
516 fileEntry.getFolderId(), parentFolderId, name, sourceFileName,
517 title, description, tagsEntries, extraSettings, bytes);
518
519 return status;
520 }
521 catch (PrincipalException pe) {
522 return HttpServletResponse.SC_FORBIDDEN;
523 }
524 catch (DuplicateFileException dfe) {
525 return HttpServletResponse.SC_PRECONDITION_FAILED;
526 }
527 catch (DuplicateFolderNameException dfne) {
528 return HttpServletResponse.SC_PRECONDITION_FAILED;
529 }
530 catch (LockException le) {
531 return WebDAVUtil.SC_LOCKED;
532 }
533 catch (Exception e) {
534 throw new WebDAVException(e);
535 }
536 }
537
538 public int putResource(WebDAVRequest webDavRequest) throws WebDAVException {
539 File file = null;
540
541 try {
542 HttpServletRequest request = webDavRequest.getHttpServletRequest();
543
544 String[] pathArray = webDavRequest.getPathArray();
545
546 long parentFolderId = getParentFolderId(pathArray);
547 String name = WebDAVUtil.getResourceName(pathArray);
548 String title = name;
549 String description = StringPool.BLANK;
550 String[] tagsEntries = null;
551 String extraSettings = StringPool.BLANK;
552 boolean addCommunityPermissions = true;
553 boolean addGuestPermissions = true;
554
555 try {
556 DLFileEntry entry = DLFileEntryServiceUtil.getFileEntryByTitle(
557 parentFolderId, name);
558
559 if (isLocked(entry, webDavRequest.getLockUuid())) {
560 return WebDAVUtil.SC_LOCKED;
561 }
562
563 name = entry.getName();
564 description = entry.getDescription();
565 tagsEntries = TagsEntryLocalServiceUtil.getEntryNames(
566 DLFileEntry.class.getName(), entry.getFileEntryId());
567 extraSettings = entry.getExtraSettings();
568
569 DLFileEntryServiceUtil.updateFileEntry(
570 parentFolderId, parentFolderId, name, title, title,
571 description, tagsEntries, extraSettings,
572 FileUtil.getBytes(request.getInputStream()));
573 }
574 catch (NoSuchFileEntryException nsfee) {
575 file = FileUtil.createTempFile(FileUtil.getExtension(name));
576
577 FileUtil.write(file, request.getInputStream());
578
579 DLFileEntryServiceUtil.addFileEntry(
580 parentFolderId, name, title, description, tagsEntries,
581 extraSettings, file, addCommunityPermissions,
582 addGuestPermissions);
583 }
584
585 return HttpServletResponse.SC_CREATED;
586 }
587 catch (PrincipalException pe) {
588 return HttpServletResponse.SC_FORBIDDEN;
589 }
590 catch (PortalException pe) {
591 if (_log.isWarnEnabled()) {
592 _log.warn(pe, pe);
593 }
594
595 return HttpServletResponse.SC_CONFLICT;
596 }
597 catch (Exception e) {
598 throw new WebDAVException(e);
599 }
600 finally {
601 if (file != null) {
602 file.delete();
603 }
604 }
605 }
606
607 public Lock refreshResourceLock(
608 WebDAVRequest webDavRequest, String uuid, long timeout)
609 throws WebDAVException {
610
611 Resource resource = getResource(webDavRequest);
612
613 Lock lock = null;
614
615 if (resource instanceof DLFileEntryResourceImpl) {
616 try {
617 lock = DLFileEntryServiceUtil.refreshFileEntryLock(
618 uuid, timeout);
619 }
620 catch (Exception e) {
621 throw new WebDAVException(e);
622 }
623 }
624
625 return lock;
626 }
627
628 public boolean unlockResource(WebDAVRequest webDavRequest, String token)
629 throws WebDAVException {
630
631 Resource resource = getResource(webDavRequest);
632
633 try {
634 if (resource instanceof DLFileEntryResourceImpl) {
635 DLFileEntry fileEntry = (DLFileEntry)resource.getModel();
636
637 DLFileEntryServiceUtil.unlockFileEntry(
638 fileEntry.getFolderId(), fileEntry.getName(), token);
639
640 return true;
641 }
642 }
643 catch (Exception e) {
644 if (e instanceof InvalidLockException) {
645 if (_log.isWarnEnabled()) {
646 _log.warn(e.getMessage());
647 }
648 }
649 else {
650 if (_log.isWarnEnabled()) {
651 _log.warn("Unable to unlock file entry", e);
652 }
653 }
654 }
655
656 return false;
657 }
658
659 protected boolean deleteResource(
660 long groupId, long parentFolderId, String name, String lockUuid)
661 throws Exception {
662
663 try {
664 DLFolder folder = DLFolderServiceUtil.getFolder(
665 groupId, parentFolderId, name);
666
667 DLFolderServiceUtil.deleteFolder(folder.getFolderId());
668
669 return true;
670 }
671 catch (NoSuchFolderException nsfe) {
672 try {
673 DLFileEntry fileEntry =
674 DLFileEntryServiceUtil.getFileEntryByTitle(
675 parentFolderId, name);
676
677 if (isLocked(fileEntry, lockUuid)) {
678 throw new LockException();
679 }
680
681 DLFileEntryServiceUtil.deleteFileEntryByTitle(
682 parentFolderId, name);
683
684 return true;
685 }
686 catch (NoSuchFileEntryException nsfee) {
687 }
688 }
689
690 return false;
691 }
692
693 protected List<Resource> getFileEntries(
694 WebDAVRequest webDavRequest, long parentFolderId)
695 throws Exception {
696
697 List<Resource> resources = new ArrayList<Resource>();
698
699 List<DLFileEntry> fileEntries = DLFileEntryServiceUtil.getFileEntries(
700 parentFolderId);
701
702 for (DLFileEntry fileEntry : fileEntries) {
703 Resource resource = toResource(webDavRequest, fileEntry, true);
704
705 resources.add(resource);
706 }
707
708 return resources;
709 }
710
711 protected long getFolderId(String[] pathArray) throws Exception {
712 return getFolderId(pathArray, false);
713 }
714
715 protected long getFolderId(String[] pathArray, boolean parent)
716 throws Exception {
717
718 long folderId = DLFolderImpl.DEFAULT_PARENT_FOLDER_ID;
719
720 if (pathArray.length <= 2) {
721 return folderId;
722 }
723 else {
724 long groupId = WebDAVUtil.getGroupId(pathArray);
725
726 int x = pathArray.length;
727
728 if (parent) {
729 x--;
730 }
731
732 for (int i = 3; i < x; i++) {
733 String name = pathArray[i];
734
735 DLFolder folder = DLFolderServiceUtil.getFolder(
736 groupId, folderId, name);
737
738 if (groupId == folder.getGroupId()) {
739 folderId = folder.getFolderId();
740 }
741 }
742 }
743
744 return folderId;
745 }
746
747 protected List<Resource> getFolders(
748 WebDAVRequest webDavRequest, long parentFolderId)
749 throws Exception {
750
751 List<Resource> resources = new ArrayList<Resource>();
752
753 long groupId = webDavRequest.getGroupId();
754
755 List<DLFolder> folders = DLFolderServiceUtil.getFolders(
756 groupId, parentFolderId);
757
758 for (DLFolder folder : folders) {
759 Resource resource = toResource(webDavRequest, folder, true);
760
761 resources.add(resource);
762 }
763
764 return resources;
765 }
766
767 protected long getParentFolderId(String[] pathArray) throws Exception {
768 return getFolderId(pathArray, true);
769 }
770
771 protected boolean isLocked(DLFileEntry fileEntry, String lockUuid)
772 throws Exception {
773
774 long parentFolderId = fileEntry.getFolderId();
775 String fileName = fileEntry.getName();
776
777 return isLocked(parentFolderId, fileName, lockUuid);
778 }
779
780 protected boolean isLocked(
781 long parentFolderId, String fileName, String lockUuid)
782 throws Exception {
783
784 boolean locked = false;
785
786 try {
787 Lock lock = DLFileEntryServiceUtil.getFileEntryLock(
788 parentFolderId, fileName);
789
790 if (!lock.getUuid().equals(lockUuid)) {
791 locked = true;
792 }
793 }
794 catch (PortalException pe) {
795 if (pe instanceof ExpiredLockException ||
796 pe instanceof NoSuchLockException) {
797 }
798 else {
799 throw pe;
800 }
801 }
802
803 return locked;
804 }
805
806 protected Resource toResource(
807 WebDAVRequest webDavRequest, DLFileEntry fileEntry,
808 boolean appendPath) {
809
810 String parentPath = getRootPath() + webDavRequest.getPath();
811 String name = StringPool.BLANK;
812
813 if (appendPath) {
814 name = fileEntry.getTitleWithExtension();
815 }
816
817 return new DLFileEntryResourceImpl(
818 webDavRequest, fileEntry, parentPath, name);
819 }
820
821 protected Resource toResource(
822 WebDAVRequest webDavRequest, DLFolder folder, boolean appendPath) {
823
824 String parentPath = getRootPath() + webDavRequest.getPath();
825 String name = StringPool.BLANK;
826
827 if (appendPath) {
828 name = folder.getName();
829 }
830
831 Resource resource = new BaseResourceImpl(
832 parentPath, name, folder.getName(), folder.getCreateDate(),
833 folder.getModifiedDate());
834
835 resource.setModel(folder);
836 resource.setClassName(DLFolder.class.getName());
837 resource.setPrimaryKey(folder.getPrimaryKey());
838
839 return resource;
840 }
841
842 private static Log _log = LogFactory.getLog(DLWebDAVStorageImpl.class);
843
844 }