|
|
|
@ -30,6 +30,8 @@ import org.wso2.carbon.device.mgt.core.task.DeviceTaskManager;
|
|
|
|
|
import org.wso2.carbon.ntask.core.Task;
|
|
|
|
|
import org.wso2.carbon.user.api.Tenant;
|
|
|
|
|
import org.wso2.carbon.user.api.UserStoreException;
|
|
|
|
|
import org.wso2.carbon.device.mgt.common.DeviceManagementException;
|
|
|
|
|
import java.util.List;
|
|
|
|
|
|
|
|
|
|
import java.util.Map;
|
|
|
|
|
|
|
|
|
@ -58,20 +60,22 @@ public class DeviceDetailsRetrieverTask implements Task {
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void execute() {
|
|
|
|
|
|
|
|
|
|
if (log.isDebugEnabled()) {
|
|
|
|
|
log.debug("Device details retrieving task started to run.");
|
|
|
|
|
}
|
|
|
|
|
try {
|
|
|
|
|
Tenant tenants[] = DeviceManagementDataHolder.getInstance().
|
|
|
|
|
getRealmService().getTenantManager().getAllTenants();
|
|
|
|
|
|
|
|
|
|
for (Tenant tenant : tenants) {
|
|
|
|
|
|
|
|
|
|
// Tenant tenants[] = DeviceManagementDataHolder.getInstance().
|
|
|
|
|
// getRealmService().getTenantManager().getAllTenants();
|
|
|
|
|
|
|
|
|
|
List<Integer> tenants = DeviceManagementDataHolder.getInstance().
|
|
|
|
|
getDeviceManagementProvider().getDeviceEnrolledTenants();
|
|
|
|
|
for (Integer tenant : tenants) {
|
|
|
|
|
String tenantDomain = DeviceManagementDataHolder.getInstance().
|
|
|
|
|
getRealmService().getTenantManager().getDomain(tenant);
|
|
|
|
|
try {
|
|
|
|
|
PrivilegedCarbonContext.startTenantFlow();
|
|
|
|
|
PrivilegedCarbonContext.getThreadLocalCarbonContext().setTenantDomain(tenant.getDomain());
|
|
|
|
|
PrivilegedCarbonContext.getThreadLocalCarbonContext().setTenantId(tenant.getId());
|
|
|
|
|
PrivilegedCarbonContext.getThreadLocalCarbonContext().setTenantDomain(tenantDomain);
|
|
|
|
|
PrivilegedCarbonContext.getThreadLocalCarbonContext().setTenantId(tenant);
|
|
|
|
|
DeviceTaskManager deviceTaskManager = new DeviceTaskManagerImpl(deviceType,
|
|
|
|
|
operationMonitoringTaskConfig);
|
|
|
|
|
//pass the configurations also from here, monitoring tasks
|
|
|
|
@ -87,8 +91,12 @@ public class DeviceDetailsRetrieverTask implements Task {
|
|
|
|
|
}
|
|
|
|
|
} catch (UserStoreException e) {
|
|
|
|
|
log.error("Error occurred while trying to get the available tenants", e);
|
|
|
|
|
} catch (DeviceManagementException e) {
|
|
|
|
|
log.error("Error occurred while trying to get the available tenants " +
|
|
|
|
|
"from device manager provider service.", e);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|