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);
}
}
}
Aggregations