TaiJuWu commented on code in PR #9110:
URL: https://github.com/apache/ozone/pull/9110#discussion_r2415911625
##########
hadoop-ozone/s3gateway/src/main/java/org/apache/hadoop/ozone/s3/endpoint/BucketEndpoint.java:
##########
@@ -193,71 +173,243 @@ public Response get(
throw ex;
}
- // The valid encodingType Values is "url"
+ // Return empty response if no keys found
+ ListObjectResponse emptyResponse = new ListObjectResponse();
+ emptyResponse.setName(bucketName);
+ emptyResponse.setKeyCount(0);
+ return Response.ok(emptyResponse).build();
+ }
+
+ private int validateMaxKeys(int maxKeys) throws OS3Exception {
+ if (maxKeys < 0) {
+ throw newError(S3ErrorTable.INVALID_ARGUMENT, "maxKeys must be >= 0");
+ }
+
+ return Math.min(maxKeys, maxKeysLimit);
+ }
+
+ /**
+ * Context class to hold bucket listing parameters and state.
+ */
+ static class BucketListingContext {
+ private final String bucketName;
+ private final String delimiter;
+ private final String encodingType;
+ private final String marker;
+ private final int maxKeys;
+ private final String prefix;
+ private final String continueToken;
+ private final String startAfter;
+ private final String prevKey;
+ private final boolean shallow;
+ private final OzoneBucket bucket;
+ private final Iterator<? extends OzoneKey> ozoneKeyIterator;
+ private final ContinueToken decodedToken;
+
+ @SuppressWarnings("parameternumber")
+ BucketListingContext(String bucketName, String delimiter, String
encodingType,
+ String marker, int maxKeys, String prefix,
String continueToken,
+ String startAfter, String prevKey, boolean
shallow,
+ OzoneBucket bucket, Iterator<? extends
OzoneKey> ozoneKeyIterator,
+ ContinueToken decodedToken) {
+ this.bucketName = bucketName;
+ this.delimiter = delimiter;
+ this.encodingType = encodingType;
+ this.marker = marker;
+ this.maxKeys = maxKeys;
+ this.prefix = prefix;
+ this.continueToken = continueToken;
+ this.startAfter = startAfter;
+ this.prevKey = prevKey;
+ this.shallow = shallow;
+ this.bucket = bucket;
+ this.ozoneKeyIterator = ozoneKeyIterator;
+ this.decodedToken = decodedToken;
+ }
+
+ // Getters
+ public String getBucketName() {
+ return bucketName;
+ }
+
+ public String getDelimiter() {
+ return delimiter;
+ }
+
+ public String getEncodingType() {
+ return encodingType;
+ }
+
+ public String getMarker() {
+ return marker;
+ }
+
+ public int getMaxKeys() {
+ return maxKeys;
+ }
+
+ public String getPrefix() {
+ return prefix;
+ }
+
+ public String getContinueToken() {
+ return continueToken;
+ }
+
+ public String getStartAfter() {
+ return startAfter;
+ }
+
+ public String getPrevKey() {
+ return prevKey;
+ }
+
+ public boolean isShallow() {
+ return shallow;
+ }
+
+ public OzoneBucket getBucket() {
+ return bucket;
+ }
+
+ public Iterator<? extends OzoneKey> getOzoneKeyIterator() {
+ return ozoneKeyIterator;
+ }
+
+ public ContinueToken getDecodedToken() {
+ return decodedToken;
+ }
+ }
+
+ /**
+ * Handle ACL request.
+ */
+ Response handleAclRequest(String bucketName, long startNanos)
+ throws OS3Exception, IOException {
+ S3GAction s3GAction = S3GAction.GET_ACL;
+ S3BucketAcl result = getAcl(bucketName);
+ getMetrics().updateGetAclSuccessStats(startNanos);
+ AUDIT.logReadSuccess(
+ buildAuditMessageForSuccess(s3GAction, getAuditParameters()));
+ return Response.ok(result, MediaType.APPLICATION_XML_TYPE).build();
+ }
+
+ /**
+ * Validate and prepare parameters for bucket listing.
+ */
+ @SuppressWarnings({"parameternumber", "checkstyle:ParameterNumber"})
+ BucketListingContext validateAndPrepareParameters(
+ String bucketName, String delimiter, String encodingType, String marker,
+ int maxKeys, String prefix, String continueToken, String startAfter)
+ throws OS3Exception, IOException {
+
+ // Validate encoding type
if (encodingType != null && !encodingType.equals(ENCODING_TYPE)) {
throw S3ErrorTable.newError(S3ErrorTable.INVALID_ARGUMENT, encodingType);
}
- // If you specify the encoding-type request parameter,should return
- // encoded key name values in the following response elements:
- // Delimiter, Prefix, Key, and StartAfter.
- //
- // For detail refer:
- // https://docs.aws.amazon.com/AmazonS3/latest/API/API_ListObjectsV2.html
- // #AmazonS3-ListObjectsV2-response-EncodingType
- //
Review Comment:
should this comment be keep?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]