Fixed line spacing issues

revert-70aa11f8
Dulitha Wijewantha 10 years ago
parent b870490ea3
commit 315603481d

@ -35,155 +35,142 @@ import java.util.List;
public class DeviceManagerImpl implements DeviceManager { public class DeviceManagerImpl implements DeviceManager {
private DeviceDAO deviceDAO; private DeviceDAO deviceDAO;
private DeviceTypeDAO deviceTypeDAO; private DeviceTypeDAO deviceTypeDAO;
private DeviceManagementConfig config; private DeviceManagementConfig config;
private DeviceManagementRepository pluginRepository; private DeviceManagementRepository pluginRepository;
public DeviceManagerImpl(DeviceManagementConfig config, DeviceManagementRepository pluginRepository) { public DeviceManagerImpl(DeviceManagementConfig config, DeviceManagementRepository pluginRepository) {
this.config = config; this.config = config;
this.pluginRepository = pluginRepository; this.pluginRepository = pluginRepository;
this.deviceDAO = DeviceManagementDAOFactory.getDeviceDAO(); this.deviceDAO = DeviceManagementDAOFactory.getDeviceDAO();
this.deviceTypeDAO = DeviceManagementDAOFactory.getDeviceTypeDAO(); this.deviceTypeDAO = DeviceManagementDAOFactory.getDeviceTypeDAO();
} }
@Override @Override public boolean enrollDevice(Device device) throws DeviceManagementException {
public boolean enrollDevice(Device device) throws DeviceManagementException { DeviceManagerService dms = this.getPluginRepository().getDeviceManagementProvider(device.getType());
DeviceManagerService dms = this.getPluginRepository().getDeviceManagementProvider(device.getType()); boolean status = dms.enrollDevice(device);
boolean status = dms.enrollDevice(device);
try {
try { org.wso2.carbon.device.mgt.core.dto.Device deviceDto = DeviceManagementDAOUtil.convertDevice(device);
org.wso2.carbon.device.mgt.core.dto.Device deviceDto = DeviceManagementDAOUtil.convertDevice(device); Integer deviceTypeId = this.getDeviceTypeDAO().getDeviceTypeIdByDeviceTypeName(device.getType());
Integer deviceTypeId = this.getDeviceTypeDAO().getDeviceTypeIdByDeviceTypeName(device.getType()); deviceDto.setDeviceTypeId(deviceTypeId);
deviceDto.setDeviceTypeId(deviceTypeId); this.getDeviceDAO().addDevice(deviceDto);
this.getDeviceDAO().addDevice(deviceDto);
} catch (DeviceManagementDAOException e) {
} catch (DeviceManagementDAOException e) { throw new DeviceManagementException("Error occurred while enrolling the device '" + device.getId() + "'",
throw new DeviceManagementException("Error occurred while enrolling the device '" + device.getId() + "'", e); e);
} }
return status; return status;
} }
@Override @Override public boolean modifyEnrollment(Device device) throws DeviceManagementException {
public boolean modifyEnrollment(Device device) throws DeviceManagementException { DeviceManagerService dms = this.getPluginRepository().getDeviceManagementProvider(device.getType());
DeviceManagerService dms = this.getPluginRepository().getDeviceManagementProvider(device.getType()); boolean status = dms.modifyEnrollment(device);
boolean status = dms.modifyEnrollment(device); try {
try { this.getDeviceDAO().updateDevice(DeviceManagementDAOUtil.convertDevice(device));
this.getDeviceDAO().updateDevice(DeviceManagementDAOUtil.convertDevice(device)); } catch (DeviceManagementDAOException e) {
} catch (DeviceManagementDAOException e) { throw new DeviceManagementException("Error occurred while modifying the device '" + device.getId() + "'",
throw new DeviceManagementException("Error occurred while modifying the device '" + device.getId() + "'", e);
e); }
} return status;
return status; }
}
@Override public boolean disenrollDevice(DeviceIdentifier deviceId) throws DeviceManagementException {
@Override DeviceManagerService dms = this.getPluginRepository().getDeviceManagementProvider(deviceId.getType());
public boolean disenrollDevice(DeviceIdentifier deviceId) throws DeviceManagementException { return dms.disenrollDevice(deviceId);
DeviceManagerService dms = this.getPluginRepository().getDeviceManagementProvider(deviceId.getType()); }
return dms.disenrollDevice(deviceId);
} @Override public boolean isEnrolled(DeviceIdentifier deviceId) throws DeviceManagementException {
DeviceManagerService dms = this.getPluginRepository().getDeviceManagementProvider(deviceId.getType());
@Override return dms.isEnrolled(deviceId);
public boolean isEnrolled(DeviceIdentifier deviceId) throws DeviceManagementException { }
DeviceManagerService dms = this.getPluginRepository().getDeviceManagementProvider(deviceId.getType());
return dms.isEnrolled(deviceId); @Override public boolean isActive(DeviceIdentifier deviceId) throws DeviceManagementException {
} DeviceManagerService dms = this.getPluginRepository().getDeviceManagementProvider(deviceId.getType());
return dms.isActive(deviceId);
@Override }
public boolean isActive(DeviceIdentifier deviceId) throws DeviceManagementException {
DeviceManagerService dms = this.getPluginRepository().getDeviceManagementProvider(deviceId.getType()); @Override public boolean setActive(DeviceIdentifier deviceId, boolean status) throws DeviceManagementException {
return dms.isActive(deviceId); DeviceManagerService dms = this.getPluginRepository().getDeviceManagementProvider(deviceId.getType());
} return dms.setActive(deviceId, status);
}
@Override
public boolean setActive(DeviceIdentifier deviceId, boolean status) @Override public List<Device> getAllDevices(String type) throws DeviceManagementException {
throws DeviceManagementException { DeviceManagerService dms = this.getPluginRepository().getDeviceManagementProvider(type);
DeviceManagerService dms = List<Device> devicesList = new ArrayList<Device>();
this.getPluginRepository().getDeviceManagementProvider(deviceId.getType()); try {
return dms.setActive(deviceId, status); Integer deviceTypeId = this.getDeviceTypeDAO().getDeviceTypeIdByDeviceTypeName(type);
} List<org.wso2.carbon.device.mgt.core.dto.Device> devices = this.getDeviceDAO().getDevices(deviceTypeId);
@Override for (org.wso2.carbon.device.mgt.core.dto.Device device : devices) {
public List<Device> getAllDevices(String type) throws DeviceManagementException { DeviceType deviceType = this.deviceTypeDAO.getDeviceType(device.getDeviceTypeId());
DeviceManagerService dms = Device convertedDevice = DeviceManagementDAOUtil.convertDevice(device, deviceType);
this.getPluginRepository().getDeviceManagementProvider(type); DeviceIdentifier deviceIdentifier = DeviceManagementDAOUtil.createDeviceIdentifier(device, deviceType);
List<Device> devicesList = new ArrayList<Device>(); Device dmsDevice = dms.getDevice(deviceIdentifier);
try { if (dmsDevice != null) {
Integer deviceTypeId = this.getDeviceTypeDAO().getDeviceTypeIdByDeviceTypeName(type); convertedDevice.setProperties(dmsDevice.getProperties());
List<org.wso2.carbon.device.mgt.core.dto.Device> devices = convertedDevice.setFeatures(dmsDevice.getFeatures());
this.getDeviceDAO().getDevices(deviceTypeId); }
devicesList.add(convertedDevice);
for (org.wso2.carbon.device.mgt.core.dto.Device device : devices) { }
DeviceType deviceType = this.deviceTypeDAO.getDeviceType(device.getDeviceTypeId()); } catch (DeviceManagementDAOException e) {
Device convertedDevice = DeviceManagementDAOUtil.convertDevice(device, deviceType); throw new DeviceManagementException("Error occurred while obtaining the device for type '" + type + "'", e);
DeviceIdentifier deviceIdentifier = }
DeviceManagementDAOUtil.createDeviceIdentifier(device, deviceType); return devicesList;
Device dmsDevice = dms.getDevice(deviceIdentifier); }
if (dmsDevice != null) {
convertedDevice.setProperties(dmsDevice.getProperties()); @Override public Device getDevice(DeviceIdentifier deviceId) throws DeviceManagementException {
convertedDevice.setFeatures(dmsDevice.getFeatures()); DeviceManagerService dms = this.getPluginRepository().getDeviceManagementProvider(deviceId.getType());
} Device convertedDevice = null;
devicesList.add(convertedDevice); try {
} Integer deviceTypeId = this.getDeviceTypeDAO().getDeviceTypeIdByDeviceTypeName(deviceId.getType());
} catch (DeviceManagementDAOException e) { org.wso2.carbon.device.mgt.core.dto.Device device =
throw new DeviceManagementException("Error occurred while obtaining the device for type '" + type + "'", this.getDeviceDAO().getDeviceByDeviceIdentifier(deviceTypeId, deviceId.getId());
e); if (device != null) {
} convertedDevice = DeviceManagementDAOUtil
return devicesList; .convertDevice(device, this.getDeviceTypeDAO().getDeviceType(deviceTypeId));
} Device dmsDevice = dms.getDevice(deviceId);
if (dmsDevice != null) {
@Override convertedDevice.setProperties(dmsDevice.getProperties());
public Device getDevice(DeviceIdentifier deviceId) throws DeviceManagementException { convertedDevice.setFeatures(dmsDevice.getFeatures());
DeviceManagerService dms = this.getPluginRepository().getDeviceManagementProvider(deviceId.getType()); }
Device convertedDevice = null; } else {
try { throw new DeviceManagementException("No device found for the id '" + deviceId.getId() + "'");
Integer deviceTypeId = this.getDeviceTypeDAO().getDeviceTypeIdByDeviceTypeName(deviceId.getType()); }
org.wso2.carbon.device.mgt.core.dto.Device device = } catch (DeviceManagementDAOException e) {
this.getDeviceDAO().getDeviceByDeviceIdentifier(deviceTypeId, deviceId.getId()); throw new DeviceManagementException(
if(device!=null){ "Error occurred while obtaining the device for id '" + deviceId.getId() + "'", e);
convertedDevice = DeviceManagementDAOUtil.convertDevice(device, this.getDeviceTypeDAO().getDeviceType(deviceTypeId)); }
Device dmsDevice = dms.getDevice(deviceId); return convertedDevice;
if (dmsDevice != null) { }
convertedDevice.setProperties(dmsDevice.getProperties());
convertedDevice.setFeatures(dmsDevice.getFeatures()); @Override public boolean updateDeviceInfo(Device device) throws DeviceManagementException {
} DeviceManagerService dms = this.getPluginRepository().getDeviceManagementProvider(device.getType());
}else{ return dms.updateDeviceInfo(device);
throw new DeviceManagementException("No device found for the id '" + deviceId.getId() + "'"); }
}
} catch (DeviceManagementDAOException e) { @Override public boolean setOwnership(DeviceIdentifier deviceId, String ownershipType)
throw new DeviceManagementException("Error occurred while obtaining the device for id '" + deviceId.getId() + "'", throws DeviceManagementException {
e); DeviceManagerService dms = this.getPluginRepository().getDeviceManagementProvider(deviceId.getType());
} return dms.setOwnership(deviceId, ownershipType);
return convertedDevice; }
}
public OperationManager getOperationManager(String type) throws DeviceManagementException {
@Override DeviceManagerService dms = this.getPluginRepository().getDeviceManagementProvider(type);
public boolean updateDeviceInfo(Device device) throws DeviceManagementException { return dms.getOperationManager();
DeviceManagerService dms = this.getPluginRepository().getDeviceManagementProvider(device.getType()); }
return dms.updateDeviceInfo(device);
} public DeviceDAO getDeviceDAO() {
return deviceDAO;
@Override }
public boolean setOwnership(DeviceIdentifier deviceId, String ownershipType) throws DeviceManagementException {
DeviceManagerService dms = this.getPluginRepository().getDeviceManagementProvider(deviceId.getType()); public DeviceTypeDAO getDeviceTypeDAO() {
return dms.setOwnership(deviceId, ownershipType); return deviceTypeDAO;
} }
public OperationManager getOperationManager(String type) throws DeviceManagementException { public DeviceManagementRepository getPluginRepository() {
DeviceManagerService dms = this.getPluginRepository().getDeviceManagementProvider(type); return pluginRepository;
return dms.getOperationManager(); }
}
public DeviceDAO getDeviceDAO() {
return deviceDAO;
}
public DeviceTypeDAO getDeviceTypeDAO() {
return deviceTypeDAO;
}
public DeviceManagementRepository getPluginRepository() {
return pluginRepository;
}
} }

