Added Android pluging DAO layer & db scripts

revert-dabc3590
harshanL 10 years ago
parent f693311ed9
commit f75aa4e1c8

@ -23,14 +23,11 @@ import org.apache.commons.logging.LogFactory;
import org.wso2.carbon.device.mgt.common.DeviceManagementException; import org.wso2.carbon.device.mgt.common.DeviceManagementException;
import org.wso2.carbon.device.mgt.common.Feature; import org.wso2.carbon.device.mgt.common.Feature;
import org.wso2.carbon.device.mgt.common.FeatureManager; import org.wso2.carbon.device.mgt.common.FeatureManager;
import org.wso2.carbon.device.mgt.mobile.common.MobileDeviceMgtPluginException;
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.MobileDeviceManagementDAOFactory;
import org.wso2.carbon.device.mgt.mobile.dao.MobileFeatureDAO; import org.wso2.carbon.device.mgt.mobile.dao.MobileFeatureDAO;
import org.wso2.carbon.device.mgt.mobile.dto.MobileFeature; import org.wso2.carbon.device.mgt.mobile.dto.MobileFeature;
import org.wso2.carbon.device.mgt.mobile.impl.android.dao.AndroidDAOFactory; import org.wso2.carbon.device.mgt.mobile.impl.android.dao.AndroidDAOFactory;
import org.wso2.carbon.device.mgt.mobile.impl.android.dao.FeatureDAO;
import org.wso2.carbon.device.mgt.mobile.impl.android.dao.FeatureManagementDAOException;
import org.wso2.carbon.device.mgt.mobile.util.MobileDeviceManagementUtil; import org.wso2.carbon.device.mgt.mobile.util.MobileDeviceManagementUtil;
import java.util.ArrayList; import java.util.ArrayList;

@ -22,7 +22,8 @@ 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.config.datasource.MobileDataSourceConfig; import org.wso2.carbon.device.mgt.mobile.config.datasource.MobileDataSourceConfig;
import org.wso2.carbon.device.mgt.mobile.dao.*; import org.wso2.carbon.device.mgt.mobile.dao.*;
import org.wso2.carbon.device.mgt.mobile.impl.android.dao.impl.FeatureDAOImpl; import org.wso2.carbon.device.mgt.mobile.impl.android.dao.impl.AndroidDeviceDAOImpl;
import org.wso2.carbon.device.mgt.mobile.impl.android.dao.impl.AndroidFeatureDAOImpl;
import javax.sql.DataSource; import javax.sql.DataSource;
@ -38,7 +39,7 @@ public class AndroidDAOFactory extends MobileDeviceManagementDAOFactory
@Override @Override
public MobileDeviceDAO getMobileDeviceDAO() { public MobileDeviceDAO getMobileDeviceDAO() {
return null; return new AndroidDeviceDAOImpl(dataSource);
} }
@Override @Override
@ -57,7 +58,7 @@ public class AndroidDAOFactory extends MobileDeviceManagementDAOFactory
} }
@Override public MobileFeatureDAO getMobileFeatureDao() { @Override public MobileFeatureDAO getMobileFeatureDao() {
return new FeatureDAOImpl(); return new AndroidFeatureDAOImpl(dataSource);
} }
public MobileFeaturePropertyDAO getFeaturePropertyDAO() { public MobileFeaturePropertyDAO getFeaturePropertyDAO() {

@ -20,7 +20,7 @@ package org.wso2.carbon.device.mgt.mobile.impl.android.dao;
import org.wso2.carbon.device.mgt.mobile.dao.MobileDeviceManagementDAOException; import org.wso2.carbon.device.mgt.mobile.dao.MobileDeviceManagementDAOException;
public class FeatureManagementDAOException extends MobileDeviceManagementDAOException { public class AndroidFeatureManagementDAOException extends MobileDeviceManagementDAOException {
private String message; private String message;
private static final long serialVersionUID = 2021891706072918865L; private static final long serialVersionUID = 2021891706072918865L;
@ -32,7 +32,7 @@ public class FeatureManagementDAOException extends MobileDeviceManagementDAOExce
* @param message error message * @param message error message
* @param nestedException exception * @param nestedException exception
*/ */
public FeatureManagementDAOException(String message, Exception nestedException) { public AndroidFeatureManagementDAOException(String message, Exception nestedException) {
super(message, nestedException); super(message, nestedException);
setErrorMessage(message); setErrorMessage(message);
} }
@ -44,7 +44,7 @@ public class FeatureManagementDAOException extends MobileDeviceManagementDAOExce
* @param message the detail message. * @param message the detail message.
* @param cause the cause of this exception. * @param cause the cause of this exception.
*/ */
public FeatureManagementDAOException(String message, Throwable cause) { public AndroidFeatureManagementDAOException(String message, Throwable cause) {
super(message, cause); super(message, cause);
setErrorMessage(message); setErrorMessage(message);
} }
@ -54,7 +54,7 @@ public class FeatureManagementDAOException extends MobileDeviceManagementDAOExce
* *
* @param message the detail message. * @param message the detail message.
*/ */
public FeatureManagementDAOException(String message) { public AndroidFeatureManagementDAOException(String message) {
super(message); super(message);
setErrorMessage(message); setErrorMessage(message);
} }
@ -64,7 +64,7 @@ public class FeatureManagementDAOException extends MobileDeviceManagementDAOExce
* *
* @param cause the cause of this exception. * @param cause the cause of this exception.
*/ */
public FeatureManagementDAOException(Throwable cause) { public AndroidFeatureManagementDAOException(Throwable cause) {
super(cause); super(cause);
} }

@ -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;
}
}

@ -174,7 +174,6 @@ public class MobileDeviceManagementUtil {
mobileFeature.setCode(feature.getCode()); mobileFeature.setCode(feature.getCode());
mobileFeature.setDescription(feature.getDescription()); mobileFeature.setDescription(feature.getDescription());
mobileFeature.setDeviceType(feature.getDeviceType()); mobileFeature.setDeviceType(feature.getDeviceType());
return mobileFeature; return mobileFeature;
} }
@ -184,7 +183,6 @@ public class MobileDeviceManagementUtil {
feature.setDeviceType(mobileFeature.getDeviceType()); feature.setDeviceType(mobileFeature.getDeviceType());
feature.setCode(mobileFeature.getCode()); feature.setCode(mobileFeature.getCode());
feature.setName(mobileFeature.getName()); feature.setName(mobileFeature.getName());
return feature; return feature;
} }
} }

