* @param name The topic name to validate.
* @throws WikiException Thrown if the user name is invalid.
*/
public static void validateTopicName(String name) throws WikiException {
if (StringUtils.isBlank(name)) {
throw new WikiException(new WikiMessage("common.exception.notopic"));
}
if (PseudoTopicHandler.isPseudoTopic(name)) {
throw new WikiException(new WikiMessage("common.exception.pseudotopic", name));
}
WikiLink wikiLink = LinkUtil.parseWikiLink(name);
String namespace = StringUtils.trimToNull(wikiLink.getNamespace());
String article = StringUtils.trimToNull(wikiLink.getArticle());
if (StringUtils.startsWith(namespace, "/") || StringUtils.startsWith(article, "/")) {
throw new WikiException(new WikiMessage("common.exception.name", name));
}
if (namespace != null && namespace.toLowerCase().equals(NamespaceHandler.NAMESPACE_SPECIAL.toLowerCase())) {
throw new WikiException(new WikiMessage("common.exception.name", name));
}
Matcher m = WikiUtil.INVALID_TOPIC_NAME_PATTERN.matcher(name);
if (m.find()) {
throw new WikiException(new WikiMessage("common.exception.name", name));
}
}