public HFCAAffiliationResp update ( User registrar , boolean force ) throws AffiliationException , InvalidArgumentException { if ( this . deleted ) { throw new AffiliationException ( "Affiliation has been deleted" ) ; } if ( registrar == null ) { throw new InvalidArgumentException ( "Registrar should be a valid member" ) ; } if ( Utils . isNullOrEmpty ( name ) ) { throw new InvalidArgumentException ( "Affiliation name cannot be null or empty" ) ; } String updateURL = "" ; try { Map < String , String > queryParm = new HashMap < String , String > ( ) ; queryParm . put ( "force" , String . valueOf ( force ) ) ; updateURL = client . getURL ( HFCA_AFFILIATION + "/" + this . name , queryParm ) ; logger . debug ( format ( "affiliation url: %s, registrar: %s" , updateURL , registrar . getName ( ) ) ) ; String body = client . toJson ( affToJsonObject ( ) ) ; JsonObject result = client . httpPut ( updateURL , body , registrar ) ; generateResponse ( result ) ; logger . debug ( format ( "identity url: %s, registrar: %s done." , updateURL , registrar ) ) ; HFCAAffiliationResp resp = getResponse ( result ) ; this . childHFCAAffiliations = resp . childHFCAAffiliations ; this . identities = resp . identities ; return getResponse ( result ) ; } catch ( HTTPException e ) { String msg = format ( "[Code: %d] - Error while updating affiliation '%s' from url '%s': %s" , e . getStatusCode ( ) , this . name , updateURL , e . getMessage ( ) ) ; AffiliationException affiliationException = new AffiliationException ( msg , e ) ; logger . error ( msg ) ; throw affiliationException ; } catch ( Exception e ) { String msg = format ( "Error while updating affiliation %s url: %s %s " , this . name , updateURL , e . getMessage ( ) ) ; AffiliationException affiliationException = new AffiliationException ( msg , e ) ; logger . error ( msg ) ; throw affiliationException ; } }
update an affiliation