mLogger.debug("editPost() Called ========[ SUPPORTED ]=====");
mLogger.debug(" PostId: " + postid);
mLogger.debug(" UserId: " + userid);
mLogger.debug(" Publish: " + publish);
Roller roller = RollerFactory.getRoller();
WeblogManager weblogMgr = roller.getWeblogManager();
WeblogEntryData entry = weblogMgr.getWeblogEntry(postid);
validate(entry.getWebsite().getHandle(), userid,password);
Hashtable postcontent = struct;
String description = (String)postcontent.get("description");
String title = (String)postcontent.get("title");
if (title == null) title = "";
Date dateCreated = (Date)postcontent.get("dateCreated");
if (dateCreated == null) dateCreated = (Date)postcontent.get("pubDate");
String cat = null;
if ( postcontent.get("categories") != null ) {
Vector cats = (Vector)postcontent.get("categories");
cat = (String)cats.elementAt(0);
}
mLogger.debug(" Title: " + title);
mLogger.debug(" Category: " + cat);
try {
Timestamp current =
new Timestamp(System.currentTimeMillis());
if ( !title.equals("") ) entry.setTitle(title);
entry.setText(description);
entry.setUpdateTime(current);
if (Boolean.valueOf(publish).booleanValue()) {
entry.setStatus(WeblogEntryData.PUBLISHED);
} else {
entry.setStatus(WeblogEntryData.DRAFT);
}
if (dateCreated != null) {
entry.setPubTime(new Timestamp(dateCreated.getTime()));
}
if ( cat != null ) {
// Use first category specified by request
WeblogCategoryData cd =
weblogMgr.getWeblogCategoryByPath(entry.getWebsite(), cat);
entry.setCategory(cd);
}
// save the entry
weblogMgr.saveWeblogEntry(entry);
roller.flush();
// notify cache
flushPageCache(entry.getWebsite());
// TODO: Roller timestamps need better than 1 second accuracy