This commit is contained in:
2019-06-04 15:09:01 +02:00
parent 308bbcbb1e
commit b8121f8770
2 changed files with 20 additions and 5 deletions
+10 -5
View File
@@ -3,6 +3,7 @@ package Lab6;
//import Lab3.Exception.CarServiceFault;
//import Lab3.Exception.WrongValueExcept;
import Lab6.Exception.WrongValueException;
import Lab6.Exception.WrongIDException;
import Lab4.common.Car;
import Lab5.CarsDAO;
@@ -57,15 +58,19 @@ public class CarExceptionsResource {
return String.valueOf(carDao.updateDB(id, name, model, country, dateOfSales, power));
}
/// Delete
@Path("/delete/ID")
@DELETE
public String deleteCars(@QueryParam("id") Integer id) {
public String deleteCars(@QueryParam("id") Integer id) throws WrongIDException {
if (carDao.findID(id)){
return carDao.deleteDB(id).getStringValue();
} else {
throw new WrongIDException(id, "delete");
}
return carDao.deleteDB(id).getStringValue();
}
}