com.atlassian.crowd.plugin.rest.util
Class EntityExpansionUtil

java.lang.Object
  extended by com.atlassian.crowd.plugin.rest.util.EntityExpansionUtil

public class EntityExpansionUtil
extends java.lang.Object

Utility class for entity expansion.

Since:
v2.1

Field Summary
static java.lang.String EXPAND_PARAM
          Name of the expand query parameter.
 
Method Summary
static com.atlassian.plugins.rest.common.expand.parameter.ExpandParameter getExpandParameter(javax.servlet.http.HttpServletRequest request)
          Returns a ExpandParameter representing the expand query parameter from an HttpServletRequest.
static boolean shouldExpandField(java.lang.Class clazz, java.lang.String fieldName, com.atlassian.plugins.rest.common.expand.parameter.ExpandParameter expandParameter)
          Returns whether a field of the specified entity class should be expanded.
static boolean shouldExpandField(java.lang.Class clazz, java.lang.String fieldName, javax.servlet.http.HttpServletRequest request)
          Returns whether a field of the specified entity class should be expanded.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

EXPAND_PARAM

public static final java.lang.String EXPAND_PARAM
Name of the expand query parameter.

See Also:
Constant Field Values
Method Detail

shouldExpandField

public static boolean shouldExpandField(java.lang.Class clazz,
                                        java.lang.String fieldName,
                                        javax.servlet.http.HttpServletRequest request)
Returns whether a field of the specified entity class should be expanded.

E.g. a client may perform a request to /user?expand=attributes which instructs the server to expand the attributes field of the user entity.

Parameters:
clazz - the class of the field to check for expansion.
fieldName - name of the field to check for expansion.
request - HttpServletRequest to extract the expand query param from.
Returns:
true if the field should be expanded, otherwise false.

shouldExpandField

public static boolean shouldExpandField(java.lang.Class clazz,
                                        java.lang.String fieldName,
                                        com.atlassian.plugins.rest.common.expand.parameter.ExpandParameter expandParameter)
Returns whether a field of the specified entity class should be expanded.

Parameters:
clazz - the class of the field to check for expansion.
fieldName - name of the field to check for expansion.
expandParameter - ExpandParameter to check for expansion.
Returns:
true if the field should be expanded, otherwise false.
Throws:
java.lang.IllegalArgumentException - if the field name could not be found in the class.
See Also:
#shouldExpandField(Class, String, javax.servlet.http.HttpServletRequest)} to extract the expand query parameter from a HttpServletRequest.

getExpandParameter

public static com.atlassian.plugins.rest.common.expand.parameter.ExpandParameter getExpandParameter(javax.servlet.http.HttpServletRequest request)
Returns a ExpandParameter representing the expand query parameter from an HttpServletRequest.

Parameters:
request - HttpServletRequest.
Returns:
ExpandParameter representing the expand query parameter.


Copyright © 2011 Atlassian. All Rights Reserved.