Created
June 18, 2015 17:45
Revisions
-
astro-jdc created this gist
Jun 18, 2015 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,43 @@ @GET @Produces("application/json") @NoCache public List<UsuarioJS> getUsuarios(@QueryParam("min") String min, @QueryParam("results") String results) { // Just to show how to user info from access token in REST endpoint KeycloakSecurityContext securityContext = (KeycloakSecurityContext) httpRequest .getAttribute(KeycloakSecurityContext.class.getName()); AccessToken accessToken = securityContext.getToken(); // Chequeamos que le valor min y max sea valido // La diferencia entre min y max no puede ser mayor a 20 int minInt, maxInt; try { minInt = Integer.parseInt(min); } catch (NumberFormatException nfe) { minInt = 0; } try { maxInt = Integer.parseInt(results); } catch (NumberFormatException nfe) { maxInt = 10; } if (minInt < 0) { minInt = 0; } if (maxInt > 20) { maxInt = 20; } // TODO registro List<Usuario> usuarios = usuarioDao.obtenerUsuarios(minInt, maxInt, "ASC"); List<UsuarioJS> finalUsuario = new ArrayList<UsuarioJS>(); for (Usuario usuario : usuarios) { // System.out.println(temp); UsuarioJS usuarioJS = new UsuarioJS(usuario); finalUsuario.add(usuarioJS); } return finalUsuario; }