@ -39,14 +39,38 @@
</ManagementRepository> </ManagementRepository>
<APIPublisher> <APIPublisher>
<APIs> <APIs>
<API> <API>
<Name>enrollment</Name> <Name>appmanager</Name>
<Owner>admin</Owner> <Owner>admin</Owner>
<Context>enrollment</Context> <Context>/devices</Context>
<Version>1.0.0</Version> <Version>1.0.0</Version>
<Endpoint>http://localhost:9763/</Endpoint> <Endpoint>http://localhost:9763/test/app</Endpoint>
<Transports>http,https</Transports> <Transports>http,https</Transports>
</API> </API>
<API>
<Name>enrol</Name>
<Owner>admin</Owner>
<Context>/enroll</Context>
<Version>1.0.0</Version>
<Endpoint>http://localhost:9763/mdm-android-agent/enrollment</Endpoint>
<Transports>http,https</Transports>
</API>
<API>
<Name>license</Name>
<Owner>admin</Owner>
<Context>/license</Context>
<Version>1.0.0</Version>
<Endpoint>http://localhost:9763/mdm-android-agent/devices/license</Endpoint>
<Transports>http,https</Transports>
</API>
<API>
<Name>operation</Name>
<Owner>admin</Owner>
<Context>/operation</Context>
<Version>1.0.0</Version>
<Endpoint>http://localhost:9763/mdm-android-agent/operations</Endpoint>
<Transports>http,https</Transports>
</API>
</APIs> </APIs>
</APIPublisher> </APIPublisher>
</MobileDeviceMgtConfiguration> </MobileDeviceMgtConfiguration>

