use of org.olat.core.util.vfs.callbacks.ReadOnlyCallback in project openolat by klemens.
the class MergedCourseContainer method getBCContainer.
private VFSContainer getBCContainer(ICourse course, BCCourseNode bcNode, NodeEvaluation nodeEval, boolean isOlatAdmin) {
bcNode.updateModuleConfigDefaults(false);
// add folder not to merge source. Use name and node id to have unique name
VFSContainer rootFolder = null;
String subpath = bcNode.getModuleConfiguration().getStringValue(BCCourseNodeEditController.CONFIG_SUBPATH);
if (StringHelper.containsNonWhitespace(subpath)) {
if (bcNode.isSharedFolder()) {
// grab any shared folder that is configured
OlatRootFolderImpl sharedFolder = null;
String sfSoftkey = course.getCourseConfig().getSharedFolderSoftkey();
if (StringHelper.containsNonWhitespace(sfSoftkey) && !CourseConfig.VALUE_EMPTY_SHAREDFOLDER_SOFTKEY.equals(sfSoftkey)) {
RepositoryManager rm = RepositoryManager.getInstance();
RepositoryEntry re = rm.lookupRepositoryEntryBySoftkey(sfSoftkey, false);
if (re != null) {
sharedFolder = SharedFolderManager.getInstance().getSharedFolder(re.getOlatResource());
VFSContainer courseBase = sharedFolder;
subpath = subpath.replaceFirst("/_sharedfolder", "");
rootFolder = (VFSContainer) courseBase.resolve(subpath);
if (rootFolder != null && (course.getCourseConfig().isSharedFolderReadOnlyMount() || courseReadOnly)) {
rootFolder.setLocalSecurityCallback(new ReadOnlyCallback());
}
}
}
} else {
VFSContainer courseBase = course.getCourseBaseContainer();
rootFolder = (VFSContainer) courseBase.resolve("/coursefolder" + subpath);
}
}
if (bcNode.getModuleConfiguration().getBooleanSafe(BCCourseNodeEditController.CONFIG_AUTO_FOLDER)) {
String path = BCCourseNode.getFoldernodePathRelToFolderBase(course.getCourseEnvironment(), bcNode);
rootFolder = new OlatRootFolderImpl(path, null);
if (nodeEval != null) {
rootFolder.setLocalSecurityCallback(new FolderNodeCallback(path, nodeEval, isOlatAdmin, false, null));
} else {
VFSSecurityCallback secCallback = VFSManager.findInheritedSecurityCallback(this);
if (secCallback != null) {
rootFolder.setLocalSecurityCallback(new OverrideQuotaSecurityCallback(path, secCallback));
}
}
}
return rootFolder;
}
use of org.olat.core.util.vfs.callbacks.ReadOnlyCallback in project openolat by klemens.
the class MergedCourseContainer method addFoldersForAdmin.
/**
* Internal method to recursively add all course building blocks of type
* BC to a given VFS container. This should only be used for an author view,
* it does not test for security.
*
* @param course
* @param nodesContainer
* @param courseNode
* @return container for the current course node
*/
private void addFoldersForAdmin(PersistingCourseImpl course, MergeSource nodesContainer, CourseNode courseNode) {
for (int i = 0; i < courseNode.getChildCount(); i++) {
CourseNode child = (CourseNode) courseNode.getChildAt(i);
String folderName = RequestUtil.normalizeFilename(child.getShortTitle());
if (child instanceof BCCourseNode) {
final BCCourseNode bcNode = (BCCourseNode) child;
// add folder not to merge source. Use name and node id to have unique name
VFSContainer rootFolder = getBCContainer(course, bcNode, null, true);
if (courseReadOnly) {
rootFolder.setLocalSecurityCallback(new ReadOnlyCallback());
}
folderName = getFolderName(nodesContainer, bcNode, folderName);
if (rootFolder != null) {
// Create a container for this node content and wrap it with a merge source which is attached to tree
VFSContainer nodeContentContainer = new NamedContainerImpl(folderName, rootFolder);
MergeSource courseNodeContainer = new MergeSource(nodesContainer, folderName);
courseNodeContainer.addContainersChildren(nodeContentContainer, true);
nodesContainer.addContainer(courseNodeContainer);
// Do recursion for all children
addFoldersForAdmin(course, courseNodeContainer, child);
}
} else if (child instanceof PFCourseNode) {
final PFCourseNode pfNode = (PFCourseNode) child;
// add folder not to merge source. Use name and node id to have unique name
PFManager pfManager = CoreSpringFactory.getImpl(PFManager.class);
folderName = getFolderName(nodesContainer, pfNode, folderName);
MergeSource courseNodeContainer = new MergeSource(nodesContainer, folderName);
VFSContainer rootFolder = pfManager.provideAdminContainer(pfNode, course.getCourseEnvironment());
VFSContainer nodeContentContainer = new NamedContainerImpl(folderName, rootFolder);
courseNodeContainer.addContainersChildren(nodeContentContainer, true);
nodesContainer.addContainer(courseNodeContainer);
// Do recursion for all children
addFoldersForAdmin(course, courseNodeContainer, child);
} else {
// For non-folder course nodes, add merge source (no files to show) ...
MergeSource courseNodeContainer = new MergeSource(null, folderName);
// , then do recursion for all children ...
addFoldersForAdmin(course, courseNodeContainer, child);
// ... but only add this container if it contains any children with at least one BC course node
if (!courseNodeContainer.getItems().isEmpty()) {
nodesContainer.addContainer(courseNodeContainer);
}
}
}
}
use of org.olat.core.util.vfs.callbacks.ReadOnlyCallback in project openolat by klemens.
the class BCCourseNodeEditController method doOpenFolder.
private void doOpenFolder(UserRequest ureq) {
VFSContainer namedContainer = null;
if (bcNode.getModuleConfiguration().getBooleanSafe(CONFIG_AUTO_FOLDER)) {
OlatNamedContainerImpl directory = BCCourseNode.getNodeFolderContainer(bcNode, course.getCourseEnvironment());
directory.setLocalSecurityCallback(getSecurityCallbackWithQuota(directory.getRelPath()));
namedContainer = directory;
} else {
VFSContainer courseContainer = course.getCourseFolderContainer();
String path = bcNode.getModuleConfiguration().getStringValue(CONFIG_SUBPATH, "");
VFSItem pathItem = courseContainer.resolve(path);
if (pathItem instanceof VFSContainer) {
namedContainer = (VFSContainer) pathItem;
if (bcNode.isSharedFolder()) {
if (course.getCourseConfig().isSharedFolderReadOnlyMount()) {
namedContainer.setLocalSecurityCallback(new ReadOnlyCallback());
} else {
String relPath = BCCourseNode.getNodeFolderContainer(bcNode, course.getCourseEnvironment()).getRelPath();
namedContainer.setLocalSecurityCallback(getSecurityCallbackWithQuota(relPath));
}
} else {
VFSContainer inheritingContainer = VFSManager.findInheritingSecurityCallbackContainer(namedContainer);
if (inheritingContainer != null && inheritingContainer.getLocalSecurityCallback() != null && inheritingContainer.getLocalSecurityCallback().getQuota() != null) {
Quota quota = inheritingContainer.getLocalSecurityCallback().getQuota();
namedContainer.setLocalSecurityCallback(new FullAccessWithQuotaCallback(quota));
} else {
namedContainer.setLocalSecurityCallback(new ReadOnlyCallback());
}
}
}
}
folderCtrl = new FolderRunController(namedContainer, false, ureq, getWindowControl());
listenTo(folderCtrl);
cmc = new CloseableModalController(getWindowControl(), translate("close"), folderCtrl.getInitialComponent());
listenTo(cmc);
cmc.activate();
}
use of org.olat.core.util.vfs.callbacks.ReadOnlyCallback in project openolat by klemens.
the class ReturnboxController method initReturnbox.
protected void initReturnbox(UserRequest ureq, WindowControl wControl, CourseNode node, UserCourseEnvironment userCourseEnv, boolean previewMode) {
// returnbox display
myContent = createVelocityContainer("returnbox");
OlatRootFolderImpl rootFolder = new OlatRootFolderImpl(getReturnboxPathFor(userCourseEnv.getCourseEnvironment(), node, ureq.getIdentity()), null);
String fullName = StringHelper.escapeHtml(userManager.getUserDisplayName(getIdentity()));
OlatNamedContainerImpl namedContainer = new OlatNamedContainerImpl(fullName, rootFolder);
namedContainer.setLocalSecurityCallback(new ReadOnlyCallback());
returnboxFolderRunController = new FolderRunController(namedContainer, false, ureq, wControl);
returnboxFolderRunController.addControllerListener(this);
myContent.put("returnbox", returnboxFolderRunController.getInitialComponent());
// notification
if (!previewMode && !ureq.getUserSession().getRoles().isGuestOnly()) {
// offer subscription, but not to guests
subsContext = ReturnboxFileUploadNotificationHandler.getSubscriptionContext(userCourseEnv.getCourseEnvironment(), node, ureq.getIdentity());
if (subsContext != null) {
contextualSubscriptionCtr = AbstractTaskNotificationHandler.createContextualSubscriptionController(ureq, wControl, getReturnboxPathFor(userCourseEnv.getCourseEnvironment(), node, ureq.getIdentity()), subsContext, ReturnboxController.class);
myContent.put("subscription", contextualSubscriptionCtr.getInitialComponent());
myContent.contextPut("hasNotification", Boolean.TRUE);
}
} else {
myContent.contextPut("hasNotification", Boolean.FALSE);
}
putInitialPanel(myContent);
}
use of org.olat.core.util.vfs.callbacks.ReadOnlyCallback in project openolat by klemens.
the class DocumentPoolMainController method doSelectTemplatesDirectory.
private DocumentDirectoryController doSelectTemplatesDirectory(UserRequest ureq, TaxonomyTreeNode node) {
content.popUpToRootController(ureq);
VFSContainer directory = node.getDirectory();
VFSSecurityCallback secCallback = isTaxonomyAdmin ? new FullAccessCallback() : new ReadOnlyCallback();
directory.setLocalSecurityCallback(secCallback);
String name = translate("document.pool.templates");
OLATResourceable ores = OresHelper.createOLATResourceableInstance("Templates", 0l);
WindowControl bwControl = addToHistory(ureq, ores, null);
DocumentDirectoryController directoryCtrl = new DocumentDirectoryController(ureq, bwControl, directory, name);
directoryCtrl.setAdditionalResourceURL("[Templates:0]");
listenTo(directoryCtrl);
content.pushController(name, directoryCtrl);
return directoryCtrl;
}
Aggregations