Class RestUtils


  • public final class RestUtils
    extends Object
    RestUtils is a utility class. All its methods must be declared as static so they can't be overridden.
    • Method Detail

      • executePost

        public static org.springframework.http.ResponseEntity<String> executePost​(String urlString,
                                                                                  String payload)
        Create a new resource by POSTing the given payload to the URL, and returns the response as ResponseEntity.
        Parameters:
        urlString - the URL
        payload - object to post
        Returns:
        See Also:
        RestTemplate.postForEntity(URI, Object, Class), ResponseEntity
      • restExchange

        public static org.springframework.http.ResponseEntity<String> restExchange​(String urlString,
                                                                                   String username,
                                                                                   String password)
        Execute the GET HTTP method to the given URL, writing the given request entity to the request, and returns the response as ResponseEntity.
        Parameters:
        urlString - the URL
        username - the username
        password - the password
        Returns:
        See Also:
        RestTemplate.exchange(String, HttpMethod, HttpEntity, Class, Object...), ResponseEntity
      • getRequestWithHeaders

        public static org.springframework.http.HttpEntity<String> getRequestWithHeaders​(String username,
                                                                                        String password)
        Creates a new HttpHeader and set the Authorization object according to @see getBase64Creds
        Parameters:
        username - the username
        password - the password
        Returns:
        the @see org.springframework.http.HttpEntity
      • getBase64Creds

        public static String getBase64Creds​(String username,
                                            String password)
        Generates a Base64 encoding of username:password string
        Parameters:
        username - the username
        password - the password
        Returns:
        the Base64 encoded string