|
|
@ -22,6 +22,7 @@ import org.apache.commons.logging.Log;
|
|
|
|
import org.apache.commons.logging.LogFactory;
|
|
|
|
import org.apache.commons.logging.LogFactory;
|
|
|
|
import org.wso2.carbon.device.mgt.mobile.dao.MobileDeviceDAO;
|
|
|
|
import org.wso2.carbon.device.mgt.mobile.dao.MobileDeviceDAO;
|
|
|
|
import org.wso2.carbon.device.mgt.mobile.dao.MobileDeviceManagementDAOException;
|
|
|
|
import org.wso2.carbon.device.mgt.mobile.dao.MobileDeviceManagementDAOException;
|
|
|
|
|
|
|
|
import org.wso2.carbon.device.mgt.mobile.dao.MobileDeviceManagementDAOFactory;
|
|
|
|
import org.wso2.carbon.device.mgt.mobile.dao.util.MobileDeviceManagementDAOUtil;
|
|
|
|
import org.wso2.carbon.device.mgt.mobile.dao.util.MobileDeviceManagementDAOUtil;
|
|
|
|
import org.wso2.carbon.device.mgt.mobile.dto.MobileDevice;
|
|
|
|
import org.wso2.carbon.device.mgt.mobile.dto.MobileDevice;
|
|
|
|
import org.wso2.carbon.device.mgt.mobile.impl.android.util.AndroidPluginConstants;
|
|
|
|
import org.wso2.carbon.device.mgt.mobile.impl.android.util.AndroidPluginConstants;
|
|
|
@ -42,13 +43,8 @@ import java.util.Map;
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
public class AndroidDeviceDAOImpl implements MobileDeviceDAO{
|
|
|
|
public class AndroidDeviceDAOImpl implements MobileDeviceDAO{
|
|
|
|
|
|
|
|
|
|
|
|
private DataSource dataSource;
|
|
|
|
|
|
|
|
private static final Log log = LogFactory.getLog(AndroidDeviceDAOImpl.class);
|
|
|
|
private static final Log log = LogFactory.getLog(AndroidDeviceDAOImpl.class);
|
|
|
|
|
|
|
|
|
|
|
|
public AndroidDeviceDAOImpl(DataSource dataSource) {
|
|
|
|
|
|
|
|
this.dataSource = dataSource;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
public MobileDevice getMobileDevice(String mblDeviceId)
|
|
|
|
public MobileDevice getMobileDevice(String mblDeviceId)
|
|
|
|
throws MobileDeviceManagementDAOException {
|
|
|
|
throws MobileDeviceManagementDAOException {
|
|
|
@ -56,7 +52,7 @@ public class AndroidDeviceDAOImpl implements MobileDeviceDAO{
|
|
|
|
PreparedStatement stmt = null;
|
|
|
|
PreparedStatement stmt = null;
|
|
|
|
MobileDevice mobileDevice = null;
|
|
|
|
MobileDevice mobileDevice = null;
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
conn = this.getConnection();
|
|
|
|
conn = MobileDeviceManagementDAOFactory.getConnection();
|
|
|
|
String selectDBQuery =
|
|
|
|
String selectDBQuery =
|
|
|
|
"SELECT ANDROID_DEVICE_ID, GCM_TOKEN, DEVICE_INFO, DEVICE_MODEL, SERIAL, " +
|
|
|
|
"SELECT ANDROID_DEVICE_ID, GCM_TOKEN, DEVICE_INFO, DEVICE_MODEL, SERIAL, " +
|
|
|
|
"VENDOR, MAC_ADDRESS, DEVICE_NAME, LATITUDE, LONGITUDE, IMEI, IMSI, OS_VERSION" +
|
|
|
|
"VENDOR, MAC_ADDRESS, DEVICE_NAME, LATITUDE, LONGITUDE, IMEI, IMSI, OS_VERSION" +
|
|
|
@ -111,7 +107,7 @@ public class AndroidDeviceDAOImpl implements MobileDeviceDAO{
|
|
|
|
Connection conn = null;
|
|
|
|
Connection conn = null;
|
|
|
|
PreparedStatement stmt = null;
|
|
|
|
PreparedStatement stmt = null;
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
conn = this.getConnection();
|
|
|
|
conn = MobileDeviceManagementDAOFactory.getConnection();
|
|
|
|
String createDBQuery =
|
|
|
|
String createDBQuery =
|
|
|
|
"INSERT INTO AD_DEVICE(ANDROID_DEVICE_ID, GCM_TOKEN, DEVICE_INFO, SERIAL, " +
|
|
|
|
"INSERT INTO AD_DEVICE(ANDROID_DEVICE_ID, GCM_TOKEN, DEVICE_INFO, SERIAL, " +
|
|
|
|
"VENDOR, MAC_ADDRESS, DEVICE_NAME, LATITUDE, LONGITUDE, IMEI, IMSI, " +
|
|
|
|
"VENDOR, MAC_ADDRESS, DEVICE_NAME, LATITUDE, LONGITUDE, IMEI, IMSI, " +
|
|
|
@ -166,7 +162,7 @@ public class AndroidDeviceDAOImpl implements MobileDeviceDAO{
|
|
|
|
Connection conn = null;
|
|
|
|
Connection conn = null;
|
|
|
|
PreparedStatement stmt = null;
|
|
|
|
PreparedStatement stmt = null;
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
conn = this.getConnection();
|
|
|
|
conn = MobileDeviceManagementDAOFactory.getConnection();
|
|
|
|
String updateDBQuery =
|
|
|
|
String updateDBQuery =
|
|
|
|
"UPDATE AD_DEVICE SET GCM_TOKEN = ?, DEVICE_INFO = ?, SERIAL = ?, VENDOR = ?, " +
|
|
|
|
"UPDATE AD_DEVICE SET GCM_TOKEN = ?, DEVICE_INFO = ?, SERIAL = ?, VENDOR = ?, " +
|
|
|
|
"MAC_ADDRESS = ?, DEVICE_NAME = ?, LATITUDE = ?, LONGITUDE = ?, IMEI = ?, " +
|
|
|
|
"MAC_ADDRESS = ?, DEVICE_NAME = ?, LATITUDE = ?, LONGITUDE = ?, IMEI = ?, " +
|
|
|
@ -221,7 +217,7 @@ public class AndroidDeviceDAOImpl implements MobileDeviceDAO{
|
|
|
|
Connection conn = null;
|
|
|
|
Connection conn = null;
|
|
|
|
PreparedStatement stmt = null;
|
|
|
|
PreparedStatement stmt = null;
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
conn = this.getConnection();
|
|
|
|
conn = MobileDeviceManagementDAOFactory.getConnection();
|
|
|
|
String deleteDBQuery =
|
|
|
|
String deleteDBQuery =
|
|
|
|
"DELETE FROM AD_DEVICE WHERE ANDROID_DEVICE_ID = ?";
|
|
|
|
"DELETE FROM AD_DEVICE WHERE ANDROID_DEVICE_ID = ?";
|
|
|
|
stmt = conn.prepareStatement(deleteDBQuery);
|
|
|
|
stmt = conn.prepareStatement(deleteDBQuery);
|
|
|
@ -252,7 +248,7 @@ public class AndroidDeviceDAOImpl implements MobileDeviceDAO{
|
|
|
|
MobileDevice mobileDevice;
|
|
|
|
MobileDevice mobileDevice;
|
|
|
|
List<MobileDevice> mobileDevices = new ArrayList<MobileDevice>();
|
|
|
|
List<MobileDevice> mobileDevices = new ArrayList<MobileDevice>();
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
conn = this.getConnection();
|
|
|
|
conn = MobileDeviceManagementDAOFactory.getConnection();
|
|
|
|
String selectDBQuery =
|
|
|
|
String selectDBQuery =
|
|
|
|
"SELECT ANDROID_DEVICE_ID, GCM_TOKEN, DEVICE_INFO, DEVICE_MODEL, SERIAL, " +
|
|
|
|
"SELECT ANDROID_DEVICE_ID, GCM_TOKEN, DEVICE_INFO, DEVICE_MODEL, SERIAL, " +
|
|
|
|
"VENDOR, MAC_ADDRESS, DEVICE_NAME, LATITUDE, LONGITUDE, IMEI, IMSI, OS_VERSION " +
|
|
|
|
"VENDOR, MAC_ADDRESS, DEVICE_NAME, LATITUDE, LONGITUDE, IMEI, IMSI, OS_VERSION " +
|
|
|
@ -296,14 +292,4 @@ public class AndroidDeviceDAOImpl implements MobileDeviceDAO{
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private Connection getConnection() throws MobileDeviceManagementDAOException {
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
|
|
|
return dataSource.getConnection();
|
|
|
|
|
|
|
|
} catch (SQLException e) {
|
|
|
|
|
|
|
|
String msg = "Error occurred while obtaining a connection from the mobile device " +
|
|
|
|
|
|
|
|
"management metadata repository datasource";
|
|
|
|
|
|
|
|
log.error(msg, e);
|
|
|
|
|
|
|
|
throw new MobileDeviceManagementDAOException(msg, e);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|