Search in sources :

Example 1 with Classes

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);
        }
    }
}
Also used : GetMethod(org.apache.commons.httpclient.methods.GetMethod) Class(org.xwiki.rest.model.jaxb.Class) Property(org.xwiki.rest.model.jaxb.Property) Classes(org.xwiki.rest.model.jaxb.Classes) AbstractHttpTest(org.xwiki.test.rest.framework.AbstractHttpTest) Test(org.junit.Test)

Example 2 with Classes

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);
    }
}
Also used : RangeIterable(org.xwiki.rest.internal.RangeIterable) XWikiRestException(org.xwiki.rest.XWikiRestException) XWikiException(com.xpn.xwiki.XWikiException) Classes(org.xwiki.rest.model.jaxb.Classes)

Aggregations

Classes (org.xwiki.rest.model.jaxb.Classes)2 XWikiException (com.xpn.xwiki.XWikiException)1 GetMethod (org.apache.commons.httpclient.methods.GetMethod)1 Test (org.junit.Test)1 XWikiRestException (org.xwiki.rest.XWikiRestException)1 RangeIterable (org.xwiki.rest.internal.RangeIterable)1 Class (org.xwiki.rest.model.jaxb.Class)1 Property (org.xwiki.rest.model.jaxb.Property)1 AbstractHttpTest (org.xwiki.test.rest.framework.AbstractHttpTest)1