mirror of
https://repository.entgra.net/community/device-mgt-core.git
synced 2025-10-06 02:01:45 +00:00
Revert f3f7635d3b
This commit is contained in:
parent
44904b6601
commit
4fdeec89cc
@ -420,12 +420,5 @@ public interface DeviceDAO {
|
|||||||
*/
|
*/
|
||||||
List<EnrolmentInfo> getEnrolmentsByStatus(List<DeviceIdentifier> deviceIds, Status status,
|
List<EnrolmentInfo> getEnrolmentsByStatus(List<DeviceIdentifier> deviceIds, Status status,
|
||||||
int tenantId) throws DeviceManagementDAOException;
|
int tenantId) throws DeviceManagementDAOException;
|
||||||
|
|
||||||
/**
|
|
||||||
* Retrieving the tenants which are have device enrolled.
|
|
||||||
* @return
|
|
||||||
* @throws DeviceManagementDAOException
|
|
||||||
*/
|
|
||||||
List<Integer> getDeviceEnrolledTenants() throws DeviceManagementDAOException;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -1062,26 +1062,4 @@ public abstract class AbstractDeviceDAOImpl implements DeviceDAO {
|
|||||||
return devices;
|
return devices;
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<Integer> getDeviceEnrolledTenants() throws DeviceManagementDAOException {
|
|
||||||
Connection conn;
|
|
||||||
PreparedStatement stmt = null;
|
|
||||||
ResultSet rs = null;
|
|
||||||
List<Integer> tenants = new ArrayList<>();
|
|
||||||
try {
|
|
||||||
conn = this.getConnection();
|
|
||||||
String sql = "SELECT distinct(TENANT_ID) FROM DM_DEVICE";
|
|
||||||
stmt = conn.prepareStatement(sql);
|
|
||||||
rs = stmt.executeQuery();
|
|
||||||
while (rs.next()) {
|
|
||||||
tenants.add(rs.getInt("TENANT_ID"));
|
|
||||||
}
|
|
||||||
} catch (SQLException e) {
|
|
||||||
throw new DeviceManagementDAOException("Error occurred while retrieving tenants which have " +
|
|
||||||
"device registered.", e);
|
|
||||||
} finally {
|
|
||||||
DeviceManagementDAOUtil.cleanupResources(stmt, rs);
|
|
||||||
}
|
|
||||||
return tenants;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -307,10 +307,6 @@ public interface DeviceManagementProviderService {
|
|||||||
|
|
||||||
PolicyMonitoringManager getPolicyMonitoringManager(String deviceType);
|
PolicyMonitoringManager getPolicyMonitoringManager(String deviceType);
|
||||||
|
|
||||||
|
|
||||||
List<Integer> getDeviceEnrolledTenants() throws DeviceManagementException;
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Change device status.
|
* Change device status.
|
||||||
*
|
*
|
||||||
@ -321,5 +317,4 @@ public interface DeviceManagementProviderService {
|
|||||||
*/
|
*/
|
||||||
boolean changeDeviceStatus(DeviceIdentifier deviceIdentifier, EnrolmentInfo.Status newStatus)
|
boolean changeDeviceStatus(DeviceIdentifier deviceIdentifier, EnrolmentInfo.Status newStatus)
|
||||||
throws DeviceManagementException;
|
throws DeviceManagementException;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1279,21 +1279,6 @@ public class DeviceManagementProviderServiceImpl implements DeviceManagementProv
|
|||||||
return dms.getPolicyMonitoringManager();
|
return dms.getPolicyMonitoringManager();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public List<Integer> getDeviceEnrolledTenants() throws DeviceManagementException {
|
|
||||||
try {
|
|
||||||
DeviceManagementDAOFactory.openConnection();
|
|
||||||
return deviceDAO.getDeviceEnrolledTenants();
|
|
||||||
} catch (DeviceManagementDAOException e) {
|
|
||||||
throw new DeviceManagementException("Error occurred while retrieving the tenants " +
|
|
||||||
"which have device enrolled.", e);
|
|
||||||
} catch (SQLException e) {
|
|
||||||
throw new DeviceManagementException("Error occurred while opening a connection to the data source", e);
|
|
||||||
} finally {
|
|
||||||
DeviceManagementDAOFactory.closeConnection();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<Device> getDevicesOfUser(String username) throws DeviceManagementException {
|
public List<Device> getDevicesOfUser(String username) throws DeviceManagementException {
|
||||||
List<Device> devices = new ArrayList<>();
|
List<Device> devices = new ArrayList<>();
|
||||||
|
|||||||
@ -23,7 +23,6 @@ import com.google.gson.Gson;
|
|||||||
import org.apache.commons.logging.Log;
|
import org.apache.commons.logging.Log;
|
||||||
import org.apache.commons.logging.LogFactory;
|
import org.apache.commons.logging.LogFactory;
|
||||||
import org.wso2.carbon.context.PrivilegedCarbonContext;
|
import org.wso2.carbon.context.PrivilegedCarbonContext;
|
||||||
import org.wso2.carbon.device.mgt.common.DeviceManagementException;
|
|
||||||
import org.wso2.carbon.device.mgt.common.OperationMonitoringTaskConfig;
|
import org.wso2.carbon.device.mgt.common.OperationMonitoringTaskConfig;
|
||||||
import org.wso2.carbon.device.mgt.core.internal.DeviceManagementDataHolder;
|
import org.wso2.carbon.device.mgt.core.internal.DeviceManagementDataHolder;
|
||||||
import org.wso2.carbon.device.mgt.core.task.DeviceMgtTaskException;
|
import org.wso2.carbon.device.mgt.core.task.DeviceMgtTaskException;
|
||||||
@ -34,7 +33,6 @@ import org.wso2.carbon.user.api.UserStoreException;
|
|||||||
import org.wso2.carbon.device.mgt.common.DeviceManagementException;
|
import org.wso2.carbon.device.mgt.common.DeviceManagementException;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
public class DeviceDetailsRetrieverTask implements Task {
|
public class DeviceDetailsRetrieverTask implements Task {
|
||||||
@ -66,18 +64,15 @@ public class DeviceDetailsRetrieverTask implements Task {
|
|||||||
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(tenantDomain);
|
PrivilegedCarbonContext.getThreadLocalCarbonContext().setTenantDomain(tenant.getDomain());
|
||||||
PrivilegedCarbonContext.getThreadLocalCarbonContext().setTenantId(tenant);
|
PrivilegedCarbonContext.getThreadLocalCarbonContext().setTenantId(tenant.getId());
|
||||||
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
|
||||||
@ -93,9 +88,6 @@ 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);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -30,9 +30,8 @@ import org.wso2.carbon.ntask.core.Task;
|
|||||||
import org.wso2.carbon.device.mgt.common.policy.mgt.monitor.PolicyComplianceException;
|
import org.wso2.carbon.device.mgt.common.policy.mgt.monitor.PolicyComplianceException;
|
||||||
import org.wso2.carbon.policy.mgt.core.internal.PolicyManagementDataHolder;
|
import org.wso2.carbon.policy.mgt.core.internal.PolicyManagementDataHolder;
|
||||||
import org.wso2.carbon.policy.mgt.core.mgt.MonitoringManager;
|
import org.wso2.carbon.policy.mgt.core.mgt.MonitoringManager;
|
||||||
|
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 org.wso2.carbon.device.mgt.core.service.DeviceManagementProviderServiceImpl;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@ -62,19 +61,15 @@ public class MonitoringTask implements Task {
|
|||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
Tenant tenants[] = PolicyManagementDataHolder.getInstance().
|
||||||
PolicyManagementDataHolder.getInstance().
|
|
||||||
getRealmService().getTenantManager().getAllTenants();
|
getRealmService().getTenantManager().getAllTenants();
|
||||||
DeviceManagementProviderService deviceManagementService = new DeviceManagementProviderServiceImpl();
|
|
||||||
List<Integer> tenants = deviceManagementService.getDeviceEnrolledTenants();
|
|
||||||
|
|
||||||
for (Integer tenant : tenants) {
|
for (Tenant tenant : tenants) {
|
||||||
String tenantDomain = PolicyManagementDataHolder.getInstance().
|
|
||||||
getRealmService().getTenantManager().getDomain(tenant);
|
|
||||||
try {
|
try {
|
||||||
PrivilegedCarbonContext.startTenantFlow();
|
PrivilegedCarbonContext.startTenantFlow();
|
||||||
PrivilegedCarbonContext.getThreadLocalCarbonContext().setTenantDomain(tenantDomain);
|
PrivilegedCarbonContext.getThreadLocalCarbonContext().setTenantDomain(tenant.getDomain());
|
||||||
PrivilegedCarbonContext.getThreadLocalCarbonContext().setTenantId(tenant);
|
PrivilegedCarbonContext.getThreadLocalCarbonContext().setTenantId(tenant.getId());
|
||||||
|
|
||||||
MonitoringManager monitoringManager = PolicyManagementDataHolder.getInstance().getMonitoringManager();
|
MonitoringManager monitoringManager = PolicyManagementDataHolder.getInstance().getMonitoringManager();
|
||||||
List<String> deviceTypes = new ArrayList<>();
|
List<String> deviceTypes = new ArrayList<>();
|
||||||
@ -147,8 +142,6 @@ public class MonitoringTask 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 service ", e);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user