use of org.xwiki.component.manager.ComponentLookupException in project celements-blog by celements.
the class BlogService method getArticleEngine.
private IArticleEngineRole getArticleEngine() throws ArticleLoadException {
IArticleEngineRole engine = null;
String engineHint = getContext().getWiki().getXWikiPreference("blog_article_engine", "blog.article.engine", null, getContext());
try {
Map<String, IArticleEngineRole> engineMap = componentManager.lookupMap(IArticleEngineRole.class);
engine = engineMap.get(engineHint);
if (engine == null) {
engine = engineMap.get("default");
}
} catch (ComponentLookupException exc) {
LOGGER.error("Error looking up engine components", exc);
}
if (engine != null) {
LOGGER.info("getArticleEngine: got engine '" + engine + "' for hint '" + engineHint + "'");
return engine;
} else {
throw new ArticleLoadException("Unable to load engine for hint");
}
}
use of org.xwiki.component.manager.ComponentLookupException in project xwiki-platform by xwiki.
the class EditableGadgetRenderer method getGadgetContentRenderer.
/**
* @return the renderer corresponding to the "annotated" version of the current target syntax
*/
protected BlockRenderer getGadgetContentRenderer() {
// Get the current syntax
Syntax currentTargetSyntax = renderingContext.getTargetSyntax();
if (currentTargetSyntax == null) {
// (it should never happen actually)
return defaultGadgetContentRenderer;
}
// Get the annotated syntax corresponding to the current target syntax
String annotatedTargetSyntax = currentTargetSyntax.toIdString();
if (!StringUtils.startsWith(annotatedTargetSyntax, ANNOTATED_SYNTAXES_PREFIX)) {
annotatedTargetSyntax = ANNOTATED_SYNTAXES_PREFIX + annotatedTargetSyntax;
}
try {
return componentManager.getInstance(BlockRenderer.class, annotatedTargetSyntax);
} catch (ComponentLookupException e) {
logger.warn("Failed to load the syntax [{}].", annotatedTargetSyntax);
// Failback to the default renderer
return defaultGadgetContentRenderer;
}
}
use of org.xwiki.component.manager.ComponentLookupException in project xwiki-platform by xwiki.
the class DefaultEditorManager method getEditor.
@Override
public <D> Editor<D> getEditor(Type dataType, String hint) {
DefaultParameterizedType editorType = new DefaultParameterizedType(null, Editor.class, dataType);
ComponentManager componentManager = this.componentManagerProvider.get();
if (componentManager.hasComponent(editorType, hint)) {
try {
return componentManager.getInstance(editorType, hint);
} catch (ComponentLookupException e) {
throw new RuntimeException(String.format("Failed to look up the [%s] editor with hint [%s]", dataType.getTypeName(), hint), e);
}
} else {
// No such editor component found.
return null;
}
}
use of org.xwiki.component.manager.ComponentLookupException 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);
}
}
use of org.xwiki.component.manager.ComponentLookupException 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);
}
}
Aggregations