com.xpn.xwiki.web.Utils类的使用及代码示例

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

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

Utils介绍

暂无

代码示例

代码示例来源:origin: org.xwiki.platform/xwiki-platform-skin-skinx

protected SkinExtensionAsync getSkinExtensionAsync()
  {
    if (this.async == null) {
      this.async = Utils.getComponent(SkinExtensionAsync.class);
    }

    return this.async;
  }
}

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

@Override
public void init(XWikiContext context)
{
  Thread thread = new Thread(new ExecutionContextRunnable(new Runnable()
  {
    @Override
    public void run()
    {
      initAsync();
    }
  }, Utils.getComponentManager()));
  thread.setName("XWiki Scheduler initialization");
  thread.setDaemon(true);
  thread.start();
  // Start listening to documents modifications
  Utils.getComponent(ObservationManager.class).addListener(this);
}

代码示例来源:origin: org.xwiki.platform/xwiki-platform-skin-skinx

XWikiContext context = Utils.getContext();
        if (Utils.getComponent(AuthorizationManager.class).hasAccess(Right.PROGRAM,
          doc.getContentAuthorReference(), doc.getDocumentReference())) {
          extensions.add(extension);

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

protected boolean prepareAction(String action, XWikiRequest request, XWikiResponse response,
  XWikiEngineContext engine_context, XWikiContext context) throws XWikiException, IOException
{
  XWiki xwiki = XWiki.getXWiki(context);
  Utils.handleMultipart(processMultipart(request.getHttpServletRequest()), context);
  XWikiURLFactory urlf = xwiki.getURLFactoryService().createURLFactory(context.getMode(), context);
  context.setURLFactory(urlf);
  VelocityManager velocityManager =
    (VelocityManager) Utils.getComponent(VelocityManager.class);
  VelocityContext vcontext = velocityManager.getVelocityContext();
  
  return xwiki.prepareDocuments(request, context, vcontext);
}

代码示例来源: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");
ServletContainerInitializer containerInitializer = Utils.getComponent(ServletContainerInitializer.class);
containerInitializer.initializeRequest(xwikiContext.getRequest().getHttpServletRequest(), xwikiContext);
containerInitializer.initializeResponse(xwikiContext.getResponse());

代码示例来源: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: org.phenotips/medsavant-client-api

String url = getMethodURL("UploadManager", "upload");
String eid = identifiers.get("external_id");
XWikiContext context = Utils.getContext();
XWikiDocument doc = context.getWiki().getDocument(patient.getDocument(), context);
method = new HttpPost(url);

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

/**
 * TODO: This is only a temporary work around, we need to use a component-based init mechanism instead. Note that we
 * need DB access to be available (at component initialization) to make this possible.
 * <p>
 * This method is protected to be able to skip it in unit tests.
 */
protected void registerWikiMacros()
{
  try {
    WikiMacroInitializer wikiMacroInitializer = Utils.getComponentManager().lookup(WikiMacroInitializer.class);
    wikiMacroInitializer.registerExistingWikiMacros();
  } catch (Exception ex) {
    LOG.error("Error while registering wiki macros.", ex);
  }
}

代码示例来源: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.phenotips/anonymous-communication

@Override
public int sendSuccessMail(Connection connection)
{
  try {
    Map<String, Object> options = new HashMap<String, Object>();
    XWikiContext context = Utils.getContext();
    XWiki xwiki = context.getWiki();
    MailSenderPlugin mailsender = (MailSenderPlugin) xwiki.getPlugin(MAIL_SENDER, context);
    String to = getEmail(connection.getInitiatingUser());
    options.put("platformName", PLATFORM);
    options.put(SUBJECT_FIELD_STRING, SUBJECT);
    options.put(RECIPIENT_NAME,
      xwiki.getUserName(connection.getInitiatingUser().toString(), null, false, context));
    options.put(CONTACTED_USER_NAME,
      xwiki.getUserName(connection.getContactedUser().toString(), null, false, context));
    options.put(MATCH_CASE_ID, connection.getTargetPatient().getDocument().getName());
    options.put("matchCaseReferenceId", connection.getReferencePatient().getDocument().getName());
    options.put(MATCH_CASE_LINK, xwiki.getDocument(connection.getTargetPatient().getDocument(), context)
      .getExternalURL(EXTERNAL_LINK_MODE, context));
    options.put("matchCaseReferenceLink",
      xwiki.getDocument(connection.getReferencePatient().getDocument(), context)
        .getExternalURL(EXTERNAL_LINK_MODE, context));
    mailsender.sendMailFromTemplate("PhenoTips.MatchSuccessContact", PHENOMECENTRAL_EMAIL,
      to, null, null, "", options, context);
    return 0;
  } catch (Exception ex) {
    this.logger.error(FAILED_MAIL_MSG, ex.getMessage(), ex);
    return 1;
  }
}

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

/**
 * Gets all syntaxes supported by the rendering parsers as an input for a syntax conversion.
 * 
 * @param token The authentication token.
 * @return A list containing all syntaxes supported by rendering parsers.
 * @throws Exception An invalid token is provided or the syntax lookup fails.
 */
public List<String> getInputSyntaxes(String token) throws Exception
{
  XWikiXmlRpcUser user = XWikiUtils.checkToken(token, this.xwikiContext);
  List<String> syntaxes = new ArrayList<String>();
  List<Parser> parsers;
  ComponentManager componentManager = Utils.getComponentManager();
  try {
    parsers = componentManager.lookupList(Parser.class);
    for (Parser parser : parsers) {
      syntaxes.add(parser.getSyntax().toIdString());
    }
  } catch (ComponentLookupException e) {
    throw new RuntimeException("Failed to lookup the list of available parser syntaxes", e);
  }
  return syntaxes;
}

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

private EntityReferenceSerializer<String> getLocalSerializer()
{
  if (this.localSerializer == null) {
    this.localSerializer = Utils.getComponent(EntityReferenceSerializer.TYPE_STRING, "local");
  }
  return this.localSerializer;
}

代码示例来源: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.phenotips/anonymous-communication

XWikiContext context = Utils.getContext();
XWiki xwiki = context.getWiki();
MailSenderPlugin mailsender = (MailSenderPlugin) xwiki.getPlugin(MAIL_SENDER, context);

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

/**
 * Gets all syntaxes supported by the rendering as an output for a syntax conversion.
 * 
 * @param token The authentication token.
 * @return A list containing all syntaxes supported by renderers.
 * @throws Exception An invalid token is provided or the syntax lookup fails.
 */
public List<String> getOutputSyntaxes(String token) throws Exception
{
  XWikiXmlRpcUser user = XWikiUtils.checkToken(token, this.xwikiContext);
  List<String> syntaxes = new ArrayList<String>();
  List<PrintRendererFactory> renderers;
  ComponentManager componentManager = Utils.getComponentManager();
  try {
    // TODO: use BlockRenderer
    renderers = componentManager.lookupList(PrintRendererFactory.class);
    for (PrintRendererFactory renderer : renderers) {
      syntaxes.add(renderer.getSyntax().toIdString());
    }
  } catch (ComponentLookupException e) {
    throw new RuntimeException("Failed to lookup the list of available renderer syntaxes", e);
  }
  return syntaxes;
}

代码示例来源:origin: org.phenotips/phenotips-crypto-xproperty

private CryptoUtils getCryptoUtils()
  {
    return Utils.getComponent(CryptoUtils.class);
  }
}

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

