Example #1
0
  /**
   * {@code posting}에 {@code original} 정보를 채우고 갱신한다.
   *
   * <p>when: 게시물이나 이슈를 수정할 떄 사용한다.
   *
   * @param original
   * @param posting
   * @param postingForm
   * @param redirectTo
   * @param updatePosting
   * @return
   */
  protected static Result editPosting(
      AbstractPosting original,
      AbstractPosting posting,
      Form<? extends AbstractPosting> postingForm,
      Call redirectTo,
      Callback updatePosting) {
    if (postingForm.hasErrors()) {
      return badRequest(postingForm.errors().toString());
    }

    if (!AccessControl.isAllowed(UserApp.currentUser(), original.asResource(), Operation.UPDATE)) {
      return forbidden(views.html.error.forbidden.render(original.project));
    }

    posting.id = original.id;
    posting.createdDate = original.createdDate;
    posting.authorId = original.authorId;
    posting.authorLoginId = original.authorLoginId;
    posting.authorName = original.authorName;
    posting.project = original.project;
    updatePosting.run();
    posting.update();

    // Attach the files in the current user's temporary storage.
    Attachment.moveAll(UserApp.currentUser().asResource(), original.asResource());

    return redirect(redirectTo);
  }
Example #2
0
 /**
  * {@code project}에 있는 {@code number}에 해당하는 글번호를 가진 게시물을 조회한다.
  *
  * @param project
  * @param number
  * @return
  */
 public static Posting findByNumber(Project project, Long number) {
   return AbstractPosting.findByNumber(finder, project, number);
 }