Search in sources :

Example 46 with OlatRootFolderImpl

use of org.olat.core.commons.modules.bc.vfs.OlatRootFolderImpl in project OpenOLAT by OpenOLAT.

the class DropboxController method getUploadLimit.

/**
 * Get upload limit for dropbox of a certain user. The upload can be limited
 * by available-folder space, max folder size or configurated upload-limit.
 * @param ureq
 * @return max upload limit in KB
 */
private int getUploadLimit() {
    String dropboxPath = getRelativeDropBoxFilePath(getIdentity());
    Quota dropboxQuota = QuotaManager.getInstance().getCustomQuota(dropboxPath);
    if (dropboxQuota == null) {
        dropboxQuota = QuotaManager.getInstance().getDefaultQuota(QuotaConstants.IDENTIFIER_DEFAULT_NODES);
    }
    OlatRootFolderImpl rootFolder = new OlatRootFolderImpl(getRelativeDropBoxFilePath(getIdentity()), null);
    VFSContainer dropboxContainer = new OlatNamedContainerImpl(getIdentity().getName(), rootFolder);
    FullAccessWithQuotaCallback secCallback = new FullAccessWithQuotaCallback(dropboxQuota);
    rootFolder.setLocalSecurityCallback(secCallback);
    return QuotaManager.getInstance().getUploadLimitKB(dropboxQuota.getQuotaKB(), dropboxQuota.getUlLimitKB(), dropboxContainer);
}
Also used : OlatNamedContainerImpl(org.olat.core.commons.modules.bc.vfs.OlatNamedContainerImpl) OlatRootFolderImpl(org.olat.core.commons.modules.bc.vfs.OlatRootFolderImpl) FullAccessWithQuotaCallback(org.olat.core.util.vfs.callbacks.FullAccessWithQuotaCallback) Quota(org.olat.core.util.vfs.Quota) VFSContainer(org.olat.core.util.vfs.VFSContainer)

Example 47 with OlatRootFolderImpl

use of org.olat.core.commons.modules.bc.vfs.OlatRootFolderImpl in project OpenOLAT by OpenOLAT.

the class AssessmentTestSessionDAO method getSessionStorage.

/**
 * Create a folder for a session in bcroot.
 *
 * @param session
 * @return
 */
public File getSessionStorage(AssessmentTestSession session) {
    OlatRootFolderImpl rootContainer = getQtiSerializationPath();
    File directory = new File(rootContainer.getBasefile(), session.getStorage());
    if (!directory.exists()) {
        directory.mkdirs();
    }
    return directory;
}
Also used : OlatRootFolderImpl(org.olat.core.commons.modules.bc.vfs.OlatRootFolderImpl) File(java.io.File)

Example 48 with OlatRootFolderImpl

use of org.olat.core.commons.modules.bc.vfs.OlatRootFolderImpl in project OpenOLAT by OpenOLAT.

the class OLATUpgrade_11_0_0 method processNonPropertiesTAStates.

/**
 * Find if someone dropped a file in a Task element without task assignment, or has a returned
 * document.
 *
 * @param assessableIdentities
 * @param tNode
 * @param course
 * @param courseEntry
 * @param nodeAssessmentMap
 */
private void processNonPropertiesTAStates(List<Identity> assessableIdentities, TACourseNode tNode, ICourse course, RepositoryEntry courseEntry, Map<AssessmentDataKey, AssessmentEntryImpl> nodeAssessmentMap, Map<AssessmentDataKey, AssessmentEntryImpl> curentNodeAssessmentMap) {
    for (Identity assessedIdentity : assessableIdentities) {
        AssessmentDataKey key = new AssessmentDataKey(assessedIdentity, course.getResourceableId(), tNode.getIdent());
        if (curentNodeAssessmentMap.containsKey(key)) {
            continue;
        }
        AssessmentEntryImpl nodeAssessment;
        if (!nodeAssessmentMap.containsKey(key)) {
            nodeAssessment = createAssessmentEntry(assessedIdentity, null, course, courseEntry, tNode.getIdent());
            nodeAssessmentMap.put(key, nodeAssessment);
            String dropbox = DropboxController.getDropboxPathRelToFolderRoot(course.getCourseEnvironment(), tNode) + File.separator + assessedIdentity.getName();
            OlatRootFolderImpl dropBox = new OlatRootFolderImpl(dropbox, null);
            if (dropBox.getBasefile().exists() && dropBox.getBasefile().listFiles(SystemFileFilter.FILES_ONLY).length > 0) {
                nodeAssessment.setAssessmentStatus(AssessmentEntryStatus.inProgress);
            } else {
                String returnbox = ReturnboxController.getReturnboxPathRelToFolderRoot(course.getCourseEnvironment(), tNode) + File.separator + assessedIdentity.getName();
                OlatRootFolderImpl returnBox = new OlatRootFolderImpl(returnbox, null);
                if (returnBox.getBasefile().exists() && returnBox.getBasefile().listFiles(SystemFileFilter.FILES_ONLY).length > 0) {
                    nodeAssessment.setAssessmentStatus(AssessmentEntryStatus.inProgress);
                }
            }
        }
    }
}
Also used : OlatRootFolderImpl(org.olat.core.commons.modules.bc.vfs.OlatRootFolderImpl) Identity(org.olat.core.id.Identity) TransientIdentity(org.olat.admin.user.imp.TransientIdentity) AssessmentEntryImpl(org.olat.modules.assessment.model.AssessmentEntryImpl)

