001
014
015 package com.liferay.portal.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.log.Log;
020 import com.liferay.portal.kernel.log.LogFactoryUtil;
021 import com.liferay.portal.kernel.util.Validator;
022 import com.liferay.portal.model.RoleConstants;
023 import com.liferay.portal.model.Team;
024 import com.liferay.portal.service.TeamLocalServiceUtil;
025 import com.liferay.portal.util.PortalUtil;
026
027
031 public class RoleImpl extends RoleBaseImpl {
032
033 public RoleImpl() {
034 }
035
036 @Override
037 public String getDescriptiveName() throws PortalException, SystemException {
038 String name = getName();
039
040 if (isTeam()) {
041 Team team = TeamLocalServiceUtil.getTeam(getClassPK());
042
043 name = team.getName();
044 }
045
046 return name;
047 }
048
049 @Override
050 public String getTitle(String languageId) {
051 String value = super.getTitle(languageId);
052
053 if (Validator.isNull(value)) {
054 try {
055 value = getDescriptiveName();
056 }
057 catch (Exception e) {
058 _log.error(e, e);
059 }
060 }
061
062 return value;
063 }
064
065 @Override
066 public String getTitle(String languageId, boolean useDefault) {
067 String value = super.getTitle(languageId, useDefault);
068
069 if (Validator.isNull(value)) {
070 try {
071 value = getDescriptiveName();
072 }
073 catch (Exception e) {
074 _log.error(e, e);
075 }
076 }
077
078 return value;
079 }
080
081 @Override
082 public String getTypeLabel() {
083 return RoleConstants.getTypeLabel(getType());
084 }
085
086 @Override
087 public boolean isTeam() {
088 return hasClassName(Team.class);
089 }
090
091 protected boolean hasClassName(Class<?> clazz) {
092 long classNameId = getClassNameId();
093
094 if (classNameId == PortalUtil.getClassNameId(clazz)) {
095 return true;
096 }
097 else {
098 return false;
099 }
100 }
101
102 private static Log _log = LogFactoryUtil.getLog(RoleImpl.class);
103
104 }