@ -3,8 +3,8 @@
-- Table `AD_DEVICE` -- Table `AD_DEVICE`
-- ----------------------------------------------------- -- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `AD_DEVICE` ( CREATE TABLE IF NOT EXISTS `AD_DEVICE` (
`MOBILE_DEVICE_ID` VARCHAR(45) NOT NULL , `ANDROID_DEVICE_ID` VARCHAR(45) NOT NULL ,
`PUSH_TOKEN` VARCHAR(45) NULL DEFAULT NULL , `GCM_TOKEN` VARCHAR(45) NULL DEFAULT NULL ,
`IMEI` VARCHAR(45) NULL DEFAULT NULL , `IMEI` VARCHAR(45) NULL DEFAULT NULL ,
`IMSI` VARCHAR(45) NULL DEFAULT NULL , `IMSI` VARCHAR(45) NULL DEFAULT NULL ,
`OS_VERSION` VARCHAR(45) NULL DEFAULT NULL , `OS_VERSION` VARCHAR(45) NULL DEFAULT NULL ,
@ -12,11 +12,10 @@ CREATE TABLE IF NOT EXISTS `AD_DEVICE` (
`VENDOR` VARCHAR(45) NULL DEFAULT NULL , `VENDOR` VARCHAR(45) NULL DEFAULT NULL ,
`LATITUDE` VARCHAR(45) NULL DEFAULT NULL, `LATITUDE` VARCHAR(45) NULL DEFAULT NULL,
`LONGITUDE` VARCHAR(45) NULL DEFAULT NULL, `LONGITUDE` VARCHAR(45) NULL DEFAULT NULL,
`CHALLENGE` VARCHAR(45) NULL DEFAULT NULL,
`TOKEN` VARCHAR(500) NULL DEFAULT NULL,
`UNLOCK_TOKEN` VARCHAR(500) NULL DEFAULT NULL,
`SERIAL` VARCHAR(45) NULL DEFAULT NULL, `SERIAL` VARCHAR(45) NULL DEFAULT NULL,
PRIMARY KEY (`MOBILE_DEVICE_ID`) ); `MAC_ADDRESS` VARCHAR(45) NULL DEFAULT NULL,
`DEVICE_NAME` VARCHAR(100) NULL DEFAULT NULL,
PRIMARY KEY (`ANDROID_DEVICE_ID`) );
-- ----------------------------------------------------- -- -----------------------------------------------------
-- Table `AD_FEATURE` -- Table `AD_FEATURE`
@ -28,15 +27,3 @@ CREATE TABLE IF NOT EXISTS `AD_FEATURE` (
`DESCRIPTION` VARCHAR(200) NULL , `DESCRIPTION` VARCHAR(200) NULL ,
PRIMARY KEY (`ID`) ); PRIMARY KEY (`ID`) );
-- -----------------------------------------------------
-- Table `AD_FEATURE_PROPERTY`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `AD_FEATURE_PROPERTY` (
`PROPERTY` VARCHAR(45) NOT NULL ,
`FEATURE_ID` INT NOT NULL ,
PRIMARY KEY (`PROPERTY`) ,
CONSTRAINT `fk_AD_FEATURE_PROPERTY_AD_FEATURE1`
FOREIGN KEY (`FEATURE_ID` )
REFERENCES `AD_FEATURE` (`ID` )
ON DELETE NO ACTION
ON UPDATE NO ACTION);

@ -30,7 +30,4 @@ CREATE TABLE IF NOT EXISTS `IOS_FEATURE` (
`ICCID` VARCHAR(45) NULL DEFAULT NULL, `ICCID` VARCHAR(45) NULL DEFAULT NULL,
`LATITUDE` VARCHAR(45) NULL DEFAULT NULL, `LATITUDE` VARCHAR(45) NULL DEFAULT NULL,
`LONGITUDE` VARCHAR(45) NULL DEFAULT NULL, `LONGITUDE` VARCHAR(45) NULL DEFAULT NULL,
PRIMARY KEY (`MOBILE_DEVICE_ID`) ); PRIMARY KEY (`MOBILE_DEVICE_ID`) );
long

