Small fixes

This commit is contained in:
Christopher Schnick
2022-01-02 23:13:10 +01:00
parent 8bb6f8be3d
commit e5a84a83db
15 changed files with 120 additions and 37 deletions

View File

@@ -1,6 +1,7 @@
package io.xpipe.api;
import io.xpipe.beacon.*;
import io.xpipe.core.util.JacksonHelper;
import java.util.Optional;
@@ -10,14 +11,8 @@ public abstract class XPipeApiConnector extends BeaconConnector {
try {
var socket = constructSocket();
handle(socket);
} catch (ConnectorException ce) {
throw new XPipeConnectException(ce.getMessage());
} catch (ClientException ce) {
throw new XPipeClientException(ce.getMessage());
} catch (ServerException se) {
throw new XPipeServerException(se.getMessage());
} catch (Throwable t) {
throw new XPipeConnectException(t);
} catch (Throwable ce) {
throw new XPipeException(ce);
}
}
@@ -25,6 +20,10 @@ public abstract class XPipeApiConnector extends BeaconConnector {
@Override
protected BeaconClient constructSocket() throws ConnectorException {
if (!JacksonHelper.isInit()) {
JacksonHelper.init(ModuleLayer.boot());
}
if (!BeaconServer.isRunning()) {
try {
start();

View File

@@ -0,0 +1,23 @@
package io.xpipe.api;
public class XPipeException extends RuntimeException {
public XPipeException() {
}
public XPipeException(String message) {
super(message);
}
public XPipeException(String message, Throwable cause) {
super(message, cause);
}
public XPipeException(Throwable cause) {
super(cause);
}
public XPipeException(String message, Throwable cause, boolean enableSuppression, boolean writableStackTrace) {
super(message, cause, enableSuppression, writableStackTrace);
}
}

View File

@@ -46,8 +46,13 @@ public abstract class DataSourceImpl implements DataSource {
@Override
protected void handle(BeaconClient sc) throws ClientException, ServerException, ConnectorException {
var req = StoreResourceExchange.Request.builder()
.url(url).type(type).build();
StoreResourceExchange.Response res = performSimpleExchange(sc, req);
.url(url).providerId(type).build();
StoreResourceExchange.Response res = performOutputExchange(sc, req, out -> {
try (var s = url.openStream()) {
writeLength(sc, s.available());
s.transferTo(out);
}
});
switch (res.getSourceType()) {
case TABLE -> {
var data = res.getTableData();