001
014
015 package com.liferay.portlet.documentlibrary.model.impl;
016
017 import com.liferay.portal.kernel.exception.PortalException;
018 import com.liferay.portal.kernel.exception.SystemException;
019 import com.liferay.portal.kernel.util.StringBundler;
020 import com.liferay.portal.kernel.util.StringPool;
021
022 import com.liferay.portlet.documentlibrary.model.DLFolder;
023 import com.liferay.portlet.documentlibrary.service.DLFolderLocalServiceUtil;
024
025 import java.util.ArrayList;
026 import java.util.List;
027
028
040 public abstract class DLFolderBaseImpl extends DLFolderModelImpl
041 implements DLFolder {
042
047 @Override
048 public void persist() throws SystemException {
049 if (this.isNew()) {
050 DLFolderLocalServiceUtil.addDLFolder(this);
051 }
052 else {
053 DLFolderLocalServiceUtil.updateDLFolder(this);
054 }
055 }
056
057 @Override
058 @SuppressWarnings("unused")
059 public String buildTreePath() throws PortalException, SystemException {
060 List<DLFolder> dlFolders = new ArrayList<DLFolder>();
061
062 DLFolder dlFolder = this;
063
064 while (dlFolder != null) {
065 dlFolders.add(dlFolder);
066
067 dlFolder = DLFolderLocalServiceUtil.fetchDLFolder(dlFolder.getParentFolderId());
068 }
069
070 StringBundler sb = new StringBundler((dlFolders.size() * 2) + 1);
071
072 sb.append(StringPool.SLASH);
073
074 for (int i = dlFolders.size() - 1; i >= 0; i--) {
075 dlFolder = dlFolders.get(i);
076
077 sb.append(dlFolder.getFolderId());
078 sb.append(StringPool.SLASH);
079 }
080
081 return sb.toString();
082 }
083
084 @Override
085 public void updateTreePath(String treePath) throws SystemException {
086 DLFolder dlFolder = this;
087
088 dlFolder.setTreePath(treePath);
089
090 DLFolderLocalServiceUtil.updateDLFolder(dlFolder);
091 }
092 }