use of org.xwiki.component.manager.ComponentLookupException in project xwiki-platform by xwiki.
the class CompositeWikiConfigurationSource method initializeWikiSources.
private synchronized List<ConfigurationSource> initializeWikiSources() {
if (this.wikiInitialized) {
return this.sources;
}
XWikiContext xcontext = this.xcontextProvider.get();
// If context is not ready don't do anything
if (xcontext == null) {
return Collections.emptyList();
}
// Inject registered configuration sources
List<ConfigurationSource> newSources = new ArrayList<>(this.sources.size() + this.wikiHints.size());
for (String wikiHint : this.wikiHints) {
try {
newSources.add(this.componentManager.getInstance(ConfigurationSource.class, wikiHint));
} catch (ComponentLookupException e) {
this.logger.error("Failed to lookup configuration source with hint [%s]. It won't be used.", wikiHint, e);
}
}
this.sources = newSources;
return this.sources;
}
use of org.xwiki.component.manager.ComponentLookupException 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));
}
use of org.xwiki.component.manager.ComponentLookupException in project xwiki-platform by xwiki.
the class AbstractWikiObjectPropertyReader method readObjectProperty.
public WikiObjectProperty readObjectProperty(XMLStreamReader xmlReader, XARInputProperties properties, WikiClass wikiClass) throws XMLStreamException, FilterException {
xmlReader.nextTag();
WikiObjectProperty property = new WikiObjectProperty();
property.name = xmlReader.getLocalName();
String type;
if (wikiClass != null) {
WikiClassProperty classProperty = wikiClass.properties.get(property.name);
type = classProperty != null ? classProperty.type : null;
} else {
type = properties.getObjectPropertyType();
}
try {
property.value = this.propertySerializerManager.getPropertySerializer(type).read(xmlReader);
} catch (ComponentLookupException e) {
throw new FilterException("Failed to get a property parser", e);
}
property.parameters.put(WikiObjectPropertyFilter.PARAMETER_TYPE, type);
xmlReader.nextTag();
return property;
}
use of org.xwiki.component.manager.ComponentLookupException 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;
}
use of org.xwiki.component.manager.ComponentLookupException in project xwiki-platform by xwiki.
the class LocalizationScriptService method render.
/**
* @param keys the translations keys to try one by one
* @param syntax the syntax in which to render the translation message
* @param parameters the translation parameters
* @param locale the {@link Locale} for which this translation is searched. The result might me associated to a
* different {@link Locale} (for example getting the {@code fr} translation when asking for the
* {@code fr_FR} one).
* @return the rendered translation message, the key if no translation can be found and null if the rendering failed
* @since 10.2
*/
public String render(Collection<String> keys, Syntax syntax, Collection<?> parameters, Locale locale) {
if (CollectionUtils.isEmpty(keys)) {
return null;
}
Translation translation = null;
for (String key : keys) {
if (key != null) {
translation = this.localization.getTranslation(key, locale);
if (translation != null) {
break;
}
}
}
String result;
if (translation != null) {
Block block = parameters != null ? translation.render(locale, parameters.toArray()) : translation.render(locale);
try {
BlockRenderer renderer = this.componentManager.get().getInstance(BlockRenderer.class, syntax.toIdString());
DefaultWikiPrinter wikiPrinter = new DefaultWikiPrinter();
renderer.render(block, wikiPrinter);
result = wikiPrinter.toString();
} catch (ComponentLookupException e) {
// TODO set current error
result = null;
}
} else {
result = null;
for (String key : keys) {
if (key != null) {
result = key;
}
}
}
return result;
}
Aggregations