|
@@ -17,6 +17,7 @@ import org.springframework.web.bind.annotation.RequestBody;
|
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
import org.springframework.web.bind.annotation.RequestParam;
|
|
|
import org.springframework.web.bind.annotation.RestController;
|
|
|
+import org.springframework.web.client.ResourceAccessException;
|
|
|
import org.springframework.web.client.RestTemplate;
|
|
|
|
|
|
import es.uv.garcosda.shared.Video;
|
|
@@ -46,12 +47,17 @@ public class VideosController {
|
|
|
url+="?userId="+userId.get();
|
|
|
}
|
|
|
|
|
|
- ResponseEntity<Video[]> response = template.getForEntity(url, Video[].class);
|
|
|
- if(response.getStatusCode() == HttpStatus.OK) {
|
|
|
- List<Video> videos = Arrays.stream(response.getBody()).collect(Collectors.toList());
|
|
|
- return new ResponseEntity<List<Video>>(videos, HttpStatus.OK);
|
|
|
+ try {
|
|
|
+ ResponseEntity<Video[]> response = template.getForEntity(url, Video[].class);
|
|
|
+ if(response.getStatusCode() == HttpStatus.OK) {
|
|
|
+ List<Video> videos = Arrays.stream(response.getBody()).collect(Collectors.toList());
|
|
|
+ return new ResponseEntity<List<Video>>(videos, HttpStatus.OK);
|
|
|
+ }
|
|
|
+ return new ResponseEntity<String>("API returned no content", HttpStatus.SERVICE_UNAVAILABLE);
|
|
|
}
|
|
|
- return new ResponseEntity<String>("API returned no content", HttpStatus.SERVICE_UNAVAILABLE);
|
|
|
+ catch(ResourceAccessException e){ }
|
|
|
+
|
|
|
+ return new ResponseEntity<String>("Cannot connect to repository", HttpStatus.SERVICE_UNAVAILABLE);
|
|
|
}
|
|
|
|
|
|
@GetMapping("{id}")
|