@RequestMapping(value = "/app/", method = RequestMethod.POST)
  public ResponseEntity<App> createApp(@RequestBody App app, UriComponentsBuilder ucBuilder) {
    System.out.println("Creating App " + app.getTitle());

    if (this.api.getAppService().isExist(app)) {
      System.out.println("A app with name " + app.getTitle() + " already exist");
      return new ResponseEntity<App>(HttpStatus.CONFLICT);
    }

    app = this.api.getAppService().createApp(app);

    HttpHeaders headers = new HttpHeaders();
    headers.setLocation(ucBuilder.path("/app/{appid}").buildAndExpand(app.getAppid()).toUri());

    ObjectMapper mapper = new ObjectMapper();
    try {
      String jsonString = mapper.writeValueAsString(app);
      System.out.print(jsonString);
    } catch (JsonGenerationException e) {
      e.printStackTrace();
    } catch (JsonMappingException e) {
      e.printStackTrace();
    } catch (IOException e) {
      e.printStackTrace();
    }

    return new ResponseEntity<App>(app, headers, HttpStatus.CREATED);
  }
  @RequestMapping(value = "/app/{appid}", method = RequestMethod.DELETE)
  public ResponseEntity<App> deleteApp(
      @RequestBody App app) { // @RequestBody App app --> 400 bad request, instead please use
    // @PathVariable("appid") String appid
    // App app = new App();
    // app.setAppid(appid);
    System.out.println("\r\n" + app.getAppid());
    String appid = app.getAppid();
    System.out.println("Fetching & Deleting App with appid " + app.getAppid());
    //
    app = this.api.getAppService().deleteApp(app);
    if (app == null) {
      System.out.println("Unable to delete. App with id " + appid + " not found");
      return new ResponseEntity<App>(HttpStatus.NOT_FOUND);
    }

    return new ResponseEntity<App>(HttpStatus.NO_CONTENT);
  }
  @RequestMapping(value = "/app/{appid}", method = RequestMethod.PUT)
  public ResponseEntity<App> updateApp(@PathVariable("appid") String appid, @RequestBody App app) {
    System.out.println("Updating app " + appid);

    App currentApp = this.api.getAppService().readApp(appid);

    if (currentApp == null) {
      System.out.println("App with id " + appid + " not found");
      return new ResponseEntity<App>(HttpStatus.NOT_FOUND);
    } else if (appid.equals(app.getAppid())) return new ResponseEntity<App>(HttpStatus.CONFLICT);

    this.api.getAppService().updateApp(app);
    return new ResponseEntity<App>(currentApp, HttpStatus.OK);
  }