use of org.olat.core.util.vfs.callbacks.ReadOnlyCallback in project OpenOLAT by OpenOLAT.
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;
}
use of org.olat.core.util.vfs.callbacks.ReadOnlyCallback in project OpenOLAT by OpenOLAT.
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 OpenOLAT.
the class MergedCourseContainer method addFolders.
private void addFolders(PersistingCourseImpl course, MergeSource nodesContainer, TreeNode courseNode) {
if (courseNode == null)
return;
for (int i = 0; i < courseNode.getChildCount(); i++) {
TreeNode child = (TreeNode) courseNode.getChildAt(i);
NodeEvaluation nodeEval;
if (child.getUserObject() instanceof NodeEvaluation) {
nodeEval = (NodeEvaluation) child.getUserObject();
} else {
continue;
}
if (nodeEval != null && nodeEval.getCourseNode() != null) {
CourseNode courseNodeChild = nodeEval.getCourseNode();
String folderName = RequestUtil.normalizeFilename(courseNodeChild.getShortTitle());
if (courseNodeChild instanceof BCCourseNode) {
final BCCourseNode bcNode = (BCCourseNode) courseNodeChild;
// add folder not to merge source. Use name and node id to have unique name
VFSContainer rootFolder = getBCContainer(course, bcNode, nodeEval, false);
boolean canDownload = nodeEval.isCapabilityAccessible("download");
if (canDownload && rootFolder != null) {
if (courseReadOnly) {
rootFolder.setLocalSecurityCallback(new ReadOnlyCallback());
} else if (nodeEval.isCapabilityAccessible("upload")) {
// inherit the security callback from the course as for author
} else {
rootFolder.setLocalSecurityCallback(new ReadOnlyCallback());
}
folderName = getFolderName(nodesContainer, bcNode, folderName);
// 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
addFolders(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 ...
addFolders(course, courseNodeContainer, child);
// ... but only add this container if it contains any children with at least one BC course node
if (courseNodeContainer.getItems().size() > 0) {
nodesContainer.addContainer(courseNodeContainer);
}
}
} else if (courseNodeChild instanceof PFCourseNode) {
final PFCourseNode pfNode = (PFCourseNode) courseNodeChild;
// 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);
UserCourseEnvironment userCourseEnv = new UserCourseEnvironmentImpl(identityEnv, course.getCourseEnvironment());
VFSContainer rootFolder = pfManager.provideCoachOrParticipantContainer(pfNode, userCourseEnv, identityEnv.getIdentity(), courseReadOnly);
VFSContainer nodeContentContainer = new NamedContainerImpl(folderName, rootFolder);
courseNodeContainer.addContainersChildren(nodeContentContainer, true);
addFolders(course, courseNodeContainer, child);
nodesContainer.addContainer(courseNodeContainer);
} 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 ...
addFolders(course, courseNodeContainer, child);
// ... but only add this container if it contains any children with at least one BC course node
if (courseNodeContainer.getItems().size() > 0) {
nodesContainer.addContainer(courseNodeContainer);
}
}
}
}
}
use of org.olat.core.util.vfs.callbacks.ReadOnlyCallback in project OpenOLAT by OpenOLAT.
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 OpenOLAT.
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();
}
Aggregations