public RatingDto[] fallbackRating(String ratingsUrl, String itemIds) { String[] ids = itemIds.split(","); RatingDto[] dtos = new RatingDto[ids.length]; for (int i = 0; i < ids.length; i++) { String id = ids[i]; RatingDto dto = new RatingDto(); dto.setItemNo(Integer.valueOf(id)); dto.setRating(6); dtos[i] = dto; } return dtos; }
/** * Generate ratings for the items * <p/> * Notice how the items is mapped to @Header with the name ids, which * refers to the context-path {ids} in the rest-dsl service */ public List<RatingDto> ratings(@Header("ids") String items) { System.out.println("Rating items " + items); List<RatingDto> answer = new ArrayList<>(); for (String id : items.split(",")) { RatingDto dto = new RatingDto(); answer.add(dto); dto.setItemNo(Integer.valueOf(id)); // generate some random ratings dto.setRating(new Random().nextInt(100)); } return answer; } }
/** * Generate ratings for the items * <p/> * Notice how the items is mapped to @Header with the name ids, which * refers to the context-path {ids} in the rest-dsl service */ public List<RatingDto> ratings(@Header("ids") String items) { System.out.println("Rating items " + items); List<RatingDto> answer = new ArrayList<>(); for (String id : items.split(",")) { RatingDto dto = new RatingDto(); answer.add(dto); dto.setItemNo(Integer.valueOf(id)); // generate some random ratings dto.setRating(new Random().nextInt(100)); } return answer; } }