Search in sources :

Example 6 with InitializationException

use of org.xwiki.component.phase.InitializationException in project xwiki-platform by xwiki.

the class EmbeddedSolrInstance method initialize.

@Override
public void initialize() throws InitializationException {
    String solrHome = determineHomeDirectory();
    try {
        // Validate and initialize the home directory if needed.
        validateAndInitializeHomeDirectory(solrHome);
        // Start embedded Solr server.
        this.logger.info("Starting embedded Solr server...");
        this.logger.info("Using Solr home directory: [{}]", solrHome);
        // Initialize the SOLR back-end using an embedded server.
        this.container = createCoreContainer(solrHome);
        // If we get here then there is at least one core found. We there are more, we use the first one.
        String coreName = this.container.getCores().iterator().next().getName();
        this.server = new EmbeddedSolrServer(container, coreName);
        this.logger.info("Started embedded Solr server.");
    } catch (Exception e) {
        throw new InitializationException(String.format("Failed to initialize the Solr embedded server with home directory set to [%s]", solrHome), e);
    }
}
Also used : InitializationException(org.xwiki.component.phase.InitializationException) EmbeddedSolrServer(org.apache.solr.client.solrj.embedded.EmbeddedSolrServer) IOException(java.io.IOException) ComponentLifecycleException(org.xwiki.component.manager.ComponentLifecycleException) InitializationException(org.xwiki.component.phase.InitializationException) SolrServerException(org.apache.solr.client.solrj.SolrServerException)

Example 7 with InitializationException

use of org.xwiki.component.phase.InitializationException in project xwiki-platform by xwiki.

the class InstanceInputFilterStreamFactory method initialize.

@Override
public void initialize() throws InitializationException {
    super.initialize();
    List<InstanceInputEventGenerator> eventGenerators;
    try {
        eventGenerators = this.componentManagerProvider.get().getInstanceList(InstanceInputEventGenerator.class);
    } catch (ComponentLookupException e) {
        throw new InitializationException("Failed to get registered instance of InstanceInputEventGenerator components", e);
    }
    FilterStreamDescriptor[] descriptors = new FilterStreamDescriptor[eventGenerators.size() + 1];
    descriptors[0] = this.descriptor;
    for (int i = 0; i < eventGenerators.size(); ++i) {
        descriptors[i + 1] = eventGenerators.get(i).getDescriptor();
    }
    setDescriptor(new CompositeFilterStreamDescriptor(this.descriptor.getName(), this.descriptor.getDescription(), descriptors));
}
Also used : CompositeFilterStreamDescriptor(org.xwiki.filter.descriptor.CompositeFilterStreamDescriptor) CompositeFilterStreamDescriptor(org.xwiki.filter.descriptor.CompositeFilterStreamDescriptor) FilterStreamDescriptor(org.xwiki.filter.descriptor.FilterStreamDescriptor) ComponentLookupException(org.xwiki.component.manager.ComponentLookupException) InitializationException(org.xwiki.component.phase.InitializationException) InstanceInputEventGenerator(org.xwiki.filter.instance.input.InstanceInputEventGenerator)

Example 8 with InitializationException

use of org.xwiki.component.phase.InitializationException in project xwiki-platform by xwiki.

the class DefaultSecurityCache method newCache.

/**
 * @return a new configured security cache
 * @throws InitializationException if a CacheException arise during creation
 */
private Cache<SecurityCacheEntry> newCache() throws InitializationException {
    CacheConfiguration cacheConfig = new CacheConfiguration();
    cacheConfig.setConfigurationId("platform.security.authorization.cache");
    LRUEvictionConfiguration lru = new LRUEvictionConfiguration();
    lru.setMaxEntries(DEFAULT_CAPACITY);
    cacheConfig.put(LRUEvictionConfiguration.CONFIGURATIONID, lru);
    try {
        return cacheManager.createNewCache(cacheConfig);
    } catch (Exception e) {
        throw new InitializationException(String.format("Unable to create the security cache with a capacity of [%d] entries", lru.getMaxEntries()), e);
    }
}
Also used : LRUEvictionConfiguration(org.xwiki.cache.eviction.LRUEvictionConfiguration) InitializationException(org.xwiki.component.phase.InitializationException) CacheConfiguration(org.xwiki.cache.config.CacheConfiguration) InitializationException(org.xwiki.component.phase.InitializationException) ParentEntryEvictedException(org.xwiki.security.authorization.cache.ParentEntryEvictedException) ConflictingInsertionException(org.xwiki.security.authorization.cache.ConflictingInsertionException)

