@Get
  @Path("/reports/{errorEntry.id}/edit")
  @LoggedIn
  public void editDetails(ErrorEntry errorEntry) {
    if (errorEntry == null) {
      result.redirectTo(getClass()).list();
      return;
    }

    ErrorEntry errorEntryFromDB = errorEntryDAO.retrieve(new Long(errorEntry.getId()));
    LOG.debug("Details for: " + errorEntryFromDB);

    if (errorEntryFromDB == null) {
      validator.add(
          new ValidationMessage(ExceptionMessages.PAGE_NOT_FOUND, ExceptionMessages.ERROR));
      validator.onErrorUse(Results.logic()).redirectTo(ErrorReportController.class).list();
    } else if (!loggedUser.isLogged() || !loggedUser.getUser().getRole().getCanEditErrorReport()) {
      validator.add(
          new ValidationMessage(ExceptionMessages.USER_UNAUTHORIZED, ExceptionMessages.ERROR));
      validator
          .onErrorUse(Results.logic())
          .redirectTo(ErrorReportController.class)
          .details(errorEntryFromDB);
    } else {
      List<ProcessResult> procRes = cogrooFacade.processText(errorEntryFromDB.getText());

      boolean hasError = false;
      for (ProcessResult processResult : procRes) {
        if (processResult.getMistakes().size() > 0) {
          hasError = true;
          break;
        }
      }

      result
          .include("errorEntry", errorEntryFromDB)
          .include("hasError", hasError)
          .include("processResultList", procRes)
          .include(
              "singleGrammarErrorList",
              cogrooFacade.asSingleGrammarErrorList(errorEntryFromDB.getText(), procRes))
          .include("omissionCategoriesList", this.errorEntryLogic.getErrorCategoriesForUser());
    }
  }
  @Post
  @Path("/reports/newtext")
  public void addReport(String text) {
    text = sanitizer.sanitize(text, false, true);
    try {
      if (text != null && text.length() >= 0) {
        if (text.length() > 255) {
          text = text.substring(0, 255);
        }

        if (!loggedUser.isLogged()) {
          // if not logged we save the text.
          if (LOG.isDebugEnabled()) {
            LOG.debug("Saving error report text before login: "******"Error text: " + text);
        }
        List<ProcessResult> pr = cogrooFacade.processText(text);
        if (LOG.isDebugEnabled()) {
          LOG.debug("Text processed. Results:");
          for (ProcessResult processResult : pr) {
            LOG.debug("... " + processResult.getTextAnnotatedWithErrors());
          }
        }
        result
            .include("analyzed", true)
            .include("cleanText", text)
            .include("annotatedText", cogrooFacade.getAnnotatedText(text, pr))
            .include("singleGrammarErrorList", cogrooFacade.asSingleGrammarErrorList(text, pr))
            .include("omissionCategoriesList", this.errorEntryLogic.getErrorCategoriesForUser())
            .include("processResultList", pr)
            .redirectTo(getClass())
            .addReport();
      } else {
        result.redirectTo(getClass()).addReport();
      }
    } catch (Exception e) {
      LOG.error("Error processing text: " + text, e);
    }
  }