Package com.emc.documentum.rest.http
Class UriHelper
java.lang.Object
com.emc.documentum.rest.http.UriHelper
A helper class to parse the request URI
-
Field Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic String
Append stringsstatic String
Deprecated.Since 7.3, the URI build in this pattern is not supported.static String
encodeQueryParam
(String queryParam, String encoding) Encode query param strictly.static String
encodeUriVariable
(String pathVar, boolean safeEncoding) Encode URI variable valueExtract custom variables from URI templatestatic String
fullHrefWithTemplateParams
(String uri, Set<String> set) Append href template parameters to the request uristatic String
Generate full URIstatic String
getFirstNonNullPathSegmentId
(String uri, String... pathSegments) Get first not null path segment idstatic String
getPathSegmentId
(String uri, String pathSegment) Retrieve the path value at the specified segment; for example, the path value for 'repositories' on the URI 'http://localhost:8080/repositories/acme' is 'acme'.getQueryParams
(String uri) Get query parametersstatic String
getUTF8Parameter
(String queryString, String param) get the UTF8 decoded query param only support the first value of the paramstatic String
getUTF8Parameter
(org.springframework.web.context.request.NativeWebRequest webRequest, String param) get the UTF8 decoded query param only support the first value of the paramstatic boolean
hasExtension
(String requestUri) Check whether the request URI has an extensionstatic String
makeRelative
(String baseUrl, String fullUrl, boolean force) Make URL path relative to its base URLstatic String
Convert query parameters into a query stringstatic void
percentEncode
(SortedMap<String, String> params) Encode parametersstatic String
queryString
(org.springframework.util.MultiValueMap<String, String> queryParams) Generate query stringstatic String
removeExtension
(String url, String suggestedExt) Remove extension from the URL.static String
Manipulate the URI, including adding or removing parametersstatic String
setParameters
(String fullUri, String requestUri, SortedMap<String, String> addParams, String... removeParams) Manipulate the URI, including adding or removing parameters
-
Field Details
-
CHARSET
- See Also:
-
-
Method Details
-
hasExtension
Check whether the request URI has an extension- Parameters:
requestUri
- the request URI- Returns:
true
if URI has an extension
-
getPathSegmentId
Retrieve the path value at the specified segment; for example, the path value for 'repositories' on the URI 'http://localhost:8080/repositories/acme' is 'acme'.- Parameters:
uri
- the request URIpathSegment
- the path segment at which the path value should be retrieved- Returns:
- the path segment value
-
getFirstNonNullPathSegmentId
Get first not null path segment id- Parameters:
uri
- the request URIpathSegments
- the path segments- Returns:
- first no null path segment id
-
queryString
Generate query string- Parameters:
queryParams
- the query parameters- Returns:
- query string comes from query parameters
-
extractCustomVariablesFromUriTemplatePath
Extract custom variables from URI template- Parameters:
path
- the source path- Returns:
- custom variables
-
setParameters
public static String setParameters(UriInfo uriInfo, SortedMap<String, String> addParams, String... removeParams) Manipulate the URI, including adding or removing parameters- Parameters:
uriInfo
- the uri infoaddParams
- parameters to addremoveParams
- parameters to remove- Returns:
- the processed URI
-
setParameters
public static String setParameters(String fullUri, String requestUri, SortedMap<String, String> addParams, String... removeParams) Manipulate the URI, including adding or removing parameters- Parameters:
fullUri
- the full URIrequestUri
- the request URIaddParams
- parameters to addremoveParams
- parameters to remove- Returns:
- the processed URI
-
makeRelative
Make URL path relative to its base URL- Parameters:
baseUrl
- request base URLfullUrl
- request full URLforce
- force to make relative regardless of runtime setting- Returns:
- path relative URL
-
getQueryParams
Get query parameters- Parameters:
uri
- the source URI- Returns:
- query parameters
-
buildUri
@Deprecated public static String buildUri(SimpleUriTemplate uriTemplate, SortedMap<String, String> params, Object... variables) Deprecated.Since 7.3, the URI build in this pattern is not supported. Please use com.emc.documentum.rest.context.ResourceUriBuilder to build URI for template.Build URI- Parameters:
uriTemplate
- the URI templateparams
- the query parametersvariables
- the URI variables- Returns:
- the generated URI
-
fullUri
Generate full URI- Parameters:
requestUri
- the request URIparams
- the query parameters- Returns:
- the full URI
-
append
Append strings- Parameters:
str
- the strings to append- Returns:
- URI string from all the input strings
-
params
Convert query parameters into a query string- Parameters:
params
- URI parameters- Returns:
- query string
-
percentEncode
Encode parameters- Parameters:
params
- the URI parameters
-
getUTF8Parameter
get the UTF8 decoded query param only support the first value of the param- Parameters:
queryString
- the query string which contains the parameter and valueparam
- the query parameter name- Returns:
- the parameter value
-
getUTF8Parameter
public static String getUTF8Parameter(org.springframework.web.context.request.NativeWebRequest webRequest, String param) get the UTF8 decoded query param only support the first value of the param- Parameters:
webRequest
- the web requestparam
- the query parameter name- Returns:
- the parameter value
-
encodeUriVariable
Encode URI variable value- Parameters:
pathVar
- the uri variable valuesafeEncoding
- safe encoding for textual value- Returns:
- the encoded uri variable value
-
encodeQueryParam
Encode query param strictly. Since new Spring(5.1.1) doesn't encode '+' in query param anymore.- Parameters:
queryParam
- query param to be encodedencoding
- coding charset- Returns:
- encoded query param
-
fullHrefWithTemplateParams
Append href template parameters to the request uri- Parameters:
uri
- the request uriset
- the href template parameters- Returns:
- the full request hreftemplate uri
-
removeExtension
Remove extension from the URL. The extension is taken as case-insensitive.- Parameters:
url
- the full URLsuggestedExt
- the suggested extension; if it's provided, will remove the specified extension; if it's empty, will remove '.xml' or '.json'.- Returns:
- the URL without extension
-