@Transactional
@IsAllowed(value = Operation.UPDATE, resourceType = ResourceType.MILESTONE)
public static Result editMilestone(String userName, String projectName, Long milestoneId) {
Project project = Project.findByOwnerAndProjectName(userName, projectName);
Form<Milestone> milestoneForm = new Form<>(Milestone.class).bindFromRequest();
Milestone original = Milestone.findById(milestoneId);
if(!original.title.equals(milestoneForm.field("title").value())) {
validate(project, milestoneForm);
}
if (milestoneForm.hasErrors()) {
return ok(edit.render("title.editMilestone", milestoneForm, milestoneId, project));
} else {
Milestone existingMilestone = Milestone.findById(milestoneId);
Milestone milestone = milestoneForm.get();
if (milestone.contents == null) {
return status(REQUEST_ENTITY_TOO_LARGE,
ErrorViews.RequestTextEntityTooLarge.render());
}