Prev | Current Page 448 | Next

Frank Zammetti

"Practical DWR 2 Projects"

getEditLockTime() + "=" + article.getText();
} else {
log.debug("Article WAS locked, checking for lock expiration");
int editLockTime = Integer.parseInt(Config.getEditLockTime());
long numMillis = 1000 * editLockTime;
CHAPTER 5 n SHARE YOUR KNOWLEDGE: DWIKI, THE DWR-BASED WIKI 254
long lockDiff = new Timestamp(new java.util.Date().getTime()).getTime() -
article.getLockTime().getTime();
if (lockDiff > numMillis) {
log.debug("Lock has expired, acquiring lock on behalf of new user");
article.setLockedBy(inRequest.getUserPrincipal().getName());
article.setLockTime(new Timestamp(new java.util.Date().getTime()));
updateArticle(article, false, inRequest);
retVal = "ok=" + Config.getEditLockTime();
} else {
log.debug("Lock has NOT expired, informing user they cannot edit");
retVal = "lockedBy=" + article.getLockedBy() + "=" +
(editLockTime - (lockDiff / 1000));
}
}
log.trace("ArticleDAO.lockArticleForEditing() - Exit");
return retVal;
} catch (Exception e) {
e.printStackTrace();
throw e;
}
} // End lockArticleForEditing().
This is probably the meatiest method in the whole ArticleDAO class. First, we call the
getArticle() method to get an Article object for the specified article (to lock an article only
the title is needed).


Pages:
436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460