desruisseaux commented on code in PR #40:
URL: https://github.com/apache/sis/pull/40#discussion_r2792595842


##########
endorsed/src/org.apache.sis.cloud.aws/main/org/apache/sis/cloud/aws/s3/FileService.java:
##########
@@ -237,47 +331,96 @@ final class Creator implements Function<String, 
ClientFileSystem> {
      * Removes the given file system from the cache.
      * This method is invoked after the file system has been closed.
      */
-    final void dispose(String identifier) {
+    final void dispose(ClientFileSystemKey identifier) {
         if (identifier == null) {
-            identifier = DEFAULT_ACCESS_KEY;
+            identifier = new ClientFileSystemKey(DEFAULT_ACCESS_KEY, 
DEFAULT_HOST_KEY, DEFAULT_PORT_KEY, DEFAULT_IS_HTTPS);
         }
         fileSystems.remove(identifier);
     }
 
     /**
-     * Returns the file system associated to the {@link #DEFAULT_ACCESS_KEY}.
+     * Returns the file system associated to the {@link #DEFAULT_ACCESS_KEY}, 
{@link #DEFAULT_HOST_KEY}, {@link #DEFAULT_PORT_KEY} and {@link 
#DEFAULT_IS_HTTPS}.
      *
      * @throws SdkException if the file system cannot be created.
      */
     private ClientFileSystem getDefaultFileSystem() {
-        return fileSystems.computeIfAbsent(DEFAULT_ACCESS_KEY, (key) -> new 
ClientFileSystem(this, S3Client.create()));
+        return fileSystems.computeIfAbsent(new 
ClientFileSystemKey(DEFAULT_ACCESS_KEY, DEFAULT_HOST_KEY, DEFAULT_PORT_KEY, 
DEFAULT_IS_HTTPS), (key) -> new ClientFileSystem(this, S3Client.create()));
+    }
+
+    /**
+     * Returns the file system associated to the {@link #DEFAULT_HOST_KEY} and 
{@link #DEFAULT_PORT_KEY}.
+     * @param accessKey     the access key
+     *
+     * @throws SdkException if the file system cannot be created.
+     */
+    private ClientFileSystem getDefaultFileSystem(String accessKey) {
+        return fileSystems.computeIfAbsent(
+                new ClientFileSystemKey(accessKey, DEFAULT_HOST_KEY, 
DEFAULT_PORT_KEY), (key) -> new ClientFileSystem(this, S3Client.create(), 
key.getAccessKey()));
+    }
+
+    /**
+     * Returns the file system associated to the {@link #DEFAULT_ACCESS_KEY}.
+     * @param host          the host
+     * @param port          the port
+     *
+     * @throws SdkException if the file system cannot be created.
+     */
+    private ClientFileSystem getDefaultFileSystem(String host, Integer port) {
+        return fileSystems.computeIfAbsent(
+                new ClientFileSystemKey(DEFAULT_ACCESS_KEY, host, port), (key) 
-> new ClientFileSystem(this, key.getAccessKey(), key.getHost(), key.getPort(), 
key.isHttps()));
+    }
+
+    /**
+     * Returns the file system associated to the {@link #DEFAULT_ACCESS_KEY}.
+     * @param host          the host
+     * @param port          the port
+     * @param isHttps       the protocol
+     *
+     * @throws SdkException if the file system cannot be created.
+     */
+    private ClientFileSystem getDefaultFileSystem(String host, Integer port, 
boolean isHttps) {
+        return fileSystems.computeIfAbsent(
+                new ClientFileSystemKey(DEFAULT_ACCESS_KEY, host, port, 
isHttps), (key) -> new ClientFileSystem(this, key.getAccessKey(), 
key.getHost(), key.getPort(), key.isHttps()));
     }
 
     /**
      * Returns a reference to a file system that was created by the {@link 
#newFileSystem(URI, Map)} method.
      * If the file system has not been created or has been closed,
      * then this method throws {@link FileSystemNotFoundException}.
      *
-     * @param  uri  a <abbr>URI</abbr> of the form {@code 
"s3://accessKey@bucket/file"}.
+     * @param  uri  a <abbr>URI</abbr> of the form {@code 
"s3://accessKey@bucket/file"} or {@code "s3://accessKey@host:port/bucket/key"}.
      * @return the file system previously created by {@link 
#newFileSystem(URI, Map)}.
      * @throws IllegalArgumentException if the URI is not supported by this 
provider.
      * @throws FileSystemNotFoundException if the file system does not exist 
or has been closed.
      */
     @Override
     public FileSystem getFileSystem(final URI uri) {
         final String accessKey = getAccessKey(uri);
-        if (accessKey == null) {
+        final String host = uri.getHost();
+        final int port = uri.getPort();
+
+        //No access key, but host and port are defined => Self Hosted

Review Comment:
   Space after `//`. More inside the `if` block for making more obvious that we 
are in this case (after the `if` has been verified). Remove blank lines.



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