Gargi-jais11 commented on code in PR #11426:
URL: https://github.com/apache/ozone/pull/11426#discussion_r4254632181
##########
hadoop-ozone/s3gateway/src/main/java/org/apache/hadoop/ozone/s3/endpoint/BucketEndpoint.java:
##########
@@ -498,6 +530,6 @@ private void handleRuntimeException(RuntimeException ex,
S3RequestContext contex
private boolean shouldIncludeOwnerInListResponse() {
int listType = queryParams().getInt(QueryParams.LIST_TYPE, 1);
boolean fetchOwner = queryParams().getBoolean(QueryParams.FETCH_OWNER,
false);
- return listType != 2 || fetchOwner;
+ return isListObjectVersions() || listType != 2 || fetchOwner;
Review Comment:
here we always includes **Owner** on ListObjectVersions whenever
`isListObjectVersions()` is true, even when `fetch-owner=false`. On AWS, owner
is omitted by default and only included when fetch-owner=true
([ListObjectVersions](https://docs.aws.amazon.com/AmazonS3/latest/API/API_ListObjectVersions.html)).
use the same rule as ListObjectsV2 here (fetchOwner only)
##########
hadoop-ozone/s3gateway/src/main/java/org/apache/hadoop/ozone/s3/endpoint/EndpointBase.java:
##########
@@ -790,6 +791,15 @@ protected void validateObjectKeyUri(String keyPath) throws
OS3Exception {
}
}
+ /**
+ * Versioning is not implemented, so each object only has the null version,
i.e. the current object.
+ *
+ * @return true if {@code versionId} refers to any other version
+ */
+ static boolean isUnsupportedVersionId(@Nullable String versionId) {
+ return versionId != null && !NULL_VERSION_ID.equals(versionId);
+ }
Review Comment:
`versionId=""` is treated as unsupported not the same as absent or "null",
so DeleteObject / tagging etc. with an empty versionId returns
**NotImplemented**.
we should be treating blank the same as absent and only reject non-null
values.
##########
hadoop-ozone/s3gateway/src/main/java/org/apache/hadoop/ozone/s3/endpoint/ListVersionsResult.java:
##########
@@ -0,0 +1,139 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.hadoop.ozone.s3.endpoint;
+
+import static org.apache.hadoop.ozone.s3.util.S3Consts.NULL_VERSION_ID;
+
+import java.util.List;
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlElement;
+import javax.xml.bind.annotation.XmlRootElement;
+import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
+import org.apache.hadoop.ozone.s3.commontypes.CommonPrefix;
+import org.apache.hadoop.ozone.s3.commontypes.EncodingTypeObject;
+import org.apache.hadoop.ozone.s3.commontypes.KeyMetadata;
+import org.apache.hadoop.ozone.s3.commontypes.ObjectKeyNameAdapter;
+import org.apache.hadoop.ozone.s3.util.S3Consts;
+
+/**
+ * Response of ListObjectVersions.
+ * <p>
+ * Versioning is not implemented, so each object is listed with its only
version, the null version.
+ * This is the same as what AWS S3 returns for a bucket that never had
versioning enabled.
+ */
+@XmlAccessorType(XmlAccessType.FIELD)
+@XmlRootElement(name = "ListVersionsResult", namespace =
S3Consts.S3_XML_NAMESPACE)
+public class ListVersionsResult {
+
+ @XmlElement(name = "Name")
+ private String name;
+
+ @XmlJavaTypeAdapter(ObjectKeyNameAdapter.class)
+ @XmlElement(name = "Prefix")
+ private EncodingTypeObject prefix;
+
+ @XmlJavaTypeAdapter(ObjectKeyNameAdapter.class)
+ @XmlElement(name = "KeyMarker")
+ private EncodingTypeObject keyMarker;
+
+ @XmlElement(name = "VersionIdMarker")
+ private String versionIdMarker;
+
+ @XmlJavaTypeAdapter(ObjectKeyNameAdapter.class)
+ @XmlElement(name = "NextKeyMarker")
+ private EncodingTypeObject nextKeyMarker;
+
+ @XmlElement(name = "NextVersionIdMarker")
+ private String nextVersionIdMarker;
+
+ @XmlElement(name = "MaxKeys")
+ private int maxKeys;
+
+ @XmlJavaTypeAdapter(ObjectKeyNameAdapter.class)
+ @XmlElement(name = "Delimiter")
+ private EncodingTypeObject delimiter;
+
+ @XmlElement(name = "EncodingType")
+ private String encodingType;
+
+ @XmlElement(name = "IsTruncated")
+ private boolean isTruncated;
+
+ @XmlElement(name = "Version")
+ private List<KeyMetadata> versions;
+
+ @XmlElement(name = "CommonPrefixes")
+ private List<CommonPrefix> commonPrefixes;
+
+ /**
+ * @param listing result of listing the bucket with {@code key-marker} as
the marker
+ * @param versionIdMarker {@code version-id-marker} of the request
+ */
+ static ListVersionsResult of(ListObjectResponse listing, String
versionIdMarker) {
Review Comment:
AWS ListObjectVersions responses include KeyCount, but ListVersionsResult
never maps it, so the XML omits KeyCount.
--
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]