update from master
[fanfix.git] / library / WebLibraryServerHtml.java
index a534b4cdafbbdd8ec1c4c6b373bb7fc2953ec58c..8895fb83a07b0eb6ff7116b3998a7a89a2acfb15 100644 (file)
@@ -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.
+        * <p>
+        * 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}.
         *