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