|
|
@ -36,6 +36,8 @@ import org.wso2.carbon.device.mgt.common.group.mgt.GroupAlreadyExistException;
|
|
|
|
import org.wso2.carbon.device.mgt.common.group.mgt.GroupManagementException;
|
|
|
|
import org.wso2.carbon.device.mgt.common.group.mgt.GroupManagementException;
|
|
|
|
import org.wso2.carbon.device.mgt.common.group.mgt.GroupNotExistException;
|
|
|
|
import org.wso2.carbon.device.mgt.common.group.mgt.GroupNotExistException;
|
|
|
|
import org.wso2.carbon.device.mgt.common.group.mgt.RoleDoesNotExistException;
|
|
|
|
import org.wso2.carbon.device.mgt.common.group.mgt.RoleDoesNotExistException;
|
|
|
|
|
|
|
|
import org.wso2.carbon.device.mgt.core.dao.DeviceDAO;
|
|
|
|
|
|
|
|
import org.wso2.carbon.device.mgt.core.dao.DeviceManagementDAOFactory;
|
|
|
|
import org.wso2.carbon.device.mgt.core.dao.GroupDAO;
|
|
|
|
import org.wso2.carbon.device.mgt.core.dao.GroupDAO;
|
|
|
|
import org.wso2.carbon.device.mgt.core.dao.GroupManagementDAOException;
|
|
|
|
import org.wso2.carbon.device.mgt.core.dao.GroupManagementDAOException;
|
|
|
|
import org.wso2.carbon.device.mgt.core.dao.GroupManagementDAOFactory;
|
|
|
|
import org.wso2.carbon.device.mgt.core.dao.GroupManagementDAOFactory;
|
|
|
@ -56,12 +58,14 @@ public class GroupManagementProviderServiceImpl implements GroupManagementProvid
|
|
|
|
private static Log log = LogFactory.getLog(GroupManagementProviderServiceImpl.class);
|
|
|
|
private static Log log = LogFactory.getLog(GroupManagementProviderServiceImpl.class);
|
|
|
|
|
|
|
|
|
|
|
|
private GroupDAO groupDAO;
|
|
|
|
private GroupDAO groupDAO;
|
|
|
|
|
|
|
|
private DeviceDAO deviceDAO;
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* Set groupDAO from GroupManagementDAOFactory when class instantiate.
|
|
|
|
* Set groupDAO from GroupManagementDAOFactory when class instantiate.
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
public GroupManagementProviderServiceImpl() {
|
|
|
|
public GroupManagementProviderServiceImpl() {
|
|
|
|
this.groupDAO = GroupManagementDAOFactory.getGroupDAO();
|
|
|
|
this.groupDAO = GroupManagementDAOFactory.getGroupDAO();
|
|
|
|
|
|
|
|
this.deviceDAO = DeviceManagementDAOFactory.getDeviceDAO();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
@ -627,7 +631,7 @@ public class GroupManagementProviderServiceImpl implements GroupManagementProvid
|
|
|
|
* {@inheritDoc}
|
|
|
|
* {@inheritDoc}
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
public List<Device> getDevices(int groupId, int startIndex, int rowCount)
|
|
|
|
public List<Device> getDevices(int groupId, int startIndex, int rowCount, boolean requireDeviceProps)
|
|
|
|
throws GroupManagementException {
|
|
|
|
throws GroupManagementException {
|
|
|
|
if (log.isDebugEnabled()) {
|
|
|
|
if (log.isDebugEnabled()) {
|
|
|
|
log.debug("Group devices of group: " + groupId + " start index " + startIndex + " row count " + rowCount);
|
|
|
|
log.debug("Group devices of group: " + groupId + " start index " + startIndex + " row count " + rowCount);
|
|
|
@ -638,6 +642,16 @@ public class GroupManagementProviderServiceImpl implements GroupManagementProvid
|
|
|
|
rowCount = DeviceManagerUtil.validateDeviceListPageSize(rowCount);
|
|
|
|
rowCount = DeviceManagerUtil.validateDeviceListPageSize(rowCount);
|
|
|
|
GroupManagementDAOFactory.openConnection();
|
|
|
|
GroupManagementDAOFactory.openConnection();
|
|
|
|
devices = this.groupDAO.getDevices(groupId, startIndex, rowCount, tenantId);
|
|
|
|
devices = this.groupDAO.getDevices(groupId, startIndex, rowCount, tenantId);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if(requireDeviceProps) {
|
|
|
|
|
|
|
|
DeviceManagementDAOFactory.openConnection();
|
|
|
|
|
|
|
|
for (Device device : devices) {
|
|
|
|
|
|
|
|
Device retrievedDevice = deviceDAO.getDeviceProps(device.getDeviceIdentifier(), tenantId);
|
|
|
|
|
|
|
|
if (retrievedDevice != null && !retrievedDevice.getProperties().isEmpty()) {
|
|
|
|
|
|
|
|
device.setProperties(retrievedDevice.getProperties());
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
} catch (GroupManagementDAOException | SQLException | DeviceManagementException e) {
|
|
|
|
} catch (GroupManagementDAOException | SQLException | DeviceManagementException e) {
|
|
|
|
String msg = "Error occurred while getting devices in group.";
|
|
|
|
String msg = "Error occurred while getting devices in group.";
|
|
|
|
log.error(msg, e);
|
|
|
|
log.error(msg, e);
|
|
|
@ -648,6 +662,9 @@ public class GroupManagementProviderServiceImpl implements GroupManagementProvid
|
|
|
|
throw new GroupManagementException(msg, e);
|
|
|
|
throw new GroupManagementException(msg, e);
|
|
|
|
} finally {
|
|
|
|
} finally {
|
|
|
|
GroupManagementDAOFactory.closeConnection();
|
|
|
|
GroupManagementDAOFactory.closeConnection();
|
|
|
|
|
|
|
|
if(requireDeviceProps){
|
|
|
|
|
|
|
|
DeviceManagementDAOFactory.closeConnection();
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return devices;
|
|
|
|
return devices;
|
|
|
|
}
|
|
|
|
}
|
|
|
|