@DELETE @Path("/{id}/") public WorkStation deleteLaptop(@PathParam("id") String id) { System.out.println("----invoking deleteCustomer, Customer id is: " + id); long idNumber = Long.parseLong(id); for (WorkStation c : cc.getUsers()) { if (c.getId() == idNumber) { cc.getUsers().remove(c); return c; } } return null; }
@POST public WorkStation addLaptop(WorkStation customer) { System.out.println("----invoking addCustomer, Customer name is: " + customer.getName()); // customer.setId(++currentId); cc.getUsers().add(customer); // customers.put(customer.getId(), customer); return customer; // Response.ok(customer).build(); }
@GET public WorkStationCollection findLaptop(@QueryParam("name") String name) { System.out.println(name); if (name.equals("shit")) { WorkStationCollection c = new WorkStationCollection(); c.getUsers().clear(); return c; } return cc; }
@GET @Path("/{id}/") public WorkStation getLaptop(@PathParam("id") String id) { System.out.println("----invoking getCustomer, Customer id is: " + id); long idNumber = Long.parseLong(id); for (WorkStation c : cc.getUsers()) { if (c.getId() == idNumber) { return c; } } return null; }
@PUT public WorkStation updateLaptop(WorkStation customer) { System.out.println( "----invoking updateCustomer, " + customer.getId() + "Customer name is: " + customer.getName()); for (WorkStation c : cc.getUsers()) { if (c.getId() == customer.getId()) { c.setName(customer.getName()); return c; } } return customer; }