@Put("json") public Representation putBusDriverJSON(Representation representation) { try { JsonRepresentation userRepresentation = new JsonRepresentation(representation); BusDriver busDriver = JsonHandler.fromJson(userRepresentation.getText(), BusDriver.class); // trying to add new user int result = busHelper.addBusDriver(busDriver); // checking errors if (result == BusHelper.EC_INVALID_DNI) // an user with that id exists getResponse().setStatus(Status.CLIENT_ERROR_CONFLICT); else if (result == BusHelper.EC_INVALID_AUTH_CODE) // invalid company registry authorization code getResponse().setStatus(Status.CLIENT_ERROR_PRECONDITION_FAILED); else if (result == BusHelper.EC_BBDD_ERROR) // error in DAO getResponse().setStatus(Status.CLIENT_ERROR_NOT_ACCEPTABLE); } catch (Exception ioe) { // an error occurred getResponse().setStatus(Status.CLIENT_ERROR_NOT_ACCEPTABLE); } return null; }