Search in sources :

Example 1 with Scope

use of org.xwiki.localization.wiki.internal.TranslationDocumentModel.Scope in project xwiki-platform by xwiki.

the class DocumentTranslationBundleFactory method registerTranslationBundle.

/**
 * @param document the translation document
 * @throws TranslationBundleDoesNotExistsException when no translation bundle could be created from the provided
 *             document
 * @throws ComponentRepositoryException when the actual registration of the document bundle failed
 * @throws AccessDeniedException when the document author does not have enough right to register the translation
 *             bundle
 */
private void registerTranslationBundle(XWikiDocument document) throws TranslationBundleDoesNotExistsException, ComponentRepositoryException, AccessDeniedException {
    Scope scope = getScope(document);
    if (scope != null && scope != Scope.ON_DEMAND) {
        checkRegistrationAuthorization(document, scope);
        ComponentDescriptor<TranslationBundle> descriptor = createComponentDescriptor(document.getDocumentReference());
        ComponentDocumentTranslationBundle bundle = createComponentDocumentBundle(document, descriptor);
        getComponentManager(document, scope, true).registerComponent(descriptor, bundle);
    }
}
Also used : TranslationBundle(org.xwiki.localization.TranslationBundle) Scope(org.xwiki.localization.wiki.internal.TranslationDocumentModel.Scope)

Example 2 with Scope

use of org.xwiki.localization.wiki.internal.TranslationDocumentModel.Scope in project xwiki-platform by xwiki.

the class DocumentTranslationBundleFactory method unregisterTranslationBundle.

/**
 * @param document the translation document
 */
private void unregisterTranslationBundle(XWikiDocument document) {
    Scope scope = getScope(document);
    // Unregister component
    if (scope != null && scope != Scope.ON_DEMAND) {
        ComponentDescriptor<TranslationBundle> descriptor = createComponentDescriptor(document.getDocumentReference());
        getComponentManager(document, scope, true).unregisterComponent(descriptor);
    }
    // Remove from cache
    this.onDemandBundleCache.remove(this.uidSerializer.serialize(document.getDocumentReference()));
}
Also used : TranslationBundle(org.xwiki.localization.TranslationBundle) Scope(org.xwiki.localization.wiki.internal.TranslationDocumentModel.Scope)

Aggregations

TranslationBundle (org.xwiki.localization.TranslationBundle)2 Scope (org.xwiki.localization.wiki.internal.TranslationDocumentModel.Scope)2