Class EntityExpansionUtil
java.lang.Object
com.atlassian.crowd.plugin.rest.util.EntityExpansionUtil
Utility class for entity expansion.
- Since:
- v2.1
-
Field Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic com.atlassian.plugins.rest.api.expand.parameter.ExpandParameter
getExpandParameter
(javax.servlet.http.HttpServletRequest request) Returns a ExpandParameter representing theexpand
query parameter from an HttpServletRequest.static boolean
shouldExpandField
(Class clazz, String fieldName, com.atlassian.plugins.rest.api.expand.parameter.ExpandParameter expandParameter) Returns whether a field of the specified entity class should be expanded.static boolean
shouldExpandField
(Class clazz, String fieldName, javax.servlet.http.HttpServletRequest request) Returns whether a field of the specified entity class should be expanded.
-
Field Details
-
EXPAND_PARAM
Name of the expand query parameter.- See Also:
-
-
Method Details
-
shouldExpandField
public static boolean shouldExpandField(Class clazz, 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(Class clazz, String fieldName, com.atlassian.plugins.rest.api.expand.parameter.ExpandParameter expandParameter) Returns whether a field of the specified entity class should be expanded. SeeshouldExpandField(Class, String, HttpServletRequest)
to extract the expand query parameter from aHttpServletRequest
.- 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:
IllegalArgumentException
- if the field name could not be found in the class.
-
getExpandParameter
public static com.atlassian.plugins.rest.api.expand.parameter.ExpandParameter getExpandParameter(javax.servlet.http.HttpServletRequest request) Returns a ExpandParameter representing theexpand
query parameter from an HttpServletRequest.- Parameters:
request
- HttpServletRequest.- Returns:
- ExpandParameter representing the
expand
query parameter.
-