|
|
|
@ -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() |
|
|
|
|