Project

General

Profile

« Previous | Next » 

Revision 8777

use HttpClient to query orcid so I can easily set headers and such -- getting 503s from their production server when I test on dev.nceas...odd

View differences:

src/edu/ucsb/nceas/metacat/annotation/OrcidService.java
9 9
import java.util.List;
10 10

  
11 11

  
12
import org.apache.commons.httpclient.HttpClient;
13
import org.apache.commons.httpclient.HttpMethod;
14
import org.apache.commons.httpclient.methods.GetMethod;
12 15
import org.apache.commons.io.IOUtils;
13 16
import org.apache.log4j.Logger;
14 17
import org.apache.wicket.protocol.http.mock.MockHttpServletRequest;
......
62 65
			
63 66
			url = REST_URL + "?q=" + urlParameters + "&rows=1";
64 67
			URL restURL = new URL(url);
65
			InputStream is = restURL.openStream();
66
			String results = IOUtils.toString(is);
68
			HttpClient client = new HttpClient();
69
			HttpMethod method = new GetMethod(url);
70
			method.addRequestHeader("Accept", "application/orcid+xml");
71
			client.executeMethod(method);
72
			InputStream is = method.getResponseBodyAsStream();
73
			//InputStream is = restURL.openStream();
74
			
75
			String results = IOUtils.toString(is, "UTF-8");
67 76
			logMetacat.debug("RESULTS: " + results);
68 77
			Node doc = XMLUtilities.getXMLReaderAsDOMTreeRootNode(new StringReader(results));
69 78
			Node orcidUriNodeList = XMLUtilities.getNodeWithXPath(doc, "//*[local-name()=\"orcid-identifier\"]/*[local-name()=\"uri\"]");

Also available in: Unified diff