@Test public void extractAlbumFromPropertiesTest() throws GalleryConnectionException { HashMap<String, String> albumsProperties = new HashMap<String, String>(); albumsProperties.put("album.name.1", "10726"); albumsProperties.put("album.title.1", "Brunch"); albumsProperties.put("album.summary.1", "Le Dimanche de 11h à 15h avait lieu le brunch"); albumsProperties.put("album.parent.1", "7"); albumsProperties.put("album.perms.add.1", "false"); albumsProperties.put("album.perms.write.1", "false"); albumsProperties.put("album.perms.del_alb.1", "false"); albumsProperties.put("album.perms.create_sub.1", "false"); albumsProperties.put("album.info.extrafields.1", "Summary,Description"); albumsProperties.put("debug_time_generate", "0,075s"); albumsProperties.put("can_create_root", "false"); albumsProperties.put("album_count", "9"); albumsProperties.put("status", "0"); Collection<G2Album> albums = g2ConnectionUtils.extractAlbumFromProperties( albumsProperties).values(); G2Album album = albums.iterator().next(); assertEquals(1, album.getId()); assertEquals("Brunch", album.getTitle()); assertEquals(10726, album.getName()); assertEquals("Le Dimanche de 11h à 15h avait lieu le brunch", album .getSummary()); assertEquals(7, album.getParentName()); assertEquals("Summary,Description", album.getExtrafields()); }
public Map<Integer, G2Album> extractAlbumFromProperties( HashMap<String, String> albumsProperties) throws GalleryConnectionException { int albumNumber = 0; Map<Integer, G2Album> albumsMap = new HashMap<Integer, G2Album>(); List<Integer> tmpAlbumNumbers = new ArrayList<Integer>(); for (Entry<String, String> entry : albumsProperties.entrySet()) { if (entry.getKey().contains("album") && !entry.getKey().contains("debug") && !entry.getKey().contains("album_count")) { albumNumber = new Integer(entry.getKey().substring( entry.getKey().lastIndexOf(".") + 1)); G2Album album = null; if (!tmpAlbumNumbers.contains(albumNumber)) { album = new G2Album(); album.setId(albumNumber); albumsMap.put(albumNumber, album); tmpAlbumNumbers.add(albumNumber); } else { album = albumsMap.get(albumNumber); } try { if (entry.getKey().contains("album.title.")) { String title = StringEscapeUtils.unescapeHtml(entry .getValue()); title = StringEscapeUtils.unescapeJava(title); album.setTitle(title); } else if (entry.getKey().contains("album.name.")) { album.setName(new Integer(entry.getValue())); } else if (entry.getKey().contains("album.summary.")) { album.setSummary(entry.getValue()); } else if (entry.getKey().contains("album.parent.")) { album.setParentName(new Integer(entry.getValue())); } else if (entry.getKey().contains( "album.info.extrafields.")) { album.setExtrafields(entry.getValue()); } } catch (NumberFormatException nfe) { throw new GalleryConnectionException(nfe); } } } return albumsMap; }
G2Client { public Map<Integer, G2Album> extractAlbumFromProperties( HashMap<String, String> albumsProperties) throws GalleryConnectionException { int albumNumber = 0; Map<Integer, G2Album> albumsMap = new HashMap<Integer, G2Album>(); List<Integer> tmpAlbumNumbers = new ArrayList<Integer>(); for (Entry<String, String> entry : albumsProperties.entrySet()) { if (entry.getKey().contains("album") && !entry.getKey().contains("debug") && !entry.getKey().contains("album_count")) { albumNumber = new Integer(entry.getKey().substring( entry.getKey().lastIndexOf(".") + 1)); G2Album album = null; if (!tmpAlbumNumbers.contains(albumNumber)) { album = new G2Album(); album.setId(albumNumber); albumsMap.put(albumNumber, album); tmpAlbumNumbers.add(albumNumber); } else { album = albumsMap.get(albumNumber); } try { if (entry.getKey().contains("album.title.")) { String title = StringEscapeUtils.unescapeHtml(entry .getValue()); title = StringEscapeUtils.unescapeJava(title); album.setTitle(title); } else if (entry.getKey().contains("album.name.")) { album.setName(new Integer(entry.getValue())); } else if (entry.getKey().contains("album.summary.")) { album.setSummary(entry.getValue()); } else if (entry.getKey().contains("album.parent.")) { album.setParentName(new Integer(entry.getValue())); } else if (entry.getKey().contains( "album.info.extrafields.")) { album.setExtrafields(entry.getValue()); } } catch (NumberFormatException nfe) { throw new GalleryConnectionException(nfe); } } } return albumsMap; } }
G2Client { public Map<Integer, G2Album> extractAlbumFromProperties( HashMap<String, String> albumsProperties) throws GalleryConnectionException { int albumNumber = 0; Map<Integer, G2Album> albumsMap = new HashMap<Integer, G2Album>(); List<Integer> tmpAlbumNumbers = new ArrayList<Integer>(); for (Entry<String, String> entry : albumsProperties.entrySet()) { if (entry.getKey().contains("album") && !entry.getKey().contains("debug") && !entry.getKey().contains("album_count")) { albumNumber = new Integer(entry.getKey().substring( entry.getKey().lastIndexOf(".") + 1)); G2Album album = null; if (!tmpAlbumNumbers.contains(albumNumber)) { album = new G2Album(); album.setId(albumNumber); albumsMap.put(albumNumber, album); tmpAlbumNumbers.add(albumNumber); } else { album = albumsMap.get(albumNumber); } try { if (entry.getKey().contains("album.title.")) { String title = StringEscapeUtils.unescapeHtml(entry .getValue()); title = StringEscapeUtils.unescapeJava(title); album.setTitle(title); } else if (entry.getKey().contains("album.name.")) { album.setName(new Integer(entry.getValue())); } else if (entry.getKey().contains("album.summary.")) { album.setSummary(entry.getValue()); } else if (entry.getKey().contains("album.parent.")) { album.setParentName(new Integer(entry.getValue())); } else if (entry.getKey().contains( "album.info.extrafields.")) { album.setExtrafields(entry.getValue()); } } catch (NumberFormatException nfe) { throw new GalleryConnectionException(nfe); } } } return albumsMap; } G2Client(String userAgent); }
G2Client { public Map<Integer, G2Album> extractAlbumFromProperties( HashMap<String, String> albumsProperties) throws GalleryConnectionException { int albumNumber = 0; Map<Integer, G2Album> albumsMap = new HashMap<Integer, G2Album>(); List<Integer> tmpAlbumNumbers = new ArrayList<Integer>(); for (Entry<String, String> entry : albumsProperties.entrySet()) { if (entry.getKey().contains("album") && !entry.getKey().contains("debug") && !entry.getKey().contains("album_count")) { albumNumber = new Integer(entry.getKey().substring( entry.getKey().lastIndexOf(".") + 1)); G2Album album = null; if (!tmpAlbumNumbers.contains(albumNumber)) { album = new G2Album(); album.setId(albumNumber); albumsMap.put(albumNumber, album); tmpAlbumNumbers.add(albumNumber); } else { album = albumsMap.get(albumNumber); } try { if (entry.getKey().contains("album.title.")) { String title = StringEscapeUtils.unescapeHtml(entry .getValue()); title = StringEscapeUtils.unescapeJava(title); album.setTitle(title); } else if (entry.getKey().contains("album.name.")) { album.setName(new Integer(entry.getValue())); } else if (entry.getKey().contains("album.summary.")) { album.setSummary(entry.getValue()); } else if (entry.getKey().contains("album.parent.")) { album.setParentName(new Integer(entry.getValue())); } else if (entry.getKey().contains( "album.info.extrafields.")) { album.setExtrafields(entry.getValue()); } } catch (NumberFormatException nfe) { throw new GalleryConnectionException(nfe); } } } return albumsMap; } G2Client(String userAgent); HashMap<String, String> fetchImages(String galleryUrl, int albumName); HashMap<String, String> fetchAlbums(String galleryUrl); void loginToGallery(String galleryUrl, String user, String password); InputStream getInputStreamFromUrl(String url); int createNewAlbum(String galleryUrl, int parentAlbumName,
			String albumName, String albumTitle, String albumDescription); int sendImageToGallery(String galleryUrl, int albumName,
			File imageFile, String imageName, String summary, String description); String getAuthToken(); void setAuthToken(String authToken); List<Cookie> getSessionCookies(); Collection<G2Picture> extractG2PicturesFromProperties(
			HashMap<String, String> fetchImages); Map<Integer, Album> getAllAlbums(String galleryUrl); Map<Integer, G2Album> extractAlbumFromProperties(
			HashMap<String, String> albumsProperties); Album organizeAlbumsHierarchy(Map<Integer, G2Album> albums); void setRootAlbum(G2Album rootAlbum); G2Album getRootAlbum(); }
