Exemplo n.º 1
0
  @Override
  public Object handle(Request request, Response response) {

    JSONObject result;

    try {
      JSONObject requestJSON = new JSONObject(request.body());
      SudokuGame game =
          new SudokuGame(convertJSONObjectToStringArray(requestJSON.getJSONArray("data")));
      game.solve();
      result = convertStringToJSONObject(game.toString());
    } catch (CannotProceedException e) {
      result = createErrorMessage("cannot solve");
      logger.error(e.getMessage());
    } catch (Exception e) {
      result = createErrorMessage("unknown");
      logger.error(e.getMessage());
    }

    response.type("application/json");
    /*try {
        Thread.sleep(15000);
    } catch (InterruptedException e) {
        e.printStackTrace();
    }*/
    return result;
  }
Exemplo n.º 2
0
 @Override
 public Object handle(Request request, Response response) throws Exception {
   try {
     String serviceName = request.params(":serviceName");
     deleteServiceJob(serviceName, user, password, tenant, dbClient);
     response.status(HttpConstants.HTTP_OK);
     response.type(HttpConstants.APPLICATION_JSON);
     return "Deletion scheduled for service " + serviceName;
   } catch (Exception e) {
     response.status(HTTP_BAD_REQUEST);
     return e.toString();
   }
 }
Exemplo n.º 3
0
 @Override
 public void type(String contentType) {
   delegate.type(contentType);
 }