if (a.getAlbumDepth() == depth) {
try { if (a.getAlbumDepth() == depth) { it.remove();  Album parentAlbum = a.getParentAlbum(); if (parentAlbum == null) { orderedAlbums.add(a); } else { int i = orderedAlbums.indexOf(parentAlbum); orderedAlbums.add(i + 1, a); } } } catch (IllegalArgumentException e) {
		private void list22() throws IOException, ModuleException {			// setup the protocol parameters			NVPair form_data[] = {				new NVPair("cmd", "fetch-albums-prune"),				new NVPair("protocol_version", PROTOCOL_VERSION)			};			Log.log(Log.LEVEL_TRACE, MODULE, "fetchAlbums parameters: " + Arrays.asList(form_data));			// load and validate the response			Properties p = requestResponse(form_data);			if (p.getProperty("status").equals(GR_STAT_SUCCESS)) {				ArrayList albums = new ArrayList();				// parse and store the data				int albumCount = Integer.parseInt(p.getProperty("album_count"));//	System.err.println( "### albumCount = " + albumCount );				HashMap name2parentName = new HashMap();				HashMap name2album = new HashMap();				for (int i = 1; i < albumCount + 1; i++) {					Album a = new Album(g);					String nameKey = "album.name." + i;					String titleKey = "album.title." + i;					String parentKey = "album.parent." + i;					String permsAddKey = "album.perms.add." + i;					String permsWriteKey = "album.perms.write." + i;					String permsDelItemKey = "album.perms.del_item." + i;					String permsDelAlbKey = "album.perms.del_alb." + i;					String permsCreateSubKey = "album.perms.create_sub." + i;					String infoExtraFieldKey = "album.info.extrafields." + i;					a.setCanAdd(isTrue(p.getProperty(permsAddKey)));					a.setCanWrite(isTrue(p.getProperty(permsWriteKey)));					a.setCanDeleteFrom(isTrue(p.getProperty(permsDelItemKey)));					a.setCanDeleteThisAlbum(isTrue(p.getProperty(permsDelAlbKey)));					a.setCanCreateSubAlbum(isTrue(p.getProperty(permsCreateSubKey)));					String name = p.getProperty(nameKey);					a.setName(name);					a.setTitle(HTMLEscaper.unescape(p.getProperty(titleKey)));					a.setExtraFieldsString(HTMLEscaper.unescape(p.getProperty(infoExtraFieldKey)));					albums.add(a);					// map album names to parent albums					name2album.put(name, a);					// map album refs to parent refs					String parentName = p.getProperty(parentKey);					if (parentName != null && parentName.length() > 0 && !parentName.equals("0")) {						name2parentName.put(name, parentName);					} else {						a.setParentAlbum(null);					}				}				Log.log(Log.LEVEL_TRACE, MODULE, "Created " + albums.size() + " albums");				// link albums to parents				Iterator it = name2parentName.keySet().iterator();				while (it.hasNext()) {					String name = (String) it.next();					String parentName = (String) name2parentName.get(name);					Album child = (Album) name2album.get(name);					Album parent = (Album) name2album.get(parentName);					if (child != null && parent != null) {						child.setParentAlbum(parent);					}				}				Log.log(Log.LEVEL_TRACE, MODULE, "Linked " + name2parentName.size() + " albums to their parents");				// reorder				//Collections.reverse(albums);				ArrayList orderedAlbums = new ArrayList();				int depth = 0;				while (!albums.isEmpty()) {					it = albums.iterator();					while (it.hasNext()) {						Album a = (Album) it.next();						if (a.getAlbumDepth() == depth) {							it.remove();							Album parentAlbum = a.getParentAlbum();							if (parentAlbum == null) {								orderedAlbums.add(a);							} else {								int i = orderedAlbums.indexOf(parentAlbum);								orderedAlbums.add(i + 1, a);							}						}					}					depth++;				}				Log.log(Log.LEVEL_TRACE, MODULE, "Ordered " + orderedAlbums.size() + " albums");				status(su, StatusUpdate.LEVEL_BACKGROUND, GRI18n.getString(MODULE, "ftchdAlbms"));				g.setAlbumList(orderedAlbums);			} else {				Object[] params = {p.getProperty("status_text")};				error(su, GRI18n.getString(MODULE, "error", params));			}		}