oscerd commented on code in PR #31262:
URL: https://github.com/apache/camel/pull/31262#discussion_r4782865021


##########
components/camel-aws/camel-aws2-s3/src/test/java/org/apache/camel/component/aws2/s3/AWS2S3ProducerListObjectsPagingTest.java:
##########
@@ -0,0 +1,129 @@
+/*
+ * 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.camel.component.aws2.s3;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.camel.CamelContext;
+import org.apache.camel.Exchange;
+import org.apache.camel.Message;
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.test.junit6.CamelTestSupport;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.Test;
+import software.amazon.awssdk.services.s3.model.S3Object;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+
+/**
+ * listObjects reads the continuation token and the maximum number of keys 
from the headers, and sets the token of the
+ * next page back on the out message, so that a route can walk a bucket with 
more objects than one answer carries.
+ */
+class AWS2S3ProducerListObjectsPagingTest extends CamelTestSupport {

Review Comment:
   Added in (5df83f69bd42): `AWS2S3ProducerListBucketsPagingTest` captures the 
`ListBucketsRequest` and checks the token and `maxBuckets` are passed, the next 
token is set back with `CamelAwsS3IsTruncated=true`, the header is removed on 
the last page, and nothing is sent without the headers.
   
   _Claude Code on behalf of oscerd_



##########
components/camel-aws/camel-aws2-s3/src/main/docs/aws2-s3-producer-operations.adoc:
##########
@@ -186,6 +187,29 @@ and the key from the `keyName` option, unless the 
`CamelAwsS3Key` header is set.
 
 This section covers operations that require special configuration beyond the 
common pattern.
 
+[[listPaging]]
+=== Paging listObjects and listBuckets
+
+Amazon S3 answers `listObjects` and `listBuckets` one page at a time, at most 
1000 entries per page. Set
+`CamelAwsS3MaxKeys` to ask for a smaller page. When more entries follow, the 
producer sets
+`CamelAwsS3IsTruncated` to `true` and `CamelAwsS3ContinuationToken` to the 
token of the next page; send that token
+back in `CamelAwsS3ContinuationToken` to read on. On the last page the 
producer sets `CamelAwsS3IsTruncated` to
+`false` and **removes** `CamelAwsS3ContinuationToken`, so a route that loops 
while the header is present stops by
+itself.
+
+[source,java]
+----
+from("direct:listAll")
+    
.loopDoWhile(header(AWS2S3Constants.CONTINUATION_TOKEN).isNotNull().or(exchangeProperty("firstPass").isNull()))

Review Comment:
   Done in (5df83f69bd42): the snippet uses the string literal 
`"CamelAwsS3ContinuationToken"` like the other examples of the page, and 
`PredicateBuilder.or(...)` so that it compiles.
   
   _Claude Code on behalf of oscerd_



##########
components/camel-aws/camel-aws2-s3/src/main/docs/aws2-s3-producer-operations.adoc:
##########
@@ -186,6 +187,29 @@ and the key from the `keyName` option, unless the 
`CamelAwsS3Key` header is set.
 
 This section covers operations that require special configuration beyond the 
common pattern.
 
+[[listPaging]]
+=== Paging listObjects and listBuckets
+
+Amazon S3 answers `listObjects` and `listBuckets` one page at a time, at most 
1000 entries per page. Set
+`CamelAwsS3MaxKeys` to ask for a smaller page. When more entries follow, the 
producer sets
+`CamelAwsS3IsTruncated` to `true` and `CamelAwsS3ContinuationToken` to the 
token of the next page; send that token
+back in `CamelAwsS3ContinuationToken` to read on. On the last page the 
producer sets `CamelAwsS3IsTruncated` to
+`false` and **removes** `CamelAwsS3ContinuationToken`, so a route that loops 
while the header is present stops by
+itself.
+
+[source,java]
+----
+from("direct:listAll")
+    
.loopDoWhile(header(AWS2S3Constants.CONTINUATION_TOKEN).isNotNull().or(exchangeProperty("firstPass").isNull()))
+        .setProperty("firstPass", constant(false))
+        .to("aws2-s3://mybucket?operation=listObjects")
+        .log("got ${body.size()} objects, more: 
${header.CamelAwsS3IsTruncated}")
+    .end();
+----
+
+In POJO mode the token is read from the `ListObjectsV2Request` body, and the 
producer still sets the two headers on
+the answer.
+
 [[uploadObject]]

Review Comment:
   Fixed in (5df83f69bd42): the section now says 1,000 per page for 
`listObjects` and 10,000 for `listBuckets`, both also the defaults.
   
   _Claude Code on behalf of oscerd_



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

Reply via email to