public void postModule ( final Module module , final String user , final String password ) throws GrapesCommunicationException , AuthenticationException { final Client client = getClient ( user , password ) ; final WebResource resource = client . resource ( serverURL ) . path ( RequestUtils . moduleResourcePath ( ) ) ; final ClientResponse response = resource . type ( MediaType . APPLICATION_JSON ) . post ( ClientResponse . class , module ) ; client . destroy ( ) ; if ( ClientResponse . Status . CREATED . getStatusCode ( ) != response . getStatus ( ) ) { final String message = "Failed to POST module" ; if ( LOG . isErrorEnabled ( ) ) { LOG . error ( String . format ( HTTP_STATUS_TEMPLATE_MSG , message , response . getStatus ( ) ) ) ; } throw new GrapesCommunicationException ( message , response . getStatus ( ) ) ; } }
Post a module to the server