public void handleGetUsers ( String jsonp , String target , HttpServletRequest request , HttpServletResponse response ) throws IOException , ServletException { ObjectMapper mapper = new ObjectMapper ( ) ; User user = null ; String [ ] splitTarget = target . split ( "/" ) ; if ( splitTarget . length < 3 || splitTarget [ 2 ] . isEmpty ( ) ) { if ( jsonp != null ) { response . getWriter ( ) . write ( jsonp + "(" ) ; } if ( getDeployment ( ) . getUsers ( ) != null ) { List < IdUser > id = new ArrayList <> ( ) ; for ( UsersType . User u : getDeployment ( ) . getUsers ( ) . getUser ( ) ) { id . add ( new IdUser ( u , getHostHeader ( ) ) ) ; } mapper . writeValue ( response . getWriter ( ) , id ) ; } else { response . getWriter ( ) . write ( "[]" ) ; } if ( jsonp != null ) { response . getWriter ( ) . write ( ")" ) ; } return ; } user = findUser ( splitTarget [ 2 ] , getDeployment ( ) ) ; if ( user == null ) { response . setStatus ( HttpServletResponse . SC_NOT_FOUND ) ; response . getWriter ( ) . print ( buildClientResponse ( jsonp , ClientResponse . UNEXPECTED_FAILURE , "User not found" ) ) ; return ; } else { if ( jsonp != null ) { response . getWriter ( ) . write ( jsonp + "(" ) ; } mapper . writeValue ( response . getWriter ( ) , new IdUser ( user , getHostHeader ( ) ) ) ; if ( jsonp != null ) { response . getWriter ( ) . write ( ")" ) ; } } }
Handle GET for users