Example 49 with OlatRootFolderImpl

use of org.olat.core.commons.modules.bc.vfs.OlatRootFolderImpl in project OpenOLAT by OpenOLAT.

the class OLATUpgrade_12_3_0 method moveDocumentPoolInfosPage.

private boolean moveDocumentPoolInfosPage(UpgradeManager upgradeManager, UpgradeHistoryData uhd) {
    boolean allOk = true;
    if (!uhd.getBooleanDataValue(MOVE_DOC_POOL_INFOS_PAGE)) {
        String path = "/" + TaxonomyService.DIRECTORY + "/" + DocumentPoolModule.INFOS_PAGE_DIRECTORY;
        VFSContainer taxonomyContainer = new OlatRootFolderImpl(path, null);
        VFSContainer documentPoolContainer = documentPoolModule.getInfoPageContainer();
        if (taxonomyContainer.exists() && documentPoolContainer.getItems(new VFSLeafButSystemFilter()).isEmpty() && !taxonomyContainer.getItems(new VFSLeafButSystemFilter()).isEmpty()) {
            VFSManager.copyContent(taxonomyContainer, documentPoolContainer);
            taxonomyContainer.delete();
        }
        uhd.setBooleanDataValue(MOVE_DOC_POOL_INFOS_PAGE, allOk);
        upgradeManager.setUpgradesHistory(uhd, VERSION);
    }
    return allOk;
}
Also used : OlatRootFolderImpl(org.olat.core.commons.modules.bc.vfs.OlatRootFolderImpl) VFSLeafButSystemFilter(org.olat.core.util.vfs.filters.VFSLeafButSystemFilter) VFSContainer(org.olat.core.util.vfs.VFSContainer)

Example 50 with OlatRootFolderImpl

use of org.olat.core.commons.modules.bc.vfs.OlatRootFolderImpl in project OpenOLAT by OpenOLAT.

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;
}
Also used : FullAccessWithLazyQuotaCallback(org.olat.core.util.vfs.callbacks.FullAccessWithLazyQuotaCallback) OlatRootFolderImpl(org.olat.core.commons.modules.bc.vfs.OlatRootFolderImpl) ReadOnlyCallback(org.olat.core.util.vfs.callbacks.ReadOnlyCallback) SubscriptionContext(org.olat.core.commons.services.notifications.SubscriptionContext) VFSSecurityCallback(org.olat.core.util.vfs.callbacks.VFSSecurityCallback) NamedContainerImpl(org.olat.core.util.vfs.NamedContainerImpl)

Aggregations

OlatRootFolderImpl (org.olat.core.commons.modules.bc.vfs.OlatRootFolderImpl)214 VFSContainer (org.olat.core.util.vfs.VFSContainer)86 VFSItem (org.olat.core.util.vfs.VFSItem)68 VFSLeaf (org.olat.core.util.vfs.VFSLeaf)58 Identity (org.olat.core.id.Identity)50 Test (org.junit.Test)48 File (java.io.File)36 InputStream (java.io.InputStream)30 OlatNamedContainerImpl (org.olat.core.commons.modules.bc.vfs.OlatNamedContainerImpl)28 OutputStream (java.io.OutputStream)26 VFSSecurityCallback (org.olat.core.util.vfs.callbacks.VFSSecurityCallback)24 URI (java.net.URI)22 RepositoryEntry (org.olat.repository.RepositoryEntry)22 ByteArrayInputStream (java.io.ByteArrayInputStream)20 Path (java.nio.file.Path)20 SubscriptionContext (org.olat.core.commons.services.notifications.SubscriptionContext)18 IOException (java.io.IOException)16 HttpResponse (org.apache.http.HttpResponse)14 CollaborationTools (org.olat.collaboration.CollaborationTools)14 FolderRunController (org.olat.core.commons.modules.bc.FolderRunController)14