Search in sources :

Example 6 with XWiki

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;
}
Also used : QueryFilter(org.xwiki.query.QueryFilter) XWikiRestException(org.xwiki.rest.XWikiRestException) Spaces(org.xwiki.rest.model.jaxb.Spaces) XWiki(com.xpn.xwiki.api.XWiki) Document(com.xpn.xwiki.api.Document) XWikiRestException(org.xwiki.rest.XWikiRestException)

Aggregations

Document (com.xpn.xwiki.api.Document)6 XWiki (com.xpn.xwiki.api.XWiki)6 ArrayList (java.util.ArrayList)4 Link (org.xwiki.rest.model.jaxb.Link)4 SearchResult (org.xwiki.rest.model.jaxb.SearchResult)4 XWikiContext (com.xpn.xwiki.XWikiContext)3 Calendar (java.util.Calendar)3 XWikiDocument (com.xpn.xwiki.doc.XWikiDocument)2 Formatter (java.util.Formatter)2 XWikiException (com.xpn.xwiki.XWikiException)1 Context (com.xpn.xwiki.api.Context)1 BaseObject (com.xpn.xwiki.objects.BaseObject)1 ScriptContext (javax.script.ScriptContext)1 DocumentReference (org.xwiki.model.reference.DocumentReference)1 SpaceReference (org.xwiki.model.reference.SpaceReference)1 WikiReference (org.xwiki.model.reference.WikiReference)1 Query (org.xwiki.query.Query)1 QueryFilter (org.xwiki.query.QueryFilter)1 XWikiRestException (org.xwiki.rest.XWikiRestException)1 Spaces (org.xwiki.rest.model.jaxb.Spaces)1