@Test public void getAffiliationNoServerResponse() throws Exception { thrown.expect(AffiliationException.class); thrown.expectMessage("Error while getting affiliation"); HFCAClient client = HFCAClient.createNewInstance("http: client.setCryptoSuite(crypto); HFCAAffiliation aff = client.newHFCAAffiliation("neworg1"); aff.read(admin); }
public int read(User registrar) throws AffiliationException, InvalidArgumentException { if (registrar == null) { throw new InvalidArgumentException("Registrar should be a valid member"); } String readAffURL = ""; try { readAffURL = HFCA_AFFILIATION + "/" + name; logger.debug(format("affiliation url: %s, registrar: %s", readAffURL, registrar.getName())); JsonObject result = client.httpGet(readAffURL, registrar); logger.debug(format("affiliation url: %s, registrar: %s done.", readAffURL, registrar)); HFCAAffiliationResp resp = getResponse(result); System.out.println("aff read resp: " + result); System.out.println("resp.getChildren().size(): " + resp.getChildren().size()); this.childHFCAAffiliations = resp.getChildren(); System.out.println("this.childHFCAAffiliations: " + this.childHFCAAffiliations.size()); this.identities = resp.getIdentities(); this.deleted = false; return resp.statusCode; } catch (HTTPException e) { String msg = format("[Code: %d] - Error while getting affiliation '%s' from url '%s': %s", e.getStatusCode(), this.name, readAffURL, e.getMessage()); AffiliationException affiliationException = new AffiliationException(msg, e); logger.error(msg); throw affiliationException; } catch (Exception e) { String msg = format("Error while getting affiliation %s url: %s %s ", this.name, readAffURL, e.getMessage()); AffiliationException affiliationException = new AffiliationException(msg, e); logger.error(msg); throw affiliationException; } }
HFCAAffiliation { public int read(User registrar) throws AffiliationException, InvalidArgumentException { if (registrar == null) { throw new InvalidArgumentException("Registrar should be a valid member"); } String readAffURL = ""; try { readAffURL = HFCA_AFFILIATION + "/" + name; logger.debug(format("affiliation url: %s, registrar: %s", readAffURL, registrar.getName())); JsonObject result = client.httpGet(readAffURL, registrar); logger.debug(format("affiliation url: %s, registrar: %s done.", readAffURL, registrar)); HFCAAffiliationResp resp = getResponse(result); System.out.println("aff read resp: " + result); System.out.println("resp.getChildren().size(): " + resp.getChildren().size()); this.childHFCAAffiliations = resp.getChildren(); System.out.println("this.childHFCAAffiliations: " + this.childHFCAAffiliations.size()); this.identities = resp.getIdentities(); this.deleted = false; return resp.statusCode; } catch (HTTPException e) { String msg = format("[Code: %d] - Error while getting affiliation '%s' from url '%s': %s", e.getStatusCode(), this.name, readAffURL, e.getMessage()); AffiliationException affiliationException = new AffiliationException(msg, e); logger.error(msg); throw affiliationException; } catch (Exception e) { String msg = format("Error while getting affiliation %s url: %s %s ", this.name, readAffURL, e.getMessage()); AffiliationException affiliationException = new AffiliationException(msg, e); logger.error(msg); throw affiliationException; } } }
HFCAAffiliation { public int read(User registrar) throws AffiliationException, InvalidArgumentException { if (registrar == null) { throw new InvalidArgumentException("Registrar should be a valid member"); } String readAffURL = ""; try { readAffURL = HFCA_AFFILIATION + "/" + name; logger.debug(format("affiliation url: %s, registrar: %s", readAffURL, registrar.getName())); JsonObject result = client.httpGet(readAffURL, registrar); logger.debug(format("affiliation url: %s, registrar: %s done.", readAffURL, registrar)); HFCAAffiliationResp resp = getResponse(result); System.out.println("aff read resp: " + result); System.out.println("resp.getChildren().size(): " + resp.getChildren().size()); this.childHFCAAffiliations = resp.getChildren(); System.out.println("this.childHFCAAffiliations: " + this.childHFCAAffiliations.size()); this.identities = resp.getIdentities(); this.deleted = false; return resp.statusCode; } catch (HTTPException e) { String msg = format("[Code: %d] - Error while getting affiliation '%s' from url '%s': %s", e.getStatusCode(), this.name, readAffURL, e.getMessage()); AffiliationException affiliationException = new AffiliationException(msg, e); logger.error(msg); throw affiliationException; } catch (Exception e) { String msg = format("Error while getting affiliation %s url: %s %s ", this.name, readAffURL, e.getMessage()); AffiliationException affiliationException = new AffiliationException(msg, e); logger.error(msg); throw affiliationException; } } HFCAAffiliation(String name, HFCAClient client);   HFCAAffiliation(JsonObject result); }
HFCAAffiliation { public int read(User registrar) throws AffiliationException, InvalidArgumentException { if (registrar == null) { throw new InvalidArgumentException("Registrar should be a valid member"); } String readAffURL = ""; try { readAffURL = HFCA_AFFILIATION + "/" + name; logger.debug(format("affiliation url: %s, registrar: %s", readAffURL, registrar.getName())); JsonObject result = client.httpGet(readAffURL, registrar); logger.debug(format("affiliation url: %s, registrar: %s done.", readAffURL, registrar)); HFCAAffiliationResp resp = getResponse(result); System.out.println("aff read resp: " + result); System.out.println("resp.getChildren().size(): " + resp.getChildren().size()); this.childHFCAAffiliations = resp.getChildren(); System.out.println("this.childHFCAAffiliations: " + this.childHFCAAffiliations.size()); this.identities = resp.getIdentities(); this.deleted = false; return resp.statusCode; } catch (HTTPException e) { String msg = format("[Code: %d] - Error while getting affiliation '%s' from url '%s': %s", e.getStatusCode(), this.name, readAffURL, e.getMessage()); AffiliationException affiliationException = new AffiliationException(msg, e); logger.error(msg); throw affiliationException; } catch (Exception e) { String msg = format("Error while getting affiliation %s url: %s %s ", this.name, readAffURL, e.getMessage()); AffiliationException affiliationException = new AffiliationException(msg, e); logger.error(msg); throw affiliationException; } } HFCAAffiliation(String name, HFCAClient client);   HFCAAffiliation(JsonObject result); String getName(); String getUpdateName(); void setUpdateName(String updateName); Collection<HFCAAffiliation> getChildren(); Collection<HFCAIdentity> getIdentities(); HFCAAffiliation createDecendent(String name); HFCAAffiliation getChild(String name); boolean isDeleted(); int read(User registrar); HFCAAffiliationResp create(User registrar); HFCAAffiliationResp create(User registrar, boolean force); HFCAAffiliationResp update(User registrar); HFCAAffiliationResp update(User registrar, boolean force); HFCAAffiliationResp delete(User registrar); HFCAAffiliationResp delete(User registrar, boolean force); }
HFCAAffiliation { public int read(User registrar) throws AffiliationException, InvalidArgumentException { if (registrar == null) { throw new InvalidArgumentException("Registrar should be a valid member"); } String readAffURL = ""; try { readAffURL = HFCA_AFFILIATION + "/" + name; logger.debug(format("affiliation url: %s, registrar: %s", readAffURL, registrar.getName())); JsonObject result = client.httpGet(readAffURL, registrar); logger.debug(format("affiliation url: %s, registrar: %s done.", readAffURL, registrar)); HFCAAffiliationResp resp = getResponse(result); System.out.println("aff read resp: " + result); System.out.println("resp.getChildren().size(): " + resp.getChildren().size()); this.childHFCAAffiliations = resp.getChildren(); System.out.println("this.childHFCAAffiliations: " + this.childHFCAAffiliations.size()); this.identities = resp.getIdentities(); this.deleted = false; return resp.statusCode; } catch (HTTPException e) { String msg = format("[Code: %d] - Error while getting affiliation '%s' from url '%s': %s", e.getStatusCode(), this.name, readAffURL, e.getMessage()); AffiliationException affiliationException = new AffiliationException(msg, e); logger.error(msg); throw affiliationException; } catch (Exception e) { String msg = format("Error while getting affiliation %s url: %s %s ", this.name, readAffURL, e.getMessage()); AffiliationException affiliationException = new AffiliationException(msg, e); logger.error(msg); throw affiliationException; } } HFCAAffiliation(String name, HFCAClient client);   HFCAAffiliation(JsonObject result); String getName(); String getUpdateName(); void setUpdateName(String updateName); Collection<HFCAAffiliation> getChildren(); Collection<HFCAIdentity> getIdentities(); HFCAAffiliation createDecendent(String name); HFCAAffiliation getChild(String name); boolean isDeleted(); int read(User registrar); HFCAAffiliationResp create(User registrar); HFCAAffiliationResp create(User registrar, boolean force); HFCAAffiliationResp update(User registrar); HFCAAffiliationResp update(User registrar, boolean force); HFCAAffiliationResp delete(User registrar); HFCAAffiliationResp delete(User registrar, boolean force);  }