Skip to content
Snippets Groups Projects
Commit d27ea6f9 authored by srosse's avatar srosse
Browse files

OO-1824: reuse the persisting course in the merged course container

parent facc829b
No related branches found
No related tags found
No related merge requests found
......@@ -86,11 +86,20 @@ public interface ICourse extends OLATResourceable {
/**
* Return the container to the coursefolder of this course.
* (E.g. "COURSEBASEPATH/coursefolder/")
* (E.g. "COURSEBASEPATH/coursefolder/"). This is for administration
* use. There is no permission check.
*
* @return the container to the coursefolder of this course
*/
public VFSContainer getCourseFolderContainer();
/**
* The course folder that the user specified by its identity environment
* can see and use.
*
* @param identityEnv
* @return The aggreagted course folder
*/
public VFSContainer getCourseFolderContainer(IdentityEnvironment identityEnv);
public OlatRootFolderImpl getCourseExportDataDir();
......
......@@ -73,55 +73,60 @@ public class MergedCourseContainer extends MergeSource {
@Override
protected void init() {
super.init();
ICourse course = CourseFactory.loadCourse(courseId);
if(course instanceof PersistingCourseImpl) {
PersistingCourseImpl persistingCourse = (PersistingCourseImpl)course;
if(identityEnv == null || identityEnv.getRoles().isOLATAdmin()) {
init((PersistingCourseImpl)course);
}
}
protected void init(PersistingCourseImpl persistingCourse) {
super.init();
if(identityEnv == null || identityEnv.getRoles().isOLATAdmin()) {
addContainersChildren(persistingCourse.getIsolatedCourseFolder(), true);
} else {
RepositoryEntry re = persistingCourse.getCourseEnvironment().getCourseGroupManager().getCourseEntry();
RepositoryEntrySecurity reSecurity = RepositoryManager.getInstance()
.isAllowed(identityEnv.getIdentity(), identityEnv.getRoles(), re);
if(reSecurity.isEntryAdmin()) {
addContainersChildren(persistingCourse.getIsolatedCourseFolder(), true);
} else {
RepositoryEntry re = course.getCourseEnvironment().getCourseGroupManager().getCourseEntry();
RepositoryEntrySecurity reSecurity = RepositoryManager.getInstance()
.isAllowed(identityEnv.getIdentity(), identityEnv.getRoles(), re);
if(reSecurity.isEntryAdmin()) {
addContainersChildren(persistingCourse.getIsolatedCourseFolder(), true);
}
}
// grab any shared folder that is configured
OlatRootFolderImpl sharedFolder = null;
String sfSoftkey = persistingCourse.getCourseConfig().getSharedFolderSoftkey();
if (StringHelper.containsNonWhitespace(sfSoftkey) && !CourseConfig.VALUE_EMPTY_SHAREDFOLDER_SOFTKEY.equals(sfSoftkey)) {
OLATResource sharedResource = CoreSpringFactory.getImpl(RepositoryService.class)
.loadRepositoryEntryResourceBySoftKey(sfSoftkey);
if (sharedResource != null) {
sharedFolder = SharedFolderManager.getInstance().getSharedFolder(sharedResource);
if (sharedFolder != null) {
sharedFolder.setLocalSecurityCallback(new ReadOnlyCallback());
//add local course folder's children as read/write source and any sharedfolder as subfolder
addContainer(new NamedContainerImpl("_sharedfolder", sharedFolder));
}
}
}
}
// add all course building blocks of type BC to a virtual folder
MergeSource nodesContainer = new MergeSource(null, "_courseelementdata");
if(identityEnv == null) {
CourseNode rootNode = course.getRunStructure().getRootNode();
addFolderBuildingBlocks(persistingCourse, nodesContainer, rootNode);
} else {
TreeEvaluation treeEval = new TreeEvaluation();
GenericTreeModel treeModel = new GenericTreeModel();
UserCourseEnvironment userCourseEnv = new UserCourseEnvironmentImpl(identityEnv, course.getCourseEnvironment());
CourseNode rootCn = userCourseEnv.getCourseEnvironment().getRunStructure().getRootNode();
NodeEvaluation rootNodeEval = rootCn.eval(userCourseEnv.getConditionInterpreter(), treeEval, new VisibleTreeFilter());
TreeNode treeRoot = rootNodeEval.getTreeNode();
treeModel.setRootNode(treeRoot);
addFolderBuildingBlocks(persistingCourse, nodesContainer, treeRoot);
// grab any shared folder that is configured
OlatRootFolderImpl sharedFolder = null;
String sfSoftkey = persistingCourse.getCourseConfig().getSharedFolderSoftkey();
if (StringHelper.containsNonWhitespace(sfSoftkey) && !CourseConfig.VALUE_EMPTY_SHAREDFOLDER_SOFTKEY.equals(sfSoftkey)) {
OLATResource sharedResource = CoreSpringFactory.getImpl(RepositoryService.class)
.loadRepositoryEntryResourceBySoftKey(sfSoftkey);
if (sharedResource != null) {
sharedFolder = SharedFolderManager.getInstance().getSharedFolder(sharedResource);
if (sharedFolder != null) {
sharedFolder.setLocalSecurityCallback(new ReadOnlyCallback());
//add local course folder's children as read/write source and any sharedfolder as subfolder
addContainer(new NamedContainerImpl("_sharedfolder", sharedFolder));
}
}
}
if (nodesContainer.getItems().size() > 0) {
addContainer(nodesContainer);
}
// add all course building blocks of type BC to a virtual folder
MergeSource nodesContainer = new MergeSource(null, "_courseelementdata");
if(identityEnv == null) {
CourseNode rootNode = persistingCourse.getRunStructure().getRootNode();
addFolderBuildingBlocks(persistingCourse, nodesContainer, rootNode);
} else {
TreeEvaluation treeEval = new TreeEvaluation();
GenericTreeModel treeModel = new GenericTreeModel();
UserCourseEnvironment userCourseEnv = new UserCourseEnvironmentImpl(identityEnv, persistingCourse.getCourseEnvironment());
CourseNode rootCn = userCourseEnv.getCourseEnvironment().getRunStructure().getRootNode();
NodeEvaluation rootNodeEval = rootCn.eval(userCourseEnv.getConditionInterpreter(), treeEval, new VisibleTreeFilter());
TreeNode treeRoot = rootNodeEval.getTreeNode();
treeModel.setRootNode(treeRoot);
addFolderBuildingBlocks(persistingCourse, nodesContainer, treeRoot);
}
if (nodesContainer.getItems().size() > 0) {
addContainer(nodesContainer);
}
}
......
......@@ -159,6 +159,7 @@ public class PersistingCourseImpl implements ICourse, OLATResourceable, Serializ
/**
* @see org.olat.course.ICourse#getCourseBasePath()
*/
@Override
public OlatRootFolderImpl getCourseBaseContainer() {
return courseRootContainer;
}
......@@ -179,7 +180,7 @@ public class PersistingCourseImpl implements ICourse, OLATResourceable, Serializ
public VFSContainer getCourseFolderContainer() {
// add local course folder's children as read/write source and any sharedfolder as subfolder
MergedCourseContainer courseFolderContainer = new MergedCourseContainer(resourceableId, getCourseTitle());
courseFolderContainer.init();
courseFolderContainer.init(this);
return courseFolderContainer;
}
......@@ -187,7 +188,7 @@ public class PersistingCourseImpl implements ICourse, OLATResourceable, Serializ
public VFSContainer getCourseFolderContainer(IdentityEnvironment identityEnv) {
// add local course folder's children as read/write source and any sharedfolder as subfolder
MergedCourseContainer courseFolderContainer = new MergedCourseContainer(resourceableId, getCourseTitle(), identityEnv);
courseFolderContainer.init();
courseFolderContainer.init(this);
return courseFolderContainer;
}
......@@ -202,6 +203,7 @@ public class PersistingCourseImpl implements ICourse, OLATResourceable, Serializ
/**
* @see org.olat.course.ICourse#getCourseTitle()
*/
@Override
public String getCourseTitle() {
if (courseTitle == null) {
synchronized (courseTitleSyncObj) { //o_clusterOK by:ld/se
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment