Update service and TBEL version improvement
This commit is contained in:
parent
d520be1ae3
commit
b1884f675a
@ -44,7 +44,7 @@ public class NewPlatformVersionTriggerProcessor implements NotificationRuleTrigg
|
||||
@Override
|
||||
public NotificationInfo constructNotificationInfo(NewPlatformVersionTrigger trigger, NewPlatformVersionNotificationRuleTriggerConfig triggerConfig) {
|
||||
return NewPlatformVersionNotificationInfo.builder()
|
||||
.message(trigger.getMessage().getMessage())
|
||||
.message("New version available - " + trigger.getMessage().getLatestVersion())
|
||||
.build();
|
||||
}
|
||||
|
||||
|
||||
@ -21,6 +21,7 @@ import com.fasterxml.jackson.databind.node.ObjectNode;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.boot.info.BuildProperties;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.web.client.RestTemplate;
|
||||
import org.thingsboard.common.util.ThingsBoardThreadFactory;
|
||||
@ -57,6 +58,9 @@ public class DefaultUpdateService implements UpdateService {
|
||||
@Value("${updates.enabled}")
|
||||
private boolean updatesEnabled;
|
||||
|
||||
@Autowired(required = false)
|
||||
private BuildProperties buildProperties;
|
||||
|
||||
@Autowired
|
||||
private NotificationRuleProcessingService notificationRuleProcessingService;
|
||||
|
||||
@ -73,14 +77,11 @@ public class DefaultUpdateService implements UpdateService {
|
||||
|
||||
@PostConstruct
|
||||
private void init() {
|
||||
updateMessage = new UpdateMessage("", false, "");
|
||||
version = buildProperties != null ? buildProperties.getVersion() : "unknown";
|
||||
updateMessage = new UpdateMessage(false, version, "", "");
|
||||
if (updatesEnabled) {
|
||||
try {
|
||||
platform = System.getProperty("platform", "unknown");
|
||||
version = getClass().getPackage().getImplementationVersion();
|
||||
if (version == null) {
|
||||
version = "unknown";
|
||||
}
|
||||
instanceId = parseInstanceId();
|
||||
checkUpdatesFuture = scheduler.scheduleAtFixedRate(checkUpdatesRunnable, 0, 1, TimeUnit.HOURS);
|
||||
} catch (Exception e) {
|
||||
@ -131,9 +132,10 @@ public class DefaultUpdateService implements UpdateService {
|
||||
JsonNode response = restClient.postForObject(UPDATE_SERVER_BASE_URL + "/api/thingsboard/updates", request, JsonNode.class);
|
||||
UpdateMessage prevUpdateMessage = updateMessage;
|
||||
updateMessage = new UpdateMessage(
|
||||
response.get("message").asText(),
|
||||
response.get("updateAvailable").asBoolean(),
|
||||
version
|
||||
version,
|
||||
"3.5.0",
|
||||
"https://thingsboard.io/docs/user-guide/install/pe/upgrade-instructions"
|
||||
);
|
||||
if (updateMessage.isUpdateAvailable() && !updateMessage.equals(prevUpdateMessage)) {
|
||||
notificationRuleProcessingService.process(TenantId.SYS_TENANT_ID, NewPlatformVersionTrigger.builder()
|
||||
|
||||
@ -23,10 +23,14 @@ import lombok.Data;
|
||||
@Data
|
||||
public class UpdateMessage {
|
||||
|
||||
@ApiModelProperty(position = 1, value = "The message about new platform update available.")
|
||||
private final String message;
|
||||
@ApiModelProperty(position = 2, value = "'True' if new platform update is available.")
|
||||
@ApiModelProperty(position = 1, value = "'True' if new platform update is available.")
|
||||
private final boolean isUpdateAvailable;
|
||||
@ApiModelProperty(position = 3, value = "Current ThingsBoard version.")
|
||||
@ApiModelProperty(position = 2, value = "Current ThingsBoard version.")
|
||||
private final String currentVersion;
|
||||
@ApiModelProperty(position = 3, value = "Latest ThingsBoard version.")
|
||||
private final String latestVersion;
|
||||
@ApiModelProperty(position = 4, value = "Upgrade instructions URL.")
|
||||
private final String upgradeInstructionsUrl;
|
||||
|
||||
|
||||
}
|
||||
|
||||
2
pom.xml
2
pom.xml
@ -78,7 +78,7 @@
|
||||
<zookeeper.version>3.5.5</zookeeper.version>
|
||||
<protobuf.version>3.21.9</protobuf.version>
|
||||
<grpc.version>1.42.1</grpc.version>
|
||||
<tbel.version>1.0.5</tbel.version>
|
||||
<tbel.version>1.0.6</tbel.version>
|
||||
<lombok.version>1.18.18</lombok.version>
|
||||
<paho.client.version>1.2.4</paho.client.version>
|
||||
<paho.mqttv5.client.version>1.2.5</paho.mqttv5.client.version>
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user