package ArchitectureTest; import javax.ws.rs.FormParam; import javax.ws.rs.GET; import javax.ws.rs.POST; import javax.ws.rs.PUT; import javax.ws.rs.Path; import javax.ws.rs.PathParam; import net.arnx.jsonic.JSON; @Path("/customers") public class CustomerRest { @GET public String getCustomers() { return JSON.encode(Customers.getInstance().getCustomers()); } @POST public void createCustomer(@FormParam("name") String name, @FormParam("office") String office, @FormParam("address") String address) { Customers.getInstance().getCustomers().put(name, new Customer(office, address)); System.out.println(Customers.getInstance().getCustomers()); } // // @Path("/{customerId}/office") // @GET // public String getOffice(@PathParam("customerId") String id) { // return Customers.getInstance().getCustomers().get(id).getOffice(); // } // // @Path("/{customerId}/office") // @PUT // public void updateOffice(@PathParam("customerId") String id, @FormParam("office") String office) { // Customers.getInstance().getCustomers().get(id).setOffice(office); // } @Path("/{customerId}/address") @GET public String getAddress(@PathParam("customerId") String id) { return Customers.getInstance().getCustomers().get(id).getAddress(); } @Path("/{customerId}/address") @PUT public void getAddress(@PathParam("customerId") String id, @FormParam("address") String address) { Customers.getInstance().getCustomers().get(id).setAddress(address); } }