Search in sources :

Example 46 with CourseEditorTreeModel

use of org.olat.course.tree.CourseEditorTreeModel in project openolat by klemens.

the class ModifyCourseEvent method publishCourse.

/**
 * Publish the course with some standard options
 * @param course
 * @param locale
 * @param identity
 */
public static void publishCourse(ICourse course, int access, boolean membersOnly, Identity identity, Locale locale) {
    CourseEditorTreeModel cetm = course.getEditorTreeModel();
    PublishProcess publishProcess = PublishProcess.getInstance(course, cetm, locale);
    PublishTreeModel publishTreeModel = publishProcess.getPublishTreeModel();
    int newAccess = (access < RepositoryEntry.ACC_OWNERS || access > RepositoryEntry.ACC_USERS_GUESTS) ? RepositoryEntry.ACC_USERS : access;
    // access rule -> all users can the see course
    // RepositoryEntry.ACC_OWNERS
    // only owners can the see course
    // RepositoryEntry.ACC_OWNERS_AUTHORS //only owners and authors can the see course
    // RepositoryEntry.ACC_USERS_GUESTS // users and guests can see the course
    // fxdiff VCRP-1,2: access control of resources
    publishProcess.changeGeneralAccess(identity, newAccess, membersOnly);
    if (publishTreeModel.hasPublishableChanges()) {
        List<String> nodeToPublish = new ArrayList<String>();
        visitPublishModel(publishTreeModel.getRootNode(), publishTreeModel, nodeToPublish);
        publishProcess.createPublishSetFor(nodeToPublish);
        PublishSetInformations set = publishProcess.testPublishSet(locale);
        StatusDescription[] status = set.getWarnings();
        // publish not possible when there are errors
        for (int i = 0; i < status.length; i++) {
            if (status[i].isError()) {
                log.error("Status error by publish: " + status[i].getLongDescription(locale));
                return;
            }
        }
        try {
            course = CourseFactory.openCourseEditSession(course.getResourceableId());
            publishProcess.applyPublishSet(identity, locale, false);
        } catch (Exception e) {
            log.error("", e);
        } finally {
            closeCourseEditSession(course.getResourceableId(), true);
        }
    }
}
Also used : CourseEditorTreeModel(org.olat.course.tree.CourseEditorTreeModel) StatusDescription(org.olat.course.editor.StatusDescription) PublishTreeModel(org.olat.course.tree.PublishTreeModel) ArrayList(java.util.ArrayList) PublishProcess(org.olat.course.editor.PublishProcess) PublishSetInformations(org.olat.course.editor.PublishSetInformations) AssertException(org.olat.core.logging.AssertException) IOException(java.io.IOException) FileNotFoundException(java.io.FileNotFoundException) OLATRuntimeException(org.olat.core.logging.OLATRuntimeException)

Aggregations

CourseEditorTreeModel (org.olat.course.tree.CourseEditorTreeModel)46 ICourse (org.olat.course.ICourse)26 CourseNode (org.olat.course.nodes.CourseNode)26 CourseEditorTreeNode (org.olat.course.tree.CourseEditorTreeNode)24 Test (org.junit.Test)18 RepositoryEntry (org.olat.repository.RepositoryEntry)16 Identity (org.olat.core.id.Identity)14 INode (org.olat.core.util.nodes.INode)12 ArrayList (java.util.ArrayList)6 CourseNodeConfiguration (org.olat.course.nodes.CourseNodeConfiguration)6 File (java.io.File)4 URI (java.net.URI)4 HttpEntity (org.apache.http.HttpEntity)4 HttpResponse (org.apache.http.HttpResponse)4 HttpPost (org.apache.http.client.methods.HttpPost)4 HttpPut (org.apache.http.client.methods.HttpPut)4 AssertException (org.olat.core.logging.AssertException)4 CourseConfig (org.olat.course.config.CourseConfig)4 PublishProcess (org.olat.course.editor.PublishProcess)4 PublishSetInformations (org.olat.course.editor.PublishSetInformations)4