xichen01 commented on code in PR #8557:
URL: https://github.com/apache/ozone/pull/8557#discussion_r2165928651


##########
hadoop-ozone/common/src/main/java/org/apache/hadoop/ozone/om/helpers/OmLCRule.java:
##########
@@ -161,6 +162,11 @@ public void valid() throws OMException {
           OMException.ResultCodes.INVALID_REQUEST);
     }
 
+    if (prefix == null && filter == null) {
+      throw new OMException("Filter and Prefix cannot both be null.",

Review Comment:
   Yes



##########
hadoop-ozone/s3gateway/src/test/java/org/apache/hadoop/ozone/s3/endpoint/TestLifecycleConfigurationGet.java:
##########
@@ -0,0 +1,100 @@
+/*
+ * 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 java.net.HttpURLConnection.HTTP_NOT_FOUND;
+import static java.net.HttpURLConnection.HTTP_OK;
+import static 
org.apache.hadoop.ozone.s3.exception.S3ErrorTable.NO_SUCH_LIFECYCLE_CONFIGURATION;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.fail;
+
+import java.io.ByteArrayInputStream;
+import java.io.InputStream;
+import java.nio.charset.StandardCharsets;
+import javax.ws.rs.core.Response;
+import org.apache.hadoop.ozone.client.ObjectStore;
+import org.apache.hadoop.ozone.client.OzoneClient;
+import org.apache.hadoop.ozone.client.OzoneClientStub;
+import org.apache.hadoop.ozone.s3.exception.OS3Exception;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+
+/**
+ * Testing for GetBucketLifecycleConfiguration.
+ */
+public class TestLifecycleConfigurationGet {
+
+  private OzoneClient clientStub;
+  private BucketEndpoint bucketEndpoint;
+
+  @BeforeEach
+  public void setup() throws Exception {
+    clientStub = new OzoneClientStub();
+    bucketEndpoint = EndpointBuilder.newBucketEndpointBuilder()
+        .setClient(clientStub)
+        .build();
+    ObjectStore objectStore = clientStub.getObjectStore();
+    objectStore.createS3Bucket("bucket1");
+  }
+
+  @Test
+  public void testGetNonExistentLifecycleConfiguration()
+      throws Exception {
+    try {
+      bucketEndpoint.get("bucket1", null, null, null, 0, null, null,
+          null, null, null, null, null, 0, "", null);
+      fail();
+    } catch (OS3Exception ex) {
+      assertEquals(HTTP_NOT_FOUND, ex.getHttpCode());
+      assertEquals(NO_SUCH_LIFECYCLE_CONFIGURATION.getCode(),
+          ex.getCode());
+    }
+  }
+
+  @Test
+  public void testCreateInvalidLifecycleConfiguration() throws Exception {

Review Comment:
   Should be Valid



##########
hadoop-ozone/s3gateway/src/main/java/org/apache/hadoop/ozone/s3/endpoint/BucketEndpoint.java:
##########
@@ -752,6 +771,97 @@ private void addKey(ListObjectResponse response, OzoneKey 
next) {
     response.addKey(keyMetadata);
   }
 
+  private void verifyBucketOwner(String bucketName, HttpHeaders httpHeaders)
+      throws OS3Exception {
+    if (httpHeaders == null) {
+      return;
+    }
+    String expectedBucketOwner = 
httpHeaders.getHeaderString("x-amz-expected-bucket-owner");
+    if (expectedBucketOwner == null || expectedBucketOwner.isEmpty()) {
+      return;

Review Comment:
   This is a optional header



##########
hadoop-ozone/client/src/main/java/org/apache/hadoop/ozone/client/OzoneBucket.java:
##########
@@ -1091,6 +1092,36 @@ public void deleteObjectTagging(String keyName) throws 
IOException {
     proxy.deleteObjectTagging(volumeName, name, keyName);
   }
 
+  /**
+   * Gets the lifecycle configuration information.
+   * @return OmLifecycleConfiguration or exception is thrown.
+   * @throws IOException
+   */
+  @JsonIgnore
+  public OzoneLifecycleConfiguration getLifecycleConfiguration()
+      throws IOException {
+    return proxy.getLifecycleConfiguration(volumeName, name);
+  }
+
+  /**
+   * Creates a new lifecycle configuration.

Review Comment:
   looks like the `setLifecycleConfiguration` is better. 



##########
hadoop-ozone/s3gateway/src/main/java/org/apache/hadoop/ozone/s3/endpoint/PutBucketLifecycleConfigurationUnmarshaller.java:
##########
@@ -0,0 +1,80 @@
+/*
+ * 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.S3_XML_NAMESPACE;
+
+import java.io.InputStream;
+import java.lang.annotation.Annotation;
+import java.lang.reflect.Type;
+import javax.ws.rs.WebApplicationException;
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.MultivaluedMap;
+import javax.ws.rs.ext.MessageBodyReader;
+import javax.xml.XMLConstants;
+import javax.xml.bind.JAXBContext;
+import javax.xml.bind.UnmarshallerHandler;
+import javax.xml.parsers.SAXParserFactory;
+import org.xml.sax.InputSource;
+import org.xml.sax.XMLReader;
+
+/**
+ * Custom unmarshaller to read Lifecycle configuration namespace.
+ */
+public class PutBucketLifecycleConfigurationUnmarshaller
+    implements MessageBodyReader<LifecycleConfiguration>  {

Review Comment:
   I remember I tried to remove `OzoneLifecycleConfiguration` but will 
Introduce some other trouble (I don't remember the details.). I think this 
`OzoneLifecycleConfiguration` is client side `OmLifecycleConfiguration `, just 
like we have `OMKeyInfo` and `OzoneKey` and `OzoneKeyDetails` both these have 
specific function.



-- 
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]

Reply via email to