// Atom supports multiple cats, but Weblogger supports one/entry
// so here we take accept the first category that exists.
List categories = entry.getCategories();
if (categories != null && categories.size() > 0) {
for (int i=0; i<categories.size(); i++) {
Category cat = (Category)categories.get(i);
if (cat.getScheme() != null && cat.getScheme().equals(
RollerAtomService.getWeblogCategoryScheme(rollerEntry.getWebsite()))) {
String catString = cat.getTerm();
if (catString != null) {
WeblogCategory rollerCat =
roller.getWeblogEntryManager().getWeblogCategoryByPath(
rollerEntry.getWebsite(), catString);
if (rollerCat != null) {
// Found a valid category, so break out
rollerEntry.setCategory(rollerCat);
break;
}
}
}
}
}
if (rollerEntry.getCategory() == null) {
// Didn't find a category? Fall back to the default Blogger API category.
rollerEntry.setCategory(rollerEntry.getWebsite().getBloggerCategory());
}
// Now process incoming categories that are tags:
// Atom categories with no scheme are considered tags.
String tags = "";
if (categories != null && categories.size() > 0) {
for (int i=0; i<categories.size(); i++) {
Category cat = (Category)categories.get(i);
if (cat.getScheme() == null) {
tags = tags + " " + cat.getTerm();
}
}
}
rollerEntry.setTagsAsString(tags);
}