ChenSammi commented on code in PR #11461:
URL: https://github.com/apache/ozone/pull/11461#discussion_r4255920928


##########
hadoop-ozone/s3gateway/src/main/java/org/apache/hadoop/ozone/s3/endpoint/PutBucketLifecycleConfigurationUnmarshaller.java:
##########
@@ -17,14 +17,67 @@
 
 package org.apache.hadoop.ozone.s3.endpoint;
 
+import static org.apache.hadoop.ozone.s3.util.S3Consts.S3_XML_NAMESPACE;
+
+import com.google.common.collect.ImmutableMap;
+import com.google.common.collect.ImmutableSet;
+import java.util.ArrayDeque;
+import java.util.Deque;
+import org.xml.sax.Attributes;
+import org.xml.sax.SAXException;
+
 /**
  * Custom unmarshaller to read Lifecycle configuration.
  */
 public class PutBucketLifecycleConfigurationUnmarshaller
     extends MessageUnmarshaller<S3LifecycleConfiguration> {
+  private static final ImmutableMap<String, ImmutableSet<String>> 
ALLOWED_CHILDREN =
+      ImmutableMap.<String, ImmutableSet<String>>builder()
+          .put("", ImmutableSet.of("LifecycleConfiguration"))
+          .put("LifecycleConfiguration", ImmutableSet.of("Rule"))
+          .put("Rule", ImmutableSet.of("ID", "Status", "Prefix", "Expiration", 
"AbortIncompleteMultipartUpload",
+              "Filter", "Transition"))
+          .put("Expiration", ImmutableSet.of("Days", "Date"))
+          .put("AbortIncompleteMultipartUpload", 
ImmutableSet.of("DaysAfterInitiation"))
+          .put("Filter", ImmutableSet.of("Prefix", "Tag", "And"))
+          .put("And", ImmutableSet.of("Prefix", "Tag"))
+          .put("Tag", ImmutableSet.of("Key", "Value"))
+          .put("Transition", ImmutableSet.of("Days", "Date", "StorageClass"))
+          .build();
 
   public PutBucketLifecycleConfigurationUnmarshaller() {

Review Comment:
   The PutBucketLifecycleConfigurationUnmarshaller is used in 
BucketLifecycleHandler. 
   
   ```
   try {
         s3LifecycleConfiguration = new 
PutBucketLifecycleConfigurationUnmarshaller().readFrom(body);
         lcc = s3LifecycleConfiguration.toOmLifecycleConfiguration(ozoneBucket);
       } catch (WebApplicationException ex) {
         throw S3ErrorTable.newError(S3ErrorTable.MALFORMED_XML, bucketName);
       }
   ```
   
   WebApplicationException catches the exception return MALFORMED_XML, with the 
ex message discarded. We should return the detail message to caller so that the 
caller will know why the put request fails.  



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