Various small fixes

This commit is contained in:
Christopher Schnick
2022-12-23 10:29:08 +01:00
parent 71b5d2d716
commit 9a2a1a8745
18 changed files with 415 additions and 137 deletions
@@ -1,5 +1,9 @@
package io.xpipe.beacon;
import io.xpipe.beacon.exchange.cli.StoreAddExchange;
import io.xpipe.beacon.util.QuietDialogHandler;
import io.xpipe.core.impl.InternalStreamStore;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
@@ -169,6 +173,14 @@ public abstract class BeaconConnection implements AutoCloseable {
}
}
public InternalStreamStore createInternalStreamStore() {
var store = new InternalStreamStore();
var addReq = StoreAddExchange.Request.builder().storeInput(store).name(store.getUuid().toString()).build();
StoreAddExchange.Response addRes = performSimpleExchange(addReq);
QuietDialogHandler.handle(addRes.getConfig(), this);
return store;
}
private BeaconException unwrapException(Exception exception) {
if (exception instanceof ServerException s) {
return new BeaconException("An internal server error occurred", s);
@@ -1,31 +0,0 @@
package io.xpipe.beacon.exchange;
import io.xpipe.beacon.RequestMessage;
import io.xpipe.beacon.ResponseMessage;
import io.xpipe.core.impl.FileStore;
import lombok.Builder;
import lombok.Value;
import lombok.extern.jackson.Jacksonized;
/**
* Stores a stream of data in a storage.
*/
public class StoreStreamExchange implements MessageExchange {
@Override
public String getId() {
return "storeStream";
}
@Jacksonized
@Builder
@Value
public static class Request implements RequestMessage {}
@Jacksonized
@Builder
@Value
public static class Response implements ResponseMessage {
FileStore store;
}
}
@@ -1,7 +1,7 @@
package io.xpipe.beacon.util;
import io.xpipe.beacon.BeaconConnection;
import io.xpipe.beacon.ClientException;
import io.xpipe.beacon.BeaconException;
import io.xpipe.beacon.exchange.cli.DialogExchange;
import io.xpipe.core.dialog.BaseQueryElement;
import io.xpipe.core.dialog.ChoiceElement;
@@ -13,7 +13,7 @@ import java.util.UUID;
public class QuietDialogHandler {
public static void handle(DialogReference ref, BeaconConnection connection) throws ClientException {
public static void handle(DialogReference ref, BeaconConnection connection) {
new QuietDialogHandler(ref, connection, Map.of()).handle();
}
@@ -29,7 +29,7 @@ public class QuietDialogHandler {
this.overrides = overrides;
}
public void handle() throws ClientException {
public void handle() {
String response = null;
if (element instanceof ChoiceElement c) {
@@ -45,7 +45,7 @@ public class QuietDialogHandler {
.value(response)
.build());
if (res.getElement() != null && element.equals(res.getElement())) {
throw new ClientException(
throw new BeaconException(
"Invalid value for key " + res.getElement().toDisplayString());
}
-1
View File
@@ -62,7 +62,6 @@ module io.xpipe.beacon {
ListStoresExchange,
DialogExchange,
QueryDataSourceExchange,
StoreStreamExchange,
EditExchange,
RemoveEntryExchange,
RemoveCollectionExchange,