@Override
public void remove(List<Long> ids) {
List<Long> removeIds = new ArrayList<Long>();
PageMessage message = new PageMessage(Topic.PAGES_DELETED);
for (Long id : ids) {
PageEntity page = getDao().getPageDao().getById(id);
if (page != null) {
if (canWritePage(page.getFriendlyURL())) {
if (isLastRootPageVersion(page)) {
continue;
}
removeIds.add(id);
message.addPage(page.getFriendlyURL(), id);
}
}
}
TreeItemDecorator<FolderEntity> root = getBusiness().getFolderBusiness()
.getTree();
List<Long> folderIds = new ArrayList<Long>();
for (Long id : removeIds) {
PageEntity page = getDao().getPageDao().getById(id);
TreeItemDecorator<FolderEntity> folder = getBusiness()
.getFolderBusiness()
.findFolderByPath(root, "/page" + page.getFriendlyURL());
if (folder != null) {
folderIds.add(folder.getEntity().getId());
}
getBusiness().getSystemService().getPageCache().remove(
page.getFriendlyURL());
}
getBusiness().getFolderBusiness().recursiveRemove(folderIds);
getDao().getPageDao().remove(removeIds);
getBusiness().getMessageQueue().publish(message);
}