public HFCAAffiliationResp delete ( 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" ) ; } String deleteURL = "" ; try { Map < String , String > queryParm = new HashMap < String , String > ( ) ; queryParm . put ( "force" , String . valueOf ( force ) ) ; deleteURL = client . getURL ( HFCA_AFFILIATION + "/" + this . name , queryParm ) ; logger . debug ( format ( "affiliation url: %s, registrar: %s" , deleteURL , registrar . getName ( ) ) ) ; JsonObject result = client . httpDelete ( deleteURL , registrar ) ; logger . debug ( format ( "identity url: %s, registrar: %s done." , deleteURL , registrar ) ) ; this . deleted = true ; return getResponse ( result ) ; } catch ( HTTPException e ) { String msg = format ( "[Code: %d] - Error while deleting affiliation '%s' from url '%s': %s" , e . getStatusCode ( ) , this . name , deleteURL , e . getMessage ( ) ) ; AffiliationException affiliationException = new AffiliationException ( msg , e ) ; logger . error ( msg ) ; throw affiliationException ; } catch ( Exception e ) { String msg = format ( "Error while deleting affiliation %s url: %s %s " , this . name , deleteURL , e . getMessage ( ) ) ; AffiliationException affiliationException = new AffiliationException ( msg , e ) ; logger . error ( msg ) ; throw affiliationException ; } }
delete an affiliation