@ -28,30 +28,30 @@ import java.util.List;
*/ */
public interface DeviceDAO { public interface DeviceDAO {
void addDevice(Device device) throws DeviceManagementDAOException; void addDevice(Device device) throws DeviceManagementDAOException;
void updateDevice(Device device) throws DeviceManagementDAOException; void updateDevice(Device device) throws DeviceManagementDAOException;
void updateDeviceStatus(Long deviceId, Status status) throws DeviceManagementDAOException; void updateDeviceStatus(Long deviceId, Status status) throws DeviceManagementDAOException;
void deleteDevice(Long deviceId) throws DeviceManagementDAOException; void deleteDevice(Long deviceId) throws DeviceManagementDAOException;
Device getDeviceByDeviceId(Long deviceId) throws DeviceManagementDAOException; Device getDeviceByDeviceId(Long deviceId) throws DeviceManagementDAOException;
/** /**
* @param type - Device type. * @param type - Device type.
* @param identifier - Device identifier. * @param identifier - Device identifier.
* @return * @return
* @throws DeviceManagementDAOException * @throws DeviceManagementDAOException
*/ */
Device getDeviceByDeviceIdentifier(Integer type, String identifier) throws DeviceManagementDAOException; Device getDeviceByDeviceIdentifier(Integer type, String identifier) throws DeviceManagementDAOException;
List<Device> getDevices() throws DeviceManagementDAOException; List<Device> getDevices() throws DeviceManagementDAOException;
/** /**
* @param type - The device type id. * @param type - The device type id.
* @return a list of devices based on the type id. * @return a list of devices based on the type id.
* @throws DeviceManagementDAOException * @throws DeviceManagementDAOException
*/ */
List<Device> getDevices(Integer type) throws DeviceManagementDAOException; List<Device> getDevices(Integer type) throws DeviceManagementDAOException;
} }