G2Client { public Map<Integer, G2Album> extractAlbumFromProperties( HashMap<String, String> albumsProperties) throws GalleryConnectionException { int albumNumber = 0; Map<Integer, G2Album> albumsMap = new HashMap<Integer, G2Album>(); List<Integer> tmpAlbumNumbers = new ArrayList<Integer>(); for (Entry<String, String> entry : albumsProperties.entrySet()) { if (entry.getKey().contains("album") && !entry.getKey().contains("debug") && !entry.getKey().contains("album_count")) { albumNumber = new Integer(entry.getKey().substring( entry.getKey().lastIndexOf(".") + 1)); G2Album album = null; if (!tmpAlbumNumbers.contains(albumNumber)) { album = new G2Album(); album.setId(albumNumber); albumsMap.put(albumNumber, album); tmpAlbumNumbers.add(albumNumber); } else { album = albumsMap.get(albumNumber); } try { if (entry.getKey().contains("album.title.")) { String title = StringEscapeUtils.unescapeHtml(entry .getValue()); title = StringEscapeUtils.unescapeJava(title); album.setTitle(title); } else if (entry.getKey().contains("album.name.")) { album.setName(new Integer(entry.getValue())); } else if (entry.getKey().contains("album.summary.")) { album.setSummary(entry.getValue()); } else if (entry.getKey().contains("album.parent.")) { album.setParentName(new Integer(entry.getValue())); } else if (entry.getKey().contains( "album.info.extrafields.")) { album.setExtrafields(entry.getValue()); } } catch (NumberFormatException nfe) { throw new GalleryConnectionException(nfe); } } } return albumsMap; } G2Client(String userAgent); HashMap<String, String> fetchImages(String galleryUrl, int albumName); HashMap<String, String> fetchAlbums(String galleryUrl); void loginToGallery(String galleryUrl, String user, String password); InputStream getInputStreamFromUrl(String url); int createNewAlbum(String galleryUrl, int parentAlbumName,
			String albumName, String albumTitle, String albumDescription); int sendImageToGallery(String galleryUrl, int albumName,
			File imageFile, String imageName, String summary, String description); String getAuthToken(); void setAuthToken(String authToken); List<Cookie> getSessionCookies(); Collection<G2Picture> extractG2PicturesFromProperties(
			HashMap<String, String> fetchImages); Map<Integer, Album> getAllAlbums(String galleryUrl); Map<Integer, G2Album> extractAlbumFromProperties(
			HashMap<String, String> albumsProperties); Album organizeAlbumsHierarchy(Map<Integer, G2Album> albums); void setRootAlbum(G2Album rootAlbum); G2Album getRootAlbum();  }