use of org.olat.core.util.vfs.NamedContainerImpl in project openolat by klemens.
the class BCCourseNodeIndexer method doIndex.
@Override
public void doIndex(SearchResourceContext repositoryResourceContext, ICourse course, CourseNode courseNode, OlatFullIndexer indexWriter) throws IOException, InterruptedException {
if (isLogDebugEnabled())
logDebug("Index Briefcase...");
BCCourseNode bcNode = (BCCourseNode) courseNode;
SearchResourceContext courseNodeResourceContext = createSearchResourceContext(repositoryResourceContext, bcNode, TYPE);
Document document = CourseNodeDocument.createDocument(courseNodeResourceContext, bcNode);
indexWriter.addDocument(document);
VFSContainer bcContainer = null;
if (bcNode.getModuleConfiguration().getBooleanSafe(BCCourseNodeEditController.CONFIG_AUTO_FOLDER)) {
bcContainer = BCCourseNode.getNodeFolderContainer(bcNode, course.getCourseEnvironment());
} else {
String subpath = courseNode.getModuleConfiguration().getStringValue(BCCourseNodeEditController.CONFIG_SUBPATH);
if (subpath != null) {
VFSItem item = course.getCourseEnvironment().getCourseFolderContainer().resolve(subpath);
if (item instanceof VFSContainer) {
bcContainer = new NamedContainerImpl(courseNode.getShortTitle(), (VFSContainer) item);
}
}
}
if (bcContainer != null) {
doIndexVFSContainer(courseNodeResourceContext, bcContainer, indexWriter, "", FolderIndexerAccess.FULL_ACCESS);
}
}
use of org.olat.core.util.vfs.NamedContainerImpl in project openolat by klemens.
the class GroupfoldersWebDAVMergeSource method getGroupContainer.
private VFSContainer getGroupContainer(String name, BusinessGroup group, boolean isOwner) {
String folderPath = collaborationManager.getFolderRelPath(group);
// create container and set quota
OlatRootFolderImpl localImpl = new OlatRootFolderImpl(folderPath, this);
// already done in OlatRootFolderImpl localImpl.getBasefile().mkdirs(); // lazy initialize dirs
String containerName = RequestUtil.normalizeFilename(name);
NamedContainerImpl grpContainer = new GroupNamedContainer(containerName, localImpl);
boolean writeAccess;
if (!isOwner) {
// check if participants have read/write access
int folderAccess = CollaborationTools.FOLDER_ACCESS_ALL;
Long lFolderAccess = collaborationManager.lookupFolderAccess(group);
if (lFolderAccess != null) {
folderAccess = lFolderAccess.intValue();
}
writeAccess = (folderAccess == CollaborationTools.FOLDER_ACCESS_ALL);
} else {
writeAccess = true;
}
VFSSecurityCallback secCallback;
if (writeAccess) {
SubscriptionContext sc = new SubscriptionContext(group, "toolfolder");
secCallback = new FullAccessWithLazyQuotaCallback(folderPath, QuotaConstants.IDENTIFIER_DEFAULT_GROUPS, sc);
} else {
secCallback = new ReadOnlyCallback();
}
grpContainer.setLocalSecurityCallback(secCallback);
return grpContainer;
}
use of org.olat.core.util.vfs.NamedContainerImpl in project openolat by klemens.
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.NamedContainerImpl in project openolat by klemens.
the class MergedCourseContainer method initSharedFolder.
/**
* Grab any shared folder that is configured, but only when in unchecked
* security mode (no identity environment) or when the user has course
* admin rights
*
* @param persistingCourse
*/
private void initSharedFolder(PersistingCourseImpl persistingCourse) {
CourseConfig courseConfig = persistingCourse.getCourseConfig();
String sfSoftkey = courseConfig.getSharedFolderSoftkey();
if (StringHelper.containsNonWhitespace(sfSoftkey) && !CourseConfig.VALUE_EMPTY_SHAREDFOLDER_SOFTKEY.equals(sfSoftkey)) {
RepositoryEntry re = persistingCourse.getCourseEnvironment().getCourseGroupManager().getCourseEntry();
if (identityEnv == null || identityEnv.getRoles().isOLATAdmin() || RepositoryManager.getInstance().isOwnerOfRepositoryEntry(identityEnv.getIdentity(), re)) {
OLATResource sharedResource = CoreSpringFactory.getImpl(RepositoryService.class).loadRepositoryEntryResourceBySoftKey(sfSoftkey);
if (sharedResource != null) {
OlatRootFolderImpl sharedFolder = SharedFolderManager.getInstance().getSharedFolder(sharedResource);
if (sharedFolder != null) {
if (courseConfig.isSharedFolderReadOnlyMount() || courseReadOnly) {
sharedFolder.setLocalSecurityCallback(new ReadOnlyCallback());
}
// add local course folder's children as read/write source and any sharedfolder as subfolder
addContainer(new NamedContainerImpl("_sharedfolder", sharedFolder));
}
}
}
}
}
use of org.olat.core.util.vfs.NamedContainerImpl in project openolat by klemens.
the class CoursefolderWebDAVMergeSource method appendCourses.
private void appendCourses(List<RepositoryEntry> courseEntries, boolean editor, List<VFSContainer> containers, boolean useTerms, Map<String, VFSContainer> terms, VirtualContainer noTermContainer, VirtualContainer finishedContainer, boolean prependReference, UniqueNames container) {
// Add all found repo entries to merge source
int count = 0;
for (RepositoryEntry re : courseEntries) {
if (container.isDuplicate(re)) {
continue;
}
String displayName = re.getDisplayname();
if (prependReference && StringHelper.containsNonWhitespace(re.getExternalRef())) {
displayName = re.getExternalRef() + " " + displayName;
}
String courseTitle = RequestUtil.normalizeFilename(displayName);
if (finishedContainer != null && re.getRepositoryEntryStatus().isClosed()) {
String name = container.getFinishedUniqueName(courseTitle);
NamedContainerImpl cfContainer = new CoursefolderWebDAVNamedContainer(name, re, editor ? null : identityEnv);
finishedContainer.getItems().add(cfContainer);
} else if (useTerms) {
RepositoryEntryLifecycle lc = re.getLifecycle();
if (lc != null && !lc.isPrivateCycle()) {
// when a semester term info is found, add it to corresponding term folder
String termSoftKey = lc.getSoftKey();
VFSContainer termContainer = terms.get(termSoftKey);
if (termContainer == null) {
// folder for this semester term does not yet exist, create one and add to map
String normalizedKey = RequestUtil.normalizeFilename(termSoftKey);
termContainer = new VirtualContainer(normalizedKey);
terms.put(termSoftKey, termContainer);
addContainerToList(termContainer, containers);
}
String name = container.getTermUniqueName(termSoftKey, courseTitle);
NamedContainerImpl cfContainer = new CoursefolderWebDAVNamedContainer(name, re, editor ? null : identityEnv);
termContainer.getItems().add(cfContainer);
} else {
// no semester term found, add to no-term folder
String name = container.getNoTermUniqueName(courseTitle);
NamedContainerImpl cfContainer = new CoursefolderWebDAVNamedContainer(name, re, editor ? null : identityEnv);
noTermContainer.getItems().add(cfContainer);
}
} else {
String name = container.getContainersUniqueName(courseTitle);
NamedContainerImpl cfContainer = new CoursefolderWebDAVNamedContainer(name, re, editor ? null : identityEnv);
addContainerToList(cfContainer, containers);
}
if (++count % 5 == 0) {
DBFactory.getInstance().commitAndCloseSession();
}
}
}
Aggregations