org.sakaiproject.util.Web类的使用及代码示例

x33g5p2x  于2022-02-03 转载在 其他  
字(14.6k)|赞(0)|评价(0)|浏览(221)

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

Web介绍

[英]Web is a web (html, http, etc) technlogies collection of helper methods.
[中]Web是Web(html、http等)技术的助手方法集合。

代码示例

代码示例来源:origin: sakaiproject/sakai

public String getActionURL(FacesContext context, String viewId)
{
  HttpServletRequest req = (HttpServletRequest) context.getExternalContext().getRequest();
  if (req.getAttribute(URL_EXT) == null)
  {
    // If the request didn't go through JsfTool (the JSF is accessed directly from its webapp, 
    // not as a Sakai tool), then don't do Sakai's special action URL handling.
    return m_wrapped.getActionURL(context, viewId);
  }
  
  // get the path that got us here (from the tool's point of view)
  String path = viewId;
  // modify the path to remove things that were added by Sakai navigation to get here (prefix path, suffix extension)
  String prefix = (String) req.getAttribute(URL_PATH);
  if ((prefix != null) && path.startsWith(prefix)) path = path.substring(prefix.length());
  Object extensions = req.getAttribute(URL_EXT);
  String [] exts = extensions instanceof String?new String[]{(String)extensions}:(String[])extensions; 
  for (String ext:exts) {
    if ((ext != null) && path.endsWith(ext)) path = path.substring(0, path.length() - ext.length());
  }
  // make sure the URL processing uses the Sakai, not Native the request object so we can get at the URL information setup by the invoker
  req.removeAttribute(Tool.NATIVE_URL);
  // form our return URL
  String rv = Web.returnUrl(req, path);
  // restore (if needed)
  req.setAttribute(Tool.NATIVE_URL, Tool.NATIVE_URL);
  log.debug("action url for view: " + viewId + " = " + rv);
  return rv;
}

代码示例来源:origin: sakaiproject/sakai

@Override
public int doGet(String[] parts, HttpServletRequest req, HttpServletResponse res,
    Session session) throws PortalHandlerException
{
  if ((parts.length >= 2) && (parts[1].equals(HelpHandler.URL_FRAGMENT)) && (parts.length == 2 || !parts[2].equals(HelpHandler.WEB_INF_FRAGMENT)))
  {
    try
    {
      doHelp(req, res, session, req.getContextPath() + req.getServletPath()
          + Web.makePath(parts, 1, 2), Web.makePath(parts, 2, parts.length));
      return END;
    }
    catch (Exception ex)
    {
      throw new PortalHandlerException(ex);
    }
  }
  else
  {
    return NEXT;
  }
}

代码示例来源:origin: org.sakaiproject.kernel/sakai-kernel-impl

/** HTML escape and store the site's short description. */
protected void escapeShortDescription()
{
  m_htmlShortDescription = Web.escapeHtml(m_shortDescription);
}

代码示例来源:origin: sakaiproject/sakai

protected String htmlContent(Event event) {
  return Web.encodeUrlsAsHtml(Web.escapeHtml(plainTextContent(event),true));
}

代码示例来源:origin: org.sakaiproject.portal/sakai-portal-render-impl

final String titleString = Web.escapeHtml(configuration.getTitle());
String toolUrl = ServerConfigurationService.getToolUrl() + "/"
    + Web.escapeUrl(configuration.getId());
StoredState ss = portalService.getStoredState();
LOG.debug("Restoring Iframe [" + ss + "]");
    Web.escapeJavascript("Main" + configuration.getId())).append("\"\n")
    .append("	id=\"").append(
        Web.escapeJavascript("Main" + configuration.getId()))
    .append("\"\n	title=\"").append(titleString).append(" ").
  sb.append("sakai_action=").append(Web.escapeHtml(sakaiAction));

代码示例来源:origin: sakaiproject/sakai

userId != null && portal.getSiteHelper().isJoinable(siteId, userId))
    String redirectUrl = Web.returnUrl(req, "/join/"+siteId);
    res.sendRedirect(redirectUrl);
    return;
      TCP = req.getContextPath() + req.getServletPath() + Web.makePath(parts, 1, 5);
      toolPathInfo = Web.makePath(parts, 5, parts.length);
  rcontext.put("shortDescription", Web.escapeHtml(site.getShortDescription()));
rcontext.put("currentUrlPath", Web.serverUrl(req) + req.getContextPath()
    + URLUtils.getSafePathInfo(req));

代码示例来源:origin: sakaiproject/sakai

