Class RequestPath


  • public class RequestPath
    extends java.lang.Object
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      boolean equals​(java.lang.Object o)  
      int getBlobSegmentIdx()  
      java.lang.String getClusterName()  
      java.lang.String getOperationOrBlobId​(boolean stripLeadingSlash)  
      java.lang.String getPathAfterPrefixes()
      For use cases that only require prefixes to be removed from a request path but do not need special handling for blob IDs and sub-resources.
      java.lang.String getPrefix()  
      RestUtils.SubResource getSubResource()  
      boolean matchesOperation​(java.lang.String operation)
      This will check if the request path matches the specified operation.
      static boolean matchesOperation​(java.lang.String path, java.lang.String operation)
      This will check if the request path matches the specified operation.
      static RequestPath parse​(RestRequest restRequest, java.util.List<java.lang.String> prefixesToRemove, java.lang.String clusterName)
      Parse the request path (and additional headers in some cases).
      static RequestPath parse​(java.lang.String path, java.util.Map<java.lang.String,​java.lang.Object> args, java.util.List<java.lang.String> prefixesToRemove, java.lang.String clusterName)
      This is similar to parse(RestRequest, List, String) but allows usage with arbitrary paths that are not part of a RestRequest.
      java.lang.String toString()  
      • Methods inherited from class java.lang.Object

        clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
    • Method Detail

      • parse

        public static RequestPath parse​(RestRequest restRequest,
                                        java.util.List<java.lang.String> prefixesToRemove,
                                        java.lang.String clusterName)
                                 throws RestServiceException
        Parse the request path (and additional headers in some cases). The path will match the following regex-like description:
         {prefixToRemove}?{clusterNameSegment}?({operationOrBlobId}|{operationOrBlobId}/{subResource})
         
        For example, something like /prefixOne/clusterA/parts/of/blobId/BlobInfo, /clusterA/operation, or /blobId, among others.
        Parameters:
        restRequest - RestRequest containing metadata about the request.
        prefixesToRemove - the list of prefixes that could precede the other parts of the URL. Removal of prefixes earlier in the list will be preferred to removal of the ones later in the list.
        clusterName - the cluster name to recognize and handle when parsing the URL. Case is ignored when matching this path segment.
        Returns:
        a RequestPath object.
        Throws:
        RestServiceException
      • parse

        public static RequestPath parse​(java.lang.String path,
                                        java.util.Map<java.lang.String,​java.lang.Object> args,
                                        java.util.List<java.lang.String> prefixesToRemove,
                                        java.lang.String clusterName)
                                 throws RestServiceException
        This is similar to parse(RestRequest, List, String) but allows usage with arbitrary paths that are not part of a RestRequest.
        Parameters:
        path - the path
        args - a map containing any request arguments. This might be used to look for blob IDs supplied via query parameters or headers.
        prefixesToRemove - the list of prefixes that could precede the other parts of the URL. Removal of prefixes earlier in the list will be preferred to removal of the ones later in the list.
        clusterName - the cluster name to recognize and handle when parsing the URL. Case is ignored when matching this path segment.
        Returns:
        a RequestPath object.
        Throws:
        RestServiceException
      • getPrefix

        public java.lang.String getPrefix()
        Returns:
        the path prefix, or an empty string if the path did not start with a recognized prefix.
      • getClusterName

        public java.lang.String getClusterName()
        Returns:
        the cluster name, or an empty string if the path did not include the recognized cluster name.
      • getPathAfterPrefixes

        public java.lang.String getPathAfterPrefixes()
        For use cases that only require prefixes to be removed from a request path but do not need special handling for blob IDs and sub-resources.
        Returns:
        the path segments starting after the prefix and cluster name, if either is present.
      • getOperationOrBlobId

        public java.lang.String getOperationOrBlobId​(boolean stripLeadingSlash)
        Parameters:
        stripLeadingSlash - true to remove the leading slash, if present.
        Returns:
        the extracted operation type or blob ID from the request.
      • getBlobSegmentIdx

        public int getBlobSegmentIdx()
        Returns:
        blob segment index for segmented blobs, or NO_BLOB_SEGMENT_IDX_SPECIFIED for non-segmented blobs
      • matchesOperation

        public boolean matchesOperation​(java.lang.String operation)
        This will check if the request path matches the specified operation. This will check that that the first one or more path segments in getOperationOrBlobId(boolean) match the path segments in operation. For example, /op or /op/sub will match the operation op.
        Parameters:
        operation - the operation name to check the path against.
        Returns:
        true if this request path matches the specified operation.
      • equals

        public boolean equals​(java.lang.Object o)
        Overrides:
        equals in class java.lang.Object
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object
      • matchesOperation

        public static boolean matchesOperation​(java.lang.String path,
                                               java.lang.String operation)
        This will check if the request path matches the specified operation. This will check that that the first one or more path segments in the supplied path match the path segments in operation. For example, /op or /op/sub will match the operation op.
        Parameters:
        path - the path to check.
        operation - the operation name to check the path against.
        Returns:
        true if this request path matches the specified operation.