Revision 57218
Added by Alessia Bardi over 4 years ago
modules/dnet-parthenos/trunk/src/main/java/eu/dnetlib/parthenos/workflows/nodes/PublishJRRJobNode.java | ||
---|---|---|
21 | 21 |
import org.springframework.http.HttpEntity; |
22 | 22 |
import org.springframework.http.HttpMethod; |
23 | 23 |
import org.springframework.http.ResponseEntity; |
24 |
import org.springframework.http.client.ClientHttpRequestFactory; |
|
25 |
import org.springframework.http.client.HttpComponentsClientHttpRequestFactory; |
|
24 | 26 |
import org.springframework.web.client.RestTemplate; |
25 | 27 |
|
26 | 28 |
public class PublishJRRJobNode extends AsyncJobNode { |
... | ... | |
50 | 52 |
HttpEntity<String> entity = new HttpEntity<String>(jsonBody); |
51 | 53 |
URI uri = new URIBuilder(getPublisherEndpoint()+"/publishJRR").build(); |
52 | 54 |
log.debug("Request goes to "+uri.toString()+" post body:\n"+jsonBody); |
55 |
restTemplate = new RestTemplate(getClientHttpRequestFactory()); |
|
53 | 56 |
ResponseEntity<Integer> res = restTemplate.exchange(uri, HttpMethod.POST, entity, Integer.class); |
54 | 57 |
if(res.getStatusCode().is2xxSuccessful()){ |
55 | 58 |
int resolved = res.getBody(); |
... | ... | |
64 | 67 |
} |
65 | 68 |
} |
66 | 69 |
|
70 |
protected ClientHttpRequestFactory getClientHttpRequestFactory() { |
|
71 |
HttpComponentsClientHttpRequestFactory clientHttpRequestFactory = new HttpComponentsClientHttpRequestFactory(); |
|
72 |
return clientHttpRequestFactory; |
|
73 |
} |
|
74 |
|
|
67 | 75 |
public String getPublisherEndpoint() { |
68 | 76 |
return publisherEndpoint; |
69 | 77 |
} |
Also available in: Unified diff
create the resttemplate