public void handleRemoveUser ( String jsonp , String target , HttpServletRequest request , HttpServletResponse response , AuthenticationResult ar ) throws IOException , ServletException { try { DeploymentType newDeployment = CatalogUtil . getDeployment ( new ByteArrayInputStream ( getDeploymentBytes ( ) ) ) ; User user = null ; String [ ] splitTarget = target . split ( "/" ) ; if ( splitTarget . length == 3 ) { user = findUser ( splitTarget [ 2 ] , newDeployment ) ; } if ( user == null ) { response . setStatus ( HttpServletResponse . SC_NOT_FOUND ) ; response . getWriter ( ) . print ( buildClientResponse ( jsonp , ClientResponse . UNEXPECTED_FAILURE , "User not found" ) ) ; return ; } if ( newDeployment . getUsers ( ) . getUser ( ) . size ( ) == 1 ) { newDeployment . setUsers ( null ) ; } else { newDeployment . getUsers ( ) . getUser ( ) . remove ( user ) ; } String dep = CatalogUtil . getDeployment ( newDeployment ) ; if ( dep == null || dep . trim ( ) . length ( ) <= 0 ) { response . setStatus ( HttpServletResponse . SC_BAD_REQUEST ) ; response . getWriter ( ) . print ( buildClientResponse ( jsonp , ClientResponse . UNEXPECTED_FAILURE , "Failed to build deployment information." ) ) ; return ; } Object [ ] params = new Object [ ] { null , dep } ; //Call sync as nothing else can happen when this is going on. SyncCallback cb = new SyncCallback ( ) ; httpClientInterface . callProcedure ( request . getRemoteHost ( ) , ar , BatchTimeoutOverrideType . NO_TIMEOUT , cb , "@UpdateApplicationCatalog" , params ) ; cb . waitForResponse ( ) ; ClientResponseImpl r = ClientResponseImpl . class . cast ( cb . getResponse ( ) ) ; response . setStatus ( HttpServletResponse . SC_NO_CONTENT ) ; if ( r . getStatus ( ) == ClientResponse . SUCCESS ) { response . getWriter ( ) . print ( buildClientResponse ( jsonp , ClientResponse . SUCCESS , "User Removed." ) ) ; } else { response . getWriter ( ) . print ( HTTPClientInterface . asJsonp ( jsonp , r . toJSONString ( ) ) ) ; } } catch ( Exception ex ) { m_log . error ( "Failed to update role from API" , ex ) ; response . setStatus ( HttpServletResponse . SC_BAD_REQUEST ) ; response . getWriter ( ) . print ( buildClientResponse ( jsonp , ClientResponse . UNEXPECTED_FAILURE , Throwables . getStackTraceAsString ( ex ) ) ) ; } }
Handle DELETE for users