示例#1
0
  @Override
  public int doGet(String[] parts, HttpServletRequest req, HttpServletResponse res, Session session)
      throws PortalHandlerException {
    // recognize and dispatch the 'tool' option: [1] = "tool", [2] =
    // placement id (of a site's tool placement), rest for the tool
    if ((parts.length > 2) && (parts[1].equals(getUrlFragment()))) {
      try {
        // Resolve the placements of the form
        // /portal/tool/sakai.resources?sakai.site=~csev
        String toolPlacement = portal.getPlacement(req, res, session, parts[2], false);
        if (toolPlacement == null) {
          return ABORT;
        }
        parts[2] = toolPlacement;

        doTool(
            req,
            res,
            session,
            parts[2],
            req.getContextPath() + req.getServletPath() + Web.makePath(parts, 1, 3),
            Web.makePath(parts, 3, parts.length));
        return END;
      } catch (Exception ex) {
        throw new PortalHandlerException(ex);
      }
    } else {
      return NEXT;
    }
  }
示例#2
0
  @Override
  public int doGet(String[] parts, HttpServletRequest req, HttpServletResponse res, Session session)
      throws PortalHandlerException {

    if ((parts.length >= 3) && (parts[1].equals(PresenceHandler.URL_FRAGMENT))) {
      try {
        doPresence(
            req,
            res,
            session,
            parts[2],
            req.getContextPath() + req.getServletPath() + Web.makePath(parts, 1, 3),
            Web.makePath(parts, 3, parts.length));
        return END;
      } catch (Exception ex) {
        throw new PortalHandlerException(ex);
      }
    } else {
      return NEXT;
    }
  }
 @Override
 public int doGet(String[] parts, HttpServletRequest req, HttpServletResponse res, Session session)
     throws PortalHandlerException {
   if ((parts.length > 2) && (parts[1].equals(SiteResetHandler.URL_FRAGMENT))) {
     try {
       String siteUrl = req.getContextPath() + "/site" + Web.makePath(parts, 2, parts.length);
       // Make sure to add the parameters such as panel=Main
       String queryString = Validator.generateQueryString(req);
       if (queryString != null) {
         siteUrl = siteUrl + "?" + queryString;
       }
       portalService.setResetState("true");
       res.sendRedirect(siteUrl);
       return RESET_DONE;
     } catch (Exception ex) {
       throw new PortalHandlerException(ex);
     }
   } else {
     return NEXT;
   }
 }
  protected boolean sendToHelper(HttpServletRequest req, HttpServletResponse res, String target) {
    String path = req.getPathInfo();
    if (path == null) path = "/";

    // 0 parts means the path was just "/", otherwise parts[0] = "", parts[1] = item id, parts[2] if
    // present is "edit"...
    String[] parts = path.split("/");

    if (parts.length < 2) {
      return false;
    }

    if (!parts[1].endsWith(HELPER_EXT)) {
      return false;
    }

    ToolSession toolSession = SessionManager.getCurrentToolSession();

    Enumeration params = req.getParameterNames();
    while (params.hasMoreElements()) {
      String paramName = (String) params.nextElement();
      if (paramName.startsWith(HELPER_SESSION_PREFIX)) {
        String attributeName = paramName.substring(HELPER_SESSION_PREFIX.length());
        toolSession.setAttribute(attributeName, req.getParameter(paramName));
      }
    }

    // calc helper id
    int posEnd = parts[1].lastIndexOf(".");

    String helperId = target.substring(1, posEnd + 1);
    ActiveTool helperTool = ActiveToolManager.getActiveTool(helperId);

    // get the current location (if one doesn't exist) and save it for when we return from the
    // helper
    if (toolSession.getAttribute(helperTool.getId() + Tool.HELPER_DONE_URL) == null) {
      toolSession.setAttribute(
          helperTool.getId() + Tool.HELPER_DONE_URL,
          req.getContextPath() + req.getServletPath() + computeDefaultTarget(true));
    }
    toolSession.setAttribute(
        helperTool.getId() + "thetoolPath", req.getContextPath() + req.getServletPath());

    // saves the alternate done url map into a tool specific attribute
    if (toolSession.getAttribute(helperTool.getId() + ToolFinishedView.ALTERNATE_DONE_URL)
        == null) {
      toolSession.setAttribute(
          helperTool.getId() + ToolFinishedView.ALTERNATE_DONE_URL,
          toolSession.getAttribute(ToolFinishedView.ALTERNATE_DONE_URL));
      toolSession.setAttribute(
          helperTool.getId() + ToolFinishedView.ALTERNATE_DONE_URL_MAP,
          toolSession.getAttribute(ToolFinishedView.ALTERNATE_DONE_URL_MAP));
      toolSession.removeAttribute(ToolFinishedView.ALTERNATE_DONE_URL);
      toolSession.removeAttribute(ToolFinishedView.ALTERNATE_DONE_URL_MAP);
    }

    /*comment out for using the global parameter rather than tool-by-tool setting
        SessionState state = UsageSessionService.getSessionState(toolSession.getPlacementId());
    		boolean show_other_sites = ServerConfigurationService.getBoolean("syllabus.resources.show_all_collections.helper", true);
    		state.setAttribute("resources.allow_user_to_see_all_sites", (new Boolean(show_other_sites)).toString());
    		state.setAttribute("resources.user_chooses_to_see_other_sites", (new Boolean(show_other_sites)).toString());
    */
    String context = req.getContextPath() + req.getServletPath() + Web.makePath(parts, 1, 2);
    String toolPath = Web.makePath(parts, 2, parts.length);
    try {
      helperTool.help(req, res, context, toolPath);
    } catch (ToolException e) {
      throw new RuntimeException(e);
    }

    return true; // was handled as helper call
  }