Пример #1
0
  @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;
  }
Пример #2
0
 @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;
 }
Пример #3
0
  @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();
  }
Пример #4
0
 @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;
 }
Пример #5
0
  @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;
  }