use of org.olat.course.tree.PublishTreeModel in project OpenOLAT by OpenOLAT.
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);
}
}
}
use of org.olat.course.tree.PublishTreeModel in project OpenOLAT by OpenOLAT.
the class EditorMainController method hasPublishableChanges.
public boolean hasPublishableChanges(ICourse course) {
if (cetm == null || course == null) {
return false;
}
PublishProcess publishProcess = PublishProcess.getInstance(course, cetm, getLocale());
PublishTreeModel publishTreeModel = publishProcess.getPublishTreeModel();
return publishTreeModel.hasPublishableChanges();
}
use of org.olat.course.tree.PublishTreeModel in project OpenOLAT by OpenOLAT.
the class QuickPublishController method doAutoPublish.
private boolean doAutoPublish() {
ICourse course = CourseFactory.loadCourse(courseOres);
CourseEditorTreeModel cetm = course.getEditorTreeModel();
PublishProcess publishProcess = PublishProcess.getInstance(course, cetm, getLocale());
PublishTreeModel publishTreeModel = publishProcess.getPublishTreeModel();
if (publishTreeModel.hasPublishableChanges()) {
List<String> nodeToPublish = new ArrayList<String>();
visitPublishModel(publishTreeModel.getRootNode(), publishTreeModel, nodeToPublish);
// only add selection if changes were possible
for (Iterator<String> selectionIt = nodeToPublish.iterator(); selectionIt.hasNext(); ) {
String ident = selectionIt.next();
TreeNode node = publishProcess.getPublishTreeModel().getNodeById(ident);
if (!publishTreeModel.isSelectable(node)) {
selectionIt.remove();
}
}
publishProcess.createPublishSetFor(nodeToPublish);
PublishSetInformations set = publishProcess.testPublishSet(getLocale());
StatusDescription[] status = set.getWarnings();
// publish not possible when there are errors
StringBuilder errMsg = new StringBuilder();
for (int i = 0; i < status.length; i++) {
if (status[i].isError()) {
errMsg.append(status[i].getLongDescription(getLocale()));
logError("Status error by publish: " + status[i].getLongDescription(getLocale()), null);
}
}
if (errMsg.length() > 0) {
getWindowControl().setWarning(errMsg.toString());
return false;
}
PublishEvents publishEvents = publishProcess.getPublishEvents();
try {
publishProcess.applyPublishSet(getIdentity(), getLocale(), false);
} catch (Exception e) {
logError("", e);
}
if (publishEvents.getPostPublishingEvents().size() > 0) {
for (MultiUserEvent event : publishEvents.getPostPublishingEvents()) {
CoordinatorManager.getInstance().getCoordinator().getEventBus().fireEventToListenersOf(event, courseOres);
}
}
}
return true;
}
use of org.olat.course.tree.PublishTreeModel in project openolat by klemens.
the class EditorMainController method hasPublishableChanges.
public boolean hasPublishableChanges(ICourse course) {
if (cetm == null || course == null) {
return false;
}
PublishProcess publishProcess = PublishProcess.getInstance(course, cetm, getLocale());
PublishTreeModel publishTreeModel = publishProcess.getPublishTreeModel();
return publishTreeModel.hasPublishableChanges();
}
use of org.olat.course.tree.PublishTreeModel in project openolat by klemens.
the class QuickPublishController method doAutoPublish.
private boolean doAutoPublish() {
ICourse course = CourseFactory.loadCourse(courseOres);
CourseEditorTreeModel cetm = course.getEditorTreeModel();
PublishProcess publishProcess = PublishProcess.getInstance(course, cetm, getLocale());
PublishTreeModel publishTreeModel = publishProcess.getPublishTreeModel();
if (publishTreeModel.hasPublishableChanges()) {
List<String> nodeToPublish = new ArrayList<String>();
visitPublishModel(publishTreeModel.getRootNode(), publishTreeModel, nodeToPublish);
// only add selection if changes were possible
for (Iterator<String> selectionIt = nodeToPublish.iterator(); selectionIt.hasNext(); ) {
String ident = selectionIt.next();
TreeNode node = publishProcess.getPublishTreeModel().getNodeById(ident);
if (!publishTreeModel.isSelectable(node)) {
selectionIt.remove();
}
}
publishProcess.createPublishSetFor(nodeToPublish);
PublishSetInformations set = publishProcess.testPublishSet(getLocale());
StatusDescription[] status = set.getWarnings();
// publish not possible when there are errors
StringBuilder errMsg = new StringBuilder();
for (int i = 0; i < status.length; i++) {
if (status[i].isError()) {
errMsg.append(status[i].getLongDescription(getLocale()));
logError("Status error by publish: " + status[i].getLongDescription(getLocale()), null);
}
}
if (errMsg.length() > 0) {
getWindowControl().setWarning(errMsg.toString());
return false;
}
PublishEvents publishEvents = publishProcess.getPublishEvents();
try {
publishProcess.applyPublishSet(getIdentity(), getLocale(), false);
} catch (Exception e) {
logError("", e);
}
if (publishEvents.getPostPublishingEvents().size() > 0) {
for (MultiUserEvent event : publishEvents.getPostPublishingEvents()) {
CoordinatorManager.getInstance().getCoordinator().getEventBus().fireEventToListenersOf(event, courseOres);
}
}
}
return true;
}
Aggregations