Search in sources :

Example 36 with ForumManager

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;
}
Also used : AssertException(org.olat.core.logging.AssertException) VFSContainer(org.olat.core.util.vfs.VFSContainer) OpenMeetingsModule(org.olat.modules.openmeetings.OpenMeetingsModule) ImportToCalendarManager(org.olat.commons.calendar.manager.ImportToCalendarManager) ImportToCalendarManager(org.olat.commons.calendar.manager.ImportToCalendarManager) CalendarManager(org.olat.commons.calendar.CalendarManager) OlatRootFolderImpl(org.olat.core.commons.modules.bc.vfs.OlatRootFolderImpl) ForumManager(org.olat.modules.fo.manager.ForumManager) OpenMeetingsException(org.olat.modules.openmeetings.manager.OpenMeetingsException) NarrowedPropertyManager(org.olat.properties.NarrowedPropertyManager) Property(org.olat.properties.Property) File(java.io.File) OpenMeetingsManager(org.olat.modules.openmeetings.manager.OpenMeetingsManager)

Example 37 with ForumManager

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;
        }
    });
}
Also used : ForumManager(org.olat.modules.fo.manager.ForumManager) OLATResourceable(org.olat.core.id.OLATResourceable) ArrayList(java.util.ArrayList) List(java.util.List) ArrayList(java.util.ArrayList) Forum(org.olat.modules.fo.Forum)

Example 38 with ForumManager

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;
}
Also used : Message(org.olat.modules.fo.Message) ForumManager(org.olat.modules.fo.manager.ForumManager) ArrayList(java.util.ArrayList) Forum(org.olat.modules.fo.Forum)

Aggregations

ForumManager (org.olat.modules.fo.manager.ForumManager)38 Forum (org.olat.modules.fo.Forum)20 Property (org.olat.properties.Property)14 URI (java.net.URI)12 HttpResponse (org.apache.http.HttpResponse)12 HttpPut (org.apache.http.client.methods.HttpPut)12 Test (org.junit.Test)12 VFSContainer (org.olat.core.util.vfs.VFSContainer)12 Message (org.olat.modules.fo.Message)12 MessageVO (org.olat.modules.fo.restapi.MessageVO)12 VFSItem (org.olat.core.util.vfs.VFSItem)10 BufferedImage (java.awt.image.BufferedImage)8 InputStream (java.io.InputStream)8 OLATResourceable (org.olat.core.id.OLATResourceable)8 VFSLeaf (org.olat.core.util.vfs.VFSLeaf)8 NarrowedPropertyManager (org.olat.properties.NarrowedPropertyManager)8 AssertException (org.olat.core.logging.AssertException)6 CoursePropertyManager (org.olat.course.properties.CoursePropertyManager)6 File (java.io.File)4 ArrayList (java.util.ArrayList)4