X-Git-Url: http://git.nikiroo.be/?a=blobdiff_plain;f=src%2Fbe%2Fnikiroo%2Ffanfix%2Flibrary%2FRemoteLibrary.java;h=bbe772a8c90168c658fa985461e92c58f13bb8d0;hb=a97f9702eae2b51ee64a163f92ec4d72a216e958;hp=e7b98282b422786eb95a077056a987039984cbfd;hpb=fb25273cf02653ac343d5437083b1bc41af5ce23;p=fanfix.git diff --git a/src/be/nikiroo/fanfix/library/RemoteLibrary.java b/src/be/nikiroo/fanfix/library/RemoteLibrary.java index e7b9828..bbe772a 100644 --- a/src/be/nikiroo/fanfix/library/RemoteLibrary.java +++ b/src/be/nikiroo/fanfix/library/RemoteLibrary.java @@ -25,6 +25,29 @@ import be.nikiroo.utils.serial.server.ConnectActionClientObject; * @author niki */ public class RemoteLibrary extends BasicLibrary { + interface RemoteAction { + public void action(ConnectActionClientObject action) throws Exception; + } + + class RemoteConnectAction extends ConnectActionClientObject { + public RemoteConnectAction() throws IOException { + super(host, port, key); + } + + @Override + public Object send(Object data) throws IOException, + NoSuchFieldException, NoSuchMethodException, + ClassNotFoundException { + Object rep = super.send(data); + if (rep instanceof RemoteLibraryException) { + RemoteLibraryException remoteEx = (RemoteLibraryException) rep; + throw remoteEx.unwrapException(); + } + + return rep; + } + } + private String host; private int port; private final String key; @@ -33,8 +56,6 @@ public class RemoteLibrary extends BasicLibrary { // informative only (server will make the actual checks) private boolean rw; - // TODO: error handling is not up to par! - /** * Create a {@link RemoteLibrary} linked to the given server. *

@@ -57,7 +78,7 @@ public class RemoteLibrary extends BasicLibrary { *

  • wl: flag to allow access to all the stories (bypassing the * whitelist if it exists)
  • * - * + *

    * Some examples: *