Project

General

Profile

« Previous | Next » 

Revision 8810

add support for v2 DataONE API.

View differences:

ReplicationService.java
65 65
import org.apache.http.conn.scheme.Scheme;
66 66
import org.apache.http.conn.ssl.SSLSocketFactory;
67 67
import org.apache.log4j.Logger;
68
import org.dataone.client.RestClient;
68
import org.dataone.client.rest.DefaultHttpMultipartRestClient;
69
import org.dataone.client.rest.RestClient;
69 70
import org.dataone.client.auth.CertificateManager;
70 71
import org.dataone.service.types.v1.Identifier;
71
import org.dataone.service.types.v1.SystemMetadata;
72
import org.dataone.service.types.v2.SystemMetadata;
72 73
import org.dataone.service.util.DateTimeMarshaller;
73 74
import org.dataone.service.util.TypeMarshaller;
74 75
import org.jibx.runtime.JiBXException;
......
1468 1469
							+ me.getMessage());
1469 1470
			// e.printStackTrace(System.out);
1470 1471
			errorMsg = me.getMessage();
1472
		} catch (Exception e) {
1473
			logReplication
1474
			.error("ReplicationService.handleGetDocumentRequest - General exception encountered."
1475
					+ "handlGetDocumentRequest for file: "
1476
					+ documentPath
1477
					+ " : "
1478
					+ e.getMessage());
1479
			// e.printStackTrace(System.out);
1480
			errorMsg = e.getMessage();
1471 1481
		} finally {
1472 1482
            IOUtils.closeQuietly(fos);
1473 1483
            IOUtils.closeQuietly(is);
......
2259 2269
	 * @return a string representing the content of the url
2260 2270
	 * @throws java.io.IOException
2261 2271
	 */
2262
	public static String getURLContent(URL u) throws java.io.IOException {
2272
	public static String getURLContent(URL u) throws Exception {
2263 2273
		char istreamChar;
2264 2274
		int istreamInt;
2265 2275
		// get the response content
......
2283 2293
	 * @return a InputStream representing the content of the url
2284 2294
	 * @throws java.io.IOException
2285 2295
	 */
2286
	public static InputStream getURLStream(URL u) throws java.io.IOException {
2296
	public static InputStream getURLStream(URL u) throws Exception {
2287 2297
	    logReplication.info("Getting url stream from " + u.toString());
2288 2298
		logReplication.info("ReplicationService.getURLStream - Before sending request to: " + u.toString());
2289 2299
		// use httpclient to set up SSL
2290
		RestClient client = getSSLClient();
2291
		HttpResponse response = client.doGetRequest(u.toString());
2300
		DefaultHttpMultipartRestClient client = getSSLClient();
2292 2301
		// get the response content
2293
		InputStream input = response.getEntity().getContent();
2302
		InputStream input = client.doGetRequest(u.toString(), CLIENTTIMEOUT);
2294 2303
		logReplication.info("ReplicationService.getURLStream - After getting response from: " + u.toString());
2295 2304
		
2296 2305
		return input;		
......
2301 2310
	 * Sends client certificate to the server when doing the request.
2302 2311
	 * @return
2303 2312
	 */
2304
	private static RestClient getSSLClient() {
2305
		RestClient client = new RestClient();
2313
	private static DefaultHttpMultipartRestClient getSSLClient() {
2314
		DefaultHttpMultipartRestClient client = new DefaultHttpMultipartRestClient();
2306 2315
		
2307 2316
		// set up this server's client identity
2308 2317
		String subject = null;
......
2321 2330
		}
2322 2331
		
2323 2332
		// set the configured timeout
2324
		client.setTimeouts(CLIENTTIMEOUT);
2333
		//client.setTimeouts(CLIENTTIMEOUT);
2325 2334

  
2326 2335
		SSLSocketFactory socketFactory = null;
2327 2336
		try {

Also available in: Unified diff