Search in sources :

Example 1 with ConfigStatusInfo

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();
}
Also used : ConfigStatusInfo(org.eclipse.smarthome.config.core.status.ConfigStatusInfo) ThingUID(org.eclipse.smarthome.core.thing.ThingUID) Thing(org.eclipse.smarthome.core.thing.Thing) Path(javax.ws.rs.Path) RolesAllowed(javax.annotation.security.RolesAllowed) GET(javax.ws.rs.GET) ApiOperation(io.swagger.annotations.ApiOperation) ApiResponses(io.swagger.annotations.ApiResponses)

Example 2 with ConfigStatusInfo

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);
}
Also used : ConfigStatusInfo(org.eclipse.smarthome.config.core.status.ConfigStatusInfo)

Aggregations

ConfigStatusInfo (org.eclipse.smarthome.config.core.status.ConfigStatusInfo)2 ApiOperation (io.swagger.annotations.ApiOperation)1 ApiResponses (io.swagger.annotations.ApiResponses)1 RolesAllowed (javax.annotation.security.RolesAllowed)1 GET (javax.ws.rs.GET)1 Path (javax.ws.rs.Path)1 Thing (org.eclipse.smarthome.core.thing.Thing)1 ThingUID (org.eclipse.smarthome.core.thing.ThingUID)1