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