X-Git-Url: http://git.nikiroo.be/?a=blobdiff_plain;f=src%2Fbe%2Fnikiroo%2Ffanfix%2Flibrary%2FRemoteLibrary.java;h=a6c68546882c0cdd64bda6c7592976d228bdfb4d;hb=e64228f886196dd1ad602c46c8b2604b5b0558c9;hp=077a857cf9a748ddbd242b1af625b853ecf6d75e;hpb=5db598bc6386aaabe69f2eed55b03625c72c236b;p=fanfix.git diff --git a/src/be/nikiroo/fanfix/library/RemoteLibrary.java b/src/be/nikiroo/fanfix/library/RemoteLibrary.java index 077a857..a6c6854 100644 --- a/src/be/nikiroo/fanfix/library/RemoteLibrary.java +++ b/src/be/nikiroo/fanfix/library/RemoteLibrary.java @@ -41,12 +41,7 @@ public class RemoteLibrary extends BasicLibrary { Object rep = super.send(data); if (rep instanceof RemoteLibraryException) { RemoteLibraryException remoteEx = (RemoteLibraryException) rep; - IOException cause = remoteEx.getCause(); - if (cause == null) { - cause = new IOException("IOException"); - } - - throw cause; + throw remoteEx.unwrapException(); } return rep; @@ -61,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. *
@@ -126,7 +119,7 @@ public class RemoteLibrary extends BasicLibrary {
@Override
public String getLibraryName() {
- return host + ":" + port;
+ return (rw ? "[READ-ONLY] " : "") + host + ":" + port;
}
@Override
@@ -150,10 +143,10 @@ public class RemoteLibrary extends BasicLibrary {
if ("r/w".equals(rep)) {
rw = true;
- result[0] = Status.READY;
+ result[0] = Status.READ_WRITE;
} else if ("r/o".equals(rep)) {
rw = false;
- result[0] = Status.READY;
+ result[0] = Status.READ_ONLY;
} else {
result[0] = Status.UNAUTHORIZED;
}
@@ -180,7 +173,7 @@ public class RemoteLibrary extends BasicLibrary {
}
@Override
- public Image getCover(final String luid) {
+ public Image getCover(final String luid) throws IOException {
final Image[] result = new Image[1];
connectRemoteAction(new RemoteAction() {
@@ -197,17 +190,18 @@ public class RemoteLibrary extends BasicLibrary {
}
@Override
- public Image getCustomSourceCover(final String source) {
+ public Image getCustomSourceCover(final String source) throws IOException {
return getCustomCover(source, "SOURCE");
}
@Override
- public Image getCustomAuthorCover(final String author) {
+ public Image getCustomAuthorCover(final String author) throws IOException {
return getCustomCover(author, "AUTHOR");
}
// type: "SOURCE" or "AUTHOR"
- private Image getCustomCover(final String source, final String type) {
+ private Image getCustomCover(final String source, final String type)
+ throws IOException {
final Image[] result = new Image[1];
connectRemoteAction(new RemoteAction() {
@@ -224,7 +218,8 @@ public class RemoteLibrary extends BasicLibrary {
}
@Override
- public synchronized Story getStory(final String luid, Progress pg) {
+ public synchronized Story getStory(final String luid, Progress pg)
+ throws IOException {
final Progress pgF = pg;
final Story[] result = new Story[1];
@@ -331,18 +326,20 @@ public class RemoteLibrary extends BasicLibrary {
}
@Override
- public void setSourceCover(final String source, final String luid) {
+ public void setSourceCover(final String source, final String luid)
+ throws IOException {
setCover(source, luid, "SOURCE");
}
@Override
- public void setAuthorCover(final String author, final String luid) {
+ public void setAuthorCover(final String author, final String luid)
+ throws IOException {
setCover(author, luid, "AUTHOR");
}
// type = "SOURCE" | "AUTHOR"
private void setCover(final String value, final String luid,
- final String type) {
+ final String type) throws IOException {
connectRemoteAction(new RemoteAction() {
@Override
public void action(ConnectActionClientObject action)
@@ -444,8 +441,11 @@ public class RemoteLibrary extends BasicLibrary {
/**
* Stop the server.
+ *
+ * @throws IOException
+ * in case of I/O error (including bad key)
*/
- public void exit() {
+ public void exit() throws IOException {
connectRemoteAction(new RemoteAction() {
@Override
public void action(ConnectActionClientObject action)
@@ -456,7 +456,7 @@ public class RemoteLibrary extends BasicLibrary {
}
@Override
- public synchronized MetaData getInfo(String luid) {
+ public synchronized MetaData getInfo(String luid) throws IOException {
List