- public synchronized Story save(Story story, String luid, Progress pg)
- throws IOException {
- getRemoteObject(new Object[] { key, "SAVE_STORY", story, luid });
+ public synchronized Story save(final Story story, final String luid,
+ Progress pg) throws IOException {
+ final String[] luidSaved = new String[1];
+ Progress pgSave = new Progress();
+ Progress pgRefresh = new Progress();
+ if (pg == null) {
+ pg = new Progress();
+ }
+
+ pg.setMinMax(0, 10);
+ pg.addProgress(pgSave, 9);
+ pg.addProgress(pgRefresh, 1);
+
+ final Progress pgF = pgSave;
+
+ new ConnectActionClientObject(host, port, true) {
+ @Override
+ public void action(Version serverVersion) throws Exception {
+ Progress pg = pgF;
+ if (story.getMeta().getWords() <= Integer.MAX_VALUE) {
+ pg.setMinMax(0, (int) story.getMeta().getWords());
+ }
+
+ send(new Object[] { md5, "SAVE_STORY", luid });
+
+ List<Object> list = RemoteLibraryServer.breakStory(story);
+ for (Object obj : list) {
+ send(obj);
+ pg.add(1);
+ }
+
+ luidSaved[0] = (String) send(null);
+
+ pg.done();
+ }
+
+ @Override
+ protected void onError(Exception e) {
+ Instance.getTraceHandler().error(e);
+ }
+ }.connect();