package org.jivesoftware.openfire.container;

import java.io.BufferedReader;
import java.io.IOException;

import javax.servlet.ServletConfig;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.jivesoftware.openfire.BootstrapProcessor;
import org.jivesoftware.openfire.BootstrapProperties;
import org.jivesoftware.util.JiveGlobals;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.google.gson.Gson;

public class BootstrapServlet extends HttpServlet {
    
	private static final Logger Log = LoggerFactory.getLogger(BootstrapServlet.class);
	
	@Override
	public void init(ServletConfig config) throws ServletException {
        super.init(config);
    }

	@Override
	public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		if (!"true".equals(JiveGlobals.getXMLProperty("setup"))) {
			BufferedReader reader = request.getReader();
			Gson gson = new Gson();
			BootstrapProperties bootsrapProperties = gson.fromJson(reader, BootstrapProperties.class);
			Log.debug("doPost : bootsrapProperties={}", bootsrapProperties);
			BootstrapProcessor bootstrapProcessor = new BootstrapProcessor(bootsrapProperties);
			bootstrapProcessor.bootstrap();
			response.setStatus(HttpServletResponse.SC_CREATED);
			return;
		}
		Log.debug("doPost : Server is already setup, ignoring...");
		response.setStatus(HttpServletResponse.SC_OK);
	}
}

@@ -1531,10 +1531,806 @@
 OK);%0A%09%7D%0A
+%09%0A%09@Override%0A%09public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException %7B%0A%09%09Gson gson = new Gson();%0A%09%09String jsonString = null;%0A%09%09if(%22true%22.equals(JiveGlobals.getXMLProperty(%22setup%22))) %7B%0A%09%09%09jsonString = gson.toJson(new Setup(true));%0A%09%09%7D else %7B%0A%09%09%09jsonString = gson.toJson(new Setup(false));%09%09%0A%09%09%7D%0A%09%09Log.debug(%22doGet : Returning setupStatus : %7B%7D%22, jsonString);%0A%09%09response.setContentType(%22application/json%22);%0A%09%09response.getWriter().write(jsonString);%0A%09%09response.setStatus(HttpServletResponse.SC_OK);%0A%09%7D%0A%09%0A%09public static class Setup %7B%0A%09  %09private boolean setupComplete;%0A%09  %09%0A%09%09public Setup(boolean setupComplete) %7B%0A%09%09%09super();%0A%09%09%09this.setupComplete = setupComplete;%0A%09%09%7D%0A%0A%09%09public boolean isSetupComplete() %7B%0A%09%09%09return setupComplete;%0A%09%09%7D%09  %09%0A%09%7D%0A
 %7D%0A

Add utility api for Edward