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 HttpSession getHttpSession() {
52 return _ses;
53 }
54
55 public void setHttpSession(HttpSession ses) {
56 _ses = ses;
57
58 setSessionId(_ses.getId());
59 }
60
61 public String getFullName() {
62 if (_fullName == null) {
63 try {
64 if (_user == null) {
65 _user = UserLocalServiceUtil.getUserById(getUserId());
66 }
67
68 _fullName = _user.getFullName();
69 }
70 catch (Exception e) {
71 }
72 }
73
74 if (_fullName == null) {
75 _fullName = StringPool.BLANK;
76 }
77
78 return _fullName;
79 }
80
81 public String getEmailAddress() {
82 if (_emailAddress == null) {
83 try {
84 if (_user == null) {
85 _user = UserLocalServiceUtil.getUserById(getUserId());
86 }
87
88 _emailAddress = _user.getEmailAddress();
89 }
90 catch (Exception e) {
91 }
92 }
93
94 if (_emailAddress == null) {
95 _emailAddress = StringPool.BLANK;
96 }
97
98 return _emailAddress;
99 }
100
101 public List getPaths() {
102 return _paths;
103 }
104
105 public void addPath(UserTrackerPath path) {
106 try {
107 _paths.add(path);
108 }
109 catch (ArrayIndexOutOfBoundsException aioobe) {
110 if (_log.isWarnEnabled()) {
111 _log.warn(aioobe);
112 }
113 }
114
115 setModifiedDate(path.getPathDate());
116 }
117
118 public int getHits() {
119 return _paths.size();
120 }
121
122 public int compareTo(Object obj) {
123 UserTracker userTracker = (UserTracker)obj;
124
125 String userName1 = getFullName().toLowerCase();
126 String userName2 = userTracker.getFullName().toLowerCase();
127
128 int value = userName1.compareTo(userName2);
129
130 if (value == 0) {
131 value = getModifiedDate().compareTo(userTracker.getModifiedDate());
132 }
133
134 return value;
135 }
136
137 private static Log _log = LogFactory.getLog(UserTrackerImpl.class);
138
139 private HttpSession _ses;
140 private User _user;
141 private String _fullName;
142 private String _emailAddress;
143 private List _paths = new ArrayList();
144
145 }