use of org.olat.core.util.vfs.NamedContainerImpl in project openolat by klemens.
the class SimpleVersionConfig method versionEnabled.
public boolean versionEnabled(VFSContainer container) {
int versionsAllowed = getVersionAllowed();
if (versionsAllowed == 0) {
return false;
}
if (container instanceof NamedContainerImpl) {
container = ((NamedContainerImpl) container).getDelegate();
}
if (container instanceof MergeSource) {
container = ((MergeSource) container).getRootWriteContainer();
}
if (container instanceof LocalFolderImpl) {
try {
LocalFolderImpl folderImpl = (LocalFolderImpl) container;
String path = folderImpl.getBasefile().getCanonicalPath();
List<String> excludedRoots = getExcludedRoots();
for (String excludedRoot : excludedRoots) {
if (path.startsWith(excludedRoot)) {
return false;
}
}
String root = getCourseRoot();
if (path.startsWith(root)) {
for (String exclusion : EXCLUSIONS_IN_COURSE_PATH) {
if (path.indexOf(exclusion) > 0) {
return false;
}
}
}
return getVersionAllowed() != 0;
} catch (IOException e) {
// fail silently;
}
}
return false;
}
use of org.olat.core.util.vfs.NamedContainerImpl in project openolat by klemens.
the class PFManager method provideAdminContainer.
/**
* Provide admin view for webdav, contains all participants of the course.
*
* @param pfNode the pf node
* @param courseEnv the course env
* @return the VFS container
*/
public VFSContainer provideAdminContainer(PFCourseNode pfNode, CourseEnvironment courseEnv) {
Translator translator = Util.createPackageTranslator(PFRunController.class, I18nModule.getDefaultLocale());
SubscriptionContext nodefolderSubContext = CourseModule.createSubscriptionContext(courseEnv, pfNode);
RepositoryEntry re = courseEnv.getCourseGroupManager().getCourseEntry();
List<Identity> participants = repositoryEntryRelationDao.getMembers(re, RepositoryEntryRelationType.both, GroupRoles.participant.name());
participants = new ArrayList<>(new HashSet<>(participants));
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);
participantFolder.setParentContainer(namedCourseFolder);
namedCourseFolder.addItem(participantFolder);
if (pfNode.hasParticipantBoxConfigured()) {
VFSContainer dropContainer = new NamedContainerImpl(translator.translate("drop.box"), VFSManager.resolveOrCreateContainerFromPath(userBaseContainer, FILENAME_DROPBOX));
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.NamedContainerImpl in project openolat by klemens.
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.NamedContainerImpl in project openolat by klemens.
the class QTIEditorPackageImpl method getBaseDir.
@Override
public VFSContainer getBaseDir() {
VFSContainer localDir = new LocalFolderImpl(packageDir);
if (secCallback != null) {
localDir.setLocalSecurityCallback(secCallback);
}
String dirName = translator.translate("qti.basedir.displayname");
NamedContainerImpl namedBaseDir = new NamedContainerImpl(dirName, localDir);
return namedBaseDir;
}
use of org.olat.core.util.vfs.NamedContainerImpl in project openolat by klemens.
the class DocumentPoolWebDAVMergeSource method addDocument.
private VFSContainer addDocument(TaxonomyTreeNode taxonomyNode) {
VFSContainer documents = taxonomyService.getDocumentsLibrary(taxonomyNode.getTaxonomyLevel());
SubscriptionContext subscriptionCtx = notificationsHandler.getTaxonomyDocumentsLibrarySubscriptionContext();
TaxonomyVFSSecurityCallback secCallback = new TaxonomyVFSSecurityCallback(taxonomyNode, subscriptionCtx);
documents.setLocalSecurityCallback(secCallback);
return new NamedContainerImpl("_documents", documents);
}
Aggregations