コード例 #1
0
  /**
   * @param entity user reference.
   * @return a pretty name for the user based on entities "alt" attributes or their names.
   */
  protected String getEntityReadableName(EntityReference entity) {
    if (entity == null) {
      return "Main Wiki";
    }

    StringBuilder result = null;

    if (entity.getType() == EntityType.DOCUMENT) {
      TestEntity docEntity = testDefinition.searchEntity(entity);
      String name =
          (docEntity != null && docEntity instanceof TestDocument)
              ? ((TestDocument) docEntity).getDescription()
              : null;
      name = (name != null) ? name : entity.getName();
      result = new StringBuilder(name);
      entity = entity.getParent();
    }

    if (entity.getType() == EntityType.SPACE) {
      TestEntity spaceEntity = testDefinition.searchEntity(entity);
      String name =
          (spaceEntity != null && spaceEntity instanceof TestSpace)
              ? ((TestSpace) spaceEntity).getDescription()
              : null;
      name = (name != null) ? name : entity.getName();
      if (result == null || !name.startsWith("any")) {
        if (result != null) {
          result.append(" in ");
          result.append(name);
        } else {
          result = new StringBuilder(name);
        }
      }
      entity = entity.getParent();
    }

    if (entity.getType() == EntityType.WIKI) {
      TestEntity wikiEntity = testDefinition.getWiki(new WikiReference(entity));
      String name = (wikiEntity != null) ? ((TestWiki) wikiEntity).getDescription() : null;
      name = (name != null) ? name : entity.getName();
      if (result == null || !name.startsWith("any")) {
        if (result != null) {
          result.append(" from ");
          result.append(name);
        } else {
          result = new StringBuilder(name);
        }
      }
    }

    return result.toString();
  }
コード例 #2
0
  /**
   * @param user user reference.
   * @return a pretty name for the user based on entities "alt" attributes or their names.
   */
  protected String getUserReadableName(DocumentReference user) {
    if (user == null) {
      return "Public";
    }

    TestEntity userEntity = testDefinition.searchEntity(user);
    String result =
        (userEntity != null && userEntity instanceof TestDocument)
            ? ((TestDocument) userEntity).getDescription()
            : null;
    result = (result != null) ? result : user.getName();

    TestWiki wiki = testDefinition.getWiki(user.getWikiReference());
    String name = (wiki != null) ? wiki.getDescription() : null;
    name = (name != null) ? name : user.getWikiReference().getName();
    if (!name.startsWith("any")) {
      result += " from " + name;
    }

    return result;
  }
コード例 #3
0
 /**
  * @param name document name.
  * @param space space name.
  * @return a reference to a document in a space of the main wiki.
  */
 protected DocumentReference getXDoc(String name, String space) {
   return new DocumentReference(
       name, new SpaceReference(space, testDefinition.getMainWiki().getWikiReference()));
 }
コード例 #4
0
 /**
  * @param space space name.
  * @return a reference to a space in the main wiki.
  */
 protected SpaceReference getXSpace(String space) {
   return new SpaceReference(space, testDefinition.getMainWiki().getWikiReference());
 }
コード例 #5
0
 /** @return a reference to the main wiki. */
 protected WikiReference getXWiki() {
   return testDefinition.getMainWiki().getWikiReference();
 }
コード例 #6
0
 /**
  * @param name user name.
  * @param wiki subwiki name.
  * @return a reference to a user in a sub wiki.
  */
 protected DocumentReference getUser(String name, String wiki) {
   return new DocumentReference(
       name,
       new SpaceReference(
           XWikiConstants.XWIKI_SPACE, testDefinition.getWiki(wiki).getWikiReference()));
 }