Add Lab6 finish

This commit is contained in:
2019-06-04 15:22:43 +02:00
parent b8121f8770
commit c9afbbe521
+14 -2
View File
@@ -54,8 +54,20 @@ public class CarExceptionsResource {
@QueryParam("model") String model, @QueryParam("model") String model,
@QueryParam("country") String country, @QueryParam("country") String country,
@QueryParam("dateOfSales") Date dateOfSales, @QueryParam("dateOfSales") Date dateOfSales,
@QueryParam("power") Integer power) { @QueryParam("power") Integer power) throws WrongIDException, WrongValueException{
return String.valueOf(carDao.updateDB(id, name, model, country, dateOfSales, power)); if (carDao.findID(id)){
if (power < 1 || power > 2000) {
throw new WrongValueException("insert","Power must be between 1 PS and 2000 PS");
} else {
return carDao.updateDB(id, name, model, country, dateOfSales, power).getStringValue();
}
} else {
throw new WrongIDException(id, "update");
}
//return String.valueOf(carDao.updateDB(id, name, model, country, dateOfSales, power));
} }