use of org.olat.modules.fo.manager.ForumManager in project openolat by klemens.
the class CollaborationTools method deleteTools.
/**
* delete all CollaborationTools stuff from the database, which is related to
* the calling OLATResourceable.
*/
public void deleteTools(BusinessGroup businessGroupTodelete) {
NarrowedPropertyManager npm = NarrowedPropertyManager.getInstance(ores);
/*
* delete the forum, if existing
*/
ForumManager fom = ForumManager.getInstance();
Property forumKeyProperty = npm.findProperty(null, null, PROP_CAT_BG_COLLABTOOLS, KEY_FORUM);
if (forumKeyProperty != null) {
// if there was a forum, delete it
Long forumKey = forumKeyProperty.getLongValue();
if (forumKey == null)
throw new AssertException("property had no longValue, prop:" + forumKeyProperty);
fom.deleteForum(forumKey);
}
/*
* delete the folder, if existing
*/
OlatRootFolderImpl vfsContainer = new OlatRootFolderImpl(getFolderRelPath(), null);
File fFolderRoot = vfsContainer.getBasefile();
if (fFolderRoot.exists()) {
FileUtils.deleteDirsAndFiles(fFolderRoot, true, true);
}
/*
* delete the wiki if existing
*/
VFSContainer rootContainer = WikiManager.getInstance().getWikiRootContainer(ores);
if (rootContainer != null)
rootContainer.delete();
/*
* Delete calendar if exists
*/
if (businessGroupTodelete != null) {
CoreSpringFactory.getImpl(ImportToCalendarManager.class).deleteGroupImportedCalendars(businessGroupTodelete);
CoreSpringFactory.getImpl(CalendarManager.class).deleteGroupCalendar(businessGroupTodelete);
}
/*
* delete chatRoom
*/
// no cleanup needed, automatically done when last user exits the room
/*
* delete all Properties defining enabled/disabled CollabTool XY and the
* news content
*/
npm.deleteProperties(null, null, PROP_CAT_BG_COLLABTOOLS, null);
/*
* Delete OpenMeetings room
*/
OpenMeetingsModule omModule = CoreSpringFactory.getImpl(OpenMeetingsModule.class);
if (omModule.isEnabled()) {
OpenMeetingsManager omManager = CoreSpringFactory.getImpl(OpenMeetingsManager.class);
try {
omManager.deleteAll(ores, null, null);
} catch (OpenMeetingsException e) {
log.error("A room could not be deleted for group: " + ores, e);
}
}
/*
* and last but not least the cache is reseted
*/
cacheToolStates.clear();
this.dirty = true;
}
use of org.olat.modules.fo.manager.ForumManager in project openolat by klemens.
the class ForumNodeForumCallback method saveMultiForums.
private Forum saveMultiForums(final CourseEnvironment courseEnv) {
final ForumManager fom = CoreSpringFactory.getImpl(ForumManager.class);
final OLATResourceable courseNodeResourceable = OresHelper.createOLATResourceableInstance(FOCourseNode.class, new Long(getIdent()));
return CoordinatorManager.getInstance().getCoordinator().getSyncer().doInSync(courseNodeResourceable, new SyncerCallback<Forum>() {
@Override
public Forum execute() {
List<Property> forumKeyProps = courseEnv.getCoursePropertyManager().findCourseNodeProperties(FOCourseNode.this, null, null, FORUM_KEY);
Forum masterForum;
if (forumKeyProps.size() == 1) {
masterForum = loadForum(courseEnv, forumKeyProps.get(0));
} else if (forumKeyProps.size() > 1) {
Long masterForumKey = forumKeyProps.get(0).getLongValue();
List<Long> forumsToMerge = new ArrayList<>();
for (int i = 1; i < forumKeyProps.size(); i++) {
forumsToMerge.add(forumKeyProps.get(i).getLongValue());
}
fom.mergeForums(masterForumKey, forumsToMerge);
masterForum = fom.loadForum(masterForumKey);
for (int i = 1; i < forumKeyProps.size(); i++) {
courseEnv.getCoursePropertyManager().deleteProperty(forumKeyProps.get(i));
}
} else {
masterForum = null;
}
return masterForum;
}
});
}
use of org.olat.modules.fo.manager.ForumManager in project openolat by klemens.
the class ForumArchiveManager method convertToThreadTrees.
/**
* If the forumCallback is null no filtering is executed,
* else if a thread is hidden and the user doesn't have moderator rights the
* hidden thread is not included into the archive.
* @param forumId
* @param metaInfo
* @return all top message nodes together with their children in a list
*/
private List<MessageNode> convertToThreadTrees(Long forumId, ForumCallback forumCallback) {
List<MessageNode> topNodeList = new ArrayList<>();
ForumManager fm = ForumManager.getInstance();
Forum f = fm.loadForum(forumId);
List<Message> messages = fm.getMessagesByForum(f);
for (Iterator<Message> iterTop = messages.iterator(); iterTop.hasNext(); ) {
Message msg = iterTop.next();
if (msg.getParent() == null) {
iterTop.remove();
MessageNode topNode = new MessageNode(msg);
if (topNode.isHidden() && (forumCallback == null || (forumCallback != null && forumCallback.mayEditMessageAsModerator()))) {
addChildren(messages, topNode);
topNodeList.add(topNode);
} else if (!topNode.isHidden()) {
addChildren(messages, topNode);
topNodeList.add(topNode);
}
}
}
Collections.sort(topNodeList, new MessageNodeComparator());
return topNodeList;
}
Aggregations