From e67de2617745573546dfd91b97ccdd097c444ccf Mon Sep 17 00:00:00 2001 From: "martin.dorange.etu" <martin.dorange.etu@univ-lille.fr> Date: Tue, 9 Feb 2021 22:45:21 +0100 Subject: [PATCH] test addfromform still not working --- .../iut/todo/ressource/TodoRessource.java | 22 ++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/src/main/java/fr/ulille/iut/todo/ressource/TodoRessource.java b/src/main/java/fr/ulille/iut/todo/ressource/TodoRessource.java index 9db4c38..c71ad28 100644 --- a/src/main/java/fr/ulille/iut/todo/ressource/TodoRessource.java +++ b/src/main/java/fr/ulille/iut/todo/ressource/TodoRessource.java @@ -57,7 +57,7 @@ public class TodoRessource { @GET @Path("{id}/description") public String getDescription(@PathParam("id") UUID id) { - LOGGER.info("getdescription()"); + LOGGER.info("getDescription()"); return todoService.getTache(id).getDescription(); } @@ -87,10 +87,22 @@ public class TodoRessource { LOGGER.info("createTacheFromForm()"); Tache tache = new Tache(); -// tache.setNom(formParams.); - - - return null; + String name= formParams.get("nom").get(0); + System.out.println(name); + tache.setNom(name); + todoService.addTache(tache); + + URI location= uri.getAbsolutePathBuilder().path(tache.getId().toString()).build(); + + EntityTag etag =new EntityTag(Integer.toString(tache.hashCode())); + ResponseBuilder builder = request.evaluatePreconditions(etag); + + if (builder == null) { + builder = Response.created(location); + builder.tag(etag); + builder.entity(tache); + } + return builder.build(); } } -- GitLab