35 |
35 |
private String resolverBodyTemplate = "{ \"entity_name\": \"%s\" }";
|
36 |
36 |
|
37 |
37 |
private final String createItemPath = "rest/api/items/create";
|
|
38 |
private final String updateItemPath = "rest/api/items/update";
|
38 |
39 |
private final String showItemPath = "rest/api/items/show"; //param id
|
39 |
40 |
private final String purgeItemPath = "rest/api/items/purge";
|
40 |
41 |
|
... | ... | |
98 |
99 |
*/
|
99 |
100 |
public String doRegister(final String json, final String resCatName) throws URISyntaxException, IOException {
|
100 |
101 |
log.debug(String.format("Catalogue --> Registering item %s : %s", resCatName, json));
|
|
102 |
return doCatalogueCall(json, resCatName, createItemPath);
|
|
103 |
}
|
|
104 |
|
|
105 |
public String doUpdate(final String json, final String resCatName) throws IOException, URISyntaxException {
|
|
106 |
log.debug(String.format("Catalogue --> Updating item %s : %s", resCatName, json));
|
|
107 |
return doCatalogueCall(json, resCatName, updateItemPath);
|
|
108 |
}
|
|
109 |
|
|
110 |
protected String doCatalogueCall(final String json, final String resCatName, final String actionPath) throws URISyntaxException, IOException {
|
101 |
111 |
HttpEntity<String> entity = new HttpEntity<String>(json, getHeaders());
|
102 |
|
URI uri = new URIBuilder(getBaseURL() + createItemPath).addParameter("gcube-token", getApplicationToken()).build();
|
|
112 |
URI uri = new URIBuilder(getBaseURL() + actionPath).addParameter("gcube-token", getApplicationToken()).build();
|
103 |
113 |
ResponseEntity<String> res = jrrRestTemplate.exchange(uri, HttpMethod.POST, entity, String.class);
|
104 |
114 |
CatalogueAPIResponse response = new CatalogueAPIResponse();
|
105 |
115 |
if (res.getStatusCode() == HttpStatus.OK) {
|
... | ... | |
108 |
118 |
if (response.isSuccess()) {
|
109 |
119 |
return response.getParthenosRegistryResource().getUuid();
|
110 |
120 |
} else {
|
111 |
|
log.warn(resCatName + " could not be registered because of " + response.getErrorMessage());
|
|
121 |
log.warn(resCatName + " could not be registered/updated because of " + response.getErrorMessage());
|
112 |
122 |
return null;
|
113 |
123 |
}
|
114 |
124 |
} else {
|
Implemented method for updating catalogue resources