1
19
20 package com.liferay.portal.model.impl;
21
22 import com.liferay.portal.kernel.log.Log;
23 import com.liferay.portal.kernel.log.LogFactoryUtil;
24 import com.liferay.portal.kernel.util.StringPool;
25 import com.liferay.portal.model.User;
26 import com.liferay.portal.model.UserTracker;
27 import com.liferay.portal.model.UserTrackerPath;
28 import com.liferay.portal.service.UserLocalServiceUtil;
29
30 import java.util.ArrayList;
31 import java.util.List;
32
33
39 public class UserTrackerImpl
40 extends UserTrackerModelImpl implements UserTracker {
41
42 public UserTrackerImpl() {
43 }
44
45 public String getFullName() {
46 if (_fullName == null) {
47 try {
48 if (_user == null) {
49 _user = UserLocalServiceUtil.getUserById(getUserId());
50 }
51
52 _fullName = _user.getFullName();
53 }
54 catch (Exception e) {
55 }
56 }
57
58 if (_fullName == null) {
59 _fullName = StringPool.BLANK;
60 }
61
62 return _fullName;
63 }
64
65 public String getEmailAddress() {
66 if (_emailAddress == null) {
67 try {
68 if (_user == null) {
69 _user = UserLocalServiceUtil.getUserById(getUserId());
70 }
71
72 _emailAddress = _user.getEmailAddress();
73 }
74 catch (Exception e) {
75 }
76 }
77
78 if (_emailAddress == null) {
79 _emailAddress = StringPool.BLANK;
80 }
81
82 return _emailAddress;
83 }
84
85 public List<UserTrackerPath> getPaths() {
86 return _paths;
87 }
88
89 public void addPath(UserTrackerPath path) {
90 try {
91 _paths.add(path);
92 }
93 catch (ArrayIndexOutOfBoundsException aioobe) {
94 if (_log.isWarnEnabled()) {
95 _log.warn(aioobe);
96 }
97 }
98
99 setModifiedDate(path.getPathDate());
100 }
101
102 public int getHits() {
103 return _paths.size();
104 }
105
106 public int compareTo(UserTracker userTracker) {
107 String userName1 = getFullName().toLowerCase();
108 String userName2 = userTracker.getFullName().toLowerCase();
109
110 int value = userName1.compareTo(userName2);
111
112 if (value == 0) {
113 value = getModifiedDate().compareTo(userTracker.getModifiedDate());
114 }
115
116 return value;
117 }
118
119 private static Log _log = LogFactoryUtil.getLog(UserTrackerImpl.class);
120
121 private User _user;
122 private String _fullName;
123 private String _emailAddress;
124 private List<UserTrackerPath> _paths = new ArrayList<UserTrackerPath>();
125
126 }