Site s = (Site) iSi.next();
if (myWorkspaceSiteId.equals(s.getId()) ) {
  mrphs_worksiteUrl = Web.returnUrl(request, "/site/" + Web.escapeUrl(siteHelper.getSiteEffectiveId(s)));
  List pages = siteHelper.getPermittedPagesInOrder(s);
  for (Iterator iPg = pages.iterator(); iPg.hasNext();) {
      ToolConfiguration placement = (ToolConfiguration) iPt.next();
      if ( profileToolId.equals(placement.getToolId()) ) {
        profileToolUrl = Web.returnUrl(request, "/site/" + Web.escapeUrl(siteHelper.getSiteEffectiveId(s)) + "/page/" + Web.escapeUrl(p.getId()));
        mrphs_profileToolUrl = Web.returnUrl(request, "/site/" + Web.escapeUrl(siteHelper.getSiteEffectiveId(s)) + "/tool-reset/" + Web.escapeUrl(placement.getId()));
      } else if ( preferencesToolId.equals(placement.getToolId()) ) {
        prefsToolUrl = Web.returnUrl(request, "/site/" + Web.escapeUrl(siteHelper.getSiteEffectiveId(s)) + "/page/" + Web.escapeUrl(p.getId()));
        mrphs_prefsToolUrl = Web.returnUrl(request, "/site/" + Web.escapeUrl(siteHelper.getSiteEffectiveId(s)) + "/tool-reset/" + Web.escapeUrl(placement.getId()));
      } else if ( worksiteToolId.equals(placement.getToolId()) ) {
        worksiteToolUrl = Web.returnUrl(request, "/site/" + Web.escapeUrl(siteHelper.getSiteEffectiveId(s)) + "/page/" + Web.escapeUrl(p.getId()));
        mrphs_worksiteToolUrl = Web.returnUrl(request, "/site/" + Web.escapeUrl(siteHelper.getSiteEffectiveId(s)) + "/tool-reset/" + Web.escapeUrl(placement.getId()));

代码示例来源:origin: sakaiproject/sakai

String pagePopupUrl = Web.returnUrl(req, "/page/");
    m.put("ispopup", Boolean.valueOf(p.isPopUp()));
    m.put("pagePopupUrl", pagePopupUrl);
    m.put("pageTitle", Web.escapeHtml(p.getTitle()));
    m.put("jsPageTitle", Web.escapeJavascript(p.getTitle()));
    m.put("pageId", Web.escapeUrl(p.getId()));
    m.put("jsPageId", Web.escapeJavascript(p.getId()));
    m.put("pageRefUrl", pagerefUrl);
    m.put("pageResetUrl", pageResetUrl);
  String toolUrl = Web.returnUrl(req, "/" + portalPrefix + "/"
    + Web.escapeUrl(getSiteEffectiveId(site)));
  if (resetTools) {
    toolUrl = toolUrl + "/tool-reset/";
      String toolrefUrl = toolUrl + Web.escapeUrl(placement.getId());
      m.put("toolId", Web.escapeUrl(placement.getId()));
      m.put("jsToolId", Web.escapeJavascript(placement.getId()));
      m.put("toolRegistryId", placement.getToolId());
      m.put("toolTitle", Web.escapeHtml(placement.getTitle()));
      m.put("jsToolTitle", Web.escapeJavascript(placement.getTitle()));
      m.put("toolrefUrl", toolrefUrl);
      m.put("toolpopup", Boolean.valueOf(source!=null));
String presenceUrl = Web.returnUrl(req, "/presence/"
    + Web.escapeUrl(site.getId()));

代码示例来源:origin: sakaiproject/sakai

String titleString = Web.escapeHtml(placement.getTitle());
String toolId = Web.escapeHtml(placement.getToolId());
  + Web.escapeUrl(placement.getId()) + "/";
log.debug("includeTool toolInline={} toolUrl={}", toolInline, toolUrl);
  resetActionUrl = Web.serverUrl(req)
  + ServerConfigurationService.getString("portalPath")
  + URLUtils.getSafePathInfo(req) + "?sakai.state.reset=true";
  toolMap.put("toolJSR168Help", Web.serverUrl(req) + renderResult.getJSR168HelpUrl());
      .getReference()))
    String editUrl = Web.serverUrl(req) + renderResult.getJSR168EditUrl();
    toolMap.put("toolJSR168Edit", editUrl);
    toolMap.put("toolJSR168EditEncode", URLUtils.encodeUrl(editUrl));
  toolMap.put("toolPlacementIDJS", Web.escapeJavascript("Main"
      + placement.getId()));
toolMap.put("toolInline", Boolean.valueOf(toolInline));
String directToolUrl = ServerConfigurationService.getPortalUrl() + "/" + DirectToolHandler.URL_FRAGMENT +"/" + Web.escapeUrl(placement.getId()) + "/";
toolMap.put("directToolUrl", directToolUrl);

代码示例来源:origin: sakaiproject/sakai

m.put("shortDescription", Web.escapeHtml(shortDesc_trimmed));
String siteUrl = Web.serverUrl(req)
    + ServerConfigurationService.getString("portalPath") + "/";
if (prefix != null) siteUrl = siteUrl + prefix + "/";
m.put("siteUrl", siteUrl + Web.escapeUrl(getSiteEffectiveId(s)));
m.put("siteType", s.getType());
m.put("siteId", s.getId());
      pm.put("siteTitle", parentSiteTitle);
      pm.put("siteTitleTrunc", parentSiteTitleTruncated);
      pm.put("siteUrl", siteUrl + Web.escapeUrl(getSiteEffectiveId(site)));

代码示例来源:origin: sakaiproject/sakai

/**
 * Compute the URL that would return to this servlet based on the current request, with the optional path and parameters
 * 
 * @param req
 *        The request.
 * @return The URL back to this servlet based on the current request.
 */
public static String returnUrl(HttpServletRequest req, String path)
{
  StringBuilder url = new StringBuilder();
  url.append(serverUrl(req));
  url.append(req.getContextPath());
  url.append(req.getServletPath());
  if (path != null) url.append(path);
  // TODO: params
  return url.toString();
}

代码示例来源:origin: org.sakaiproject/sakai-chat-impl

String msgbody = Web.escapeJsQuoted(Web.escapeHtmlFormattedText(message.getBody()));
msgbody = msgbody.replace('\n',' ').replace('\r',' ');
retvalBuf.append( Web.escapeJsQuoted(Web.escapeHtml(displayName)) );

代码示例来源:origin: org.sakaiproject.metaobj/sakai-metaobj-tool-lib

protected Map getParameters(HttpServletRequest request) {
 Map params = super.getParameters(request);
 if (params == null) {
   params = new Hashtable();
 }
 if (ToolManager.getCurrentPlacement() != null) {
   params.put("panelId", Web.escapeJavascript("Main" + ToolManager.getCurrentPlacement().getId()));
   params.put(FormHelper.XSL_SITE_ID, ToolManager.getCurrentPlacement().getContext());
 }
 if ( request.getAttribute(STYLESHEET_PARAMS) != null )
   params.putAll((Map) request.getAttribute(STYLESHEET_PARAMS));
 if ( request.getAttribute(STYLESHEET_LOCATION) != null )
   params.put(STYLESHEET_LOCATION, request.getAttribute(STYLESHEET_LOCATION));
 return params;
}

代码示例来源:origin: org.sakaiproject.kernel/sakai-kernel-impl

public String getUrl(boolean relative)
{
  return getAccessPoint(relative) + Web.escapeUrl(convertIdToUserEid(m_id));
}

代码示例来源:origin: org.sakaiproject.portal/sakai-portal-impl

userId != null && portal.getSiteHelper().isJoinable(siteId, userId))
    String redirectUrl = Web.returnUrl(req, "/join/"+siteId);
    res.sendRedirect(redirectUrl);
    return;
      TCP = req.getContextPath() + req.getServletPath() + Web.makePath(parts, 1, 5);
      toolPathInfo = Web.makePath(parts, 5, parts.length);
  rcontext.put("shortDescription", Web.escapeHtml(site.getShortDescription()));
rcontext.put("currentUrlPath", Web.serverUrl(req) + req.getContextPath()
    + URLUtils.getSafePathInfo(req));

代码示例来源:origin: sakaiproject/sakai

String pageUrl = Web.returnUrl(req, "/" + portalPrefix + "/"
    + Web.escapeUrl(effectiveSiteId) + "/page/");
pageUrl = pageUrl + Web.escapeUrl(pageAlias);
if (!trinity) return pageUrl;
pageUrl = Web.returnUrl(req, "/" + portalPrefix + "/" + Web.escapeUrl(effectiveSiteId));
if (reset || resetSiteProperty) {
  pageUrl = pageUrl + "/tool-reset/";

代码示例来源:origin: org.sakaiproject.portal/sakai-portal-impl

String pagePopupUrl = Web.returnUrl(req, "/page/");
    m.put("ispopup", Boolean.valueOf(p.isPopUp()));
    m.put("pagePopupUrl", pagePopupUrl);
    m.put("pageTitle", Web.escapeHtml(p.getTitle()));
    m.put("jsPageTitle", Web.escapeJavascript(p.getTitle()));
    m.put("pageId", Web.escapeUrl(p.getId()));
    m.put("jsPageId", Web.escapeJavascript(p.getId()));
    m.put("pageRefUrl", pagerefUrl);
    m.put("pageResetUrl", pageResetUrl);
  String toolUrl = Web.returnUrl(req, "/" + portalPrefix + "/"
    + Web.escapeUrl(getSiteEffectiveId(site)));
  if (resetTools) {
    toolUrl = toolUrl + "/tool-reset/";
      String toolrefUrl = toolUrl + Web.escapeUrl(placement.getId());
      m.put("toolId", Web.escapeUrl(placement.getId()));
      m.put("jsToolId", Web.escapeJavascript(placement.getId()));
      m.put("toolRegistryId", placement.getToolId());
      m.put("toolTitle", Web.escapeHtml(placement.getTitle()));
      m.put("jsToolTitle", Web.escapeJavascript(placement.getTitle()));
      m.put("toolrefUrl", toolrefUrl);
      m.put("toolpopup", Boolean.valueOf(source!=null));
String presenceUrl = Web.returnUrl(req, "/presence/"
    + Web.escapeUrl(site.getId()));

代码示例来源:origin: org.sakaiproject.portal/sakai-portal-impl

String titleString = Web.escapeHtml(placement.getTitle());
String toolId = Web.escapeHtml(placement.getToolId());
  + Web.escapeUrl(placement.getId()) + "/";
log.debug("includeTool toolInline={} toolUrl={}", toolInline, toolUrl);
  resetActionUrl = Web.serverUrl(req)
  + ServerConfigurationService.getString("portalPath")
  + URLUtils.getSafePathInfo(req) + "?sakai.state.reset=true";
  toolMap.put("toolJSR168Help", Web.serverUrl(req) + renderResult.getJSR168HelpUrl());
      .getReference()))
    String editUrl = Web.serverUrl(req) + renderResult.getJSR168EditUrl();
    toolMap.put("toolJSR168Edit", editUrl);
    toolMap.put("toolJSR168EditEncode", URLUtils.encodeUrl(editUrl));
  toolMap.put("toolPlacementIDJS", Web.escapeJavascript("Main"
      + placement.getId()));
toolMap.put("toolInline", Boolean.valueOf(toolInline));
String directToolUrl = ServerConfigurationService.getPortalUrl() + "/" + DirectToolHandler.URL_FRAGMENT +"/" + Web.escapeUrl(placement.getId()) + "/";
toolMap.put("directToolUrl", directToolUrl);

代码示例来源:origin: org.sakaiproject.portal/sakai-portal-impl

m.put("shortDescription", Web.escapeHtml(shortDesc_trimmed));
String siteUrl = Web.serverUrl(req)
    + ServerConfigurationService.getString("portalPath") + "/";
if (prefix != null) siteUrl = siteUrl + prefix + "/";
m.put("siteUrl", siteUrl + Web.escapeUrl(getSiteEffectiveId(s)));
m.put("siteType", s.getType());
m.put("siteId", s.getId());
      pm.put("siteTitle", parentSiteTitle);
      pm.put("siteTitleTrunc", parentSiteTitleTruncated);
      pm.put("siteUrl", siteUrl + Web.escapeUrl(getSiteEffectiveId(site)));

代码示例来源:origin: sakaiproject/sakai

/**
 * Send the HTML / Javascript to invoke an automatic update
 * 
 * @param out
 * @param req
 *        The request.
 * @param placementId
 *        The tool's placement id / presence location / part of the delivery address
 * @param updateTime
 *        The time (seconds) between courier checks
 * @deprecated 
 *        To avoid inappropriate kernel dependencies, construct this URL in the tool pending relocation of this to courier (see SAK-18481).
 */
public static void sendAutoUpdate(PrintWriter out, HttpServletRequest req, String placementId, int updateTime)
{
  String userId = ComponentManager.get(SessionManager.class).getCurrentSessionUserId();
  StringBuilder url = new StringBuilder(serverUrl(req));
  url.append("/courier/");
  url.append(placementId);
  url.append("?userId=");
  url.append(userId);
  
  out.println("<script type=\"text/javascript\" language=\"JavaScript\">");
  out.println("updateTime = " + updateTime + "000;");
  out.println("updateUrl = \"" + url.toString() + "\";");
  out.println("scheduleUpdate();");
  out.println("</script>");
}

相关文章