Search in sources :

Example 21 with AssertException

use of org.olat.core.logging.AssertException in project OpenOLAT by OpenOLAT.

the class ForumManager method deleteForum.

/**
 * @param forumKey
 */
public void deleteForum(Long forumKey) {
    Forum foToDel = loadForum(forumKey);
    if (foToDel == null)
        throw new AssertException("forum to delete was not found: key=" + forumKey);
    // delete properties, messages and the forum itself
    doDeleteForum(foToDel);
    // delete directory for messages with attachments
    deleteForumContainer(forumKey);
}
Also used : AssertException(org.olat.core.logging.AssertException) Forum(org.olat.modules.fo.Forum)

Example 22 with AssertException

use of org.olat.core.logging.AssertException in project OpenOLAT by OpenOLAT.

the class ForumStreamedRTFFormatter method writeToFile.

/**
 * @param append
 * @param buff
 */
private void writeToFile(StringBuilder buff) {
    try {
        StringBuilder out = new StringBuilder();
        int len = buff.length();
        for (int i = 0; i < len; i++) {
            char c = buff.charAt(i);
            int val = c;
            if (val > 127) {
                out.append("\\u").append(String.valueOf(val)).append("?");
            } else {
                out.append(c);
            }
        }
        String encoded = out.toString();
        exportStream.putNextEntry(new ZipEntry(path + "/" + fileName));
        IOUtils.write(encoded, exportStream, "UTF-8");
        exportStream.closeEntry();
    } catch (UnsupportedEncodingException ueEx) {
        throw new AssertException("could not encode stream from forum export file: " + ueEx);
    } catch (IOException e) {
        throw new AssertException("could not write to forum export file: " + e);
    }
}
Also used : AssertException(org.olat.core.logging.AssertException) ZipEntry(java.util.zip.ZipEntry) UnsupportedEncodingException(java.io.UnsupportedEncodingException) IOException(java.io.IOException)

Example 23 with AssertException

use of org.olat.core.logging.AssertException in project OpenOLAT by OpenOLAT.

the class ProjectGroupManagerImpl method getAccountManagerGroupFor.

@Override
public BusinessGroup getAccountManagerGroupFor(CoursePropertyManager cpm, CourseNode courseNode, ICourse course, String groupName, String groupDescription, Identity identity) {
    BusinessGroup accountManagerGroup = null;
    try {
        Long groupKey = null;
        Property accountManagerGroupProperty = cpm.findCourseNodeProperty(courseNode, null, null, ProjectBrokerCourseNode.CONF_ACCOUNTMANAGER_GROUP_KEY);
        // Check if account-manager-group-key-property already exist
        if (accountManagerGroupProperty != null) {
            groupKey = accountManagerGroupProperty.getLongValue();
            log.debug("accountManagerGroupProperty=" + accountManagerGroupProperty + "  groupKey=" + groupKey);
        }
        log.debug("groupKey=" + groupKey);
        if (groupKey != null) {
            accountManagerGroup = businessGroupService.loadBusinessGroup(groupKey);
            log.debug("load businessgroup=" + accountManagerGroup);
            if (accountManagerGroup != null) {
                return accountManagerGroup;
            } else {
                if (accountManagerGroupProperty != null) {
                    cpm.deleteProperty(accountManagerGroupProperty);
                }
                groupKey = null;
                log.warn("ProjectBroker: Account-manager does no longer exist, create a new one", null);
            }
        } else {
            log.debug("No group for project-broker exist => create a new one");
            RepositoryEntry re = course.getCourseEnvironment().getCourseGroupManager().getCourseEntry();
            accountManagerGroup = businessGroupService.createBusinessGroup(identity, groupName, groupDescription, -1, -1, false, false, re);
            int i = 2;
            while (accountManagerGroup == null) {
                // group with this name exist already, try another name
                accountManagerGroup = businessGroupService.createBusinessGroup(identity, groupName + " _" + i, groupDescription, -1, -1, false, false, re);
                i++;
            }
            log.debug("createAndPersistBusinessGroup businessgroup=" + accountManagerGroup);
            if (accountManagerGroupProperty != null) {
                accountManagerGroupProperty.setLongValue(accountManagerGroup.getKey());
                cpm.updateProperty(accountManagerGroupProperty);
            } else {
                saveAccountManagerGroupKey(accountManagerGroup.getKey(), cpm, courseNode);
            }
            log.debug("created account-manager default businessgroup=" + accountManagerGroup);
        }
    } catch (AssertException e) {
        log.error("", e);
        if (tryToRepareAccountManagerProperty(cpm, courseNode)) {
            accountManagerGroup = getAccountManagerGroupFor(cpm, courseNode, course, groupName, groupDescription, identity);
        }
    }
    return accountManagerGroup;
}
Also used : AssertException(org.olat.core.logging.AssertException) BusinessGroup(org.olat.group.BusinessGroup) RepositoryEntry(org.olat.repository.RepositoryEntry) Property(org.olat.properties.Property)

Example 24 with AssertException

use of org.olat.core.logging.AssertException in project OpenOLAT by OpenOLAT.

the class CourseEditorTreeModel method addCourseNode.

/**
 * append new course
 * @param newNode
 * @param parentNode
 */
public CourseEditorTreeNode addCourseNode(CourseNode newNode, CourseNode parentNode) {
    // update editor tree model
    CourseEditorTreeNode ctnParent = (CourseEditorTreeNode) getNodeById(parentNode.getIdent());
    if (ctnParent == null)
        throw new AssertException("Corrupt CourseEditorTreeModel.");
    CourseEditorTreeNode newCetn = new CourseEditorTreeNode(newNode);
    newCetn.setNewnode(true);
    newCetn.setDirty(true);
    ctnParent.addChild(newCetn);
    log.debug("addCourseNode - nodeId: " + newNode.getIdent());
    return newCetn;
}
Also used : AssertException(org.olat.core.logging.AssertException)

Example 25 with AssertException

use of org.olat.core.logging.AssertException in project OpenOLAT by OpenOLAT.

the class CourseEditorTreeModel method removeCourseNode.

/**
 * @deprecated REVIEW:pb: no longer used? it is not referenced from java, and
 *             also not found in velocity *.html
 * @param courseNode
 */
public void removeCourseNode(CourseNode courseNode) {
    CourseEditorTreeNode cetNode = (CourseEditorTreeNode) getNodeById(courseNode.getIdent());
    if (cetNode == null)
        throw new AssertException("Corrupt CourseEditorTreeModel.");
    cetNode.removeFromParent();
}
Also used : AssertException(org.olat.core.logging.AssertException)

Aggregations

AssertException (org.olat.core.logging.AssertException)364 IOException (java.io.IOException)38 File (java.io.File)28 Identity (org.olat.core.id.Identity)28 ArrayList (java.util.ArrayList)26 HashMap (java.util.HashMap)24 Controller (org.olat.core.gui.control.Controller)22 OLATResourceable (org.olat.core.id.OLATResourceable)22 RepositoryEntry (org.olat.repository.RepositoryEntry)22 WindowControl (org.olat.core.gui.control.WindowControl)20 UnsupportedEncodingException (java.io.UnsupportedEncodingException)18 JSONException (org.json.JSONException)18 BusinessGroup (org.olat.group.BusinessGroup)18 JSONObject (org.json.JSONObject)16 UserRequest (org.olat.core.gui.UserRequest)16 VFSContainer (org.olat.core.util.vfs.VFSContainer)16 VFSItem (org.olat.core.util.vfs.VFSItem)16 Date (java.util.Date)14 Properties (java.util.Properties)14 Property (org.olat.properties.Property)14