Search in sources :

Example 1 with VFSLeafFilter

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

the class VersionsFileManager method getDeletedFiles.

@Override
public List<Versions> getDeletedFiles(VFSContainer container) {
    List<Versions> deletedRevisions = new ArrayList<Versions>();
    VFSContainer versionContainer = getCanonicalVersionFolder(container, false);
    if (versionContainer != null) {
        Set<String> currentNames = new HashSet<String>();
        for (VFSItem item : container.getItems(new VFSLeafFilter())) {
            currentNames.add(item.getName() + ".xml");
        }
        List<VFSItem> versionItems = versionContainer.getItems(new VFSItemSuffixFilter(new String[] { "xml" }));
        for (VFSItem versionItem : versionItems) {
            String name = versionItem.getName();
            if (versionItem instanceof VFSLeaf && !currentNames.contains(name) && isVersionsXmlFile((VFSLeaf) versionItem)) {
                Versions versions = readVersions(null, (VFSLeaf) versionItem);
                if (versions != null) {
                    List<VFSRevision> revisions = versions.getRevisions();
                    if (!revisions.isEmpty()) {
                        deletedRevisions.add(versions);
                    }
                }
            }
        }
    }
    return deletedRevisions;
}
Also used : VFSLeaf(org.olat.core.util.vfs.VFSLeaf) VFSItemSuffixFilter(org.olat.core.util.vfs.filters.VFSItemSuffixFilter) VFSContainer(org.olat.core.util.vfs.VFSContainer) ArrayList(java.util.ArrayList) VFSItem(org.olat.core.util.vfs.VFSItem) HashSet(java.util.HashSet) VFSLeafFilter(org.olat.core.util.vfs.filters.VFSLeafFilter)

Example 2 with VFSLeafFilter

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

the class DialogCourseNodeIndexer method doIndexFile.

/**
 * Index a file of dialog-module.
 * @param filename
 * @param forumKey
 * @param leafResourceContext
 * @param indexWriter
 * @throws IOException
 * @throws InterruptedException
 */
private void doIndexFile(DialogElement element, SearchResourceContext leafResourceContext, OlatFullIndexer indexWriter) throws IOException, InterruptedException {
    DialogElementsManager dialogElmsMgr = CoreSpringFactory.getImpl(DialogElementsManager.class);
    VFSContainer dialogContainer = dialogElmsMgr.getDialogContainer(element);
    VFSLeaf leaf = (VFSLeaf) dialogContainer.getItems(new VFSLeafFilter()).get(0);
    if (isLogDebugEnabled())
        logDebug("Analyse VFSLeaf=" + leaf.getName());
    try {
        if (CoreSpringFactory.getImpl(FileDocumentFactory.class).isFileSupported(leaf)) {
            leafResourceContext.setFilePath(element.getFilename());
            leafResourceContext.setDocumentType(TYPE_FILE);
            Document document = CoreSpringFactory.getImpl(FileDocumentFactory.class).createDocument(leafResourceContext, leaf);
            indexWriter.addDocument(document);
        } else {
            if (isLogDebugEnabled())
                logDebug("Documenttype not supported. file=" + leaf.getName());
        }
    } catch (DocumentAccessException e) {
        if (isLogDebugEnabled())
            logDebug("Can not access document." + e.getMessage());
    } catch (IOException ioEx) {
        logWarn("IOException: Can not index leaf=" + leaf.getName(), ioEx);
    } catch (InterruptedException iex) {
        throw new InterruptedException(iex.getMessage());
    } catch (Exception ex) {
        logWarn("Exception: Can not index leaf=" + leaf.getName(), ex);
    }
}
Also used : VFSLeaf(org.olat.core.util.vfs.VFSLeaf) VFSContainer(org.olat.core.util.vfs.VFSContainer) IOException(java.io.IOException) DialogElementsManager(org.olat.course.nodes.dialog.DialogElementsManager) Document(org.apache.lucene.document.Document) ForumMessageDocument(org.olat.search.service.document.ForumMessageDocument) CourseNodeDocument(org.olat.search.service.document.CourseNodeDocument) FileDocumentFactory(org.olat.search.service.document.file.FileDocumentFactory) IOException(java.io.IOException) DocumentAccessException(org.olat.search.service.document.file.DocumentAccessException) VFSLeafFilter(org.olat.core.util.vfs.filters.VFSLeafFilter) DocumentAccessException(org.olat.search.service.document.file.DocumentAccessException)

Example 3 with VFSLeafFilter

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

