Interface PlatformConverterService
-
@ProviderType public interface PlatformConverterService
Service that provides common functionality that can be used by any Platform API based HypermediaConverter when serializing resources to Platform API style JSON.
-
-
Field Summary
Fields Modifier and Type Field Description static SortOrder
DEFAULT_SORTORDER
static String
HEADER_LINK
static String
JSON_NAME_CHILDREN
static String
JSON_NAME_HREF
static String
JSON_NAME_LINKS
static String
JSON_NAME_PAGE
static String
PARAM_LIMIT
static String
PARAM_ORDERBY
static String
PARAM_SORTORDER
static String
PARAM_START
static String
PROP_COUNT
static String
PROP_NAME
static String
PROP_NEXT
static String
PROP_PAGE
static String
PROP_PROPERTY
static String
PROP_TYPE
static String
REL_ADOBECLOUD
static String
REL_ADOBECLOUD_DELETE
static String
REL_ADOBECLOUD_DIRECTORY
static String
REL_COLLECTION
static String
REL_LATEST_VERSION
static String
REL_PARENT
static String
REL_SELF
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description JSONArray
buildChildren(ConverterContext context, ModelDescription description, HypermediaConverter converter)
Build the children JSONArray that can be added to the response body.JSONObject
buildLinksObject(ConverterContext context, Resource resource, ModelDescription description)
Builds the links JSONObject that can be added to the response body.JSONObject
buildPageObject(ConverterContext context, String nextValue, String resourcePath, String category, int count)
Build the page JSONObject that can be added to the response body.Map<String,Object>
buildProps(Resource resource, ModelDescription description, ApiProperty.SCOPE scope)
Build a map of the properties to be serialized into the response body, filtered by the provided scope.String
buildURL(ConverterContext context, String resourcePath)
Builds a URL for a resource that can be used in the response.String
getApiPrefix(ConverterContext context, String category)
Get the API prefix that can be used when building URLs for API managed resources.List<OrderByDetails>
getOrderBy(HttpServletRequest request)
Get the ordering parameters from the request that will be used to build a paginated child entity list.int
getPaginationLimitValue(HttpServletRequest request)
Get the pagination limit value that will be used to build a paginated child entity list.String
getPaginationStartValue(HttpServletRequest request)
Get the pagination start value that will be used to build a paginated child entity list.void
populateHeaders(ConverterResponseBuilder builder, ModelDescription description)
Builds the response headers as defined in the model using the ApiHeader annotations and sets them in the response builder.void
populateLinkHeader(ConverterResponseBuilder builder, ConverterContext context, Resource resource, ModelDescription description, ApiLink.SCOPE scope)
Builds the link header for the response based on the ApiHeader annotations in the model, filtered by the scope parameter supplied.
-
-
-
Field Detail
-
REL_ADOBECLOUD
static final String REL_ADOBECLOUD
- See Also:
- Constant Field Values
-
REL_ADOBECLOUD_DIRECTORY
static final String REL_ADOBECLOUD_DIRECTORY
- See Also:
- Constant Field Values
-
REL_ADOBECLOUD_DELETE
static final String REL_ADOBECLOUD_DELETE
- See Also:
- Constant Field Values
-
REL_SELF
static final String REL_SELF
- See Also:
- Constant Field Values
-
REL_PARENT
static final String REL_PARENT
- See Also:
- Constant Field Values
-
REL_LATEST_VERSION
static final String REL_LATEST_VERSION
- See Also:
- Constant Field Values
-
REL_COLLECTION
static final String REL_COLLECTION
- See Also:
- Constant Field Values
-
HEADER_LINK
static final String HEADER_LINK
- See Also:
- Constant Field Values
-
PARAM_START
static final String PARAM_START
- See Also:
- Constant Field Values
-
PARAM_LIMIT
static final String PARAM_LIMIT
- See Also:
- Constant Field Values
-
PARAM_ORDERBY
static final String PARAM_ORDERBY
- See Also:
- Constant Field Values
-
PARAM_SORTORDER
static final String PARAM_SORTORDER
- See Also:
- Constant Field Values
-
PROP_NEXT
static final String PROP_NEXT
- See Also:
- Constant Field Values
-
PROP_PAGE
static final String PROP_PAGE
- See Also:
- Constant Field Values
-
PROP_PROPERTY
static final String PROP_PROPERTY
- See Also:
- Constant Field Values
-
PROP_TYPE
static final String PROP_TYPE
- See Also:
- Constant Field Values
-
PROP_COUNT
static final String PROP_COUNT
- See Also:
- Constant Field Values
-
PROP_NAME
static final String PROP_NAME
- See Also:
- Constant Field Values
-
JSON_NAME_PAGE
static final String JSON_NAME_PAGE
- See Also:
- Constant Field Values
-
JSON_NAME_LINKS
static final String JSON_NAME_LINKS
- See Also:
- Constant Field Values
-
JSON_NAME_CHILDREN
static final String JSON_NAME_CHILDREN
- See Also:
- Constant Field Values
-
JSON_NAME_HREF
static final String JSON_NAME_HREF
- See Also:
- Constant Field Values
-
DEFAULT_SORTORDER
static final SortOrder DEFAULT_SORTORDER
-
-
Method Detail
-
populateHeaders
void populateHeaders(ConverterResponseBuilder builder, ModelDescription description)
Builds the response headers as defined in the model using the ApiHeader annotations and sets them in the response builder.- Parameters:
builder
- The ConverterResponseBuilder responsible for building the response.description
- The metadata description of the model.
-
populateLinkHeader
void populateLinkHeader(ConverterResponseBuilder builder, ConverterContext context, Resource resource, ModelDescription description, ApiLink.SCOPE scope) throws URISyntaxException, UnsupportedEncodingException
Builds the link header for the response based on the ApiHeader annotations in the model, filtered by the scope parameter supplied.- Parameters:
builder
- The ConverterResponseBuilder responsible for building the response.context
- The ConverterContext providing information about the request.resource
- The resource being serialized.description
- The metadata description of the model.scope
- The scope a link should satisfy in order to be serialized into the link header.- Throws:
UnsupportedEncodingException
- If encoding is not supported.URISyntaxException
-
buildLinksObject
@Nonnull JSONObject buildLinksObject(ConverterContext context, Resource resource, ModelDescription description) throws JSONException, URISyntaxException, UnsupportedEncodingException
Builds the links JSONObject that can be added to the response body.- Parameters:
context
- The ConverterContext providing information about the request.resource
- The resource being serialized.description
- The metadata description of the model.- Returns:
- The JSONObject that is the links object.
- Throws:
JSONException
- If an error occurs when creating the links object.URISyntaxException
- If an error occurs building the URL.UnsupportedEncodingException
- If encoding is not supported.
-
buildProps
@Nonnull Map<String,Object> buildProps(Resource resource, ModelDescription description, ApiProperty.SCOPE scope)
Build a map of the properties to be serialized into the response body, filtered by the provided scope.- Parameters:
resource
- The resource being serialized.description
- The metadata description of the model.scope
- The scope a property should satisfy in order to be serialized into the Map.- Returns:
- The Map of properties to be serialized.
-
buildChildren
@Nonnull JSONArray buildChildren(ConverterContext context, ModelDescription description, HypermediaConverter converter)
Build the children JSONArray that can be added to the response body.- Parameters:
context
- The ConverterContext providing information about the request.description
- The metadata description of the model.converter
- The HypermediaConverter to be used to render the children resources as sub entities.- Returns:
- The JSONArray that represents the children to be serialized.
-
buildPageObject
@CheckForNull JSONObject buildPageObject(ConverterContext context, String nextValue, String resourcePath, String category, int count) throws JSONException
Build the page JSONObject that can be added to the response body.- Parameters:
context
- The ConverterContext providing information about the request.nextValue
- The value to be used to get the next page.resourcePath
- The path to the resource.category
- The API category.count
- The number of resources contained in the children array.- Returns:
- The JSONObject that is the page object.
- Throws:
JSONException
- If an error occurs when creating the JSONObject.
-
buildURL
@Nonnull String buildURL(ConverterContext context, String resourcePath) throws URISyntaxException, UnsupportedEncodingException
Builds a URL for a resource that can be used in the response.- Parameters:
context
- The ConverterContext providing information about the request.resourcePath
- The path to the resource.- Returns:
- The URL to the resource.
- Throws:
URISyntaxException
- If an error occurs building the URL.UnsupportedEncodingException
- If encoding is not supported.
-
getApiPrefix
@Nonnull String getApiPrefix(ConverterContext context, String category)
Get the API prefix that can be used when building URLs for API managed resources.- Parameters:
context
- The ConverterContext providing information about the request.category
- The API category the resource is being managed under.- Returns:
- The API prefix string.
-
getPaginationStartValue
@CheckForNull String getPaginationStartValue(HttpServletRequest request)
Get the pagination start value that will be used to build a paginated child entity list.- Parameters:
request
- The HTTPServletRequest.- Returns:
- The pagination start value.
-
getPaginationLimitValue
int getPaginationLimitValue(HttpServletRequest request)
Get the pagination limit value that will be used to build a paginated child entity list.- Parameters:
request
- The HTTPServletRequest.- Returns:
- The pagination limit value.
-
getOrderBy
@Nonnull List<OrderByDetails> getOrderBy(HttpServletRequest request)
Get the ordering parameters from the request that will be used to build a paginated child entity list.- Parameters:
request
- The HTTPServletRequest.- Returns:
- The pagination ordering parameters.
-
-