1
22
23 package com.liferay.portlet.documentlibrary.model.impl;
24
25 import com.liferay.portal.PortalException;
26 import com.liferay.portal.SystemException;
27 import com.liferay.portal.kernel.util.StringPool;
28 import com.liferay.portal.kernel.util.StringUtil;
29 import com.liferay.portlet.documentlibrary.model.DLFolder;
30 import com.liferay.portlet.documentlibrary.model.DLFolderConstants;
31 import com.liferay.portlet.documentlibrary.service.DLFolderLocalServiceUtil;
32
33
38 public class DLFolderImpl extends DLFolderModelImpl implements DLFolder {
39
40 public DLFolderImpl() {
41 }
42
43 public String getPath() throws PortalException, SystemException {
44 StringBuilder sb = new StringBuilder();
45
46 DLFolder folder = this;
47
48 while (true) {
49 sb.insert(0, folder.getName());
50 sb.insert(0, StringPool.SLASH);
51
52 if (folder.getParentFolderId() !=
53 DLFolderConstants.DEFAULT_PARENT_FOLDER_ID) {
54
55 folder = DLFolderLocalServiceUtil.getFolder(
56 folder.getParentFolderId());
57 }
58 else {
59 break;
60 }
61 }
62
63 return sb.toString();
64 }
65
66 public String[] getPathArray() throws PortalException, SystemException {
67 String path = getPath();
68
69
71 path = path.substring(1, path.length());
72
73 return StringUtil.split(path, StringPool.SLASH);
74 }
75
76 public boolean isRoot() {
77 if (getParentFolderId() == DLFolderConstants.DEFAULT_PARENT_FOLDER_ID) {
78 return true;
79 }
80 else {
81 return false;
82 }
83 }
84
85 }