diff --git a/application/src/main/java/org/thingsboard/server/service/edge/instructions/DefaultEdgeInstallInstructionsService.java b/application/src/main/java/org/thingsboard/server/service/edge/instructions/DefaultEdgeInstallInstructionsService.java index fef3c2644a..ba2cd06ee1 100644 --- a/application/src/main/java/org/thingsboard/server/service/edge/instructions/DefaultEdgeInstallInstructionsService.java +++ b/application/src/main/java/org/thingsboard/server/service/edge/instructions/DefaultEdgeInstallInstructionsService.java @@ -16,6 +16,7 @@ package org.thingsboard.server.service.edge.instructions; import lombok.RequiredArgsConstructor; +import lombok.Setter; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Value; import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; @@ -52,6 +53,7 @@ public class DefaultEdgeInstallInstructionsService implements EdgeInstallInstruc private boolean sslEnabled; @Value("${app.version:unknown}") + @Setter private String appVersion; @Override @@ -68,11 +70,6 @@ public class DefaultEdgeInstallInstructionsService implements EdgeInstallInstruc } } - @Override - public void updateApplicationVersion(String version) { - appVersion = version; - } - private EdgeInstructions getDockerInstallInstructions(Edge edge, HttpServletRequest request) { String dockerInstallInstructions = readFile(resolveFile("docker", "instructions.md")); String baseUrl = request.getServerName(); diff --git a/application/src/main/java/org/thingsboard/server/service/edge/instructions/DefaultEdgeUpgradeInstructionsService.java b/application/src/main/java/org/thingsboard/server/service/edge/instructions/DefaultEdgeUpgradeInstructionsService.java index 212fe781de..940a813fc6 100644 --- a/application/src/main/java/org/thingsboard/server/service/edge/instructions/DefaultEdgeUpgradeInstructionsService.java +++ b/application/src/main/java/org/thingsboard/server/service/edge/instructions/DefaultEdgeUpgradeInstructionsService.java @@ -16,6 +16,7 @@ package org.thingsboard.server.service.edge.instructions; import lombok.RequiredArgsConstructor; +import lombok.Setter; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Value; import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; @@ -48,6 +49,7 @@ public class DefaultEdgeUpgradeInstructionsService implements EdgeUpgradeInstruc private final InstallScripts installScripts; @Value("${app.version:unknown}") + @Setter private String appVersion; @Override @@ -65,11 +67,6 @@ public class DefaultEdgeUpgradeInstructionsService implements EdgeUpgradeInstruc } } - @Override - public void updateApplicationVersion(String version) { - appVersion = version; - } - @Override public void updateInstructionMap(Map map) { for (String key : map.keySet()) { diff --git a/application/src/main/java/org/thingsboard/server/service/edge/instructions/EdgeInstallInstructionsService.java b/application/src/main/java/org/thingsboard/server/service/edge/instructions/EdgeInstallInstructionsService.java index 2c1ef4fe87..9df1f86e86 100644 --- a/application/src/main/java/org/thingsboard/server/service/edge/instructions/EdgeInstallInstructionsService.java +++ b/application/src/main/java/org/thingsboard/server/service/edge/instructions/EdgeInstallInstructionsService.java @@ -24,5 +24,5 @@ public interface EdgeInstallInstructionsService { EdgeInstructions getInstallInstructions(Edge edge, String installationMethod, HttpServletRequest request); - void updateApplicationVersion(String version); + void setAppVersion(String version); } diff --git a/application/src/main/java/org/thingsboard/server/service/edge/instructions/EdgeUpgradeInstructionsService.java b/application/src/main/java/org/thingsboard/server/service/edge/instructions/EdgeUpgradeInstructionsService.java index e6f5cb0753..be40bc6c89 100644 --- a/application/src/main/java/org/thingsboard/server/service/edge/instructions/EdgeUpgradeInstructionsService.java +++ b/application/src/main/java/org/thingsboard/server/service/edge/instructions/EdgeUpgradeInstructionsService.java @@ -26,5 +26,5 @@ public interface EdgeUpgradeInstructionsService { void updateInstructionMap(Map upgradeVersions); - void updateApplicationVersion(String version); + void setAppVersion(String version); } diff --git a/application/src/main/java/org/thingsboard/server/service/update/DefaultUpdateService.java b/application/src/main/java/org/thingsboard/server/service/update/DefaultUpdateService.java index 6a86d022df..48a4187efc 100644 --- a/application/src/main/java/org/thingsboard/server/service/update/DefaultUpdateService.java +++ b/application/src/main/java/org/thingsboard/server/service/update/DefaultUpdateService.java @@ -155,15 +155,13 @@ public class DefaultUpdateService implements UpdateService { .build()); } ObjectNode edgeRequest = JacksonUtil.newObjectNode().put(VERSION_PARAM, version); - String prevEdgeInstallVersion = edgeInstallVersion; - edgeInstallVersion = restClient.postForObject(UPDATE_SERVER_BASE_URL + "/api/v1/edge/installMapping", new HttpEntity<>(edgeRequest.toString(), headers), String.class); - if (edgeInstallVersion != null && !edgeInstallVersion.equals(prevEdgeInstallVersion)) { - edgeInstallInstructionsService.updateApplicationVersion(edgeInstallVersion); - edgeUpgradeInstructionsService.updateApplicationVersion(edgeInstallVersion); + String edgeInstallVersion = restClient.postForObject(UPDATE_SERVER_BASE_URL + "/api/v1/edge/installMapping", new HttpEntity<>(edgeRequest.toString(), headers), String.class); + if (edgeInstallVersion != null) { + edgeInstallInstructionsService.setAppVersion(edgeInstallVersion); + edgeUpgradeInstructionsService.setAppVersion(edgeInstallVersion); } - EdgeUpgradeMessage prevEdgeUpgradeMessage = edgeUpgradeMessage; - edgeUpgradeMessage = restClient.postForObject(UPDATE_SERVER_BASE_URL + "/api/v1/edge/upgradeMapping", new HttpEntity<>(edgeRequest.toString(), headers), EdgeUpgradeMessage.class); - if (edgeUpgradeMessage != null && !edgeUpgradeMessage.equals(prevEdgeUpgradeMessage)) { + EdgeUpgradeMessage edgeUpgradeMessage = restClient.postForObject(UPDATE_SERVER_BASE_URL + "/api/v1/edge/upgradeMapping", new HttpEntity<>(edgeRequest.toString(), headers), EdgeUpgradeMessage.class); + if (edgeUpgradeMessage != null) { edgeUpgradeInstructionsService.updateInstructionMap(edgeUpgradeMessage.getEdgeVersions()); } } catch (Exception e) {