Package zowe.client.sdk.utility
Class UtilRest
- java.lang.Object
-
- zowe.client.sdk.utility.UtilRest
-
public class UtilRest extends Object
Utility Class for Rest related static helper methods.- Version:
- 1.0
- Author:
- Frank Giordano
-
-
Constructor Summary
Constructors Constructor Description UtilRest()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static void
checkHttpErrors(Response response)
Return specialized http error messagestatic Object
getJsonResponseEntity(org.apache.http.HttpResponse httpResponse)
Retrieve response JSON entity content from httpResponse objectstatic Object
getTextResponseEntity(org.apache.http.HttpResponse httpResponse)
Retrieve response text entity content from httpResponse objectstatic boolean
isHttpError(int statusCode)
Checks if statusCode is a valid http code or notstatic boolean
isUrlValid(String url)
Checks if url is a valid http or https url.
-
-
-
Method Detail
-
getJsonResponseEntity
public static Object getJsonResponseEntity(org.apache.http.HttpResponse httpResponse) throws Exception
Retrieve response JSON entity content from httpResponse object- Parameters:
httpResponse
- HttpResponse object- Returns:
- response Json entity content
- Throws:
Exception
- due to extracting entity or parsing entity problem
-
getTextResponseEntity
public static Object getTextResponseEntity(org.apache.http.HttpResponse httpResponse) throws Exception
Retrieve response text entity content from httpResponse object- Parameters:
httpResponse
- HttpResponse object- Returns:
- response text entity content
- Throws:
Exception
- due to extracting entity or parsing entity problem
-
checkHttpErrors
public static void checkHttpErrors(Response response) throws Exception
Return specialized http error message- Parameters:
response
- Response object- Throws:
Exception
- containing specialized http error message
-
isHttpError
public static boolean isHttpError(int statusCode)
Checks if statusCode is a valid http code or not- Parameters:
statusCode
- http code value- Returns:
- boolean value
-
isUrlValid
public static boolean isUrlValid(String url)
Checks if url is a valid http or https url.The method will create a URL object from the specified string representation. A MalformedURLException will be thrown if no protocol is specified, or an unknown protocol is found, or spec is null which will result in a false value to be returned. Then a call the toURI() method is made that throws a URISyntaxException if the URL is not formatted strictly according to RFC 2396 and cannot be converted to a URI which will result in a false value to be returned.
- Parameters:
url
- value- Returns:
- boolean value
-
-