status(su, "Fetched albums");
status(su, StatusUpdate.LEVEL_BACKGROUND, "Fetched albums");
		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.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 mAlbumList = 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();					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 );					String title = p.getProperty( titleKey );					a.setName( name );					a.setTitle( title );					a.setExtraFieldsString( p.getProperty(infoExtraFieldKey));					a.setGallery( g );					mAlbumList.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 );					}				}				// 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);					}				}				// reorder				//Collections.reverse(mAlbumList);				ArrayList orderedAlbums = new ArrayList();				int depth = 0;				while (!mAlbumList.isEmpty()) {					it = mAlbumList.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++;				}				status(su, "Fetched albums");				g.setAlbumList(orderedAlbums);			} else {				error(su, "Error: " + p.getProperty( "status_text" ));			}		}