Esempio n. 1
0
 @Override
 public int hashCode() {
   final int prime = 31;
   int result = 1;
   result = prime * result + ((response == null) ? 0 : response.hashCode());
   result = prime * result + statusCode;
   return result;
 }
 public static ContributorFact createContributorFact(HttpResponse res) {
   if (null == res) {
     return null;
   }
   XMLParser parser = new XMLParser(res.asString());
   ContributorFact contributorFact = new ContributorFactImpl(parser, false);
   return contributorFact;
 }
Esempio n. 3
0
 public String getResponseHeader(String name) {
   String value = null;
   if (response != null) {
     List<String> header = response.getResponseHeaderFields().get(name);
     if (header.size() > 0) {
       value = header.get(0);
     }
   }
   return value;
 }
Esempio n. 4
0
 @Override
 public boolean equals(Object obj) {
   if (this == obj) return true;
   if (obj == null) return false;
   if (getClass() != obj.getClass()) return false;
   OhlohException other = (OhlohException) obj;
   if (response == null) {
     if (other.response != null) return false;
   } else if (!response.equals(other.response)) return false;
   if (statusCode != other.statusCode) return false;
   return true;
 }
 public static ResponseList<ContributorFact> createContributorFactList(HttpResponse res) {
   if (null == res) {
     return null;
   }
   XMLParser parser = new XMLParser(res.asString());
   NodeList nodelist = parser.getNodeList("response/result/contributor_fact");
   ResponseList<ContributorFact> list =
       new ResponseListImpl<ContributorFact>(nodelist.getLength(), res);
   for (int i = 0; i < nodelist.getLength(); i++) {
     Node node = nodelist.item(i);
     try {
       XMLParser childParser = new XMLParser(XMLParser.getXmlStringFromNode(node));
       ContributorFact contributorFact = new ContributorFactImpl(childParser, true);
       list.add(contributorFact);
     } catch (TransformerFactoryConfigurationError e) {
       e.printStackTrace();
     } catch (TransformerException e) {
       e.printStackTrace();
     }
   }
   return list;
 }
Esempio n. 6
0
 public OhlohException(String message, HttpResponse res) {
   this(message);
   response = res;
   this.statusCode = res.getStatusCode();
 }