1
22
23 package com.liferay.portal.model.impl;
24
25 import com.liferay.portal.kernel.log.Log;
26 import com.liferay.portal.kernel.log.LogFactoryUtil;
27 import com.liferay.portal.kernel.util.StringPool;
28 import com.liferay.portal.model.User;
29 import com.liferay.portal.model.UserTracker;
30 import com.liferay.portal.model.UserTrackerPath;
31 import com.liferay.portal.service.UserLocalServiceUtil;
32
33 import java.util.ArrayList;
34 import java.util.List;
35
36
41 public class UserTrackerImpl
42 extends UserTrackerModelImpl implements UserTracker {
43
44 public UserTrackerImpl() {
45 }
46
47 public String getFullName() {
48 if (_fullName == null) {
49 try {
50 if (_user == null) {
51 _user = UserLocalServiceUtil.getUserById(getUserId());
52 }
53
54 _fullName = _user.getFullName();
55 }
56 catch (Exception e) {
57 }
58 }
59
60 if (_fullName == null) {
61 _fullName = StringPool.BLANK;
62 }
63
64 return _fullName;
65 }
66
67 public String getEmailAddress() {
68 if (_emailAddress == null) {
69 try {
70 if (_user == null) {
71 _user = UserLocalServiceUtil.getUserById(getUserId());
72 }
73
74 _emailAddress = _user.getEmailAddress();
75 }
76 catch (Exception e) {
77 }
78 }
79
80 if (_emailAddress == null) {
81 _emailAddress = StringPool.BLANK;
82 }
83
84 return _emailAddress;
85 }
86
87 public List<UserTrackerPath> getPaths() {
88 return _paths;
89 }
90
91 public void addPath(UserTrackerPath path) {
92 try {
93 _paths.add(path);
94 }
95 catch (ArrayIndexOutOfBoundsException aioobe) {
96 if (_log.isWarnEnabled()) {
97 _log.warn(aioobe);
98 }
99 }
100
101 setModifiedDate(path.getPathDate());
102 }
103
104 public int getHits() {
105 return _paths.size();
106 }
107
108 public int compareTo(UserTracker userTracker) {
109 String userName1 = getFullName().toLowerCase();
110 String userName2 = userTracker.getFullName().toLowerCase();
111
112 int value = userName1.compareTo(userName2);
113
114 if (value == 0) {
115 value = getModifiedDate().compareTo(userTracker.getModifiedDate());
116 }
117
118 return value;
119 }
120
121 private static Log _log = LogFactoryUtil.getLog(UserTrackerImpl.class);
122
123 private User _user;
124 private String _fullName;
125 private String _emailAddress;
126 private List<UserTrackerPath> _paths = new ArrayList<UserTrackerPath>();
127
128 }