001
014
015 package com.liferay.portlet.journal.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.journal.model.JournalFolder;
023 import com.liferay.portlet.journal.service.JournalFolderLocalServiceUtil;
024
025 import java.util.ArrayList;
026 import java.util.List;
027
028
040 public abstract class JournalFolderBaseImpl extends JournalFolderModelImpl
041 implements JournalFolder {
042
047 @Override
048 public void persist() throws SystemException {
049 if (this.isNew()) {
050 JournalFolderLocalServiceUtil.addJournalFolder(this);
051 }
052 else {
053 JournalFolderLocalServiceUtil.updateJournalFolder(this);
054 }
055 }
056
057 @Override
058 @SuppressWarnings("unused")
059 public String buildTreePath() throws PortalException, SystemException {
060 List<JournalFolder> journalFolders = new ArrayList<JournalFolder>();
061
062 JournalFolder journalFolder = this;
063
064 while (journalFolder != null) {
065 journalFolders.add(journalFolder);
066
067 journalFolder = JournalFolderLocalServiceUtil.fetchJournalFolder(journalFolder.getParentFolderId());
068 }
069
070 StringBundler sb = new StringBundler((journalFolders.size() * 2) + 1);
071
072 sb.append(StringPool.SLASH);
073
074 for (int i = journalFolders.size() - 1; i >= 0; i--) {
075 journalFolder = journalFolders.get(i);
076
077 sb.append(journalFolder.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 JournalFolder journalFolder = this;
087
088 journalFolder.setTreePath(treePath);
089
090 JournalFolderLocalServiceUtil.updateJournalFolder(journalFolder);
091 }
092 }