001: /**
002: * Copyright (c) 2000-2008 Liferay, Inc. All rights reserved.
003: *
004: * Permission is hereby granted, free of charge, to any person obtaining a copy
005: * of this software and associated documentation files (the "Software"), to deal
006: * in the Software without restriction, including without limitation the rights
007: * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
008: * copies of the Software, and to permit persons to whom the Software is
009: * furnished to do so, subject to the following conditions:
010: *
011: * The above copyright notice and this permission notice shall be included in
012: * all copies or substantial portions of the Software.
013: *
014: * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
015: * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
016: * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
017: * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
018: * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
019: * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
020: * SOFTWARE.
021: */package com.liferay.portlet.documentlibrary.webdav;
022:
023: import com.liferay.documentlibrary.DuplicateFileException;
024: import com.liferay.portal.PortalException;
025: import com.liferay.portal.SystemException;
026: import com.liferay.portal.kernel.security.permission.ActionKeys;
027: import com.liferay.portal.kernel.util.StringPool;
028: import com.liferay.portal.kernel.util.StringUtil;
029: import com.liferay.portal.security.auth.PrincipalException;
030: import com.liferay.portal.service.LayoutLocalServiceUtil;
031: import com.liferay.portal.webdav.BaseResourceImpl;
032: import com.liferay.portal.webdav.BaseWebDAVStorageImpl;
033: import com.liferay.portal.webdav.Resource;
034: import com.liferay.portal.webdav.Status;
035: import com.liferay.portal.webdav.WebDAVException;
036: import com.liferay.portal.webdav.WebDAVRequest;
037: import com.liferay.portal.webdav.WebDAVUtil;
038: import com.liferay.portlet.documentlibrary.DuplicateFolderNameException;
039: import com.liferay.portlet.documentlibrary.NoSuchFileEntryException;
040: import com.liferay.portlet.documentlibrary.NoSuchFolderException;
041: import com.liferay.portlet.documentlibrary.model.DLFileEntry;
042: import com.liferay.portlet.documentlibrary.model.DLFolder;
043: import com.liferay.portlet.documentlibrary.model.impl.DLFolderImpl;
044: import com.liferay.portlet.documentlibrary.service.DLFileEntryLocalServiceUtil;
045: import com.liferay.portlet.documentlibrary.service.DLFileEntryServiceUtil;
046: import com.liferay.portlet.documentlibrary.service.DLFolderLocalServiceUtil;
047: import com.liferay.portlet.documentlibrary.service.DLFolderServiceUtil;
048: import com.liferay.portlet.documentlibrary.service.permission.DLFileEntryPermission;
049: import com.liferay.portlet.documentlibrary.service.permission.DLFolderPermission;
050: import com.liferay.util.FileUtil;
051: import com.liferay.util.PwdGenerator;
052: import com.liferay.util.SystemProperties;
053: import com.liferay.util.Time;
054:
055: import java.io.File;
056: import java.io.InputStream;
057:
058: import java.util.ArrayList;
059: import java.util.Iterator;
060: import java.util.List;
061:
062: import javax.servlet.http.HttpServletRequest;
063: import javax.servlet.http.HttpServletResponse;
064:
065: import org.apache.commons.logging.Log;
066: import org.apache.commons.logging.LogFactory;
067:
068: /**
069: * <a href="DLWebDAVStorageImpl.java.html"><b><i>View Source</i></b></a>
070: *
071: * @author Brian Wing Shun Chan
072: * @author Alexander Chow
073: *
074: */
075: public class DLWebDAVStorageImpl extends BaseWebDAVStorageImpl {
076:
077: public Status addCollection(WebDAVRequest webDavReq)
078: throws WebDAVException {
079:
080: try {
081: HttpServletRequest req = webDavReq.getHttpServletRequest();
082:
083: if (req.getContentLength() > 0) {
084: return new Status(
085: HttpServletResponse.SC_UNSUPPORTED_MEDIA_TYPE);
086: }
087:
088: String[] pathArray = webDavReq.getPathArray();
089: long parentFolderId = getParentFolderId(pathArray);
090: String name = WebDAVUtil.getEntryName(pathArray);
091:
092: try {
093: DLFileEntryLocalServiceUtil.getFileEntryByTitle(
094: parentFolderId, name);
095:
096: return new Status(HttpServletResponse.SC_CONFLICT);
097: } catch (Exception e) {
098: }
099:
100: long plid = getPlid(webDavReq.getGroupId());
101: String description = StringPool.BLANK;
102: boolean addCommunityPermissions = true;
103: boolean addGuestPermissions = true;
104:
105: DLFolderServiceUtil.addFolder(plid, parentFolderId, name,
106: description, addCommunityPermissions,
107: addGuestPermissions);
108:
109: String location = StringUtil.merge(pathArray,
110: StringPool.SLASH);
111:
112: return new Status(location, HttpServletResponse.SC_CREATED);
113: } catch (DuplicateFolderNameException dfne) {
114: return new Status(HttpServletResponse.SC_METHOD_NOT_ALLOWED);
115: } catch (NoSuchFolderException nsfe) {
116: return new Status(HttpServletResponse.SC_CONFLICT);
117: } catch (PrincipalException pe) {
118: return new Status(HttpServletResponse.SC_FORBIDDEN);
119: } catch (Exception e) {
120: throw new WebDAVException(e);
121: }
122: }
123:
124: public int copyCollectionResource(WebDAVRequest webDavReq,
125: Resource resource, String destination, boolean overwrite,
126: long depth) throws WebDAVException {
127:
128: try {
129: String[] destinationArray = WebDAVUtil.getPathArray(
130: destination, true);
131:
132: long parentFolderId = DLFolderImpl.DEFAULT_PARENT_FOLDER_ID;
133:
134: try {
135: parentFolderId = getParentFolderId(destinationArray);
136: } catch (NoSuchFolderException nsfe) {
137: return HttpServletResponse.SC_CONFLICT;
138: }
139:
140: DLFolder folder = (DLFolder) resource.getModel();
141:
142: long groupId = WebDAVUtil.getGroupId(destination);
143: long plid = getPlid(groupId);
144: String name = WebDAVUtil.getEntryName(destinationArray);
145: String description = folder.getDescription();
146: boolean addCommunityPermissions = true;
147: boolean addGuestPermissions = true;
148:
149: int status = HttpServletResponse.SC_CREATED;
150:
151: if (overwrite) {
152: try {
153: DLFolder destFolder = DLFolderServiceUtil
154: .getFolder(groupId, parentFolderId, name);
155:
156: DLFolderServiceUtil.deleteFolder(destFolder
157: .getFolderId());
158:
159: status = HttpServletResponse.SC_NO_CONTENT;
160: } catch (NoSuchFolderException nsfe) {
161: try {
162: DLFileEntryServiceUtil.deleteFileEntryByTitle(
163: parentFolderId, name);
164:
165: status = HttpServletResponse.SC_NO_CONTENT;
166: } catch (NoSuchFileEntryException nsfee) {
167: }
168: }
169: }
170:
171: if (depth == 0) {
172: DLFolderServiceUtil.addFolder(plid, parentFolderId,
173: name, description, addCommunityPermissions,
174: addGuestPermissions);
175: } else {
176: DLFolderServiceUtil.copyFolder(plid, folder
177: .getFolderId(), parentFolderId, name,
178: description, addCommunityPermissions,
179: addGuestPermissions);
180: }
181:
182: return status;
183: } catch (DuplicateFolderNameException dfne) {
184: return HttpServletResponse.SC_PRECONDITION_FAILED;
185: } catch (PrincipalException pe) {
186: return HttpServletResponse.SC_FORBIDDEN;
187: } catch (Exception e) {
188: throw new WebDAVException(e);
189: }
190: }
191:
192: public int copySimpleResource(WebDAVRequest webDavReq,
193: Resource resource, String destination, boolean overwrite)
194: throws WebDAVException {
195:
196: File file = null;
197:
198: try {
199: String[] destinationArray = WebDAVUtil.getPathArray(
200: destination, true);
201:
202: long parentFolderId;
203:
204: try {
205: parentFolderId = getParentFolderId(destinationArray);
206: } catch (NoSuchFolderException nsfe) {
207: return HttpServletResponse.SC_CONFLICT;
208: }
209:
210: DLFileEntry fileEntry = (DLFileEntry) resource.getModel();
211:
212: DLFileEntryPermission
213: .check(webDavReq.getPermissionChecker(), fileEntry,
214: ActionKeys.VIEW);
215:
216: long userId = webDavReq.getUserId();
217: String name = StringPool.BLANK;
218: String sourceName = fileEntry.getName();
219: String title = WebDAVUtil.getEntryName(destinationArray);
220: String description = fileEntry.getDescription();
221: String[] tagsEntries = new String[0];
222: String extraSettings = fileEntry.getExtraSettings();
223: boolean addCommunityPermissions = true;
224: boolean addGuestPermissions = true;
225:
226: String fileName = SystemProperties
227: .get(SystemProperties.TMP_DIR)
228: + StringPool.SLASH
229: + Time.getTimestamp()
230: + PwdGenerator.getPassword(PwdGenerator.KEY2, 8);
231:
232: file = new File(fileName);
233:
234: InputStream is = DLFileEntryLocalServiceUtil
235: .getFileAsStream(fileEntry.getCompanyId(), userId,
236: fileEntry.getFolderId(), fileEntry
237: .getName());
238:
239: FileUtil.write(file, is);
240:
241: if (_log.isDebugEnabled()) {
242: _log.debug("Writing request to file " + fileName);
243: }
244:
245: DLFolderPermission.check(webDavReq.getPermissionChecker(),
246: parentFolderId, ActionKeys.ADD_DOCUMENT);
247:
248: int status = HttpServletResponse.SC_CREATED;
249:
250: if (overwrite) {
251: try {
252: long groupId = webDavReq.getGroupId();
253:
254: DLFolderServiceUtil.deleteFolder(groupId,
255: parentFolderId, title);
256:
257: DLFileEntryLocalServiceUtil.addFileEntry(userId,
258: parentFolderId, name, title, description,
259: tagsEntries, extraSettings, file,
260: addCommunityPermissions,
261: addGuestPermissions);
262:
263: status = HttpServletResponse.SC_NO_CONTENT;
264: } catch (NoSuchFolderException nsfe) {
265: DLFileEntry destFile = DLFileEntryLocalServiceUtil
266: .addOrOverwriteFileEntry(userId,
267: parentFolderId, name, sourceName,
268: title, description, tagsEntries,
269: extraSettings, file,
270: addCommunityPermissions,
271: addGuestPermissions);
272:
273: if (destFile.getVersion() > 1.0) {
274: status = HttpServletResponse.SC_NO_CONTENT;
275: } else {
276: status = HttpServletResponse.SC_CREATED;
277: }
278: }
279: } else {
280: DLFileEntryLocalServiceUtil.addFileEntry(userId,
281: parentFolderId, name, title, description,
282: tagsEntries, extraSettings, file,
283: addCommunityPermissions, addGuestPermissions);
284:
285: status = HttpServletResponse.SC_CREATED;
286: }
287:
288: return status;
289: } catch (DuplicateFolderNameException dfne) {
290: return HttpServletResponse.SC_PRECONDITION_FAILED;
291: } catch (DuplicateFileException dfe) {
292: return HttpServletResponse.SC_PRECONDITION_FAILED;
293: } catch (PrincipalException pe) {
294: return HttpServletResponse.SC_FORBIDDEN;
295: } catch (Exception e) {
296: throw new WebDAVException(e);
297: } finally {
298: if (file != null) {
299: file.delete();
300: }
301: }
302: }
303:
304: public int deleteResource(WebDAVRequest webDavReq)
305: throws WebDAVException {
306: try {
307: Resource resource = getResource(webDavReq);
308:
309: if (resource == null) {
310: return HttpServletResponse.SC_NOT_FOUND;
311: }
312:
313: Object model = resource.getModel();
314:
315: if (model instanceof DLFolder) {
316: DLFolder folder = (DLFolder) model;
317:
318: DLFolderServiceUtil.deleteFolder(folder.getFolderId());
319: } else {
320: DLFileEntry fileEntry = (DLFileEntry) model;
321:
322: DLFileEntryServiceUtil.deleteFileEntry(fileEntry
323: .getFolderId(), fileEntry.getName());
324: }
325:
326: return HttpServletResponse.SC_NO_CONTENT;
327: } catch (PrincipalException pe) {
328: return HttpServletResponse.SC_FORBIDDEN;
329: } catch (Exception e) {
330: throw new WebDAVException(e);
331: }
332: }
333:
334: public Resource getResource(WebDAVRequest webDavReq)
335: throws WebDAVException {
336:
337: try {
338: String[] pathArray = webDavReq.getPathArray();
339:
340: long parentFolderId = getParentFolderId(pathArray);
341: String name = WebDAVUtil.getEntryName(pathArray);
342:
343: try {
344: DLFolder folder = DLFolderServiceUtil.getFolder(
345: webDavReq.getGroupId(), parentFolderId, name);
346:
347: if ((folder.getParentFolderId() != parentFolderId)
348: || (webDavReq.getGroupId() != folder
349: .getGroupId())) {
350:
351: throw new NoSuchFolderException();
352: }
353:
354: return toResource(webDavReq, folder, false);
355: } catch (NoSuchFolderException nsfe) {
356: try {
357: String titleWithExtension = name;
358:
359: DLFileEntry fileEntry = DLFileEntryLocalServiceUtil
360: .getFileEntryByTitle(parentFolderId,
361: titleWithExtension);
362:
363: DLFileEntryPermission.check(webDavReq
364: .getPermissionChecker(), fileEntry,
365: ActionKeys.VIEW);
366:
367: return toResource(webDavReq, fileEntry, false);
368: } catch (NoSuchFileEntryException nsfee) {
369: return null;
370: }
371: }
372: } catch (Exception e) {
373: throw new WebDAVException(e);
374: }
375: }
376:
377: public List getResources(WebDAVRequest webDavReq)
378: throws WebDAVException {
379:
380: try {
381: long folderId = getFolderId(webDavReq.getPathArray());
382:
383: List folders = getFolders(webDavReq, folderId);
384: List fileEntries = getFileEntries(webDavReq, folderId);
385:
386: List resources = new ArrayList(folders.size()
387: + fileEntries.size());
388:
389: resources.addAll(folders);
390: resources.addAll(fileEntries);
391:
392: return resources;
393: } catch (Exception e) {
394: throw new WebDAVException(e);
395: }
396: }
397:
398: public int moveCollectionResource(WebDAVRequest webDavReq,
399: Resource resource, String destination, boolean overwrite)
400: throws WebDAVException {
401:
402: try {
403: String[] destinationArray = WebDAVUtil.getPathArray(
404: destination, true);
405:
406: DLFolder folder = (DLFolder) resource.getModel();
407:
408: long groupId = webDavReq.getGroupId();
409: long folderId = folder.getFolderId();
410: long parentFolderId = getParentFolderId(destinationArray);
411: String name = WebDAVUtil.getEntryName(destinationArray);
412: String description = folder.getDescription();
413:
414: if (parentFolderId != folder.getParentFolderId()) {
415: name = folder.getName();
416: }
417:
418: int status = HttpServletResponse.SC_CREATED;
419:
420: if (overwrite) {
421: try {
422: DLFolder destFolder = DLFolderServiceUtil
423: .getFolder(groupId, parentFolderId, name);
424:
425: DLFolderServiceUtil.deleteFolder(destFolder
426: .getFolderId());
427:
428: status = HttpServletResponse.SC_NO_CONTENT;
429: } catch (NoSuchFolderException nsfe) {
430: try {
431: DLFileEntryServiceUtil.deleteFileEntryByTitle(
432: parentFolderId, name);
433:
434: status = HttpServletResponse.SC_NO_CONTENT;
435: } catch (NoSuchFileEntryException nsfee) {
436: }
437: }
438: }
439:
440: DLFolderServiceUtil.updateFolder(folderId, parentFolderId,
441: name, description);
442:
443: return status;
444: } catch (PrincipalException pe) {
445: return HttpServletResponse.SC_FORBIDDEN;
446: } catch (DuplicateFileException dfe) {
447: return HttpServletResponse.SC_PRECONDITION_FAILED;
448: } catch (DuplicateFolderNameException dfne) {
449: return HttpServletResponse.SC_PRECONDITION_FAILED;
450: } catch (Exception e) {
451: throw new WebDAVException(e);
452: }
453: }
454:
455: public int moveSimpleResource(WebDAVRequest webDavReq,
456: Resource resource, String destination, boolean overwrite)
457: throws WebDAVException {
458:
459: try {
460: String[] destinationArray = WebDAVUtil.getPathArray(
461: destination, true);
462:
463: DLFileEntry fileEntry = (DLFileEntry) resource.getModel();
464:
465: long folderId = fileEntry.getFolderId();
466: long newFolderId = getParentFolderId(destinationArray);
467: String name = fileEntry.getName();
468: String sourceFileName = null;
469: String title = WebDAVUtil.getEntryName(destinationArray);
470: String description = fileEntry.getDescription();
471: String[] tagsEntries = new String[0];
472: String extraSettings = fileEntry.getExtraSettings();
473: byte[] byteArray = null;
474:
475: if (newFolderId != folderId) {
476: title = fileEntry.getTitle();
477: }
478:
479: int status = HttpServletResponse.SC_CREATED;
480:
481: if (overwrite) {
482: try {
483: DLFileEntry destFile = DLFileEntryServiceUtil
484: .getFileEntryByTitle(folderId, title);
485:
486: DLFileEntryServiceUtil.deleteFileEntry(destFile
487: .getFolderId(), destFile.getName());
488:
489: status = HttpServletResponse.SC_NO_CONTENT;
490: } catch (NoSuchFileEntryException nsfee) {
491: try {
492: long groupId = webDavReq.getGroupId();
493:
494: DLFolderServiceUtil.deleteFolder(groupId,
495: folderId, title);
496:
497: status = HttpServletResponse.SC_NO_CONTENT;
498: } catch (NoSuchFolderException nsfe) {
499: }
500: }
501: }
502:
503: DLFileEntryServiceUtil.updateFileEntry(folderId,
504: newFolderId, name, sourceFileName, title,
505: description, tagsEntries, extraSettings, byteArray);
506:
507: return status;
508: } catch (PrincipalException pe) {
509: return HttpServletResponse.SC_FORBIDDEN;
510: } catch (DuplicateFileException dfe) {
511: return HttpServletResponse.SC_PRECONDITION_FAILED;
512: } catch (DuplicateFolderNameException dfne) {
513: return HttpServletResponse.SC_PRECONDITION_FAILED;
514: } catch (Exception e) {
515: throw new WebDAVException(e);
516: }
517: }
518:
519: public int putResource(WebDAVRequest webDavReq)
520: throws WebDAVException {
521: File file = null;
522:
523: try {
524: HttpServletRequest req = webDavReq.getHttpServletRequest();
525: String[] pathArray = webDavReq.getPathArray();
526: long userId = webDavReq.getUserId();
527:
528: long parentFolderId = getParentFolderId(pathArray);
529: String name = WebDAVUtil.getEntryName(pathArray);
530: String title = WebDAVUtil.getEntryName(pathArray);
531: String description = StringPool.BLANK;
532: String[] tagsEntries = new String[0];
533: String extraSettings = StringPool.BLANK;
534: boolean addCommunityPermissions = true;
535: boolean addGuestPermissions = true;
536:
537: String fileName = SystemProperties
538: .get(SystemProperties.TMP_DIR)
539: + StringPool.SLASH
540: + Time.getTimestamp()
541: + PwdGenerator.getPassword(PwdGenerator.KEY2, 8);
542:
543: file = new File(fileName);
544:
545: FileUtil.write(file, req.getInputStream());
546:
547: if (_log.isDebugEnabled()) {
548: _log.debug("Writing request to file " + fileName);
549: }
550:
551: DLFolderPermission.check(webDavReq.getPermissionChecker(),
552: parentFolderId, ActionKeys.ADD_DOCUMENT);
553:
554: DLFileEntryLocalServiceUtil.addFileEntry(userId,
555: parentFolderId, name, title, description,
556: tagsEntries, extraSettings, file,
557: addCommunityPermissions, addGuestPermissions);
558:
559: return HttpServletResponse.SC_CREATED;
560: } catch (PrincipalException pe) {
561: return HttpServletResponse.SC_FORBIDDEN;
562: } catch (PortalException pe) {
563: if (_log.isWarnEnabled()) {
564: _log.warn(pe, pe);
565: }
566:
567: return HttpServletResponse.SC_CONFLICT;
568: } catch (Exception e) {
569: throw new WebDAVException(e);
570: } finally {
571: if (file != null) {
572: file.delete();
573: }
574: }
575: }
576:
577: protected List getFileEntries(WebDAVRequest webDavReq,
578: long parentFolderId) throws Exception {
579:
580: List fileEntries = new ArrayList();
581:
582: long plid = getPlid(webDavReq.getGroupId());
583:
584: DLFolderPermission.check(webDavReq.getPermissionChecker(),
585: plid, parentFolderId, ActionKeys.VIEW);
586:
587: Iterator itr = DLFileEntryLocalServiceUtil.getFileEntries(
588: parentFolderId).iterator();
589:
590: while (itr.hasNext()) {
591: DLFileEntry fileEntry = (DLFileEntry) itr.next();
592:
593: if (DLFileEntryPermission
594: .contains(webDavReq.getPermissionChecker(),
595: fileEntry, ActionKeys.VIEW)) {
596:
597: Resource resource = toResource(webDavReq, fileEntry,
598: true);
599:
600: fileEntries.add(resource);
601: }
602: }
603:
604: return fileEntries;
605: }
606:
607: protected long getFolderId(String[] pathArray) throws Exception {
608: return getFolderId(pathArray, false);
609: }
610:
611: protected long getFolderId(String[] pathArray, boolean parent)
612: throws Exception {
613:
614: long folderId = DLFolderImpl.DEFAULT_PARENT_FOLDER_ID;
615:
616: if (pathArray.length <= 2) {
617: return folderId;
618: } else {
619: long groupId = WebDAVUtil.getGroupId(pathArray);
620:
621: int x = pathArray.length;
622:
623: if (parent) {
624: x--;
625: }
626:
627: for (int i = 2; i < x; i++) {
628: String name = pathArray[i];
629:
630: DLFolder folder = DLFolderServiceUtil.getFolder(
631: groupId, folderId, name);
632:
633: if (groupId == folder.getGroupId()) {
634: folderId = folder.getFolderId();
635: }
636: }
637: }
638:
639: return folderId;
640: }
641:
642: protected List getFolders(WebDAVRequest webDavReq,
643: long parentFolderId) throws Exception {
644:
645: List folders = new ArrayList();
646:
647: long plid = getPlid(webDavReq.getGroupId());
648: long groupId = webDavReq.getGroupId();
649:
650: DLFolderPermission.check(webDavReq.getPermissionChecker(),
651: plid, parentFolderId, ActionKeys.VIEW);
652:
653: Iterator itr = DLFolderLocalServiceUtil.getFolders(groupId,
654: parentFolderId).iterator();
655:
656: while (itr.hasNext()) {
657: DLFolder folder = (DLFolder) itr.next();
658:
659: if (DLFolderPermission.contains(webDavReq
660: .getPermissionChecker(), folder, ActionKeys.VIEW)) {
661:
662: Resource resource = toResource(webDavReq, folder, true);
663:
664: folders.add(resource);
665: }
666: }
667:
668: return folders;
669: }
670:
671: protected long getParentFolderId(String[] pathArray)
672: throws Exception {
673: return getFolderId(pathArray, true);
674: }
675:
676: protected long getPlid(long groupId) throws SystemException {
677: return LayoutLocalServiceUtil.getDefaultPlid(groupId);
678: }
679:
680: protected Resource toResource(WebDAVRequest webDavReq,
681: DLFileEntry fileEntry, boolean appendPath) {
682:
683: String parentPath = getRootPath() + webDavReq.getPath();
684: String name = StringPool.BLANK;
685:
686: if (appendPath) {
687: name = fileEntry.getTitleWithExtension();
688: }
689:
690: return new DLFileEntryResourceImpl(webDavReq, fileEntry,
691: parentPath, name);
692: }
693:
694: protected Resource toResource(WebDAVRequest webDavReq,
695: DLFolder folder, boolean appendPath) {
696:
697: String parentPath = getRootPath() + webDavReq.getPath();
698: String name = StringPool.BLANK;
699:
700: if (appendPath) {
701: name = folder.getName();
702: }
703:
704: Resource resource = new BaseResourceImpl(parentPath, name,
705: folder.getName(), folder.getCreateDate(), folder
706: .getModifiedDate());
707:
708: resource.setModel(folder);
709: resource.setClassName(DLFolder.class.getName());
710: resource.setPrimaryKey(folder.getPrimaryKey());
711:
712: return resource;
713: }
714:
715: private static Log _log = LogFactory
716: .getLog(DLWebDAVStorageImpl.class);
717:
718: }
|