Make A2 API more public.
[lgpl/argeo-commons.git] / org.argeo.init / src / org / argeo / init / a2 / FsA2Source.java
index 067537d5911d24bddd7fe8fa2bec73688bcc85de..eb00659dcb4b7db84d381a1d5f86642a6c8d215f 100644 (file)
@@ -1,6 +1,8 @@
 package org.argeo.init.a2;
 
 import java.io.IOException;
+import java.net.URI;
+import java.net.URISyntaxException;
 import java.nio.file.DirectoryStream;
 import java.nio.file.Files;
 import java.nio.file.Path;
@@ -16,7 +18,6 @@ public class FsA2Source extends AbstractProvisioningSource implements A2Source {
        private final Path base;
 
        public FsA2Source(Path base) {
-               super();
                this.base = base;
        }
 
@@ -75,6 +76,20 @@ public class FsA2Source extends AbstractProvisioningSource implements A2Source {
 
        }
 
+       @Override
+       public URI getUri() {
+               URI baseUri = base.toUri();
+               try {
+                       if (baseUri.getScheme().equals("file")) {
+                               return new URI(SCHEME_A2, null, base.toString(), null);
+                       } else {
+                               throw new UnsupportedOperationException("Unsupported scheme " + baseUri.getScheme());
+                       }
+               } catch (URISyntaxException e) {
+                       throw new IllegalStateException("Cannot build URI from " + baseUri, e);
+               }
+       }
+
        public static void main(String[] args) {
                try {
                        FsA2Source context = new FsA2Source(Paths.get(