Exemple #1
0
 @Test
 public void testConstructor() throws Throwable {
   WikiLink wikiLink = new WikiLink("/wiki", "en", null);
   assertNull("wikiLink.getQuery()", wikiLink.getQuery());
   assertNull("wikiLink.getSection()", wikiLink.getSection());
   assertNull("wikiLink.getText()", wikiLink.getText());
   assertNull("wikiLink.getArticle()", wikiLink.getArticle());
   assertEquals(
       "wikiLink.getNamespace()", Namespace.namespace(Namespace.MAIN_ID), wikiLink.getNamespace());
   assertNull("wikiLink.getDestination()", wikiLink.getDestination());
   assertFalse("wikiLink.getColon()", wikiLink.getColon());
 }
Exemple #2
0
 /**
  * Build a URL to the topic page for a given topic.
  *
  * @param context The servlet context path. If this value is <code>null</code> then the resulting
  *     URL will NOT include context path, which breaks HTML links but is useful for servlet
  *     redirection URLs.
  * @param virtualWiki The virtual wiki for the link that is being created.
  * @param wikiLink The WikiLink object containing all relevant information about the link being
  *     generated.
  * @throws DataAccessException Thrown if any error occurs while retrieving topic information.
  */
 public static String buildTopicUrl(String context, String virtualWiki, WikiLink wikiLink)
     throws DataAccessException {
   String topic = wikiLink.getDestination();
   String section = wikiLink.getSection();
   String query = wikiLink.getQuery();
   String url = LinkUtil.buildTopicUrlNoEdit(context, virtualWiki, topic, section, query);
   if (StringUtils.isBlank(topic) && !StringUtils.isBlank(section)) {
     // do not check existence for section links
     return url;
   }
   if (!LinkUtil.isExistingArticle(virtualWiki, topic)) {
     url = LinkUtil.buildEditLinkUrl(context, virtualWiki, topic, query, -1);
   }
   return url;
 }
Exemple #3
0
 /**
  * Build a URL to the topic page for a given topic.
  *
  * @param context The servlet context path. If this value is <code>null</code> then the resulting
  *     URL will NOT include context path, which breaks HTML links but is useful for servlet
  *     redirection URLs.
  * @param virtualWiki The virtual wiki for the link that is being created.
  * @param topic The topic name for the URL that is being generated.
  * @param validateTopic Set to <code>true</code> if the topic must exist and must not be a
  *     "Special:" page. If the topic does not exist then a link to an edit page will be returned.
  * @throws DataAccessException Thrown if any error occurs while retrieving topic information.
  */
 public static String buildTopicUrl(
     String context, String virtualWiki, String topic, boolean validateTopic)
     throws DataAccessException {
   if (StringUtils.isBlank(topic)) {
     return null;
   }
   WikiLink wikiLink = LinkUtil.parseWikiLink(topic);
   if (validateTopic) {
     return LinkUtil.buildTopicUrl(context, virtualWiki, wikiLink);
   } else {
     return LinkUtil.buildTopicUrlNoEdit(
         context,
         virtualWiki,
         wikiLink.getDestination(),
         wikiLink.getSection(),
         wikiLink.getQuery());
   }
 }
Exemple #4
0
 @Test
 public void testSetQuery() throws Throwable {
   WikiLink wikiLink = new WikiLink("/wiki", "en", null);
   wikiLink.setQuery("testWikiLinkQuery");
   assertEquals("wikiLink.getQuery()", "testWikiLinkQuery", wikiLink.getQuery());
 }