+ public synchronized void delete(final String luid) throws IOException {
+ connectRemoteAction(new RemoteAction() {
+ @Override
+ public void action(ConnectActionClientObject action)
+ throws Exception {
+ action.send(new Object[] { subkey, "DELETE_STORY", luid });
+ }
+ });
+ }
+
+ @Override
+ 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)
+ throws IOException {
+ setCover(author, luid, "AUTHOR");
+ }
+
+ // type = "SOURCE" | "AUTHOR"
+ private void setCover(final String value, final String luid,
+ final String type) throws IOException {
+ connectRemoteAction(new RemoteAction() {
+ @Override
+ public void action(ConnectActionClientObject action)
+ throws Exception {
+ action.send(new Object[] { subkey, "SET_COVER", type, value,
+ luid });
+ }
+ });
+ }
+
+ @Override
+ // Could work (more slowly) without it
+ public MetaData imprt(final URL url, Progress pg) throws IOException {
+ // Import the file locally if it is actually a file
+
+ if (url == null || url.getProtocol().equalsIgnoreCase("file")) {
+ return super.imprt(url, pg);
+ }
+
+ // Import it remotely if it is an URL
+
+ if (pg == null) {
+ pg = new Progress();
+ }
+
+ final Progress pgF = pg;
+ final String[] luid = new String[1];
+
+ connectRemoteAction(new RemoteAction() {
+ @Override
+ public void action(ConnectActionClientObject action)
+ throws Exception {
+ Progress pg = pgF;
+
+ Object rep = action.send(new Object[] { subkey, "IMPORT",
+ url.toString() });
+
+ while (true) {
+ if (!RemoteLibraryServer.updateProgress(pg, rep)) {
+ break;
+ }
+
+ rep = action.send(null);
+ }
+
+ pg.done();
+ luid[0] = (String) rep;
+ }
+ });
+
+ if (luid[0] == null) {
+ throw new IOException("Remote failure");
+ }
+
+ pg.done();
+ return getInfo(luid[0]);
+ }
+
+ @Override
+ // Could work (more slowly) without it
+ protected synchronized void changeSTA(final String luid,
+ final String newSource, final String newTitle,
+ final String newAuthor, Progress pg) throws IOException {
+
+ final Progress pgF = pg == null ? new Progress() : pg;
+
+ connectRemoteAction(new RemoteAction() {
+ @Override
+ public void action(ConnectActionClientObject action)
+ throws Exception {
+ Progress pg = pgF;
+
+ Object rep = action.send(new Object[] { subkey, "CHANGE_STA",
+ luid, newSource, newTitle, newAuthor });
+ while (true) {
+ if (!RemoteLibraryServer.updateProgress(pg, rep)) {
+ break;
+ }
+
+ rep = action.send(null);
+ }
+ }
+ });