use of org.apache.hadoop.ozone.s3.exception.S3ErrorTable.INVALID_ARGUMENT in project ozone by apache.
the class ObjectEndpoint method parseSourceHeader.
/**
* Parse the key and bucket name from copy header.
*/
@VisibleForTesting
public static Pair<String, String> parseSourceHeader(String copyHeader) throws OS3Exception {
String header = copyHeader;
if (header.startsWith("/")) {
header = copyHeader.substring(1);
}
int pos = header.indexOf('/');
if (pos == -1) {
OS3Exception ex = newError(INVALID_ARGUMENT, header);
ex.setErrorMessage("Copy Source must mention the source bucket and " + "key: sourcebucket/sourcekey");
throw ex;
}
try {
String bucket = header.substring(0, pos);
String key = urlDecode(header.substring(pos + 1));
return Pair.of(bucket, key);
} catch (UnsupportedEncodingException e) {
OS3Exception ex = newError(INVALID_ARGUMENT, header, e);
ex.setErrorMessage("Copy Source header could not be url-decoded");
throw ex;
}
}
Aggregations