public Collection < Group > getPublicGroups ( String userId ) throws FlickrException { List < Group > groups = new ArrayList < Group > ( ) ; Map < String , Object > parameters = new HashMap < String , Object > ( ) ; parameters . put ( "method" , METHOD_GET_PUBLIC_GROUPS ) ; parameters . put ( "user_id" , userId ) ; Response response = transportAPI . get ( transportAPI . getPath ( ) , parameters , apiKey , sharedSecret ) ; if ( response . isError ( ) ) { throw new FlickrException ( response . getErrorCode ( ) , response . getErrorMessage ( ) ) ; } Element groupsElement = response . getPayload ( ) ; 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 ( "nsid" ) ) ; group . setName ( groupElement . getAttribute ( "name" ) ) ; group . setAdmin ( "1" . equals ( groupElement . getAttribute ( "admin" ) ) ) ; group . setEighteenPlus ( groupElement . getAttribute ( "eighteenplus" ) . equals ( "0" ) ? false : true ) ; groups . add ( group ) ; } return groups ; }
Get a collection of public groups for the user .