use of org.xwiki.component.manager.ComponentLookupException in project xwiki-platform by xwiki.
the class UIExtensionScriptService method getExtensions.
/**
* Retrieves all the {@link UIExtension}s for a given Extension Point.
*
* @param extensionPointId The ID of the Extension Point to retrieve the {@link UIExtension}s for
* @return the list of {@link UIExtension} for the given Extension Point
*/
public List<UIExtension> getExtensions(String extensionPointId) {
UIExtensionManager manager = this.uiExtensionManager;
ComponentManager componentManager = contextComponentManagerProvider.get();
if (componentManager.hasComponent(UIExtensionManager.class, extensionPointId)) {
try {
// Look for a specific UI extension manager for the given extension point
manager = componentManager.getInstance(UIExtensionManager.class, extensionPointId);
} catch (ComponentLookupException e) {
this.logger.error("Failed to initialize UI extension manager", e);
}
}
return manager.get(extensionPointId);
}
use of org.xwiki.component.manager.ComponentLookupException in project xwiki-platform by xwiki.
the class DefaultIconSetCache method initialize.
@Override
public void initialize() throws InitializationException {
try {
CacheConfiguration configuration = new CacheConfiguration(ICON_SET_CACHE_ID);
CacheFactory cacheFactory = cacheManager.getCacheFactory();
this.cache = cacheFactory.newCache(configuration);
} catch (ComponentLookupException | CacheException e) {
throw new InitializationException("Failed to initialize the IconSet Cache.", e);
}
}
use of org.xwiki.component.manager.ComponentLookupException in project xwiki-platform by xwiki.
the class ModelScriptServiceTest method createDocumentReferenceWithDeprecatedHint.
@Test
public void createDocumentReferenceWithDeprecatedHint() throws Exception {
when(this.componentManager.getInstance(DocumentReferenceResolver.TYPE_REFERENCE, "current/reference")).thenThrow(new ComponentLookupException("error"));
DocumentReference reference = new DocumentReference("wiki", "space", "page");
// Make sure backward compatibility is preserved.
when(this.componentManager.getInstance(DocumentReferenceResolver.class, "current/reference")).thenReturn(this.resolver);
when(this.resolver.resolve(reference)).thenReturn(reference);
Assert.assertEquals(reference, this.service.createDocumentReference("wiki", "space", "page", "current/reference"));
// Verify that we log a warning!
verify(this.logger).warn("Deprecated usage of DocumentReferenceResolver with hint [{}]. " + "Please consider using a DocumentReferenceResolver that takes into account generic types.", "current/reference");
}
use of org.xwiki.component.manager.ComponentLookupException in project xwiki-platform by xwiki.
the class ModelScriptServiceTest method getEntityReferenceValueWithInvalidHint.
@Test
public void getEntityReferenceValueWithInvalidHint() throws Exception {
when(this.componentManager.getInstance(EntityReferenceValueProvider.class, "invalid")).thenThrow(new ComponentLookupException("error"));
Assert.assertNull(this.service.getEntityReferenceValue(EntityType.WIKI, "invalid"));
}
use of org.xwiki.component.manager.ComponentLookupException in project xwiki-platform by xwiki.
the class ModelScriptService method createDocumentReference.
/**
* Create a Document Reference from a passed wiki, list of spaces and page names, which can be empty strings or null
* in which case they are resolved against the Resolver having the hint passed as parameter. Valid hints are for
* example "default", "current", "currentmixed".
*
* @param wiki the wiki reference name to use (can be empty or null)
* @param spaces the spaces list to use (can be empty or null)
* @param page the page reference name to use (can be empty or null)
* @param hint the hint of the Resolver to use in case any parameter is empty or null
* @return the typed Document Reference object or null if no Resolver with the passed hint could be found
*
* @since 7.2M2
*/
public DocumentReference createDocumentReference(String wiki, List<String> spaces, String page, String hint) {
EntityReference reference = null;
if (!StringUtils.isEmpty(wiki)) {
reference = new EntityReference(wiki, EntityType.WIKI);
}
if (spaces != null && !spaces.isEmpty()) {
for (String space : spaces) {
reference = new EntityReference(space, EntityType.SPACE, reference);
}
}
if (!StringUtils.isEmpty(page)) {
reference = new EntityReference(page, EntityType.DOCUMENT, reference);
}
DocumentReference documentReference;
try {
DocumentReferenceResolver<EntityReference> resolver = this.componentManager.getInstance(DocumentReferenceResolver.TYPE_REFERENCE, hint);
documentReference = resolver.resolve(reference);
} catch (ComponentLookupException e) {
try {
// Ensure backward compatibility with older scripts that use hints like "default/reference" because at
// the time they were written we didn't have support for generic types in component role.
DocumentReferenceResolver<EntityReference> drr = this.componentManager.getInstance(DocumentReferenceResolver.class, hint);
documentReference = drr.resolve(reference);
this.logger.warn("Deprecated usage of DocumentReferenceResolver with hint [{}]. " + "Please consider using a DocumentReferenceResolver that takes into account generic types.", hint);
} catch (ComponentLookupException ex) {
documentReference = null;
}
}
return documentReference;
}
Aggregations