Search in sources :

Example 36 with OlatRootFolderImpl

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

the class ProjectBrokerManagerImpl method deleteAllAttachmentFilesOfProject.

private void deleteAllAttachmentFilesOfProject(Project project, CourseEnvironment courseEnv, CourseNode cNode) {
    VFSContainer attachmentDir = new OlatRootFolderImpl(getAttamchmentRelativeRootPath(project, courseEnv, cNode), null);
    attachmentDir.delete();
    logDebug("deleteAllAttachmentFilesOfProject path=" + attachmentDir);
}
Also used : OlatRootFolderImpl(org.olat.core.commons.modules.bc.vfs.OlatRootFolderImpl) VFSContainer(org.olat.core.util.vfs.VFSContainer)

Example 37 with OlatRootFolderImpl

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

the class ProjectBrokerManagerImpl method saveAttachedFile.

public void saveAttachedFile(Project project, String fileName, VFSLeaf uploadedItem, CourseEnvironment courseEnv, CourseNode cNode) {
    logDebug("saveAttachedFile file-name=" + uploadedItem.getName());
    OlatRootFolderImpl uploadVFSContainer = new OlatRootFolderImpl(getAttamchmentRelativeRootPath(project, courseEnv, cNode), null);
    logDebug("saveAttachedFile uploadVFSContainer.relPath=" + uploadVFSContainer.getRelPath());
    // only one attachment, delete other file
    for (Iterator<VFSItem> iterator = uploadVFSContainer.getItems().iterator(); iterator.hasNext(); ) {
        VFSItem item = iterator.next();
        // Project.getAttachmentFileName is the previous file-name, will not be deleted; student could have open detail-project page with previous attachemnt-link
        if (!item.getName().equals(project.getAttachmentFileName())) {
            item.delete();
        }
    }
    VFSLeaf newFile = (VFSLeaf) uploadVFSContainer.resolve(fileName);
    if (newFile == null) {
        newFile = uploadVFSContainer.createChildLeaf(fileName);
    }
    BufferedInputStream in = new BufferedInputStream(uploadedItem.getInputStream());
    BufferedOutputStream out = new BufferedOutputStream(newFile.getOutputStream(false));
    boolean success = false;
    if (in != null) {
        success = FileUtils.copy(in, out);
    }
    FileUtils.closeSafely(in);
    FileUtils.closeSafely(out);
    logDebug("saveAttachedFile success=" + success);
}
Also used : VFSLeaf(org.olat.core.util.vfs.VFSLeaf) OlatRootFolderImpl(org.olat.core.commons.modules.bc.vfs.OlatRootFolderImpl) BufferedInputStream(java.io.BufferedInputStream) VFSItem(org.olat.core.util.vfs.VFSItem) BufferedOutputStream(java.io.BufferedOutputStream)

Example 38 with OlatRootFolderImpl

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

the class ForumRTFFormatter method makeTempVFSContainer.

/**
 * Generates a new temporary VFSContainer.
 * @return the temp container.
 */
private VFSContainer makeTempVFSContainer() {
    Long forumKey = getForumKey();
    String dateStamp = String.valueOf(System.currentTimeMillis());
    // TODO: (LD) could this filename regarded as unique or use System.nanoTime() instead?
    String fileName = "forum" + forumKey.toString() + "_" + dateStamp;
    LocalFolderImpl tempFolder = new OlatRootFolderImpl("/tmp/" + fileName, null);
    return tempFolder;
}
Also used : OlatRootFolderImpl(org.olat.core.commons.modules.bc.vfs.OlatRootFolderImpl) LocalFolderImpl(org.olat.core.util.vfs.LocalFolderImpl)

Example 39 with OlatRootFolderImpl

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

the class FeedManagerImpl method getQuota.

@Override
public Quota getQuota(OLATResourceable feed) {
    OlatRootFolderImpl container = feedFileStorage.getResourceContainer(feed);
    Quota quota = QuotaManager.getInstance().getCustomQuota(container.getRelPath());
    if (quota == null) {
        Quota defQuota = QuotaManager.getInstance().getDefaultQuota(QuotaConstants.IDENTIFIER_DEFAULT_FEEDS);
        quota = QuotaManager.getInstance().createQuota(container.getRelPath(), defQuota.getQuotaKB(), defQuota.getUlLimitKB());
    }
    return quota;
}
Also used : OlatRootFolderImpl(org.olat.core.commons.modules.bc.vfs.OlatRootFolderImpl) Quota(org.olat.core.util.vfs.Quota)

Example 40 with OlatRootFolderImpl

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

the class ForumManager method getForumContainer.

public VFSContainer getForumContainer(Long forumKey) {
    OlatRootFolderImpl fContainer = new OlatRootFolderImpl("/forum", null);
    VFSItem forumContainer = fContainer.resolve(forumKey.toString());
    if (forumContainer == null) {
        return fContainer.createChildContainer(forumKey.toString());
    } else if (forumContainer instanceof VFSContainer) {
        return (VFSContainer) forumContainer;
    }
    log.error("The following forum container is not a directory: " + forumContainer);
    return null;
}
Also used : OlatRootFolderImpl(org.olat.core.commons.modules.bc.vfs.OlatRootFolderImpl) VFSContainer(org.olat.core.util.vfs.VFSContainer) VFSItem(org.olat.core.util.vfs.VFSItem)

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