Remove unused parameters in service
This commit is contained in:
parent
7fad29e059
commit
6a1e5f315f
@ -571,7 +571,7 @@ public class EdgeController extends BaseController {
|
|||||||
EdgeId edgeId = new EdgeId(toUUID(strEdgeId));
|
EdgeId edgeId = new EdgeId(toUUID(strEdgeId));
|
||||||
edgeId = checkNotNull(edgeId);
|
edgeId = checkNotNull(edgeId);
|
||||||
Edge edge = checkEdgeId(edgeId, Operation.READ);
|
Edge edge = checkEdgeId(edgeId, Operation.READ);
|
||||||
return checkNotNull(edgeInstallServiceOpt.get().getInstallInstructions(getTenantId(), edge, installationMethod, request));
|
return checkNotNull(edgeInstallServiceOpt.get().getInstallInstructions(edge, installationMethod, request));
|
||||||
} else {
|
} else {
|
||||||
throw new ThingsboardException("Edges support disabled", ThingsboardErrorCode.GENERAL);
|
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")
|
@ApiParam(value = "Installation method ('docker', 'ubuntu' or 'centos')", allowableValues = "docker,ubuntu,centos")
|
||||||
@PathVariable("method") String method) throws Exception {
|
@PathVariable("method") String method) throws Exception {
|
||||||
if (isEdgesEnabled() && edgeUpgradeServiceOpt.isPresent()) {
|
if (isEdgesEnabled() && edgeUpgradeServiceOpt.isPresent()) {
|
||||||
return checkNotNull(edgeUpgradeServiceOpt.get().getUpgradeInstructions(getTenantId(), edgeVersion, method));
|
return checkNotNull(edgeUpgradeServiceOpt.get().getUpgradeInstructions(edgeVersion, method));
|
||||||
} else {
|
} else {
|
||||||
throw new ThingsboardException("Edges support disabled", ThingsboardErrorCode.GENERAL);
|
throw new ThingsboardException("Edges support disabled", ThingsboardErrorCode.GENERAL);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -22,7 +22,6 @@ import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
|
|||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.thingsboard.server.common.data.edge.Edge;
|
import org.thingsboard.server.common.data.edge.Edge;
|
||||||
import org.thingsboard.server.common.data.edge.EdgeInstructions;
|
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.queue.util.TbCoreComponent;
|
||||||
import org.thingsboard.server.service.install.InstallScripts;
|
import org.thingsboard.server.service.install.InstallScripts;
|
||||||
|
|
||||||
@ -55,7 +54,7 @@ public class DefaultEdgeInstallService implements EdgeInstallService {
|
|||||||
private String appVersion;
|
private String appVersion;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public EdgeInstructions getInstallInstructions(TenantId tenantId, Edge edge, String installationMethod, HttpServletRequest request) {
|
public EdgeInstructions getInstallInstructions(Edge edge, String installationMethod, HttpServletRequest request) {
|
||||||
switch (installationMethod.toLowerCase()) {
|
switch (installationMethod.toLowerCase()) {
|
||||||
case "docker":
|
case "docker":
|
||||||
return getDockerInstallInstructions(edge, request);
|
return getDockerInstallInstructions(edge, request);
|
||||||
|
|||||||
@ -16,14 +16,13 @@
|
|||||||
package org.thingsboard.server.service.edge.instructions;
|
package org.thingsboard.server.service.edge.instructions;
|
||||||
|
|
||||||
import lombok.AllArgsConstructor;
|
import lombok.AllArgsConstructor;
|
||||||
import lombok.Data;
|
import lombok.Getter;
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.springframework.beans.factory.annotation.Value;
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
|
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.thingsboard.server.common.data.edge.EdgeInstructions;
|
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.queue.util.TbCoreComponent;
|
||||||
import org.thingsboard.server.service.install.InstallScripts;
|
import org.thingsboard.server.service.install.InstallScripts;
|
||||||
|
|
||||||
@ -59,21 +58,21 @@ public class DefaultEdgeUpgradeService implements EdgeUpgradeService {
|
|||||||
private String appVersion;
|
private String appVersion;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public EdgeInstructions getUpgradeInstructions(TenantId tenantId, String edgeVersion, String upgradeMethod) {
|
public EdgeInstructions getUpgradeInstructions(String edgeVersion, String upgradeMethod) {
|
||||||
String tbVersion = appVersion.replace("-SNAPSHOT", "");
|
String tbVersion = appVersion.replace("-SNAPSHOT", "");
|
||||||
String currentEdgeVersion = convertEdgeVersionToDocsFormat(edgeVersion);
|
String currentEdgeVersion = convertEdgeVersionToDocsFormat(edgeVersion);
|
||||||
switch (upgradeMethod.toLowerCase()) {
|
switch (upgradeMethod.toLowerCase()) {
|
||||||
case "docker":
|
case "docker":
|
||||||
return getDockerUpgradeInstructions(tenantId, tbVersion, currentEdgeVersion);
|
return getDockerUpgradeInstructions(tbVersion, currentEdgeVersion);
|
||||||
case "ubuntu":
|
case "ubuntu":
|
||||||
case "centos":
|
case "centos":
|
||||||
return getLinuxUpgradeInstructions(tenantId, tbVersion, currentEdgeVersion, upgradeMethod.toLowerCase());
|
return getLinuxUpgradeInstructions(tbVersion, currentEdgeVersion, upgradeMethod.toLowerCase());
|
||||||
default:
|
default:
|
||||||
throw new IllegalArgumentException("Unsupported upgrade method for Edge: " + upgradeMethod);
|
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);
|
UpgradeInfo upgradeInfo = upgradeVersionHashMap.get(currentEdgeVersion);
|
||||||
if (upgradeInfo.getNextVersion() == null || tbVersion.equals(currentEdgeVersion)) {
|
if (upgradeInfo.getNextVersion() == null || tbVersion.equals(currentEdgeVersion)) {
|
||||||
return null;
|
return null;
|
||||||
@ -105,7 +104,7 @@ public class DefaultEdgeUpgradeService implements EdgeUpgradeService {
|
|||||||
return new EdgeInstructions(result.toString());
|
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);
|
UpgradeInfo upgradeInfo = upgradeVersionHashMap.get(currentEdgeVersion);
|
||||||
if (upgradeInfo.getNextVersion() == null || tbVersion.equals(currentEdgeVersion)) {
|
if (upgradeInfo.getNextVersion() == null || tbVersion.equals(currentEdgeVersion)) {
|
||||||
return null;
|
return null;
|
||||||
@ -148,10 +147,6 @@ public class DefaultEdgeUpgradeService implements EdgeUpgradeService {
|
|||||||
return edgeVersion.replace("_", ".").substring(2);
|
return edgeVersion.replace("_", ".").substring(2);
|
||||||
}
|
}
|
||||||
|
|
||||||
private String convertDocsFormatToEdgeVersion(String edgeVersion) {
|
|
||||||
return "V_" + edgeVersion.replace(".", "_");
|
|
||||||
}
|
|
||||||
|
|
||||||
private String readFile(Path file) {
|
private String readFile(Path file) {
|
||||||
try {
|
try {
|
||||||
return Files.readString(file);
|
return Files.readString(file);
|
||||||
@ -170,7 +165,7 @@ public class DefaultEdgeUpgradeService implements EdgeUpgradeService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@AllArgsConstructor
|
@AllArgsConstructor
|
||||||
@Data
|
@Getter
|
||||||
public static class UpgradeInfo {
|
public static class UpgradeInfo {
|
||||||
private boolean upgradeDb;
|
private boolean upgradeDb;
|
||||||
private String nextVersion;
|
private String nextVersion;
|
||||||
|
|||||||
@ -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.Edge;
|
||||||
import org.thingsboard.server.common.data.edge.EdgeInstructions;
|
import org.thingsboard.server.common.data.edge.EdgeInstructions;
|
||||||
import org.thingsboard.server.common.data.id.TenantId;
|
|
||||||
|
|
||||||
import javax.servlet.http.HttpServletRequest;
|
import javax.servlet.http.HttpServletRequest;
|
||||||
|
|
||||||
public interface EdgeInstallService {
|
public interface EdgeInstallService {
|
||||||
|
|
||||||
EdgeInstructions getInstallInstructions(TenantId tenantId, Edge edge, String installationMethod, HttpServletRequest request);
|
EdgeInstructions getInstallInstructions(Edge edge, String installationMethod, HttpServletRequest request);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -16,9 +16,8 @@
|
|||||||
package org.thingsboard.server.service.edge.instructions;
|
package org.thingsboard.server.service.edge.instructions;
|
||||||
|
|
||||||
import org.thingsboard.server.common.data.edge.EdgeInstructions;
|
import org.thingsboard.server.common.data.edge.EdgeInstructions;
|
||||||
import org.thingsboard.server.common.data.id.TenantId;
|
|
||||||
|
|
||||||
public interface EdgeUpgradeService {
|
public interface EdgeUpgradeService {
|
||||||
|
|
||||||
EdgeInstructions getUpgradeInstructions(TenantId tenantId, String edgeVersion, String upgradeMethod) throws Exception;
|
EdgeInstructions getUpgradeInstructions(String edgeVersion, String upgradeMethod);
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user