@ Override public ArtifactoryResponse restCall ( ArtifactoryRequest artifactoryRequest ) throws IOException { HttpRequestBase httpRequest ; String requestPath = "/" + artifactoryRequest . getApiUrl ( ) ; ContentType contentType = Util . getContentType ( artifactoryRequest . getRequestType ( ) ) ; String queryPath = "" ; if ( ! artifactoryRequest . getQueryParams ( ) . isEmpty ( ) ) { queryPath = Util . getQueryPath ( "?" , artifactoryRequest . getQueryParams ( ) ) ; } switch ( artifactoryRequest . getMethod ( ) ) { case GET : httpRequest = new HttpGet ( ) ; break ; case POST : httpRequest = new HttpPost ( ) ; setEntity ( ( HttpPost ) httpRequest , artifactoryRequest . getBody ( ) , contentType ) ; break ; case PUT : httpRequest = new HttpPut ( ) ; setEntity ( ( HttpPut ) httpRequest , artifactoryRequest . getBody ( ) , contentType ) ; break ; case DELETE : httpRequest = new HttpDelete ( ) ; break ; case PATCH : httpRequest = new HttpPatch ( ) ; setEntity ( ( HttpPatch ) httpRequest , artifactoryRequest . getBody ( ) , contentType ) ; break ; case OPTIONS : httpRequest = new HttpOptions ( ) ; break ; default : throw new IllegalArgumentException ( "Unsupported request method." ) ; } httpRequest . setURI ( URI . create ( url + requestPath + queryPath ) ) ; addAccessTokenHeaderIfNeeded ( httpRequest ) ; if ( contentType != null ) { httpRequest . setHeader ( "Content-type" , contentType . getMimeType ( ) ) ; } Map < String , String > headers = artifactoryRequest . getHeaders ( ) ; for ( String key : headers . keySet ( ) ) { httpRequest . setHeader ( key , headers . get ( key ) ) ; } HttpResponse httpResponse = httpClient . execute ( httpRequest ) ; return new ArtifactoryResponseImpl ( httpResponse ) ; }
Create a REST call to artifactory with a generic request