From 8295860064e8a86c4801b3a39f115877988eeb3c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=8D=C3=B1igo=20Cobi=C3=A1n?= Date: Thu, 9 Jan 2025 18:08:38 +0100 Subject: [PATCH 1/4] Check that item_assets is not empty --- .../integratedmodelling/klab/stac/STACCollectionParser.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/adapters/klab.ogc/src/main/java/org/integratedmodelling/klab/stac/STACCollectionParser.java b/adapters/klab.ogc/src/main/java/org/integratedmodelling/klab/stac/STACCollectionParser.java index 01701b220..a3ccdfa97 100644 --- a/adapters/klab.ogc/src/main/java/org/integratedmodelling/klab/stac/STACCollectionParser.java +++ b/adapters/klab.ogc/src/main/java/org/integratedmodelling/klab/stac/STACCollectionParser.java @@ -85,7 +85,9 @@ public static JSONObject readAssetsFromCollection(String collectionUrl, JSONObje // item_assets is a shortcut for obtaining information about the assets // https://github.com/stac-extensions/item-assets if (collection.has("item_assets")) { - return STACCollectionParser.readItemAssets(collection); + if (!collection.getJSONObject("item_assets").isEmpty()) { + return STACCollectionParser.readItemAssets(collection); + } } // TODO Move the query to another place. From 3805ae70664bf3b3bce044add4b10c488d0d6483 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=8D=C3=B1igo=20Cobi=C3=A1n?= Date: Thu, 9 Jan 2025 18:18:12 +0100 Subject: [PATCH 2/4] Update supported media type --- .../org/integratedmodelling/klab/stac/STACAssetParser.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/adapters/klab.ogc/src/main/java/org/integratedmodelling/klab/stac/STACAssetParser.java b/adapters/klab.ogc/src/main/java/org/integratedmodelling/klab/stac/STACAssetParser.java index 22332cbe9..f28739c1d 100644 --- a/adapters/klab.ogc/src/main/java/org/integratedmodelling/klab/stac/STACAssetParser.java +++ b/adapters/klab.ogc/src/main/java/org/integratedmodelling/klab/stac/STACAssetParser.java @@ -9,7 +9,9 @@ public class STACAssetParser { // https://github.com/radiantearth/stac-spec/blob/master/best-practices.md#common-media-types-in-stac - final private static Set SUPPORTED_MEDIA_TYPE = Set.of("image/tiff;application=geotiff;profile=cloud-optimized","image/vnd.stac.geotiff;profile=cloud-optimized"); + final private static Set SUPPORTED_MEDIA_TYPE = Set.of("image/tiff;application=geotiff", "image/vnd.stac.geotiff", + "image/tiff;application=geotiff;profile=cloud-optimized", "image/vnd.stac.geotiff;profile=cloud-optimized", + "image/vnd.stac.geotiff;cloud-optimized=true", "application/geo+json"); /** * Check if the MIME value is supported. From 0e460e71b305819c3d9b1570b880f9c8f2335be8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=8D=C3=B1igo=20Cobi=C3=A1n?= Date: Wed, 15 Jan 2025 09:52:24 +0100 Subject: [PATCH 3/4] Bump and adapt AWS dependency to version 2.0 --- adapters/klab.ogc/pom.xml | 26 ++++++++----- .../klab/stac/STACEncoder.java | 38 +++++++++---------- .../main/resources/ogc/prototypes/stac.kdl | 3 ++ pom.xml | 4 +- 4 files changed, 39 insertions(+), 32 deletions(-) diff --git a/adapters/klab.ogc/pom.xml b/adapters/klab.ogc/pom.xml index 21f8caae9..17e7a65f6 100644 --- a/adapters/klab.ogc/pom.xml +++ b/adapters/klab.ogc/pom.xml @@ -63,16 +63,22 @@ - - com.amazonaws - aws-java-sdk-core - ${aws.version} - - - com.amazonaws - aws-java-sdk-s3 - ${aws.version} - + + software.amazon.awssdk + netty-nio-client + ${aws.version} + + + commons-logging + commons-logging + + + + + software.amazon.awssdk + protocol-core + ${aws.version} + 28.0 - 0.10.9-SNAPSHOT + 0.10.9-S3-SDK-2.0-SNAPSHOT 1.20.0 1.5.0 11 @@ -131,7 +131,7 @@ 5.6.0 2.2 2.0.9 - 1.12.767 + 2.29.14 From 4d59d263cbd5d67834fd49ba43f1ec1c8abdd830 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=8D=C3=B1igo=20Cobi=C3=A1n?= Date: Thu, 23 Jan 2025 14:01:42 +0100 Subject: [PATCH 4/4] Switch from Async to Synchronous S3 client --- adapters/klab.ogc/pom.xml | 8 ++++---- .../integratedmodelling/klab/stac/STACEncoder.java | 14 +++++++------- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/adapters/klab.ogc/pom.xml b/adapters/klab.ogc/pom.xml index 17e7a65f6..510b3f1d5 100644 --- a/adapters/klab.ogc/pom.xml +++ b/adapters/klab.ogc/pom.xml @@ -64,10 +64,10 @@ - software.amazon.awssdk - netty-nio-client - ${aws.version} - + apache-client + software.amazon.awssdk + ${aws.version} + commons-logging commons-logging diff --git a/adapters/klab.ogc/src/main/java/org/integratedmodelling/klab/stac/STACEncoder.java b/adapters/klab.ogc/src/main/java/org/integratedmodelling/klab/stac/STACEncoder.java index 6e1e1af10..091175737 100644 --- a/adapters/klab.ogc/src/main/java/org/integratedmodelling/klab/stac/STACEncoder.java +++ b/adapters/klab.ogc/src/main/java/org/integratedmodelling/klab/stac/STACEncoder.java @@ -56,13 +56,14 @@ import org.opengis.feature.simple.SimpleFeature; import org.opengis.feature.simple.SimpleFeatureType; +import kong.unirest.apache.ApacheClient; import kong.unirest.json.JSONObject; import software.amazon.awssdk.auth.credentials.AwsBasicCredentials; import software.amazon.awssdk.auth.credentials.AwsCredentials; import software.amazon.awssdk.auth.credentials.StaticCredentialsProvider; -import software.amazon.awssdk.http.nio.netty.NettyNioAsyncHttpClient; +import software.amazon.awssdk.http.apache.ApacheHttpClient; import software.amazon.awssdk.regions.Region; -import software.amazon.awssdk.services.s3.S3AsyncClient; +import software.amazon.awssdk.services.s3.S3Client; public class STACEncoder implements IResourceEncoder { @@ -162,7 +163,7 @@ private void sortByDate(List items, IMonitor monitor) { "Ordered STAC items. First: [" + items.get(0).getTimestamp() + "]; Last [" + items.get(items.size() - 1).getTimestamp() + "]"); } - private S3AsyncClient buildS3Client(String bucketRegion) throws IOException { + private S3Client buildS3Client(String bucketRegion) throws IOException { ExternalAuthenticationCredentials awsCredentials = Authentication.INSTANCE.getCredentials(S3URLUtils.AWS_ENDPOINT); AwsCredentials credentials = null; try { @@ -170,8 +171,8 @@ private S3AsyncClient buildS3Client(String bucketRegion) throws IOException { } catch (Exception e) { throw new KlabIOException("Error defining AWS credenetials. " + e.getMessage()); } - return S3AsyncClient.builder() - .httpClient(NettyNioAsyncHttpClient.builder().build()) + return S3Client.builder() + .httpClientBuilder(ApacheHttpClient.builder()) .region(Region.of(bucketRegion)) .credentialsProvider(StaticCredentialsProvider.create(credentials)) .build(); @@ -275,8 +276,7 @@ public void getEncodedData(IResource resource, Map urnParameters if (resource.getParameters().contains("s3BucketRegion")) { String bucketRegion = resource.getParameters().get("s3BucketRegion", String.class); - S3AsyncClient s3Client = buildS3Client(bucketRegion); - // TODO waiting until the library version is updated + S3Client s3Client = buildS3Client(bucketRegion); collection.setS3Client(s3Client); }