// Create workspace to represent weblog
workspace = new Workspace(Utilities.removeHTML(perm.getWeblog().getName()), "text");
addWorkspace(workspace);
// Create collection for entries within that workspace
Collection entryCol = new Collection("Weblog Entries", "text", atomURL + "/" + weblog.getHandle() + "/entries");
entryCol.addAccept("application/atom+xml;type=entry");
// Add fixed categories using scheme that points to
// weblog because categories are weblog specific
weblog = perm.getWeblog();
Categories cats = new Categories();
cats.setFixed(true);
cats.setScheme(getWeblogCategoryScheme(weblog));
List rollerCats = roller.getWeblogEntryManager().getWeblogCategories(weblog, 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);
workspace.addCollection(entryCol);
} catch (Exception e) {
throw new AtomException("Creating weblog entry collection for service doc", e);
}
// And add one media collection for each of weblog's upload directories
try {
MediaFileManager mgr = roller.getMediaFileManager();
List<MediaFileDirectory> dirs = mgr.getMediaFileDirectories(weblog);
for (MediaFileDirectory dir : dirs) {
Collection uploadSubCol = new Collection(
"Media Files: " + dir.getPath(), "text",
atomURL + "/" + weblog.getHandle() + "/resources/" + dir.getPath());
uploadSubCol.setAccepts(uploadAccepts);
workspace.addCollection(uploadSubCol);
}
} catch (Exception e) {
throw new AtomException("Creating weblog entry collection for service doc", e);