Exemple #1
0
  private void handleCliRequestNoSyncRunning(CliRequest cliRequest) {
    try {
      Command command = CommandFactory.getInstance(cliRequest.getCommand());
      String[] commandArgs = cliRequest.getCommandArgs().toArray(new String[0]);

      ByteArrayOutputStream cliOutputStream = new ByteArrayOutputStream();

      Client client = new Client();
      client.setConfig(config);

      command.setOut(new PrintStream(cliOutputStream));
      command.setClient(client);
      command.setLocalDir(config.getLocalDir());

      command.execute(commandArgs);

      String cliOutput = cliOutputStream.toString();

      CliResponse cliResponse = new CliResponse(cliRequest.getId(), cliOutput);
      eventBus.post(cliResponse);

      cliOutputStream.close();
    } catch (Exception e) {
      logger.log(
          Level.WARNING, "Exception thrown when running CLI command through daemon: " + e, e);
      eventBus.post(new BadRequestResponse(cliRequest.getId(), e.getMessage()));
    }
  }
Exemple #2
0
 private void handleCliRequestSyncRunning(CliRequest cliRequest) {
   CliResponse cliResponse =
       new CliResponse(
           cliRequest.getId(), "Cannot run CLI commands while sync is running or requested.\n");
   eventBus.post(cliResponse);
 }