public void uploadZippedApplicationTemplate ( File applicationFile ) throws ManagementWsException , IOException { if ( applicationFile == null || ! applicationFile . exists ( ) || ! applicationFile . isFile ( ) ) throw new IOException ( "Expected an existing file as parameter." ) ; this . logger . finer ( "Loading an application from " + applicationFile . getAbsolutePath ( ) + "..." ) ; FormDataMultiPart part = new FormDataMultiPart ( ) ; part . bodyPart ( new FileDataBodyPart ( "file" , applicationFile , MediaType . APPLICATION_OCTET_STREAM_TYPE ) ) ; WebResource path = this . resource . path ( UrlConstants . APPLICATIONS ) . path ( "templates" ) ; ClientResponse response = this . wsClient . createBuilder ( path ) . type ( MediaType . MULTIPART_FORM_DATA_TYPE ) . post ( ClientResponse . class , part ) ; if ( Family . SUCCESSFUL != response . getStatusInfo ( ) . getFamily ( ) ) { String value = response . getEntity ( String . class ) ; this . logger . finer ( response . getStatusInfo ( ) + ": " + value ) ; throw new ManagementWsException ( response . getStatusInfo ( ) . getStatusCode ( ) , value ) ; } this . logger . finer ( String . valueOf ( response . getStatusInfo ( ) ) ) ; }
Uploads a ZIP file and loads its application template .