@RequestMapping(value = "", method = RequestMethod.POST) @JsonView(View.PrincipalWithManyToOne.class) public ResponseEntity<Offender> create(@Valid @RequestBody Offender teacher) throws URISyntaxException { teacher.setType(OffenderTypeEnum.TEACHER); return super.create(teacher); }
@RequestMapping(value = "", method = RequestMethod.PUT) @JsonView(View.PrincipalWithManyToOne.class) public ResponseEntity<Offender> update(@Valid @RequestBody Offender teacher) throws URISyntaxException { if (!teacher.getType().equals(OffenderTypeEnum.TEACHER)) { return ResponseEntity.badRequest().header("Failure", "This is not a teacher").body(null); } return super.update(teacher); }