public void uploadRepository ( String name , File archive ) throws ClientException { HttpPut putMethod = new HttpPut ( baseUri + "/repository/" + encodeURIComponent ( name ) ) ; HttpEntity httpEntity = MultipartEntityBuilder . create ( ) . addBinaryBody ( "file" , archive , ContentType . create ( "application/zip" ) , archive . getName ( ) ) . build ( ) ; putMethod . setEntity ( httpEntity ) ; try { CloseableHttpResponse result = httpClient . execute ( putMethod ) ; try { StatusLine status = result . getStatusLine ( ) ; if ( status . getStatusCode ( ) != HttpStatus . SC_CREATED ) { throw new APICallException ( EntityUtils . toString ( result . getEntity ( ) ) , status . getStatusCode ( ) ) ; } } finally { result . close ( ) ; } } catch ( HttpResponseException e ) { throw new APICallException ( e . getMessage ( ) , e . getStatusCode ( ) ) ; } catch ( IOException e ) { throw new NotAvailableException ( e ) ; } }
Creates or updates repository by the given name