forked from community/device-mgt-plugins
parent
f693311ed9
commit
f75aa4e1c8
10
components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/android/dao/FeatureManagementDAOException.java → components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/android/dao/AndroidFeatureManagementDAOException.java
10
components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/android/dao/FeatureManagementDAOException.java → components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/android/dao/AndroidFeatureManagementDAOException.java
@ -1,36 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
|
||||||
*
|
|
||||||
* WSO2 Inc. licenses this file to you under the Apache License,
|
|
||||||
* Version 2.0 (the "License"); you may not use this file except
|
|
||||||
* in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing,
|
|
||||||
* software distributed under the License is distributed on an
|
|
||||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
|
||||||
* KIND, either express or implied. See the License for the
|
|
||||||
* specific language governing permissions and limitations
|
|
||||||
* under the License.
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
package org.wso2.carbon.device.mgt.mobile.impl.android.dao;
|
|
||||||
|
|
||||||
import org.wso2.carbon.device.mgt.common.Feature;
|
|
||||||
import org.wso2.carbon.device.mgt.mobile.dto.MobileFeature;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
public interface FeatureDAO {
|
|
||||||
|
|
||||||
void addFeature(MobileFeature feature) throws FeatureManagementDAOException;
|
|
||||||
|
|
||||||
void removeFeature(String name) throws FeatureManagementDAOException;
|
|
||||||
|
|
||||||
MobileFeature getFeature(String name) throws FeatureManagementDAOException;
|
|
||||||
|
|
||||||
List<MobileFeature> getFeatures() throws FeatureManagementDAOException;
|
|
||||||
|
|
||||||
}
|
|
@ -0,0 +1,338 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
||||||
|
*
|
||||||
|
* WSO2 Inc. licenses this file to you under the Apache License,
|
||||||
|
* Version 2.0 (the "License"); you may not use this file except
|
||||||
|
* in compliance with the License.
|
||||||
|
* you may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing,
|
||||||
|
* software distributed under the License is distributed on an
|
||||||
|
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||||
|
* KIND, either express or implied. See the License for the
|
||||||
|
* specific language governing permissions and limitations
|
||||||
|
* under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package org.wso2.carbon.device.mgt.mobile.impl.android.dao.impl;
|
||||||
|
|
||||||
|
import org.apache.commons.logging.Log;
|
||||||
|
import org.apache.commons.logging.LogFactory;
|
||||||
|
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.util.MobileDeviceManagementDAOUtil;
|
||||||
|
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.AndroidUtils;
|
||||||
|
|
||||||
|
import javax.sql.DataSource;
|
||||||
|
import java.sql.Connection;
|
||||||
|
import java.sql.PreparedStatement;
|
||||||
|
import java.sql.ResultSet;
|
||||||
|
import java.sql.SQLException;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Implements MobileDeviceDAO for Android Devices.
|
||||||
|
*/
|
||||||
|
public class AndroidDeviceDAOImpl implements MobileDeviceDAO{
|
||||||
|
|
||||||
|
private DataSource dataSource;
|
||||||
|
private static final Log log = LogFactory.getLog(AndroidDeviceDAOImpl.class);
|
||||||
|
|
||||||
|
public AndroidDeviceDAOImpl(DataSource dataSource) {
|
||||||
|
this.dataSource = dataSource;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public MobileDevice getMobileDevice(String mblDeviceId)
|
||||||
|
throws MobileDeviceManagementDAOException {
|
||||||
|
Connection conn = null;
|
||||||
|
PreparedStatement stmt = null;
|
||||||
|
MobileDevice mobileDevice = null;
|
||||||
|
try {
|
||||||
|
conn = this.getConnection();
|
||||||
|
String selectDBQuery =
|
||||||
|
"SELECT ANDROID_DEVICE_ID, GCM_TOKEN, DEVICE_INFO, SERIAL, VENDOR, MAC_ADDRESS, " +
|
||||||
|
"DEVICE_NAME, LATITUDE, LONGITUDE, IMEI, IMSI, 0S_VERSION FROM AD_DEVICE WHERE" +
|
||||||
|
" MOBILE_DEVICE_ID = ?";
|
||||||
|
stmt = conn.prepareStatement(selectDBQuery);
|
||||||
|
stmt.setString(1, mblDeviceId);
|
||||||
|
ResultSet resultSet = stmt.executeQuery();
|
||||||
|
|
||||||
|
if (resultSet.next()) {
|
||||||
|
mobileDevice = new MobileDevice();
|
||||||
|
mobileDevice.setMobileDeviceId(resultSet.getString(AndroidPluginConstants.ANDROID_DEVICE_ID));
|
||||||
|
|
||||||
|
Map<String, String> propertyMap = new HashMap<String, String>();
|
||||||
|
propertyMap.put(AndroidPluginConstants.GCM_TOKEN,
|
||||||
|
resultSet.getString(AndroidPluginConstants.GCM_TOKEN));
|
||||||
|
propertyMap.put(AndroidPluginConstants.DEVICE_INFO,
|
||||||
|
resultSet.getString(AndroidPluginConstants.DEVICE_INFO));
|
||||||
|
propertyMap.put(AndroidPluginConstants.SERIAL,
|
||||||
|
resultSet.getString(AndroidPluginConstants.SERIAL));
|
||||||
|
propertyMap.put(AndroidPluginConstants.VENDOR,
|
||||||
|
resultSet.getString(AndroidPluginConstants.VENDOR));
|
||||||
|
propertyMap.put(AndroidPluginConstants.MAC_ADDRESS,
|
||||||
|
resultSet.getString(AndroidPluginConstants.MAC_ADDRESS));
|
||||||
|
propertyMap.put(AndroidPluginConstants.DEVICE_NAME,
|
||||||
|
resultSet.getString(AndroidPluginConstants.DEVICE_NAME));
|
||||||
|
propertyMap.put(AndroidPluginConstants.LATITUDE,
|
||||||
|
resultSet.getString(AndroidPluginConstants.LATITUDE));
|
||||||
|
propertyMap.put(AndroidPluginConstants.LONGITUDE,
|
||||||
|
resultSet.getString(AndroidPluginConstants.LONGITUDE));
|
||||||
|
propertyMap.put(AndroidPluginConstants.IMEI,
|
||||||
|
resultSet.getString(AndroidPluginConstants.IMEI));
|
||||||
|
propertyMap.put(AndroidPluginConstants.IMSI,
|
||||||
|
resultSet.getString(AndroidPluginConstants.IMSI));
|
||||||
|
propertyMap.put(AndroidPluginConstants.OS_VERSION,
|
||||||
|
resultSet.getString(AndroidPluginConstants.OS_VERSION));
|
||||||
|
|
||||||
|
mobileDevice.setDeviceProperties(propertyMap);
|
||||||
|
|
||||||
|
if (log.isDebugEnabled()) {
|
||||||
|
log.debug("Android device " + mblDeviceId + " data has been fetched from Android database.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (SQLException e) {
|
||||||
|
String msg = "Error occurred while fetching Android device : '" + mblDeviceId + "'";
|
||||||
|
log.error(msg, e);
|
||||||
|
throw new MobileDeviceManagementDAOException(msg, e);
|
||||||
|
} finally {
|
||||||
|
MobileDeviceManagementDAOUtil.cleanupResources(conn, stmt, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
return mobileDevice;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean addMobileDevice(MobileDevice mobileDevice)
|
||||||
|
throws MobileDeviceManagementDAOException {
|
||||||
|
boolean status = false;
|
||||||
|
Connection conn = null;
|
||||||
|
PreparedStatement stmt = null;
|
||||||
|
try {
|
||||||
|
conn = this.getConnection();
|
||||||
|
String createDBQuery =
|
||||||
|
"INSERT INTO AD_DEVICE(ANDROID_DEVICE_ID, GCM_TOKEN, DEVICE_INFO, SERIAL, " +
|
||||||
|
"VENDOR, MAC_ADDRESS, DEVICE_NAME, LATITUDE, LONGITUDE, IMEI, IMSI, OS_VERSION)" +
|
||||||
|
" VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)";
|
||||||
|
|
||||||
|
stmt = conn.prepareStatement(createDBQuery);
|
||||||
|
stmt.setString(1, mobileDevice.getMobileDeviceId());
|
||||||
|
|
||||||
|
if (mobileDevice.getDeviceProperties() == null) {
|
||||||
|
mobileDevice.setDeviceProperties(new HashMap<String, String>());
|
||||||
|
}
|
||||||
|
|
||||||
|
stmt.setString(2, AndroidUtils.getDeviceProperty(
|
||||||
|
mobileDevice.getDeviceProperties(),
|
||||||
|
AndroidPluginConstants.GCM_TOKEN));
|
||||||
|
stmt.setString(3, AndroidUtils.getDeviceProperty(mobileDevice.getDeviceProperties(),
|
||||||
|
AndroidPluginConstants.DEVICE_INFO));
|
||||||
|
stmt.setString(4, AndroidUtils.getDeviceProperty(mobileDevice.getDeviceProperties(),
|
||||||
|
AndroidPluginConstants.SERIAL));
|
||||||
|
stmt.setString(5, AndroidUtils.getDeviceProperty(mobileDevice.getDeviceProperties(),
|
||||||
|
AndroidPluginConstants.VENDOR));
|
||||||
|
stmt.setString(6, AndroidUtils.getDeviceProperty(mobileDevice.getDeviceProperties(),
|
||||||
|
AndroidPluginConstants.MAC_ADDRESS));
|
||||||
|
stmt.setString(7, AndroidUtils.getDeviceProperty(mobileDevice.getDeviceProperties(),
|
||||||
|
AndroidPluginConstants.DEVICE_NAME));
|
||||||
|
stmt.setString(8, AndroidUtils.getDeviceProperty(mobileDevice.getDeviceProperties(),
|
||||||
|
AndroidPluginConstants.LATITUDE));
|
||||||
|
stmt.setString(9, AndroidUtils.getDeviceProperty(mobileDevice.getDeviceProperties(),
|
||||||
|
AndroidPluginConstants.LONGITUDE));
|
||||||
|
stmt.setString(10, AndroidUtils.getDeviceProperty(mobileDevice.getDeviceProperties(),
|
||||||
|
AndroidPluginConstants.IMEI));
|
||||||
|
stmt.setString(11, AndroidUtils.getDeviceProperty(mobileDevice.getDeviceProperties(),
|
||||||
|
AndroidPluginConstants.IMSI));
|
||||||
|
stmt.setString(12, AndroidUtils.getDeviceProperty(mobileDevice.getDeviceProperties(),
|
||||||
|
AndroidPluginConstants.OS_VERSION));
|
||||||
|
int rows = stmt.executeUpdate();
|
||||||
|
if (rows > 0) {
|
||||||
|
status = true;
|
||||||
|
if (log.isDebugEnabled()) {
|
||||||
|
log.debug("Android device " + mobileDevice.getMobileDeviceId() + " data has been added" +
|
||||||
|
" to the Android database.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (SQLException e) {
|
||||||
|
String msg = "Error occurred while adding the Android device '" +
|
||||||
|
mobileDevice.getMobileDeviceId() + "' to the Android db.";
|
||||||
|
log.error(msg, e);
|
||||||
|
throw new MobileDeviceManagementDAOException(msg, e);
|
||||||
|
} finally {
|
||||||
|
MobileDeviceManagementDAOUtil.cleanupResources(conn, stmt, null);
|
||||||
|
}
|
||||||
|
return status;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean updateMobileDevice(MobileDevice mobileDevice)
|
||||||
|
throws MobileDeviceManagementDAOException {
|
||||||
|
boolean status = false;
|
||||||
|
Connection conn = null;
|
||||||
|
PreparedStatement stmt = null;
|
||||||
|
try {
|
||||||
|
conn = this.getConnection();
|
||||||
|
String updateDBQuery =
|
||||||
|
"UPDATE AD_DEVICE SET GCM_TOKEN = ?, DEVICE_INFO = ?, SERIAL = ?, VENDOR = ?, MAC_ADDRESS = ?, " +
|
||||||
|
"DEVICE_NAME = ?, LATITUDE = ?, LONGITUDE = ?, IMEI = ?, IMSI = ?, OS_VERSION = ? " +
|
||||||
|
"WHERE ANDROID_DEVICE_ID = ?";
|
||||||
|
|
||||||
|
stmt = conn.prepareStatement(updateDBQuery);
|
||||||
|
stmt.setString(1, mobileDevice.getMobileDeviceId());
|
||||||
|
|
||||||
|
if (mobileDevice.getDeviceProperties() == null) {
|
||||||
|
mobileDevice.setDeviceProperties(new HashMap<String, String>());
|
||||||
|
}
|
||||||
|
|
||||||
|
stmt.setString(2, AndroidUtils.getDeviceProperty(
|
||||||
|
mobileDevice.getDeviceProperties(),
|
||||||
|
AndroidPluginConstants.GCM_TOKEN));
|
||||||
|
stmt.setString(3, AndroidUtils.getDeviceProperty(mobileDevice.getDeviceProperties(),
|
||||||
|
AndroidPluginConstants.DEVICE_INFO));
|
||||||
|
stmt.setString(4, AndroidUtils.getDeviceProperty(mobileDevice.getDeviceProperties(),
|
||||||
|
AndroidPluginConstants.SERIAL));
|
||||||
|
stmt.setString(5, AndroidUtils.getDeviceProperty(mobileDevice.getDeviceProperties(),
|
||||||
|
AndroidPluginConstants.VENDOR));
|
||||||
|
stmt.setString(6, AndroidUtils.getDeviceProperty(mobileDevice.getDeviceProperties(),
|
||||||
|
AndroidPluginConstants.MAC_ADDRESS));
|
||||||
|
stmt.setString(7, AndroidUtils.getDeviceProperty(mobileDevice.getDeviceProperties(),
|
||||||
|
AndroidPluginConstants.DEVICE_NAME));
|
||||||
|
stmt.setString(8, AndroidUtils.getDeviceProperty(mobileDevice.getDeviceProperties(),
|
||||||
|
AndroidPluginConstants.LATITUDE));
|
||||||
|
stmt.setString(9, AndroidUtils.getDeviceProperty(mobileDevice.getDeviceProperties(),
|
||||||
|
AndroidPluginConstants.LONGITUDE));
|
||||||
|
stmt.setString(10, AndroidUtils.getDeviceProperty(mobileDevice.getDeviceProperties(),
|
||||||
|
AndroidPluginConstants.IMEI));
|
||||||
|
stmt.setString(11, AndroidUtils.getDeviceProperty(mobileDevice.getDeviceProperties(),
|
||||||
|
AndroidPluginConstants.IMSI));
|
||||||
|
stmt.setString(12, AndroidUtils.getDeviceProperty(mobileDevice.getDeviceProperties(),
|
||||||
|
AndroidPluginConstants.OS_VERSION));
|
||||||
|
int rows = stmt.executeUpdate();
|
||||||
|
if (rows > 0) {
|
||||||
|
status = true;
|
||||||
|
if (log.isDebugEnabled()) {
|
||||||
|
log.debug("Android device " + mobileDevice.getMobileDeviceId() + " data has been" +
|
||||||
|
" modified.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (SQLException e) {
|
||||||
|
String msg = "Error occurred while modifying the Android device '" +
|
||||||
|
mobileDevice.getMobileDeviceId() + "' data.";
|
||||||
|
log.error(msg, e);
|
||||||
|
throw new MobileDeviceManagementDAOException(msg, e);
|
||||||
|
} finally {
|
||||||
|
MobileDeviceManagementDAOUtil.cleanupResources(conn, stmt, null);
|
||||||
|
}
|
||||||
|
return status;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean deleteMobileDevice(String mblDeviceId)
|
||||||
|
throws MobileDeviceManagementDAOException {
|
||||||
|
boolean status = false;
|
||||||
|
Connection conn = null;
|
||||||
|
PreparedStatement stmt = null;
|
||||||
|
try {
|
||||||
|
conn = this.getConnection();
|
||||||
|
String deleteDBQuery =
|
||||||
|
"DELETE FROM AD_DEVICE WHERE ANDROID_DEVICE_ID = ?";
|
||||||
|
stmt = conn.prepareStatement(deleteDBQuery);
|
||||||
|
stmt.setString(1, mblDeviceId);
|
||||||
|
int rows = stmt.executeUpdate();
|
||||||
|
if (rows > 0) {
|
||||||
|
status = true;
|
||||||
|
if (log.isDebugEnabled()) {
|
||||||
|
log.debug("Android device " + mblDeviceId + " data has deleted" +
|
||||||
|
" from the Android database.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (SQLException e) {
|
||||||
|
String msg = "Error occurred while deleting android device " + mblDeviceId;
|
||||||
|
log.error(msg, e);
|
||||||
|
throw new MobileDeviceManagementDAOException(msg, e);
|
||||||
|
} finally {
|
||||||
|
MobileDeviceManagementDAOUtil.cleanupResources(conn, stmt, null);
|
||||||
|
}
|
||||||
|
return status;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<MobileDevice> getAllMobileDevices()
|
||||||
|
throws MobileDeviceManagementDAOException {
|
||||||
|
Connection conn = null;
|
||||||
|
PreparedStatement stmt = null;
|
||||||
|
|
||||||
|
List<MobileDevice> mobileDevices = new ArrayList<MobileDevice>();
|
||||||
|
try {
|
||||||
|
conn = this.getConnection();
|
||||||
|
String selectDBQuery =
|
||||||
|
"SELECT ANDROID_DEVICE_ID, GCM_TOKEN, DEVICE_INFO, SERIAL, VENDOR, MAC_ADDRESS," +
|
||||||
|
"DEVICE_NAME, LATITUDE, LONGITUDE, IMEI, IMSI, 0S_VERSION FROM AD_DEVICE";
|
||||||
|
stmt = conn.prepareStatement(selectDBQuery);
|
||||||
|
ResultSet resultSet = stmt.executeQuery();
|
||||||
|
while (resultSet.next()) {
|
||||||
|
|
||||||
|
MobileDevice mobileDevice = new MobileDevice();
|
||||||
|
mobileDevice.setMobileDeviceId
|
||||||
|
(resultSet.getString(AndroidPluginConstants.ANDROID_DEVICE_ID));
|
||||||
|
|
||||||
|
Map<String, String> propertyMap = new HashMap<String, String>();
|
||||||
|
propertyMap.put(AndroidPluginConstants.GCM_TOKEN,
|
||||||
|
resultSet.getString(AndroidPluginConstants.GCM_TOKEN));
|
||||||
|
propertyMap.put(AndroidPluginConstants.DEVICE_INFO,
|
||||||
|
resultSet.getString(AndroidPluginConstants.DEVICE_INFO));
|
||||||
|
propertyMap.put(AndroidPluginConstants.SERIAL,
|
||||||
|
resultSet.getString(AndroidPluginConstants.SERIAL));
|
||||||
|
propertyMap.put(AndroidPluginConstants.VENDOR,
|
||||||
|
resultSet.getString(AndroidPluginConstants.VENDOR));
|
||||||
|
propertyMap.put(AndroidPluginConstants.MAC_ADDRESS,
|
||||||
|
resultSet.getString(AndroidPluginConstants.MAC_ADDRESS));
|
||||||
|
propertyMap.put(AndroidPluginConstants.DEVICE_NAME,
|
||||||
|
resultSet.getString(AndroidPluginConstants.DEVICE_NAME));
|
||||||
|
propertyMap.put(AndroidPluginConstants.LATITUDE,
|
||||||
|
resultSet.getString(AndroidPluginConstants.LATITUDE));
|
||||||
|
propertyMap.put(AndroidPluginConstants.LONGITUDE,
|
||||||
|
resultSet.getString(AndroidPluginConstants.LONGITUDE));
|
||||||
|
propertyMap.put(AndroidPluginConstants.IMEI,
|
||||||
|
resultSet.getString(AndroidPluginConstants.IMEI));
|
||||||
|
propertyMap.put(AndroidPluginConstants.IMSI,
|
||||||
|
resultSet.getString(AndroidPluginConstants.IMSI));
|
||||||
|
propertyMap.put(AndroidPluginConstants.OS_VERSION,
|
||||||
|
resultSet.getString(AndroidPluginConstants.OS_VERSION));
|
||||||
|
|
||||||
|
mobileDevice.setDeviceProperties(propertyMap);
|
||||||
|
|
||||||
|
mobileDevices.add(mobileDevice);
|
||||||
|
}
|
||||||
|
if (log.isDebugEnabled()) {
|
||||||
|
log.debug("All Android device details have fetched from Android database.");
|
||||||
|
}
|
||||||
|
return mobileDevices;
|
||||||
|
} catch (SQLException e) {
|
||||||
|
String msg = "Error occurred while fetching all Android device data'";
|
||||||
|
log.error(msg, e);
|
||||||
|
throw new MobileDeviceManagementDAOException(msg, e);
|
||||||
|
} finally {
|
||||||
|
MobileDeviceManagementDAOUtil.cleanupResources(conn, stmt, null);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,258 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
||||||
|
*
|
||||||
|
* WSO2 Inc. licenses this file to you under the Apache License,
|
||||||
|
* Version 2.0 (the "License"); you may not use this file except
|
||||||
|
* in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing,
|
||||||
|
* software distributed under the License is distributed on an
|
||||||
|
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||||
|
* KIND, either express or implied. See the License for the
|
||||||
|
* specific language governing permissions and limitations
|
||||||
|
* under the License.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
package org.wso2.carbon.device.mgt.mobile.impl.android.dao.impl;
|
||||||
|
|
||||||
|
import org.apache.commons.logging.Log;
|
||||||
|
import org.apache.commons.logging.LogFactory;
|
||||||
|
import org.wso2.carbon.device.mgt.common.DeviceManagementConstants;
|
||||||
|
import org.wso2.carbon.device.mgt.mobile.dao.MobileDeviceManagementDAOException;
|
||||||
|
import org.wso2.carbon.device.mgt.mobile.dao.MobileFeatureDAO;
|
||||||
|
import org.wso2.carbon.device.mgt.mobile.dao.util.MobileDeviceManagementDAOUtil;
|
||||||
|
import org.wso2.carbon.device.mgt.mobile.dto.MobileFeature;
|
||||||
|
import org.wso2.carbon.device.mgt.mobile.impl.android.dao.AndroidFeatureManagementDAOException;
|
||||||
|
import org.wso2.carbon.device.mgt.mobile.impl.android.util.AndroidPluginConstants;
|
||||||
|
|
||||||
|
import javax.sql.DataSource;
|
||||||
|
import java.sql.Connection;
|
||||||
|
import java.sql.PreparedStatement;
|
||||||
|
import java.sql.ResultSet;
|
||||||
|
import java.sql.SQLException;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public class AndroidFeatureDAOImpl implements MobileFeatureDAO {
|
||||||
|
|
||||||
|
private DataSource dataSource;
|
||||||
|
private static final Log log = LogFactory.getLog(AndroidFeatureDAOImpl.class);
|
||||||
|
|
||||||
|
public AndroidFeatureDAOImpl(DataSource dataSource) {
|
||||||
|
this.dataSource = dataSource;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean addFeature(MobileFeature mobileFeature) throws MobileDeviceManagementDAOException {
|
||||||
|
PreparedStatement stmt = null;
|
||||||
|
boolean status = false;
|
||||||
|
try {
|
||||||
|
Connection conn = this.getConnection();
|
||||||
|
String sql = "INSERT INTO AD_FEATURE(CODE, NAME, DESCRIPTION) VALUES (?, ?, ?)";
|
||||||
|
stmt = conn.prepareStatement(sql);
|
||||||
|
stmt.setString(1, mobileFeature.getCode());
|
||||||
|
stmt.setString(2, mobileFeature.getName());
|
||||||
|
stmt.setString(3, mobileFeature.getDescription());
|
||||||
|
stmt.executeUpdate();
|
||||||
|
status = true;
|
||||||
|
status = true;
|
||||||
|
} catch (SQLException e) {
|
||||||
|
throw new AndroidFeatureManagementDAOException(
|
||||||
|
"Error occurred while adding android feature '" +
|
||||||
|
mobileFeature.getName() + "' into the metadata repository", e);
|
||||||
|
} finally {
|
||||||
|
MobileDeviceManagementDAOUtil.cleanupResources(stmt, null);
|
||||||
|
}
|
||||||
|
return status;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean updateFeature(MobileFeature mobileFeature) throws MobileDeviceManagementDAOException {
|
||||||
|
boolean status = false;
|
||||||
|
Connection conn = null;
|
||||||
|
PreparedStatement stmt = null;
|
||||||
|
try {
|
||||||
|
conn = this.getConnection();
|
||||||
|
String updateDBQuery =
|
||||||
|
"UPDATE AD_FEATURE SET NAME = ?, DESCRIPTION = ?" +
|
||||||
|
"WHERE CODE = ?";
|
||||||
|
|
||||||
|
stmt = conn.prepareStatement(updateDBQuery);
|
||||||
|
stmt.setString(1, mobileFeature.getName());
|
||||||
|
stmt.setString(2, mobileFeature.getDescription());
|
||||||
|
stmt.setString(3, mobileFeature.getCode());
|
||||||
|
|
||||||
|
int rows = stmt.executeUpdate();
|
||||||
|
if (rows > 0) {
|
||||||
|
status = true;
|
||||||
|
if (log.isDebugEnabled()) {
|
||||||
|
log.debug("Android Feature " + mobileFeature.getCode() + " data has been modified.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (SQLException e) {
|
||||||
|
String msg = "Error occurred while updating the Android Feature '" +
|
||||||
|
mobileFeature.getCode() + "' to the Android db.";
|
||||||
|
log.error(msg, e);
|
||||||
|
throw new AndroidFeatureManagementDAOException(msg, e);
|
||||||
|
} finally {
|
||||||
|
MobileDeviceManagementDAOUtil.cleanupResources(conn, stmt, null);
|
||||||
|
}
|
||||||
|
return status;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean deleteFeatureById(int mblFeatureId) throws MobileDeviceManagementDAOException {
|
||||||
|
PreparedStatement stmt = null;
|
||||||
|
boolean status = false;
|
||||||
|
try {
|
||||||
|
Connection conn = this.getConnection();
|
||||||
|
String sql = "DELETE FROM AD_FEATURE WHERE ID = ?";
|
||||||
|
stmt = conn.prepareStatement(sql);
|
||||||
|
stmt.setInt(1, mblFeatureId);
|
||||||
|
stmt.execute();
|
||||||
|
status = true;
|
||||||
|
} catch (SQLException e) {
|
||||||
|
throw new AndroidFeatureManagementDAOException(
|
||||||
|
"Error occurred while deleting android feature '" +
|
||||||
|
mblFeatureId + "' from Android database.", e);
|
||||||
|
} finally {
|
||||||
|
MobileDeviceManagementDAOUtil.cleanupResources(stmt, null);
|
||||||
|
}
|
||||||
|
return status;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean deleteFeatureByCode(String mblFeatureCode) throws MobileDeviceManagementDAOException {
|
||||||
|
PreparedStatement stmt = null;
|
||||||
|
boolean status = false;
|
||||||
|
try {
|
||||||
|
Connection conn = this.getConnection();
|
||||||
|
String sql = "DELETE FROM AD_FEATURE WHERE CODE = ?";
|
||||||
|
stmt = conn.prepareStatement(sql);
|
||||||
|
stmt.setString(1, mblFeatureCode);
|
||||||
|
stmt.execute();
|
||||||
|
status = true;
|
||||||
|
} catch (SQLException e) {
|
||||||
|
throw new AndroidFeatureManagementDAOException(
|
||||||
|
"Error occurred while deleting android feature '" +
|
||||||
|
mblFeatureCode + "' from Android database.", e);
|
||||||
|
} finally {
|
||||||
|
MobileDeviceManagementDAOUtil.cleanupResources(stmt, null);
|
||||||
|
}
|
||||||
|
return status;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public MobileFeature getFeatureById(int mblFeatureId) throws MobileDeviceManagementDAOException {
|
||||||
|
PreparedStatement stmt = null;
|
||||||
|
ResultSet rs = null;
|
||||||
|
try {
|
||||||
|
Connection conn = this.getConnection();
|
||||||
|
String sql = "SELECT ID, CODE, NAME, DESCRIPTION FROM AD_FEATURE WHERE ID = ?";
|
||||||
|
stmt = conn.prepareStatement(sql);
|
||||||
|
stmt.setInt(1, mblFeatureId);
|
||||||
|
rs = stmt.executeQuery();
|
||||||
|
|
||||||
|
MobileFeature mobileFeature = null;
|
||||||
|
if (rs.next()) {
|
||||||
|
mobileFeature = new MobileFeature();
|
||||||
|
mobileFeature.setId(rs.getInt(AndroidPluginConstants.ANDROID_FEATURE_ID));
|
||||||
|
mobileFeature.setCode(rs.getString(AndroidPluginConstants.ANDROID_FEATURE_CODE));
|
||||||
|
mobileFeature.setName(rs.getString(AndroidPluginConstants.ANDROID_FEATURE_NAME));
|
||||||
|
mobileFeature.setDescription(rs.getString(AndroidPluginConstants.ANDROID_FEATURE_DESCRIPTION));
|
||||||
|
mobileFeature.setDeviceType(
|
||||||
|
DeviceManagementConstants.MobileDeviceTypes.MOBILE_DEVICE_TYPE_ANDROID);
|
||||||
|
}
|
||||||
|
return mobileFeature;
|
||||||
|
} catch (SQLException e) {
|
||||||
|
throw new AndroidFeatureManagementDAOException(
|
||||||
|
"Error occurred while retrieving android feature '" +
|
||||||
|
mblFeatureId + "' from the Android database.", e);
|
||||||
|
} finally {
|
||||||
|
MobileDeviceManagementDAOUtil.cleanupResources(stmt, rs);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public MobileFeature getFeatureByCode(String mblFeatureCode) throws MobileDeviceManagementDAOException {
|
||||||
|
PreparedStatement stmt = null;
|
||||||
|
ResultSet rs = null;
|
||||||
|
try {
|
||||||
|
Connection conn = this.getConnection();
|
||||||
|
String sql = "SELECT ID, CODE, NAME, DESCRIPTION FROM AD_FEATURE WHERE CODE = ?";
|
||||||
|
stmt = conn.prepareStatement(sql);
|
||||||
|
stmt.setString(1, mblFeatureCode);
|
||||||
|
rs = stmt.executeQuery();
|
||||||
|
|
||||||
|
MobileFeature mobileFeature = null;
|
||||||
|
if (rs.next()) {
|
||||||
|
mobileFeature = new MobileFeature();
|
||||||
|
mobileFeature.setId(rs.getInt(AndroidPluginConstants.ANDROID_FEATURE_ID));
|
||||||
|
mobileFeature.setCode(rs.getString(AndroidPluginConstants.ANDROID_FEATURE_CODE));
|
||||||
|
mobileFeature.setName(rs.getString(AndroidPluginConstants.ANDROID_FEATURE_NAME));
|
||||||
|
mobileFeature.setDescription(rs.getString(AndroidPluginConstants.ANDROID_FEATURE_DESCRIPTION));
|
||||||
|
mobileFeature.setDeviceType(
|
||||||
|
DeviceManagementConstants.MobileDeviceTypes.MOBILE_DEVICE_TYPE_ANDROID);
|
||||||
|
}
|
||||||
|
return mobileFeature;
|
||||||
|
} catch (SQLException e) {
|
||||||
|
throw new AndroidFeatureManagementDAOException(
|
||||||
|
"Error occurred while retrieving android feature '" +
|
||||||
|
mblFeatureCode + "' from the Android database.", e);
|
||||||
|
} finally {
|
||||||
|
MobileDeviceManagementDAOUtil.cleanupResources(stmt, rs);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<MobileFeature> getFeatureByDeviceType(String deviceType)
|
||||||
|
throws MobileDeviceManagementDAOException {
|
||||||
|
return this.getAllFeatures();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<MobileFeature> getAllFeatures() throws MobileDeviceManagementDAOException {
|
||||||
|
PreparedStatement stmt = null;
|
||||||
|
ResultSet rs = null;
|
||||||
|
List<MobileFeature> features = new ArrayList<MobileFeature>();
|
||||||
|
|
||||||
|
try {
|
||||||
|
Connection conn = this.getConnection();
|
||||||
|
String sql = "SELECT ID, CODE, NAME, DESCRIPTION FROM AD_FEATURE";
|
||||||
|
stmt = conn.prepareStatement(sql);
|
||||||
|
rs = stmt.executeQuery();
|
||||||
|
MobileFeature mobileFeature = null;
|
||||||
|
|
||||||
|
while (rs.next()) {
|
||||||
|
mobileFeature = new MobileFeature();
|
||||||
|
mobileFeature.setId(rs.getInt(AndroidPluginConstants.ANDROID_FEATURE_ID));
|
||||||
|
mobileFeature.setCode(rs.getString(AndroidPluginConstants.ANDROID_FEATURE_CODE));
|
||||||
|
mobileFeature.setName(rs.getString(AndroidPluginConstants.ANDROID_FEATURE_NAME));
|
||||||
|
mobileFeature.setDescription(rs.getString(AndroidPluginConstants.ANDROID_FEATURE_DESCRIPTION));
|
||||||
|
mobileFeature.setDeviceType(
|
||||||
|
DeviceManagementConstants.MobileDeviceTypes.MOBILE_DEVICE_TYPE_ANDROID);
|
||||||
|
features.add(mobileFeature);
|
||||||
|
}
|
||||||
|
return features;
|
||||||
|
} catch (SQLException e) {
|
||||||
|
throw new AndroidFeatureManagementDAOException("Error occurred while retrieving all android " +
|
||||||
|
"features from the android database.", e);
|
||||||
|
} finally {
|
||||||
|
MobileDeviceManagementDAOUtil.cleanupResources(stmt, rs);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private Connection getConnection() throws MobileDeviceManagementDAOException {
|
||||||
|
try {
|
||||||
|
return dataSource.getConnection();
|
||||||
|
} catch (SQLException e) {
|
||||||
|
String msg = "Error occurred while obtaining a connection from the Android mobile device " +
|
||||||
|
"management metadata repository datasource";
|
||||||
|
log.error(msg, e);
|
||||||
|
throw new MobileDeviceManagementDAOException(msg, e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -1,165 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
|
||||||
*
|
|
||||||
* WSO2 Inc. licenses this file to you under the Apache License,
|
|
||||||
* Version 2.0 (the "License"); you may not use this file except
|
|
||||||
* in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing,
|
|
||||||
* software distributed under the License is distributed on an
|
|
||||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
|
||||||
* KIND, either express or implied. See the License for the
|
|
||||||
* specific language governing permissions and limitations
|
|
||||||
* under the License.
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
package org.wso2.carbon.device.mgt.mobile.impl.android.dao.impl;
|
|
||||||
|
|
||||||
import org.wso2.carbon.device.mgt.common.Feature;
|
|
||||||
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.MobileFeatureDAO;
|
|
||||||
import org.wso2.carbon.device.mgt.mobile.dao.util.MobileDeviceManagementDAOUtil;
|
|
||||||
import org.wso2.carbon.device.mgt.mobile.dto.MobileFeature;
|
|
||||||
import org.wso2.carbon.device.mgt.mobile.impl.android.dao.FeatureManagementDAOException;
|
|
||||||
import org.wso2.carbon.device.mgt.mobile.util.MobileDeviceManagementUtil;
|
|
||||||
|
|
||||||
import java.sql.Connection;
|
|
||||||
import java.sql.PreparedStatement;
|
|
||||||
import java.sql.ResultSet;
|
|
||||||
import java.sql.SQLException;
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
public class FeatureDAOImpl implements MobileFeatureDAO {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean addFeature(MobileFeature mobileFeature) throws MobileDeviceManagementDAOException {
|
|
||||||
PreparedStatement stmt = null;
|
|
||||||
boolean status = false;
|
|
||||||
try {
|
|
||||||
Connection conn = MobileDeviceManagementDAOFactory.getConnection();
|
|
||||||
String sql = "INSERT INTO AD_FEATURE(CODE, NAME, DESCRIPTION) VALUES (?, ?, ?)";
|
|
||||||
stmt = conn.prepareStatement(sql);
|
|
||||||
stmt.setString(1, mobileFeature.getCode());
|
|
||||||
stmt.setString(2, mobileFeature.getName());
|
|
||||||
stmt.setString(3, mobileFeature.getDescription());
|
|
||||||
stmt.executeUpdate();
|
|
||||||
status = true;
|
|
||||||
status = true;
|
|
||||||
} catch (SQLException e) {
|
|
||||||
throw new org.wso2.carbon.device.mgt.mobile.impl.ios.dao.FeatureManagementDAOException(
|
|
||||||
"Error occurred while adding feature '" +
|
|
||||||
mobileFeature.getName() + "' into the metadata repository", e);
|
|
||||||
} finally {
|
|
||||||
MobileDeviceManagementDAOUtil.cleanupResources(stmt, null);
|
|
||||||
}
|
|
||||||
return status;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean updateFeature(MobileFeature mobileFeature) throws MobileDeviceManagementDAOException {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean deleteFeatureById(int mblFeatureId) throws MobileDeviceManagementDAOException {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean deleteFeatureByCode(String mblFeatureCode) throws MobileDeviceManagementDAOException {
|
|
||||||
PreparedStatement stmt = null;
|
|
||||||
boolean status = false;
|
|
||||||
try {
|
|
||||||
Connection conn = MobileDeviceManagementDAOFactory.getConnection();
|
|
||||||
String sql = "DELETE FROM AD_FEATURE WHERE CODE = ?";
|
|
||||||
stmt = conn.prepareStatement(sql);
|
|
||||||
stmt.setString(1, mblFeatureCode);
|
|
||||||
stmt.execute();
|
|
||||||
status = true;
|
|
||||||
} catch (SQLException e) {
|
|
||||||
throw new org.wso2.carbon.device.mgt.mobile.impl.ios.dao.FeatureManagementDAOException(
|
|
||||||
"Error occurred while adding feature '" +
|
|
||||||
mblFeatureCode + "' into the metadata repository", e);
|
|
||||||
} finally {
|
|
||||||
MobileDeviceManagementDAOUtil.cleanupResources(stmt, null);
|
|
||||||
}
|
|
||||||
return status;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public MobileFeature getFeatureById(int mblFeatureId) throws MobileDeviceManagementDAOException {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public MobileFeature getFeatureByCode(String mblFeatureCode) throws MobileDeviceManagementDAOException {
|
|
||||||
PreparedStatement stmt = null;
|
|
||||||
ResultSet rs = null;
|
|
||||||
try {
|
|
||||||
Connection conn = MobileDeviceManagementDAOFactory.getConnection();
|
|
||||||
String sql = "SELECT ID, CODE, NAME, DESCRIPTION FROM AD_FEATURE WHERE CODE = ?";
|
|
||||||
stmt = conn.prepareStatement(sql);
|
|
||||||
stmt.setString(1, mblFeatureCode);
|
|
||||||
rs = stmt.executeQuery();
|
|
||||||
|
|
||||||
Feature feature = null;
|
|
||||||
if (rs.next()) {
|
|
||||||
feature = new Feature();
|
|
||||||
feature.setId(rs.getInt("ID"));
|
|
||||||
feature.setCode(rs.getString("CODE"));
|
|
||||||
feature.setName(rs.getString("NAME"));
|
|
||||||
feature.setDescription(rs.getString("DESCRIPTION"));
|
|
||||||
}
|
|
||||||
MobileFeature mobileFeature = MobileDeviceManagementUtil.convertToMobileFeature(feature);
|
|
||||||
return mobileFeature;
|
|
||||||
} catch (SQLException e) {
|
|
||||||
throw new org.wso2.carbon.device.mgt.mobile.impl.ios.dao.FeatureManagementDAOException(
|
|
||||||
"Error occurred while retrieving feature metadata '" +
|
|
||||||
mblFeatureCode + "' from the feature metadata repository", e);
|
|
||||||
} finally {
|
|
||||||
MobileDeviceManagementDAOUtil.cleanupResources(stmt, rs);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public List<MobileFeature> getFeatureByDeviceType(String deviceType)
|
|
||||||
throws MobileDeviceManagementDAOException {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public List<MobileFeature> getAllFeatures() throws MobileDeviceManagementDAOException {
|
|
||||||
PreparedStatement stmt = null;
|
|
||||||
ResultSet rs = null;
|
|
||||||
List<MobileFeature> features = new ArrayList<MobileFeature>();
|
|
||||||
|
|
||||||
try {
|
|
||||||
Connection conn = MobileDeviceManagementDAOFactory.getConnection();
|
|
||||||
String sql = "SELECT ID, CODE, NAME, DESCRIPTION FROM AD_FEATURE";
|
|
||||||
stmt = conn.prepareStatement(sql);
|
|
||||||
rs = stmt.executeQuery();
|
|
||||||
MobileFeature mobileFeature;
|
|
||||||
|
|
||||||
while (rs.next()) {
|
|
||||||
Feature feature = new Feature();
|
|
||||||
feature.setId(rs.getInt("ID"));
|
|
||||||
feature.setCode(rs.getString("CODE"));
|
|
||||||
feature.setName(rs.getString("NAME"));
|
|
||||||
feature.setDescription(rs.getString("DESCRIPTION"));
|
|
||||||
mobileFeature = MobileDeviceManagementUtil.convertToMobileFeature(feature);
|
|
||||||
features.add(mobileFeature);
|
|
||||||
}
|
|
||||||
return features;
|
|
||||||
} catch (SQLException e) {
|
|
||||||
throw new FeatureManagementDAOException("Error occurred while retrieving all feature metadata from the " +
|
|
||||||
"feature metadata repository", e);
|
|
||||||
} finally {
|
|
||||||
MobileDeviceManagementDAOUtil.cleanupResources(stmt, rs);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -0,0 +1,47 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
||||||
|
*
|
||||||
|
* WSO2 Inc. licenses this file to you under the Apache License,
|
||||||
|
* Version 2.0 (the "License"); you may not use this file except
|
||||||
|
* in compliance with the License.
|
||||||
|
* you may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing,
|
||||||
|
* software distributed under the License is distributed on an
|
||||||
|
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||||
|
* KIND, either express or implied. See the License for the
|
||||||
|
* specific language governing permissions and limitations
|
||||||
|
* under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package org.wso2.carbon.device.mgt.mobile.impl.android.util;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Defines constants used by android plugin.
|
||||||
|
*/
|
||||||
|
public class AndroidPluginConstants {
|
||||||
|
|
||||||
|
//Properties related to AD_DEVICE table
|
||||||
|
public static final String ANDROID_DEVICE_ID = "ANDROID_DEVICE_ID";
|
||||||
|
public static final String GCM_TOKEN = "GCM_TOKEN";
|
||||||
|
public static final String DEVICE_INFO = "DEVICE_INFO";
|
||||||
|
public static final String SERIAL = "SERIAL";
|
||||||
|
public static final String DEVICE_MODEL = "DEVICE_MODEL";
|
||||||
|
public static final String DEVICE_NAME = "DEVICE_NAME";
|
||||||
|
public static final String LATITUDE = "LATITUDE";
|
||||||
|
public static final String LONGITUDE = "LONGITUDE";
|
||||||
|
public static final String IMEI = "IMEI";
|
||||||
|
public static final String IMSI = "IMEI";
|
||||||
|
public static final String VENDOR = "VENDOR";
|
||||||
|
public static final String OS_VERSION = "OS_VERSION";
|
||||||
|
public static final String MAC_ADDRESS = "MAC_ADDRESS";
|
||||||
|
|
||||||
|
//Properties related to AD_FEATURE table
|
||||||
|
public static final String ANDROID_FEATURE_ID = "ID";
|
||||||
|
public static final String ANDROID_FEATURE_CODE = "CODE";
|
||||||
|
public static final String ANDROID_FEATURE_NAME = "NAME";
|
||||||
|
public static final String ANDROID_FEATURE_DESCRIPTION = "DESCRIPTION";
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,38 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
||||||
|
*
|
||||||
|
* WSO2 Inc. licenses this file to you under the Apache License,
|
||||||
|
* Version 2.0 (the "License"); you may not use this file except
|
||||||
|
* in compliance with the License.
|
||||||
|
* you may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing,
|
||||||
|
* software distributed under the License is distributed on an
|
||||||
|
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||||
|
* KIND, either express or implied. See the License for the
|
||||||
|
* specific language governing permissions and limitations
|
||||||
|
* under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package org.wso2.carbon.device.mgt.mobile.impl.android.util;
|
||||||
|
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Contains utility methods used by Android plugin.
|
||||||
|
*/
|
||||||
|
public class AndroidUtils {
|
||||||
|
|
||||||
|
public static String getDeviceProperty(Map<String, String> deviceProperties, String property) {
|
||||||
|
|
||||||
|
String deviceProperty = deviceProperties.get(property);
|
||||||
|
|
||||||
|
if (deviceProperty == null) {
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
|
||||||
|
return deviceProperty;
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in new issue