parent
862a352b28
commit
4887952386
|
@ -8,10 +8,14 @@ import com.dispose.ability.impl.HuaWeiAbilityImpl;
|
||||||
import com.dispose.ability.impl.PengXinAbilityImpl;
|
import com.dispose.ability.impl.PengXinAbilityImpl;
|
||||||
import com.dispose.ability.impl.VirtualAbilityImpl;
|
import com.dispose.ability.impl.VirtualAbilityImpl;
|
||||||
import com.dispose.common.DisposeCapacityType;
|
import com.dispose.common.DisposeCapacityType;
|
||||||
|
import com.dispose.common.DisposeConfigValue;
|
||||||
|
import com.dispose.common.DisposeObjectType;
|
||||||
import com.dispose.common.ErrorCode;
|
import com.dispose.common.ErrorCode;
|
||||||
|
import com.dispose.common.Helper;
|
||||||
import com.dispose.common.HttpType;
|
import com.dispose.common.HttpType;
|
||||||
import com.dispose.manager.DisposeDeviceManager;
|
import com.dispose.manager.DisposeDeviceManager;
|
||||||
import com.dispose.mapper.ServiceGroupMapper;
|
import com.dispose.mapper.ServiceGroupMapper;
|
||||||
|
import com.dispose.pojo.entity.DisposeCapacity;
|
||||||
import com.dispose.pojo.entity.DisposeDevice;
|
import com.dispose.pojo.entity.DisposeDevice;
|
||||||
import com.dispose.pojo.po.AbilityInfo;
|
import com.dispose.pojo.po.AbilityInfo;
|
||||||
import com.dispose.service.DisposeAbilityRouterService;
|
import com.dispose.service.DisposeAbilityRouterService;
|
||||||
|
@ -115,7 +119,8 @@ public class DisposeAbilityRouterServiceImpl implements DisposeAbilityRouterServ
|
||||||
DisposeAbility db;
|
DisposeAbility db;
|
||||||
|
|
||||||
String httpType = dev.getUrlType() == HttpType.HTTP ? "http://" : "https://";
|
String httpType = dev.getUrlType() == HttpType.HTTP ? "http://" : "https://";
|
||||||
String addr = (dev.getIpPort() == null || dev.getIpPort().length() == 0) ? dev.getIpAddr() : (dev.getIpAddr() + ":" + dev.getIpPort());
|
String addr = (dev.getIpPort() == null || dev.getIpPort()
|
||||||
|
.length() == 0) ? dev.getIpAddr() : (dev.getIpAddr() + ":" + dev.getIpPort());
|
||||||
String url = httpType + addr + "/" + dev.getUrlPath();
|
String url = httpType + addr + "/" + dev.getUrlPath();
|
||||||
|
|
||||||
switch (dev.getDeviceType()) {
|
switch (dev.getDeviceType()) {
|
||||||
|
@ -160,6 +165,38 @@ public class DisposeAbilityRouterServiceImpl implements DisposeAbilityRouterServ
|
||||||
return ErrorCode.ERR_OK;
|
return ErrorCode.ERR_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Is carry ip boolean.
|
||||||
|
*
|
||||||
|
* @param disposeIp the dispose ip
|
||||||
|
* @param ipSegment the ip segment
|
||||||
|
* @return the boolean
|
||||||
|
*/
|
||||||
|
private boolean isCarryIp(String disposeIp, String ipSegment) {
|
||||||
|
for (String v : ipSegment.split(DisposeConfigValue.SPLIT_CHAR)) {
|
||||||
|
if (Helper.ipInRange(v, disposeIp)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Is carry dispose object boolean.
|
||||||
|
*
|
||||||
|
* @param disposeIp the dispose ip
|
||||||
|
* @param cfgProtect the cfg protect
|
||||||
|
* @return the boolean
|
||||||
|
*/
|
||||||
|
private boolean isCarryDisposeObject(String disposeIp, List<DisposeCapacity> cfgProtect) {
|
||||||
|
|
||||||
|
if (cfgProtect.stream().noneMatch(k -> (k.getObjectType().getValue() & DisposeObjectType.IP.getValue()) != 0)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return cfgProtect.stream().anyMatch(k -> isCarryIp(disposeIp, k.getProtectIp()));
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Verify dispose capacity error code.
|
* Verify dispose capacity error code.
|
||||||
*
|
*
|
||||||
|
@ -182,6 +219,12 @@ public class DisposeAbilityRouterServiceImpl implements DisposeAbilityRouterServ
|
||||||
return ErrorCode.ERR_NOSUCHTYPE;
|
return ErrorCode.ERR_NOSUCHTYPE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// if (getAllAbilityDevices().stream()
|
||||||
|
// .filter(f -> deviceId == -1 || f.getDev().getId().equals(deviceId))
|
||||||
|
// .noneMatch(f -> isCarryDisposeObject(disposeIp, f.getDev().getDevCapacity()))) {
|
||||||
|
// return ErrorCode.ERR_NOSUCHDEVICE;
|
||||||
|
// }
|
||||||
|
|
||||||
if (getAllAbilityDevices().stream()
|
if (getAllAbilityDevices().stream()
|
||||||
.noneMatch(c -> c.getDb().isCarryProtectIp(disposeIp))) {
|
.noneMatch(c -> c.getDb().isCarryProtectIp(disposeIp))) {
|
||||||
return ErrorCode.ERR_IPNODEVICE;
|
return ErrorCode.ERR_IPNODEVICE;
|
||||||
|
@ -211,6 +254,7 @@ public class DisposeAbilityRouterServiceImpl implements DisposeAbilityRouterServ
|
||||||
*
|
*
|
||||||
* @param ipAddr the ip addr
|
* @param ipAddr the ip addr
|
||||||
* @param ipPort the ip port
|
* @param ipPort the ip port
|
||||||
|
* @param deviceType the device type
|
||||||
* @return the ability device hash key
|
* @return the ability device hash key
|
||||||
*/
|
*/
|
||||||
private String getAbilityDeviceHashKey(String ipAddr, String ipPort, String deviceType) {
|
private String getAbilityDeviceHashKey(String ipAddr, String ipPort, String deviceType) {
|
||||||
|
|
Loading…
Reference in New Issue