@PUT @Path("{id}") @UnitOfWork public Project amend(Project project) { if (project.getInitiatorId() != null) { User author = userDao.get(project.getInitiatorId()); if (author == null) { throw new IllegalArgumentException("Author id is incorrect"); } project = project.withInitiator(author); } return projectDao.saveOrUpdate(project); }
@POST @UnitOfWork public Project save(@Context User user, Project project) { return projectDao.saveOrUpdate( project.withInitiator(user).withStartDate(Calendar.getInstance().getTime())); }