public int read ( User registrar ) throws IdentityException , InvalidArgumentException { if ( registrar == null ) { throw new InvalidArgumentException ( "Registrar should be a valid member" ) ; } String readIdURL = "" ; try { readIdURL = HFCA_IDENTITY + "/" + enrollmentID ; logger . debug ( format ( "identity url: %s, registrar: %s" , readIdURL , registrar . getName ( ) ) ) ; JsonObject result = client . httpGet ( readIdURL , registrar ) ; statusCode = result . getInt ( "statusCode" ) ; if ( statusCode < 400 ) { type = result . getString ( "type" ) ; maxEnrollments = result . getInt ( "max_enrollments" ) ; affiliation = result . getString ( "affiliation" ) ; JsonArray attributes = result . getJsonArray ( "attrs" ) ; Collection < Attribute > attrs = new ArrayList < Attribute > ( ) ; if ( attributes != null && ! attributes . isEmpty ( ) ) { for ( int i = 0 ; i < attributes . size ( ) ; i ++ ) { JsonObject attribute = attributes . getJsonObject ( i ) ; Attribute attr = new Attribute ( attribute . getString ( "name" ) , attribute . getString ( "value" ) , attribute . getBoolean ( "ecert" , false ) ) ; attrs . add ( attr ) ; } } this . attrs = attrs ; logger . debug ( format ( "identity url: %s, registrar: %s done." , readIdURL , registrar ) ) ; } this . deleted = false ; return statusCode ; } catch ( HTTPException e ) { String msg = format ( "[Code: %d] - Error while getting user '%s' from url '%s': %s" , e . getStatusCode ( ) , getEnrollmentId ( ) , readIdURL , e . getMessage ( ) ) ; IdentityException identityException = new IdentityException ( msg , e ) ; logger . error ( msg ) ; throw identityException ; } catch ( Exception e ) { String msg = format ( "Error while getting user '%s' from url '%s': %s" , enrollmentID , readIdURL , e . getMessage ( ) ) ; IdentityException identityException = new IdentityException ( msg , e ) ; logger . error ( msg ) ; throw identityException ; } }
read retrieves a specific identity