Search in sources :

Example 56 with OlatRootFolderImpl

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

the class CheckboxManagerImpl method getFileContainer.

@Override
public VFSContainer getFileContainer(CourseEnvironment courseEnv, CheckListCourseNode cNode) {
    String path = courseEnv.getCourseBaseContainer().getRelPath() + "/" + CheckListCourseNode.FOLDER_NAME + "/" + cNode.getIdent();
    OlatRootFolderImpl rootFolder = new OlatRootFolderImpl(path, null);
    return rootFolder;
}
Also used : OlatRootFolderImpl(org.olat.core.commons.modules.bc.vfs.OlatRootFolderImpl)

Example 57 with OlatRootFolderImpl

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

the class ProjectDetailsDisplayController method doFileDelivery.

private void doFileDelivery(UserRequest ureq, final Project project, final CourseEnvironment courseEnv, final CourseNode cNode) {
    // Create a mapper to deliver the auto-download of the file. We have to
    // create a dedicated mapper here
    // and can not reuse the standard briefcase way of file delivering, some
    // very old fancy code
    // Mapper is cleaned up automatically by basic controller
    OlatRootFolderImpl rootFolder = new OlatRootFolderImpl(projectBrokerManager.getAttamchmentRelativeRootPath(project, courseEnv, cNode), null);
    VFSItem item = rootFolder.resolve(project.getAttachmentFileName());
    if (item instanceof VFSLeaf) {
        VFSLeaf attachment = (VFSLeaf) item;
        MediaResource resource = new VFSMediaResource(attachment);
        ureq.getDispatchResult().setResultingMediaResource(resource);
    }
}
Also used : VFSLeaf(org.olat.core.util.vfs.VFSLeaf) OlatRootFolderImpl(org.olat.core.commons.modules.bc.vfs.OlatRootFolderImpl) VFSItem(org.olat.core.util.vfs.VFSItem) MediaResource(org.olat.core.gui.media.MediaResource) VFSMediaResource(org.olat.core.util.vfs.VFSMediaResource) VFSMediaResource(org.olat.core.util.vfs.VFSMediaResource)

Example 58 with OlatRootFolderImpl

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

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 59 with OlatRootFolderImpl

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

the class ProjectBrokerManagerImpl method deleteAllDropboxFilesOfProject.

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

Example 60 with OlatRootFolderImpl

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

the class PFManager method getLastUpdated.

/**
 * Gets the last updated file for each participant.
 *
 * @param courseEnv
 * @param pfNode
 * @param identity
 * @return the last updated file as Date
 */
private Date getLastUpdated(CourseEnvironment courseEnv, PFCourseNode pfNode, Identity identity, String fileName) {
    Date latest = null;
    List<Long> lastUpdated = new ArrayList<>();
    OlatRootFolderImpl baseContainer = courseEnv.getCourseBaseContainer();
    Path path = Paths.get(baseContainer.getBasefile().toPath().toString(), FILENAME_PARTICIPANTFOLDER, pfNode.getIdent(), getIdFolderName(identity), fileName);
    try {
        Files.walkFileTree(path, new SimpleFileVisitor<Path>() {

            @Override
            public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) throws IOException {
                lastUpdated.add(attrs.lastModifiedTime().toMillis());
                return FileVisitResult.CONTINUE;
            }
        });
    } catch (IOException e) {
        log.error("Unknown IOE", e);
    }
    Collections.sort(lastUpdated);
    if (lastUpdated.size() > 0) {
        latest = new Date(lastUpdated.get(lastUpdated.size() - 1));
    }
    return latest;
}
Also used : Path(java.nio.file.Path) OlatRootFolderImpl(org.olat.core.commons.modules.bc.vfs.OlatRootFolderImpl) ArrayList(java.util.ArrayList) FileVisitResult(java.nio.file.FileVisitResult) IOException(java.io.IOException) Date(java.util.Date) BasicFileAttributes(java.nio.file.attribute.BasicFileAttributes)

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