100% open-source IoT Platform - Integrate your devices, add intelligence, build custom apps
Java asset-managementbuildingdashboarddataplatformdevice-managementedge-computingenergyenergy-managementenergy-monitorfleet-managementfleet-telematicsiotiot-applicationiot-platformmodbusmqttmqtt-brokerota-updaterules-enginesmartcity
updated de-serialisation of model value type and notification updates
Rich Turneraf5621c62697
diff --git a/client/src/main/java/org/openremote/app/client/notifications/NotificationEditorImpl.java b/client/src/main/java/org/openremote/app/client/notifications/NotificationEditorImpl.javaindex d866fee89..c1118d4bb 100644--- a/client/src/main/java/org/openremote/app/client/notifications/NotificationEditorImpl.java+++ b/client/src/main/java/org/openremote/app/client/notifications/NotificationEditorImpl.java@@ -176,7 +176,13 @@ public class NotificationEditorImpl implements NotificationEditor {targetTypesList.addChangeHandler(event -> {if (sendOptions != null) {sendOptions.setSelectedTargetType(targetTypesList.getSelectedValue());- targetsGroup.setVisible(sendOptions.getSelectedTargetType() != Notification.TargetType.TENANT);+ if (sendOptions.getSelectedTargetType() == Notification.TargetType.TENANT) {+ sendOptions.setSelectedTarget(sendOptions.getSelectedRealm());+ targetsGroup.setVisible(false);+ } else {+ targetsList.selectItem("");+ targetsGroup.setVisible(true);+ }}});diff --git a/container/src/main/java/org/openremote/container/json/ModelValueMessageBodyConverter.java b/container/src/main/java/org/openremote/container/json/ModelValueMessageBodyConverter.javaindex 0757b937a..40c2d7c5f 100644--- a/container/src/main/java/org/openremote/container/json/ModelValueMessageBodyConverter.java+++ b/container/src/main/java/org/openremote/container/json/ModelValueMessageBodyConverter.java@@ -20,6 +20,7 @@package org.openremote.container.json;import org.jboss.resteasy.plugins.providers.ProviderHelper;+import org.openremote.model.util.TextUtil;import org.openremote.model.value.Value;import org.openremote.model.value.Values;@@ -46,7 +47,7 @@ public class ModelValueMessageBodyConverter implements MessageBodyReader<Value>,@Overridepublic Value readFrom(Class<Value> type, Type genericType, Annotation[] annotations, MediaType mediaType, MultivaluedMap<String, String> httpHeaders, InputStream entityStream) throws IOException, WebApplicationException {String str = ProviderHelper.readString(entityStream, mediaType);- return Values.parse(str).orElseThrow(() -> new IOException("Empty JSON data"));+ return TextUtil.isNullOrEmpty(str) ? null : Values.parse(str).orElseThrow(() -> new IOException("Empty JSON data"));}@Overridediff --git a/manager/src/main/java/org/openremote/manager/asset/console/ConsoleResourceImpl.java b/manager/src/main/java/org/openremote/manager/asset/console/ConsoleResourceImpl.javaindex f8279b46d..261a12cfa 100644--- a/manager/src/main/java/org/openremote/manager/asset/console/ConsoleResourceImpl.java+++ b/manager/src/main/java/org/openremote/manager/asset/console/ConsoleResourceImpl.java@@ -98,12 +98,16 @@ public class ConsoleResourceImpl extends ManagerWebResource implements ConsoleRe// Check authenticated user is already linked to this console; if anonymous request then check console isn't linked to any usersif (isAuthenticated()) {- List<UserAsset> consoleUserAssets = assetStorageService.findUserAssets(getAuthenticatedTenant().getId(),- null,- consoleRegistration.getId());- if (consoleUserAssets.isEmpty()) {- throw new WebApplicationException(FORBIDDEN);- }+ // Make asset private+ consoleAsset.setAccessPublicRead(false);++ // RT: Disabled below to allow multiple users to share a console (to support a shared device)+// List<UserAsset> consoleUserAssets = assetStorageService.findUserAssets(getAuthenticatedTenant().getId(),+// null,+// consoleRegistration.getId());+// if (consoleUserAssets.isEmpty()) {+// throw new WebApplicationException(FORBIDDEN);+// }} else {List<UserAsset> consoleUserAssets = assetStorageService.findUserAssets(getRequestTenant().getId(),null,diff --git a/manager/src/main/java/org/openremote/manager/notification/NotificationResourceImpl.java b/manager/src/main/java/org/openremote/manager/notification/NotificationResourceImpl.javaindex 7dc785840..c068b9652 100644--- a/manager/src/main/java/org/openremote/manager/notification/NotificationResourceImpl.java+++ b/manager/src/main/java/org/openremote/manager/notification/NotificationResourceImpl.java@@ -136,7 +136,7 @@ public class NotificationResourceImpl extends WebResource implements NotificatioSentNotification sentNotification = notificationService.getSentNotification(notificationId);verifyAccess(sentNotification, targetId);- notificationService.setNotificationAcknowleged(notificationId, acknowledgement.toString());+ notificationService.setNotificationAcknowleged(notificationId, acknowledgement == null ? null : acknowledgement.toString());}protected void verifyAccess(SentNotification sentNotification, String targetId) {diff --git a/model/src/main/java/org/openremote/model/notification/PushNotificationAction.java b/model/src/main/java/org/openremote/model/notification/PushNotificationAction.javaindex b71c4075e..372eac4e8 100644--- a/model/src/main/java/org/openremote/model/notification/PushNotificationAction.java+++ b/model/src/main/java/org/openremote/model/notification/PushNotificationAction.java@@ -98,7 +98,9 @@ public class PushNotificationAction {public ObjectValue toValue() {ObjectValue val = Values.createObject();- val.put("url", url);+ if (!TextUtil.isNullOrEmpty(url)) {+ val.put("url", url);+ }if (!TextUtil.isNullOrEmpty(httpMethod)) {val.put("httpMethod", httpMethod);}diff --git a/model/src/main/java/org/openremote/model/value/impl/ValueFactoryImpl.java b/model/src/main/java/org/openremote/model/value/impl/ValueFactoryImpl.javaindex 6d19e24ee..051834835 100644--- a/model/src/main/java/org/openremote/model/value/impl/ValueFactoryImpl.java+++ b/model/src/main/java/org/openremote/model/value/impl/ValueFactoryImpl.java@@ -51,6 +51,9 @@ public class ValueFactoryImpl implements ValueFactory {@Overridepublic <T extends Value> Optional<T> parse(String jsonString) throws ValueException {+ if (jsonString.isEmpty()) {+ return Optional.empty();+ }if (jsonString.startsWith("(") && jsonString.endsWith(")")) {// some clients send in (json) expecting an eval is requiredjsonString = jsonString.substring(1, jsonString.length() - 1);