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 javax.servlet.http.HttpSession;
35
36 import org.apache.commons.logging.Log;
37 import org.apache.commons.logging.LogFactory;
38
39
45 public class UserTrackerImpl
46 extends UserTrackerModelImpl implements UserTracker {
47
48 public UserTrackerImpl() {
49 }
50
51 public String getFullName() {
52 if (_fullName == null) {
53 try {
54 if (_user == null) {
55 _user = UserLocalServiceUtil.getUserById(getUserId());
56 }
57
58 _fullName = _user.getFullName();
59 }
60 catch (Exception e) {
61 }
62 }
63
64 if (_fullName == null) {
65 _fullName = StringPool.BLANK;
66 }
67
68 return _fullName;
69 }
70
71 public String getEmailAddress() {
72 if (_emailAddress == null) {
73 try {
74 if (_user == null) {
75 _user = UserLocalServiceUtil.getUserById(getUserId());
76 }
77
78 _emailAddress = _user.getEmailAddress();
79 }
80 catch (Exception e) {
81 }
82 }
83
84 if (_emailAddress == null) {
85 _emailAddress = StringPool.BLANK;
86 }
87
88 return _emailAddress;
89 }
90
91 public List<UserTrackerPath> getPaths() {
92 return _paths;
93 }
94
95 public void addPath(UserTrackerPath path) {
96 try {
97 _paths.add(path);
98 }
99 catch (ArrayIndexOutOfBoundsException aioobe) {
100 if (_log.isWarnEnabled()) {
101 _log.warn(aioobe);
102 }
103 }
104
105 setModifiedDate(path.getPathDate());
106 }
107
108 public int getHits() {
109 return _paths.size();
110 }
111
112 public int compareTo(Object obj) {
113 UserTracker userTracker = (UserTracker)obj;
114
115 String userName1 = getFullName().toLowerCase();
116 String userName2 = userTracker.getFullName().toLowerCase();
117
118 int value = userName1.compareTo(userName2);
119
120 if (value == 0) {
121 value = getModifiedDate().compareTo(userTracker.getModifiedDate());
122 }
123
124 return value;
125 }
126
127 private static Log _log = LogFactory.getLog(UserTrackerImpl.class);
128
129 private HttpSession _session;
130 private User _user;
131 private String _fullName;
132 private String _emailAddress;
133 private List<UserTrackerPath> _paths = new ArrayList<UserTrackerPath>();
134
135 }