update from master
[fanfix.git] / library / WebLibraryServerHtml.java
index e96edef95584b5f18a63f62ab630c75abe92f6b0..8895fb83a07b0eb6ff7116b3998a7a89a2acfb15 100644 (file)
@@ -70,6 +70,13 @@ abstract class WebLibraryServerHtml implements Runnable {
        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);
@@ -166,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)) {
@@ -210,6 +218,8 @@ abstract class WebLibraryServerHtml implements Runnable {
                                                                }
                                                        } 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: "
@@ -256,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.");
@@ -274,6 +282,10 @@ abstract class WebLibraryServerHtml implements Runnable {
                }
        }
 
+       protected void doStop() {
+               server.stop();
+       }
+
        /**
         * The traces handler for this {@link WebLibraryServerHtml}.
         *