<commit_before>package org.uiautomation.ios.ide.controllers;

import java.io.IOException;
import java.net.MalformedURLException;
import java.net.URL;

import javax.servlet.http.HttpServletRequest;

import org.apache.http.HttpHost;
import org.apache.http.HttpResponse;
import org.apache.http.client.ClientProtocolException;
import org.apache.http.client.HttpClient;
import org.apache.http.message.BasicHttpEntityEnclosingRequest;
import org.json.JSONException;
import org.json.JSONObject;
import org.uiautomation.ios.UIAModels.Session;
import org.uiautomation.ios.client.uiamodels.impl.RemoteUIADriver;
import org.uiautomation.ios.communication.Helper;
import org.uiautomation.ios.communication.HttpClientFactory;
import org.uiautomation.ios.exceptions.IOSAutomationException;
import org.uiautomation.ios.ide.model.Cache;
import org.uiautomation.ios.ide.views.RedirectView;
import org.uiautomation.ios.ide.views.View;

public class SessionGuesserController implements IDECommandController {

  private final Cache cache;


  public SessionGuesserController(Cache cache) {
    this.cache = cache;
  }

  @Override
  public boolean canHandle(String pathInfo) {
    return pathInfo.equals("/");
  }

  @Override
  public View handle(HttpServletRequest req) throws IOSAutomationException, Exception {
    Session session = getSession();
    return new RedirectView("session/" + session.getSessionId() + "/home");

  }


  private Session getSession() throws ClientProtocolException, IOException, JSONException {<commit_msg>organize imports<commit_after>package org.uiautomation.ios.ide.controllers;

import java.io.IOException;
import java.net.URL;

import javax.servlet.http.HttpServletRequest;

import org.apache.http.HttpHost;
import org.apache.http.HttpResponse;
import org.apache.http.client.ClientProtocolException;
import org.apache.http.client.HttpClient;
import org.apache.http.message.BasicHttpEntityEnclosingRequest;
import org.json.JSONException;
import org.json.JSONObject;
import org.uiautomation.ios.UIAModels.Session;
import org.uiautomation.ios.communication.Helper;
import org.uiautomation.ios.communication.HttpClientFactory;
import org.uiautomation.ios.exceptions.IOSAutomationException;
import org.uiautomation.ios.ide.model.Cache;
import org.uiautomation.ios.ide.views.RedirectView;
import org.uiautomation.ios.ide.views.View;

public class SessionGuesserController implements IDECommandController {

  private final Cache cache;


  public SessionGuesserController(Cache cache) {
    this.cache = cache;
  }

  @Override
  public boolean canHandle(String pathInfo) {
    return pathInfo.equals("/");
  }

  @Override
  public View handle(HttpServletRequest req) throws IOSAutomationException, Exception {
    Session session = getSession();
    return new RedirectView("session/" + session.getSessionId() + "/home");

  }


  private Session getSession() throws ClientProtocolException, IOException, JSONException {
{'fraction_non_alphanumeric': 0.0954653937947494, 'fraction_numerical': 0.0, 'mean_word_length': 5.791666666666667, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, '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': '7063327', 'n_tokens_mistral': 882, 'n_tokens_neox': 867, 'n_words': 165}