Example 9 with InitializationException

use of org.xwiki.component.phase.InitializationException in project xwiki-platform by xwiki.

the class DefaultColorThemeCache method initialize.

@Override
public void initialize() throws InitializationException {
    try {
        // Create the cache
        CacheConfiguration configuration = new CacheConfiguration(LESS_COLOR_THEMES_CACHE_ID);
        CacheFactory cacheFactory = cacheManager.getCacheFactory();
        super.cache = cacheFactory.newCache(configuration);
        // The Color Theme only depends on colors which do not depend on the XWikiContext. So we don't handle the
        // XWikiContext in this cache.
        super.isContextHandled = false;
    } catch (ComponentLookupException | CacheException e) {
        throw new InitializationException(String.format("Failed to initialize LESS color themes cache [%s].", LESS_COLOR_THEMES_CACHE_ID), e);
    }
}
Also used : CacheException(org.xwiki.cache.CacheException) ComponentLookupException(org.xwiki.component.manager.ComponentLookupException) CacheFactory(org.xwiki.cache.CacheFactory) InitializationException(org.xwiki.component.phase.InitializationException) CacheConfiguration(org.xwiki.cache.config.CacheConfiguration)

Example 10 with InitializationException

use of org.xwiki.component.phase.InitializationException in project xwiki-platform by xwiki.

the class DefaultLESSResourcesCache method initialize.

@Override
public void initialize() throws InitializationException {
    try {
        CacheConfiguration configuration = new CacheConfiguration(LESS_FILES_CACHE_ID);
        CacheFactory cacheFactory = cacheManager.getCacheFactory();
        this.cache = cacheFactory.newCache(configuration);
    } catch (ComponentLookupException | CacheException e) {
        throw new InitializationException(String.format("Failed to initialize LESS skin files cache [%s].", LESS_FILES_CACHE_ID), e);
    }
}
Also used : CacheException(org.xwiki.cache.CacheException) ComponentLookupException(org.xwiki.component.manager.ComponentLookupException) CacheFactory(org.xwiki.cache.CacheFactory) InitializationException(org.xwiki.component.phase.InitializationException) CacheConfiguration(org.xwiki.cache.config.CacheConfiguration)

Aggregations

InitializationException (org.xwiki.component.phase.InitializationException)24 ComponentLookupException (org.xwiki.component.manager.ComponentLookupException)9 CacheException (org.xwiki.cache.CacheException)8 CacheConfiguration (org.xwiki.cache.config.CacheConfiguration)8 IOException (java.io.IOException)4 CacheFactory (org.xwiki.cache.CacheFactory)4 InputStream (java.io.InputStream)3 LRUEvictionConfiguration (org.xwiki.cache.eviction.LRUEvictionConfiguration)3 DefaultComponentDescriptor (org.xwiki.component.descriptor.DefaultComponentDescriptor)2 ComponentRepositoryException (org.xwiki.component.manager.ComponentRepositoryException)2 CompositeFilterStreamDescriptor (org.xwiki.filter.descriptor.CompositeFilterStreamDescriptor)2 FilterStreamDescriptor (org.xwiki.filter.descriptor.FilterStreamDescriptor)2 EntityReference (org.xwiki.model.reference.EntityReference)2 XWikiContext (com.xpn.xwiki.XWikiContext)1 XWikiException (com.xpn.xwiki.XWikiException)1 File (java.io.File)1 FileInputStream (java.io.FileInputStream)1 StringReader (java.io.StringReader)1 Type (java.lang.reflect.Type)1 ArrayList (java.util.ArrayList)1