/**
   * For test purpose only
   *
   * @param entities
   * @return
   */
  @POST
  @Consumes({"application/json"})
  @Produces({"application/json"})
  public Response post(List<Product> entities, @Context UriInfo info)
      throws UnknownResourceException {

    if (entities == null) {
      return Response.status(Response.Status.BAD_REQUEST.getStatusCode()).build();
    }

    int previousRows = productInventoryFacade.count();
    int affectedRows = 0;

    // Try to persist entities
    try {
      for (Product entitie : entities) {
        productInventoryFacade.checkCreation(entitie);
        productInventoryFacade.create(entitie);
        entitie.setHref(info.getAbsolutePath() + "/" + Long.toString(entitie.getId()));
        productInventoryFacade.edit(entitie);
        affectedRows = affectedRows + 1;
        //                publisher.createNotification(entitie, new Date());
      }
    } catch (BadUsageException e) {
      return Response.status(Response.Status.BAD_REQUEST.getStatusCode()).build();
    }

    Report stat = new Report(productInventoryFacade.count());
    stat.setAffectedRows(affectedRows);
    stat.setPreviousRows(previousRows);

    // 201 OK
    return Response.created(null).entity(stat).build();
  }
  @PUT
  @Path("{id}")
  @Consumes({"application/json"})
  @Produces({"application/json"})
  public Response update(@PathParam("id") long id, Product entity) throws UnknownResourceException {
    Response response = null;
    Product productInventory = productInventoryFacade.find(id);
    if (productInventory != null) {
      entity.setId(id);
      productInventoryFacade.edit(entity);
      //            publisher.valueChangedNotification(entity, new Date());
      // 200 OK + location
      response = Response.status(Response.Status.OK).entity(entity).build();

    } else {
      // 404 not found
      response = Response.status(Response.Status.NOT_FOUND).build();
    }
    return response;
  }