Пример #1
0
 public CatalogItem[] getAllItems() {
   return services
       .getCatalogService()
       .register(CatalogItem.class)
       .request()
       .get(CatalogItem[].class);
 }
Пример #2
0
  public void addCatalog() {
    Response response = services.getCatalogService().request().post(Entity.xml(catalogItem));

    Response.StatusType statusInfo = response.getStatusInfo();

    if (statusInfo.getStatusCode() == Response.Status.CREATED.getStatusCode())
      status = "User added successfully";
    else status = statusInfo.getReasonPhrase();
  }
Пример #3
0
  public String catalogServiceEndpoint() {
    String itemId =
        FacesContext.getCurrentInstance()
            .getExternalContext()
            .getRequestParameterMap()
            .get("itemId");

    String response = services.getCatalogService().path(itemId).request().get(String.class);

    JsonObject jsonObject = Json.createReader(new StringReader(response)).readObject();
    catalogItem.setId(jsonObject.getInt("id"));
    catalogItem.setName(jsonObject.getString("name"));
    catalogItem.setDescription(jsonObject.getString("description"));

    return response;
  }