Search in sources :

Example 1 with DialogElementsManager

use of org.olat.course.nodes.dialog.DialogElementsManager 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 2 with DialogElementsManager

use of org.olat.course.nodes.dialog.DialogElementsManager 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 3 with DialogElementsManager

use of org.olat.course.nodes.dialog.DialogElementsManager in project OpenOLAT by OpenOLAT.

the class DialogCourseNode method cleanupOnDelete.

/**
 * life cycle of node data e.g properties stuff should be deleted if node gets
 * deleted life cycle: create - delete - migrate
 */
@Override
public void cleanupOnDelete(ICourse course) {
    super.cleanupOnDelete(course);
    DialogElementsManager depm = CoreSpringFactory.getImpl(DialogElementsManager.class);
    RepositoryEntry entry = course.getCourseEnvironment().getCourseGroupManager().getCourseEntry();
    List<DialogElement> dialogElements = depm.getDialogElements(entry, getIdent());
    for (DialogElement dialogElement : dialogElements) {
        Long forumKey = dialogElement.getForum().getKey();
        SubscriptionContext subsContext = CourseModule.createSubscriptionContext(course.getCourseEnvironment(), this, forumKey.toString());
        NotificationsManager.getInstance().delete(subsContext);
        depm.deleteDialogElement(dialogElement);
    }
}
Also used : DialogElement(org.olat.course.nodes.dialog.DialogElement) RepositoryEntry(org.olat.repository.RepositoryEntry) SubscriptionContext(org.olat.core.commons.services.notifications.SubscriptionContext) DialogElementsManager(org.olat.course.nodes.dialog.DialogElementsManager)

Example 4 with DialogElementsManager

use of org.olat.course.nodes.dialog.DialogElementsManager 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 DialogElementsManager

use of org.olat.course.nodes.dialog.DialogElementsManager 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

DialogElementsManager (org.olat.course.nodes.dialog.DialogElementsManager)10 VFSContainer (org.olat.core.util.vfs.VFSContainer)6 VFSLeafFilter (org.olat.core.util.vfs.filters.VFSLeafFilter)6 Date (java.util.Date)4 Document (org.apache.lucene.document.Document)4 VFSItem (org.olat.core.util.vfs.VFSItem)4 DialogElement (org.olat.course.nodes.dialog.DialogElement)4 ForumArchiveManager (org.olat.modules.fo.archiver.ForumArchiveManager)4 ForumFormatter (org.olat.modules.fo.archiver.formatters.ForumFormatter)4 RepositoryEntry (org.olat.repository.RepositoryEntry)4 CourseNodeDocument (org.olat.search.service.document.CourseNodeDocument)4 ForumMessageDocument (org.olat.search.service.document.ForumMessageDocument)4 IOException (java.io.IOException)2 SubscriptionContext (org.olat.core.commons.services.notifications.SubscriptionContext)2 LocalFolderImpl (org.olat.core.util.vfs.LocalFolderImpl)2 VFSLeaf (org.olat.core.util.vfs.VFSLeaf)2 FullAccessCallback (org.olat.core.util.vfs.callbacks.FullAccessCallback)2 Forum (org.olat.modules.fo.Forum)2 ForumRTFFormatter (org.olat.modules.fo.archiver.formatters.ForumRTFFormatter)2 ForumStreamedRTFFormatter (org.olat.modules.fo.archiver.formatters.ForumStreamedRTFFormatter)2