use of org.eclipse.smarthome.io.rest.core.thing.EnrichedThingDTO in project smarthome by eclipse.
the class ThingResource method getThingResponse.
/**
* helper: create a Response holding a Thing and/or error information.
*
* @param status
* @param thing
* @param errormessage an optional error message (may be null), ignored if the status family is successful
* @return Response
*/
private Response getThingResponse(Status status, Thing thing, Locale locale, String errormessage) {
ThingStatusInfo thingStatusInfo = thingStatusInfoI18nLocalizationService.getLocalizedThingStatusInfo(thing, locale);
boolean managed = managedThingProvider.get(thing.getUID()) != null;
EnrichedThingDTO enrichedThingDTO = thing != null ? EnrichedThingDTOMapper.map(thing, thingStatusInfo, this.getThingFirmwareStatus(thing.getUID()), getLinkedItemsMap(thing), managed) : null;
return JSONResponse.createResponse(status, enrichedThingDTO, errormessage);
}
use of org.eclipse.smarthome.io.rest.core.thing.EnrichedThingDTO in project smarthome by eclipse.
the class ThingResource method getAll.
@GET
@RolesAllowed({ Role.USER, Role.ADMIN })
@Produces(MediaType.APPLICATION_JSON)
@ApiOperation(value = "Get all available things.", response = EnrichedThingDTO.class, responseContainer = "Set")
@ApiResponses(value = { @ApiResponse(code = 200, message = "OK", response = EnrichedThingDTO.class, responseContainer = "Set") })
public Response getAll(@HeaderParam(HttpHeaders.ACCEPT_LANGUAGE) @ApiParam(value = "language") String language) {
final Locale locale = LocaleUtil.getLocale(language);
Stream<EnrichedThingDTO> thingStream = thingRegistry.stream().map(t -> convertToEnrichedThingDTO(t, locale)).distinct();
return Response.ok(new Stream2JSONInputStream(thingStream)).build();
}
Aggregations