gpt4 book ai didi

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

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

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

XWiki.exists介绍

[英]Returns whether a document exists or not
[中]返回文档是否存在

代码示例

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

/**
 * Get a specific class.
 * 
 * @param token The authentication token.
 * @param className The class name.
 * @return A map representing a XWikiClass object.
 * @throws Exception An invalid token is provided or if the given class does not exist.
 */
public Map getClass(String token, String className) throws Exception
{
  XWikiXmlRpcUser user = XWikiUtils.checkToken(token, this.xwikiContext);
  LOG.debug(String.format("User %s has called getClass()", user.getName()));
  if (!this.xwikiApi.exists(className)) {
    throw new Exception(String.format("[Class '%s' does not exist]", className));
  }
  com.xpn.xwiki.api.Class userClass = this.xwikiApi.getClass(className);
  return DomainObjectFactory.createXWikiClass(userClass).toRawMap();
}

代码示例来源: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

if (!xwikiApi.exists(pageId)) {
  throw new Exception(String.format("[Page '%s' doesn't exist]", 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-core

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

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

private List<SearchResult> getRelevantResults()
{
  if (this.relevantResults == null) {
    this.relevantResults = new ArrayList<SearchResult>();
    TopDocs docs = this.results.topDocs();
    for (int i = 0; i < docs.scoreDocs.length; i++) {
      try {
        SearchResult result =
          new SearchResult(this.searcher.doc(docs.scoreDocs[i].doc), docs.scoreDocs[i].score, this.xwiki);
        if (result.isWikiContent()) {
          String prefixedFullName =
            ((EntityReferenceSerializer<String>)
              Utils.getComponent(EntityReferenceSerializer.TYPE_STRING))
              .serialize(result.getDocumentReference());
          if (this.xwiki.exists(result.getDocumentReference())
            && this.xwiki.hasAccessLevel("view", this.context.getUser(), prefixedFullName)) {
            this.relevantResults.add(result);
          }
        }
      } catch (Exception e) {
        LOGGER.error("Error getting search result", e);
      }
    }
  }
  return this.relevantResults;
}

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

String pageId = Utils.getPageId(wikiName, childPageFullName);
if (!Utils.getXWikiApi(componentManager).exists(pageId)) {
  logger.warning(String.format(
    "[Page '%s' appears to be in space '%s' but no information is available.]", pageName, spaceName));

代码示例来源: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

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

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

if (Utils.getXWikiApi(componentManager).exists(webHomePageId)
  && Utils.getXWikiApi(componentManager).hasAccessLevel("view", webHomePageId)) {
  String pageUri =

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

String pageFullName = Utils.getPageId(wikiName, spaceName, pageName);
if (!Utils.getXWikiApi(componentManager).exists(pageFullName)) {
  logger.warning(String
    .format("[Page '%s' appears to be in space '%s' but no information is available.]", pageName,

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

boolean existed = Utils.getXWikiApi(componentManager).exists(pageFullName);

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

pageName = result.getWiki() + ":" + result.getSpace() + "." + result.getName();
if (result.isWikiContent() && this.xwiki.exists(pageName)
  && this.xwiki.checkAccess(pageName, "view")) {
  if (resultcount >= listStartIndex) {

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

&& (!overwrite || !exists(targetDocumentReference) || hasAccessLevel("delete", targetDocStringRef))) {

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

boolean pageAlreadyExists = this.xwikiApi.exists(extendedId.getBasePageId());
Document doc = this.xwikiApi.getDocument(extendedId.getBasePageId());

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

if (!this.xwikiApi.exists(extendedId.getBasePageId())) {
  return storePage(token, pageMap);

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