public boolean load ( InputStream input ) throws IOException { boolean success = true ; BufferedReader reader = new BufferedReader ( new InputStreamReader ( input ) ) ; Map localMap = new HashMap ( ) ; GridMapEntry entry ; QuotedStringTokenizer tokenizer ; StringTokenizer idTokenizer ; String line ; while ( ( line = reader . readLine ( ) ) != null ) { line = line . trim ( ) ; if ( ( line . length ( ) == 0 ) || ( COMMENT_CHARS . indexOf ( line . charAt ( 0 ) ) != - 1 ) ) { continue ; } tokenizer = new QuotedStringTokenizer ( line ) ; String globusID = null ; if ( tokenizer . hasMoreTokens ( ) ) { globusID = tokenizer . nextToken ( ) ; } else { if ( this . ignoreErrors ) { success = false ; logger . warn ( "Globus ID missing: " + line ) ; continue ; } else { throw new IOException ( i18n . getMessage ( "globusIdErr" , line ) ) ; } } String userIDs = null ; if ( tokenizer . hasMoreTokens ( ) ) { userIDs = tokenizer . nextToken ( ) ; } else { if ( this . ignoreErrors ) { success = false ; logger . warn ( "User ID mapping missing: " + line ) ; continue ; } else { throw new IOException ( i18n . getMessage ( "userIdErr" , line ) ) ; } } idTokenizer = new StringTokenizer ( userIDs , "," ) ; String [ ] ids = new String [ idTokenizer . countTokens ( ) ] ; int i = 0 ; while ( idTokenizer . hasMoreTokens ( ) ) { ids [ i ++ ] = idTokenizer . nextToken ( ) ; } String normalizedDN = normalizeDN ( globusID ) ; entry = ( GridMapEntry ) localMap . get ( normalizedDN ) ; if ( entry == null ) { entry = new GridMapEntry ( ) ; entry . setGlobusID ( globusID ) ; entry . setUserIDs ( ids ) ; localMap . put ( normalizedDN , entry ) ; } else { entry . addUserIDs ( ids ) ; } } this . map = localMap ; return success ; }
Loads grid map file definition from a given input stream . The input stream is not closed in case of an error .