the class DialogCourseNode method doArchiveElement.

/**
 * Archive a single dialog element with files and forum
 * @param element
 * @param exportDirectory
 */
public void doArchiveElement(DialogElement element, File exportDirectory, Locale locale) {
    DialogElementsManager depm = CoreSpringFactory.getImpl(DialogElementsManager.class);
    VFSContainer dialogContainer = depm.getDialogContainer(element);
    // there is only one file (leave) in the top forum container
    VFSItem dialogFile = dialogContainer.getItems(new VFSLeafFilter()).get(0);
    VFSContainer exportContainer = new LocalFolderImpl(exportDirectory);
    // append export timestamp to avoid overwriting previous export
    String exportDirName = Formatter.makeStringFilesystemSave(getShortTitle()) + "_" + element.getForum().getKey() + "_" + Formatter.formatDatetimeFilesystemSave(new Date(System.currentTimeMillis()));
    VFSContainer diaNodeElemExportContainer = exportContainer.createChildContainer(exportDirName);
    // don't check quota
    diaNodeElemExportContainer.setLocalSecurityCallback(new FullAccessCallback());
    diaNodeElemExportContainer.copyFrom(dialogFile);
    ForumArchiveManager fam = ForumArchiveManager.getInstance();
    ForumFormatter ff = new ForumRTFFormatter(diaNodeElemExportContainer, false, locale);
    fam.applyFormatter(ff, element.getForum().getKey(), null);
}
Also used : ForumFormatter(org.olat.modules.fo.archiver.formatters.ForumFormatter) FullAccessCallback(org.olat.core.util.vfs.callbacks.FullAccessCallback) ForumArchiveManager(org.olat.modules.fo.archiver.ForumArchiveManager) ForumRTFFormatter(org.olat.modules.fo.archiver.formatters.ForumRTFFormatter) VFSContainer(org.olat.core.util.vfs.VFSContainer) VFSItem(org.olat.core.util.vfs.VFSItem) DialogElementsManager(org.olat.course.nodes.dialog.DialogElementsManager) Date(java.util.Date) VFSLeafFilter(org.olat.core.util.vfs.filters.VFSLeafFilter) LocalFolderImpl(org.olat.core.util.vfs.LocalFolderImpl)

Example 4 with VFSLeafFilter

use of org.olat.core.util.vfs.filters.VFSLeafFilter in project openolat by klemens.

the class DialogCourseNodeIndexer method doIndexFile.

/**
 * Index a file of dialog-module.
 * @param filename
 * @param forumKey
 * @param leafResourceContext
 * @param indexWriter
 * @throws IOException
 * @throws InterruptedException
 */
private void doIndexFile(DialogElement element, SearchResourceContext leafResourceContext, OlatFullIndexer indexWriter) throws IOException, InterruptedException {
    DialogElementsManager dialogElmsMgr = CoreSpringFactory.getImpl(DialogElementsManager.class);
    VFSContainer dialogContainer = dialogElmsMgr.getDialogContainer(element);
    VFSLeaf leaf = (VFSLeaf) dialogContainer.getItems(new VFSLeafFilter()).get(0);
    if (isLogDebugEnabled())
        logDebug("Analyse VFSLeaf=" + leaf.getName());
    try {
        if (CoreSpringFactory.getImpl(FileDocumentFactory.class).isFileSupported(leaf)) {
            leafResourceContext.setFilePath(element.getFilename());
            leafResourceContext.setDocumentType(TYPE_FILE);
            Document document = CoreSpringFactory.getImpl(FileDocumentFactory.class).createDocument(leafResourceContext, leaf);
            indexWriter.addDocument(document);
        } else {
            if (isLogDebugEnabled())
                logDebug("Documenttype not supported. file=" + leaf.getName());
        }
    } catch (DocumentAccessException e) {
        if (isLogDebugEnabled())
            logDebug("Can not access document." + e.getMessage());
    } catch (IOException ioEx) {
        logWarn("IOException: Can not index leaf=" + leaf.getName(), ioEx);
    } catch (InterruptedException iex) {
        throw new InterruptedException(iex.getMessage());
    } catch (Exception ex) {
        logWarn("Exception: Can not index leaf=" + leaf.getName(), ex);
    }
}
Also used : VFSLeaf(org.olat.core.util.vfs.VFSLeaf) VFSContainer(org.olat.core.util.vfs.VFSContainer) IOException(java.io.IOException) DialogElementsManager(org.olat.course.nodes.dialog.DialogElementsManager) Document(org.apache.lucene.document.Document) ForumMessageDocument(org.olat.search.service.document.ForumMessageDocument) CourseNodeDocument(org.olat.search.service.document.CourseNodeDocument) FileDocumentFactory(org.olat.search.service.document.file.FileDocumentFactory) IOException(java.io.IOException) DocumentAccessException(org.olat.search.service.document.file.DocumentAccessException) VFSLeafFilter(org.olat.core.util.vfs.filters.VFSLeafFilter) DocumentAccessException(org.olat.search.service.document.file.DocumentAccessException)

