X-Git-Url: http://git.nikiroo.be/?p=fanfix.git;a=blobdiff_plain;f=library%2FWebLibraryServerHtml.java;h=8895fb83a07b0eb6ff7116b3998a7a89a2acfb15;hp=a534b4cdafbbdd8ec1c4c6b373bb7fc2953ec58c;hb=002972e9de731678035d56304d75a6d9e8233635;hpb=4536c5cf2d7b8e68768f90d281b3e4974cd26ae9 diff --git a/library/WebLibraryServerHtml.java b/library/WebLibraryServerHtml.java index a534b4c..8895fb8 100644 --- a/library/WebLibraryServerHtml.java +++ b/library/WebLibraryServerHtml.java @@ -67,6 +67,16 @@ abstract class WebLibraryServerHtml implements Runnable { protected abstract Response imprtProgress(String uri, WLoginResult login); + protected abstract Response delete(String uri, WLoginResult login) + throws IOException; + + /** + * Wait until all operations are done and stop the server. + *

+ * All the new R/W operations will be refused after a call to stop. + */ + protected abstract Response stop(WLoginResult login); + public WebLibraryServerHtml(boolean secure) throws IOException { Integer port = Instance.getInstance().getConfig() .getInteger(Config.SERVER_PORT); @@ -163,13 +173,14 @@ abstract class WebLibraryServerHtml implements Runnable { } Response rep = null; - if (!login.isSuccess() && WebLibraryUrls.isSupportedUrl(uri)) { + if (!login.isSuccess() + && WebLibraryUrls.isSupportedUrl(uri, true)) { rep = loginPage(login, uri); } if (rep == null) { try { - if (WebLibraryUrls.isSupportedUrl(uri)) { + if (WebLibraryUrls.isSupportedUrl(uri, false)) { if (WebLibraryUrls.INDEX_URL.equals(uri)) { rep = root(session, cookies, login); } else if (WebLibraryUrls.VERSION_URL.equals(uri)) { @@ -205,6 +216,10 @@ abstract class WebLibraryServerHtml implements Runnable { } else { rep = imprtProgress(uri, login); } + } else if (WebLibraryUrls.isDeleteUrl(uri)) { + rep = delete(uri, login); + } else if (WebLibraryUrls.EXIT_URL.equals(uri)) { + rep = WebLibraryServerHtml.this.stop(login); } else { getTraceHandler().error( "Supported URL was not processed: " @@ -251,9 +266,7 @@ abstract class WebLibraryServerHtml implements Runnable { } }; - if (ssf != null) - - { + if (ssf != null) { getTraceHandler().trace("Install SSL on the web server..."); server.makeSecure(ssf, null); getTraceHandler().trace("Done."); @@ -269,6 +282,10 @@ abstract class WebLibraryServerHtml implements Runnable { } } + protected void doStop() { + server.stop(); + } + /** * The traces handler for this {@link WebLibraryServerHtml}. *