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);
}
}
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);
}
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);
}
}
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);
}
}
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);
}
Aggregations