diff --git a/extension/src/main/java/io/xpipe/extension/DataStoreProvider.java b/extension/src/main/java/io/xpipe/extension/DataStoreProvider.java index f07ff5869..3f9d14310 100644 --- a/extension/src/main/java/io/xpipe/extension/DataStoreProvider.java +++ b/extension/src/main/java/io/xpipe/extension/DataStoreProvider.java @@ -1,10 +1,12 @@ package io.xpipe.extension; import io.xpipe.core.dialog.Dialog; -import io.xpipe.core.store.*; +import io.xpipe.core.store.DataStore; +import io.xpipe.core.store.MachineFileStore; +import io.xpipe.core.store.ShellStore; +import io.xpipe.core.store.StreamDataStore; import javafx.beans.property.Property; -import java.net.URI; import java.util.List; public interface DataStoreProvider { @@ -74,10 +76,6 @@ public interface DataStoreProvider { return null; } - default Dialog dialogForURI(URI uri) { - return null; - } - default Dialog defaultDialog() { throw new ExtensionException("CLI Dialog not implemented by provider"); } diff --git a/extension/src/main/java/io/xpipe/extension/DataStoreProviders.java b/extension/src/main/java/io/xpipe/extension/DataStoreProviders.java index 247cf05dd..f54d62e6c 100644 --- a/extension/src/main/java/io/xpipe/extension/DataStoreProviders.java +++ b/extension/src/main/java/io/xpipe/extension/DataStoreProviders.java @@ -4,7 +4,6 @@ import io.xpipe.core.dialog.Dialog; import io.xpipe.core.store.DataStore; import io.xpipe.extension.event.ErrorEvent; -import java.net.URI; import java.util.Objects; import java.util.Optional; import java.util.ServiceLoader; @@ -19,11 +18,12 @@ public class DataStoreProviders { if (ALL == null) { ALL = ServiceLoader.load(layer, DataStoreProvider.class).stream() .map(ServiceLoader.Provider::get).collect(Collectors.toSet()); - ALL.forEach(p -> { + ALL.removeIf(p -> { try { - p.init(); + return !p.init(); } catch (Exception e) { ErrorEvent.fromThrowable(e).handle(); + return true; } }); } @@ -38,13 +38,6 @@ public class DataStoreProviders { .anyMatch(s -> s.equalsIgnoreCase(name))).findAny(); } - public static Optional byURI(URI uri) { - if (ALL == null) { - throw new IllegalStateException("Not initialized"); - } - - return ALL.stream().map(d -> d.dialogForURI(uri)).filter(Objects::nonNull).findAny(); - } public static Optional byString(String s) { if (ALL == null) { @@ -56,17 +49,16 @@ public class DataStoreProviders { public static T byStore(DataStore store) { - return byStoreClass(store.getClass()); + return (T) byStoreClass(store.getClass()).orElseThrow(() -> new IllegalArgumentException("Provider for " + store.getClass().getSimpleName() + " not found")); } @SuppressWarnings("unchecked") - public static T byStoreClass(Class c) { + public static Optional byStoreClass(Class c) { if (ALL == null) { throw new IllegalStateException("Not initialized"); } - return (T) ALL.stream().filter(d -> d.getStoreClasses().contains(c)).findAny() - .orElseThrow(() -> new IllegalArgumentException("Provider for " + c.getSimpleName() + " not found")); + return (Optional) ALL.stream().filter(d -> d.getStoreClasses().contains(c)).findAny(); } public static Set getAll() { diff --git a/misc/version b/misc/version index dc9a74edd..a5fb8d5df 100644 --- a/misc/version +++ b/misc/version @@ -1 +1 @@ -0.0.1.3 \ No newline at end of file +0.0.1.4-SNAPSHOT \ No newline at end of file