1
14
15 package com.liferay.portal.model.impl;
16
17 import com.liferay.portal.kernel.exception.PortalException;
18 import com.liferay.portal.kernel.exception.SystemException;
19 import com.liferay.portal.kernel.log.Log;
20 import com.liferay.portal.kernel.log.LogFactoryUtil;
21 import com.liferay.portal.kernel.util.Validator;
22 import com.liferay.portal.model.Role;
23 import com.liferay.portal.model.RoleConstants;
24 import com.liferay.portal.model.Team;
25 import com.liferay.portal.service.TeamLocalServiceUtil;
26 import com.liferay.portal.util.PortalUtil;
27
28
34 public class RoleImpl extends RoleModelImpl implements Role {
35
36 public RoleImpl() {
37 }
38
39 public String getDescriptiveName() throws PortalException, SystemException {
40 String name = getName();
41
42 if (isTeam()) {
43 Team team = TeamLocalServiceUtil.getTeam(getClassPK());
44
45 name = team.getName();
46 }
47
48 return name;
49 }
50
51 public String getTitle(String languageId) {
52 String value = super.getTitle(languageId);
53
54 if (Validator.isNull(value)) {
55 try {
56 value = getDescriptiveName();
57 }
58 catch (Exception e) {
59 _log.error(e, e);
60 }
61 }
62
63 return value;
64 }
65
66 public String getTitle(String languageId, boolean useDefault) {
67 String value = super.getTitle(languageId, useDefault);
68
69 if (Validator.isNull(value)) {
70 try {
71 value = getDescriptiveName();
72 }
73 catch (Exception e) {
74 _log.error(e, e);
75 }
76 }
77
78 return value;
79 }
80
81 public String getTypeLabel() {
82 return RoleConstants.getTypeLabel(getType());
83 }
84
85 public boolean isTeam() {
86 return hasClassName(Team.class);
87 }
88
89 protected boolean hasClassName(Class<?> classObj) {
90 long classNameId = getClassNameId();
91
92 if (classNameId == PortalUtil.getClassNameId(classObj)) {
93 return true;
94 }
95 else {
96 return false;
97 }
98 }
99
100 private static Log _log = LogFactoryUtil.getLog(RoleImpl.class);
101
102 }