Search in sources :

Example 26 with ThingType

use of org.eclipse.smarthome.core.thing.type.ThingType in project smarthome by eclipse.

the class ThingTypeResource method getByUID.

@GET
@RolesAllowed({ Role.USER })
@Path("/{thingTypeUID}")
@Produces(MediaType.APPLICATION_JSON)
@ApiOperation(value = "Gets thing type by UID.", response = ThingTypeDTO.class)
@ApiResponses(value = { @ApiResponse(code = 200, message = "Thing type with provided thingTypeUID does not exist.", response = ThingTypeDTO.class), @ApiResponse(code = 404, message = "No content") })
public Response getByUID(@PathParam("thingTypeUID") @ApiParam(value = "thingTypeUID") String thingTypeUID, @HeaderParam(HttpHeaders.ACCEPT_LANGUAGE) @ApiParam(value = HttpHeaders.ACCEPT_LANGUAGE) String language) {
    Locale locale = LocaleUtil.getLocale(language);
    ThingType thingType = thingTypeRegistry.getThingType(new ThingTypeUID(thingTypeUID), locale);
    if (thingType != null) {
        return Response.ok(convertToThingTypeDTO(thingType, locale)).build();
    } else {
        return Response.noContent().build();
    }
}
Also used : Locale(java.util.Locale) ThingTypeUID(org.eclipse.smarthome.core.thing.ThingTypeUID) ThingType(org.eclipse.smarthome.core.thing.type.ThingType) Path(javax.ws.rs.Path) RolesAllowed(javax.annotation.security.RolesAllowed) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET) ApiOperation(io.swagger.annotations.ApiOperation) ApiResponses(io.swagger.annotations.ApiResponses)

Aggregations

ThingType (org.eclipse.smarthome.core.thing.type.ThingType)26 JavaOSGiTest (org.eclipse.smarthome.test.java.JavaOSGiTest)15 Test (org.junit.Test)15 Bundle (org.osgi.framework.Bundle)15 ChannelDefinition (org.eclipse.smarthome.core.thing.type.ChannelDefinition)7 List (java.util.List)3 Nullable (org.eclipse.jdt.annotation.Nullable)3 Thing (org.eclipse.smarthome.core.thing.Thing)3 ThingUID (org.eclipse.smarthome.core.thing.ThingUID)3 ThingTypeProvider (org.eclipse.smarthome.core.thing.binding.ThingTypeProvider)3 Before (org.junit.Before)3 URI (java.net.URI)2 ArrayList (java.util.ArrayList)2 Collection (java.util.Collection)2 Lock (java.util.concurrent.locks.Lock)2 ReentrantLock (java.util.concurrent.locks.ReentrantLock)2 ConfigDescription (org.eclipse.smarthome.config.core.ConfigDescription)2 ConfigDescriptionParameter (org.eclipse.smarthome.config.core.ConfigDescriptionParameter)2 Configuration (org.eclipse.smarthome.config.core.Configuration)2 ThingHandler (org.eclipse.smarthome.core.thing.binding.ThingHandler)2