Exemplo n.º 1
0
  private void readConfigure() throws FileNotFoundException {
    ConfigureManager configureManager = new ConfigureManager();
    AccountManager accountManager = new AccountManager();
    ProblemManager problemManager = new ProblemManager();
    SubmissionManager submissionManager = new SubmissionManager();
    QAManager qaManager = new QAManager();
    ClarificationManager clarificationManager = new ClarificationManager();
    Map<String, String> config = new HashMap<String, String>();

    configureManager.createTable();
    accountManager.createTable();
    problemManager.createTable();
    submissionManager.createTable();
    qaManager.createTable();
    clarificationManager.createTable();
    this.port = 8888;
    this.scoreBoardPort = 8889;
    // default port

    File file = new File("config.txt");
    try (BufferedReader br = new BufferedReader(new FileReader(file))) {
      String line;
      while ((line = br.readLine()) != null) {
        String[] sp = line.split(":");
        if (sp[0].equals("port")) this.port = Integer.valueOf(sp[1]);
        else if (sp[0].equals("scoreboardport")) this.scoreBoardPort = Integer.valueOf(sp[1]);
        else if (sp[0].equals("team")) {
          readTeamAccount(sp[1]);
        } else if (sp[0].equals("judge")) {
          readJudgeAccount(sp[1]);
        } else if (sp[0].equals("problem")) {
          readProblemInfo(sp[1]);
        }
      }
    } catch (IOException e) {
      e.printStackTrace();
      System.exit(1);
    }

    config.put("ip", this.ip.getHostAddress());
    config.put("port", Integer.toString(this.port));
    config.put("scoreboard_port", Integer.toString(this.scoreBoardPort));
    config.put("start_time", "0");
    config.put("duration", "300");
    config.put("time_stamp", "0");
    configureManager.addEntry(config);
  }
Exemplo n.º 2
0
 private void readJudgeAccount(String pathName) {
   AccountManager accountManager = new AccountManager();
   File file = new File(pathName);
   try (BufferedReader br = new BufferedReader(new FileReader(file))) {
     String line;
     while ((line = br.readLine()) != null) {
       String[] sp = line.split(",");
       this.judges.put(sp[0], new Judge(sp[0], null));
       Map<String, String> judge_account = new HashMap<String, String>();
       judge_account.put("account", sp[0]);
       judge_account.put("password", sp[1]);
       judge_account.put("type", "judge");
       accountManager.addEntry(judge_account);
     }
   } catch (IOException e) {
     e.printStackTrace();
     System.exit(1);
   }
 }