@RequestMapping(value = "create", method = RequestMethod.POST) public Movie create(@RequestBody JsonNode jsonNode) { Map<Locale, String> translations = new HashMap<>(); jsonNode .fields() .forEachRemaining( field -> { if (field.getKey().startsWith(Movie.TITLE + "-")) { String[] fieldName = field.getKey().split("-"); translations.put(new Locale(fieldName[1]), field.getValue().asText()); } }); return moviesService.create( jsonNode.get(Movie.TITLE).asText(), jsonNode.get(Movie.YEAR).asInt(), translations); }
@RequestMapping(value = "getByYear/{year}/{locale}", method = RequestMethod.GET) public List<Movie> getByYear(@PathVariable Integer year, @PathVariable String locale) { exampleThreadLocale.setLocale(new Locale(locale)); return moviesService.getByYear(year); }