use of org.olat.core.util.vfs.VirtualContainer in project openolat by klemens.
the class DocumentPoolWebDAVMergeSource method loadRecursiveMergedContainers.
private VFSContainer loadRecursiveMergedContainers(Taxonomy taxonomy, INode node) {
VFSContainer container = null;
if (node instanceof TaxonomyTreeNode) {
TaxonomyTreeNode taxonomyNode = (TaxonomyTreeNode) node;
String name = RequestUtil.normalizeFilename(taxonomyNode.getTitle());
VirtualContainer levelContainer = new VirtualContainer(name);
levelContainer.setLocalSecurityCallback(new DefaultVFSSecurityCallback());
boolean hasDocuments = false;
if (taxonomyNode.getType() == TaxonomyTreeNodeType.templates) {
// the templates
return addTemplates(taxonomyNode, taxonomy);
} else if (taxonomyNode.getTaxonomyLevel() != null && taxonomyNode.isDocumentsLibraryEnabled() && taxonomyNode.isCanRead()) {
// the real thing
levelContainer.addItem(addDocument(taxonomyNode));
hasDocuments = true;
}
for (int i = 0; i < node.getChildCount(); i++) {
VFSContainer childContainer = loadRecursiveMergedContainers(taxonomy, node.getChildAt(i));
if (childContainer != null) {
levelContainer.addItem(childContainer);
hasDocuments = true;
}
}
container = hasDocuments ? levelContainer : null;
}
return container;
}
use of org.olat.core.util.vfs.VirtualContainer in project openolat by klemens.
the class WebDAVManagerImpl method getWebDAVRoot.
@Override
public WebResourceRoot getWebDAVRoot(HttpServletRequest req) {
UserSession usess = getUserSession(req);
if (usess == null || usess.getIdentity() == null) {
return createEmptyRoot(usess);
}
usess.getSessionInfo().setLastClickTime();
VFSResourceRoot fdc = (VFSResourceRoot) usess.getEntry("_DIRCTX");
if (fdc != null) {
return fdc;
}
IdentityEnvironment identityEnv = usess.getIdentityEnvironment();
VFSContainer webdavContainer = getMountableRoot(identityEnv);
// create the / folder
VirtualContainer rootContainer = new VirtualContainer("");
rootContainer.addItem(webdavContainer);
rootContainer.setLocalSecurityCallback(new ReadOnlyCallback());
fdc = new VFSResourceRoot(identityEnv.getIdentity(), rootContainer);
usess.putEntry("_DIRCTX", fdc);
return fdc;
}
use of org.olat.core.util.vfs.VirtualContainer in project openolat by klemens.
the class WebDAVManagerImpl method createEmptyRoot.
private WebResourceRoot createEmptyRoot(UserSession usess) {
// create the / folder
VirtualContainer rootContainer = new VirtualContainer("");
rootContainer.setLocalSecurityCallback(new ReadOnlyCallback());
return new VFSResourceRoot(usess.getIdentity(), rootContainer);
}
use of org.olat.core.util.vfs.VirtualContainer in project OpenOLAT by OpenOLAT.
the class PFManager method provideCoachContainer.
/**
* Provide coach view in webdav.
*
* @param pfNode
* @param courseEnv
* @param identity
* @return the VFSContainer
*/
private VFSContainer provideCoachContainer(PFCourseNode pfNode, CourseEnvironment courseEnv, Identity identity, boolean admin) {
Locale locale = I18nManager.getInstance().getLocaleOrDefault(identity.getUser().getPreferences().getLanguage());
Translator translator = Util.createPackageTranslator(PFRunController.class, locale);
SubscriptionContext nodefolderSubContext = CourseModule.createSubscriptionContext(courseEnv, pfNode);
List<Identity> participants = getParticipants(identity, courseEnv, admin);
String path = courseEnv.getCourseBaseContainer().getRelPath() + "/" + FILENAME_PARTICIPANTFOLDER;
VFSContainer courseElementBaseContainer = new OlatRootFolderImpl(path, null);
VirtualContainer namedCourseFolder = new VirtualContainer(translator.translate("participant.folder"));
for (Identity participant : participants) {
Path relPath = Paths.get(pfNode.getIdent(), getIdFolderName(participant));
VFSContainer userBaseContainer = VFSManager.resolveOrCreateContainerFromPath(courseElementBaseContainer, relPath.toString());
String participantfoldername = userManager.getUserDisplayName(participant);
VirtualContainer participantFolder = new VirtualContainer(participantfoldername);
namedCourseFolder.addItem(participantFolder);
if (pfNode.hasParticipantBoxConfigured()) {
VFSContainer dropContainer = new NamedContainerImpl(translator.translate("drop.box"), VFSManager.resolveOrCreateContainerFromPath(userBaseContainer, FILENAME_DROPBOX));
// if coach is also participant, can user his/her webdav folder with participant rights
if (identity.equals(participant)) {
VFSContainer dropbox = resolveOrCreateDropFolder(courseEnv, pfNode, identity);
VFSSecurityCallback callback = calculateCallback(courseEnv, pfNode, dropbox, true);
dropContainer.setLocalSecurityCallback(callback);
} else {
dropContainer.setLocalSecurityCallback(new ReadOnlyCallback(nodefolderSubContext));
}
participantFolder.addItem(dropContainer);
}
if (pfNode.hasCoachBoxConfigured()) {
VFSContainer returnContainer = new NamedContainerImpl(translator.translate("return.box"), VFSManager.resolveOrCreateContainerFromPath(userBaseContainer, FILENAME_RETURNBOX));
returnContainer.setLocalSecurityCallback(new ReadWriteDeleteCallback(nodefolderSubContext));
participantFolder.addItem(returnContainer);
}
}
return namedCourseFolder;
}
use of org.olat.core.util.vfs.VirtualContainer in project OpenOLAT by OpenOLAT.
the class WebDAVManagerImpl method getWebDAVRoot.
@Override
public WebResourceRoot getWebDAVRoot(HttpServletRequest req) {
UserSession usess = getUserSession(req);
if (usess == null || usess.getIdentity() == null) {
return createEmptyRoot(usess);
}
usess.getSessionInfo().setLastClickTime();
VFSResourceRoot fdc = (VFSResourceRoot) usess.getEntry("_DIRCTX");
if (fdc != null) {
return fdc;
}
IdentityEnvironment identityEnv = usess.getIdentityEnvironment();
VFSContainer webdavContainer = getMountableRoot(identityEnv);
// create the / folder
VirtualContainer rootContainer = new VirtualContainer("");
rootContainer.addItem(webdavContainer);
rootContainer.setLocalSecurityCallback(new ReadOnlyCallback());
fdc = new VFSResourceRoot(identityEnv.getIdentity(), rootContainer);
usess.putEntry("_DIRCTX", fdc);
return fdc;
}
Aggregations