use of org.eclipse.smarthome.core.extension.ExtensionService in project smarthome by eclipse.
the class ExtensionResource method uninstallExtension.
@POST
@Path("/{extensionId: [a-zA-Z_0-9-:]*}/uninstall")
@ApiResponses(value = { @ApiResponse(code = 200, message = "OK") })
public Response uninstallExtension(@PathParam("extensionId") @ApiParam(value = "extension ID", required = true) final String extensionId) {
ThreadPoolManager.getPool(THREAD_POOL_NAME).submit(() -> {
try {
ExtensionService extensionService = getExtensionService(extensionId);
extensionService.uninstall(extensionId);
} catch (Exception e) {
logger.error("Exception while uninstalling extension: {}", e.getMessage());
postFailureEvent(extensionId, e.getMessage());
}
});
return Response.ok(null, MediaType.TEXT_PLAIN).build();
}
use of org.eclipse.smarthome.core.extension.ExtensionService in project smarthome by eclipse.
the class ExtensionResource method getAllExtensionTypes.
private Set<ExtensionType> getAllExtensionTypes(Locale locale) {
final Collator coll = Collator.getInstance(locale);
coll.setStrength(Collator.PRIMARY);
Set<ExtensionType> ret = new TreeSet<>(new Comparator<ExtensionType>() {
@Override
public int compare(ExtensionType o1, ExtensionType o2) {
return coll.compare(o1.getLabel(), o2.getLabel());
}
});
for (ExtensionService extensionService : extensionServices) {
ret.addAll(extensionService.getTypes(locale));
}
return ret;
}
use of org.eclipse.smarthome.core.extension.ExtensionService in project smarthome by eclipse.
the class ExtensionResource method getById.
@GET
@Path("/{extensionId: [a-zA-Z_0-9-]*}")
@Produces(MediaType.APPLICATION_JSON)
@ApiOperation(value = "Get extension with given ID.")
@ApiResponses(value = { @ApiResponse(code = 200, message = "OK", response = String.class), @ApiResponse(code = 404, message = "Not found") })
public Response getById(@HeaderParam("Accept-Language") @ApiParam(value = "language") String language, @PathParam("extensionId") @ApiParam(value = "extension ID", required = true) String extensionId) {
logger.debug("Received HTTP GET request at '{}'.", uriInfo.getPath());
Locale locale = LocaleUtil.getLocale(language);
ExtensionService extensionService = getExtensionService(extensionId);
Extension responseObject = extensionService.getExtension(extensionId, locale);
if (responseObject != null) {
return Response.ok(responseObject).build();
}
return Response.status(404).build();
}
use of org.eclipse.smarthome.core.extension.ExtensionService in project smarthome by eclipse.
the class ExtensionResource method installExtension.
@POST
@Path("/{extensionId: [a-zA-Z_0-9-:]*}/install")
@ApiOperation(value = "Installs the extension with the given ID.")
@ApiResponses(value = { @ApiResponse(code = 200, message = "OK") })
public Response installExtension(@PathParam("extensionId") @ApiParam(value = "extension ID", required = true) final String extensionId) {
ThreadPoolManager.getPool(THREAD_POOL_NAME).submit(() -> {
try {
ExtensionService extensionService = getExtensionService(extensionId);
extensionService.install(extensionId);
} catch (Exception e) {
logger.error("Exception while installing extension: {}", e.getMessage());
postFailureEvent(extensionId, e.getMessage());
}
});
return Response.ok(null, MediaType.TEXT_PLAIN).build();
}
Aggregations