diff --git a/application/src/main/java/org/thingsboard/server/controller/EdgeController.java b/application/src/main/java/org/thingsboard/server/controller/EdgeController.java index 26a7938dfb..f85529dbfe 100644 --- a/application/src/main/java/org/thingsboard/server/controller/EdgeController.java +++ b/application/src/main/java/org/thingsboard/server/controller/EdgeController.java @@ -571,7 +571,7 @@ public class EdgeController extends BaseController { EdgeId edgeId = new EdgeId(toUUID(strEdgeId)); edgeId = checkNotNull(edgeId); Edge edge = checkEdgeId(edgeId, Operation.READ); - return checkNotNull(edgeInstallServiceOpt.get().getInstallInstructions(getTenantId(), edge, installationMethod, request)); + return checkNotNull(edgeInstallServiceOpt.get().getInstallInstructions(edge, installationMethod, request)); } else { throw new ThingsboardException("Edges support disabled", ThingsboardErrorCode.GENERAL); } @@ -589,7 +589,7 @@ public class EdgeController extends BaseController { @ApiParam(value = "Installation method ('docker', 'ubuntu' or 'centos')", allowableValues = "docker,ubuntu,centos") @PathVariable("method") String method) throws Exception { if (isEdgesEnabled() && edgeUpgradeServiceOpt.isPresent()) { - return checkNotNull(edgeUpgradeServiceOpt.get().getUpgradeInstructions(getTenantId(), edgeVersion, method)); + return checkNotNull(edgeUpgradeServiceOpt.get().getUpgradeInstructions(edgeVersion, method)); } else { throw new ThingsboardException("Edges support disabled", ThingsboardErrorCode.GENERAL); } diff --git a/application/src/main/java/org/thingsboard/server/service/edge/instructions/DefaultEdgeInstallService.java b/application/src/main/java/org/thingsboard/server/service/edge/instructions/DefaultEdgeInstallService.java index 24340f7a97..8ebc5322c7 100644 --- a/application/src/main/java/org/thingsboard/server/service/edge/instructions/DefaultEdgeInstallService.java +++ b/application/src/main/java/org/thingsboard/server/service/edge/instructions/DefaultEdgeInstallService.java @@ -22,7 +22,6 @@ import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; import org.springframework.stereotype.Service; import org.thingsboard.server.common.data.edge.Edge; import org.thingsboard.server.common.data.edge.EdgeInstructions; -import org.thingsboard.server.common.data.id.TenantId; import org.thingsboard.server.queue.util.TbCoreComponent; import org.thingsboard.server.service.install.InstallScripts; @@ -55,7 +54,7 @@ public class DefaultEdgeInstallService implements EdgeInstallService { private String appVersion; @Override - public EdgeInstructions getInstallInstructions(TenantId tenantId, Edge edge, String installationMethod, HttpServletRequest request) { + public EdgeInstructions getInstallInstructions(Edge edge, String installationMethod, HttpServletRequest request) { switch (installationMethod.toLowerCase()) { case "docker": return getDockerInstallInstructions(edge, request); diff --git a/application/src/main/java/org/thingsboard/server/service/edge/instructions/DefaultEdgeUpgradeService.java b/application/src/main/java/org/thingsboard/server/service/edge/instructions/DefaultEdgeUpgradeService.java index dbd08faef8..338c1fb8b7 100644 --- a/application/src/main/java/org/thingsboard/server/service/edge/instructions/DefaultEdgeUpgradeService.java +++ b/application/src/main/java/org/thingsboard/server/service/edge/instructions/DefaultEdgeUpgradeService.java @@ -16,14 +16,13 @@ package org.thingsboard.server.service.edge.instructions; import lombok.AllArgsConstructor; -import lombok.Data; +import lombok.Getter; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Value; import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; import org.springframework.stereotype.Service; import org.thingsboard.server.common.data.edge.EdgeInstructions; -import org.thingsboard.server.common.data.id.TenantId; import org.thingsboard.server.queue.util.TbCoreComponent; import org.thingsboard.server.service.install.InstallScripts; @@ -59,21 +58,21 @@ public class DefaultEdgeUpgradeService implements EdgeUpgradeService { private String appVersion; @Override - public EdgeInstructions getUpgradeInstructions(TenantId tenantId, String edgeVersion, String upgradeMethod) { + public EdgeInstructions getUpgradeInstructions(String edgeVersion, String upgradeMethod) { String tbVersion = appVersion.replace("-SNAPSHOT", ""); String currentEdgeVersion = convertEdgeVersionToDocsFormat(edgeVersion); switch (upgradeMethod.toLowerCase()) { case "docker": - return getDockerUpgradeInstructions(tenantId, tbVersion, currentEdgeVersion); + return getDockerUpgradeInstructions(tbVersion, currentEdgeVersion); case "ubuntu": case "centos": - return getLinuxUpgradeInstructions(tenantId, tbVersion, currentEdgeVersion, upgradeMethod.toLowerCase()); + return getLinuxUpgradeInstructions(tbVersion, currentEdgeVersion, upgradeMethod.toLowerCase()); default: throw new IllegalArgumentException("Unsupported upgrade method for Edge: " + upgradeMethod); } } - private EdgeInstructions getDockerUpgradeInstructions(TenantId tenantId, String tbVersion, String currentEdgeVersion) { + private EdgeInstructions getDockerUpgradeInstructions(String tbVersion, String currentEdgeVersion) { UpgradeInfo upgradeInfo = upgradeVersionHashMap.get(currentEdgeVersion); if (upgradeInfo.getNextVersion() == null || tbVersion.equals(currentEdgeVersion)) { return null; @@ -105,7 +104,7 @@ public class DefaultEdgeUpgradeService implements EdgeUpgradeService { return new EdgeInstructions(result.toString()); } - private EdgeInstructions getLinuxUpgradeInstructions(TenantId tenantId, String tbVersion, String currentEdgeVersion, String os) { + private EdgeInstructions getLinuxUpgradeInstructions(String tbVersion, String currentEdgeVersion, String os) { UpgradeInfo upgradeInfo = upgradeVersionHashMap.get(currentEdgeVersion); if (upgradeInfo.getNextVersion() == null || tbVersion.equals(currentEdgeVersion)) { return null; @@ -148,10 +147,6 @@ public class DefaultEdgeUpgradeService implements EdgeUpgradeService { return edgeVersion.replace("_", ".").substring(2); } - private String convertDocsFormatToEdgeVersion(String edgeVersion) { - return "V_" + edgeVersion.replace(".", "_"); - } - private String readFile(Path file) { try { return Files.readString(file); @@ -170,7 +165,7 @@ public class DefaultEdgeUpgradeService implements EdgeUpgradeService { } @AllArgsConstructor - @Data + @Getter public static class UpgradeInfo { private boolean upgradeDb; private String nextVersion; diff --git a/application/src/main/java/org/thingsboard/server/service/edge/instructions/EdgeInstallService.java b/application/src/main/java/org/thingsboard/server/service/edge/instructions/EdgeInstallService.java index cba8703920..996e14f16e 100644 --- a/application/src/main/java/org/thingsboard/server/service/edge/instructions/EdgeInstallService.java +++ b/application/src/main/java/org/thingsboard/server/service/edge/instructions/EdgeInstallService.java @@ -17,11 +17,10 @@ package org.thingsboard.server.service.edge.instructions; import org.thingsboard.server.common.data.edge.Edge; import org.thingsboard.server.common.data.edge.EdgeInstructions; -import org.thingsboard.server.common.data.id.TenantId; import javax.servlet.http.HttpServletRequest; public interface EdgeInstallService { - EdgeInstructions getInstallInstructions(TenantId tenantId, Edge edge, String installationMethod, HttpServletRequest request); + EdgeInstructions getInstallInstructions(Edge edge, String installationMethod, HttpServletRequest request); } diff --git a/application/src/main/java/org/thingsboard/server/service/edge/instructions/EdgeUpgradeService.java b/application/src/main/java/org/thingsboard/server/service/edge/instructions/EdgeUpgradeService.java index 878e38a468..b7747655ef 100644 --- a/application/src/main/java/org/thingsboard/server/service/edge/instructions/EdgeUpgradeService.java +++ b/application/src/main/java/org/thingsboard/server/service/edge/instructions/EdgeUpgradeService.java @@ -16,9 +16,8 @@ package org.thingsboard.server.service.edge.instructions; import org.thingsboard.server.common.data.edge.EdgeInstructions; -import org.thingsboard.server.common.data.id.TenantId; public interface EdgeUpgradeService { - EdgeInstructions getUpgradeInstructions(TenantId tenantId, String edgeVersion, String upgradeMethod) throws Exception; + EdgeInstructions getUpgradeInstructions(String edgeVersion, String upgradeMethod); }