@ -37,162 +37,153 @@ import java.util.List;
public class DeviceDAOImpl implements DeviceDAO { public class DeviceDAOImpl implements DeviceDAO {
private DataSource dataSource; private DataSource dataSource;
private static final Log log = LogFactory.getLog(DeviceDAOImpl.class); private static final Log log = LogFactory.getLog(DeviceDAOImpl.class);
public DeviceDAOImpl(DataSource dataSource) {
public DeviceDAOImpl(DataSource dataSource) { this.dataSource = dataSource;
this.dataSource = dataSource; }
}
@Override public void addDevice(Device device) throws DeviceManagementDAOException {
@Override Connection conn = null;
public void addDevice(Device device) throws DeviceManagementDAOException { PreparedStatement stmt = null;
Connection conn = null; try {
PreparedStatement stmt = null; conn = this.getConnection();
try { String createDBQuery =
conn = this.getConnection(); "INSERT INTO DM_DEVICE(DESCRIPTION, NAME, DATE_OF_ENROLLMENT, DATE_OF_LAST_UPDATE, OWNERSHIP," +
String createDBQuery = "STATUS, DEVICE_TYPE_ID, DEVICE_IDENTIFICATION, OWNER, TENANT_ID) VALUES " +
"INSERT INTO DM_DEVICE(DESCRIPTION, NAME, DATE_OF_ENROLLMENT, DATE_OF_LAST_UPDATE, OWNERSHIP," + "(?, ?, ?, ?, ?, ?, ?, ?, ?, ?)";
"STATUS, DEVICE_TYPE_ID, DEVICE_IDENTIFICATION, OWNER, TENANT_ID) VALUES " +
"(?, ?, ?, ?, ?, ?, ?, ?, ?, ?)"; stmt = conn.prepareStatement(createDBQuery);
stmt.setString(1, device.getDescription());
stmt = conn.prepareStatement(createDBQuery); stmt.setString(2, device.getName());
stmt.setString(1, device.getDescription()); stmt.setLong(3, new Date().getTime());
stmt.setString(2, device.getName()); stmt.setLong(4, new Date().getTime());
stmt.setLong(3, new Date().getTime()); stmt.setString(5, device.getOwnerShip());
stmt.setLong(4, new Date().getTime()); stmt.setString(6, device.getStatus().toString());
stmt.setString(5, device.getOwnerShip()); stmt.setInt(7, device.getDeviceTypeId());
stmt.setString(6, device.getStatus().toString()); stmt.setString(8, device.getDeviceIdentificationId());
stmt.setInt(7, device.getDeviceTypeId()); stmt.setString(9, device.getOwnerId());
stmt.setString(8, device.getDeviceIdentificationId()); stmt.setInt(10, device.getTenantId());
stmt.setString(9, device.getOwnerId()); stmt.executeUpdate();
stmt.setInt(10, device.getTenantId()); } catch (SQLException e) {
stmt.executeUpdate(); String msg = "Error occurred while enrolling device '" + device.getName() + "'";
} catch (SQLException e) { log.error(msg, e);
String msg = "Error occurred while enrolling device '" + device.getName() + "'"; throw new DeviceManagementDAOException(msg, e);
log.error(msg, e); } finally {
throw new DeviceManagementDAOException(msg, e); DeviceManagementDAOUtil.cleanupResources(conn, stmt, null);
} finally { }
DeviceManagementDAOUtil.cleanupResources(conn, stmt, null); }
}
} @Override public void updateDevice(Device device) throws DeviceManagementDAOException {
@Override }
public void updateDevice(Device device) throws DeviceManagementDAOException {
@Override public void updateDeviceStatus(Long deviceId, Status status) throws DeviceManagementDAOException {
}
}
@Override
public void updateDeviceStatus(Long deviceId, Status status) throws DeviceManagementDAOException { @Override public void deleteDevice(Long deviceId) throws DeviceManagementDAOException {
} }
@Override @Override public Device getDeviceByDeviceId(Long deviceId) throws DeviceManagementDAOException {
public void deleteDevice(Long deviceId) throws DeviceManagementDAOException { return null;
}
}
@Override public Device getDeviceByDeviceIdentifier(Integer type, String identifier)
@Override throws DeviceManagementDAOException {
public Device getDeviceByDeviceId(Long deviceId) Connection conn = null;
throws DeviceManagementDAOException { PreparedStatement stmt = null;
return null; ResultSet resultSet = null;
} Device device = null;
try {
@Override public Device getDeviceByDeviceIdentifier(Integer type, String identifier) conn = this.getConnection();
throws DeviceManagementDAOException { String selectDBQueryForType = "SELECT ID, DESCRIPTION, NAME, DATE_OF_ENROLLMENT, " +
Connection conn = null; "DATE_OF_LAST_UPDATE, OWNERSHIP, STATUS, DEVICE_TYPE_ID, " +
PreparedStatement stmt = null; "DEVICE_IDENTIFICATION, OWNER, TENANT_ID FROM DM_DEVICE " +
ResultSet resultSet = null; "WHERE DM_DEVICE.DEVICE_TYPE_ID=? AND DM_DEVICE.DEVICE_IDENTIFICATION=?";
Device device = null; stmt = conn.prepareStatement(selectDBQueryForType);
try { stmt.setInt(1, type);
conn = this.getConnection(); stmt.setString(2, identifier);
String selectDBQueryForType = "SELECT ID, DESCRIPTION, NAME, DATE_OF_ENROLLMENT, " + resultSet = stmt.executeQuery();
"DATE_OF_LAST_UPDATE, OWNERSHIP, STATUS, DEVICE_TYPE_ID, " + while (resultSet.next()) {
"DEVICE_IDENTIFICATION, OWNER, TENANT_ID FROM DM_DEVICE " + device = new Device();
"WHERE DM_DEVICE.DEVICE_TYPE_ID=? AND DM_DEVICE.DEVICE_IDENTIFICATION=?"; device.setId(resultSet.getInt(1));
stmt = conn.prepareStatement(selectDBQueryForType); device.setDescription(resultSet.getString(2));
stmt.setInt(1, type); device.setName(resultSet.getString(3));
stmt.setString(2, identifier); device.setDateOfEnrollment(resultSet.getLong(4));
resultSet = stmt.executeQuery(); device.setDateOfLastUpdate(resultSet.getLong(5));
while (resultSet.next()) { //TODO:- Ownership is not a enum in DeviceDAO
device = new Device(); device.setOwnerShip(resultSet.getString(6));
device.setId(resultSet.getInt(1)); device.setStatus(Status.valueOf(resultSet.getString(7)));
device.setDescription(resultSet.getString(2)); device.setDeviceTypeId(resultSet.getInt(8));
device.setName(resultSet.getString(3)); device.setDeviceIdentificationId(resultSet.getString(9));
device.setDateOfEnrollment(resultSet.getLong(4)); device.setOwnerId(resultSet.getString(10));
device.setDateOfLastUpdate(resultSet.getLong(5)); device.setTenantId(resultSet.getInt(11));
//TODO:- Ownership is not a enum in DeviceDAO }
device.setOwnerShip(resultSet.getString(6)); } catch (SQLException e) {
device.setStatus(Status.valueOf(resultSet.getString(7))); String msg = "Error occurred while listing devices for type '" + type + "'";
device.setDeviceTypeId(resultSet.getInt(8)); log.error(msg, e);
device.setDeviceIdentificationId(resultSet.getString(9)); throw new DeviceManagementDAOException(msg, e);
device.setOwnerId(resultSet.getString(10)); } finally {
device.setTenantId(resultSet.getInt(11)); DeviceManagementDAOUtil.cleanupResources(conn, stmt, resultSet);
} }
} catch (SQLException e) { return device;
String msg = "Error occurred while listing devices for type '" + type + "'"; }
log.error(msg, e);
throw new DeviceManagementDAOException(msg, e); @Override public List<Device> getDevices() throws DeviceManagementDAOException {
} finally { return null;
DeviceManagementDAOUtil.cleanupResources(conn, stmt, resultSet); }
}
return device; @Override public List<Device> getDevices(Integer type) throws DeviceManagementDAOException {
} Connection conn = null;
PreparedStatement stmt = null;
ResultSet resultSet = null;
@Override List<Device> devicesList = null;
public List<Device> getDevices() throws DeviceManagementDAOException { try {
return null; conn = this.getConnection();
} String selectDBQueryForType = "SELECT ID, DESCRIPTION, NAME, DATE_OF_ENROLLMENT, " +
"DATE_OF_LAST_UPDATE, OWNERSHIP, STATUS, DEVICE_TYPE_ID, " +
@Override public List<Device> getDevices(Integer type) throws DeviceManagementDAOException { "DEVICE_IDENTIFICATION, OWNER, TENANT_ID FROM DM_DEVICE " +
Connection conn = null; "WHERE DM_DEVICE.DEVICE_TYPE_ID=?";
PreparedStatement stmt = null; stmt = conn.prepareStatement(selectDBQueryForType);
ResultSet resultSet = null; stmt.setInt(1, type);
List<Device> devicesList = null; resultSet = stmt.executeQuery();
try { devicesList = new ArrayList<Device>();
conn = this.getConnection(); while (resultSet.next()) {
String selectDBQueryForType = "SELECT ID, DESCRIPTION, NAME, DATE_OF_ENROLLMENT, " + Device device = new Device();
"DATE_OF_LAST_UPDATE, OWNERSHIP, STATUS, DEVICE_TYPE_ID, " + device.setId(resultSet.getInt(1));
"DEVICE_IDENTIFICATION, OWNER, TENANT_ID FROM DM_DEVICE " + device.setDescription(resultSet.getString(2));
"WHERE DM_DEVICE.DEVICE_TYPE_ID=?"; device.setName(resultSet.getString(3));
stmt = conn.prepareStatement(selectDBQueryForType); device.setDateOfEnrollment(resultSet.getLong(4));
stmt.setInt(1, type); device.setDateOfLastUpdate(resultSet.getLong(5));
resultSet = stmt.executeQuery(); //TODO:- Ownership is not a enum in DeviceDAO
devicesList = new ArrayList<Device>(); device.setOwnerShip(resultSet.getString(6));
while (resultSet.next()) { device.setStatus(Status.valueOf(resultSet.getString(7)));
Device device = new Device(); device.setDeviceTypeId(resultSet.getInt(8));
device.setId(resultSet.getInt(1)); device.setDeviceIdentificationId(resultSet.getString(9));
device.setDescription(resultSet.getString(2)); device.setOwnerId(resultSet.getString(10));
device.setName(resultSet.getString(3)); device.setTenantId(resultSet.getInt(11));
device.setDateOfEnrollment(resultSet.getLong(4)); devicesList.add(device);
device.setDateOfLastUpdate(resultSet.getLong(5)); }
//TODO:- Ownership is not a enum in DeviceDAO } catch (SQLException e) {
device.setOwnerShip(resultSet.getString(6)); String msg = "Error occurred while listing devices for type '" + type + "'";
device.setStatus(Status.valueOf(resultSet.getString(7))); log.error(msg, e);
device.setDeviceTypeId(resultSet.getInt(8)); throw new DeviceManagementDAOException(msg, e);
device.setDeviceIdentificationId(resultSet.getString(9)); } finally {
device.setOwnerId(resultSet.getString(10)); DeviceManagementDAOUtil.cleanupResources(conn, stmt, resultSet);
device.setTenantId(resultSet.getInt(11)); }
devicesList.add(device); return devicesList;
} }
} catch (SQLException e) {
String msg = "Error occurred while listing devices for type '" + type + "'"; private Connection getConnection() throws DeviceManagementDAOException {
log.error(msg, e); try {
throw new DeviceManagementDAOException(msg, e); return dataSource.getConnection();
} finally { } catch (SQLException e) {
DeviceManagementDAOUtil.cleanupResources(conn, stmt, resultSet); throw new DeviceManagementDAOException("Error occurred while obtaining a connection from the device " +
} "management metadata repository datasource", e);
return devicesList; }
} }
private Connection getConnection() throws DeviceManagementDAOException {
try {
return dataSource.getConnection();
} catch (SQLException e) {
throw new DeviceManagementDAOException("Error occurred while obtaining a connection from the device " +
"management metadata repository datasource", e);
}
}
} }

Loading…
Cancel
Save