Search in sources :

Example 1 with CreateResourceTypeException

use of org.xwiki.resource.CreateResourceTypeException in project xwiki-platform by xwiki.

the class DefaultStringResourceTypeResolver method resolve.

@Override
public ResourceType resolve(String type, Map<String, Object> parameters) throws CreateResourceTypeException {
    ResourceTypeResolver resolver;
    DefaultParameterizedType parameterizedType = new DefaultParameterizedType(null, ResourceTypeResolver.class, String.class);
    String hint = this.configuration.getURLFormatId();
    if (this.componentManager.hasComponent(parameterizedType, hint)) {
        try {
            resolver = this.componentManager.getInstance(parameterizedType, hint);
        } catch (ComponentLookupException e) {
            throw new CreateResourceTypeException(String.format("Failed to convert Resource Type from String [%s] to [%s]", type, ResourceType.class.getSimpleName()), e);
        }
    } else {
        // No specific String Resource Type Resolver for the Scheme URL, use the generic one!
        resolver = this.genericResourceTypeResolver;
    }
    return resolver.resolve(type, parameters);
}
Also used : ResourceTypeResolver(org.xwiki.resource.ResourceTypeResolver) ComponentLookupException(org.xwiki.component.manager.ComponentLookupException) ResourceType(org.xwiki.resource.ResourceType) DefaultParameterizedType(org.xwiki.component.util.DefaultParameterizedType) CreateResourceTypeException(org.xwiki.resource.CreateResourceTypeException)

Aggregations

ComponentLookupException (org.xwiki.component.manager.ComponentLookupException)1 DefaultParameterizedType (org.xwiki.component.util.DefaultParameterizedType)1 CreateResourceTypeException (org.xwiki.resource.CreateResourceTypeException)1 ResourceType (org.xwiki.resource.ResourceType)1 ResourceTypeResolver (org.xwiki.resource.ResourceTypeResolver)1