Ejemplo n.º 1
0
  public CTVRepresentation(String targetDocument, Type type, XWikiContext context)
      throws IOException, XWikiException {
    super(jsonMediaType);
    this.xwiki = context.getWiki();
    this.userGroups = new TreeSet<String>();
    for (Object groupName :
        ((CurrikiSpaceManager) xwiki.getPlugin("csm", context))
            .getSpaceNames(context.getUser(), null, context)) {
      userGroups.add(((String) groupName).substring("Group_".length()));
    }
    this.type = type;
    this.userName = context.getUser();
    if (userName.startsWith("XWiki.")) userName = userName.substring("XWiki.".length());
    this.userIsAdmin =
        xwiki.checkAccess("admin", xwiki.getDocument("XWiki.XWikiPreferences", context), context);
    this.docFullName = targetDocument;
    this.currikiPlugin = (CurrikiPlugin) xwiki.getPlugin("curriki", context);

    if (!currikiPlugin.solrCheckIsUp()) useBackEnd = false;

    // identify docs to queries
    if (type == Type.USER_COLLECTIONS) {
      solrField = "userCollections";
      propNameForFullname = "collectionPage";
    } else if (type == Type.USER_GROUPS) {
      solrField = "userGroups";
      propNameForFullname = "groupSpace";
    } else if (type == Type.GROUP_COLLECTIONS) {
      solrField = "childInfo";
      propNameForFullname = "collectionPage";
    } else if (type == Type.COLLECTION_CONTENT) {
      solrField = "childInfo";
      propNameForFullname = "assetpage";
    } else {
      throw new UnsupportedEncodingException();
    }
  }