mirror of
https://repository.entgra.net/community/device-mgt-core.git
synced 2025-10-06 02:01:45 +00:00
Fix config fetching and device type filtering for tenants
This commit is contained in:
parent
2c7463a072
commit
2e811aa12b
@ -1410,29 +1410,26 @@ public class DeviceManagementProviderServiceImpl implements DeviceManagementProv
|
|||||||
publicSharedDeviceTypesInDB = deviceTypeDAO.getSharedDeviceTypes();
|
publicSharedDeviceTypesInDB = deviceTypeDAO.getSharedDeviceTypes();
|
||||||
Map<DeviceTypeServiceIdentifier, DeviceManagementService> registeredTypes =
|
Map<DeviceTypeServiceIdentifier, DeviceManagementService> registeredTypes =
|
||||||
pluginRepository.getAllDeviceManagementServices(tenantId);
|
pluginRepository.getAllDeviceManagementServices(tenantId);
|
||||||
Set<String> deviceTypeSetForTenant = new HashSet<>();
|
|
||||||
|
|
||||||
if (registeredTypes != null) {
|
|
||||||
if (deviceTypesProvidedByTenant != null) {
|
|
||||||
for (DeviceType deviceType : deviceTypesProvidedByTenant) {
|
|
||||||
DeviceTypeServiceIdentifier providerKey = new DeviceTypeServiceIdentifier(deviceType.getName(), tenantId);
|
|
||||||
if (registeredTypes.get(providerKey) != null || deviceType.getDeviceTypeMetaDefinition() != null) {
|
|
||||||
deviceTypesResponse.add(deviceType.getName());
|
|
||||||
deviceTypeSetForTenant.add(deviceType.getName());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// Get the device from the public space, however if there is another device with same name then give
|
// Get the device from the public space, however if there is another device with same name then give
|
||||||
// priority to that
|
// priority to that
|
||||||
|
if (deviceTypesProvidedByTenant != null) {
|
||||||
|
for (DeviceType deviceType : deviceTypesProvidedByTenant) {
|
||||||
|
deviceTypesResponse.add(deviceType.getName());
|
||||||
|
}
|
||||||
|
}
|
||||||
if (publicSharedDeviceTypesInDB != null) {
|
if (publicSharedDeviceTypesInDB != null) {
|
||||||
for (String deviceType : publicSharedDeviceTypesInDB) {
|
for (String deviceType: publicSharedDeviceTypesInDB) {
|
||||||
DeviceTypeServiceIdentifier providerKey = new DeviceTypeServiceIdentifier(deviceType);
|
if (!deviceTypesResponse.contains(deviceType)) {
|
||||||
if (registeredTypes.get(providerKey) != null && !deviceTypeSetForTenant.contains(deviceType)) {
|
|
||||||
deviceTypesResponse.add(deviceType);
|
deviceTypesResponse.add(deviceType);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (registeredTypes != null) {
|
||||||
|
for (DeviceTypeServiceIdentifier deviceType: registeredTypes.keySet()) {
|
||||||
|
if (!deviceTypesResponse.contains(deviceType.getDeviceType())) {
|
||||||
|
deviceTypesResponse.add(deviceType.getDeviceType());
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} catch (DeviceManagementDAOException e) {
|
} catch (DeviceManagementDAOException e) {
|
||||||
String msg = "Error occurred while obtaining the device types.";
|
String msg = "Error occurred while obtaining the device types.";
|
||||||
@ -3489,12 +3486,12 @@ public class DeviceManagementProviderServiceImpl implements DeviceManagementProv
|
|||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
Device device = this.getDevice(new DeviceIdentifier(deviceProperties.getDeviceIdentifier(),
|
|
||||||
deviceProperties.getDeviceTypeName()), false);
|
|
||||||
String owner = device.getEnrolmentInfo().getOwner();
|
|
||||||
PrivilegedCarbonContext.startTenantFlow();
|
PrivilegedCarbonContext.startTenantFlow();
|
||||||
PrivilegedCarbonContext ctx = PrivilegedCarbonContext.getThreadLocalCarbonContext();
|
PrivilegedCarbonContext ctx = PrivilegedCarbonContext.getThreadLocalCarbonContext();
|
||||||
ctx.setTenantId(Integer.parseInt(deviceProperties.getTenantId()), true);
|
ctx.setTenantId(Integer.parseInt(deviceProperties.getTenantId()), true);
|
||||||
|
Device device = this.getDevice(new DeviceIdentifier(deviceProperties.getDeviceIdentifier(),
|
||||||
|
deviceProperties.getDeviceTypeName()), false);
|
||||||
|
String owner = device.getEnrolmentInfo().getOwner();
|
||||||
PlatformConfiguration configuration = this.getConfiguration(device.getType());
|
PlatformConfiguration configuration = this.getConfiguration(device.getType());
|
||||||
List<ConfigurationEntry> configurationEntries = new ArrayList<>();
|
List<ConfigurationEntry> configurationEntries = new ArrayList<>();
|
||||||
if (configuration != null) {
|
if (configuration != null) {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user