}
}
}
public UserAccount loginStarts(HttpSession session, UserAccount user) {
UserAccount aUser = UserAccount.findOrCreateUser(user);
UserAccount u = null;
// update user info under transactional control
PersistenceManager pm = PMF.getTxnPm();
Transaction tx = pm.currentTransaction();
try {
for (int i = 0; i < NUM_RETRIES; i++) {
tx = pm.currentTransaction();
tx.begin();
u = (UserAccount) pm.getObjectById(UserAccount.class, aUser.getId());
String channelId = ChannelServer.createChannel(u.getUniqueId());
u.setChannelId(channelId);
u.setLastActive(new Date());
u.setLastLoginOn(new Date());
try {
tx.commit();
// update session if successful
session.setAttribute("userId", String.valueOf(u.getId()));
session.setAttribute("loggedin", true);
break;
}
catch (JDOCanRetryException e1) {
if (i == (NUM_RETRIES - 1)) {