This is an automated email from the ASF dual-hosted git repository. desruisseaux pushed a commit to branch geoapi-4.0 in repository https://gitbox.apache.org/repos/asf/sis.git
commit 11790ff20eef0f5fc7017f6270fbf3b78de6b8e0 Author: Martin Desruisseaux <martin.desruisse...@geomatys.com> AuthorDate: Fri Dec 20 10:41:53 2024 +0100 Accept also regions encoded as character strings instead of as an instance of the Region class. --- .../main/org/apache/sis/cloud/aws/s3/FileService.java | 16 ++++++++++++---- .../org/apache/sis/cloud/aws/s3/ObjectAttributes.java | 5 ++--- .../main/org/apache/sis/cloud/aws/s3/package-info.java | 2 +- 3 files changed, 15 insertions(+), 8 deletions(-) diff --git a/endorsed/src/org.apache.sis.cloud.aws/main/org/apache/sis/cloud/aws/s3/FileService.java b/endorsed/src/org.apache.sis.cloud.aws/main/org/apache/sis/cloud/aws/s3/FileService.java index d9a982e2c5..210c84bacc 100644 --- a/endorsed/src/org.apache.sis.cloud.aws/main/org/apache/sis/cloud/aws/s3/FileService.java +++ b/endorsed/src/org.apache.sis.cloud.aws/main/org/apache/sis/cloud/aws/s3/FileService.java @@ -75,7 +75,7 @@ import org.apache.sis.util.collection.Containers; * instead of the data to access, and can be a global configuration for the server. * * @author Martin Desruisseaux (Geomatys) - * @version 1.4 + * @version 1.5 * @since 1.2 */ public class FileService extends FileSystemProvider { @@ -109,7 +109,8 @@ public class FileService extends FileSystemProvider { /** * The property for the secret access key (password). - * Values shall be instances of {@link Region}. + * Values shall should be instances of {@link Region} or + * strings {@linkplain Region#of(String) convertible} to region. * If not specified, the AWS SDK default mechanism searches for the first of the following: * * <ul> @@ -188,7 +189,8 @@ public class FileService extends FileSystemProvider { * * <ul> * <li>{@value #AWS_SECRET_ACCESS_KEY} with {@link String} value.</li> - * <li>{@value #AWS_REGION} with {@link Region} value.</li> + * <li>{@value #AWS_REGION} with {@link Region} value or a string + * {@linkplain Region#of(String) convertible} to region.</li> * </ul> * * @param uri a URI of the form {@code "s3://accessKey@bucket/key"}. @@ -207,7 +209,13 @@ public class FileService extends FileSystemProvider { throw new IllegalArgumentException(Resources.format(Resources.Keys.MissingAccessKey_2, (accessKey == null) ? 0 : 1, uri)); } final String separator = Containers.property(properties, SEPARATOR, String.class); - final Region region = Containers.property(properties, AWS_REGION, Region.class); + final Region region; + Object value = properties.get(AWS_REGION); + if (value instanceof String) { + region = Region.of((String) value); + } else { + region = Containers.property(properties, AWS_REGION, Region.class); + } final class Creator implements Function<String, ClientFileSystem> { /** Identifies if a new file system is created. */ boolean created; diff --git a/endorsed/src/org.apache.sis.cloud.aws/main/org/apache/sis/cloud/aws/s3/ObjectAttributes.java b/endorsed/src/org.apache.sis.cloud.aws/main/org/apache/sis/cloud/aws/s3/ObjectAttributes.java index 27b71256bb..de31ea55a6 100644 --- a/endorsed/src/org.apache.sis.cloud.aws/main/org/apache/sis/cloud/aws/s3/ObjectAttributes.java +++ b/endorsed/src/org.apache.sis.cloud.aws/main/org/apache/sis/cloud/aws/s3/ObjectAttributes.java @@ -252,8 +252,7 @@ final class ObjectAttributes implements BasicFileAttributeView { String[] keys = (String[]) CharSequences.split(attributes, ','); boolean isBasic = true; int count = 0; - for (int i=0; i<keys.length; i++) { - String key = keys[i]; + for (final String key : keys) { final int s = key.indexOf(':'); if (s >= 0) { isBasic = NAME.regionMatches(true, 0, key, 0, s); @@ -271,7 +270,7 @@ final class ObjectAttributes implements BasicFileAttributeView { /* * Now copy in the map all requested attributes. */ - final Map<String,Object> map = new HashMap<>(8); + final var map = new HashMap<String,Object>(8); for (final String key : keys) { final Object value; switch (key) { diff --git a/endorsed/src/org.apache.sis.cloud.aws/main/org/apache/sis/cloud/aws/s3/package-info.java b/endorsed/src/org.apache.sis.cloud.aws/main/org/apache/sis/cloud/aws/s3/package-info.java index 619a9bac6b..62ea6f97c0 100644 --- a/endorsed/src/org.apache.sis.cloud.aws/main/org/apache/sis/cloud/aws/s3/package-info.java +++ b/endorsed/src/org.apache.sis.cloud.aws/main/org/apache/sis/cloud/aws/s3/package-info.java @@ -49,7 +49,7 @@ * All classes provided by this package are safe of usage in multi-threading environment. * * @author Martin Desruisseaux (Geomatys) - * @version 1.4 + * @version 1.5 * * @see <a href="https://sdk.amazonaws.com/java/api/latest/index.html">AWS SDK for Java</a> *