use of org.xwiki.rest.model.jaxb.Objects in project xwiki-platform by xwiki.
the class ObjectsAtPageVersionResourceImpl method getObjects.
@Override
public Objects getObjects(String wikiName, String spaceName, String pageName, String version, Integer start, Integer number, Boolean withPrettyNames) throws XWikiRestException {
try {
DocumentInfo documentInfo = getDocumentInfo(wikiName, spaceName, pageName, null, version, true, false);
Document doc = documentInfo.getDocument();
Objects objects = objectFactory.createObjects();
List<com.xpn.xwiki.objects.BaseObject> objectList = getBaseObjects(doc);
RangeIterable<com.xpn.xwiki.objects.BaseObject> ri = new RangeIterable<com.xpn.xwiki.objects.BaseObject>(objectList, start, number);
for (com.xpn.xwiki.objects.BaseObject object : ri) {
/* By deleting objects, some of them might become null, so we must check for this */
if (object != null) {
objects.getObjectSummaries().add(DomainObjectFactory.createObjectSummary(objectFactory, uriInfo.getBaseUri(), Utils.getXWikiContext(componentManager), doc, object, true, Utils.getXWikiApi(componentManager), withPrettyNames));
}
}
return objects;
} catch (XWikiException e) {
throw new XWikiRestException(e);
}
}
use of org.xwiki.rest.model.jaxb.Objects in project xwiki-platform by xwiki.
the class ObjectsResourceImpl method getObjects.
@Override
public Objects getObjects(String wikiName, String spaceName, String pageName, Integer start, Integer number, Boolean withPrettyNames) throws XWikiRestException {
try {
DocumentInfo documentInfo = getDocumentInfo(wikiName, spaceName, pageName, null, null, true, false);
Document doc = documentInfo.getDocument();
Objects objects = objectFactory.createObjects();
List<BaseObject> objectList = getBaseObjects(doc);
RangeIterable<BaseObject> ri = new RangeIterable<BaseObject>(objectList, start, number);
for (BaseObject object : ri) {
/* By deleting objects, some of them might become null, so we must check for this */
if (object != null) {
objects.getObjectSummaries().add(DomainObjectFactory.createObjectSummary(objectFactory, uriInfo.getBaseUri(), Utils.getXWikiContext(componentManager), doc, object, false, Utils.getXWikiApi(componentManager), withPrettyNames));
}
}
return objects;
} catch (XWikiException e) {
throw new XWikiRestException(e);
}
}
use of org.xwiki.rest.model.jaxb.Objects in project xwiki-platform by xwiki.
the class UIExtensionTest method testUIExtension.
@Test
public void testUIExtension() throws Exception {
// Test Java UI extensions
getUtil().rest().savePage(new LocalDocumentReference(getTestClassName(), HELLOWORLD_UIX_PAGE), "{{velocity}}\n" + "\n" + "{{html}}\n" + "#foreach($uix in $services.uix.getExtensions('hello', {'sortByParameter' : 'HelloWorldKey'}))" + "$services.rendering.render($uix.execute(), " + "'xhtml/1.0')#end\n" + "{{/html}}\n" + "\n" + "#foreach($uix in $services.uix.getExtensions('hello', {'sortByParameter' : 'HelloWorldKey'}))\n" + "$uix.parameters\n" + "#end\n" + "{{/velocity}}\n", "");
// Test Wiki UI extension
Page extensionsPage = getUtil().rest().page(new LocalDocumentReference(getTestClassName(), HELLOWIKIWORLD_UIX_PAGE));
Objects objects = new Objects();
extensionsPage.setObjects(objects);
Object object = RestTestUtils.object(WikiUIExtensionConstants.CLASS_REFERENCE_STRING);
object.setNumber(0);
object.withProperties(RestTestUtils.property("name", "helloWikiWorld2"));
object.withProperties(RestTestUtils.property("extensionPointId", "hello"));
object.withProperties(RestTestUtils.property("content", "HelloWikiWorld2"));
object.withProperties(RestTestUtils.property("parameters", "HelloWorldKey=zz2_$xcontext.user"));
objects.withObjectSummaries(object);
object = RestTestUtils.object(WikiUIExtensionConstants.CLASS_REFERENCE_STRING);
object.setNumber(1);
object.withProperties(RestTestUtils.property("name", "helloWikiWorld1"));
object.withProperties(RestTestUtils.property("extensionPointId", "hello"));
object.withProperties(RestTestUtils.property("content", "HelloWikiWorld1"));
object.withProperties(RestTestUtils.property("parameters", "HelloWorldKey=zz1_$xcontext.user"));
objects.withObjectSummaries(object);
getUtil().rest().save(extensionsPage);
ViewPage page = getUtil().gotoPage(getTestClassName(), HELLOWORLD_UIX_PAGE);
Assert.assertEquals("HelloWorld\n" + "HelloWikiWorld1\n" + "HelloWikiWorld2\n" + "{HelloWorldKey=HelloWorldValue}\n" + "{HelloWorldKey=zz1_XWiki.superadmin}\n" + "{HelloWorldKey=zz2_XWiki.superadmin}", page.getContent());
}
Aggregations