Search in sources :

Example 1 with ParametrizedRestURLGenerator

use of org.xwiki.rest.url.ParametrizedRestURLGenerator in project xwiki-platform by xwiki.

the class DefaultRestURLGenerator method getURL.

@Override
public URL getURL(EntityReference entityReference) throws XWikiRestException {
    try {
        ParameterizedType type = new DefaultParameterizedType(null, ParametrizedRestURLGenerator.class, entityReference.getClass());
        ParametrizedRestURLGenerator parametrizedRestURLGenerator = componentManager.getInstance(type);
        return parametrizedRestURLGenerator.getURL(entityReference);
    } catch (ComponentLookupException e) {
        throw new XWikiRestException(String.format("Unsupported entity type: [%s]", entityReference.getClass()), e);
    }
}
Also used : DefaultParameterizedType(org.xwiki.component.util.DefaultParameterizedType) ParameterizedType(java.lang.reflect.ParameterizedType) ParametrizedRestURLGenerator(org.xwiki.rest.url.ParametrizedRestURLGenerator) XWikiRestException(org.xwiki.rest.XWikiRestException) ComponentLookupException(org.xwiki.component.manager.ComponentLookupException) DefaultParameterizedType(org.xwiki.component.util.DefaultParameterizedType)

Aggregations

ParameterizedType (java.lang.reflect.ParameterizedType)1 ComponentLookupException (org.xwiki.component.manager.ComponentLookupException)1 DefaultParameterizedType (org.xwiki.component.util.DefaultParameterizedType)1 XWikiRestException (org.xwiki.rest.XWikiRestException)1 ParametrizedRestURLGenerator (org.xwiki.rest.url.ParametrizedRestURLGenerator)1