public static void showPicasaGallery(Long id, String name) { notFoundIfNull(id); PicasaGallery gallery = PicasaGallery.findById(id); notFoundIfNull(gallery); PicasawebService service = new PicasawebService("portfolio"); List<PhotoEntry> photoEntries = Collections.emptyList(); try { java.net.URL feedUrl = new java.net.URL(gallery.getFeedUrl()); AlbumFeed feed = service.getFeed(feedUrl, AlbumFeed.class); photoEntries = feed.getPhotoEntries(); } catch (MalformedURLException e) { Logger.error("Service URL for Picasa is not well formed"); e.printStackTrace(); } catch (IOException e) { Logger.error("Error I/O while communicating with Picasa Service"); e.printStackTrace(); } catch (ServiceException e) { Logger.error("Picasa service error"); e.printStackTrace(); } List<ImageView> images = new ArrayList<ImageView>(); for (PhotoEntry entry : photoEntries) { ImageView image = new ImageView(); // We take the largest image.thumbnail = entry.getMediaThumbnails().get(entry.getMediaThumbnails().size() - 1).getUrl(); image.url = entry.getMediaContents().get(0).getUrl(); images.add(image); } render("Application/gallery.html", images, gallery); }
@Util public static List<Gallery> getPicasaGalleries() { return PicasaGallery.all().fetch(); }