Search in sources :

Example 1 with ExtensionAuthor

use of org.xwiki.extension.repository.xwiki.model.jaxb.ExtensionAuthor in project xwiki-platform by xwiki.

the class AbstractExtensionRESTResource method resolveExtensionAuthor.

protected ExtensionAuthor resolveExtensionAuthor(String authorId) {
    ExtensionAuthor author = new ExtensionAuthor();
    XWikiContext xcontext = getXWikiContext();
    XWikiDocument document;
    try {
        document = xcontext.getWiki().getDocument(authorId, xcontext);
    } catch (XWikiException e) {
        document = null;
    }
    if (document != null && !document.isNew()) {
        author.setName(xcontext.getWiki().getPlainUserName(document.getDocumentReference(), xcontext));
        author.setUrl(document.getExternalURL("view", xcontext));
    } else {
        author.setName(authorId);
    }
    return author;
}
Also used : XWikiDocument(com.xpn.xwiki.doc.XWikiDocument) XWikiContext(com.xpn.xwiki.XWikiContext) XWikiException(com.xpn.xwiki.XWikiException) ExtensionAuthor(org.xwiki.extension.repository.xwiki.model.jaxb.ExtensionAuthor)

Aggregations

XWikiContext (com.xpn.xwiki.XWikiContext)1 XWikiException (com.xpn.xwiki.XWikiException)1 XWikiDocument (com.xpn.xwiki.doc.XWikiDocument)1 ExtensionAuthor (org.xwiki.extension.repository.xwiki.model.jaxb.ExtensionAuthor)1