use of org.olat.modules.wiki.Wiki in project openolat by klemens.
the class WikiArtefactHandler method prefillArtefactAccordingToSource.
/**
* @see org.olat.portfolio.EPAbstractHandler#prefillArtefactAccordingToSource(org.olat.portfolio.model.artefacts.AbstractArtefact, java.lang.Object)
*/
@Override
public void prefillArtefactAccordingToSource(AbstractArtefact artefact, Object source) {
super.prefillArtefactAccordingToSource(artefact, source);
WikiPage page = null;
OLATResourceable ores = null;
if (source instanceof OLATResourceable) {
ores = (OLATResourceable) source;
// fxdiff: FXOLAT-148 a wiki from a businessgroup needs to be wrapped accordingly!
if (artefact.getBusinessPath().contains(BusinessGroup.class.getSimpleName())) {
ores = OresHelper.createOLATResourceableInstance(BusinessGroup.class, ores.getResourceableId());
}
Wiki wiki = WikiManager.getInstance().getOrLoadWiki(ores);
String pageName = getPageName(artefact.getBusinessPath());
page = wiki.getPage(pageName, true);
} else if (source instanceof WikiPage) {
page = (WikiPage) source;
}
if (page != null) {
artefact.setSource(getSourceInfo(artefact.getBusinessPath(), ores));
artefact.setTitle(page.getPageName());
artefact.setFulltextContent(page.getContent());
artefact.setSignature(70);
}
}
use of org.olat.modules.wiki.Wiki in project openolat by klemens.
the class OlatWikiDataHandler method exists.
/**
* @see org.jamwiki.DataHandler#exists(java.lang.String, java.lang.String)
*/
public boolean exists(String virtualWiki, String topic) {
if (!StringUtils.hasText(topic)) {
return false;
}
if (PseudoTopicHandler.isPseudoTopic(topic)) {
return true;
}
if (InterWikiHandler.isInterWiki(topic)) {
return true;
}
// try {
// Utilities.validateTopicName(topic);
// } catch (WikiException e) {
// throw new OLATRuntimeException(this.getClass(), "invalid topic name!", e);
// }
Wiki wiki = WikiManager.getInstance().getOrLoadWiki(ores);
if (topic.startsWith(IMAGE_NAMESPACE) || topic.startsWith(MEDIA_NAMESPACE)) {
return wiki.pageExists(topic);
}
String pageId = WikiManager.generatePageId(FilterUtil.normalizeWikiLink(topic));
return wiki.pageExists(pageId);
}
use of org.olat.modules.wiki.Wiki in project OpenOLAT by OpenOLAT.
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 OpenOLAT.
the class WikiArtefactHandler method prefillArtefactAccordingToSource.
/**
* @see org.olat.portfolio.EPAbstractHandler#prefillArtefactAccordingToSource(org.olat.portfolio.model.artefacts.AbstractArtefact, java.lang.Object)
*/
@Override
public void prefillArtefactAccordingToSource(AbstractArtefact artefact, Object source) {
super.prefillArtefactAccordingToSource(artefact, source);
WikiPage page = null;
OLATResourceable ores = null;
if (source instanceof OLATResourceable) {
ores = (OLATResourceable) source;
// fxdiff: FXOLAT-148 a wiki from a businessgroup needs to be wrapped accordingly!
if (artefact.getBusinessPath().contains(BusinessGroup.class.getSimpleName())) {
ores = OresHelper.createOLATResourceableInstance(BusinessGroup.class, ores.getResourceableId());
}
Wiki wiki = WikiManager.getInstance().getOrLoadWiki(ores);
String pageName = getPageName(artefact.getBusinessPath());
page = wiki.getPage(pageName, true);
} else if (source instanceof WikiPage) {
page = (WikiPage) source;
}
if (page != null) {
artefact.setSource(getSourceInfo(artefact.getBusinessPath(), ores));
artefact.setTitle(page.getPageName());
artefact.setFulltextContent(page.getContent());
artefact.setSignature(70);
}
}
use of org.olat.modules.wiki.Wiki in project OpenOLAT by OpenOLAT.
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);
}
}
Aggregations