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