Class RestUtil
- java.lang.Object
-
- org.glassfish.admingui.common.util.RestUtil
-
public class RestUtil extends Object
- Author:
- anilam
-
-
Field Summary
Fields Modifier and Type Field Description static StringFORM_ENCODINGstatic StringGUI_TOKEN_FOR_EMPTY_PROPERTY_VALUEstatic StringRESPONSE_TYPEstatic StringREST_TOKEN_COOKIE
-
Constructor Summary
Constructors Constructor Description RestUtil()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static StringappendEncodedSegment(String base, String segment)This method will encode append segment to base, encoding it so that a correct URL is returned.static List<Map>buildChildEntityList(String parent, String childType, List skipList, List includeList, String id)Given the parent URL and the desired childType, this method will build a List of Maps that contains each child entities values.static Map<String,String>buildDefaultValueMap(String endpoint)protected static jakarta.ws.rs.core.MultivaluedMapbuildMultivalueMap(Map<String,Object> payload)protected static MapbuildUseOnlyAttrMap(Map<String,Object> attrs, List<String> onlyUseAttrs)static voidcheckStatusForSuccess(jakarta.ws.rs.core.Response cr)protected static Map<String,Object>convertNullValuesToFalse(Map<String,Object> attrs, List<String> convertToFalse)static RestResponsedelete(String address, Map<String,Object> payload)static BooleandoesProxyExist(String endpoint)protected static Map<String,Object>fixKeyNames(Map<String,Object> map)static RestResponseget(String address)static RestResponseget(String address, Map<String,Object> payload)static MapgetAttributesMap(String endpoint)static List<String>getChildList(String endpoint)Given the parent URL and the desired childType, this method will build a List of Strings that contains child entity names.static Map<String,String>getChildMap(String endpoint)static Map<String,String>getChildMap(String endpoint, Map attrs)static List<String>getChildResourceList(String document)static Map<String,Object>getEntityAttrs(String endpoint, String key)static jakarta.ws.rs.client.ClientgetJerseyClient()static StringgetPropValue(String endpoint, String propName, com.sun.jsftemplating.layout.descriptors.handler.HandlerContext handlerCtx)static jakarta.ws.rs.core.ResponsegetRequestFromServlet(jakarta.servlet.http.HttpServletRequest request, String endpoint, Map<String,Object> attrs)static voidgetRestRequestFromServlet(jakarta.servlet.http.HttpServletRequest request, String endpoint, Map<String,Object> attrs, boolean quiet, boolean throwException)static StringgetRestToken()This method returns the value of the REST token if it is successfully set in session scope.static booleanhasWarning(Map responseMap)static jakarta.ws.rs.client.ClientBuilderinitialize(jakarta.ws.rs.client.ClientBuilder clientBuilder)static MapmaskOffPassword(Map<String,Object> attrs)static RestResponseoptions(String address, String responseType)static Map<String,Object>parseResponse(RestResponse response, com.sun.jsftemplating.layout.descriptors.handler.HandlerContext handlerCtx, String endpoint, Object attrs, boolean quiet, boolean throwException)static RestResponsepost(String address, Object payload, String contentType)static RestResponsepost(String address, Map<String,Object> payload)static voidpostRestRequestFromServlet(jakarta.servlet.http.HttpServletRequest request, String endpoint, Map<String,Object> attrs, boolean quiet, boolean throwException)static RestResponseput(String address, Map<String,Object> payload)protected static voidremoveSpecifiedAttrs(Map<String,Object> attrs, List<String> removeList)static StringresolveToken(String endpoint, String token)static Map<String,Object>restRequest(String endpoint, Map<String,Object> attrs, String method, com.sun.jsftemplating.layout.descriptors.handler.HandlerContext handlerCtx, boolean quiet)static Map<String,Object>restRequest(String endpoint, Map<String,Object> attrs, String method, com.sun.jsftemplating.layout.descriptors.handler.HandlerContext handlerCtx, boolean quiet, boolean throwException)static RestResponsesendCreateRequest(String endpoint, Map<String,Object> attrs, List<String> skipAttrs, List<String> onlyUseAttrs, List<String> convertToFalse)static RestResponsesendUpdateRequest(String endpoint, Map<String,Object> attrs, List<String> skipAttrs, List<String> onlyUseAttrs, List<String> convertToFalse)static jakarta.ws.rs.client.WebTargettargetWithQueryParams(jakarta.ws.rs.client.WebTarget target, Map<String,Object> paramMap)static StringupperCaseFirstLetter(String string)Converts the first letter of the given string to Uppercase.
-
-
-
Field Detail
-
FORM_ENCODING
public static final String FORM_ENCODING
- See Also:
- Constant Field Values
-
RESPONSE_TYPE
public static final String RESPONSE_TYPE
- See Also:
- Constant Field Values
-
GUI_TOKEN_FOR_EMPTY_PROPERTY_VALUE
public static final String GUI_TOKEN_FOR_EMPTY_PROPERTY_VALUE
- See Also:
- Constant Field Values
-
REST_TOKEN_COOKIE
public static final String REST_TOKEN_COOKIE
- See Also:
- Constant Field Values
-
-
Method Detail
-
getJerseyClient
public static jakarta.ws.rs.client.Client getJerseyClient()
-
getPropValue
public static String getPropValue(String endpoint, String propName, com.sun.jsftemplating.layout.descriptors.handler.HandlerContext handlerCtx)
-
restRequest
public static Map<String,Object> restRequest(String endpoint, Map<String,Object> attrs, String method, com.sun.jsftemplating.layout.descriptors.handler.HandlerContext handlerCtx, boolean quiet)
-
restRequest
public static Map<String,Object> restRequest(String endpoint, Map<String,Object> attrs, String method, com.sun.jsftemplating.layout.descriptors.handler.HandlerContext handlerCtx, boolean quiet, boolean throwException)
-
buildDefaultValueMap
public static Map<String,String> buildDefaultValueMap(String endpoint) throws ParserConfigurationException, SAXException, IOException
-
parseResponse
public static Map<String,Object> parseResponse(RestResponse response, com.sun.jsftemplating.layout.descriptors.handler.HandlerContext handlerCtx, String endpoint, Object attrs, boolean quiet, boolean throwException)
-
hasWarning
public static boolean hasWarning(Map responseMap)
-
appendEncodedSegment
public static String appendEncodedSegment(String base, String segment)
This method will encode append segment to base, encoding it so that a correct URL is returned.- Parameters:
base-segment-- Returns:
-
buildMultivalueMap
protected static jakarta.ws.rs.core.MultivaluedMap buildMultivalueMap(Map<String,Object> payload)
-
sendCreateRequest
public static RestResponse sendCreateRequest(String endpoint, Map<String,Object> attrs, List<String> skipAttrs, List<String> onlyUseAttrs, List<String> convertToFalse)
-
sendUpdateRequest
public static RestResponse sendUpdateRequest(String endpoint, Map<String,Object> attrs, List<String> skipAttrs, List<String> onlyUseAttrs, List<String> convertToFalse)
-
removeSpecifiedAttrs
protected static void removeSpecifiedAttrs(Map<String,Object> attrs, List<String> removeList)
-
buildUseOnlyAttrMap
protected static Map buildUseOnlyAttrMap(Map<String,Object> attrs, List<String> onlyUseAttrs)
-
convertNullValuesToFalse
protected static Map<String,Object> convertNullValuesToFalse(Map<String,Object> attrs, List<String> convertToFalse)
-
upperCaseFirstLetter
public static String upperCaseFirstLetter(String string)
Converts the first letter of the given string to Uppercase.- Parameters:
string- the input string- Returns:
- the string with the Uppercase first letter
-
getChildResourceList
public static List<String> getChildResourceList(String document) throws SAXException, IOException, ParserConfigurationException
-
buildChildEntityList
public static List<Map> buildChildEntityList(String parent, String childType, List skipList, List includeList, String id) throws Exception
Given the parent URL and the desired childType, this method will build a List of Maps that contains each child entities values. In addition to the entity values, each row will have a field, 'selected', set to false, as well as the URL encoded entity name ('encodedName').- Parameters:
parent-childType-skipList-- Returns:
- Throws:
Exception
-
getChildList
public static List<String> getChildList(String endpoint) throws Exception
Given the parent URL and the desired childType, this method will build a List of Strings that contains child entity names.- Parameters:
endpoint-- Returns:
- Throws:
Exception
-
getChildMap
public static Map<String,String> getChildMap(String endpoint) throws Exception
- Throws:
Exception
-
getChildMap
public static Map<String,String> getChildMap(String endpoint, Map attrs) throws Exception
- Throws:
Exception
-
getRestToken
public static String getRestToken()
This method returns the value of the REST token if it is successfully set in session scope.
-
getRequestFromServlet
public static jakarta.ws.rs.core.Response getRequestFromServlet(jakarta.servlet.http.HttpServletRequest request, String endpoint, Map<String,Object> attrs)
-
getRestRequestFromServlet
public static void getRestRequestFromServlet(jakarta.servlet.http.HttpServletRequest request, String endpoint, Map<String,Object> attrs, boolean quiet, boolean throwException)
-
targetWithQueryParams
public static jakarta.ws.rs.client.WebTarget targetWithQueryParams(jakarta.ws.rs.client.WebTarget target, Map<String,Object> paramMap)
-
get
public static RestResponse get(String address)
-
get
public static RestResponse get(String address, Map<String,Object> payload)
-
post
public static RestResponse post(String address, Object payload, String contentType)
-
post
public static RestResponse post(String address, Map<String,Object> payload)
-
put
public static RestResponse put(String address, Map<String,Object> payload)
-
delete
public static RestResponse delete(String address, Map<String,Object> payload)
-
options
public static RestResponse options(String address, String responseType)
-
checkStatusForSuccess
public static void checkStatusForSuccess(jakarta.ws.rs.core.Response cr)
-
initialize
public static jakarta.ws.rs.client.ClientBuilder initialize(jakarta.ws.rs.client.ClientBuilder clientBuilder)
-
-