@Override
  public List<DocumentReference> getDocumentReferences(SpaceReference spaceReference)
      throws FilterException {
    List<String> documentNames;
    try {
      Query query =
          this.queryManager.createQuery(
              "select distinct doc.name from Document doc where doc.space = :space order by doc.name asc",
              Query.XWQL);
      query.bindValue("space", localSerializer.serialize(spaceReference));
      query.setWiki(spaceReference.getWikiReference().getName());

      documentNames = query.execute();
    } catch (QueryException e) {
      throw new FilterException(
          String.format("Failed to get the list of documents in space [%s]", spaceReference), e);
    }

    List<DocumentReference> documentReferences = new ArrayList<>(documentNames.size());
    for (String documentName : documentNames) {
      documentReferences.add(new DocumentReference(documentName, spaceReference));
    }

    return documentReferences;
  }
  @Override
  public EntityReference getDefaultReference(EntityType type) {
    EntityReference result = null;

    XWikiContext xcontext = this.xcontextProvider.get();
    if (xcontext != null) {
      if (type == EntityType.WIKI) {
        result = xcontext.getWikiReference();
      } else if (type == EntityType.SPACE) {
        XWikiDocument currentDoc = xcontext.getDoc();
        if (currentDoc != null) {
          SpaceReference spaceReference = currentDoc.getDocumentReference().getLastSpaceReference();
          // Keep only the spaces part
          result = spaceReference.removeParent(spaceReference.getWikiReference());
        }
      } else if (type == EntityType.DOCUMENT) {
        XWikiDocument currentDoc = xcontext.getDoc();
        if (currentDoc != null) {
          DocumentReference documentReference = currentDoc.getDocumentReference();
          // Keep only the document part
          result = documentReference.removeParent(documentReference.getLastSpaceReference());
        }
      }
    }

    if (result == null) {
      result = super.getDefaultReference(type);
    }

    return result;
  }