Search in sources :

Example 96 with OlatRootFolderImpl

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

the class ForumHelper method getArchiveContainer.

public static final VFSContainer getArchiveContainer(UserRequest ureq, Forum forum) {
    VFSContainer container = new OlatRootFolderImpl(FolderConfig.getUserHomes() + File.separator + ureq.getIdentity().getName() + "/private/archive", null);
    // append export timestamp to avoid overwriting previous export
    DateFormat formatter = new SimpleDateFormat("yyyy-MM-dd'T'HH_mm_ss");
    String folder = "forum_" + forum.getKey().toString() + "_" + formatter.format(new Date());
    VFSItem vfsItem = container.resolve(folder);
    if (vfsItem == null || !(vfsItem instanceof VFSContainer)) {
        vfsItem = container.createChildContainer(folder);
    }
    container = (VFSContainer) vfsItem;
    return container;
}
Also used : OlatRootFolderImpl(org.olat.core.commons.modules.bc.vfs.OlatRootFolderImpl) VFSContainer(org.olat.core.util.vfs.VFSContainer) SimpleDateFormat(java.text.SimpleDateFormat) DateFormat(java.text.DateFormat) VFSItem(org.olat.core.util.vfs.VFSItem) SimpleDateFormat(java.text.SimpleDateFormat) Date(java.util.Date)

Example 97 with OlatRootFolderImpl

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

the class BCCourseNode method getNodeFolderContainer.

/**
 * Get a named container of a node with the node title as its name.
 * @param node
 * @param courseEnv
 * @return
 */
public static OlatNamedContainerImpl getNodeFolderContainer(BCCourseNode node, CourseEnvironment courseEnv) {
    String path = getFoldernodePathRelToFolderBase(courseEnv, node);
    OlatRootFolderImpl rootFolder = new OlatRootFolderImpl(path, null);
    OlatNamedContainerImpl namedFolder = new OlatNamedContainerImpl(node.getShortTitle(), rootFolder);
    return namedFolder;
}
Also used : OlatNamedContainerImpl(org.olat.core.commons.modules.bc.vfs.OlatNamedContainerImpl) OlatRootFolderImpl(org.olat.core.commons.modules.bc.vfs.OlatRootFolderImpl)

Example 98 with OlatRootFolderImpl

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

the class ConvertToGTACourseNode method convertReturnbox.

private void convertReturnbox(TaskList taskList, TACourseNode sourceNode, GTACourseNode gtaNode, CourseEnvironment courseEnv) {
    String returnbox = ReturnboxController.getReturnboxPathRelToFolderRoot(courseEnv, sourceNode);
    OlatRootFolderImpl returnContainer = new OlatRootFolderImpl(returnbox, null);
    for (VFSItem item : returnContainer.getItems()) {
        if (item instanceof VFSContainer) {
            VFSContainer userContainer = (VFSContainer) item;
            String username = userContainer.getName();
            Identity assessedIdentity = securityManager.findIdentityByName(username);
            if (assessedIdentity != null) {
                VFSContainer correctionContainer = gtaManager.getCorrectionContainer(courseEnv, gtaNode, assessedIdentity);
                boolean returned = false;
                for (VFSItem returnedItem : userContainer.getItems()) {
                    if (returnedItem instanceof VFSLeaf) {
                        VFSLeaf correctionDocument = correctionContainer.createChildLeaf(returnedItem.getName());
                        VFSManager.copyContent((VFSLeaf) returnedItem, correctionDocument);
                        convertMetada(userContainer, correctionContainer, returnedItem.getName(), null, null);
                        returned = true;
                    }
                }
                if (returned) {
                    setTaskStatus(taskList, assessedIdentity, TaskProcess.grading, gtaNode);
                }
            }
        }
    }
}
Also used : VFSLeaf(org.olat.core.util.vfs.VFSLeaf) OlatRootFolderImpl(org.olat.core.commons.modules.bc.vfs.OlatRootFolderImpl) VFSContainer(org.olat.core.util.vfs.VFSContainer) VFSItem(org.olat.core.util.vfs.VFSItem) Identity(org.olat.core.id.Identity)

Example 99 with OlatRootFolderImpl

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

the class ConvertToGTACourseNode method convertDropbox.

private void convertDropbox(TaskList taskList, TACourseNode sourceNode, GTACourseNode gtaNode, CourseEnvironment courseEnv) {
    String dropbox = DropboxController.getDropboxPathRelToFolderRoot(courseEnv, sourceNode);
    OlatRootFolderImpl dropboxContainer = new OlatRootFolderImpl(dropbox, null);
    for (VFSItem userDropbox : dropboxContainer.getItems()) {
        if (userDropbox instanceof VFSContainer) {
            VFSContainer userDropContainer = (VFSContainer) userDropbox;
            String username = userDropContainer.getName();
            Identity assessedIdentity = securityManager.findIdentityByName(username);
            if (assessedIdentity != null) {
                VFSContainer sumbitContainer = gtaManager.getSubmitContainer(courseEnv, gtaNode, assessedIdentity);
                boolean dropped = false;
                for (VFSItem dropppedItem : userDropContainer.getItems()) {
                    if (dropppedItem instanceof VFSLeaf) {
                        VFSLeaf submittedDocument = sumbitContainer.createChildLeaf(dropppedItem.getName());
                        VFSManager.copyContent((VFSLeaf) dropppedItem, submittedDocument);
                        convertMetada(userDropContainer, sumbitContainer, dropppedItem.getName(), null, null);
                        dropped = true;
                    }
                }
                if (dropped) {
                    setTaskStatus(taskList, assessedIdentity, TaskProcess.submit, gtaNode);
                }
            }
        }
    }
}
Also used : VFSLeaf(org.olat.core.util.vfs.VFSLeaf) OlatRootFolderImpl(org.olat.core.commons.modules.bc.vfs.OlatRootFolderImpl) VFSContainer(org.olat.core.util.vfs.VFSContainer) VFSItem(org.olat.core.util.vfs.VFSItem) Identity(org.olat.core.id.Identity)

Example 100 with OlatRootFolderImpl

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

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)

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