コード例 #1
0
ファイル: ChangeInvitee.java プロジェクト: ctsidev/WISE_2015
  @Override
  public void getMethod(
      HttpServletRequest request, HttpServletResponse response, AdminUserSession adminUserSession)
      throws IOException, TemplateException {

    PrintWriter out = response.getWriter();

    String path = request.getContextPath();
    // get the edit type - add, delete, update etc from the request
    String editType = request.getParameter("cedit");
    // Security features Changes
    if (SanityCheck.sanityCheck(editType)) {
      response.sendRedirect("/admin/error_pages/sanity_error.html");
      return;
    }
    editType = SanityCheck.onlyAlphaNumeric(editType);

    String colOName, colName, colValue, colDef;
    String column_name, column_type, column_default, column_key;

    // get the new column name, data type, default value and old column
    // name
    if (editType != null) {
      colName = request.getParameter("cname");
      colValue = request.getParameter("ctype");
      colDef = request.getParameter("cdefault");
      colOName = request.getParameter("coname");
      if (SanityCheck.sanityCheck(colName)
          || SanityCheck.sanityCheck(colValue)
          || SanityCheck.sanityCheck(colDef)
          || SanityCheck.sanityCheck(colOName)) {
        response.sendRedirect(path + "/admin/error_pages/sanity_error.html");
        return;
      }
      colName = SanityCheck.onlyAlphaNumericandSpecial(colName);
      colValue = SanityCheck.onlyAlphaNumericandSpecial(colValue);
      colDef = SanityCheck.onlyAlphaNumericandSpecial(colDef);
      colOName = SanityCheck.onlyAlphaNumericandSpecial(colOName);
      // end of security features changes

      WebResponseMessage crudWebResponseMessage =
          adminUserSession
              .getMyStudySpace()
              .modifyInviteeTable(editType, colName, colValue, colDef, colOName);

      WebResponseMessage describeInviteeResponse =
          adminUserSession.getMyStudySpace().describeInviteeTable();

      if (crudWebResponseMessage.isSuccess() && describeInviteeResponse.isSuccess()) {
        Map<String, Object> parametersForChangeInviteePage = new HashMap<>();
        parametersForChangeInviteePage.put("crudMessage", crudWebResponseMessage.getResponse());
        parametersForChangeInviteePage.put(
            "inviteeTableDescription", describeInviteeResponse.getResponse());
        String html =
            TemplateUtils.getHtmlFromTemplateForAdmin(
                parametersForChangeInviteePage, "changeInviteeTemplate.ftl");
        out.write(html);
      } else {
        out.write("Error in page, please contact the developers");
      }
    }
  }