public Collection < Group > getGroups ( ) throws FlickrException { GroupList < Group > groups = new GroupList < Group > ( ) ; Map < String , Object > parameters = new HashMap < String , Object > ( ) ; parameters . put ( "method" , METHOD_GET_GROUPS ) ; Response response = transport . get ( transport . getPath ( ) , parameters , apiKey , sharedSecret ) ; if ( response . isError ( ) ) { throw new FlickrException ( response . getErrorCode ( ) , response . getErrorMessage ( ) ) ; } Element groupsElement = response . getPayload ( ) ; groups . setPage ( groupsElement . getAttribute ( "page" ) ) ; groups . setPages ( groupsElement . getAttribute ( "pages" ) ) ; groups . setPerPage ( groupsElement . getAttribute ( "perpage" ) ) ; groups . setTotal ( groupsElement . getAttribute ( "total" ) ) ; NodeList groupNodes = groupsElement . getElementsByTagName ( "group" ) ; for ( int i = 0 ; i < groupNodes . getLength ( ) ; i ++ ) { Element groupElement = ( Element ) groupNodes . item ( i ) ; Group group = new Group ( ) ; group . setId ( groupElement . getAttribute ( "id" ) ) ; group . setName ( groupElement . getAttribute ( "name" ) ) ; group . setAdmin ( "1" . equals ( groupElement . getAttribute ( "admin" ) ) ) ; group . setPrivacy ( groupElement . getAttribute ( "privacy" ) ) ; group . setIconServer ( groupElement . getAttribute ( "iconserver" ) ) ; group . setIconFarm ( groupElement . getAttribute ( "iconfarm" ) ) ; group . setPhotoCount ( groupElement . getAttribute ( "photos" ) ) ; groups . add ( group ) ; } return groups ; }
Get a collection of all of the user s groups .