revert-dabc3590
milanperera 9 years ago
commit b0bc3ff3f1

@ -76,7 +76,7 @@
org.wso2.carbon.registry.core.service,
org.wso2.carbon.registry.core.session,
org.wso2.carbon.registry.api,
org.wso2.carbon.device.mgt.extensions.license.mgt
org.wso2.carbon.device.mgt.extensions.license.mgt.registry
</Import-Package>
<Export-Package>
!org.wso2.carbon.device.mgt.mobile.internal,

@ -19,6 +19,7 @@
package org.wso2.carbon.device.mgt.mobile.dto;
import java.io.Serializable;
import java.util.HashMap;
import java.util.Map;
/**
@ -37,6 +38,10 @@ public class MobileDevice implements Serializable {
private String serial;
private Map<String, String> deviceProperties;
public MobileDevice() {
this.deviceProperties = new HashMap<>();
}
public String getMobileDeviceId() {
return mobileDeviceId;
}

@ -27,12 +27,13 @@ import org.wso2.carbon.device.mgt.common.configuration.mgt.TenantConfiguration;
import org.wso2.carbon.device.mgt.common.license.mgt.License;
import org.wso2.carbon.device.mgt.common.license.mgt.LicenseManagementException;
import org.wso2.carbon.device.mgt.common.license.mgt.LicenseManager;
import org.wso2.carbon.device.mgt.extensions.license.mgt.RegistryBasedLicenseManager;
import org.wso2.carbon.device.mgt.extensions.license.mgt.registry.RegistryBasedLicenseManager;
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.MobileDeviceManagementDAOFactory;
import org.wso2.carbon.device.mgt.mobile.dto.MobileDevice;
import org.wso2.carbon.device.mgt.mobile.impl.android.dao.AndroidDAOFactory;
import org.wso2.carbon.device.mgt.mobile.impl.android.util.AndroidPluginUtils;
import org.wso2.carbon.device.mgt.mobile.util.MobileDeviceManagementUtil;
import org.wso2.carbon.registry.api.Collection;
import org.wso2.carbon.registry.api.RegistryException;
@ -43,14 +44,21 @@ import java.util.List;
public class AndroidDeviceManager implements DeviceManager {
private MobileDeviceManagementDAOFactory mobileDeviceManagementDAOFactory;
private MobileDeviceManagementDAOFactory daoFactory;
private static final Log log = LogFactory.getLog(AndroidDeviceManagementService.class);
private FeatureManager featureManager = new AndroidFeatureManager();
private LicenseManager licenseManager;
public AndroidDeviceManager() {
this.mobileDeviceManagementDAOFactory = new AndroidDAOFactory();
this.daoFactory = new AndroidDAOFactory();
this.licenseManager = new RegistryBasedLicenseManager();
License defaultLicense = AndroidPluginUtils.getDefaultLicense();
try {
licenseManager.addLicense(AndroidDeviceManagementService.DEVICE_TYPE_ANDROID, defaultLicense);
} catch (LicenseManagementException e) {
log.error("Error occurred while adding default license for Android devices", e);
}
}
@Override
@ -89,9 +97,9 @@ public class AndroidDeviceManager implements DeviceManager {
@Override
public TenantConfiguration getConfiguration() throws DeviceManagementException {
Collection dsCollection = null;
Collection dsCollection;
TenantConfiguration tenantConfiguration;
List<ConfigurationEntry> configs = new ArrayList<ConfigurationEntry>();
List<ConfigurationEntry> configs = new ArrayList<>();
ConfigurationEntry entry;
Resource resource;
try {
@ -135,7 +143,7 @@ public class AndroidDeviceManager implements DeviceManager {
this.modifyEnrollment(device);
} else {
AndroidDAOFactory.beginTransaction();
status = mobileDeviceManagementDAOFactory.getMobileDeviceDAO().addMobileDevice(
status = daoFactory.getMobileDeviceDAO().addMobileDevice(
mobileDevice);
AndroidDAOFactory.commitTransaction();
}
@ -162,7 +170,7 @@ public class AndroidDeviceManager implements DeviceManager {
log.debug("Modifying the Android device enrollment data");
}
AndroidDAOFactory.beginTransaction();
status = mobileDeviceManagementDAOFactory.getMobileDeviceDAO()
status = daoFactory.getMobileDeviceDAO()
.updateMobileDevice(mobileDevice);
AndroidDAOFactory.commitTransaction();
} catch (MobileDeviceManagementDAOException e) {
@ -189,7 +197,7 @@ public class AndroidDeviceManager implements DeviceManager {
log.debug("Dis-enrolling Android device : " + deviceId);
}
AndroidDAOFactory.beginTransaction();
status = mobileDeviceManagementDAOFactory.getMobileDeviceDAO()
status = daoFactory.getMobileDeviceDAO()
.deleteMobileDevice(deviceId.getId());
AndroidDAOFactory.commitTransaction();
} catch (MobileDeviceManagementDAOException e) {
@ -215,7 +223,7 @@ public class AndroidDeviceManager implements DeviceManager {
log.debug("Checking the enrollment of Android device : " + deviceId.getId());
}
MobileDevice mobileDevice =
mobileDeviceManagementDAOFactory.getMobileDeviceDAO().getMobileDevice(
daoFactory.getMobileDeviceDAO().getMobileDevice(
deviceId.getId());
if (mobileDevice != null) {
isEnrolled = true;
@ -245,15 +253,14 @@ public class AndroidDeviceManager implements DeviceManager {
Device device;
try {
if (log.isDebugEnabled()) {
log.debug("Getting the details of Android device : " + deviceId.getId());
log.debug("Getting the details of Android device : '" + deviceId.getId() + "'");
}
MobileDevice mobileDevice = mobileDeviceManagementDAOFactory.getMobileDeviceDAO().
MobileDevice mobileDevice = daoFactory.getMobileDeviceDAO().
getMobileDevice(deviceId.getId());
device = MobileDeviceManagementUtil.convertToDevice(mobileDevice);
} catch (MobileDeviceManagementDAOException e) {
String msg = "Error while fetching the Android device : " + deviceId.getId();
log.error(msg, e);
throw new DeviceManagementException(msg, e);
throw new DeviceManagementException("Error occurred while fetching the Android device: '" +
deviceId.getId() + "'", e);
}
return device;
}
@ -304,25 +311,21 @@ public class AndroidDeviceManager implements DeviceManager {
try {
if (log.isDebugEnabled()) {
log.debug(
"updating the details of Android device : " + device.getDeviceIdentifier());
log.debug("updating the details of Android device : " + device.getDeviceIdentifier());
}
AndroidDAOFactory.beginTransaction();
status = mobileDeviceManagementDAOFactory.getMobileDeviceDAO()
status = daoFactory.getMobileDeviceDAO()
.updateMobileDevice(existingMobileDevice);
AndroidDAOFactory.commitTransaction();
} catch (MobileDeviceManagementDAOException e) {
try {
AndroidDAOFactory.rollbackTransaction();
} catch (MobileDeviceManagementDAOException mobileDAOEx) {
String msg = "Error occurred while roll back the update device info transaction :" +
device.toString();
log.warn(msg, mobileDAOEx);
} catch (MobileDeviceManagementDAOException e1) {
log.warn("Error occurred while roll back the update device info transaction : '" +
device.toString() + "'", e1);
}
String msg =
"Error while updating the Android device : " + device.getDeviceIdentifier();
log.error(msg, e);
throw new DeviceManagementException(msg, e);
throw new DeviceManagementException("Error occurred while updating the Android device: '" +
device.getDeviceIdentifier() + "'", e);
}
return status;
}
@ -335,18 +338,15 @@ public class AndroidDeviceManager implements DeviceManager {
log.debug("Fetching the details of all Android devices");
}
List<MobileDevice> mobileDevices =
mobileDeviceManagementDAOFactory.getMobileDeviceDAO().
getAllMobileDevices();
daoFactory.getMobileDeviceDAO().getAllMobileDevices();
if (mobileDevices != null) {
devices = new ArrayList<Device>();
devices = new ArrayList<>();
for (MobileDevice mobileDevice : mobileDevices) {
devices.add(MobileDeviceManagementUtil.convertToDevice(mobileDevice));
}
}
} catch (MobileDeviceManagementDAOException e) {
String msg = "Error while fetching all Android devices.";
log.error(msg, e);
throw new DeviceManagementException(msg, e);
throw new DeviceManagementException("Error occurred while fetching all Android devices", e);
}
return devices;
}

@ -19,17 +19,24 @@
package org.wso2.carbon.device.mgt.mobile.impl.android;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.wso2.carbon.device.mgt.common.Device;
import org.wso2.carbon.device.mgt.common.DeviceIdentifier;
import org.wso2.carbon.device.mgt.common.DeviceManagementConstants;
import org.wso2.carbon.policy.mgt.common.Policy;
import org.wso2.carbon.policy.mgt.common.monitor.ComplianceData;
import org.wso2.carbon.policy.mgt.common.monitor.ComplianceFeature;
import org.wso2.carbon.policy.mgt.common.monitor.PolicyComplianceException;
import org.wso2.carbon.policy.mgt.common.spi.PolicyMonitoringService;
import java.util.ArrayList;
import java.util.List;
public class AndroidPolicyMonitoringService implements PolicyMonitoringService {
private static Log log = LogFactory.getLog(AndroidPolicyMonitoringService.class);
@Override
public void notifyDevices(List<Device> list) throws PolicyComplianceException {
@ -37,8 +44,25 @@ public class AndroidPolicyMonitoringService implements PolicyMonitoringService {
@Override
public ComplianceData checkPolicyCompliance(DeviceIdentifier deviceIdentifier, Policy policy, Object o) throws PolicyComplianceException {
ComplianceData complianceData = new ComplianceData();
if (log.isDebugEnabled()) {
log.info("Checking policy compliance status of device '" + deviceIdentifier.getId() + "'");
}
if (o == null || policy == null) {
return null;
}
List<ComplianceFeature> complianceFeatures = (List<ComplianceFeature>) o;
log.info("size of list: " + complianceFeatures.size());
complianceData.setComplianceFeatures(complianceFeatures);
for (ComplianceFeature cf : complianceFeatures) {
if(!cf.isCompliance()){
complianceData.setStatus(false);
break;
}
}
return complianceData;
}
@Override
public String getType() {

@ -22,14 +22,11 @@ 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.MobileDeviceManagementDAOFactory;
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.dao.AndroidDAOFactory;
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;
@ -47,12 +44,11 @@ public class AndroidDeviceDAOImpl implements MobileDeviceDAO{
private static final Log log = LogFactory.getLog(AndroidDeviceDAOImpl.class);
@Override
public MobileDevice getMobileDevice(String mblDeviceId)
throws MobileDeviceManagementDAOException {
Connection conn = null;
public MobileDevice getMobileDevice(String mblDeviceId) throws MobileDeviceManagementDAOException {
Connection conn;
PreparedStatement stmt = null;
MobileDevice mobileDevice = null;
ResultSet resultSet = null;
ResultSet rs = null;
try {
conn = AndroidDAOFactory.getConnection();
String selectDBQuery =
@ -61,29 +57,25 @@ public class AndroidDeviceDAOImpl implements MobileDeviceDAO{
" FROM AD_DEVICE WHERE ANDROID_DEVICE_ID = ?";
stmt = conn.prepareStatement(selectDBQuery);
stmt.setString(1, mblDeviceId);
resultSet = stmt.executeQuery();
rs = stmt.executeQuery();
if (resultSet.next()) {
if (rs.next()) {
mobileDevice = new MobileDevice();
mobileDevice.setMobileDeviceId(resultSet.getString(AndroidPluginConstants.
mobileDevice.setMobileDeviceId(rs.getString(AndroidPluginConstants.
ANDROID_DEVICE_ID));
mobileDevice.setModel(resultSet.getString(AndroidPluginConstants.DEVICE_MODEL));
mobileDevice.setSerial(resultSet.getString(AndroidPluginConstants.SERIAL));
mobileDevice.setVendor(resultSet.getString(AndroidPluginConstants.VENDOR));
mobileDevice.setLatitude(resultSet.getString(AndroidPluginConstants.LATITUDE));
mobileDevice.setLongitude(resultSet.getString(AndroidPluginConstants.LONGITUDE));
mobileDevice.setImei(resultSet.getString(AndroidPluginConstants.IMEI));
mobileDevice.setImsi(resultSet.getString(AndroidPluginConstants.IMSI));
mobileDevice.setOsVersion(resultSet.getString(AndroidPluginConstants.OS_VERSION));
mobileDevice.setModel(rs.getString(AndroidPluginConstants.DEVICE_MODEL));
mobileDevice.setSerial(rs.getString(AndroidPluginConstants.SERIAL));
mobileDevice.setVendor(rs.getString(AndroidPluginConstants.VENDOR));
mobileDevice.setLatitude(rs.getString(AndroidPluginConstants.LATITUDE));
mobileDevice.setLongitude(rs.getString(AndroidPluginConstants.LONGITUDE));
mobileDevice.setImei(rs.getString(AndroidPluginConstants.IMEI));
mobileDevice.setImsi(rs.getString(AndroidPluginConstants.IMSI));
mobileDevice.setOsVersion(rs.getString(AndroidPluginConstants.OS_VERSION));
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.DEVICE_NAME,
resultSet.getString(AndroidPluginConstants.DEVICE_NAME));
propertyMap.put(AndroidPluginConstants.GCM_TOKEN, rs.getString(AndroidPluginConstants.GCM_TOKEN));
propertyMap.put(AndroidPluginConstants.DEVICE_INFO, rs.getString(AndroidPluginConstants.DEVICE_INFO));
propertyMap.put(AndroidPluginConstants.DEVICE_NAME, rs.getString(AndroidPluginConstants.DEVICE_NAME));
mobileDevice.setDeviceProperties(propertyMap);
if (log.isDebugEnabled()) {
@ -96,7 +88,7 @@ public class AndroidDeviceDAOImpl implements MobileDeviceDAO{
log.error(msg, e);
throw new MobileDeviceManagementDAOException(msg, e);
} finally {
MobileDeviceManagementDAOUtil.cleanupResources(stmt, resultSet);
MobileDeviceManagementDAOUtil.cleanupResources(stmt, rs);
AndroidDAOFactory.closeConnection();
}
@ -104,10 +96,9 @@ public class AndroidDeviceDAOImpl implements MobileDeviceDAO{
}
@Override
public boolean addMobileDevice(MobileDevice mobileDevice)
throws MobileDeviceManagementDAOException {
public boolean addMobileDevice(MobileDevice mobileDevice) throws MobileDeviceManagementDAOException {
boolean status = false;
Connection conn = null;
Connection conn;
PreparedStatement stmt = null;
try {
conn = AndroidDAOFactory.getConnection();
@ -119,19 +110,13 @@ public class AndroidDeviceDAOImpl implements MobileDeviceDAO{
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));
Map<String, String> properties = mobileDevice.getDeviceProperties();
stmt.setString(2, properties.get(AndroidPluginConstants.GCM_TOKEN));
stmt.setString(3, properties.get(AndroidPluginConstants.DEVICE_INFO));
stmt.setString(4, mobileDevice.getSerial());
stmt.setString(5, mobileDevice.getVendor());
stmt.setString(6, mobileDevice.getMobileDeviceId());
stmt.setString(7, AndroidUtils.getDeviceProperty(mobileDevice.getDeviceProperties(),
AndroidPluginConstants.DEVICE_NAME));
stmt.setString(7, properties.get(AndroidPluginConstants.DEVICE_NAME));
stmt.setString(8, mobileDevice.getLongitude());
stmt.setString(9, mobileDevice.getLongitude());
stmt.setString(10, mobileDevice.getImei());
@ -147,10 +132,8 @@ public class AndroidDeviceDAOImpl implements MobileDeviceDAO{
}
}
} 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);
throw new MobileDeviceManagementDAOException("Error occurred while adding the Android device '" +
mobileDevice.getMobileDeviceId() + "' information to the Android plugin data store.", e);
} finally {
MobileDeviceManagementDAOUtil.cleanupResources(stmt, null);
}
@ -158,10 +141,9 @@ public class AndroidDeviceDAOImpl implements MobileDeviceDAO{
}
@Override
public boolean updateMobileDevice(MobileDevice mobileDevice)
throws MobileDeviceManagementDAOException {
public boolean updateMobileDevice(MobileDevice mobileDevice) throws MobileDeviceManagementDAOException {
boolean status = false;
Connection conn = null;
Connection conn;
PreparedStatement stmt = null;
try {
conn = AndroidDAOFactory.getConnection();
@ -169,23 +151,15 @@ public class AndroidDeviceDAOImpl implements MobileDeviceDAO{
"UPDATE AD_DEVICE SET GCM_TOKEN = ?, DEVICE_INFO = ?, SERIAL = ?, VENDOR = ?, " +
"MAC_ADDRESS = ?, DEVICE_NAME = ?, LATITUDE = ?, LONGITUDE = ?, IMEI = ?, " +
"IMSI = ?, OS_VERSION = ?, DEVICE_MODEL = ? WHERE ANDROID_DEVICE_ID = ?";
stmt = conn.prepareStatement(updateDBQuery);
if (mobileDevice.getDeviceProperties() == null) {
mobileDevice.setDeviceProperties(new HashMap<String, String>());
}
stmt.setString(1, AndroidUtils.getDeviceProperty(
mobileDevice.getDeviceProperties(),
AndroidPluginConstants.GCM_TOKEN));
stmt.setString(2, AndroidUtils.getDeviceProperty(mobileDevice.getDeviceProperties(),
AndroidPluginConstants.DEVICE_INFO));
Map<String, String> properties = mobileDevice.getDeviceProperties();
stmt.setString(1, properties.get(AndroidPluginConstants.GCM_TOKEN));
stmt.setString(2, properties.get(AndroidPluginConstants.DEVICE_INFO));
stmt.setString(3, mobileDevice.getSerial());
stmt.setString(4, mobileDevice.getVendor());
stmt.setString(5, mobileDevice.getMobileDeviceId());
stmt.setString(6, AndroidUtils.getDeviceProperty(mobileDevice.getDeviceProperties(),
AndroidPluginConstants.DEVICE_NAME));
stmt.setString(6, properties.get(AndroidPluginConstants.DEVICE_NAME));
stmt.setString(7, mobileDevice.getLatitude());
stmt.setString(8, mobileDevice.getLongitude());
stmt.setString(9, mobileDevice.getImei());
@ -216,7 +190,7 @@ public class AndroidDeviceDAOImpl implements MobileDeviceDAO{
public boolean deleteMobileDevice(String mblDeviceId)
throws MobileDeviceManagementDAOException {
boolean status = false;
Connection conn = null;
Connection conn;
PreparedStatement stmt = null;
try {
conn = AndroidDAOFactory.getConnection();
@ -233,9 +207,8 @@ public class AndroidDeviceDAOImpl implements MobileDeviceDAO{
}
}
} catch (SQLException e) {
String msg = "Error occurred while deleting android device " + mblDeviceId;
log.error(msg, e);
throw new MobileDeviceManagementDAOException(msg, e);
throw new MobileDeviceManagementDAOException("Error occurred while deleting android device '" +
mblDeviceId + "'", e);
} finally {
MobileDeviceManagementDAOUtil.cleanupResources(stmt, null);
}
@ -243,15 +216,12 @@ public class AndroidDeviceDAOImpl implements MobileDeviceDAO{
}
@Override
public List<MobileDevice> getAllMobileDevices()
throws MobileDeviceManagementDAOException {
Connection conn = null;
public List<MobileDevice> getAllMobileDevices() throws MobileDeviceManagementDAOException {
Connection conn;
PreparedStatement stmt = null;
ResultSet resultSet = null;
ResultSet rs = null;
MobileDevice mobileDevice;
List<MobileDevice> mobileDevices = new ArrayList<MobileDevice>();
try {
conn = AndroidDAOFactory.getConnection();
String selectDBQuery =
@ -259,29 +229,27 @@ public class AndroidDeviceDAOImpl implements MobileDeviceDAO{
"VENDOR, MAC_ADDRESS, DEVICE_NAME, LATITUDE, LONGITUDE, IMEI, IMSI, OS_VERSION " +
"FROM AD_DEVICE";
stmt = conn.prepareStatement(selectDBQuery);
resultSet = stmt.executeQuery();
while (resultSet.next()) {
rs = stmt.executeQuery();
while (rs.next()) {
mobileDevice = new MobileDevice();
mobileDevice.setMobileDeviceId(resultSet.getString(AndroidPluginConstants.
mobileDevice.setMobileDeviceId(rs.getString(AndroidPluginConstants.
ANDROID_DEVICE_ID));
mobileDevice.setModel(resultSet.getString(AndroidPluginConstants.DEVICE_MODEL));
mobileDevice.setSerial(resultSet.getString(AndroidPluginConstants.SERIAL));
mobileDevice.setVendor(resultSet.getString(AndroidPluginConstants.VENDOR));
mobileDevice.setLatitude(resultSet.getString(AndroidPluginConstants.LATITUDE));
mobileDevice.setLongitude(resultSet.getString(AndroidPluginConstants.LONGITUDE));
mobileDevice.setImei(resultSet.getString(AndroidPluginConstants.IMEI));
mobileDevice.setImsi(resultSet.getString(AndroidPluginConstants.IMSI));
mobileDevice.setOsVersion(resultSet.getString(AndroidPluginConstants.OS_VERSION));
mobileDevice.setModel(rs.getString(AndroidPluginConstants.DEVICE_MODEL));
mobileDevice.setSerial(rs.getString(AndroidPluginConstants.SERIAL));
mobileDevice.setVendor(rs.getString(AndroidPluginConstants.VENDOR));
mobileDevice.setLatitude(rs.getString(AndroidPluginConstants.LATITUDE));
mobileDevice.setLongitude(rs.getString(AndroidPluginConstants.LONGITUDE));
mobileDevice.setImei(rs.getString(AndroidPluginConstants.IMEI));
mobileDevice.setImsi(rs.getString(AndroidPluginConstants.IMSI));
mobileDevice.setOsVersion(rs.getString(AndroidPluginConstants.OS_VERSION));
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.DEVICE_NAME,
resultSet.getString(AndroidPluginConstants.DEVICE_NAME));
propertyMap.put(AndroidPluginConstants.GCM_TOKEN, rs.getString(AndroidPluginConstants.GCM_TOKEN));
propertyMap.put(AndroidPluginConstants.DEVICE_INFO, rs.getString(AndroidPluginConstants.DEVICE_INFO));
propertyMap.put(AndroidPluginConstants.DEVICE_NAME, rs.getString(AndroidPluginConstants.DEVICE_NAME));
mobileDevice.setDeviceProperties(propertyMap);
mobileDevices.add(mobileDevice);
}
if (log.isDebugEnabled()) {
@ -289,11 +257,9 @@ public class AndroidDeviceDAOImpl implements MobileDeviceDAO{
}
return mobileDevices;
} catch (SQLException e) {
String msg = "Error occurred while fetching all Android device data'";
log.error(msg, e);
throw new MobileDeviceManagementDAOException(msg, e);
throw new MobileDeviceManagementDAOException("Error occurred while fetching all Android device data", e);
} finally {
MobileDeviceManagementDAOUtil.cleanupResources(stmt, resultSet);
MobileDeviceManagementDAOUtil.cleanupResources(stmt, rs);
AndroidDAOFactory.closeConnection();
}
}

@ -0,0 +1,58 @@
/*
* 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 org.wso2.carbon.device.mgt.common.license.mgt.License;
import org.wso2.carbon.device.mgt.mobile.impl.android.AndroidDeviceManagementService;
/**
* Contains utility methods used by Android plugin.
*/
public class AndroidPluginUtils {
public static License getDefaultLicense() {
License license = new License();
license.setName(AndroidDeviceManagementService.DEVICE_TYPE_ANDROID);
license.setLanguage("en_US");
license.setVersion("1.0.0");
license.setText("This End User License Agreement (“Agreement”) is a legal agreement between you (“You”) " +
"and WSO2, Inc., regarding the enrollment of Your personal mobile device (“Device”) in SoRs " +
"mobile device management program, and the loading to and removal from Your Device and Your use " +
"of certain applications and any associated software and user documentation, whether provided in " +
"“online” or electronic format, used in connection with the operation of or provision of services " +
"to WSO2, Inc., BY SELECTING “I ACCEPT” DURING INSTALLATION, YOU ARE ENROLLING YOUR DEVICE, AND " +
"THEREBY AUTHORIZING SOR OR ITS AGENTS TO INSTALL, UPDATE AND REMOVE THE APPS FROM YOUR DEVICE AS " +
"DESCRIBED IN THIS AGREEMENT. YOU ARE ALSO EXPLICITLY ACKNOWLEDGING AND AGREEING THAT (1) THIS IS " +
"A BINDING CONTRACT AND (2) YOU HAVE READ AND AGREE TO THE TERMS OF THIS AGREEMENT.\n" +
"\n" +
"IF YOU DO NOT ACCEPT THESE TERMS, DO NOT ENROLL YOUR DEVICE AND DO NOT PROCEED ANY FURTHER.\n" +
"\n" +
"You agree that: (1) You understand and agree to be bound by the terms and conditions contained " +
"in this Agreement, and (2) You are at least 21 years old and have the legal capacity to enter " +
"into this Agreement as defined by the laws of Your jurisdiction. SoR shall have the right, " +
"without prior notice, to terminate or suspend (i) this Agreement, (ii) the enrollment of Your " +
"Device, or (iii) the functioning of the Apps in the event of a violation of this Agreement or " +
"the cessation of Your relationship with SoR (including termination of Your employment if You are " +
"an employee or expiration or termination of Your applicable franchise or supply agreement if You " +
"are a franchisee of or supplier to the WSO2 WSO2, Inc., system). SoR expressly reserves all " +
"rights not expressly granted herein.");
return license;
}
}

@ -25,7 +25,7 @@ import org.wso2.carbon.device.mgt.common.configuration.mgt.TenantConfiguration;
import org.wso2.carbon.device.mgt.common.license.mgt.License;
import org.wso2.carbon.device.mgt.common.license.mgt.LicenseManagementException;
import org.wso2.carbon.device.mgt.common.license.mgt.LicenseManager;
import org.wso2.carbon.device.mgt.extensions.license.mgt.RegistryBasedLicenseManager;
import org.wso2.carbon.device.mgt.extensions.license.mgt.registry.RegistryBasedLicenseManager;
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.dto.MobileDevice;

Loading…
Cancel
Save