Class UriHelper

java.lang.Object
com.emc.documentum.rest.http.UriHelper

public final class UriHelper extends Object
A helper class to parse the request URI
  • Field Details

  • Method Details

    • hasExtension

      public static boolean hasExtension(String requestUri)
      Check whether the request URI has an extension
      Parameters:
      requestUri - the request URI
      Returns:
      true if URI has an extension
    • getPathSegmentId

      public static 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'.
      Parameters:
      uri - the request URI
      pathSegment - the path segment at which the path value should be retrieved
      Returns:
      the path segment value
    • getFirstNonNullPathSegmentId

      public static String getFirstNonNullPathSegmentId(String uri, String... pathSegments)
      Get first not null path segment id
      Parameters:
      uri - the request URI
      pathSegments - the path segments
      Returns:
      first no null path segment id
    • queryString

      public static String queryString(org.springframework.util.MultiValueMap<String,String> queryParams)
      Generate query string
      Parameters:
      queryParams - the query parameters
      Returns:
      query string comes from query parameters
    • extractCustomVariablesFromUriTemplatePath

      public static Set<String> extractCustomVariablesFromUriTemplatePath(String path)
      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 info
      addParams - parameters to add
      removeParams - 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 URI
      requestUri - the request URI
      addParams - parameters to add
      removeParams - parameters to remove
      Returns:
      the processed URI
    • makeRelative

      public static String makeRelative(String baseUrl, String fullUrl, boolean force)
      Make URL path relative to its base URL
      Parameters:
      baseUrl - request base URL
      fullUrl - request full URL
      force - force to make relative regardless of runtime setting
      Returns:
      path relative URL
    • getQueryParams

      public static org.springframework.util.MultiValueMap<String,String> getQueryParams(String uri)
      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 template
      params - the query parameters
      variables - the URI variables
      Returns:
      the generated URI
    • fullUri

      public static String fullUri(String requestUri, SortedMap<String,String> params)
      Generate full URI
      Parameters:
      requestUri - the request URI
      params - the query parameters
      Returns:
      the full URI
    • append

      public static String append(String... str)
      Append strings
      Parameters:
      str - the strings to append
      Returns:
      URI string from all the input strings
    • params

      public static String params(SortedMap<String,String> params)
      Convert query parameters into a query string
      Parameters:
      params - URI parameters
      Returns:
      query string
    • percentEncode

      public static void percentEncode(SortedMap<String,String> params)
      Encode parameters
      Parameters:
      params - the URI parameters
    • getUTF8Parameter

      public static String getUTF8Parameter(String queryString, String param)
      get the UTF8 decoded query param only support the first value of the param
      Parameters:
      queryString - the query string which contains the parameter and value
      param - 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 request
      param - the query parameter name
      Returns:
      the parameter value
    • encodeUriVariable

      public static String encodeUriVariable(String pathVar, boolean safeEncoding)
      Encode URI variable value
      Parameters:
      pathVar - the uri variable value
      safeEncoding - safe encoding for textual value
      Returns:
      the encoded uri variable value
    • encodeQueryParam

      public static String encodeQueryParam(String queryParam, String encoding)
      Encode query param strictly. Since new Spring(5.1.1) doesn't encode '+' in query param anymore.
      Parameters:
      queryParam - query param to be encoded
      encoding - coding charset
      Returns:
      encoded query param
    • fullHrefWithTemplateParams

      public static String fullHrefWithTemplateParams(String uri, Set<String> set)
      Append href template parameters to the request uri
      Parameters:
      uri - the request uri
      set - the href template parameters
      Returns:
      the full request hreftemplate uri
    • removeExtension

      public static String removeExtension(String url, String suggestedExt)
      Remove extension from the URL. The extension is taken as case-insensitive.
      Parameters:
      url - the full URL
      suggestedExt - 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