use of org.olat.core.util.vfs.filters.VFSLeafFilter in project openolat by klemens.
the class Wiki method getHistory.
protected List<WikiPage> getHistory(WikiPage page) {
List<WikiPage> versions = new ArrayList<>();
List<VFSItem> leafs = versionsContainer.getItems(new VFSLeafFilter());
if (leafs.size() > 0) {
for (Iterator<VFSItem> iter = leafs.iterator(); iter.hasNext(); ) {
VFSLeaf leaf = (VFSLeaf) iter.next();
String filename = leaf.getName();
// try this: List leafs = wikiCont.getItems(new VFSItemSuffixFilter(new String[]{WikiManager.WIKI_PROPERTIES_SUFFIX}));
if (filename.indexOf(WikiManager.WIKI_PROPERTIES_SUFFIX) != -1 && filename.startsWith(page.getPageId())) {
versions.add(assignPropertiesToPage(leaf));
}
}
// add also the current version but only if saved once
}
if (page.getModificationTime() > 0)
versions.add(page);
return versions;
}
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, ZipOutputStream exportStream, Locale locale) {
DialogElementsManager depm = CoreSpringFactory.getImpl(DialogElementsManager.class);
String exportDirName = Formatter.makeStringFilesystemSave(getShortTitle()) + "_" + element.getForum().getKey() + "_" + Formatter.formatDatetimeFilesystemSave(new Date());
VFSContainer forumContainer = depm.getDialogContainer(element);
for (VFSItem item : forumContainer.getItems(new VFSLeafFilter())) {
ZipUtil.addToZip(item, exportDirName, exportStream);
}
ForumArchiveManager fam = ForumArchiveManager.getInstance();
ForumFormatter ff = new ForumStreamedRTFFormatter(exportStream, exportDirName, 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 DialogElementListController method doFileDelivery.
/**
* deliver the selected file and show in a popup
*
* @param ureq
* @param command
*/
private void doFileDelivery(UserRequest ureq, DialogElement element) {
VFSContainer forumContainer = dialogElementsManager.getDialogContainer(element);
List<VFSItem> items = forumContainer.getItems(new VFSLeafFilter());
if (items.size() > 0 && items.get(0) instanceof VFSLeaf) {
VFSLeaf vl = (VFSLeaf) items.get(0);
ureq.getDispatchResult().setResultingMediaResource(new VFSMediaResource(vl));
ThreadLocalUserActivityLogger.log(CourseLoggingAction.DIALOG_ELEMENT_FILE_DOWNLOADED, getClass(), LoggingResourceable.wrapBCFile(vl.getName()));
} else {
logError("No file to discuss: " + forumContainer, null);
}
}
use of org.olat.core.util.vfs.filters.VFSLeafFilter in project openolat by klemens.
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;
}
Aggregations