* Create a Rome Atom entry based on a Weblogger entry.
* Content is escaped.
* Link is stored as rel=alternate link.
*/
private Entry createAtomEntry(WeblogEntry entry) {
Entry atomEntry = new Entry();
String absUrl = WebloggerRuntimeConfig.getAbsoluteContextURL();
atomEntry.setId( absUrl + entry.getPermaLink());
atomEntry.setTitle( entry.getTitle());
atomEntry.setPublished( entry.getPubTime());
atomEntry.setUpdated( entry.getUpdateTime());
Content content = new Content();
content.setType(Content.HTML);
content.setValue(entry.getText());
List contents = new ArrayList();
contents.add(content);
atomEntry.setContents(contents);
if (StringUtils.isNotEmpty(entry.getSummary())) {
Content summary = new Content();
summary.setType(Content.HTML);
summary.setValue(entry.getSummary());
atomEntry.setSummary(summary);
}
User creator = entry.getCreator();
Person author = new Person();
author.setName( creator.getUserName());
author.setEmail( creator.getEmailAddress());
atomEntry.setAuthors( Collections.singletonList(author));
// Add Atom category for Weblogger category, using category scheme
List categories = new ArrayList();
Category atomCat = new Category();
atomCat.setScheme(getWeblogCategoryScheme(entry.getWebsite()));
atomCat.setTerm(entry.getCategory().getPath().substring(1));
categories.add(atomCat);
// Add Atom categories for each Weblogger tag with null scheme
for (Iterator tagit = entry.getTags().iterator(); tagit.hasNext();) {
WeblogEntryTag tag = (WeblogEntryTag) tagit.next();
Category newcat = new Category();
newcat.setTerm(tag.getName());
categories.add(newcat);
}
atomEntry.setCategories(categories);
Link altlink = new Link();
altlink.setRel("alternate");
altlink.setHref(absUrl + entry.getPermaLink());
List altlinks = new ArrayList();
altlinks.add(altlink);
atomEntry.setAlternateLinks(altlinks);
Link editlink = new Link();
editlink.setRel("edit");
editlink.setHref(
atomURL
+"/"+entry.getWebsite().getHandle() + "/entry/" + entry.getId());
List otherlinks = new ArrayList();
otherlinks.add(editlink);
atomEntry.setOtherLinks(otherlinks);
List modules = new ArrayList();
AppModule app = new AppModuleImpl();
app.setDraft(!WeblogEntry.PUBLISHED.equals(entry.getStatus()));
app.setEdited(entry.getUpdateTime());
modules.add(app);
atomEntry.setModules(modules);
return atomEntry;
}