com.xpn.xwiki.web.Utils.prepareContext()方法的使用及代码示例

x33g5p2x  于2022-02-01 转载在 其他  
字(3.8k)|赞(0)|评价(0)|浏览(94)

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

Utils.prepareContext介绍

暂无

代码示例

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

protected XWikiContext initializeXWikiContext(PortletRequest portletRequest, PortletResponse portletResponse)
  throws XWikiException, PortletException
{
  XWikiRequest request = new XWikiPortletRequest(portletRequest);
  XWikiResponse response = new XWikiPortletResponse(portletResponse);
  XWikiEngineContext engineContext = new XWikiPortletContext(portletRequest.getPortletSession().getPortletContext());
  String action = request.getParameter("action");
  if ((action == null) || (action.equals(""))) {
    if (RenderRequest.class.isAssignableFrom(portletRequest.getClass())) {
      action = portletRequest.getPortletMode().equals(CONFIG_PORTLET_MODE)
        ? "portletConfig" : "view";
    } else {
      action = "view";
    }
  }
  
  XWikiContext context = Utils.prepareContext(action, request, response, engineContext);
  // Initialize the Container component which is the new of transporting the Context in the new
  // component architecture.
  initializeContainerComponent(context);
  return context;
}

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

protected XWikiContext initializeXWikiContext(ActionMapping mapping, ActionForm form, HttpServletRequest req,
  HttpServletResponse resp) throws XWikiException, ServletException
{
  String action = mapping.getName();
  XWikiRequest request = new XWikiServletRequest(req);
  XWikiResponse response = new XWikiServletResponse(resp);
  XWikiContext context =
    Utils.prepareContext(action, request, response, new XWikiServletContext(this.servlet.getServletContext()));
  // This code is already called by struts.
  // However struts will also set all the parameters of the form data
  // directly from the request objects.
  // However because of bug http://jira.xwiki.org/jira/browse/XWIKI-2422
  // We need to perform encoding of windows-1252 chars in ISO mode
  // So we need to make sure this code is called
  // TODO: completely get rid of struts so that we control this part of the code and can reduce drastically the
  // number of calls
  if (form != null) {
    form.reset(mapping, request);
  }
  // Add the form to the context
  context.setForm((XWikiForm) form);
  // Initialize the Container component which is the new way of transporting the Context in the new
  // component architecture.
  initializeContainerComponent(context);
  return context;
}

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

/**
 * Initialize XWiki Context and XWiki Container Objects.
 */
private void initXWiki() throws Exception
{
  XWikiEngineContext engine = new XWikiServletContext(getServletContext());
  XWikiRequest request = new XWikiServletRequest(getThreadLocalRequest());
  XWikiResponse response = new XWikiServletResponse(getThreadLocalResponse());
  XWikiContext context = Utils.prepareContext("", request, response, engine);
  context.setMode(XWikiContext.MODE_GWT);
  context.setWikiId("xwiki");
  initializeContainerComponent(context);
  XWiki xwiki = XWiki.getXWiki(context);
  XWikiURLFactory urlf = xwiki.getURLFactoryService().createURLFactory(context.getMode(), context);
  context.setURLFactory(urlf);
  xwiki.prepareResources(context);
  String username = "XWiki.XWikiGuest";
  if (context.getMode() == XWikiContext.MODE_GWT_DEBUG) {
    username = "XWiki.superadmin";
  }
  XWikiUser user = context.getWiki().checkAuth(context);
  if (user != null) {
    username = user.getUser();
  }
  context.setUser(username);
  if (context.getDoc() == null) {
    context.setDoc(new XWikiDocument("Fake", "Document"));
  }
  context.put("ajax", new Boolean(true));
}

代码示例来源:origin: org.xwiki.platform/xwiki-platform-webdav-server

XWikiResponse xwikiResponse = new XWikiServletResponse(response);
xwikiContext = Utils.prepareContext("", xwikiRequest, xwikiResponse, xwikiEngine);
xwikiContext.setMode(XWikiContext.MODE_SERVLET);
xwikiContext.setWikiId("xwiki");

相关文章