X-Git-Url: http://git.nikiroo.be/?p=nikiroo-utils.git;a=blobdiff_plain;f=library%2FWebLibrary.java;h=9af38e2b6bd1c7ccb565ca6f244e31ef42f40746;hp=ac1349e7ac51b3015050a4725a28265ef13a211a;hb=258e065f81071a861711ef935dca3ec5563f4360;hpb=159e970c23d9634d39bb8cf2a194f7088f4d59ab diff --git a/library/WebLibrary.java b/library/WebLibrary.java index ac1349e..9af38e2 100644 --- a/library/WebLibrary.java +++ b/library/WebLibrary.java @@ -126,6 +126,26 @@ public class WebLibrary extends BasicLibrary { return new Version(); } + /** + * Stop the server. + * + * @throws IOException + * in case of I/O errors + */ + public void stop() throws IOException { + try { + post(WebLibraryUrls.EXIT_URL, null).close(); + } catch (Exception e) { + try { + Thread.sleep(200); + } catch (InterruptedException e1) { + } + if (getStatus() != Status.UNAVAILABLE) { + throw new IOException("Cannot exit the library", e); + } + } + } + @Override public Status getStatus() { try { @@ -154,6 +174,7 @@ public class WebLibrary extends BasicLibrary { try { Image img = new Image(in); if (img.getSize() > 0) { + img.close(); return img; } @@ -169,6 +190,7 @@ public class WebLibrary extends BasicLibrary { try { Image img = new Image(in); if (img.getSize() > 0) { + img.close(); return img; } @@ -184,6 +206,7 @@ public class WebLibrary extends BasicLibrary { try { Image img = new Image(in); if (img.getSize() > 0) { + img.close(); return img; } @@ -309,6 +332,9 @@ public class WebLibrary extends BasicLibrary { try { subPg = JsonIO.toProgress( new JSONObject(IOUtils.readSmallStream(in))); + pg.setName(subPg.getName()); + pg.setMinMax(subPg.getMin(), subPg.getMax()); + pg.setProgress(subPg.getProgress()); } catch (Exception e) { subPg = null; } finally { @@ -353,6 +379,11 @@ public class WebLibrary extends BasicLibrary { } } + @Override + public synchronized void delete(String luid) throws IOException { + post(WebLibraryUrls.getDeleteUrlStory(luid), null).close(); + } + @Override protected void updateInfo(MetaData meta) { // Will be taken care of directly server side