use of org.eclipse.smarthome.config.core.status.ConfigStatusInfo in project smarthome by eclipse.
the class ThingResource method getConfigStatus.
@GET
@RolesAllowed({ Role.USER, Role.ADMIN })
@Path("/{thingUID}/config/status")
@ApiOperation(value = "Gets thing's config status.")
@ApiResponses(value = { @ApiResponse(code = 200, message = "OK", response = String.class), @ApiResponse(code = 404, message = "Thing not found.") })
public Response getConfigStatus(@HeaderParam(HttpHeaders.ACCEPT_LANGUAGE) String language, @PathParam("thingUID") @ApiParam(value = "thing") String thingUID) throws IOException {
ThingUID thingUIDObject = new ThingUID(thingUID);
// Check if the Thing exists, 404 if not
Thing thing = thingRegistry.get(thingUIDObject);
if (null == thing) {
logger.info("Received HTTP GET request for thing config status at '{}' for the unknown thing '{}'.", uriInfo.getPath(), thingUID);
return getThingNotFoundResponse(thingUID);
}
ConfigStatusInfo info = configStatusService.getConfigStatus(thingUID, LocaleUtil.getLocale(language));
if (info != null) {
return Response.ok(null, MediaType.TEXT_PLAIN).entity(info.getConfigStatusMessages()).build();
}
return Response.ok(null, MediaType.TEXT_PLAIN).entity(Collections.EMPTY_SET).build();
}
use of org.eclipse.smarthome.config.core.status.ConfigStatusInfo in project smarthome by eclipse.
the class ConfigStatusEventFactory method createStatusInfoEvent.
private Event createStatusInfoEvent(String topic, String payload) throws Exception {
String[] topicElements = getTopicElements(topic);
if (topicElements.length != 5) {
throw new IllegalArgumentException("ConfigStatusInfoEvent creation failed, invalid topic: " + topic);
}
ConfigStatusInfo thingStatusInfo = deserializePayload(payload, ConfigStatusInfo.class);
return new ConfigStatusInfoEvent(topic, thingStatusInfo);
}
Aggregations