[Admin tools | Trunk]: BrowserCacheController.java: Commented catch of exceptions to print error stacktraces | [Bug fix] Response is HTML, so added String.class instead of Object.class.

This commit is contained in:
Konstantina Galouni 2022-08-11 15:03:51 +00:00
parent ee0eb49e24
commit 09d1088a8b
1 changed files with 12 additions and 10 deletions

View File

@ -3,7 +3,6 @@ package eu.dnetlib.uoaadmintools.controllers;
import eu.dnetlib.uoaadmintools.configuration.properties.BrowserCacheConfig;
import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.client.HttpClientErrorException;
@ -27,15 +26,18 @@ public class BrowserCacheController {
"@AuthorizationService.curator('community'), @AuthorizationService.manager('community', #pid))")
@RequestMapping(value = "/{pid}", method = RequestMethod.GET)
public boolean purge(@PathVariable(value = "pid") String pid) {
try {
ResponseEntity<Object> responseEntity = restTemplate.getForEntity(config.getUrl().replace("{community}", pid), Object.class);
} catch(HttpClientErrorException httpClientErrorException) {
log.debug("Purge browser cache: HttpClientErrorException for "+pid + " - code: " + httpClientErrorException.getStatusCode());
} catch(ResourceAccessException resourceAccessException) {
log.debug("Purge browser cache: ResourceAccessException for "+pid);
} catch(Exception exception) {
log.debug("Purge browser cache: " + exception.getClass() + " for "+pid);
}
// try {
restTemplate.getForEntity(config.getUrl().replace("{community}", pid), String.class);
// } catch(HttpClientErrorException httpClientErrorException) {
// log.debug("Purge browser cache: HttpClientErrorException for "+pid + " - code: " + httpClientErrorException.getStatusCode());
// return false;
// } catch(ResourceAccessException resourceAccessException) {
// log.debug("Purge browser cache: ResourceAccessException for "+pid);
// return false;
// } catch(Exception exception) {
// log.debug("Purge browser cache: " + exception.getClass() + " for "+pid);
// return false;
// }
return true;
}
}