use of org.xwiki.rest.XWikiRestException 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);
}
}
use of org.xwiki.rest.XWikiRestException in project xwiki-platform by xwiki.
the class PageTranslationsResourceImpl method getTranslations.
@Override
public Translations getTranslations(String wikiName, String spaceName, String pageName) throws XWikiRestException {
try {
DocumentInfo documentInfo = getDocumentInfo(wikiName, spaceName, pageName, null, null, true, false);
Document doc = documentInfo.getDocument();
return DomainObjectFactory.createTranslations(objectFactory, uriInfo.getBaseUri(), doc);
} catch (XWikiException e) {
throw new XWikiRestException(e);
}
}
use of org.xwiki.rest.XWikiRestException in project xwiki-platform by xwiki.
the class DBListClassPropertyValuesProviderTest method getValuesForWrongProperty.
@Test
public void getValuesForWrongProperty() throws Exception {
ClassPropertyReference propertyReference = new ClassPropertyReference("date", this.classReference);
when(this.entityReferenceSerializer.serialize(propertyReference)).thenReturn("status reference");
try {
this.mocker.getComponentUnderTest().getValues(propertyReference, 0);
fail();
} catch (XWikiRestException expected) {
assertEquals("This [status reference] is not a [DBListClass] property.", expected.getMessage());
}
}
use of org.xwiki.rest.XWikiRestException in project xwiki-platform by xwiki.
the class DefaultClassPropertyValuesProviderTest method getValuesForMissingProperty.
@Test
public void getValuesForMissingProperty() throws Exception {
ClassPropertyReference propertyReference = new ClassPropertyReference("status", this.classReference);
EntityReferenceSerializer<String> entityReferenceSerializer = this.mocker.getInstance(EntityReferenceSerializer.TYPE_STRING);
when(entityReferenceSerializer.serialize(propertyReference)).thenReturn("status reference");
try {
this.mocker.getComponentUnderTest().getValues(propertyReference, 13);
fail();
} catch (XWikiRestException expected) {
assertEquals("No such property [status reference].", expected.getMessage());
}
}
use of org.xwiki.rest.XWikiRestException in project xwiki-platform by xwiki.
the class WikisSearchQueryResourceImpl method search.
@Override
public SearchResults search(String query, Integer number, Integer start, Boolean distinct, String searchWikis, String orderField, String order, Boolean withPrettyNames, String className) throws XWikiRestException {
try {
SearchResults searchResults = objectFactory.createSearchResults();
searchResults.setTemplate(String.format("%s?%s", uriInfo.getBaseUri().toString(), MULTIWIKI_QUERY_TEMPLATE_INFO));
searchResults.getSearchResults().addAll(this.solrSearch.search(query, getXWikiContext().getWikiId(), searchWikis, Utils.getXWiki(componentManager).getRightService().hasProgrammingRights(Utils.getXWikiContext(componentManager)), orderField, order, distinct, number, start, withPrettyNames, className, uriInfo));
return searchResults;
} catch (Exception e) {
throw new XWikiRestException(e);
}
}
Aggregations