private void checkForError(Document document, Field field) {
   Property property = document.get(field);
   String value = property.getValue();
   if ("error".equalsIgnoreCase(value)) {
     property = property.copyWithMessage("Oops - <error> was provided");
     document.set(field, property);
   }
 }
Exemple #2
0
  public Redirect execute(Request request) {
    Identity documentId = request.getIdentity("documentId");

    Document document = repository.get(documentId);

    setProperties(request, document);
    validator.validate(document);
    repository.set(document);

    if (document.isValid()) {
      return new Redirect(SuccessPresenter.class, "documentId", documentId);
    }
    return new Redirect(FormPresenter.class, "documentId", documentId);
  }