1010import org .apache .http .util .EntityUtils ;
1111import org .apache .log4j .Logger ;
1212import org .springframework .beans .factory .annotation .Autowired ;
13+ import org .springframework .data .domain .Page ;
14+ import org .springframework .data .domain .PageRequest ;
1315import org .springframework .http .HttpHeaders ;
1416import org .springframework .http .HttpStatus ;
1517import org .springframework .http .ResponseEntity ;
@@ -45,7 +47,7 @@ public HueMulator(){
4547 @ RequestMapping (value = "/{userId}/lights" , method = RequestMethod .GET , produces = "application/json" )
4648 public ResponseEntity <Map <String , String >> getUpnpConfiguration (@ PathVariable (value = "userId" ) String userId , HttpServletRequest request ) {
4749 log .info ("hue lights list requested: " + userId + " from " + request .getRemoteAddr ());
48- List <DeviceDescriptor > deviceList = repository .findByDeviceType ("switch" );
50+ Page <DeviceDescriptor > deviceList = repository .findByDeviceType ("switch" , new PageRequest ( 0 , 100 ) );
4951 Map <String , String > deviceResponseMap = new HashMap <>();
5052 for (DeviceDescriptor device : deviceList ) {
5153 deviceResponseMap .put (device .getId (), device .getName ());
@@ -56,7 +58,7 @@ public ResponseEntity<Map<String, String>> getUpnpConfiguration(@PathVariable(va
5658 @ RequestMapping (value = "/{userId}" , method = RequestMethod .GET , produces = "application/json" )
5759 public ResponseEntity <HueApiResponse > getApi (@ PathVariable (value = "userId" ) String userId , HttpServletRequest request ) {
5860 log .info ("hue api root requested: " + userId + " from " + request .getRemoteAddr ());
59- List <DeviceDescriptor > descriptorList = repository .findByDeviceType ("switch" );
61+ Page <DeviceDescriptor > descriptorList = repository .findByDeviceType ("switch" , new PageRequest ( 0 , 100 ) );
6062 if (descriptorList == null ) {
6163 return new ResponseEntity <>(null , null , HttpStatus .NOT_FOUND );
6264 }
0 commit comments