public void moveWeblogCategoryContents(String srcId, String destId)
throws RollerException {
WeblogCategoryData srcCd =
(WeblogCategoryData) this.strategy.load(
srcId, WeblogCategoryData.class);
WeblogCategoryData destCd =
(WeblogCategoryData) this.strategy.load(
destId, WeblogCategoryData.class);
// TODO: this check should be made before calling this method?
if (destCd.descendentOf(srcCd)) {
throw new RollerException(
"ERROR cannot move parent category into it's own child");
}
// get all entries in category and subcats
List results = getWeblogEntries(srcCd, true);
// Loop through entries in src cat, assign them to dest cat
Iterator iter = results.iterator();
WebsiteData website = destCd.getWebsite();
while (iter.hasNext()) {
WeblogEntryData entry = (WeblogEntryData) iter.next();
entry.setCategory(destCd);
entry.setWebsite(website);
this.strategy.store(entry);