use of org.traccar.model.Server in project traccar by tananaev.
the class DeviceManager method lookupAttribute.
private Object lookupAttribute(long deviceId, String attributeName, boolean lookupConfig) {
Object result = null;
Device device = getById(deviceId);
if (device != null) {
result = device.getAttributes().get(attributeName);
if (result == null && lookupGroupsAttribute) {
long groupId = device.getGroupId();
while (groupId != 0) {
Group group = Context.getGroupsManager().getById(groupId);
if (group != null) {
result = group.getAttributes().get(attributeName);
if (result != null) {
break;
}
groupId = group.getGroupId();
} else {
groupId = 0;
}
}
}
if (result == null) {
if (lookupConfig) {
result = Context.getConfig().getString(attributeName);
} else {
Server server = Context.getPermissionsManager().getServer();
result = server.getAttributes().get(attributeName);
}
}
}
return result;
}