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