Package com.stormpath.samples.todos.entity

Examples of com.stormpath.samples.todos.entity.Todo


    @Path("/{id}")
    @GET
    @Produces(MediaType.APPLICATION_JSON)
    public TodoResource getTodo(@Context UriInfo info, @PathParam("id") String id) {
        Todo todo = todoService.getById(id);
        if (todo == null) {
            throw new UnknownResourceException();
        }
        return new TodoResource(info, todo);
    }
View Full Code Here


    @Path("/{id}")
    @POST
    @Consumes(MediaType.APPLICATION_JSON)
    public Response updateTodo(@Context UriInfo info, @PathParam("id") String id, Map map) {
        Todo existing = todoService.getById(id);
        if (existing == null) {
            throw new UnknownResourceException();
        }
        //typically done via a framework call to automate this for any type of entity:
        if (map.containsKey("name")) {
            existing.setName(String.valueOf(map.get("name")));
        }
        if (map.containsKey("done")) {
            existing.setDone(Boolean.valueOf(String.valueOf(map.get("done"))));
        }
        existing = todoService.save(existing);
        return Response.ok(new TodoResource(info, existing), MediaType.APPLICATION_JSON).build();
    }
View Full Code Here

    }

    @Path("/{id}")
    @DELETE
    public void deleteTodo(@PathParam("id") String id) {
        Todo todo = todoService.deleteById(id);
        if (todo == null) {
            throw new UnknownResourceException();
        }
    }
View Full Code Here

TOP

Related Classes of com.stormpath.samples.todos.entity.Todo

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.