gpt4 book ai didi

com.xpn.xwiki.api.XWiki类的使用及代码示例

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

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

XWiki介绍

暂无

代码示例

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

public XWikiXmlRpcApiImpl()
{
  this.xwikiContext = getContext();
  this.xwiki = this.xwikiContext.getWiki();
  this.xwikiApi = new com.xpn.xwiki.api.XWiki(this.xwiki, this.xwikiContext);
}

代码示例来源: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 (hasAccessLevel("view", this.defaultStringEntityReferenceSerializer.serialize(sourceDocumentReference))) {
  String targetDocStringRef = this.defaultStringEntityReferenceSerializer.serialize(targetDocumentReference);
  if (hasAccessLevel("edit", targetDocStringRef)
    && (!overwrite || !exists(targetDocumentReference) || hasAccessLevel("delete", targetDocStringRef))) {
      resetHistory, overwrite, true, getXWikiContext());

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

/**
 * Priviledge API to regenerate the links/backlinks table Normally links and backlinks are stored when a page is
 * modified This function will regenerate all the backlinks This function can be long to run
 * 
 * @throws XWikiException exception if the generation fails
 */
public void refreshLinks() throws XWikiException
{
  if (hasAdminRights()) {
    this.xwiki.refreshLinks(getXWikiContext());
  }
}

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

/**
 * API to check rights on the current document for the current user
 * 
 * @param level right to check (view, edit, comment, delete)
 * @return true if right is granted/false if not
 */
public boolean hasAccessLevel(String level)
{
  return hasAccessLevel(level, getXWikiContext().getUser(), getXWikiContext().getDoc().getFullName());
}

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

XWiki xwikiApi = new XWiki(xwikiContext.getWiki(), xwikiContext);
    if (xwikiApi.hasAccessLevel("view", pageId)) {
      Document doc = xwikiApi.getDocument(pageId);
      String title = doc.getDisplayTitle();
        searchResult.setAuthorName(xwikiApi.getUserName(luceneSearchResult.getAuthor(), false));

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

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

LOG.debug(String.format("User %s has called removeSpace()", user.getName()));
if (!this.xwikiApi.getSpaces().contains(spaceKey)) {
  throw new Exception(String.format("[Space '%s' does not exist.]", spaceKey));
List<String> pageNames = this.xwikiApi.getSpaceDocsName(spaceKey);
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) {
      try {

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

page.setSyntaxId(xwikiApi.getDefaultDocumentSyntax());
boolean pageAlreadyExists = this.xwikiApi.exists(extendedId.getBasePageId());
Document doc = this.xwikiApi.getDocument(extendedId.getBasePageId());
    this.xwikiApi.renamePage(doc, newPageId);
    doc = this.xwikiApi.getDocument(newPageId);
  } else {

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

/**
 * 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: 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

/**
 * 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-rest-server

@GET
  public Classes getClasses(@PathParam("wikiName") String wikiName,
    @QueryParam("start") @DefaultValue("0") Integer start, @QueryParam("number") @DefaultValue("-1") Integer number)
    throws XWikiException
  {

    String database = Utils.getXWikiContext(componentManager).getDatabase();

    try {
      Utils.getXWikiContext(componentManager).setDatabase(wikiName);

      List<String> classNames = Utils.getXWikiApi(componentManager).getClassList();
      Collections.sort(classNames);

      RangeIterable<String> ri = new RangeIterable<String>(classNames, start, number);

      Classes classes = objectFactory.createClasses();

      for (String className : ri) {
        com.xpn.xwiki.api.Class xwikiClass = Utils.getXWikiApi(componentManager).getClass(className);
        classes.getClazzs().add(
          DomainObjectFactory.createClass(objectFactory, uriInfo.getBaseUri(), wikiName, xwikiClass));
      }

      return classes;
    } finally {
      Utils.getXWiki(componentManager).setDatabase(database);
    }
  }
}

代码示例来源: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: 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) {
    relResults.add(result);

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

if (Utils.getXWikiApi(componentManager).hasAccessLevel("view", pageId)) {
  SearchResult searchResult = objectFactory.createSearchResult();
  searchResult.setType("page");

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

@GET
  public Class getClass(@PathParam("wikiName") String wikiName, @PathParam("className") String className)
    throws XWikiException
  {

    String database = Utils.getXWikiContext(componentManager).getDatabase();

    try {
      Utils.getXWikiContext(componentManager).setDatabase(wikiName);

      com.xpn.xwiki.api.Class xwikiClass = Utils.getXWikiApi(componentManager).getClass(className);
      if (xwikiClass == null) {
        throw new WebApplicationException(Status.NOT_FOUND);
      }

      return DomainObjectFactory.createClass(objectFactory, uriInfo.getBaseUri(), wikiName, xwikiClass);
    } finally {
      Utils.getXWiki(componentManager).setDatabase(database);
    }
  }
}

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

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

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