executeUpdate(), passing it the SQL_UPDATE_ARTICLE statement and the
HashMap.
The next task is to write the history record so we know who made the edit and when. To
do this, an ArticleHistoryItem is created and populated, and a call to addArticleHistory(),
which we already saw, is made.
CHAPTER 5 n SHARE YOUR KNOWLEDGE: DWIKI, THE DWR-BASED WIKI 253
Note that both saving the article and adding the history record require the username,
so again we see the HttpServletRequest object as a method parameter and a call to
getUserPrincipal().getName() being used.
Oh yeah, one bit of trickiness I skipped over here: did you notice the if check to see
whether the lockedBy field has a value? And did you notice the check of inWriteHistory
around the history record creation? Those are necessary because when a user requests an article
be locked so he or she can edit it, we need to record the lock information on the record for
the article in the database. However, in that situation, we don??™t want to create a history record.
So, updateArticle() will be called when a user is given an edit lock, and the inWriteHistory
flag will be false, which will cause the history record to not be written.
Pages:
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458