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