use of com.xpn.xwiki.api.XWiki in project xwiki-platform by xwiki.
the class SpacesResourceImpl method getSpaces.
@Override
public Spaces getSpaces(String wikiName, Integer start, Integer number) throws XWikiRestException {
Spaces spaces = objectFactory.createSpaces();
try {
List<String> spaceNames = queryManager.getNamedQuery("getSpaces").addFilter(componentManager.<QueryFilter>getInstance(QueryFilter.class, "hidden")).setOffset(start).setLimit(number).setWiki(wikiName).execute();
for (String spaceName : spaceNames) {
List<String> spaceList = Utils.getSpacesFromSpaceId(spaceName);
String homeId = Utils.getPageId(wikiName, spaceList, "WebHome");
Document home = null;
XWiki xwikiApi = Utils.getXWikiApi(componentManager);
if (xwikiApi.hasAccessLevel("view", homeId)) {
if (xwikiApi.exists(homeId)) {
home = Utils.getXWikiApi(componentManager).getDocument(homeId);
}
spaces.getSpaces().add(DomainObjectFactory.createSpace(objectFactory, uriInfo.getBaseUri(), wikiName, spaceList, home));
}
}
} catch (Exception e) {
throw new XWikiRestException(e);
}
return spaces;
}
Aggregations