001
014
015 package com.liferay.portal.model.impl;
016
017 import com.liferay.portal.kernel.log.Log;
018 import com.liferay.portal.kernel.log.LogFactoryUtil;
019 import com.liferay.portal.kernel.util.StringPool;
020 import com.liferay.portal.kernel.util.StringUtil;
021 import com.liferay.portal.model.User;
022 import com.liferay.portal.model.UserTracker;
023 import com.liferay.portal.model.UserTrackerPath;
024 import com.liferay.portal.service.UserLocalServiceUtil;
025
026 import java.util.ArrayList;
027 import java.util.List;
028
029
032 public class UserTrackerImpl extends UserTrackerBaseImpl {
033
034 public UserTrackerImpl() {
035 }
036
037 @Override
038 public void addPath(UserTrackerPath path) {
039 try {
040 _paths.add(path);
041 }
042 catch (ArrayIndexOutOfBoundsException aioobe) {
043 if (_log.isWarnEnabled()) {
044 _log.warn(aioobe);
045 }
046 }
047
048 setModifiedDate(path.getPathDate());
049 }
050
051 @Override
052 public int compareTo(UserTracker userTracker) {
053 String userName1 = StringUtil.toLowerCase(getFullName());
054 String userName2 = StringUtil.toLowerCase(userTracker.getFullName());
055
056 int value = userName1.compareTo(userName2);
057
058 if (value == 0) {
059 value = getModifiedDate().compareTo(userTracker.getModifiedDate());
060 }
061
062 return value;
063 }
064
065 @Override
066 public String getEmailAddress() {
067 if (_emailAddress == null) {
068 try {
069 if (_user == null) {
070 _user = UserLocalServiceUtil.getUserById(getUserId());
071 }
072
073 _emailAddress = _user.getEmailAddress();
074 }
075 catch (Exception e) {
076 }
077 }
078
079 if (_emailAddress == null) {
080 _emailAddress = StringPool.BLANK;
081 }
082
083 return _emailAddress;
084 }
085
086 @Override
087 public String getFullName() {
088 if (_fullName == null) {
089 try {
090 if (_user == null) {
091 _user = UserLocalServiceUtil.getUserById(getUserId());
092 }
093
094 _fullName = _user.getFullName();
095 }
096 catch (Exception e) {
097 }
098 }
099
100 if (_fullName == null) {
101 _fullName = StringPool.BLANK;
102 }
103
104 return _fullName;
105 }
106
107 @Override
108 public int getHits() {
109 return _paths.size();
110 }
111
112 @Override
113 public List<UserTrackerPath> getPaths() {
114 return _paths;
115 }
116
117 private static Log _log = LogFactoryUtil.getLog(UserTrackerImpl.class);
118
119 private String _emailAddress;
120 private String _fullName;
121 private List<UserTrackerPath> _paths = new ArrayList<UserTrackerPath>();
122 private User _user;
123
124 }