gpt4 book ai didi

com.xpn.xwiki.api.XWiki.getDocument()方法的使用及代码示例

转载 作者:知者 更新时间:2024-03-27 08:27:05 29 4
gpt4 key购买 nike

本文整理了Java中com.xpn.xwiki.api.XWiki.getDocument()方法的一些代码示例,展示了XWiki.getDocument()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。XWiki.getDocument()方法的具体详情如下:
包路径:com.xpn.xwiki.api.XWiki
类名称:XWiki
方法名:getDocument

XWiki.getDocument介绍

[英]Load a specific revision of a document
[中]加载文档的特定版本

代码示例

代码示例来源:origin: com.xpn.xwiki.platform/xwiki-core

/**
 * Function to wrap a list of XWikiDocument into Document objects
 * 
 * @param docs list of XWikiDocument
 * @return list of Document objects
 */
public List<Document> wrapDocs(List< ? > docs)
{
  List<Document> result = new ArrayList<Document>();
  if (docs != null) {
    for (java.lang.Object obj : docs) {
      try {
        if (obj instanceof XWikiDocument) {
          XWikiDocument doc = (XWikiDocument) obj;
          Document wrappedDoc = doc.newDocument(getXWikiContext());
          result.add(wrappedDoc);
        } else if (obj instanceof Document) {
          result.add((Document) obj);
        } else if (obj instanceof String) {
          Document doc = getDocument(obj.toString());
          if (doc != null) {
            result.add(doc);
          }
        }
      } catch (XWikiException ex) {
      }
    }
  }
  return result;
}

代码示例来源:origin: com.xpn.xwiki.platform/xwiki-core

/**
 * Loads an Document from the database. Rights are checked before sending back the document.
 * 
 * @param fullName the full name of the XWiki document to be loaded
 * @return a Document object or null if it is not accessible
 * @throws XWikiException
 */
public Document getDocument(String fullName) throws XWikiException
{
  DocumentReference reference;
  // We ignore the passed full name if it's null to be backward compatible with previous behaviors.
  if (fullName != null) {
    // Note: We use the CurrentMixed Resolver since we want to use the default page name if the page isn't
    // specified in the passed string, rather than use the current document's page name.
    reference = this.currentMixedDocumentReferenceResolver.resolve(fullName);
  } else {
    reference = this.defaultDocumentReferenceResolver.resolve("");
  }
  return getDocument(reference);
}

代码示例来源:origin: org.xwiki.platform/xwiki-platform-search-lucene-api

