Revision 61318
Added by Konstantinos Spyrou almost 3 years ago
HttpUtils.java | ||
---|---|---|
18 | 18 |
|
19 | 19 |
private static final Logger logger = Logger.getLogger(HttpUtils.class); |
20 | 20 |
|
21 |
//TODO: refactor |
|
21 | 22 |
// TODO: To be changed the values |
22 | 23 |
// @Value("https://aai.openaire.eu/registry/") |
23 | 24 |
@Value("https://openaire-dev.aai-dev.grnet.gr/registry/") |
... | ... | |
35 | 36 |
headers.setContentType(MediaType.APPLICATION_JSON); |
36 | 37 |
HttpEntity<String> request = new HttpEntity<>(body.toString(), headers); |
37 | 38 |
ResponseEntity<String> responseEntity = restTemplate.exchange(issuer + path, HttpMethod.POST, request, String.class); |
38 |
if(responseEntity.getBody() != null) { |
|
39 |
if (responseEntity.getBody() != null) {
|
|
39 | 40 |
return new JsonParser().parse(responseEntity.getBody()); |
40 | 41 |
} else { |
41 | 42 |
return null; |
... | ... | |
48 | 49 |
headers.setContentType(MediaType.APPLICATION_JSON); |
49 | 50 |
HttpEntity<String> request = new HttpEntity<>(body.toString(), headers); |
50 | 51 |
ResponseEntity<String> responseEntity = restTemplate.exchange(issuer + path, HttpMethod.PUT, request, String.class); |
51 |
if(responseEntity.getBody() != null) { |
|
52 |
if (responseEntity.getBody() != null) {
|
|
52 | 53 |
return new JsonParser().parse(responseEntity.getBody()); |
53 | 54 |
} else { |
54 | 55 |
return null; |
... | ... | |
60 | 61 |
String url = issuer + path + ((params != null) ? createParams(params) : null); |
61 | 62 |
ResponseEntity<String> responseEntity = restTemplate.exchange |
62 | 63 |
(url, HttpMethod.GET, new HttpEntity<>(createHeaders(user, password)), String.class); |
63 |
if(responseEntity.getBody() != null) { |
|
64 |
if (responseEntity.getBody() != null) {
|
|
64 | 65 |
return new JsonParser().parse(responseEntity.getBody()); |
65 | 66 |
} else { |
66 | 67 |
return null; |
... | ... | |
72 | 73 |
String url = issuer + path; |
73 | 74 |
ResponseEntity<String> responseEntity = restTemplate.exchange |
74 | 75 |
(url, HttpMethod.DELETE, new HttpEntity<>(createHeaders(user, password)), String.class); |
75 |
if(responseEntity.getBody() != null) { |
|
76 |
if (responseEntity.getBody() != null) {
|
|
76 | 77 |
return new JsonParser().parse(responseEntity.getBody()); |
77 | 78 |
} else { |
78 | 79 |
return null; |
Also available in: Unified diff
1. fixed authorization in RepositoryController
2. created new methods and classes
3. made authorities mapping the same as with other openaire projects
4. refactoring