1818import com .fasterxml .jackson .databind .JsonNode ;
1919import com .fasterxml .jackson .databind .ObjectMapper ;
2020import org .apache .commons .io .IOUtils ;
21- import org .apache .http .Header ;
22- import org .apache .http .HttpEntity ;
23- import org .apache .http .HttpResponse ;
24- import org .apache .http .NameValuePair ;
25- import org .apache .http .client .entity .UrlEncodedFormEntity ;
26- import org .apache .http .client .methods .CloseableHttpResponse ;
27- import org .apache .http .client .utils .URIBuilder ;
28- import org .apache .http .entity .ContentType ;
29- import org .apache .http .entity .mime .MultipartEntityBuilder ;
30- import org .apache .http .message .BasicNameValuePair ;
31- import org .apache .http .util .EntityUtils ;
21+ import org .apache .hc .core5 .http .Header ;
22+ import org .apache .hc .core5 .http .HttpEntity ;
23+ import org .apache .hc .core5 .http .HttpResponse ;
24+ import org .apache .hc .core5 .http .NameValuePair ;
25+ import org .apache .hc .client5 .http .entity .UrlEncodedFormEntity ;
26+ import org .apache .hc .client5 .http .impl .classic .CloseableHttpResponse ;
27+ import org .apache .hc .core5 .net .URIBuilder ;
28+ import org .apache .hc .core5 .http .ContentType ;
29+ import org .apache .hc .client5 .http .entity .mime .MultipartEntityBuilder ;
30+ import org .apache .hc .core5 .http .message .BasicNameValuePair ;
31+ import org .apache .hc .core5 .http .io .entity .EntityUtils ;
32+ import org .apache .hc .core5 .http .ParseException ;
3233import org .ehcache .Cache ;
3334import org .ehcache .CacheManager ;
3435import org .ehcache .StateTransitionException ;
@@ -231,7 +232,7 @@ public void loginToAPIManager() throws AppException {
231232 User user = getCurrentUser ();
232233 String role = getHigherRole (user );
233234 assignRoles (role );
234- } catch (IOException | URISyntaxException e ) {
235+ } catch (IOException | URISyntaxException | ParseException e ) {
235236 throw new AppException ("Can't login to API-Manager" , ErrorCode .API_MANAGER_COMMUNICATION , e );
236237 } catch (InterruptedException e ) {
237238 Thread .currentThread ().interrupt ();
@@ -294,7 +295,7 @@ public void logoutFromAPIManager() throws AppException {
294295 URI uri = new URIBuilder (cmd .getAPIManagerURL ()).setPath (cmd .getApiBasepath () + "/login" ).build ();
295296 DELRequest logoutRequest = new DELRequest (uri );
296297 try (CloseableHttpResponse httpResponse = (CloseableHttpResponse ) logoutRequest .execute ()) {
297- int statusCode = httpResponse .getStatusLine (). getStatusCode ();
298+ int statusCode = httpResponse .getCode ();
298299 if (statusCode != 204 ) {
299300 String response = EntityUtils .toString (httpResponse .getEntity ());
300301 LOG .warn ("Logout failed with statusCode: {} Got response: {}" , statusCode , response );
@@ -313,7 +314,7 @@ public static User getCurrentUser() throws AppException {
313314 try (CloseableHttpResponse httpResponse = (CloseableHttpResponse ) currentUserRequest .execute ()) {
314315 getCsrfToken (httpResponse );
315316 String currentUser = EntityUtils .toString (httpResponse .getEntity ());
316- int statusCode = httpResponse .getStatusLine (). getStatusCode ();
317+ int statusCode = httpResponse .getCode ();
317318 if (statusCode != 200 ) {
318319 throw new AppException ("Status-Code: " + statusCode + ", Can't get current-user for user '" + currentUser + "'" ,
319320 ErrorCode .API_MANAGER_COMMUNICATION );
@@ -332,7 +333,7 @@ public static User getCurrentUser() throws AppException {
332333 }
333334
334335 private static void getCsrfToken (HttpResponse response ) throws AppException {
335- for (Header header : response .getAllHeaders ()) {
336+ for (Header header : response .getHeaders ()) {
336337 if (header .getName ().equalsIgnoreCase ("csrf-token" )) {
337338 APIMHttpClient .getInstance ().setCsrfToken (header .getValue ());
338339 break ;
@@ -532,7 +533,7 @@ public static Image getImageFromAPIM(URI uri, String baseFilename) throws AppExc
532533 try {
533534 RestAPICall getRequest = new GETRequest (uri );
534535 try (CloseableHttpResponse httpResponse = (CloseableHttpResponse ) getRequest .execute ()) {
535- int statusCode = httpResponse .getStatusLine (). getStatusCode ();
536+ int statusCode = httpResponse .getCode ();
536537 if (statusCode == 404 ) return null ; // No Image found
537538 if (statusCode != 200 ) {
538539 String response = EntityUtils .toString (httpResponse .getEntity ());
@@ -583,7 +584,7 @@ public static String getCertInfo(InputStream certificate, String password, CaCer
583584 .build ();
584585 POSTRequest postRequest = new POSTRequest (entity , uri );
585586 try (CloseableHttpResponse httpResponse = (CloseableHttpResponse ) postRequest .execute ()) {
586- int statusCode = httpResponse .getStatusLine (). getStatusCode ();
587+ int statusCode = httpResponse .getCode ();
587588 String response = EntityUtils .toString (httpResponse .getEntity ());
588589 if (statusCode != 200 ) {
589590 if (response != null && response .contains ("Bad password" )) {
@@ -608,7 +609,7 @@ public List<CaCert> getCertInfoFromUrl(String url) throws AppException {
608609 params .add (new BasicNameValuePair ("outbound" , "true" ));
609610 POSTRequest postRequest = new POSTRequest (new UrlEncodedFormEntity (params ), uri );
610611 try (CloseableHttpResponse httpResponse = (CloseableHttpResponse ) postRequest .execute ()) {
611- int statusCode = httpResponse .getStatusLine (). getStatusCode ();
612+ int statusCode = httpResponse .getCode ();
612613 if (statusCode != 200 ) {
613614 String response = EntityUtils .toString (httpResponse .getEntity ());
614615 throw new AppException ("API-Manager failed to read certificate information from URL. Got response: '" + response + "'" , ErrorCode .API_MANAGER_COMMUNICATION );
0 commit comments