Package com.emc.documentum.rest.context
Class ResourceUriBuilder
java.lang.Object
com.emc.documentum.rest.context.ResourceUriBuilder
Builder to build the URI based on a given resource or a custom URI template. The methods
onResource(Class)
and onResource(String)
are used to build URIs from a given resource; and the method onTemplate(String)
is used to build URIs from a give YAML URI template. These methods can not be called simultaneously on a single builder
instance.-
Field Summary
-
Method Summary
Modifier and TypeMethodDescriptionasTemplate
(String... templateParams) Force this resource URI to be normalized as an URI template.Specify the base URI for the builder when required.build()
Build the URI for the resource.Specify the extension for the builder when required.protected String
protected String
protected String
Resource URI is bound with controller.static ResourceUriBuilder
onResource
(Class<?> controller) Create the resource URI builder from a resource controller.static ResourceUriBuilder
onResource
(String resource) Create the resource URI builder from a resource.static ResourceUriBuilder
onTemplate
(String templateName) Create the resource URI builder from a custom URI template in YAML.pathVariable
(boolean safeEncoding, String pathVariable) Specify the path variable for the given resource URI template.pathVariable
(String pathVariable) Specify the path variable for the given resource URI template.pathVariables
(String... pathVariables) Specify the path variable values for the given resource URI template.queryParam
(String key, Object value) Specify the single query parameter for the resource URI.queryParams
(Map<String, String> parameters) Specify the query queryParams for the resource URI.relative()
Whether force to make relative URI.repository
(String repository) Specify the repository name for the builder when required.Specify the base URI information, including base URI and format extenstion.validate
(boolean validate) Whether validate the resource when building the URI.
-
Field Details
-
INACTIVE_URL
The inactive URL flag.- See Also:
-
-
Method Details
-
onResource
Create the resource URI builder from a resource. If the resource name is not found in classpath, the built URI will beINACTIVE_URL
. Creating ResourceUriBuilder upon the resource name has advantages over the resource controller class because at runtime the resource could be overridden. In such a case, the overridden controller class may not be loaded, but the resource name remains effective.- Parameters:
resource
- the resource name from the resource controller definition.- Returns:
- the ResourceUriBuilder itself
- See Also:
-
onResource
Create the resource URI builder from a resource controller.- Parameters:
controller
- the resource controller class- Returns:
- the ResourceUriBuilder itself
- See Also:
-
onTemplate
Create the resource URI builder from a custom URI template in YAML.- Parameters:
templateName
- the URI template name- Returns:
- the ResourceUriBuilder itself
-
uriInfo
Specify the base URI information, including base URI and format extenstion.- Parameters:
uriInfo
- the URI info from last request.- Returns:
- the ResourceUriBuilder itself
-
baseUri
Specify the base URI for the builder when required. This will overwrite the default base URI.- Parameters:
baseUri
- the base URI of the REST server, e.g. http://localhost:8080/dctm-rest- Returns:
- the ResourceUriBuilder itself
-
extension
Specify the extension for the builder when required. This will overwrite the default base URI.- Parameters:
extension
- the format extension, e.g. .xml or .json- Returns:
- the ResourceUriBuilder itself
-
pathVariables
Specify the path variable values for the given resource URI template. If the URI template starts with the relative repository path segment "/repositories/{repositoryName}", it is optional to specify the repository name in the path variables. The builder will resolve the repository name implicitly from current HTTP request. This method can be called multiple times to accumulate the path variables in order.- Parameters:
pathVariables
- the raw variable values in the path; the values cannot contain null or empty string, otherwise the built link is invalid.- Returns:
- the ResourceUriBuilder itself
- See Also:
-
pathVariable
Specify the path variable for the given resource URI template. If the URI template starts with the relative repository path segment "/repositories/{repositoryName}", it is optional to specify the repository name in the path variables. The builder will resolve the repository name implicitly from current HTTP request. This method can be called multiple times to accumulate the path variables in order.- Parameters:
safeEncoding
- indicate whether to safe encoding the path variable values; it is required to safe encode the path value for the value that contains URI reservered characters, e.g. '/', '.', etc.pathVariable
- the raw variable value in the path; the value cannot be null or empty, otherwise the built link is invalid.- Returns:
- the ResourceUriBuilder itself
- See Also:
-
pathVariable
Specify the path variable for the given resource URI template. If the URI template starts with the relative repository path segment "/repositories/{repositoryName}", it is optional to specify the repository name in the path variables. The builder will resolve the repository name implicitly from current HTTP request. This method can be called multiple times to accumulate the path variables in order.- Parameters:
pathVariable
- the raw variable value in the path; the value cannot be null or empty, otherwise the built link is invalid.- Returns:
- the ResourceUriBuilder itself
- See Also:
-
queryParams
Specify the query queryParams for the resource URI. This method can be called multiple times to accumulate the path variables in order. The existing parameter values will be overwritten. The query queryParams in the built URI is in the order of alpha-beta of the query parameter names.- Parameters:
parameters
- the query queryParams- Returns:
- the ResourceUriBuilder itself
-
queryParam
Specify the single query parameter for the resource URI. The existing parameter values will be overwritten. This method can be called multiple times for multiple queryParams.- Parameters:
key
- the query parameter keyvalue
- the query parameter value- Returns:
- the ResourceUriBuilder itself
-
repository
Specify the repository name for the builder when required. It is optional to specify the repository name as the builder will resolve it implicitly from current HTTP request. However, it is necessary to set the repository name if the builder is building a repository level URI from non repository level HTTP requests. This setting override the implicit repository name. This will overwrite the default repository name.- Parameters:
repository
- the repository name- Returns:
- the ResourceUriBuilder itself
-
validate
Whether validate the resource when building the URI. If true, the link will be built only when the corresponding resource controller is active. Default istrue
. The default can be changed tofalse
by setting the REST runtime property 'rest.link.relation.validate=false'.- Parameters:
validate
- whether validate when build- Returns:
- the ResourceUriBuilder itself
-
relative
Whether force to make relative URI.- Returns:
- the ResourceUriBuilder itself
-
asTemplate
Force this resource URI to be normalized as an URI template.- Parameters:
templateParams
- the additional template query queryParams. The input template queryParams will be merged with the template queryParams defined on the resource URI.- Returns:
- the ResourceUriBuilder itself
-
noHrefTemplate
Resource URI is bound with controller. Once the controller has annotation @TemplateParams, the URI built withResourceUriBuilder
is always href template. This method overrides the behavior of building href template so that URI based on controllers like SearchController can be built with no template parameters.- Returns:
- the ResourceUriBuilder itself
-
build
Build the URI for the resource. If the target resource's URI is a href template, or the build is explicitly set withasTemplate(String...)
, the built URI is a URI template.- Returns:
- the URI of the resource
-
getRepositoryName
-
getBaseUri
-
getExtension
-