Example #1
0
 private void forwardToErrorPage(
     HttpServletRequest request, HttpServletResponse response, String userMessage, XDebug xdebug)
     throws ServletException, IOException {
   request.setAttribute("xdebug_object", xdebug);
   request.setAttribute(QueryBuilder.USER_ERROR_MESSAGE, userMessage);
   RequestDispatcher dispatcher =
       getServletContext().getRequestDispatcher("/WEB-INF/jsp/error.jsp");
   dispatcher.forward(request, response);
 }
Example #2
0
  private void setGeneticProfiles(HttpServletRequest request) throws DaoException {
    CancerStudy cancerStudy = (CancerStudy) request.getAttribute(CANCER_STUDY);
    GeneticProfile mutProfile = cancerStudy.getMutationProfile();
    if (mutProfile != null) {
      request.setAttribute(MUTATION_PROFILE, mutProfile);
    }

    GeneticProfile cnaProfile = cancerStudy.getCopyNumberAlterationProfile(true);
    if (cnaProfile != null) {
      request.setAttribute(CNA_PROFILE, cnaProfile);
    }
  }
  private void processRequestDefault(HttpServletRequest request, HttpServletResponse response)
      throws ServletException, IOException {
    request.setAttribute(QueryBuilder.HTML_TITLE, GlobalProperties.getTitle());

    RequestDispatcher dispatcher =
        getServletContext().getRequestDispatcher("/WEB-INF/jsp/tumormap/tumormap.jsp");
    dispatcher.forward(request, response);
  }
Example #4
0
  private boolean validate(HttpServletRequest request) throws DaoException {
    String cancerStudyID = request.getParameter(ID);
    if (cancerStudyID == null) {
      cancerStudyID = request.getParameter(QueryBuilder.CANCER_STUDY_ID);
    }

    CancerStudy cancerStudy = DaoCancerStudy.getCancerStudyByStableId(cancerStudyID);
    if (cancerStudy == null) {
      try {
        cancerStudy = DaoCancerStudy.getCancerStudyByInternalId(Integer.parseInt(cancerStudyID));
      } catch (NumberFormatException ex) {
      }
    }
    if (cancerStudy == null) {
      request.setAttribute(ERROR, "No such cancer study");
      return false;
    }
    String cancerStudyIdentifier = cancerStudy.getCancerStudyStableId();

    if (accessControl.isAccessibleCancerStudy(cancerStudyIdentifier).size() != 1) {
      request.setAttribute(
          ERROR,
          "You are not authorized to view the cancer study with id: '"
              + cancerStudyIdentifier
              + "'. ");
      return false;
    } else {
      UserDetails ud = accessControl.getUserDetails();
      if (ud != null) {
        logger.info("CancerStudyView.validate: Query initiated by user: "******"_all";
      request.setAttribute(QueryBuilder.CASE_SET_ID, sampleListId);
    }

    SampleList sampleList = daoSampleList.getSampleListByStableId(sampleListId);
    if (sampleList == null) {
      request.setAttribute(ERROR, "Could not find sample list of '" + sampleListId + "'. ");
      return false;
    }

    request.setAttribute(QueryBuilder.CASE_IDS, sampleList.getSampleList());

    request.setAttribute(CANCER_STUDY, cancerStudy);
    request.setAttribute(QueryBuilder.HTML_TITLE, cancerStudy.getName());
    return true;
  }
Example #5
0
  /**
   * Processes requests for both HTTP <code>GET</code> and <code>POST</code> methods.
   *
   * @param request servlet request
   * @param response servlet response
   * @throws ServletException if a servlet-specific error occurs
   * @throws IOException if an I/O error occurs
   */
  protected void processRequest(HttpServletRequest request, HttpServletResponse response)
      throws ServletException, IOException {
    XDebug xdebug = new XDebug(request);
    request.setAttribute(QueryBuilder.XDEBUG_OBJECT, xdebug);

    try {
      if (validate(request)) {
        setGeneticProfiles(request);
      }

      if (request.getAttribute(ERROR) != null) {
        forwardToErrorPage(request, response, (String) request.getAttribute(ERROR), xdebug);
      } else {
        RequestDispatcher dispatcher =
            getServletContext().getRequestDispatcher("/WEB-INF/jsp/dashboard/dashboard.jsp");
        dispatcher.forward(request, response);
      }

    } catch (DaoException e) {
      xdebug.logMsg(this, "Got Database Exception:  " + e.getMessage());
      forwardToErrorPage(
          request, response, "An error occurred while trying to connect to the database.", xdebug);
    }
  }