Ejemplo n.º 1
0
  /** Final initialization, once all dependencies are set. */
  public void init() {
    if (m_enabled) {
      // slip in our appender
      Appender a = Logger.getRootLogger().getAppender("Sakai");
      if (a != null) {
        Logger.getRootLogger().removeAppender(a);
        Logger.getRootLogger().addAppender(new SakaiAppender(a));
      }

      // set the log4j logging system with some overrides from sakai.properties
      // each in the form LEVEL.NAME where LEVEL is OFF | TRACE | DEBUG | INFO | WARN | ERROR |
      // FATAL | ALL, name is the logger name (such as org.sakaiproject)
      // example:
      // log.config.count=3
      // log.config.1 = ALL.org.sakaiproject.log.impl
      // log.config.2 = OFF.org.sakaiproject
      // log.config.3 = DEBUG.org.sakaiproject.db.impl
      String configs[] = serverConfigurationService().getStrings("log.config");
      if (configs != null) {
        for (int i = 0; i < configs.length; i++) {
          String parts[] = StringUtil.splitFirst(configs[i], ".");
          if ((parts != null) && (parts.length == 2)) {
            doSetLogLevel(parts[0], parts[1]);
          } else {
            M_log.warn("invalid log.config entry: ignoring: " + configs[i]);
          }
        }
      }
    }

    M_log.info("init(): enabled: " + m_enabled);
  }
Ejemplo n.º 2
0
  /**
   * Respond to navigation / access requests.
   *
   * @param req The servlet request.
   * @param res The servlet response.
   * @throws ServletException.
   * @throws IOException.
   */
  @Override
  protected void doGet(HttpServletRequest req, HttpServletResponse res)
      throws ServletException, IOException {
    try {
      // this is either going to be editor.js or editor-launch.js
      String path = URLUtils.getSafePathInfo(req);
      if ((path == null) || (path.length() <= 1)) throw new Exception("no path");

      // get the requested file, ignoring the first "/"
      String[] parts = StringUtil.splitFirst(path.substring(1), "/");
      String name = parts[0];

      String placementId = req.getParameter("placement");
      ToolConfiguration tool = SiteService.findTool(placementId);

      Editor editor = portalService.getActiveEditor(tool);

      if (EDITOR_JS.equals(name)) {
        res.sendRedirect(editor.getEditorUrl());
        // res.sendRedirect("/library/editor/FCKeditor/fckeditor.js");
        // res.sendRedirect("/library/editor/ckeditor/ckeditor.js");
      } else if (EDITOR_LAUNCH_JS.equals(name)) {
        res.sendRedirect(editor.getLaunchUrl());
        // res.sendRedirect("/library/editor/launchfck.js");
        // res.sendRedirect("/library/editor/ckeditor.launch.js");
      } else if (EDITOR_BOOTSTRAP_JS.equals(name)) {
        res.addHeader("Pragma", "no-cache");
        res.addHeader("Cache-Control", "no-cache");
        res.addHeader("Content-Type", "text/javascript");

        // Note that this is the same stuff as in SkinnableCharonPortal. We should probably do a bit
        // of refactoring.
        PrintWriter out = res.getWriter();
        out.print("var sakai = sakai || {}; sakai.editor = sakai.editor || {}; \n");
        out.print(
            "sakai.editor.collectionId = '" + portalService.getBrowserCollectionId(tool) + "';\n");
        out.print(
            "sakai.editor.enableResourceSearch = '"
                + EditorConfiguration.enableResourceSearch()
                + "';\n");
        out.print(editor.getPreloadScript());
      } else {
        throw new Exception("unrecognized request");
      }

    } catch (Throwable t) {
      doError(req, res, t);
    }
  }
Ejemplo n.º 3
0
  /**
   * Respond to navigation / access requests.
   *
   * @param req The servlet request.
   * @param res The servlet response.
   * @throws ServletException.
   * @throws IOException.
   */
  @Override
  protected void doGet(HttpServletRequest req, HttpServletResponse res)
      throws ServletException, IOException {
    try {
      // get the Sakai session
      Session session = SessionManager.getCurrentSession();

      // our path is /placement-id/tool-destination, but we want to
      // include anchors and parameters in the destination...
      String path = URLUtils.getSafePathInfo(req);
      if ((path == null) || (path.length() <= 1)) {
        res.sendError(HttpServletResponse.SC_NOT_FOUND);
        return;
      }

      // get the placement id, ignoring the first "/"
      String[] parts = StringUtil.splitFirst(path.substring(1), "/");
      String placementId = parts[0];

      // get the toolPath if specified
      String toolPath = null;
      if (parts.length == 2) toolPath = "/" + parts[1];

      boolean success =
          doTool(
              req,
              res,
              session,
              placementId,
              req.getContextPath() + req.getServletPath() + "/" + placementId,
              toolPath);

    } catch (Exception t) {
      doError(req, res, t);
    }
  }