public class NettyRestUtils extends Object
Modifier and Type | Class and Description |
---|---|
static interface |
NettyRestUtils.RestCallable<T>
An interface representing a callable.
|
Modifier and Type | Field and Description |
---|---|
static Authenticator |
AUTHENTICATOR |
static io.netty.handler.codec.http.HttpVersion |
HTTP_VERSION |
Constructor and Description |
---|
NettyRestUtils() |
Modifier and Type | Method and Description |
---|---|
static <T> io.netty.handler.codec.http.HttpResponse |
call(String resource,
NettyRestUtils.RestCallable<T> callable)
Calls the given
NettyRestUtils.RestCallable and handles any exceptions thrown. |
static Map<String,String> |
convertToSingleValueMap(io.netty.handler.codec.http.HttpHeaders httpHeaders)
Convert
HttpHeaders to a single value map. |
static javax.ws.rs.core.MediaType |
deserializeContentType(Map<String,byte[]> xAttr)
Given xAttr, parses and returns the Content-Type header metadata
as its corresponding
MediaType , or otherwise defaults
to MediaType.APPLICATION_OCTET_STREAM_TYPE . |
static TaggingData |
deserializeTags(Map<String,byte[]> xAttr)
Given xAttr, parses and deserializes the Tagging metadata
into a
TaggingData object. |
static Map<String,String> |
fromListValueMapToSingleValueMap(Map<String,List<String>> queryParameters)
Convert MultivaluedMap to a single value map.
|
static Map<String,String> |
fromMultiValueToSingleValueMap(javax.ws.rs.core.MultivaluedMap<String,String> queryParameters,
boolean lowerCase)
Convert MultivaluedMap to a single value map.
|
static String |
getEntityTag(FileInfo status)
This helper method is used to get the ETag xAttr on an object.
|
static String |
getFullPath(String bucket,
String object)
Gets the full path combined by bucket name and object name.
|
static String |
getScheme(io.netty.handler.codec.http.HttpRequest fullHttpRequest)
Get the scheme of a
HttpRequest . |
static String |
getUser(io.netty.handler.codec.http.HttpRequest request)
Get username from header info from FullHttpRequest.
|
static String |
getUserFromAuthorization(String authorization,
AlluxioConfiguration conf)
Gets the user from the authorization header string for AWS Signature Version 4.
|
static String |
parsePath(String bucketPath)
Format bucket path.
|
static S3Exception |
toBucketS3Exception(Exception exception,
String resource,
S3AuditContext auditContext)
Convert an exception to instance of
S3Exception . |
static S3Exception |
toObjectS3Exception(Exception exception,
String resource,
S3AuditContext auditContext)
Convert an exception to instance of
S3Exception . |
public static final io.netty.handler.codec.http.HttpVersion HTTP_VERSION
public static final Authenticator AUTHENTICATOR
public static <T> io.netty.handler.codec.http.HttpResponse call(String resource, NettyRestUtils.RestCallable<T> callable)
NettyRestUtils.RestCallable
and handles any exceptions thrown.T
- the return type of the callableresource
- the resource (bucket or object) to be operated oncallable
- the callable to callpublic static javax.ws.rs.core.MediaType deserializeContentType(Map<String,byte[]> xAttr)
MediaType
, or otherwise defaults
to MediaType.APPLICATION_OCTET_STREAM_TYPE
.xAttr
- the Inode's xAttrsMediaType
corresponding to the Content-Type header@Nullable public static String getEntityTag(FileInfo status)
status
- The URIStatus
of the objectpublic static String parsePath(String bucketPath)
bucketPath
- bucket pathpublic static S3Exception toBucketS3Exception(Exception exception, String resource, S3AuditContext auditContext)
S3Exception
.exception
- Exception thrown when process s3 object rest requestresource
- complete bucket pathauditContext
- the audit context for exceptionS3Exception
public static S3Exception toObjectS3Exception(Exception exception, String resource, S3AuditContext auditContext)
S3Exception
.exception
- Exception thrown when process s3 object rest requestresource
- object complete pathauditContext
- the audit context for exceptionS3Exception
public static TaggingData deserializeTags(Map<String,byte[]> xAttr) throws IOException
TaggingData
object. Returns null if no data exists.xAttr
- the Inode's xAttrsTaggingData
objectIOException
public static String getUser(io.netty.handler.codec.http.HttpRequest request) throws S3Exception
request
- FullHttpRequestS3Exception
@Nullable public static String getUserFromAuthorization(String authorization, AlluxioConfiguration conf) throws S3Exception
authorization
- the authorization header stringconf
- the AlluxioConfiguration
Alluxio confS3Exception
public static Map<String,String> fromMultiValueToSingleValueMap(javax.ws.rs.core.MultivaluedMap<String,String> queryParameters, boolean lowerCase)
queryParameters
- MultivaluedMaplowerCase
- whether to use lower casepublic static Map<String,String> convertToSingleValueMap(io.netty.handler.codec.http.HttpHeaders httpHeaders)
HttpHeaders
to a single value map.httpHeaders
- HttpHeaderspublic static Map<String,String> fromListValueMapToSingleValueMap(Map<String,List<String>> queryParameters)
queryParameters
- MultivaluedMappublic static String getScheme(io.netty.handler.codec.http.HttpRequest fullHttpRequest)
HttpRequest
.fullHttpRequest
- FullHttpRequestCopyright © 2023. All Rights Reserved.