use of org.xwiki.component.manager.ComponentLookupException in project xwiki-platform by xwiki.
the class DefaultTranslationBundleContext method initializeCurrentBundles.
private SortedSet<TranslationBundle> initializeCurrentBundles() {
SortedSet<TranslationBundle> currentBundles = new TreeSet<>();
try {
ComponentManager componentManager = this.componentManagerProvider.get();
List<TranslationBundle> availableBundles = componentManager.<TranslationBundle>getInstanceList(TranslationBundle.class);
currentBundles.addAll(availableBundles);
} catch (ComponentLookupException e) {
this.logger.error("Failed to lookup Bundle components", e);
}
return currentBundles;
}
use of org.xwiki.component.manager.ComponentLookupException in project xwiki-platform by xwiki.
the class VelocityMacro method getFilter.
/**
* @param parameters the velocity macros parameters
* @return the velocity content filter
* @since 2.0M1
*/
private VelocityMacroFilter getFilter(VelocityMacroParameters parameters) {
String filterName = parameters.getFilter();
if (StringUtils.isEmpty(filterName)) {
filterName = this.configuration.getFilter();
if (StringUtils.isEmpty(filterName)) {
filterName = null;
}
}
VelocityMacroFilter filter = null;
if (filterName != null) {
try {
filter = getComponentManager().getInstance(VelocityMacroFilter.class, filterName);
} catch (ComponentLookupException e) {
this.logger.error("Can't find velocity macro filter", e);
}
}
return filter;
}
use of org.xwiki.component.manager.ComponentLookupException in project xwiki-platform by xwiki.
the class StandardExtendedURLResourceReferenceSerializerTest method serializeWhenNoMatchingSerializer.
@Test
public void serializeWhenNoMatchingSerializer() throws Exception {
TestResourceReference resource = new TestResourceReference();
ComponentManager componentManager = this.mocker.getInstance(ComponentManager.class, "context");
when(componentManager.getInstance(new DefaultParameterizedType(null, ResourceReferenceSerializer.class, TestResourceReference.class, ExtendedURL.class), "standard")).thenThrow(new ComponentLookupException("error"));
when(componentManager.getInstance(new DefaultParameterizedType(null, ResourceReferenceSerializer.class, TestResourceReference.class, ExtendedURL.class))).thenThrow(new ComponentLookupException("error"));
try {
this.mocker.getComponentUnderTest().serialize(resource);
fail("Should have thrown an exception here");
} catch (UnsupportedResourceReferenceException expected) {
assertEquals("Failed to find serializer for Resource Reference [type = [test], parameters = []] and " + "URL format [standard]", expected.getMessage());
}
}
use of org.xwiki.component.manager.ComponentLookupException in project xwiki-platform by xwiki.
the class URIVfsResourceReferenceSerializer method serialize.
@Override
public URI serialize(VfsResourceReference reference) throws SerializeResourceReferenceException, UnsupportedResourceReferenceException {
URI resultURI;
try {
ResourceReferenceSerializer<VfsResourceReference, URI> serializer = this.componentManagerProvider.get().getInstance(new DefaultParameterizedType(null, ResourceReferenceSerializer.class, VfsResourceReference.class, URI.class), String.format("truevfs/%s", reference.getURI().getScheme()));
resultURI = serializer.serialize(reference);
} catch (ComponentLookupException e) {
// No serializer exist, we just don't perform any conversion!
resultURI = reference.toURI();
}
return resultURI;
}
use of org.xwiki.component.manager.ComponentLookupException in project xwiki-platform by xwiki.
the class VfsResourceReferenceSerializer method serialize.
@Override
public ExtendedURL serialize(VfsResourceReference resourceReference) throws SerializeResourceReferenceException, UnsupportedResourceReferenceException {
ExtendedURL extendedURL;
// We need to ensure that the URI contains absolute references since the VFS handler that will handle
// the generated URL won't have any base reference to resolve any relative refeence.
//
// Look for a scheme-specific serializer to convert from a relative URI into an absolute URI and if not found
// then don't perform any transformation of the URI.
URI uri = resourceReference.getURI();
try {
ResourceReferenceSerializer<VfsResourceReference, ExtendedURL> schemeSpecificSerializer = this.componentManagerProvider.get().getInstance(TYPE, uri.getScheme());
extendedURL = schemeSpecificSerializer.serialize(resourceReference);
} catch (ComponentLookupException e) {
extendedURL = super.serialize(resourceReference);
}
return extendedURL;
}
Aggregations