use of org.olat.modules.wiki.Wiki in project OpenOLAT by OpenOLAT.
the class WikiCourseNode method archiveNodeData.
@Override
public boolean archiveNodeData(Locale locale, ICourse course, ArchiveOptions options, ZipOutputStream exportStream, String charset) {
String repoRef = (String) getModuleConfiguration().get("reporef");
OLATResourceable ores = RepositoryManager.getInstance().lookupRepositoryEntryBySoftkey(repoRef, true).getOlatResource();
Wiki wiki = WikiManager.getInstance().getOrLoadWiki(ores);
if (wiki.getAllPagesWithContent().isEmpty()) {
return false;
}
// OK, there is something to archive
String currentPath = "wiki_" + StringHelper.transformDisplayNameToFileSystemName(getShortName()) + "_" + Formatter.formatDatetimeFilesystemSave(new Date(System.currentTimeMillis()));
VFSContainer container = WikiManager.getInstance().getWikiContainer(ores, WikiManager.WIKI_RESOURCE_FOLDER_NAME);
if (container != null) {
// the container could be null if the wiki is an old empty one - so nothing to archive
try {
VFSContainer parent = container.getParentContainer();
WikiToZipUtils.wikiToZip(parent, currentPath, exportStream);
} catch (IOException e) {
log.error("", e);
}
}
return true;
}
use of org.olat.modules.wiki.Wiki in project openolat by klemens.
the class OlatWikiDataHandler method lookupTopic.
/**
* @see org.jamwiki.DataHandler#lookupTopic(java.lang.String,
* java.lang.String, boolean, java.lang.Object)
*/
public Topic lookupTopic(String virtualWiki, String topicName, boolean deleteOK, Object transactionObject) throws Exception {
String decodedName = null;
Wiki wiki = WikiManager.getInstance().getOrLoadWiki(ores);
try {
decodedName = URLDecoder.decode(topicName, "utf-8");
} catch (UnsupportedEncodingException e) {
//
}
if (log.isDebug()) {
log.debug("page name not normalized: " + topicName);
log.debug("page name normalized: " + FilterUtil.normalizeWikiLink(topicName));
try {
log.debug("page name urldecoded name: " + URLDecoder.decode(topicName, "utf-8"));
log.debug("page name urldecoded and normalized: " + FilterUtil.normalizeWikiLink(URLDecoder.decode(topicName, "utf-8")));
log.debug("page name urldecoded normalized and transformed to id: " + wiki.generatePageId(FilterUtil.normalizeWikiLink(decodedName)));
} catch (UnsupportedEncodingException e) {
//
}
}
Topic topic = new Topic();
if (decodedName.startsWith(IMAGE_NAMESPACE)) {
String imageName = topicName.substring(IMAGE_NAMESPACE.length());
if (!wiki.mediaFileExists(imageName))
return null;
topic.setName(imageName);
topic.setTopicType(Topic.TYPE_IMAGE);
return topic;
} else if (decodedName.startsWith(MEDIA_NAMESPACE)) {
String mediaName = topicName.substring(MEDIA_NAMESPACE.length(), topicName.length());
if (!wiki.mediaFileExists(mediaName))
return null;
topic.setName(mediaName);
topic.setTopicType(Topic.TYPE_FILE);
return topic;
}
if (wiki.pageExists(wiki.generatePageId(FilterUtil.normalizeWikiLink(decodedName)))) {
topic.setName(topicName);
return topic;
}
return null;
}
use of org.olat.modules.wiki.Wiki in project openolat by klemens.
the class WikiCourseNodeIndexer method doIndex.
@Override
public void doIndex(SearchResourceContext repositoryResourceContext, ICourse course, CourseNode courseNode, OlatFullIndexer indexWriter) {
String repoEntryName = "*name not available*";
try {
SearchResourceContext courseNodeResourceContext = createSearchResourceContext(repositoryResourceContext, courseNode, TYPE);
Document nodeDocument = CourseNodeDocument.createDocument(courseNodeResourceContext, courseNode);
indexWriter.addDocument(nodeDocument);
RepositoryEntry repositoryEntry = courseNode.getReferencedRepositoryEntry();
if (repositoryEntry == null)
return;
repoEntryName = repositoryEntry.getDisplayname();
Wiki wiki = WikiManager.getInstance().getOrLoadWiki(repositoryEntry.getOlatResource());
// loop over all wiki pages
List<WikiPage> wikiPageList = wiki.getAllPagesWithContent();
for (WikiPage wikiPage : wikiPageList) {
try {
courseNodeResourceContext.setFilePath(wikiPage.getPageName());
Document document = WikiPageDocument.createDocument(courseNodeResourceContext, wikiPage);
indexWriter.addDocument(document);
} catch (Exception e) {
log.error("Error indexing wiki page:" + (wikiPage == null ? "null" : wikiPage.getPageName()), e);
}
}
} catch (Exception e) {
log.error("Error indexing wiki:" + repoEntryName, e);
}
}
use of org.olat.modules.wiki.Wiki in project openolat by klemens.
the class WikiCourseNode method archiveNodeData.
@Override
public boolean archiveNodeData(Locale locale, ICourse course, ArchiveOptions options, ZipOutputStream exportStream, String charset) {
String repoRef = (String) getModuleConfiguration().get("reporef");
OLATResourceable ores = RepositoryManager.getInstance().lookupRepositoryEntryBySoftkey(repoRef, true).getOlatResource();
Wiki wiki = WikiManager.getInstance().getOrLoadWiki(ores);
if (wiki.getAllPagesWithContent().isEmpty()) {
return false;
}
// OK, there is something to archive
String currentPath = "wiki_" + StringHelper.transformDisplayNameToFileSystemName(getShortName()) + "_" + Formatter.formatDatetimeFilesystemSave(new Date(System.currentTimeMillis()));
VFSContainer container = WikiManager.getInstance().getWikiContainer(ores, WikiManager.WIKI_RESOURCE_FOLDER_NAME);
if (container != null) {
// the container could be null if the wiki is an old empty one - so nothing to archive
try {
VFSContainer parent = container.getParentContainer();
WikiToZipUtils.wikiToZip(parent, currentPath, exportStream);
} catch (IOException e) {
log.error("", e);
}
}
return true;
}
Aggregations