use of org.xwiki.rest.model.jaxb.Classes in project xwiki-platform by xwiki.
the class ClassesResourceTest method testRepresentation.
@Override
@Test
public void testRepresentation() throws Exception {
GetMethod getMethod = executeGet(buildURI(ClassesResource.class, getWiki()).toString());
Assert.assertEquals(getHttpMethodInfo(getMethod), HttpStatus.SC_OK, getMethod.getStatusCode());
Classes classes = (Classes) unmarshaller.unmarshal(getMethod.getResponseBodyAsStream());
for (Class clazz : classes.getClazzs()) {
checkLinks(clazz);
for (Property property : clazz.getProperties()) {
checkLinks(property);
}
}
}
use of org.xwiki.rest.model.jaxb.Classes in project xwiki-platform by xwiki.
the class ClassesResourceImpl method getClasses.
@Override
public Classes getClasses(String wikiName, Integer start, Integer number) throws XWikiRestException {
String database = Utils.getXWikiContext(componentManager).getWikiId();
try {
getXWikiContext().setWikiId(wikiName);
List<String> classNames = Utils.getXWikiApi(componentManager).getClassList();
Collections.sort(classNames);
RangeIterable<String> ri = new RangeIterable<String>(classNames, start, number);
Classes classes = objectFactory.createClasses();
for (String className : ri) {
com.xpn.xwiki.api.Class xwikiClass = Utils.getXWikiApi(componentManager).getClass(className);
classes.getClazzs().add(this.utils.toRestClass(uriInfo.getBaseUri(), xwikiClass));
}
return classes;
} catch (XWikiException e) {
throw new XWikiRestException(e);
} finally {
Utils.getXWikiContext(componentManager).setWikiId(database);
}
}
Aggregations