@ -1,52 +1,31 @@
-- ----------------------------------------------------- -- -----------------------------------------------------
-- Table `MBL_DEVICE` -- Table `MBL_DEVICE`
-- ----------------------------------------------------- -- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `MBL_DEVICE` ( CREATE TABLE IF NOT EXISTS `AD_DEVICE` (
`MOBILE_DEVICE_ID` VARCHAR(45) NOT NULL, `ANDROID_DEVICE_ID` VARCHAR(45) NOT NULL ,
`PUSH_TOKEN` VARCHAR(45) NULL DEFAULT NULL, `GCM_TOKEN` VARCHAR(45) NULL DEFAULT NULL ,
`IMEI` VARCHAR(45) NULL DEFAULT NULL, `IMEI` VARCHAR(45) NULL DEFAULT NULL ,
`IMSI` VARCHAR(45) NULL DEFAULT NULL, `IMSI` VARCHAR(45) NULL DEFAULT NULL ,
`OS_VERSION` VARCHAR(45) NULL DEFAULT NULL, `OS_VERSION` VARCHAR(45) NULL DEFAULT NULL ,
`DEVICE_MODEL` VARCHAR(45) NULL DEFAULT NULL, `DEVICE_MODEL` VARCHAR(45) NULL DEFAULT NULL ,
`VENDOR` VARCHAR(45) NULL DEFAULT NULL, `VENDOR` VARCHAR(45) NULL DEFAULT NULL ,
`LATITUDE` VARCHAR(45) NULL DEFAULT NULL, `LATITUDE` VARCHAR(45) NULL DEFAULT NULL,
`LONGITUDE` VARCHAR(45) NULL DEFAULT NULL, `LONGITUDE` VARCHAR(45) NULL DEFAULT NULL,
`CHALLENGE` VARCHAR(45) NULL DEFAULT NULL,
`TOKEN` VARCHAR(50) NULL DEFAULT NULL,
`UNLOCK_TOKEN` VARCHAR(2000) NULL DEFAULT NULL,
`SERIAL` VARCHAR(45) NULL DEFAULT NULL, `SERIAL` VARCHAR(45) NULL DEFAULT NULL,
PRIMARY KEY (`MOBILE_DEVICE_ID`)) `MAC_ADDRESS` VARCHAR(45) NULL DEFAULT NULL,
`DEVICE_NAME` VARCHAR(100) NULL DEFAULT NULL,
PRIMARY KEY (`ANDROID_DEVICE_ID`))
ENGINE = InnoDB; ENGINE = InnoDB;
-- ----------------------------------------------------- -- -----------------------------------------------------
-- Table `MBL_FEATURE` -- Table `MBL_FEATURE`
-- ----------------------------------------------------- -- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `MBL_FEATURE` ( CREATE TABLE IF NOT EXISTS `AD_FEATURE` (
`FEATURE_ID` INT NOT NULL AUTO_INCREMENT, `ID` INT NOT NULL AUTO_INCREMENT ,
`DEVICE_TYPE` VARCHAR(45) NOT NULL , `CODE` VARCHAR(45) NOT NULL,
`CODE` VARCHAR(45) NULL, `NAME` VARCHAR(100) NULL ,
`NAME` VARCHAR(100) NULL, `DESCRIPTION` VARCHAR(200) NULL ,
`DESCRIPTION` VARCHAR(200) NULL, PRIMARY KEY (`ID`))
PRIMARY KEY (`FEATURE_ID`))
ENGINE = InnoDB; ENGINE = InnoDB;
-- -----------------------------------------------------
-- Table `MBL_FEATURE_PROPERTY`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `MBL_FEATURE_PROPERTY` (
`PROPERTY` VARCHAR(45) NOT NULL ,
`FEATURE_ID` INT NOT NULL ,
PRIMARY KEY (`PROPERTY`),
CONSTRAINT `fk_MBL_FEATURE_PROPERTY_MBL_FEATURE1`
FOREIGN KEY (`FEATURE_ID`)
REFERENCES `MBL_FEATURE` (`FEATURE_ID`)
ON DELETE NO ACTION
ON UPDATE NO ACTION)
ENGINE = InnoDB;
-- -----------------------------------------------------
-- Inserts
-- -----------------------------------------------------
INSERT INTO MBL_FEATURE (DEVICE_TYPE,NAME,CODE, DESCRIPTION) VALUES ('android','DEVICE_LOCK','503A','Device Lock'),('android','WIPE','504A','Device Wipe'),('android','CLEARPASSCODE','505A','Clear Passcode'),('android','APPLIST','502A','Get All Applications'),('android','LOCATION','501A','Location'),('android','INFO','500A','Device Information'),('android','NOTIFICATION','506A','Message'),('android','WIFI','507A','Setup Wifi'),('android','CAMERA','508A','Camera Control'),('android','MUTE','513A','Mute Device'),('android','INSTALLAPP','509A','Install Application'),('android','UNINSTALLAPP','510A','Uninstall Application'),('android','ENCRYPT','511A','Encrypt Storage'),('android','APN','512A','APN'),('android','WEBCLIP','518A','Create Webclips'),('android','PASSWORDPOLICY','519A','Passcode Policy'),('android','EMAIL','520A','Email Configuration'),('android','GOOGLECALENDAR','521A','Calender Subscription'),('android','VPN','523A','VPN'),('android','LDAP','524A','LDAP'),('android','CHANGEPASSWORD','526A','Set Passcode'),('android','ENTERPRISEWIPE','527A','Enterprise Wipe'),('android','POLICY','500P','Policy Enforcement'),('android','MONITORING','501P','Policy Monitoring '),('android','BLACKLISTAPPS','528B','Blacklist Apps'),('android','REVOKEPOLICY','502P','Revoke Policy');

Loading…
Cancel
Save