Ejemplo n.º 1
0
  @GET
  @Produces({MediaType.WILDCARD})
  public Response getItems(
      @Context HttpHeaders headers,
      @QueryParam("type") String type,
      @QueryParam("jsoncallback") @DefaultValue("callback") String callback) {
    logger.debug("Received HTTP GET request at '{}' for media type '{}'.", uriInfo.getPath(), type);

    String responseType =
        MediaTypeHelper.getResponseMediaType(headers.getAcceptableMediaTypes(), type);
    if (responseType != null) {
      Object responseObject =
          responseType.equals(MediaTypeHelper.APPLICATION_X_JAVASCRIPT)
              ? new JSONWithPadding(new ItemConfigListBean(getItemConfigBeanList()), callback)
              : new ItemConfigListBean(getItemConfigBeanList());
      return Response.ok(responseObject, responseType).build();
    } else {
      return Response.notAcceptable(null).build();
    }
  }
Ejemplo n.º 2
0
  @PUT
  @Path("/{itemname: [a-zA-Z_0-9]*}")
  @Produces({MediaType.WILDCARD})
  public Response putItem(
      @Context HttpHeaders headers,
      @QueryParam("type") String type,
      @PathParam("itemname") String itemname,
      @QueryParam("jsoncallback") @DefaultValue("callback") String callback,
      ItemConfigBean item) {
    logger.debug("Received HTTP PUT request at '{}' for media type '{}'.", uriInfo.getPath(), type);

    String responseType =
        MediaTypeHelper.getResponseMediaType(headers.getAcceptableMediaTypes(), type);
    if (responseType != null) {
      Object responseObject =
          responseType.equals(MediaTypeHelper.APPLICATION_X_JAVASCRIPT)
              ? new JSONWithPadding(updateItemConfigBean(itemname, item, false), callback)
              : updateItemConfigBean(itemname, item, false);
      return Response.ok(responseObject, responseType).build();
    } else {
      return Response.notAcceptable(null).build();
    }
  }