} catch (WebloggerException re) {
throw new AtomException("Getting site's accept range", re);
}
if (perms != null) {
for (Iterator iter=perms.iterator(); iter.hasNext();) {
WeblogPermission perm = (WeblogPermission)iter.next();
// only include weblog's that have client API support enabled
if (!Boolean.TRUE.equals(perm.getWebsite().getEnableBloggerApi())) continue;
// Create workspace to represent weblog
Workspace workspace = new Workspace(
Utilities.removeHTML(perm.getWebsite().getName()), "text");
service.addWorkspace(workspace);
// Create collection for entries within that workspace
String handle = perm.getWebsite().getHandle();
Collection entryCol = new Collection("Weblog Entries", "text",
atomURL+"/"+handle+"/entries");
entryCol.addAccept("application/atom+xml;type=entry");
try {
// Add fixed categories using scheme that points to
// weblog because categories are weblog specific
Categories cats = new Categories();
cats.setFixed(true);
cats.setScheme(getWeblogCategoryScheme(perm.getWebsite()));
List rollerCats = roller.getWeblogManager().getWeblogCategories(perm.getWebsite(), false);
for (Iterator it = rollerCats.iterator(); it.hasNext();) {
WeblogCategory rollerCat = (WeblogCategory)it.next();
Category cat = new Category();
cat.setTerm(rollerCat.getPath().substring(1));
cat.setLabel(rollerCat.getName());
cats.addCategory(cat);
}
entryCol.addCategories(cats);
// Add tags as free-form categories using scheme that points
// to site because tags can be considered site-wide
Categories tags = new Categories();
tags.setFixed(false);
entryCol.addCategories(tags);
} catch (Exception e) {
throw new AtomException("Fetching weblog categories");
}
workspace.addCollection(entryCol);
// Add media collection for upload dir
Collection uploadCol = new Collection("Media Files", "text",
atomURL+"/"+handle+"/resources/");
uploadCol.setAccepts(uploadAccepts);
workspace.addCollection(uploadCol);
// And add one media collection for each of weblog's upload sub-directories
ThemeResource[] dirs;
try {
dirs = roller.getFileManager().getDirectories(perm.getWebsite());
for (int i=0; i<dirs.length; i++) {
Collection uploadSubCol = new Collection(
"Media Files: " + dirs[i].getPath(), "text",
atomURL+"/"+handle+"/resources/" + dirs[i].getPath());
uploadSubCol.setAccepts(uploadAccepts);