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 @Override
035 public void addPath(UserTrackerPath path) {
036 try {
037 _paths.add(path);
038 }
039 catch (ArrayIndexOutOfBoundsException aioobe) {
040 if (_log.isWarnEnabled()) {
041 _log.warn(aioobe);
042 }
043 }
044
045 setModifiedDate(path.getPathDate());
046 }
047
048 @Override
049 public int compareTo(UserTracker userTracker) {
050 String userName1 = StringUtil.toLowerCase(getFullName());
051 String userName2 = StringUtil.toLowerCase(userTracker.getFullName());
052
053 int value = userName1.compareTo(userName2);
054
055 if (value == 0) {
056 value = getModifiedDate().compareTo(userTracker.getModifiedDate());
057 }
058
059 return value;
060 }
061
062 @Override
063 public String getEmailAddress() {
064 if (_emailAddress == null) {
065 try {
066 if (_user == null) {
067 _user = UserLocalServiceUtil.getUserById(getUserId());
068 }
069
070 _emailAddress = _user.getEmailAddress();
071 }
072 catch (Exception e) {
073 }
074 }
075
076 if (_emailAddress == null) {
077 _emailAddress = StringPool.BLANK;
078 }
079
080 return _emailAddress;
081 }
082
083 @Override
084 public String getFullName() {
085 if (_fullName == null) {
086 try {
087 if (_user == null) {
088 _user = UserLocalServiceUtil.getUserById(getUserId());
089 }
090
091 _fullName = _user.getFullName();
092 }
093 catch (Exception e) {
094 }
095 }
096
097 if (_fullName == null) {
098 _fullName = StringPool.BLANK;
099 }
100
101 return _fullName;
102 }
103
104 @Override
105 public int getHits() {
106 return _paths.size();
107 }
108
109 @Override
110 public List<UserTrackerPath> getPaths() {
111 return _paths;
112 }
113
114 private static final Log _log = LogFactoryUtil.getLog(
115 UserTrackerImpl.class);
116
117 private String _emailAddress;
118 private String _fullName;
119 private final List<UserTrackerPath> _paths = new ArrayList<>();
120 private User _user;
121
122 }