Search in sources :

Example 76 with ComponentManager

use of org.xwiki.component.manager.ComponentManager in project xwiki-platform by xwiki.

the class XarScriptService method isXARExportAvailable.

/**
 * @return true if the XAR export feature is available in the current XWiki instance, false otherwise
 * @since 8.3RC1
 */
public boolean isXARExportAvailable() {
    boolean available = false;
    // Check the value of the xwiki.action.export.xar.usefilter config parameter in xwiki.cfg
    int useFilter = this.xwikiCfgConfigurationSource.getProperty(EXPORT_USEFILTER_KEY, (Integer) 1);
    if (useFilter == 1) {
        // Are the following 2 components available?
        ComponentManager cm = this.contextComponentManagerProvider.get();
        if (cm.hasComponent(InputFilterStreamFactory.class, FilterStreamType.XWIKI_INSTANCE.serialize()) && cm.hasComponent(OutputFilterStreamFactory.class, FilterStreamType.XWIKI_XAR_CURRENT.serialize())) {
            available = true;
        }
    } else {
        // We're using the old packager plugin, verify it's there
        XWikiContext xcontext = (XWikiContext) this.execution.getContext().getProperty(XWikiContext.EXECUTIONCONTEXT_KEY);
        if (xcontext != null && xcontext.getWiki().getPlugin("package", xcontext) != null) {
            available = true;
        }
    }
    return available;
}
Also used : OutputFilterStreamFactory(org.xwiki.filter.output.OutputFilterStreamFactory) ComponentManager(org.xwiki.component.manager.ComponentManager) InputFilterStreamFactory(org.xwiki.filter.input.InputFilterStreamFactory) XWikiContext(com.xpn.xwiki.XWikiContext)

Aggregations

ComponentManager (org.xwiki.component.manager.ComponentManager)76 Test (org.junit.Test)34 ComponentLookupException (org.xwiki.component.manager.ComponentLookupException)23 DefaultParameterizedType (org.xwiki.component.util.DefaultParameterizedType)18 DocumentReference (org.xwiki.model.reference.DocumentReference)17 Provider (javax.inject.Provider)14 NamespacedComponentManager (org.xwiki.component.manager.NamespacedComponentManager)12 Before (org.junit.Before)11 DefaultComponentDescriptor (org.xwiki.component.descriptor.DefaultComponentDescriptor)11 XWikiContext (com.xpn.xwiki.XWikiContext)9 Expectations (org.jmock.Expectations)9 WikiReference (org.xwiki.model.reference.WikiReference)9 HashMap (java.util.HashMap)7 Execution (org.xwiki.context.Execution)7 SpaceReference (org.xwiki.model.reference.SpaceReference)7 XWiki (com.xpn.xwiki.XWiki)6 XWikiDocument (com.xpn.xwiki.doc.XWikiDocument)6 ArrayList (java.util.ArrayList)6 ExecutionContext (org.xwiki.context.ExecutionContext)6 MimeMessage (javax.mail.internet.MimeMessage)5