package de.bornemisza.rest;

import java.util.List;
import java.util.Map;
import java.util.logging.Logger;

import org.javalite.http.Post;

public class HealthChecks {

    public boolean isCouchDbReady(Http http) {
        try {
            Post post = http.post("");
            Map<String, List<String>> headers = post.headers();
            List<String> header = headers.get("Server");
            return header != null && !header.isEmpty() && header.get(0).startsWith("CouchDB");
        }
        catch (Exception e) {
            Logger.getAnonymousLogger().warning("CouchDB not ready: " + e.toString());
            return false;
        }
    }

}

@@ -399,34 +399,30 @@
     
-return 
+if (
 header 
-!
+=
 = null 
-&& !
+%7C%7C 
 head
@@ -437,48 +437,360 @@
 ty()
- && header.get(0).startsWith(%22CouchDB%22);
+) %7B%0A                Logger.getAnonymousLogger().warning(%22Health Check failed: No Header%22);%0A                return false;%0A            %7D%0A            else if (header.get(0).startsWith(%22CouchDB%22)) return true;%0A            else %7B%0A                Logger.getAnonymousLogger(%22Health Check failed: %22 + header.get(0));%0A                return false;%0A            %7D
 %0A   

introduce some logging