Example 5 with VFSLeafFilter

use of org.olat.core.util.vfs.filters.VFSLeafFilter in project openolat by klemens.

the class DialogCourseNode method doArchiveElement.

/**
 * Archive a single dialog element with files and forum
 * @param element
 * @param exportDirectory
 */
public void doArchiveElement(DialogElement element, File exportDirectory, Locale locale) {
    DialogElementsManager depm = CoreSpringFactory.getImpl(DialogElementsManager.class);
    VFSContainer dialogContainer = depm.getDialogContainer(element);
    // there is only one file (leave) in the top forum container
    VFSItem dialogFile = dialogContainer.getItems(new VFSLeafFilter()).get(0);
    VFSContainer exportContainer = new LocalFolderImpl(exportDirectory);
    // append export timestamp to avoid overwriting previous export
    String exportDirName = Formatter.makeStringFilesystemSave(getShortTitle()) + "_" + element.getForum().getKey() + "_" + Formatter.formatDatetimeFilesystemSave(new Date(System.currentTimeMillis()));
    VFSContainer diaNodeElemExportContainer = exportContainer.createChildContainer(exportDirName);
    // don't check quota
    diaNodeElemExportContainer.setLocalSecurityCallback(new FullAccessCallback());
    diaNodeElemExportContainer.copyFrom(dialogFile);
    ForumArchiveManager fam = ForumArchiveManager.getInstance();
    ForumFormatter ff = new ForumRTFFormatter(diaNodeElemExportContainer, false, locale);
    fam.applyFormatter(ff, element.getForum().getKey(), null);
}
Also used : ForumFormatter(org.olat.modules.fo.archiver.formatters.ForumFormatter) FullAccessCallback(org.olat.core.util.vfs.callbacks.FullAccessCallback) ForumArchiveManager(org.olat.modules.fo.archiver.ForumArchiveManager) ForumRTFFormatter(org.olat.modules.fo.archiver.formatters.ForumRTFFormatter) VFSContainer(org.olat.core.util.vfs.VFSContainer) VFSItem(org.olat.core.util.vfs.VFSItem) DialogElementsManager(org.olat.course.nodes.dialog.DialogElementsManager) Date(java.util.Date) VFSLeafFilter(org.olat.core.util.vfs.filters.VFSLeafFilter) LocalFolderImpl(org.olat.core.util.vfs.LocalFolderImpl)

Aggregations

VFSLeafFilter (org.olat.core.util.vfs.filters.VFSLeafFilter)14 VFSContainer (org.olat.core.util.vfs.VFSContainer)12 VFSItem (org.olat.core.util.vfs.VFSItem)12 VFSLeaf (org.olat.core.util.vfs.VFSLeaf)10 DialogElementsManager (org.olat.course.nodes.dialog.DialogElementsManager)6 ArrayList (java.util.ArrayList)4 Date (java.util.Date)4 ForumArchiveManager (org.olat.modules.fo.archiver.ForumArchiveManager)4 ForumFormatter (org.olat.modules.fo.archiver.formatters.ForumFormatter)4 IOException (java.io.IOException)2 HashSet (java.util.HashSet)2 Document (org.apache.lucene.document.Document)2 LocalFolderImpl (org.olat.core.util.vfs.LocalFolderImpl)2 VFSMediaResource (org.olat.core.util.vfs.VFSMediaResource)2 FullAccessCallback (org.olat.core.util.vfs.callbacks.FullAccessCallback)2 VFSItemSuffixFilter (org.olat.core.util.vfs.filters.VFSItemSuffixFilter)2 ForumRTFFormatter (org.olat.modules.fo.archiver.formatters.ForumRTFFormatter)2 ForumStreamedRTFFormatter (org.olat.modules.fo.archiver.formatters.ForumStreamedRTFFormatter)2 CourseNodeDocument (org.olat.search.service.document.CourseNodeDocument)2 ForumMessageDocument (org.olat.search.service.document.ForumMessageDocument)2