|
|
@ -21,35 +21,29 @@ package org.coffeeking.connectedcup.plugin.impl.dao.impl;
|
|
|
|
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.coffeeking.connectedcup.plugin.constants.ConnectedCupConstants;
|
|
|
|
import org.coffeeking.connectedcup.plugin.constants.ConnectedCupConstants;
|
|
|
|
|
|
|
|
import org.coffeeking.connectedcup.plugin.exception.ConnectedCupDeviceMgtPluginException;
|
|
|
|
import org.coffeeking.connectedcup.plugin.impl.dao.ConnectedCupDAO;
|
|
|
|
import org.coffeeking.connectedcup.plugin.impl.dao.ConnectedCupDAO;
|
|
|
|
import org.wso2.carbon.device.mgt.iot.util.iotdevice.dao.IotDeviceDAO;
|
|
|
|
import org.coffeeking.connectedcup.plugin.impl.dao.util.ConnectedCupUtils;
|
|
|
|
import org.wso2.carbon.device.mgt.iot.util.iotdevice.dao.IotDeviceManagementDAOException;
|
|
|
|
import org.wso2.carbon.device.mgt.common.Device;
|
|
|
|
import org.wso2.carbon.device.mgt.iot.util.iotdevice.dao.util.IotDeviceManagementDAOUtil;
|
|
|
|
|
|
|
|
import org.wso2.carbon.device.mgt.iot.util.iotdevice.dto.IotDevice;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import java.sql.Connection;
|
|
|
|
import java.sql.Connection;
|
|
|
|
import java.sql.PreparedStatement;
|
|
|
|
import java.sql.PreparedStatement;
|
|
|
|
import java.sql.ResultSet;
|
|
|
|
import java.sql.ResultSet;
|
|
|
|
import java.sql.SQLException;
|
|
|
|
import java.sql.SQLException;
|
|
|
|
import java.util.ArrayList;
|
|
|
|
import java.util.ArrayList;
|
|
|
|
import java.util.HashMap;
|
|
|
|
|
|
|
|
import java.util.List;
|
|
|
|
import java.util.List;
|
|
|
|
import java.util.Map;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* Implements IotDeviceDAO for virtual firealarm Devices.
|
|
|
|
* Device Dao for connected cup Devices.
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
public class ConnectedCupDAOImpl implements IotDeviceDAO {
|
|
|
|
public class ConnectedCupDAOImpl {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private static final Log log = LogFactory.getLog(ConnectedCupDAOImpl.class);
|
|
|
|
private static final Log log = LogFactory.getLog(ConnectedCupDAOImpl.class);
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public Device getDevice(String deviceId) throws ConnectedCupDeviceMgtPluginException {
|
|
|
|
public IotDevice getIotDevice(String iotDeviceId)
|
|
|
|
|
|
|
|
throws IotDeviceManagementDAOException {
|
|
|
|
|
|
|
|
Connection conn = null;
|
|
|
|
Connection conn = null;
|
|
|
|
PreparedStatement stmt = null;
|
|
|
|
PreparedStatement stmt = null;
|
|
|
|
IotDevice iotDevice = null;
|
|
|
|
Device connectedCupDevice = null;
|
|
|
|
ResultSet resultSet = null;
|
|
|
|
ResultSet resultSet = null;
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
conn = ConnectedCupDAO.getConnection();
|
|
|
|
conn = ConnectedCupDAO.getConnection();
|
|
|
@ -57,116 +51,121 @@ public class ConnectedCupDAOImpl implements IotDeviceDAO {
|
|
|
|
"SELECT CONNECTED_CUP_DEVICE_ID, DEVICE_NAME, ACCESS_TOKEN, REFRESH_TOKEN" +
|
|
|
|
"SELECT CONNECTED_CUP_DEVICE_ID, DEVICE_NAME, ACCESS_TOKEN, REFRESH_TOKEN" +
|
|
|
|
" FROM CONNECTED_CUP_DEVICE WHERE CONNECTED_CUP_DEVICE_ID = ?";
|
|
|
|
" FROM CONNECTED_CUP_DEVICE WHERE CONNECTED_CUP_DEVICE_ID = ?";
|
|
|
|
stmt = conn.prepareStatement(selectDBQuery);
|
|
|
|
stmt = conn.prepareStatement(selectDBQuery);
|
|
|
|
stmt.setString(1, iotDeviceId);
|
|
|
|
stmt.setString(1, deviceId);
|
|
|
|
resultSet = stmt.executeQuery();
|
|
|
|
resultSet = stmt.executeQuery();
|
|
|
|
|
|
|
|
|
|
|
|
if (resultSet.next()) {
|
|
|
|
if (resultSet.next()) {
|
|
|
|
iotDevice = new IotDevice();
|
|
|
|
connectedCupDevice = new Device();
|
|
|
|
iotDevice.setIotDeviceName(resultSet.getString(
|
|
|
|
connectedCupDevice.setName(resultSet.getString(
|
|
|
|
ConnectedCupConstants.DEVICE_PLUGIN_DEVICE_NAME));
|
|
|
|
ConnectedCupConstants.DEVICE_PLUGIN_DEVICE_NAME));
|
|
|
|
Map<String, String> propertyMap = new HashMap<String, String>();
|
|
|
|
List<Device.Property> propertyList = new ArrayList<Device.Property>();
|
|
|
|
propertyMap.put(ConnectedCupConstants.DEVICE_PLUGIN_PROPERTY_ACCESS_TOKEN, resultSet.getString("ACCESS_TOKEN"));
|
|
|
|
propertyList.add(ConnectedCupUtils.getProperty(
|
|
|
|
propertyMap.put(ConnectedCupConstants.DEVICE_PLUGIN_PROPERTY_REFRESH_TOKEN, resultSet.getString("REFRESH_TOKEN"));
|
|
|
|
ConnectedCupConstants.DEVICE_PLUGIN_PROPERTY_ACCESS_TOKEN,
|
|
|
|
iotDevice.setDeviceProperties(propertyMap);
|
|
|
|
resultSet.getString("ACCESS_TOKEN")));
|
|
|
|
|
|
|
|
propertyList.add(ConnectedCupUtils.getProperty(
|
|
|
|
|
|
|
|
ConnectedCupConstants.DEVICE_PLUGIN_PROPERTY_REFRESH_TOKEN,
|
|
|
|
|
|
|
|
resultSet.getString("REFRESH_TOKEN")));
|
|
|
|
|
|
|
|
connectedCupDevice.setProperties(propertyList);
|
|
|
|
|
|
|
|
|
|
|
|
if (log.isDebugEnabled()) {
|
|
|
|
if (log.isDebugEnabled()) {
|
|
|
|
log.debug("Connected Cup service " + iotDeviceId + " data has been fetched from " +
|
|
|
|
log.debug("Connected Cup service " + deviceId + " data has been fetched from" +
|
|
|
|
"Connected Cup database.");
|
|
|
|
"Connected Cup database.");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} catch (SQLException e) {
|
|
|
|
} catch (SQLException e) {
|
|
|
|
String msg = "Error occurred while fetching Connected Cup device : '" + iotDeviceId + "'";
|
|
|
|
String msg = "Error occurred while fetching Connected Cup device : '" + deviceId + "'";
|
|
|
|
log.error(msg, e);
|
|
|
|
log.error(msg, e);
|
|
|
|
throw new IotDeviceManagementDAOException(msg, e);
|
|
|
|
throw new ConnectedCupDeviceMgtPluginException(msg, e);
|
|
|
|
} finally {
|
|
|
|
} finally {
|
|
|
|
IotDeviceManagementDAOUtil.cleanupResources(stmt, resultSet);
|
|
|
|
ConnectedCupUtils.cleanupResources(stmt, resultSet);
|
|
|
|
ConnectedCupDAO.closeConnection();
|
|
|
|
ConnectedCupDAO.closeConnection();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return connectedCupDevice;
|
|
|
|
return iotDevice;
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
|
|
|
public boolean addIotDevice(IotDevice iotDevice)
|
|
|
|
public boolean addDevice(Device connectedCupDevice) throws ConnectedCupDeviceMgtPluginException {
|
|
|
|
throws IotDeviceManagementDAOException {
|
|
|
|
|
|
|
|
boolean status = false;
|
|
|
|
boolean status = false;
|
|
|
|
Connection conn = null;
|
|
|
|
Connection conn = null;
|
|
|
|
PreparedStatement stmt = null;
|
|
|
|
PreparedStatement stmt = null;
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
conn = ConnectedCupDAO.getConnection();
|
|
|
|
conn = ConnectedCupDAO.getConnection();
|
|
|
|
String createDBQuery =
|
|
|
|
String createDBQuery =
|
|
|
|
"INSERT INTO CONNECTED_CUP_DEVICE(CONNECTED_CUP_DEVICE_ID, DEVICE_NAME, ACCESS_TOKEN, REFRESH_TOKEN) VALUES (?, ?, ?, ?)";
|
|
|
|
"INSERT INTO CONNECTED_CUP_DEVICE(CONNECTED_CUP_DEVICE_ID, DEVICE_NAME, " +
|
|
|
|
|
|
|
|
"ACCESS_TOKEN, REFRESH_TOKEN) VALUES (?, ?, ?, ?)";
|
|
|
|
|
|
|
|
|
|
|
|
stmt = conn.prepareStatement(createDBQuery);
|
|
|
|
stmt = conn.prepareStatement(createDBQuery);
|
|
|
|
stmt.setString(1, iotDevice.getIotDeviceId());
|
|
|
|
stmt.setString(1, connectedCupDevice.getDeviceIdentifier());
|
|
|
|
stmt.setString(2, iotDevice.getIotDeviceName());
|
|
|
|
stmt.setString(2, connectedCupDevice.getName());
|
|
|
|
stmt.setString(3, iotDevice.getDeviceProperties().get(ConnectedCupConstants.DEVICE_PLUGIN_PROPERTY_ACCESS_TOKEN));
|
|
|
|
stmt.setString(3, ConnectedCupUtils.getDeviceProperty(
|
|
|
|
stmt.setString(4, iotDevice.getDeviceProperties().get(ConnectedCupConstants.DEVICE_PLUGIN_PROPERTY_REFRESH_TOKEN));
|
|
|
|
connectedCupDevice.getProperties(),
|
|
|
|
|
|
|
|
ConnectedCupConstants.DEVICE_PLUGIN_PROPERTY_ACCESS_TOKEN));
|
|
|
|
|
|
|
|
stmt.setString(4, ConnectedCupUtils.getDeviceProperty(
|
|
|
|
|
|
|
|
connectedCupDevice.getProperties(),
|
|
|
|
|
|
|
|
ConnectedCupConstants.DEVICE_PLUGIN_PROPERTY_REFRESH_TOKEN));
|
|
|
|
|
|
|
|
|
|
|
|
int rows = stmt.executeUpdate();
|
|
|
|
int rows = stmt.executeUpdate();
|
|
|
|
if (rows > 0) {
|
|
|
|
if (rows > 0) {
|
|
|
|
status = true;
|
|
|
|
status = true;
|
|
|
|
if (log.isDebugEnabled()) {
|
|
|
|
if (log.isDebugEnabled()) {
|
|
|
|
log.debug("Connected Cup device " + iotDevice.getIotDeviceId() + " data has been" +
|
|
|
|
log.debug("Connected Cup device " + connectedCupDevice.getDeviceIdentifier() +
|
|
|
|
" added to the Connected Cup database.");
|
|
|
|
" data has been added to the Connected Cup database.");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} catch (SQLException e) {
|
|
|
|
} catch (SQLException e) {
|
|
|
|
String msg = "Error occurred while adding the Connected Cup device '" +
|
|
|
|
String msg = "Error occurred while adding the Connected Cup device '" +
|
|
|
|
iotDevice.getIotDeviceId() + "' to the Connected Cup db.";
|
|
|
|
connectedCupDevice.getDeviceIdentifier() + "' to the Connected Cup db.";
|
|
|
|
log.error(msg, e);
|
|
|
|
log.error(msg, e);
|
|
|
|
throw new IotDeviceManagementDAOException(msg, e);
|
|
|
|
throw new ConnectedCupDeviceMgtPluginException(msg, e);
|
|
|
|
} finally {
|
|
|
|
} finally {
|
|
|
|
IotDeviceManagementDAOUtil.cleanupResources(stmt, null);
|
|
|
|
ConnectedCupUtils.cleanupResources(stmt, null);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return status;
|
|
|
|
return status;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public boolean updateDevice(Device connectedCupDevice) throws ConnectedCupDeviceMgtPluginException {
|
|
|
|
public boolean updateIotDevice(IotDevice iotDevice)
|
|
|
|
|
|
|
|
throws IotDeviceManagementDAOException {
|
|
|
|
|
|
|
|
boolean status = false;
|
|
|
|
boolean status = false;
|
|
|
|
Connection conn = null;
|
|
|
|
Connection conn = null;
|
|
|
|
PreparedStatement stmt = null;
|
|
|
|
PreparedStatement stmt = null;
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
conn = ConnectedCupDAO.getConnection();
|
|
|
|
conn = ConnectedCupDAO.getConnection();
|
|
|
|
String updateDBQuery =
|
|
|
|
String updateDBQuery =
|
|
|
|
"UPDATE CONNECTED_CUP_DEVICE SET DEVICE_NAME = ?, ACCESS_TOKEN=?, REFRESH_TOKEN=? WHERE CONNECTED_CUP_DEVICE_ID = ?";
|
|
|
|
"UPDATE CONNECTED_CUP_DEVICE SET DEVICE_NAME = ?, ACCESS_TOKEN=?, " +
|
|
|
|
|
|
|
|
"REFRESH_TOKEN=? WHERE CONNECTED_CUP_DEVICE_ID = ?";
|
|
|
|
|
|
|
|
|
|
|
|
stmt = conn.prepareStatement(updateDBQuery);
|
|
|
|
stmt = conn.prepareStatement(updateDBQuery);
|
|
|
|
|
|
|
|
|
|
|
|
if (iotDevice.getDeviceProperties() == null) {
|
|
|
|
if (connectedCupDevice.getProperties() == null) {
|
|
|
|
iotDevice.setDeviceProperties(new HashMap<String, String>());
|
|
|
|
connectedCupDevice.setProperties(new ArrayList<Device.Property>());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
stmt.setString(1, iotDevice.getIotDeviceName());
|
|
|
|
stmt.setString(1, connectedCupDevice.getName());
|
|
|
|
stmt.setString(2, iotDevice.getDeviceProperties().get(
|
|
|
|
stmt.setString(2, ConnectedCupUtils.getDeviceProperty(
|
|
|
|
|
|
|
|
connectedCupDevice.getProperties(),
|
|
|
|
ConnectedCupConstants.DEVICE_PLUGIN_PROPERTY_ACCESS_TOKEN));
|
|
|
|
ConnectedCupConstants.DEVICE_PLUGIN_PROPERTY_ACCESS_TOKEN));
|
|
|
|
stmt.setString(3, iotDevice.getDeviceProperties().get(
|
|
|
|
stmt.setString(3, ConnectedCupUtils.getDeviceProperty(
|
|
|
|
ConnectedCupConstants.DEVICE_PLUGIN_PROPERTY_ACCESS_TOKEN));
|
|
|
|
connectedCupDevice.getProperties(),
|
|
|
|
stmt.setString(4, iotDevice.getIotDeviceId());
|
|
|
|
ConnectedCupConstants.DEVICE_PLUGIN_PROPERTY_REFRESH_TOKEN));
|
|
|
|
|
|
|
|
stmt.setString(4, connectedCupDevice.getDeviceIdentifier());
|
|
|
|
int rows = stmt.executeUpdate();
|
|
|
|
int rows = stmt.executeUpdate();
|
|
|
|
if (rows > 0) {
|
|
|
|
if (rows > 0) {
|
|
|
|
status = true;
|
|
|
|
status = true;
|
|
|
|
if (log.isDebugEnabled()) {
|
|
|
|
if (log.isDebugEnabled()) {
|
|
|
|
log.debug("Connected Cup device " + iotDevice.getIotDeviceId() + " data has been" +
|
|
|
|
log.debug("Connected Cup device " + connectedCupDevice.getDeviceIdentifier() +
|
|
|
|
" modified.");
|
|
|
|
" data has been modified.");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} catch (SQLException e) {
|
|
|
|
} catch (SQLException e) {
|
|
|
|
String msg = "Error occurred while modifying the Connected Cup device '" +
|
|
|
|
String msg = "Error occurred while modifying the Connected Cup device '" +
|
|
|
|
iotDevice.getIotDeviceId() + "' data.";
|
|
|
|
connectedCupDevice.getDeviceIdentifier() + "' data.";
|
|
|
|
log.error(msg, e);
|
|
|
|
log.error(msg, e);
|
|
|
|
throw new IotDeviceManagementDAOException(msg, e);
|
|
|
|
throw new ConnectedCupDeviceMgtPluginException(msg, e);
|
|
|
|
} finally {
|
|
|
|
} finally {
|
|
|
|
IotDeviceManagementDAOUtil.cleanupResources(stmt, null);
|
|
|
|
ConnectedCupUtils.cleanupResources(stmt, null);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return status;
|
|
|
|
return status;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public boolean deleteDevice(String deviceId) throws ConnectedCupDeviceMgtPluginException {
|
|
|
|
public boolean deleteIotDevice(String iotDeviceId)
|
|
|
|
|
|
|
|
throws IotDeviceManagementDAOException {
|
|
|
|
|
|
|
|
boolean status = false;
|
|
|
|
boolean status = false;
|
|
|
|
Connection conn = null;
|
|
|
|
Connection conn = null;
|
|
|
|
PreparedStatement stmt = null;
|
|
|
|
PreparedStatement stmt = null;
|
|
|
@ -175,34 +174,32 @@ public class ConnectedCupDAOImpl implements IotDeviceDAO {
|
|
|
|
String deleteDBQuery =
|
|
|
|
String deleteDBQuery =
|
|
|
|
"DELETE FROM CONNECTED_CUP_DEVICE WHERE CONNECTED_CUP_DEVICE_ID = ?";
|
|
|
|
"DELETE FROM CONNECTED_CUP_DEVICE WHERE CONNECTED_CUP_DEVICE_ID = ?";
|
|
|
|
stmt = conn.prepareStatement(deleteDBQuery);
|
|
|
|
stmt = conn.prepareStatement(deleteDBQuery);
|
|
|
|
stmt.setString(1, iotDeviceId);
|
|
|
|
stmt.setString(1, deviceId);
|
|
|
|
int rows = stmt.executeUpdate();
|
|
|
|
int rows = stmt.executeUpdate();
|
|
|
|
if (rows > 0) {
|
|
|
|
if (rows > 0) {
|
|
|
|
status = true;
|
|
|
|
status = true;
|
|
|
|
if (log.isDebugEnabled()) {
|
|
|
|
if (log.isDebugEnabled()) {
|
|
|
|
log.debug("Connected Cup device " + iotDeviceId + " data has deleted" +
|
|
|
|
log.debug("Connected Cup device " + deviceId + " data has deleted" +
|
|
|
|
" from the Connected Cup database.");
|
|
|
|
" from the Connected Cup database.");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} catch (SQLException e) {
|
|
|
|
} catch (SQLException e) {
|
|
|
|
String msg = "Error occurred while deleting Connected Cup device " + iotDeviceId;
|
|
|
|
String msg = "Error occurred while deleting Connected Cup device " + deviceId;
|
|
|
|
log.error(msg, e);
|
|
|
|
log.error(msg, e);
|
|
|
|
throw new IotDeviceManagementDAOException(msg, e);
|
|
|
|
throw new ConnectedCupDeviceMgtPluginException(msg, e);
|
|
|
|
} finally {
|
|
|
|
} finally {
|
|
|
|
IotDeviceManagementDAOUtil.cleanupResources(stmt, null);
|
|
|
|
ConnectedCupUtils.cleanupResources(stmt, null);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return status;
|
|
|
|
return status;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public List<Device> getAllDevices() throws ConnectedCupDeviceMgtPluginException {
|
|
|
|
public List<IotDevice> getAllIotDevices()
|
|
|
|
|
|
|
|
throws IotDeviceManagementDAOException {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Connection conn = null;
|
|
|
|
Connection conn = null;
|
|
|
|
PreparedStatement stmt = null;
|
|
|
|
PreparedStatement stmt = null;
|
|
|
|
ResultSet resultSet = null;
|
|
|
|
ResultSet resultSet = null;
|
|
|
|
IotDevice iotDevice;
|
|
|
|
Device connectedCupDevice;
|
|
|
|
List<IotDevice> iotDevices = new ArrayList<>();
|
|
|
|
List<Device> iotDevices = new ArrayList<>();
|
|
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
conn = ConnectedCupDAO.getConnection();
|
|
|
|
conn = ConnectedCupDAO.getConnection();
|
|
|
@ -212,31 +209,35 @@ public class ConnectedCupDAOImpl implements IotDeviceDAO {
|
|
|
|
stmt = conn.prepareStatement(selectDBQuery);
|
|
|
|
stmt = conn.prepareStatement(selectDBQuery);
|
|
|
|
resultSet = stmt.executeQuery();
|
|
|
|
resultSet = stmt.executeQuery();
|
|
|
|
while (resultSet.next()) {
|
|
|
|
while (resultSet.next()) {
|
|
|
|
iotDevice = new IotDevice();
|
|
|
|
connectedCupDevice = new Device();
|
|
|
|
iotDevice.setIotDeviceId(resultSet.getString(ConnectedCupConstants.DEVICE_PLUGIN_DEVICE_ID));
|
|
|
|
connectedCupDevice.setDeviceIdentifier(resultSet.getString(
|
|
|
|
iotDevice.setIotDeviceName(resultSet.getString(ConnectedCupConstants.DEVICE_PLUGIN_DEVICE_NAME));
|
|
|
|
ConnectedCupConstants.DEVICE_PLUGIN_DEVICE_ID));
|
|
|
|
|
|
|
|
connectedCupDevice.setName(resultSet.getString(
|
|
|
|
Map<String, String> propertyMap = new HashMap<>();
|
|
|
|
ConnectedCupConstants.DEVICE_PLUGIN_DEVICE_NAME));
|
|
|
|
propertyMap.put(ConnectedCupConstants.DEVICE_PLUGIN_PROPERTY_ACCESS_TOKEN,
|
|
|
|
|
|
|
|
resultSet.getString("ACCESS_TOKEN"));
|
|
|
|
List<Device.Property> propertyList = new ArrayList<Device.Property>();
|
|
|
|
propertyMap.put(ConnectedCupConstants.DEVICE_PLUGIN_PROPERTY_REFRESH_TOKEN,
|
|
|
|
propertyList.add(ConnectedCupUtils.getProperty(
|
|
|
|
resultSet.getString("REFRESH_TOKEN"));
|
|
|
|
ConnectedCupConstants.DEVICE_PLUGIN_PROPERTY_ACCESS_TOKEN,
|
|
|
|
iotDevice.setDeviceProperties(propertyMap);
|
|
|
|
resultSet.getString("ACCESS_TOKEN")));
|
|
|
|
iotDevices.add(iotDevice);
|
|
|
|
propertyList.add(ConnectedCupUtils.getProperty(
|
|
|
|
|
|
|
|
ConnectedCupConstants.DEVICE_PLUGIN_PROPERTY_REFRESH_TOKEN,
|
|
|
|
|
|
|
|
resultSet.getString("REFRESH_TOKEN")));
|
|
|
|
|
|
|
|
connectedCupDevice.setProperties(propertyList);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (log.isDebugEnabled()) {
|
|
|
|
if (log.isDebugEnabled()) {
|
|
|
|
log.debug("All Connected Cup device details have fetched from Connected Cup database.");
|
|
|
|
log.debug("All Connected Cup device details have fetched from Connected Cup database" +
|
|
|
|
|
|
|
|
".");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return iotDevices;
|
|
|
|
return iotDevices;
|
|
|
|
} catch (SQLException e) {
|
|
|
|
} catch (SQLException e) {
|
|
|
|
String msg = "Error occurred while fetching all Connected Cup device data'";
|
|
|
|
String msg = "Error occurred while fetching all Connected Cup device data'";
|
|
|
|
log.error(msg, e);
|
|
|
|
log.error(msg, e);
|
|
|
|
throw new IotDeviceManagementDAOException(msg, e);
|
|
|
|
throw new ConnectedCupDeviceMgtPluginException(msg, e);
|
|
|
|
} finally {
|
|
|
|
} finally {
|
|
|
|
IotDeviceManagementDAOUtil.cleanupResources(stmt, resultSet);
|
|
|
|
ConnectedCupUtils.cleanupResources(stmt, resultSet);
|
|
|
|
ConnectedCupDAO.closeConnection();
|
|
|
|
ConnectedCupDAO.closeConnection();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|