X-Git-Url: http://git.nikiroo.be/?a=blobdiff_plain;f=src%2Fbe%2Fnikiroo%2Ffanfix%2Flibrary%2FRemoteLibrary.java;h=9fa8c66190174bd1a92536b995d181a16bc8744a;hb=f433d15308b70e23280a65cef8c54002a7a971ce;hp=e7b98282b422786eb95a077056a987039984cbfd;hpb=fb25273cf02653ac343d5437083b1bc41af5ce23;p=nikiroo-utils.git diff --git a/src/be/nikiroo/fanfix/library/RemoteLibrary.java b/src/be/nikiroo/fanfix/library/RemoteLibrary.java index e7b9828..9fa8c66 100644 --- a/src/be/nikiroo/fanfix/library/RemoteLibrary.java +++ b/src/be/nikiroo/fanfix/library/RemoteLibrary.java @@ -21,10 +21,35 @@ import be.nikiroo.utils.serial.server.ConnectActionClientObject; * This {@link BasicLibrary} will access a remote server to list the available * stories, and download the ones you try to load to the local directory * specified in the configuration. + *

+ * This remote library uses a custom fanfix:// protocol. * * @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 +58,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 +80,7 @@ public class RemoteLibrary extends BasicLibrary { *

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

    * Some examples: *