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