@@ -268,24 +268,19 @@ public Post setPostFeaturedMedia(Long postId, Media media) {
268268
269269 @ Override
270270 public List <Media > getPostMedias (Long postId ) {
271- Media [] medias = CustomRenderableParser .parse (
272- doExchange1 (
273- Request .MEDIAS , HttpMethod .GET , String .class , forExpand (),
274- ImmutableMap .of ("parent" , postId , CONTEXT_ , Contexts .EDIT ), null
275- ).getBody (),
276- Media [].class );
277- return Arrays .asList (medias );
271+ return getPostMedias (postId , Contexts .EDIT );
278272 }
279273
280274 @ Override
281275 public List <Media > getPostMedias (Long postId , @ Nullable String context ) {
282- Media [] medias = CustomRenderableParser .parse (
283- doExchange1 (
284- Request .MEDIAS , HttpMethod .GET , String .class , forExpand (),
285- ImmutableMap .of ("parent" , postId , CONTEXT_ , context ), null
286- ).getBody (),
287- Media [].class );
288- return Arrays .asList (medias );
276+ List <Media > collected = new ArrayList <>();
277+ PagedResponse <Media > pagedResponse = this .getPagedResponse (Request .POST_MEDIAS , Media .class , String .valueOf (postId ), context );
278+ collected .addAll (pagedResponse .getList ());
279+ while (pagedResponse .hasNext ()) {
280+ pagedResponse = this .traverse (pagedResponse , PagedResponse .NEXT );
281+ collected .addAll (pagedResponse .getList ());
282+ }
283+ return collected ;
289284 }
290285
291286 @ Override
0 commit comments