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