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