1 15 package org.apache.tapestry.vlib; 16 17 import java.io.Serializable ; 18 import java.sql.Timestamp ; 19 20 import org.apache.tapestry.IRequestCycle; 21 import org.apache.tapestry.vlib.ejb.Person; 22 23 34 35 public class Visit implements Serializable 36 { 37 private static final long serialVersionUID = 8589862098677603655L; 38 39 43 44 private transient Person _user; 45 private Integer _userId; 46 47 53 54 private Timestamp _lastAccess; 55 56 61 62 public Timestamp getLastAccess() 63 { 64 return _lastAccess; 65 } 66 67 71 72 public Person getUser(IRequestCycle cycle) 73 { 74 if (_user != null) 75 return _user; 76 77 if (_userId == null) 78 return null; 79 80 VirtualLibraryEngine vengine = (VirtualLibraryEngine) cycle.getEngine(); 81 82 _user = vengine.readPerson(_userId); 83 84 return _user; 85 } 86 87 92 93 public Integer getUserId() 94 { 95 return _userId; 96 } 97 98 103 104 public void setUser(Person value) 105 { 106 _lastAccess = null; 107 _user = value; 108 _userId = null; 109 110 if (_user == null) 111 return; 112 113 _userId = _user.getId(); 114 115 _lastAccess = _user.getLastAccess(); 116 } 117 118 122 123 public boolean isUserLoggedIn() 124 { 125 return _userId != null; 126 } 127 128 133 134 public boolean isUserLoggedOut() 135 { 136 return _userId == null; 137 } 138 139 public boolean isLoggedInUser(Integer id) 140 { 141 if (_userId == null) 142 return false; 143 144 return _userId.equals(id); 145 } 146 147 152 153 public void clearCache() 154 { 155 _user = null; 156 } 157 158 } | Popular Tags |