Search in sources :

Example 1 with Topic

use of org.jamwiki.model.Topic in project openolat by klemens.

the class StaticExportWikiDataHandler 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 {
    Topic topic = new Topic();
    if (topicName.startsWith("Image:")) {
        // TODO:gs:b now about the german "Bild"
        String imageName = topicName.substring(NamespaceHandler.NAMESPACE_IMAGE.length() + 1);
        topic.setName(imageName);
        topic.setTopicType(Topic.TYPE_IMAGE);
        return topic;
    }
    topic.setName(topicName);
    return topic;
}
Also used : Topic(org.jamwiki.model.Topic)

Example 2 with Topic

use of org.jamwiki.model.Topic 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;
}
Also used : Wiki(org.olat.modules.wiki.Wiki) UnsupportedEncodingException(java.io.UnsupportedEncodingException) Topic(org.jamwiki.model.Topic)

Example 3 with Topic

use of org.jamwiki.model.Topic in project OpenOLAT by OpenOLAT.

the class StaticExportWikiDataHandler 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 {
    Topic topic = new Topic();
    if (topicName.startsWith("Image:")) {
        // TODO:gs:b now about the german "Bild"
        String imageName = topicName.substring(NamespaceHandler.NAMESPACE_IMAGE.length() + 1);
        topic.setName(imageName);
        topic.setTopicType(Topic.TYPE_IMAGE);
        return topic;
    }
    topic.setName(topicName);
    return topic;
}
Also used : Topic(org.jamwiki.model.Topic)

Example 4 with Topic

use of org.jamwiki.model.Topic 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;
}
Also used : Wiki(org.olat.modules.wiki.Wiki) UnsupportedEncodingException(java.io.UnsupportedEncodingException) Topic(org.jamwiki.model.Topic)

Aggregations

Topic (org.jamwiki.model.Topic)4 UnsupportedEncodingException (java.io.UnsupportedEncodingException)2 Wiki (org.olat.modules.wiki.Wiki)2