@Override
  public void submit(int problemId, String programText)
      throws CloudCoderAuthenticationException, SubmissionException {
    // Make sure that client is authenticated and has permission to edit the given problem
    User user = ServletUtil.checkClientIsAuthenticated(getThreadLocalRequest());

    HttpSession session = getThreadLocalRequest().getSession();

    // The Problem should be stored in the user's session
    Problem problem = (Problem) session.getAttribute(SessionAttributeKeys.PROBLEM_KEY);
    if (problem == null || problem.getProblemId() != problemId) {
      throw new CloudCoderAuthenticationException();
    }

    // Insert a full-text change into the database.
    Change fullTextChange =
        new Change(
            ChangeType.FULL_TEXT,
            0,
            0,
            0,
            0,
            System.currentTimeMillis(),
            user.getId(),
            problem.getProblemId(),
            programText);
    Database.getInstance().storeChanges(new Change[] {fullTextChange});

    // Get test cases.  (TODO: cache them?)
    List<TestCase> testCaseList = Database.getInstance().getTestCasesForProblem(problemId);

    ISubmitService submitService = DefaultSubmitService.getInstance();

    logger.info("Passing submission to submit service...");
    IFutureSubmissionResult future = submitService.submitAsync(problem, testCaseList, programText);

    // Put the full-text Change and IFutureSubmissionResult in the user's session.
    addSessionObjects(session, fullTextChange, future);
  }
  @Override
  public void run(Problem problem, String programText, TestCase[] testCases)
      throws CloudCoderAuthenticationException, SubmissionException {
    // Make sure that client is authenticated and has permission to edit the given problem
    User user =
        ServletUtil.checkClientIsAuthenticated(getThreadLocalRequest(), RunServiceImpl.class);

    HttpSession session = getThreadLocalRequest().getSession();

    // TODO Don't insert into the DB yet, until we have some kind of a virtual file system
    // (or something like it)
    //        Change fullTextChange = new Change(
    //                ChangeType.FULL_TEXT,
    //                0, 0, 0, 0,
    //                System.currentTimeMillis(),
    //                user.getId(), problem.getProblemId(),
    //                programText);
    //        Database.getInstance().storeChanges(new Change[]{fullTextChange});

    ISubmitService submitService = DefaultSubmitService.getInstance();

    logger.info("Passing submission to submit service...");

    // Convert TestCase[] to List<TestCase> to match ISubmitService
    List<TestCase> listTestCases = new LinkedList<TestCase>();
    for (TestCase tc : testCases) {
      listTestCases.add(tc);
    }

    IFutureSubmissionResult future = submitService.submitAsync(problem, listTestCases, programText);

    // put the future into the session
    session.setAttribute(SessionAttributeKeys.FUTURE_SUBMISSION_RESULT_KEY, future);

    // Put the full-text Change and IFutureSubmissionResult in the user's session.
    // addSessionObjects(session, fullTextChange, future);
  }