Search in sources :

Example 1 with TranslationBundleDoesNotExistsException

use of org.xwiki.localization.TranslationBundleDoesNotExistsException in project xwiki-platform by xwiki.

the class DocumentTranslationBundleFactory method createOnDemandDocumentBundle.

private OnDemandDocumentTranslationBundle createOnDemandDocumentBundle(DocumentReference documentReference, String uid) throws TranslationBundleDoesNotExistsException {
    XWikiContext context = this.xcontextProvider.get();
    XWikiDocument document;
    try {
        document = context.getWiki().getDocument(documentReference, context);
    } catch (XWikiException e) {
        throw new TranslationBundleDoesNotExistsException("Failed to get translation document", e);
    }
    if (document.isNew()) {
        throw new TranslationBundleDoesNotExistsException(String.format("Document [%s] does not exists", documentReference));
    }
    OnDemandDocumentTranslationBundle documentBundle;
    try {
        documentBundle = new OnDemandDocumentTranslationBundle(ID_PREFIX, document.getDocumentReference(), this.componentManagerProvider.get(), this.translationParser, this, uid);
    } catch (ComponentLookupException e) {
        throw new TranslationBundleDoesNotExistsException("Failed to create document bundle", e);
    }
    return documentBundle;
}
Also used : XWikiDocument(com.xpn.xwiki.doc.XWikiDocument) XWikiContext(com.xpn.xwiki.XWikiContext) ComponentLookupException(org.xwiki.component.manager.ComponentLookupException) TranslationBundleDoesNotExistsException(org.xwiki.localization.TranslationBundleDoesNotExistsException) XWikiException(com.xpn.xwiki.XWikiException)

Aggregations

XWikiContext (com.xpn.xwiki.XWikiContext)1 XWikiException (com.xpn.xwiki.XWikiException)1 XWikiDocument (com.xpn.xwiki.doc.XWikiDocument)1 ComponentLookupException (org.xwiki.component.manager.ComponentLookupException)1 TranslationBundleDoesNotExistsException (org.xwiki.localization.TranslationBundleDoesNotExistsException)1