org.glassfish.admingui.common.util
Class RestUtil

java.lang.Object
  extended by org.glassfish.admingui.common.util.RestUtil

public class RestUtil
extends Object

Author:
anilam

Field Summary
static String FORM_ENCODING
           
static String GUI_TOKEN_FOR_EMPTY_PROPERTY_VALUE
           
static String RESPONSE_TYPE
           
 
Constructor Summary
RestUtil()
           
 
Method Summary
static String appendEncodedSegment(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 javax.ws.rs.core.MultivaluedMap buildMultivalueMap(Map<String,Object> payload)
           
protected static Map buildUseOnlyAttrMap(Map<String,Object> attrs, List<String> onlyUseAttrs)
           
static void checkStatusForSuccess(com.sun.jersey.api.client.ClientResponse cr)
           
protected static Map<String,Object> convertNullValuesToFalse(Map<String,Object> attrs, List<String> convertToFalse)
           
static RestResponse delete(String address, Map<String,Object> payload)
           
static Boolean doesProxyExist(String endpoint)
           
protected static Map<String,Object> fixKeyNames(Map<String,Object> map)
           
static RestResponse get(String address)
           
static RestResponse get(String address, Map<String,Object> payload)
           
static Map getAttributesMap(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 List<String> getChildResourceList(String document)
           
static Map<String,Object> getEntityAttrs(String endpoint, String key)
           
static com.sun.jersey.api.client.Client getJerseyClient()
           
static String getPropValue(String endpoint, String propName, com.sun.jsftemplating.layout.descriptors.handler.HandlerContext handlerCtx)
           
static com.sun.jersey.api.client.ClientResponse getRequestFromServlet(javax.servlet.http.HttpServletRequest request, String endpoint, Map<String,Object> attrs)
           
static void getRestRequestFromServlet(javax.servlet.http.HttpServletRequest request, String endpoint, Map<String,Object> attrs, boolean quiet, boolean throwException)
           
static boolean hasWarning(Map responseMap)
           
static void initialize(com.sun.jersey.api.client.Client client)
           
static Map maskOffPassword(Map<String,Object> attrs)
           
static RestResponse options(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 RestResponse post(String address, Map<String,Object> payload)
           
static RestResponse post(String address, Object payload, String contentType)
           
static void postRestRequestFromServlet(javax.servlet.http.HttpServletRequest request, String endpoint, Map<String,Object> attrs, boolean quiet, boolean throwException)
           
static RestResponse put(String address, Map<String,Object> payload)
           
protected static void removeSpecifiedAttrs(Map<String,Object> attrs, List<String> removeList)
           
static String resolveToken(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 RestResponse sendCreateRequest(String endpoint, Map<String,Object> attrs, List<String> skipAttrs, List<String> onlyUseAttrs, List<String> convertToFalse)
           
static RestResponse sendUpdateRequest(String endpoint, Map<String,Object> attrs, List<String> skipAttrs, List<String> onlyUseAttrs, List<String> convertToFalse)
           
static String upperCaseFirstLetter(String string)
          Converts the first letter of the given string to Uppercase.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

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
Constructor Detail

RestUtil

public RestUtil()
Method Detail

getJerseyClient

public static com.sun.jersey.api.client.Client getJerseyClient()

getPropValue

public static String getPropValue(String endpoint,
                                  String propName,
                                  com.sun.jsftemplating.layout.descriptors.handler.HandlerContext handlerCtx)

resolveToken

public static String resolveToken(String endpoint,
                                  String token)

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)

maskOffPassword

public static Map maskOffPassword(Map<String,Object> attrs)

buildDefaultValueMap

public static Map<String,String> buildDefaultValueMap(String endpoint)
                                               throws ParserConfigurationException,
                                                      SAXException,
                                                      IOException
Throws:
ParserConfigurationException
SAXException
IOException

getAttributesMap

public static Map getAttributesMap(String endpoint)

getEntityAttrs

public static Map<String,Object> getEntityAttrs(String endpoint,
                                                String key)

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 javax.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)

fixKeyNames

protected static Map<String,Object> fixKeyNames(Map<String,Object> map)

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
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

doesProxyExist

public static Boolean doesProxyExist(String endpoint)

getRequestFromServlet

public static com.sun.jersey.api.client.ClientResponse getRequestFromServlet(javax.servlet.http.HttpServletRequest request,
                                                                             String endpoint,
                                                                             Map<String,Object> attrs)

getRestRequestFromServlet

public static void getRestRequestFromServlet(javax.servlet.http.HttpServletRequest request,
                                             String endpoint,
                                             Map<String,Object> attrs,
                                             boolean quiet,
                                             boolean throwException)

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(com.sun.jersey.api.client.ClientResponse cr)

initialize

public static void initialize(com.sun.jersey.api.client.Client client)

postRestRequestFromServlet

public static void postRestRequestFromServlet(javax.servlet.http.HttpServletRequest request,
                                              String endpoint,
                                              Map<String,Object> attrs,
                                              boolean quiet,
                                              boolean throwException)


Copyright © 2012. All Rights Reserved.