Search in sources :

Example 1 with EntityReferenceTree

use of org.xwiki.model.reference.EntityReferenceTree in project xwiki-platform by xwiki.

the class DefaultInstanceModel method getSpaceReferences.

@Override
public EntityReferenceTreeNode getSpaceReferences(WikiReference wikiReference) throws FilterException {
    // Get the spaces
    List<String> spaceReferenceStrings;
    try {
        spaceReferenceStrings = this.queryManager.getNamedQuery("getSpaces").setWiki(wikiReference.getName()).execute();
    } catch (QueryException e) {
        throw new FilterException(String.format("Failed to get the list of spaces in wiki [%s]", wikiReference), e);
    }
    // Get references
    List<SpaceReference> spaceReferences = new ArrayList<>(spaceReferenceStrings.size());
    for (String spaceReferenceString : spaceReferenceStrings) {
        spaceReferences.add(this.spaceResolver.resolve(spaceReferenceString, wikiReference));
    }
    // Create the tree
    EntityReferenceTree tree = new EntityReferenceTree(spaceReferences);
    return tree.getChildren().iterator().next();
}
Also used : QueryException(org.xwiki.query.QueryException) EntityReferenceTree(org.xwiki.model.reference.EntityReferenceTree) SpaceReference(org.xwiki.model.reference.SpaceReference) ArrayList(java.util.ArrayList) FilterException(org.xwiki.filter.FilterException)

Aggregations

ArrayList (java.util.ArrayList)1 FilterException (org.xwiki.filter.FilterException)1 EntityReferenceTree (org.xwiki.model.reference.EntityReferenceTree)1 SpaceReference (org.xwiki.model.reference.SpaceReference)1 QueryException (org.xwiki.query.QueryException)1