Search in sources :

Example 81 with VFSLeaf

use of org.olat.core.util.vfs.VFSLeaf in project OpenOLAT by OpenOLAT.

the class GTASampleSolutionsEditController method updateModel.

private void updateModel() {
    List<Solution> solutionList = gtaManager.getSolutions(courseEnv, gtaNode);
    List<SolutionRow> rows = new ArrayList<>(solutionList.size());
    for (Solution solution : solutionList) {
        String filename = solution.getFilename();
        String author = null;
        VFSItem item = solutionContainer.resolve(filename);
        if (item instanceof MetaTagged) {
            MetaInfo metaInfo = ((MetaTagged) item).getMetaInfo();
            if (metaInfo != null && metaInfo.getAuthorIdentityKey() != null) {
                author = userManager.getUserDisplayName(metaInfo.getAuthorIdentityKey());
            }
        }
        DownloadLink downloadLink = null;
        if (item instanceof VFSLeaf) {
            downloadLink = uifactory.addDownloadLink("file_" + (++linkCounter), filename, null, (VFSLeaf) item, solutionTable);
        }
        rows.add(new SolutionRow(solution, author, downloadLink));
    }
    solutionModel.setObjects(rows);
    solutionTable.reset();
}
Also used : DownloadLink(org.olat.core.gui.components.form.flexible.elements.DownloadLink) VFSLeaf(org.olat.core.util.vfs.VFSLeaf) ArrayList(java.util.ArrayList) MetaTagged(org.olat.core.commons.modules.bc.meta.tagged.MetaTagged) MetaInfo(org.olat.core.commons.modules.bc.meta.MetaInfo) VFSItem(org.olat.core.util.vfs.VFSItem) Solution(org.olat.course.nodes.gta.model.Solution)

Example 82 with VFSLeaf

use of org.olat.core.util.vfs.VFSLeaf in project OpenOLAT by OpenOLAT.

the class PFPeekviewController method addItems.

private void addItems(VFSContainer container, List<VFSLeaf> allLeafs) {
    // exclude files which are also excluded in FolderComponent
    for (VFSItem vfsItem : container.getItems(attachmentExcludeFilter)) {
        if (vfsItem instanceof VFSLeaf) {
            // add leaf to our list
            VFSLeaf leaf = (VFSLeaf) vfsItem;
            allLeafs.add(leaf);
        } else if (vfsItem instanceof VFSContainer) {
            // do it recursively for all children
            VFSContainer childContainer = (VFSContainer) vfsItem;
            addItems(childContainer, allLeafs);
        } else {
        // hu?
        }
    }
}
Also used : VFSLeaf(org.olat.core.util.vfs.VFSLeaf) VFSContainer(org.olat.core.util.vfs.VFSContainer) VFSItem(org.olat.core.util.vfs.VFSItem)

Example 83 with VFSLeaf

use of org.olat.core.util.vfs.VFSLeaf in project OpenOLAT by OpenOLAT.

the class OfficeDocumentTest method testWordOpenXMLDocument.

@Test
public void testWordOpenXMLDocument() throws IOException, DocumentException, DocumentAccessException, URISyntaxException {
    URL docUrl = OfficeDocumentTest.class.getResource("Test_word_indexing.docx");
    Assert.assertNotNull(docUrl);
    VFSLeaf doc = new VFSJavaIOFile(new File(docUrl.toURI()));
    WordOOXMLDocument document = new WordOOXMLDocument();
    FileContent content = document.readContent(doc);
    Assert.assertNotNull(content);
    String body = content.getContent();
    Assert.assertTrue(body.contains("Document compatibility test"));
    Assert.assertTrue(body.contains("They prefer to start writing a document at home in desktop or laptop computer"));
}
Also used : VFSLeaf(org.olat.core.util.vfs.VFSLeaf) VFSJavaIOFile(org.olat.test.VFSJavaIOFile) File(java.io.File) URL(java.net.URL) VFSJavaIOFile(org.olat.test.VFSJavaIOFile) Test(org.junit.Test)

Example 84 with VFSLeaf

use of org.olat.core.util.vfs.VFSLeaf in project OpenOLAT by OpenOLAT.

the class OfficeDocumentTest method testPowerPointOpenXMLDocument.

@Test
public void testPowerPointOpenXMLDocument() throws IOException, DocumentException, DocumentAccessException, URISyntaxException {
    URL docUrl = OfficeDocumentTest.class.getResource("Test_ppt_indexing.pptx");
    Assert.assertNotNull(docUrl);
    VFSLeaf doc = new VFSJavaIOFile(new File(docUrl.toURI()));
    PowerPointOOXMLDocument document = new PowerPointOOXMLDocument();
    FileContent content = document.readContent(doc);
    Assert.assertNotNull(content);
    String body = content.getContent();
    Assert.assertTrue(body.contains("Here is some text"));
}
Also used : VFSLeaf(org.olat.core.util.vfs.VFSLeaf) VFSJavaIOFile(org.olat.test.VFSJavaIOFile) File(java.io.File) URL(java.net.URL) VFSJavaIOFile(org.olat.test.VFSJavaIOFile) Test(org.junit.Test)

Example 85 with VFSLeaf

use of org.olat.core.util.vfs.VFSLeaf in project OpenOLAT by OpenOLAT.

the class OfficeDocumentTest method testPowerPointDocument.

@Test
public void testPowerPointDocument() throws IOException, DocumentException, DocumentAccessException, URISyntaxException {
    URL docUrl = OfficeDocumentTest.class.getResource("Test_ppt_indexing.ppt");
    Assert.assertNotNull(docUrl);
    VFSLeaf doc = new VFSJavaIOFile(new File(docUrl.toURI()));
    PowerPointDocument document = new PowerPointDocument();
    FileContent content = document.readContent(doc);
    Assert.assertNotNull(content);
    String body = content.getContent();
    Assert.assertTrue(body.contains("Sample Powerpoint Slide"));
}
Also used : VFSLeaf(org.olat.core.util.vfs.VFSLeaf) VFSJavaIOFile(org.olat.test.VFSJavaIOFile) File(java.io.File) URL(java.net.URL) VFSJavaIOFile(org.olat.test.VFSJavaIOFile) Test(org.junit.Test)

Aggregations

VFSLeaf (org.olat.core.util.vfs.VFSLeaf)642 VFSContainer (org.olat.core.util.vfs.VFSContainer)338 VFSItem (org.olat.core.util.vfs.VFSItem)280 File (java.io.File)114 InputStream (java.io.InputStream)96 IOException (java.io.IOException)92 Test (org.junit.Test)86 ArrayList (java.util.ArrayList)72 OutputStream (java.io.OutputStream)60 MetaInfo (org.olat.core.commons.modules.bc.meta.MetaInfo)58 MetaTagged (org.olat.core.commons.modules.bc.meta.tagged.MetaTagged)58 OlatRootFolderImpl (org.olat.core.commons.modules.bc.vfs.OlatRootFolderImpl)58 Identity (org.olat.core.id.Identity)54 LocalFileImpl (org.olat.core.util.vfs.LocalFileImpl)52 VFSMediaResource (org.olat.core.util.vfs.VFSMediaResource)46 URL (java.net.URL)40 Date (java.util.Date)40 RepositoryEntry (org.olat.repository.RepositoryEntry)36 URI (java.net.URI)34 MediaResource (org.olat.core.gui.media.MediaResource)34