<commit_before>package codeine;

import java.util.List;

import org.eclipse.jetty.security.ConstraintMapping;
import org.eclipse.jetty.security.ConstraintSecurityHandler;
import org.eclipse.jetty.security.DefaultIdentityService;
import org.eclipse.jetty.security.SpnegoLoginService;
import org.eclipse.jetty.security.authentication.FormAuthenticator;
import org.eclipse.jetty.security.authentication.SpnegoAuthenticator;
import org.eclipse.jetty.server.handler.ContextHandlerCollection;
import org.eclipse.jetty.servlet.ServletContextHandler;
import org.eclipse.jetty.servlet.ServletHolder;
import org.eclipse.jetty.util.security.Constraint;

import codeine.configuration.PathHelper;
import codeine.executer.PeriodicExecuter;
import codeine.jsons.auth.AuthenticationMethod;
import codeine.jsons.global.GlobalConfigurationJsonStore;
import codeine.jsons.peer_status.PeersProjectsStatus;
import codeine.model.Constants;
import codeine.servlet.UsersManager;
import codeine.statistics.IMonitorStatistics;
import codeine.statistics.MonitorsStatistics;
import codeine.users.LogoutServlet;

import com.google.common.collect.Lists;
import com.google.inject.Injector;
import com.google.inject.Module;

public class CodeineWebServerBootstrap extends AbstractCodeineBootstrap
{
	public CodeineWebServerBootstrap(Injector injector) {
		super(injector);
	}

	public CodeineWebServerBootstrap() {
	}

	public static void main(String[] args)
	{
		System.setProperty("org.eclipse.jetty.server.Request.maxFormContentSize", "10000000");
		boot(Component.WEB, CodeineWebServerBootstrap.class);
	}
	
	@Override
	protected void execute() {
		log.info("executing web server bootstrap");
		new PeriodicExecuter(PeersProjectsStatus.SLEEP_TIME ,injector().getInstance(PeersProjectsStatus.class)).runInThread();
		try {
			injector().getInstance(ConfigurationManagerServer.class).updateDb();
		} catch (Exception e) {
			log.error("fail to update projects in db", e);
		}
		new PeriodicExecuter(ProjectConfigurationInPeerUpdater.MAX_SLEEP_TIME_MILLI ,injector().getInstance(ProjectConfigurationInPeerUpdater.class)).runInThread();
		new PeriodicExecuter(MonitorsStatistics.SLEEP_TIME ,injector().getInstance(IMonitorStatistics.class)).runInThreadSleepFirst();
	}

	@Override
	protected void createMoreContext(ContextHandlerCollection contexts) {
		ServletContextHandler handler = createServletContextHandler();
		handler.setContextPath("/");
		handler.addServlet(AngularServlet.class, Constants.ANGULAR_WEB_URLS_PATH_SPEC);
		contexts.addHandler(handler);
		addHandler(Constants.ANGULAR_RESOURCES_CONTEXT_PATH, Constants.getAngularDir(), contexts);
		log.info("context " + Constants.ANGULAR_WEB_URLS_PATH_SPEC + " is serving " + Constants.getAngularMainHtml());
	}
	
	@Override
	protected List<Module> getGuiceModules() {
		return Lists.<Module>newArrayList(new WebServerModule(), new ServerServletModule());
	}

	@Override
	public int getHttpPort() {
		return injector().getInstance(GlobalConfigurationJsonStore.class).get().web_server_port();
	}
	@Override
	protected ServletContextHandler createServletContextHandler() {<commit_msg>fixed #114 login bug in Builtin mode<commit_after>package codeine;

import java.util.List;

import org.eclipse.jetty.security.ConstraintMapping;
import org.eclipse.jetty.security.ConstraintSecurityHandler;
import org.eclipse.jetty.security.DefaultIdentityService;
import org.eclipse.jetty.security.SpnegoLoginService;
import org.eclipse.jetty.security.authentication.FormAuthenticator;
import org.eclipse.jetty.security.authentication.SpnegoAuthenticator;
import org.eclipse.jetty.server.handler.ContextHandlerCollection;
import org.eclipse.jetty.servlet.ServletContextHandler;
import org.eclipse.jetty.servlet.ServletHolder;
import org.eclipse.jetty.util.security.Constraint;

import codeine.configuration.PathHelper;
import codeine.executer.PeriodicExecuter;
import codeine.jsons.auth.AuthenticationMethod;
import codeine.jsons.global.GlobalConfigurationJsonStore;
import codeine.jsons.peer_status.PeersProjectsStatus;
import codeine.model.Constants;
import codeine.servlet.UsersManager;
import codeine.statistics.IMonitorStatistics;
import codeine.statistics.MonitorsStatistics;
import codeine.users.LogoutServlet;

import com.google.common.collect.Lists;
import com.google.inject.Injector;
import com.google.inject.Module;

public class CodeineWebServerBootstrap extends AbstractCodeineBootstrap
{
	public CodeineWebServerBootstrap(Injector injector) {
		super(injector);
	}

	public CodeineWebServerBootstrap() {
	}

	public static void main(String[] args)
	{
		System.setProperty("org.eclipse.jetty.server.Request.maxFormContentSize", "10000000");
		boot(Component.WEB, CodeineWebServerBootstrap.class);
	}
	
	@Override
	protected void execute() {
		log.info("executing web server bootstrap");
		new PeriodicExecuter(PeersProjectsStatus.SLEEP_TIME ,injector().getInstance(PeersProjectsStatus.class)).runInThread();
		try {
			injector().getInstance(ConfigurationManagerServer.class).updateDb();
		} catch (Exception e) {
			log.error("fail to update projects in db", e);
		}
		new PeriodicExecuter(ProjectConfigurationInPeerUpdater.MAX_SLEEP_TIME_MILLI ,injector().getInstance(ProjectConfigurationInPeerUpdater.class)).runInThread();
		new PeriodicExecuter(MonitorsStatistics.SLEEP_TIME ,injector().getInstance(IMonitorStatistics.class)).runInThreadSleepFirst();
	}

	@Override
	protected void createMoreContext(ContextHandlerCollection contexts) {
		ServletContextHandler handler = createServletContextHandler();
		handler.setContextPath(Constants.ANGULAR_RESOURCES_CONTEXT_PATH);
		handler.addServlet(AngularServlet.class, Constants.ANGULAR_WEB_URLS_PATH_SPEC);
		contexts.addHandler(handler);
		addHandler(Constants.ANGULAR_RESOURCES_CONTEXT_PATH, Constants.getAngularDir(), contexts);
		log.info("context " + Constants.ANGULAR_WEB_URLS_PATH_SPEC + " is serving " + Constants.getAngularMainHtml());
	}
	
	@Override
	protected List<Module> getGuiceModules() {
		return Lists.<Module>newArrayList(new WebServerModule(), new ServerServletModule());
	}

	@Override
	public int getHttpPort() {
		return injector().getInstance(GlobalConfigurationJsonStore.class).get().web_server_port();
	}
	@Override
	protected ServletContextHandler createServletContextHandler() {
{'fraction_non_alphanumeric': 0.09923542529467984, 'fraction_numerical': 0.003026441541892322, 'mean_word_length': 7.636863823933975, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 2, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '368455', 'n_tokens_mistral': 1909, 'n_tokens_neox': 1824, 'n_words': 282}