[rest] Add timezone information to root resource (#4826)
Signed-off-by: Florian Hotze <dev@florianhotze.com>pull/4835/head
parent
07ad5b52b2
commit
5126166611
|
@ -26,6 +26,7 @@ import javax.ws.rs.core.UriInfo;
|
||||||
|
|
||||||
import org.eclipse.jdt.annotation.NonNullByDefault;
|
import org.eclipse.jdt.annotation.NonNullByDefault;
|
||||||
import org.openhab.core.i18n.LocaleProvider;
|
import org.openhab.core.i18n.LocaleProvider;
|
||||||
|
import org.openhab.core.i18n.TimeZoneProvider;
|
||||||
import org.openhab.core.i18n.UnitProvider;
|
import org.openhab.core.i18n.UnitProvider;
|
||||||
import org.openhab.core.io.rest.RESTConstants;
|
import org.openhab.core.io.rest.RESTConstants;
|
||||||
import org.openhab.core.io.rest.RESTResource;
|
import org.openhab.core.io.rest.RESTResource;
|
||||||
|
@ -83,13 +84,15 @@ public class RootResource implements RESTResource {
|
||||||
private final JaxrsServiceRuntime runtime;
|
private final JaxrsServiceRuntime runtime;
|
||||||
private final LocaleProvider localeProvider;
|
private final LocaleProvider localeProvider;
|
||||||
private final UnitProvider unitProvider;
|
private final UnitProvider unitProvider;
|
||||||
|
private final TimeZoneProvider timeZoneProvider;
|
||||||
|
|
||||||
@Activate
|
@Activate
|
||||||
public RootResource(final @Reference JaxrsServiceRuntime runtime, final @Reference LocaleProvider localeProvider,
|
public RootResource(final @Reference JaxrsServiceRuntime runtime, final @Reference LocaleProvider localeProvider,
|
||||||
final @Reference UnitProvider unitProvider) {
|
final @Reference UnitProvider unitProvider, final @Reference TimeZoneProvider timeZoneProvider) {
|
||||||
this.runtime = runtime;
|
this.runtime = runtime;
|
||||||
this.localeProvider = localeProvider;
|
this.localeProvider = localeProvider;
|
||||||
this.unitProvider = unitProvider;
|
this.unitProvider = unitProvider;
|
||||||
|
this.timeZoneProvider = timeZoneProvider;
|
||||||
}
|
}
|
||||||
|
|
||||||
@GET
|
@GET
|
||||||
|
@ -102,7 +105,7 @@ public class RootResource implements RESTResource {
|
||||||
final Map<String, String> collectedLinks = new HashMap<>();
|
final Map<String, String> collectedLinks = new HashMap<>();
|
||||||
|
|
||||||
final RuntimeDTO runtimeDTO = runtime.getRuntimeDTO();
|
final RuntimeDTO runtimeDTO = runtime.getRuntimeDTO();
|
||||||
final RootBean bean = new RootBean(localeProvider, unitProvider);
|
final RootBean bean = new RootBean(localeProvider, unitProvider, timeZoneProvider);
|
||||||
for (final ApplicationDTO applicationDTO : runtimeDTO.applicationDTOs) {
|
for (final ApplicationDTO applicationDTO : runtimeDTO.applicationDTOs) {
|
||||||
for (final ResourceDTO resourceDTO : applicationDTO.resourceDTOs) {
|
for (final ResourceDTO resourceDTO : applicationDTO.resourceDTOs) {
|
||||||
// We are using the JAX-RS name per convention for the link type.
|
// We are using the JAX-RS name per convention for the link type.
|
||||||
|
|
|
@ -18,6 +18,7 @@ import java.util.List;
|
||||||
import org.eclipse.jdt.annotation.NonNullByDefault;
|
import org.eclipse.jdt.annotation.NonNullByDefault;
|
||||||
import org.openhab.core.OpenHAB;
|
import org.openhab.core.OpenHAB;
|
||||||
import org.openhab.core.i18n.LocaleProvider;
|
import org.openhab.core.i18n.LocaleProvider;
|
||||||
|
import org.openhab.core.i18n.TimeZoneProvider;
|
||||||
import org.openhab.core.i18n.UnitProvider;
|
import org.openhab.core.i18n.UnitProvider;
|
||||||
import org.openhab.core.io.rest.RESTConstants;
|
import org.openhab.core.io.rest.RESTConstants;
|
||||||
|
|
||||||
|
@ -37,13 +38,16 @@ public class RootBean {
|
||||||
|
|
||||||
public final String measurementSystem;
|
public final String measurementSystem;
|
||||||
|
|
||||||
|
public final String timezone;
|
||||||
|
|
||||||
public final RuntimeInfo runtimeInfo = new RuntimeInfo();
|
public final RuntimeInfo runtimeInfo = new RuntimeInfo();
|
||||||
|
|
||||||
public final List<Links> links = new ArrayList<>();
|
public final List<Links> links = new ArrayList<>();
|
||||||
|
|
||||||
public RootBean(LocaleProvider localeProvider, UnitProvider unitProvider) {
|
public RootBean(LocaleProvider localeProvider, UnitProvider unitProvider, TimeZoneProvider timeZoneProvider) {
|
||||||
this.locale = localeProvider.getLocale().toString();
|
this.locale = localeProvider.getLocale().toString();
|
||||||
this.measurementSystem = unitProvider.getMeasurementSystem().getName();
|
this.measurementSystem = unitProvider.getMeasurementSystem().getName();
|
||||||
|
this.timezone = timeZoneProvider.getTimeZone().toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class RuntimeInfo {
|
public static class RuntimeInfo {
|
||||||
|
|
Loading…
Reference in New Issue