コード例 #1
0
ファイル: SitemapResource.java プロジェクト: watou/smarthome
  @GET
  @Path("/{sitemapname: [a-zA-Z_0-9]*}/{pageid: [a-zA-Z_0-9]*}")
  @Produces(MediaType.APPLICATION_JSON)
  @ApiOperation(value = "Polls the data for a sitemap.", response = PageDTO.class)
  @ApiResponses(
      value = {
        @ApiResponse(code = 200, message = "OK"),
        @ApiResponse(
            code = 404,
            message =
                "Sitemap with requested name does not exist or page does not exist, or page refers to a non-linkable widget")
      })
  public Response getPageData(
      @Context HttpHeaders headers,
      @HeaderParam(HttpHeaders.ACCEPT_LANGUAGE) @ApiParam(value = "language") String language,
      @PathParam("sitemapname") @ApiParam(value = "sitemap name") String sitemapname,
      @PathParam("pageid") @ApiParam(value = "page id") String pageId) {
    final Locale locale = LocaleUtil.getLocale(language);
    logger.debug("Received HTTP GET request at '{}'", uriInfo.getPath());

    if (headers.getRequestHeader("X-Atmosphere-Transport") != null) {
      // Make the REST-API pseudo-compatible with openHAB 1.x
      // The client asks Atmosphere for server push functionality,
      // so we do a simply listening for changes on the appropriate items
      blockUnlessChangeOccurs(sitemapname, pageId);
    }
    Object responseObject =
        getPageBean(sitemapname, pageId, uriInfo.getBaseUriBuilder().build(), locale);
    return Response.ok(responseObject).build();
  }
コード例 #2
0
ファイル: SitemapResource.java プロジェクト: watou/smarthome
 @GET
 @Path("/{sitemapname: [a-zA-Z_0-9]*}")
 @Produces(MediaType.APPLICATION_JSON)
 @ApiOperation(value = "Get sitemap by name.", response = SitemapDTO.class)
 @ApiResponses(value = {@ApiResponse(code = 200, message = "OK")})
 public Response getSitemapData(
     @Context HttpHeaders headers,
     @HeaderParam(HttpHeaders.ACCEPT_LANGUAGE) @ApiParam(value = "language") String language,
     @PathParam("sitemapname") @ApiParam(value = "sitemap name") String sitemapname,
     @QueryParam("type") String type,
     @QueryParam("jsoncallback") @DefaultValue("callback") String callback) {
   final Locale locale = LocaleUtil.getLocale(language);
   logger.debug(
       "Received HTTP GET request at '{}' for media type '{}'.",
       new Object[] {uriInfo.getPath(), type});
   Object responseObject =
       getSitemapBean(sitemapname, uriInfo.getBaseUriBuilder().build(), locale);
   return Response.ok(responseObject).build();
 }