X-Git-Url: http://git.nikiroo.be/?a=blobdiff_plain;f=src%2Fbe%2Fnikiroo%2Ffanfix%2Flibrary%2FRemoteLibrary.java;h=3e0e192d1806abb2e7d4bd270f0e808821c20991;hb=cfdaf6052ddc5ca44cf19f1f6d9f154cc8443024;hp=6e3380b4a2239a074c26750436f8abc0df368e12;hpb=651072f36310e996632979953e71275d3cbed5a3;p=nikiroo-utils.git diff --git a/src/be/nikiroo/fanfix/library/RemoteLibrary.java b/src/be/nikiroo/fanfix/library/RemoteLibrary.java index 6e3380b..3e0e192 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,13 +58,11 @@ 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. *

* Note that the key is structured: - * xxx(|yyy|wl)(|rw) + * xxx(|yyy(|wl)(|bl)(|rw) *

* Note that anything before the first pipe (|) character is * considered to be the encryption key, anything after that character is @@ -54,16 +77,16 @@ public class RemoteLibrary extends BasicLibrary { *

  • yyy: the secondary key
  • *
  • rw: flag to allow read and write access if it is not the * default on this server
  • - *
  • wl: flag to allow access to all the stories (bypassing the - * whitelist if it exists)
  • + *
  • bl: flag to bypass the blacklist (if it exists)
  • + *
  • wl: flag to bypass the whitelist if it exists
  • * - * + *

    * Some examples: *