new StringBuffer(this.wiki).append(":").append(this.space).append(".").append(this.name).toString();
try {
  document = xwiki.getDocument(fullDocName);
  if (document != null) {
    this.url = document.getAttachmentURL(this.filename, "download");

代码示例来源:origin: com.xpn.xwiki.platform/xwiki-rest-server

/**
 * <p>
 * Get parent document for a given document.
 * </p>
 * 
 * @param doc document to get the parent from.
 * @param xwikiApi the xwiki api.
 * @return parent of the given document, null if none is specified.
 * @throws XWikiException if getting the parent document has failed.
 */
public static Document getParentDocument(Document doc, com.xpn.xwiki.api.XWiki xwikiApi) throws XWikiException
{
  if (StringUtils.isEmpty(doc.getParent())) {
    return null;
  }
  /*
   * This is ugly but we have to mimic the behavior of link generation: if the parent does not specify its space,
   * use the current document space.
   */
  String parentName = doc.getParent();
  if (!parentName.contains(".")) {
    parentName = doc.getSpace() + "." + parentName;
  }
  return xwikiApi.getDocument(parentName);
}

代码示例来源:origin: com.xpn.xwiki.platform/xwiki-core

/**
 * @param token The authentication token.
 * @param spaceKey The space name.
 * @return A list containing PageSummary objects.
 * @throws Exception An invalid token is provided.
 */
public List getPages(String token, String spaceKey) throws Exception
{
  XWikiXmlRpcUser user = XWikiUtils.checkToken(token, this.xwikiContext);
  LOG.debug(String.format("User %s has called getPages()", user.getName()));
  List result = new ArrayList();
  List<String> pageNames = this.xwikiApi.getSpaceDocsName(spaceKey);
  for (String pageName : pageNames) {
    String pageFullName = String.format("%s.%s", spaceKey, pageName);
    if (!this.xwikiApi.exists(pageFullName)) {
      LOG.warn(String.format("[Page '%s' appears to be in space '%s' but no information is available.]",
        pageName, spaceKey));
    } else {
      Document doc = this.xwikiApi.getDocument(pageFullName);
      /* We only add pages we have the right to access */
      if (doc != null) {
        XWikiPageSummary pageSummary = DomainObjectFactory.createXWikiPageSummary(doc);
        result.add(pageSummary.toRawMap());
      }
    }
  }
  return result;
}

代码示例来源:origin: com.xpn.xwiki.platform/xwiki-core

/**
 * Get information about a given space.
 * 
 * @param token The authentication token.
 * @param spaceKey The space name.
 * @return A map representing a Space object.
 * @throws Exception An invalid token is provided or the user doesn't have enough rights to access the space.
 */
public Map getSpace(String token, String spaceKey) throws Exception
{
  XWikiXmlRpcUser user = XWikiUtils.checkToken(token, this.xwikiContext);
  LOG.debug(String.format("User %s has called getSpace()", user.getName()));
  if (!this.xwikiApi.getSpaces().contains(spaceKey)) {
    throw new Exception(String.format("[Space '%s' does not exist]", spaceKey));
  }
  String spaceWebHomeId = String.format("%s.WebHome", spaceKey);
  if (!this.xwikiApi.exists(spaceWebHomeId)) {
    return DomainObjectFactory.createSpace(spaceKey).toRawMap();
  } else {
    Document spaceWebHome = this.xwikiApi.getDocument(spaceWebHomeId);
    /*
     * If doc is null, then we don't have the rights to access the document
     */
    if (spaceWebHome != null) {
      return DomainObjectFactory.createSpace(spaceWebHome).toRawMap();
    } else {
      throw new RuntimeException(String.format("[Space '%s' cannot be accessed]", spaceKey));
    }
  }
}

代码示例来源:origin: com.xpn.xwiki.platform/xwiki-core

Document doc = xwikiApi.getDocument(pageId);
if (doc == null) {
  throw new Exception(String.format("[Page '%s' cannot be accessed]", pageId));

代码示例来源:origin: com.xpn.xwiki.platform/xwiki-core

/**
 * Get the list of spaces.
 * 
 * @param token The authentication token.
 * @return A list of Maps that represent SpaceSummary objects.
 * @throws Exception An invalid token is provided.
 */
public List getSpaces(String token) throws Exception
{
  XWikiXmlRpcUser user = XWikiUtils.checkToken(token, this.xwikiContext);
  LOG.debug(String.format("User %s has called getSpaces()", user.getName()));
  List result = new ArrayList();
  List<String> spaceKeys = this.xwikiApi.getSpaces();
  for (String spaceKey : spaceKeys) {
    String spaceWebHomeId = String.format("%s.WebHome", spaceKey);
    if (!this.xwikiApi.exists(spaceWebHomeId)) {
      result.add(DomainObjectFactory.createSpaceSummary(spaceKey).toRawMap());
    } else {
      Document spaceWebHome = this.xwikiApi.getDocument(spaceWebHomeId);
      /*
       * If doc is null, then we don't have the rights to access the document, and therefore to the space.
       */
      if (spaceWebHome != null) {
        result.add(DomainObjectFactory.createSpaceSummary(spaceWebHome).toRawMap());
      }
    }
  }
  return result;
}

代码示例来源:origin: com.xpn.xwiki.platform/xwiki-rest-server

Document doc = Utils.getXWikiApi(componentManager).getDocument(documentName);
if (doc != null) {
  pages.getPageSummaries().add(

代码示例来源:origin: com.xpn.xwiki.platform/xwiki-core

/**
 * Get revision history of a page.
 * 
 * @param token The authentication token.
 * @param pageId The pageId in the 'Space.Page[?language=lang]' format.
 * @return A list of maps representing PageHistorySummary objects.
 * @throws Exception An invalid token is provided or if the page does not exist or the user has not the right to
 *             access it.
 */
public List getPageHistory(String token, String pageId) throws Exception
{
  XWikiXmlRpcUser user = XWikiUtils.checkToken(token, this.xwikiContext);
  LOG.debug(String.format("User %s has called getPageHistory()", user.getName()));
  List result = new ArrayList();
  Document doc = XWikiUtils.getDocument(this.xwikiApi, pageId, true);
  Version[] versions = doc.getRevisions();
  for (Version version : versions) {
    Document docRevision = this.xwikiApi.getDocument(doc, version.toString());
    /*
     * The returned document has the right content but the wrong content update date, that is always equals to
     * the current date. Don't know why.
     */
    result.add(DomainObjectFactory.createXWikiPageHistorySummary(docRevision).toRawMap());
  }
  return result;
}

代码示例来源:origin: com.xpn.xwiki.platform/xwiki-core

String pageFullName = String.format("%s.%s", spaceKey, pageName);
if (this.xwikiApi.exists(pageFullName)) {
  Document doc = this.xwikiApi.getDocument(pageFullName);
  if (doc != null) {
    try {

代码示例来源:origin: com.xpn.xwiki.platform/xwiki-rest-server

"[Page '%s' appears to be in space '%s' but no information is available.]", pageName, spaceName));
} else {
  Document childDoc = Utils.getXWikiApi(componentManager).getDocument(pageId);

代码示例来源:origin: com.xpn.xwiki.platform/xwiki-core

/**
 * Add a new space. It basically creates a SpaceKey.WebHome page with no content and the space title as its title.
 * 
 * @param token The authentication token.
 * @param spaceMap The map representing a Space object.
 * @return The newly created space as a Space object.
 * @throws Exception An invalid token is provided or the space cannot be created or it already exists and the user
 *             has not the rights to modify it
 */
public Map addSpace(String token, Map spaceMap) throws Exception
{
  XWikiXmlRpcUser user = XWikiUtils.checkToken(token, this.xwikiContext);
  LOG.debug(String.format("User %s has called addSpace()", user.getName()));
  Space space = new Space(spaceMap);
  if (this.xwikiApi.getSpaces().contains(space.getKey())) {
    throw new Exception(String.format("[Space '%s' already exists]", space.getKey()));
  }
  String spaceWebHomeId = String.format("%s.WebHome", space.getKey());
  Document spaceWebHome = this.xwikiApi.getDocument(spaceWebHomeId);
  if (spaceWebHome != null) {
    spaceWebHome.setContent("");
    spaceWebHome.setTitle(space.getName());
    spaceWebHome.save();
    return DomainObjectFactory.createSpace(spaceWebHome).toRawMap();
  } else {
    throw new Exception(String.format(
      "[Space cannot be created or it already exists and user '%s' has not the right to modify it]",
      user.getName()));
  }
}

代码示例来源:origin: com.xpn.xwiki.platform/xwiki-rest-server

@GET
  public Space getSpace(@PathParam("wikiName") String wikiName, @PathParam("spaceName") String spaceName)
    throws XWikiException
  {
    String database = Utils.getXWikiContext(componentManager).getDatabase();

    /* This try is just needed for executing the finally clause. */
    try {
      Utils.getXWikiContext(componentManager).setDatabase(wikiName);

      String homeId = Utils.getPageId(wikiName, spaceName, "WebHome");
      Document home = null;

      if (Utils.getXWikiApi(componentManager).exists(homeId)) {
        home = Utils.getXWikiApi(componentManager).getDocument(homeId);
      }

      return DomainObjectFactory.createSpace(objectFactory, uriInfo.getBaseUri(), wikiName, spaceName, home);
    } finally {
      Utils.getXWikiContext(componentManager).setDatabase(database);
    }
  }
}

代码示例来源:origin: com.xpn.xwiki.platform/xwiki-rest-server

home = Utils.getXWikiApi(componentManager).getDocument(homeId);

代码示例来源:origin: com.xpn.xwiki.platform/xwiki-rest-server

spaceName));
} else {
  Document doc = Utils.getXWikiApi(componentManager).getDocument(pageFullName);

代码示例来源:origin: com.xpn.xwiki.platform/xwiki-rest-server

Document doc = Utils.getXWikiApi(componentManager).getDocument(pageFullName);

代码示例来源:origin: com.xpn.xwiki.platform/xwiki-core

Document doc = this.xwikiApi.getDocument(extendedId.getBasePageId());
    doc = this.xwikiApi.getDocument(newPageId);
  } else {

代码示例来源:origin: org.xwiki.platform/xwiki-platform-search-lucene-api

Document doc = xwikiApi.getDocument(pageId);
String title = doc.getDisplayTitle();

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com