/**
 * Ensure that mandatory classes (ie classes XWiki needs to work properly) exist and create them if they don't
 * exist.
 */
private void initializeMandatoryClasses(XWikiContext context) throws XWikiException
{
  getPrefsClass(context);
  getUserClass(context);
  getTagClass(context);
  getGroupClass(context);
  getRightsClass(context);
  getCommentsClass(context);
  getSkinClass(context);
  getGlobalRightsClass(context);
  getSheetClass(context);
  try {
    WikiMacroInitializer wikiMacroInitializer = Utils.getComponentManager().lookup(WikiMacroInitializer.class);
    wikiMacroInitializer.installOrUpgradeWikiMacroClasses();
  } catch (Exception ex) {
    LOG.error("Error while installing / upgrading xwiki classes required for wiki macros.", ex);
  }
  if (context.getDatabase().equals(context.getMainXWiki())
    && "1".equals(context.getWiki().Param("xwiki.preferences.redirect"))) {
    getRedirectClass(context);
  }
}

代码示例来源:origin: org.xwiki.platform/xwiki-platform-skin-skinx

/**
 * Used to convert a proper Document Reference to string (standard form).
 */
protected EntityReferenceSerializer<String> getDefaultEntityReferenceSerializer()
{
  if (this.defaultEntityReferenceSerializer == null) {
    this.defaultEntityReferenceSerializer = Utils.getComponent(EntityReferenceSerializer.TYPE_STRING);
  }
  return this.defaultEntityReferenceSerializer;
}

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

public void initCache(int iCapacity, int iClassCapacity, XWikiContext context) throws XWikiException
{
  try {
    CacheManager cacheManager = Utils.getComponentManager().lookup(CacheManager.class);
    CacheConfiguration configuration = new CacheConfiguration();
    configuration.setConfigurationId("xwiki.groovy.content");
    LRUEvictionConfiguration lru = new LRUEvictionConfiguration();
    lru.setMaxEntries(iCapacity);
    configuration.put(LRUEvictionConfiguration.CONFIGURATIONID, lru);
    this.cache = cacheManager.createNewLocalCache(configuration);
    configuration = new CacheConfiguration();
    configuration.setConfigurationId("xwiki.groovy.class");
    lru = new LRUEvictionConfiguration();
    lru.setMaxEntries(iClassCapacity);
    configuration.put(LRUEvictionConfiguration.CONFIGURATIONID, lru);
    this.classCache = cacheManager.createNewLocalCache(configuration);
  } catch (CacheException e) {
    throw new XWikiException(XWikiException.MODULE_XWIKI_CACHE, XWikiException.ERROR_CACHE_INITIALIZING,
      "Failed to initilize caches", e);
  } catch (ComponentLookupException e) {
    throw new XWikiException(XWikiException.MODULE_XWIKI_CACHE, XWikiException.ERROR_CACHE_INITIALIZING,
      "Failed to initilize caches", e);
  }
}

代码示例来源:origin: org.xwiki.platform/xwiki-platform-skin-skinx

/**
 * Used to resolve a document string reference to a Document Reference.
 */
protected DocumentReferenceResolver<String> getCurrentDocumentReferenceResolver()
{
  if (this.currentDocumentReferenceResolver == null) {
    this.currentDocumentReferenceResolver =
      Utils.getComponent(DocumentReferenceResolver.TYPE_STRING, "current");
  }
  return this.currentDocumentReferenceResolver;
}

相关文章

微信公众号

最新文章

更多