public interface QueryRequest extends Request
There are four types of query request:
QueryFilters
specified using QueryRequest.setQueryFilter(QueryFilter)
QueryRequest.setQueryId(String)
QueryRequest.setQueryExpression(String)
. Note that this type of query
should only be used in very rare cases since it introduces a tight coupling between the application and the
underlying JSON resource. In addition, applications should take care to prevent users from directly accessing this
form of query for security reasons.
In addition to the above mentioned query types queries may also be paged when a page size is found via QueryRequest.getPageSize()
. Paged requests should be used in most cases when an unknown number of query results will be
returned.
Modifier and Type | Field and Description |
---|---|
static String |
FIELD_PAGE_SIZE
The name of the field which contains the page size in the JSON representation.
|
static String |
FIELD_PAGED_RESULTS_COOKIE
The name of the field which contains the paged results cookie in the JSON representation.
|
static String |
FIELD_PAGED_RESULTS_OFFSET
The name of the field which contains the paged results offset in the JSON representation.
|
static String |
FIELD_QUERY_EXPRESSION
The name of the field which contains the query expression in the JSON representation.
|
static String |
FIELD_QUERY_FILTER
The name of the field which contains the query filter in the JSON representation.
|
static String |
FIELD_QUERY_ID
The name of the field which contains the query ID in the JSON representation.
|
static String |
FIELD_SORT_KEYS
The name of the field which contains the sort keys in the JSON representation.
|
static String |
FIELD_TOTAL_PAGED_RESULTS_POLICY
The name of the field which contains the policy used for calculating the total number of paged results.
|
FIELD_ADDITIONAL_PARAMETERS, FIELD_FIELDS, FIELD_RESOURCE_PATH, FIELD_VALUE_ALL
Modifier and Type | Method and Description |
---|---|
<R,P> R |
accept(RequestVisitor<R,P> v,
P p)
Applies a
RequestVisitor to this Request . |
QueryRequest |
addField(JsonPointer... fields)
Adds one or more fields which should be included with each JSON resource returned by this request.
|
QueryRequest |
addField(String... fields)
Adds one or more fields which should be included with each JSON resource returned by this request.
|
QueryRequest |
addSortKey(SortKey... keys)
Adds one or more sort keys which will be used for ordering the JSON resources returned by this query request.
|
QueryRequest |
addSortKey(String... keys)
Adds one or more sort keys which will be used for ordering the JSON resources returned by this query request.
|
String |
getAdditionalParameter(String name)
Returns the additional parameter which should be used to control the behavior of this action request.
|
Map<String,String> |
getAdditionalParameters()
Returns the additional parameters which should be used to control the behavior of this action request.
|
List<JsonPointer> |
getFields()
Returns the list of fields which should be included with each JSON resource returned by this request.
|
String |
getPagedResultsCookie()
Returns the opaque cookie which is used by the resource provider to track its position in the set of query
results.
|
int |
getPagedResultsOffset()
Returns the zero-based index of the first resource which should be included in the query results.
|
int |
getPageSize()
Returns the requested page results page size or
0 if paged results are not required. |
PreferredLocales |
getPreferredLocales()
Get the locale preference for the request.
|
String |
getQueryExpression()
Returns the native query expression which will be used for processing the query request.
|
QueryFilter<JsonPointer> |
getQueryFilter()
Returns the query filter which will be used for selecting which JSON resources will be returned.
|
String |
getQueryId()
Returns the query identifier for pre-defined queries.
|
RequestType |
getRequestType()
Returns the type of this request.
|
String |
getResourcePath()
Returns the non-
null path of the JSON resource to which this request should be targeted. |
ResourcePath |
getResourcePathObject()
Returns the non-
null path of the JSON resource to which this request should be targeted. |
Version |
getResourceVersion()
Gets the requested API version of the resource.
|
List<SortKey> |
getSortKeys()
Returns the sort keys which should be used for ordering the JSON resources returned by this query request.
|
CountPolicy |
getTotalPagedResultsPolicy()
Returns the
CountPolicy used to calculate QueryResponse.getTotalPagedResults() . |
QueryRequest |
setAdditionalParameter(String name,
String value)
Sets an additional parameter which should be used to control the behavior of this action request.
|
QueryRequest |
setPagedResultsCookie(String cookie)
Sets the opaque cookie which is used by the resource provider to track its position in the set of query results.
|
QueryRequest |
setPagedResultsOffset(int offset)
Sets the zero-based index of the first resource which should be included in the query results.
|
QueryRequest |
setPageSize(int size)
Sets the requested page results page size or
0 if paged results are not required. |
QueryRequest |
setPreferredLocales(PreferredLocales preferredLocales)
Set the locale preference for the request.
|
QueryRequest |
setQueryExpression(String expression)
Sets the native query expression which will be used for processing the query request.
|
QueryRequest |
setQueryFilter(QueryFilter<JsonPointer> filter)
Sets the query filter which will be used for selecting which JSON resources will be returned.
|
QueryRequest |
setQueryId(String id)
Sets the query identifier for pre-defined queries.
|
QueryRequest |
setResourcePath(ResourcePath path)
Sets the non-
null path of the JSON resource to which this request should be targeted. |
QueryRequest |
setResourcePath(String path)
Sets the non-
null path of the JSON resource to which this request should be targeted. |
QueryRequest |
setResourceVersion(Version resourceVersion)
Sets the requested API version of the resource.
|
QueryRequest |
setTotalPagedResultsPolicy(CountPolicy policy)
Sets the policy for calculating the total number of paged results.
|
JsonValue |
toJsonValue()
Return a JsonValue representation of this request.
|
static final String FIELD_PAGED_RESULTS_COOKIE
static final String FIELD_PAGED_RESULTS_OFFSET
static final String FIELD_PAGE_SIZE
static final String FIELD_QUERY_EXPRESSION
static final String FIELD_QUERY_FILTER
static final String FIELD_QUERY_ID
static final String FIELD_SORT_KEYS
static final String FIELD_TOTAL_PAGED_RESULTS_POLICY
<R,P> R accept(RequestVisitor<R,P> v, P p)
Request
RequestVisitor
to this Request
.QueryRequest addField(JsonPointer... fields)
Request
QueryRequest addField(String... fields)
Request
QueryRequest addSortKey(SortKey... keys)
keys
- The sort keys which will be used for ordering the JSON resources returned by this query request.UnsupportedOperationException
- If this query request does not permit changes to the sort keys.QueryRequest addSortKey(String... keys)
keys
- The sort keys which will be used for ordering the JSON resources returned by this query request.IllegalArgumentException
- If one or more of the provided sort keys could not be parsed.UnsupportedOperationException
- If this query request does not permit changes to the sort keys.String getAdditionalParameter(String name)
Request
getAdditionalParameter
in interface Request
name
- The name of the additional parameter.Map<String,String> getAdditionalParameters()
Request
getAdditionalParameters
in interface Request
null
).List<JsonPointer> getFields()
Request
NOTE: field filtering alters the structure of a JSON resource and MUST only be performed once while processing a request. It is therefore the responsibility of front-end implementations (e.g. HTTP listeners, Servlets, etc) to perform field filtering. Request handler and resource provider implementations SHOULD NOT filter fields, but MAY choose to optimise their processing in order to return a resource containing only the fields targeted by the field filters.
int getPageSize()
0
if paged results are not required. For all paged result
requests other than the initial request, a cookie should be provided with the query request. See QueryRequest.getPagedResultsCookie()
for more information.0
if paged results are not required.QueryRequest.getPagedResultsCookie()
,
QueryRequest.getPagedResultsOffset()
String getPagedResultsCookie()
The cookie must be null
in the initial query request sent by the client. For subsequent query requests
the client must include the cookie returned with the previous query result, until the resource provider returns a
null
cookie indicating that the final page of results has been returned.
Note: Cookies and offsets are mutually exclusive.
null
if paged results are not requested (when the page size is 0) or if the first page of
results is being requested (when the page size is non-zero).QueryRequest.getPageSize()
,
QueryRequest.getPagedResultsOffset()
int getPagedResultsOffset()
1
will return the second, and so
on ...
Note: Offsets and cookies are mutually exclusive. When a cookie is supplied only the default 0
offset is supported.
Offset must be a zero-based integer denoting the number of records to skip. This is very similar to the
LIMIT
and SKIP
clauses in SQL databases.
QueryRequest.getPageSize()
,
QueryRequest.getPagedResultsCookie()
PreferredLocales getPreferredLocales()
Request
getPreferredLocales
in interface Request
PreferredLocales
instance for the request.String getQueryExpression()
NOTE: the native query expression, query filter, and query ID parameters are mutually exclusive and only one of them may be specified.
null
if
another type of query is to be performed.QueryRequest.getQueryFilter()
,
QueryRequest.getQueryId()
QueryFilter<JsonPointer> getQueryFilter()
NOTE: the native query expression, query filter, and query ID parameters are mutually exclusive and only one of them may be specified.
null
if another type of query is to be performed.QueryRequest.getQueryExpression()
,
QueryRequest.getQueryId()
String getQueryId()
NOTE: the native query expression, query filter, and query ID parameters are mutually exclusive and only one of them may be specified.
null
if a pre-defined query is not to be used,
or null
if another type of query is to be performed.QueryRequest.getQueryExpression()
,
QueryRequest.getQueryFilter()
RequestType getRequestType()
Request
getRequestType
in interface Request
String getResourcePath()
Request
null
path of the JSON resource to which this request should be targeted. The resource
path is relative and never begins or ends with a forward slash, but may be empty.
NOTE: for resource provider implementations the resource path is relative to the current resource being
accessed. See the description of UriRouterContext
for more information.
getResourcePath
in interface Request
null
path of the JSON resource to which this request should be targeted, which may be the
empty string.ResourcePath getResourcePathObject()
Request
null
path of the JSON resource to which this request should be targeted. The resource
path is relative and never begins or ends with a forward slash, but may be empty.
NOTE: for resource provider implementations the resource path is relative to the current resource being
accessed. See the description of UriRouterContext
for more information.
getResourcePathObject
in interface Request
null
path of the JSON resource to which this request should be targeted, which may be the
empty string.Version getResourceVersion()
Request
getResourceVersion
in interface Request
List<SortKey> getSortKeys()
null
).CountPolicy getTotalPagedResultsPolicy()
CountPolicy
used to calculate QueryResponse.getTotalPagedResults()
.QueryResponse.getTotalPagedResults()
QueryRequest setAdditionalParameter(String name, String value) throws BadRequestException
Request
setAdditionalParameter
in interface Request
name
- The name of the additional parameter.value
- The additional parameter's value.BadRequestException
- If this request does not permit the additional parameter to be set.QueryRequest setPageSize(int size)
0
if paged results are not required. For all paged result
requests other than the initial request, a cookie should be provided with the query request. See QueryRequest.setPagedResultsCookie(String)
for more information.size
- The requested page results page size or 0
if paged results are not required.UnsupportedOperationException
- If this query request does not permit changes to the page size.QueryRequest.getPagedResultsCookie()
,
QueryRequest.setPagedResultsOffset(int)
QueryRequest setPagedResultsCookie(String cookie)
The cookie must be null
in the initial query request sent by the client. For subsequent query requests
the client must include the cookie returned with the previous query result, until the resource provider returns a
null
cookie indicating that the final page of results has been returned.
When subsequent paged requests are being made no query parameters may be altered; doing so will result in undefined behavior. The only parameter that may be changed during paged requests is the page size.
cookie
- The opaque cookie which is used by the resource provider to track its position in the set of query
results.UnsupportedOperationException
- If this query request does not permit changes to the paged results cookie.QueryRequest.setPageSize(int)
,
QueryRequest.addSortKey(SortKey...)
,
QueryRequest.addSortKey(String...)
QueryRequest setPagedResultsOffset(int offset)
1
will return the second, and so
on ...
Note: Offsets and cookies are mutually exclusive. When a cookie is supplied only the default 0
offset is supported.
Offset must be a zero-based integer denoting the number of records to skip. This is very similar to the
LIMIT
and SKIP
clauses in SQL databases.
offset
- The index within the result set of the first result which should be returned.UnsupportedOperationException
- If this query request does not permit changes to the paged results offset.QueryRequest.setPageSize(int)
,
QueryRequest.setPagedResultsCookie(String)
QueryRequest setPreferredLocales(PreferredLocales preferredLocales)
Request
setPreferredLocales
in interface Request
preferredLocales
- The PreferredLocales
instance for the request.QueryRequest setQueryExpression(String expression)
NOTE: the native query expression, query filter, and query ID parameters are mutually exclusive and only one of them may be specified.
expression
- The native query expression which will be used for processing the query request, or null
if
another type of query is to be performed.UnsupportedOperationException
- If this query request does not permit changes to the query identifier.QueryRequest.setQueryFilter(QueryFilter)
,
QueryRequest.setQueryId(String)
QueryRequest setQueryFilter(QueryFilter<JsonPointer> filter)
NOTE: the native query expression, query filter, and query ID parameters are mutually exclusive and only one of them may be specified.
filter
- The query filter which will be used for selecting which JSON resources will be returned, or null
if another type of query is to be performed.UnsupportedOperationException
- If this query request does not permit changes to the query filter.QueryRequest.setQueryExpression(String)
,
QueryRequest.setQueryId(String)
QueryRequest setQueryId(String id)
NOTE: the native query expression, query filter, and query ID parameters are mutually exclusive and only one of them may be specified.
id
- The query identifier for pre-defined queries, or null
if another type of query is to be
performed.UnsupportedOperationException
- If this query request does not permit changes to the query identifier.QueryRequest.setQueryExpression(String)
,
QueryRequest.setQueryFilter(QueryFilter)
QueryRequest setResourcePath(ResourcePath path)
Request
null
path of the JSON resource to which this request should be targeted. The resource path
is relative and never begins or ends with a forward slash, but may be empty.
NOTE: for resource provider implementations the resource path is relative to the current resource being
accessed. See the description of UriRouterContext
for more information.
setResourcePath
in interface Request
path
- The non-null
path of the JSON resource to which this request should be targeted, which may be the
empty string.QueryRequest setResourcePath(String path)
Request
null
path of the JSON resource to which this request should be targeted. The resource path
is relative and never begins or ends with a forward slash, but may be empty.
NOTE: for resource provider implementations the resource path is relative to the current resource being
accessed. See the description of UriRouterContext
for more information.
setResourcePath
in interface Request
path
- The non-null
path of the JSON resource to which this request should be targeted, which may be the
empty string. The path should be URL-encoded.QueryRequest setResourceVersion(Version resourceVersion)
Request
setResourceVersion
in interface Request
resourceVersion
- The requested API version of the resource.QueryRequest setTotalPagedResultsPolicy(CountPolicy policy)
CountPolicy.NONE
will be used. This will result in no count being
performed and no overhead incurred.policy
- The policy used to calculate total paged resultsQueryResponse.getTotalPagedResultsPolicy()
,
QueryResponse.getTotalPagedResults()
JsonValue toJsonValue()
Request
toJsonValue
in interface Request
Copyright © 2010-2018, ForgeRock All Rights Reserved.