Refractor Plugin DAO factories

revert-dabc3590
manoj 10 years ago
parent c75a32a36e
commit fe72fc5b97

@ -20,14 +20,16 @@ package org.wso2.carbon.device.mgt.mobile.dao;
import org.apache.commons.logging.Log; import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory; import org.apache.commons.logging.LogFactory;
import org.wso2.carbon.device.mgt.common.DeviceManagementException;
import org.wso2.carbon.device.mgt.mobile.DataSourceNotAvailableException; import org.wso2.carbon.device.mgt.mobile.DataSourceNotAvailableException;
import org.wso2.carbon.device.mgt.mobile.common.MobileDeviceMgtPluginException;
import org.wso2.carbon.device.mgt.mobile.config.datasource.JNDILookupDefinition; import org.wso2.carbon.device.mgt.mobile.config.datasource.JNDILookupDefinition;
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.impl.*;
import org.wso2.carbon.device.mgt.mobile.dao.util.MobileDeviceManagementDAOUtil; import org.wso2.carbon.device.mgt.mobile.dao.util.MobileDeviceManagementDAOUtil;
import org.wso2.carbon.device.mgt.mobile.impl.ios.dao.FeatureManagementDAOException;
import javax.sql.DataSource; import javax.sql.DataSource;
import java.sql.Connection;
import java.sql.SQLException;
import java.util.HashMap; import java.util.HashMap;
import java.util.Hashtable; import java.util.Hashtable;
import java.util.List; import java.util.List;
@ -36,21 +38,16 @@ import java.util.Map;
/** /**
* Factory class used to create MobileDeviceManagement related DAO objects. * Factory class used to create MobileDeviceManagement related DAO objects.
*/ */
public class MobileDeviceManagementDAOFactory { public abstract class MobileDeviceManagementDAOFactory implements MobileDeviceManagementDAOFactoryInterface {
private static final Log log = LogFactory.getLog(MobileDeviceManagementDAOFactory.class); private static final Log log = LogFactory.getLog(MobileDeviceManagementDAOFactory.class);
private static Map<String, MobileDataSourceConfig> mobileDataSourceConfigMap; private static Map<String, MobileDataSourceConfig> mobileDataSourceConfigMap;
private static Map<String, DataSource> dataSourceMap; private static Map<String, DataSource> dataSourceMap;
private String pluginProvider;
private DataSource dataSource;
private static boolean isInitialized; private static boolean isInitialized;
private static ThreadLocal<Connection> currentConnection = new ThreadLocal<Connection>();
protected static DataSource dataSource;
public MobileDeviceManagementDAOFactory(String pluginProvider) { public static void init() throws MobileDeviceMgtPluginException {
this.pluginProvider = pluginProvider;
this.dataSource = dataSourceMap.get(pluginProvider);
}
public static void init() throws DeviceManagementException {
dataSourceMap = new HashMap<String, DataSource>(); dataSourceMap = new HashMap<String, DataSource>();
DataSource dataSource; DataSource dataSource;
@ -68,8 +65,7 @@ public class MobileDeviceManagementDAOFactory {
* @param config Mobile data source configuration * @param config Mobile data source configuration
* @return data source resolved from the data source definition * @return data source resolved from the data source definition
*/ */
private static DataSource resolveDataSource(MobileDataSourceConfig config) protected static DataSource resolveDataSource(MobileDataSourceConfig config) {
throws DeviceManagementException {
DataSource dataSource = null; DataSource dataSource = null;
if (config == null) { if (config == null) {
throw new RuntimeException("Device Management Repository data source configuration " + throw new RuntimeException("Device Management Repository data source configuration " +
@ -99,34 +95,6 @@ public class MobileDeviceManagementDAOFactory {
return dataSource; return dataSource;
} }
public MobileDeviceDAO getMobileDeviceDAO() {
return new MobileDeviceDAOImpl(dataSource);
}
public MobileOperationDAO getMobileOperationDAO() {
return new MobileOperationDAOImpl(dataSource);
}
public MobileOperationPropertyDAO getMobileOperationPropertyDAO() {
return new MobileOperationPropertyDAOImpl(dataSource);
}
public MobileDeviceOperationMappingDAO getMobileDeviceOperationDAO() {
return new MobileDeviceOperationMappingDAOImpl(dataSource);
}
public MobileFeatureDAO getFeatureDAO() {
return new MobileFeatureDAOImpl(dataSource);
}
public MobileFeaturePropertyDAO getFeaturePropertyDAO() {
return new MobileFeaturePropertyDAOImpl(dataSource);
}
public MobileDataSourceConfig getMobileDeviceManagementConfig(String pluginType) {
return mobileDataSourceConfigMap.get(pluginType);
}
public static Map<String, MobileDataSourceConfig> getMobileDataSourceConfigMap() { public static Map<String, MobileDataSourceConfig> getMobileDataSourceConfigMap() {
return mobileDataSourceConfigMap; return mobileDataSourceConfigMap;
} }
@ -135,14 +103,10 @@ public class MobileDeviceManagementDAOFactory {
MobileDeviceManagementDAOFactory.mobileDataSourceConfigMap = mobileDataSourceConfigMap; MobileDeviceManagementDAOFactory.mobileDataSourceConfigMap = mobileDataSourceConfigMap;
} }
public DataSource getDataSource(String type) { public static DataSource getDataSource(String type) {
return dataSourceMap.get(type); return dataSourceMap.get(type);
} }
public DataSource getDataSource() {
return dataSource;
}
public static Map<String, DataSource> getDataSourceMap() { public static Map<String, DataSource> getDataSourceMap() {
return dataSourceMap; return dataSourceMap;
} }
@ -153,4 +117,51 @@ public class MobileDeviceManagementDAOFactory {
"is not initialized"); "is not initialized");
} }
} }
public static void beginTransaction() throws MobileDeviceManagementDAOException {
try {
Connection conn = dataSource.getConnection();
conn.setAutoCommit(false);
currentConnection.set(conn);
} catch (SQLException e) {
throw new MobileDeviceManagementDAOException("Error occurred while retrieving datasource connection", e);
}
}
public static Connection getConnection() {
return currentConnection.get();
}
public static void commitTransaction() throws MobileDeviceManagementDAOException {
try {
Connection conn = currentConnection.get();
if (conn != null) {
conn.commit();
} else {
if (log.isDebugEnabled()) {
log.debug("Datasource connection associated with the current thread is null, hence commit " +
"has not been attempted");
}
}
} catch (SQLException e) {
throw new MobileDeviceManagementDAOException("Error occurred while committing the transaction", e);
}
}
public static void rollbackTransaction() throws MobileDeviceManagementDAOException {
try {
Connection conn = currentConnection.get();
if (conn != null) {
conn.rollback();
} else {
if (log.isDebugEnabled()) {
log.debug("Datasource connection associated with the current thread is null, hence rollback " +
"has not been attempted");
}
}
} catch (SQLException e) {
throw new MobileDeviceManagementDAOException("Error occurred while rollbacking the transaction", e);
}
}
} }

@ -35,7 +35,7 @@ public interface MobileFeatureDAO {
* @return The id of inserted MobileFeature. * @return The id of inserted MobileFeature.
* @throws MobileDeviceManagementDAOException * @throws MobileDeviceManagementDAOException
*/ */
int addMobileFeature(MobileFeature mobileFeature) throws MobileDeviceManagementDAOException; boolean addFeature(MobileFeature mobileFeature) throws MobileDeviceManagementDAOException;
/** /**
* Updates a MobileFeature in Mobile-Feature table. * Updates a MobileFeature in Mobile-Feature table.
@ -44,7 +44,7 @@ public interface MobileFeatureDAO {
* @return The status of the operation. * @return The status of the operation.
* @throws MobileDeviceManagementDAOException * @throws MobileDeviceManagementDAOException
*/ */
boolean updateMobileFeature(MobileFeature mobileFeature) throws MobileDeviceManagementDAOException; boolean updateFeature(MobileFeature mobileFeature) throws MobileDeviceManagementDAOException;
/** /**
* Deletes a MobileFeature from Mobile-Feature table when the feature id is given. * Deletes a MobileFeature from Mobile-Feature table when the feature id is given.
@ -53,7 +53,7 @@ public interface MobileFeatureDAO {
* @return The status of the operation. * @return The status of the operation.
* @throws MobileDeviceManagementDAOException * @throws MobileDeviceManagementDAOException
*/ */
boolean deleteMobileFeatureById(int mblFeatureId) throws MobileDeviceManagementDAOException; boolean deleteFeatureById(int mblFeatureId) throws MobileDeviceManagementDAOException;
/** /**
* Deletes a MobileFeature from Mobile-Feature table when the feature code is given. * Deletes a MobileFeature from Mobile-Feature table when the feature code is given.
@ -62,7 +62,7 @@ public interface MobileFeatureDAO {
* @return The status of the operation. * @return The status of the operation.
* @throws MobileDeviceManagementDAOException * @throws MobileDeviceManagementDAOException
*/ */
boolean deleteMobileFeatureByCode(String mblFeatureCode) throws MobileDeviceManagementDAOException; boolean deleteFeatureByCode(String mblFeatureCode) throws MobileDeviceManagementDAOException;
/** /**
* Retrieves a given MobileFeature from Mobile-Feature table when the feature id is given. * Retrieves a given MobileFeature from Mobile-Feature table when the feature id is given.
@ -71,7 +71,7 @@ public interface MobileFeatureDAO {
* @return MobileFeature object that holds data of the feature represented by featureId. * @return MobileFeature object that holds data of the feature represented by featureId.
* @throws MobileDeviceManagementDAOException * @throws MobileDeviceManagementDAOException
*/ */
MobileFeature getMobileFeatureById(int mblFeatureId) throws MobileDeviceManagementDAOException; MobileFeature getFeatureById(int mblFeatureId) throws MobileDeviceManagementDAOException;
/** /**
* Retrieves a given MobileFeature from Mobile-Feature table when the feature code is given. * Retrieves a given MobileFeature from Mobile-Feature table when the feature code is given.
@ -80,7 +80,7 @@ public interface MobileFeatureDAO {
* @return MobileFeature object that holds data of the feature represented by featureCode. * @return MobileFeature object that holds data of the feature represented by featureCode.
* @throws MobileDeviceManagementDAOException * @throws MobileDeviceManagementDAOException
*/ */
MobileFeature getMobileFeatureByCode(String mblFeatureCode) throws MobileDeviceManagementDAOException; MobileFeature getFeatureByCode(String mblFeatureCode) throws MobileDeviceManagementDAOException;
/** /**
* Retrieves all MobileFeatures of a MobileDevice type from Mobile-Feature table. * Retrieves all MobileFeatures of a MobileDevice type from Mobile-Feature table.
@ -89,7 +89,7 @@ public interface MobileFeatureDAO {
* @return MobileFeature object list. * @return MobileFeature object list.
* @throws MobileDeviceManagementDAOException * @throws MobileDeviceManagementDAOException
*/ */
List<MobileFeature> getMobileFeatureByDeviceType(String deviceType) throws MobileDeviceManagementDAOException; List<MobileFeature> getFeatureByDeviceType(String deviceType) throws MobileDeviceManagementDAOException;
/** /**
* Retrieve all the MobileFeatures from Mobile-Feature table. * Retrieve all the MobileFeatures from Mobile-Feature table.
@ -97,5 +97,5 @@ public interface MobileFeatureDAO {
* @return MobileFeature object list. * @return MobileFeature object list.
* @throws MobileDeviceManagementDAOException * @throws MobileDeviceManagementDAOException
*/ */
List<MobileFeature> getAllMobileFeatures() throws MobileDeviceManagementDAOException; List<MobileFeature> getAllFeatures() throws MobileDeviceManagementDAOException;
} }

@ -46,9 +46,9 @@ public class MobileFeatureDAOImpl implements MobileFeatureDAO {
} }
@Override @Override
public int addMobileFeature(MobileFeature mobileFeature) public boolean addFeature(MobileFeature mobileFeature)
throws MobileDeviceManagementDAOException { throws MobileDeviceManagementDAOException {
int status = 0; boolean status = false;
Connection conn = null; Connection conn = null;
PreparedStatement stmt = null; PreparedStatement stmt = null;
try { try {
@ -63,15 +63,13 @@ public class MobileFeatureDAOImpl implements MobileFeatureDAO {
stmt.setString(4, mobileFeature.getDeviceType()); stmt.setString(4, mobileFeature.getDeviceType());
int rows = stmt.executeUpdate(); int rows = stmt.executeUpdate();
if (rows > 0) { if (rows > 0) {
ResultSet rs = stmt.getGeneratedKeys();
if (rs != null && rs.next()) {
status = rs.getInt(1);
}
if (log.isDebugEnabled()) { if (log.isDebugEnabled()) {
log.debug("Added a new MobileFeature " + mobileFeature.getCode() + " to the" + log.debug("Added a new MobileFeature " + mobileFeature.getCode() + " to the" +
" MDM database."); " MDM database.");
} }
status = true;
} }
} catch (SQLException e) { } catch (SQLException e) {
String msg = "Error occurred while adding feature code - '" + String msg = "Error occurred while adding feature code - '" +
mobileFeature.getCode() + "' to feature table"; mobileFeature.getCode() + "' to feature table";
@ -84,7 +82,7 @@ public class MobileFeatureDAOImpl implements MobileFeatureDAO {
} }
@Override @Override
public boolean updateMobileFeature(MobileFeature mobileFeature) public boolean updateFeature(MobileFeature mobileFeature)
throws MobileDeviceManagementDAOException { throws MobileDeviceManagementDAOException {
boolean status = false; boolean status = false;
Connection conn = null; Connection conn = null;
@ -119,7 +117,7 @@ public class MobileFeatureDAOImpl implements MobileFeatureDAO {
} }
@Override @Override
public boolean deleteMobileFeatureByCode(String mblFeatureCode) public boolean deleteFeatureByCode(String mblFeatureCode)
throws MobileDeviceManagementDAOException { throws MobileDeviceManagementDAOException {
boolean status = false; boolean status = false;
Connection conn = null; Connection conn = null;
@ -149,7 +147,7 @@ public class MobileFeatureDAOImpl implements MobileFeatureDAO {
} }
@Override @Override
public boolean deleteMobileFeatureById(int mblFeatureId) public boolean deleteFeatureById(int mblFeatureId)
throws MobileDeviceManagementDAOException { throws MobileDeviceManagementDAOException {
boolean status = false; boolean status = false;
Connection conn = null; Connection conn = null;
@ -179,7 +177,7 @@ public class MobileFeatureDAOImpl implements MobileFeatureDAO {
} }
@Override @Override
public MobileFeature getMobileFeatureByCode(String mblFeatureCode) public MobileFeature getFeatureByCode(String mblFeatureCode)
throws MobileDeviceManagementDAOException { throws MobileDeviceManagementDAOException {
Connection conn = null; Connection conn = null;
PreparedStatement stmt = null; PreparedStatement stmt = null;
@ -216,7 +214,7 @@ public class MobileFeatureDAOImpl implements MobileFeatureDAO {
} }
@Override @Override
public MobileFeature getMobileFeatureById(int mblFeatureId) public MobileFeature getFeatureById(int mblFeatureId)
throws MobileDeviceManagementDAOException { throws MobileDeviceManagementDAOException {
Connection conn = null; Connection conn = null;
PreparedStatement stmt = null; PreparedStatement stmt = null;
@ -253,7 +251,7 @@ public class MobileFeatureDAOImpl implements MobileFeatureDAO {
} }
@Override @Override
public List<MobileFeature> getAllMobileFeatures() throws MobileDeviceManagementDAOException { public List<MobileFeature> getAllFeatures() throws MobileDeviceManagementDAOException {
Connection conn = null; Connection conn = null;
PreparedStatement stmt = null; PreparedStatement stmt = null;
MobileFeature mobileFeature; MobileFeature mobileFeature;
@ -287,7 +285,7 @@ public class MobileFeatureDAOImpl implements MobileFeatureDAO {
} }
@Override @Override
public List<MobileFeature> getMobileFeatureByDeviceType(String deviceType) throws public List<MobileFeature> getFeatureByDeviceType(String deviceType) throws
MobileDeviceManagementDAOException { MobileDeviceManagementDAOException {
Connection conn = null; Connection conn = null;
PreparedStatement stmt = null; PreparedStatement stmt = null;

@ -25,7 +25,7 @@ import org.wso2.carbon.device.mgt.common.spi.DeviceManager;
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.dto.MobileDevice; import org.wso2.carbon.device.mgt.mobile.dto.MobileDevice;
import org.wso2.carbon.device.mgt.mobile.impl.android.dao.FeatureManagementDAOFactory; import org.wso2.carbon.device.mgt.mobile.impl.android.dao.AndroidDAOFactory;
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;
@ -36,180 +36,177 @@ import java.util.List;
*/ */
public class AndroidDeviceManager implements DeviceManager { public class AndroidDeviceManager implements DeviceManager {
private MobileDeviceManagementDAOFactory mobileDeviceManagementDAOFactory; private MobileDeviceManagementDAOFactory mobileDeviceManagementDAOFactory;
private static final Log log = LogFactory.getLog(AndroidDeviceManager.class); private static final Log log = LogFactory.getLog(AndroidDeviceManager.class);
public AndroidDeviceManager() { public AndroidDeviceManager() {
mobileDeviceManagementDAOFactory = new MobileDeviceManagementDAOFactory( mobileDeviceManagementDAOFactory = new AndroidDAOFactory();
DeviceManagementConstants.MobileDeviceTypes.MOBILE_DEVICE_TYPE_ANDROID); }
FeatureManagementDAOFactory
.init(mobileDeviceManagementDAOFactory.getDataSource(this.getProviderType())); @Override
} public String getProviderType() {
return DeviceManagementConstants.MobileDeviceTypes.MOBILE_DEVICE_TYPE_ANDROID;
@Override }
public String getProviderType() {
return DeviceManagementConstants.MobileDeviceTypes.MOBILE_DEVICE_TYPE_ANDROID; @Override
} public FeatureManager getFeatureManager() {
return new AndroidFeatureManager();
@Override }
public FeatureManager getFeatureManager() {
return new AndroidFeatureManager(); @Override
} public boolean enrollDevice(Device device) throws DeviceManagementException {
boolean status;
@Override MobileDevice mobileDevice = MobileDeviceManagementUtil.convertToMobileDevice(device);
public boolean enrollDevice(Device device) throws DeviceManagementException { try {
boolean status; if (log.isDebugEnabled()) {
MobileDevice mobileDevice = MobileDeviceManagementUtil.convertToMobileDevice(device); log.debug("Enrolling a new Android device : " + device.getDeviceIdentifier());
try { }
if (log.isDebugEnabled()) { status = mobileDeviceManagementDAOFactory.getMobileDeviceDAO().addMobileDevice(
log.debug("Enrolling a new Android device : " + device.getDeviceIdentifier()); mobileDevice);
} } catch (MobileDeviceManagementDAOException e) {
status = mobileDeviceManagementDAOFactory.getMobileDeviceDAO().addMobileDevice( String msg = "Error while enrolling the Android device : " +
mobileDevice); device.getDeviceIdentifier();
} catch (MobileDeviceManagementDAOException e) { log.error(msg, e);
String msg = "Error while enrolling the Android device : " + throw new DeviceManagementException(msg, e);
device.getDeviceIdentifier(); }
log.error(msg, e); return status;
throw new DeviceManagementException(msg, e); }
}
return status; @Override
} public boolean modifyEnrollment(Device device) throws DeviceManagementException {
boolean status;
@Override MobileDevice mobileDevice = MobileDeviceManagementUtil.convertToMobileDevice(device);
public boolean modifyEnrollment(Device device) throws DeviceManagementException { try {
boolean status; if (log.isDebugEnabled()) {
MobileDevice mobileDevice = MobileDeviceManagementUtil.convertToMobileDevice(device); log.debug("Modifying the Android device enrollment data");
try { }
if (log.isDebugEnabled()) { status = mobileDeviceManagementDAOFactory.getMobileDeviceDAO()
log.debug("Modifying the Android device enrollment data"); .updateMobileDevice(mobileDevice);
} } catch (MobileDeviceManagementDAOException e) {
status = mobileDeviceManagementDAOFactory.getMobileDeviceDAO() String msg = "Error while updating the enrollment of the Android device : " +
.updateMobileDevice(mobileDevice); device.getDeviceIdentifier();
} catch (MobileDeviceManagementDAOException e) { log.error(msg, e);
String msg = "Error while updating the enrollment of the Android device : " + throw new DeviceManagementException(msg, e);
device.getDeviceIdentifier(); }
log.error(msg, e); return status;
throw new DeviceManagementException(msg, e); }
}
return status; @Override
} public boolean disenrollDevice(DeviceIdentifier deviceId) throws DeviceManagementException {
boolean status;
@Override try {
public boolean disenrollDevice(DeviceIdentifier deviceId) throws DeviceManagementException { if (log.isDebugEnabled()) {
boolean status; log.debug("Dis-enrolling Android device : " + deviceId);
try { }
if (log.isDebugEnabled()) { status = mobileDeviceManagementDAOFactory.getMobileDeviceDAO()
log.debug("Dis-enrolling Android device : " + deviceId); .deleteMobileDevice(deviceId.getId());
} } catch (MobileDeviceManagementDAOException e) {
status = mobileDeviceManagementDAOFactory.getMobileDeviceDAO() String msg = "Error while removing the Android device : " + deviceId.getId();
.deleteMobileDevice(deviceId.getId()); log.error(msg, e);
} catch (MobileDeviceManagementDAOException e) { throw new DeviceManagementException(msg, e);
String msg = "Error while removing the Android device : " + deviceId.getId(); }
log.error(msg, e); return status;
throw new DeviceManagementException(msg, e); }
}
return status; @Override
} public boolean isEnrolled(DeviceIdentifier deviceId) throws DeviceManagementException {
boolean isEnrolled = false;
@Override try {
public boolean isEnrolled(DeviceIdentifier deviceId) throws DeviceManagementException { if (log.isDebugEnabled()) {
boolean isEnrolled = false; log.debug("Checking the enrollment of Android device : " + deviceId.getId());
try { }
if (log.isDebugEnabled()) { MobileDevice mobileDevice =
log.debug("Checking the enrollment of Android device : " + deviceId.getId()); mobileDeviceManagementDAOFactory.getMobileDeviceDAO().getMobileDevice(
} deviceId.getId());
MobileDevice mobileDevice = if (mobileDevice != null) {
mobileDeviceManagementDAOFactory.getMobileDeviceDAO().getMobileDevice( isEnrolled = true;
deviceId.getId()); }
if (mobileDevice != null) { } catch (MobileDeviceManagementDAOException e) {
isEnrolled = true; String msg = "Error while checking the enrollment status of Android device : " +
} deviceId.getId();
} catch (MobileDeviceManagementDAOException e) { log.error(msg, e);
String msg = "Error while checking the enrollment status of Android device : " + throw new DeviceManagementException(msg, e);
deviceId.getId(); }
log.error(msg, e); return isEnrolled;
throw new DeviceManagementException(msg, e); }
}
return isEnrolled; @Override
} public boolean isActive(DeviceIdentifier deviceId) throws DeviceManagementException {
return true;
@Override }
public boolean isActive(DeviceIdentifier deviceId) throws DeviceManagementException {
return true; @Override
} public boolean setActive(DeviceIdentifier deviceId, boolean status)
throws DeviceManagementException {
@Override return true;
public boolean setActive(DeviceIdentifier deviceId, boolean status) }
throws DeviceManagementException {
return true; @Override
} public Device getDevice(DeviceIdentifier deviceId) throws DeviceManagementException {
Device device;
@Override try {
public Device getDevice(DeviceIdentifier deviceId) throws DeviceManagementException { if (log.isDebugEnabled()) {
Device device; log.debug("Getting the details of Android device : " + deviceId.getId());
try { }
if (log.isDebugEnabled()) { MobileDevice mobileDevice = mobileDeviceManagementDAOFactory.getMobileDeviceDAO().
log.debug("Getting the details of Android device : " + deviceId.getId()); getMobileDevice(deviceId.getId());
} device = MobileDeviceManagementUtil.convertToDevice(mobileDevice);
MobileDevice mobileDevice = mobileDeviceManagementDAOFactory.getMobileDeviceDAO(). } catch (MobileDeviceManagementDAOException e) {
getMobileDevice(deviceId.getId()); String msg = "Error while fetching the Android device : " + deviceId.getId();
device = MobileDeviceManagementUtil.convertToDevice(mobileDevice); log.error(msg, e);
} catch (MobileDeviceManagementDAOException e) { throw new DeviceManagementException(msg, e);
String msg = "Error while fetching the Android device : " + deviceId.getId(); }
log.error(msg, e); return device;
throw new DeviceManagementException(msg, e); }
}
return device; @Override
} public boolean setOwnership(DeviceIdentifier deviceId, String ownershipType)
throws DeviceManagementException {
@Override return true;
public boolean setOwnership(DeviceIdentifier deviceId, String ownershipType) }
throws DeviceManagementException {
return true; @Override
} public boolean updateDeviceInfo(Device device) throws DeviceManagementException {
boolean status;
@Override MobileDevice mobileDevice = MobileDeviceManagementUtil.convertToMobileDevice(device);
public boolean updateDeviceInfo(Device device) throws DeviceManagementException { try {
boolean status; if (log.isDebugEnabled()) {
MobileDevice mobileDevice = MobileDeviceManagementUtil.convertToMobileDevice(device); log.debug(
try { "updating the details of Android device : " + device.getDeviceIdentifier());
if (log.isDebugEnabled()) { }
log.debug( status = mobileDeviceManagementDAOFactory.getMobileDeviceDAO()
"updating the details of Android device : " + device.getDeviceIdentifier()); .updateMobileDevice(mobileDevice);
} } catch (MobileDeviceManagementDAOException e) {
status = mobileDeviceManagementDAOFactory.getMobileDeviceDAO() String msg =
.updateMobileDevice(mobileDevice); "Error while updating the Android device : " + device.getDeviceIdentifier();
} catch (MobileDeviceManagementDAOException e) { log.error(msg, e);
String msg = throw new DeviceManagementException(msg, e);
"Error while updating the Android device : " + device.getDeviceIdentifier(); }
log.error(msg, e); return status;
throw new DeviceManagementException(msg, e); }
}
return status; @Override
} public List<Device> getAllDevices() throws DeviceManagementException {
List<Device> devices = null;
@Override try {
public List<Device> getAllDevices() throws DeviceManagementException { if (log.isDebugEnabled()) {
List<Device> devices = null; log.debug("Fetching the details of all Android devices");
try { }
if (log.isDebugEnabled()) { List<MobileDevice> mobileDevices =
log.debug("Fetching the details of all Android devices"); mobileDeviceManagementDAOFactory.getMobileDeviceDAO().
} getAllMobileDevices();
List<MobileDevice> mobileDevices = if (mobileDevices != null) {
mobileDeviceManagementDAOFactory.getMobileDeviceDAO(). devices = new ArrayList<Device>();
getAllMobileDevices(); for (MobileDevice mobileDevice : mobileDevices) {
if (mobileDevices != null) { devices.add(MobileDeviceManagementUtil.convertToDevice(mobileDevice));
devices = new ArrayList<Device>(); }
for (MobileDevice mobileDevice : mobileDevices) { }
devices.add(MobileDeviceManagementUtil.convertToDevice(mobileDevice)); } catch (MobileDeviceManagementDAOException e) {
} String msg = "Error while fetching all Android devices.";
} log.error(msg, e);
} catch (MobileDeviceManagementDAOException e) { throw new DeviceManagementException(msg, e);
String msg = "Error while fetching all Android devices."; }
log.error(msg, e); return devices;
throw new DeviceManagementException(msg, e); }
}
return devices;
}
} }

@ -22,34 +22,44 @@ import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory; 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.FeatureManagementException;
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.MobileDeviceManagementDAOFactory;
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.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.FeatureDAO;
import org.wso2.carbon.device.mgt.mobile.impl.android.dao.FeatureManagementDAOException; import org.wso2.carbon.device.mgt.mobile.impl.android.dao.FeatureManagementDAOException;
import org.wso2.carbon.device.mgt.mobile.impl.android.dao.FeatureManagementDAOFactory; import org.wso2.carbon.device.mgt.mobile.util.MobileDeviceManagementUtil;
import java.util.ArrayList;
import java.util.List; import java.util.List;
public class AndroidFeatureManager implements FeatureManager { public class AndroidFeatureManager implements FeatureManager {
private FeatureDAO featureDAO; private MobileFeatureDAO featureDAO;
private static final Log log = LogFactory.getLog(AndroidFeatureManager.class); private static final Log log = LogFactory.getLog(AndroidFeatureManager.class);
private MobileDeviceManagementDAOFactory mobileDeviceManagementDAOFactory;
public AndroidFeatureManager() { public AndroidFeatureManager() {
this.featureDAO = FeatureManagementDAOFactory.getFeatureDAO(); mobileDeviceManagementDAOFactory = new AndroidDAOFactory();
this.featureDAO = mobileDeviceManagementDAOFactory.getMobileFeatureDao();
} }
@Override @Override
public boolean addFeature(Feature feature) throws DeviceManagementException { public boolean addFeature(Feature feature) throws DeviceManagementException {
try { try {
FeatureManagementDAOFactory.beginTransaction(); mobileDeviceManagementDAOFactory.beginTransaction();
featureDAO.addFeature(feature); MobileFeature mobileFeature = MobileDeviceManagementUtil.convertToMobileFeature(feature);
FeatureManagementDAOFactory.commitTransaction(); featureDAO.addFeature(mobileFeature);
mobileDeviceManagementDAOFactory.commitTransaction();
return true; return true;
} catch (FeatureManagementDAOException e) { } catch (MobileDeviceManagementDAOException e) {
try { try {
FeatureManagementDAOFactory.rollbackTransaction(); mobileDeviceManagementDAOFactory.rollbackTransaction();
} catch (FeatureManagementDAOException e1) { } catch (MobileDeviceManagementDAOException e1) {
log.warn("Error occurred while roll-backing the transaction", e); log.warn("Error occurred while roll-backing the transaction", e);
} }
throw new DeviceManagementException("Error occurred while adding the feature", e); throw new DeviceManagementException("Error occurred while adding the feature", e);
@ -59,14 +69,13 @@ public class AndroidFeatureManager implements FeatureManager {
@Override @Override
public Feature getFeature(String name) throws DeviceManagementException { public Feature getFeature(String name) throws DeviceManagementException {
try { try {
FeatureManagementDAOFactory.beginTransaction(); MobileFeature mobileFeature = featureDAO.getFeatureByCode(name);
Feature feature = featureDAO.getFeature(name); Feature feature = MobileDeviceManagementUtil.convertToFeature(mobileFeature);
FeatureManagementDAOFactory.commitTransaction();
return feature; return feature;
} catch (FeatureManagementDAOException e) { } catch (MobileDeviceManagementDAOException e) {
try { try {
FeatureManagementDAOFactory.rollbackTransaction(); mobileDeviceManagementDAOFactory.rollbackTransaction();
} catch (FeatureManagementDAOException e1) { } catch (MobileDeviceManagementDAOException e1) {
log.warn("Error occurred while roll-backing the transaction", e); log.warn("Error occurred while roll-backing the transaction", e);
} }
throw new DeviceManagementException("Error occurred while retrieving the feature", e); throw new DeviceManagementException("Error occurred while retrieving the feature", e);
@ -75,15 +84,18 @@ public class AndroidFeatureManager implements FeatureManager {
@Override @Override
public List<Feature> getFeatures() throws DeviceManagementException { public List<Feature> getFeatures() throws DeviceManagementException {
List<Feature> featureList = new ArrayList<Feature>();
try { try {
FeatureManagementDAOFactory.beginTransaction(); List<MobileFeature> mobileFeatures = featureDAO.getAllFeatures();
List<Feature> features = featureDAO.getFeatures(); for (MobileFeature mobileFeature : mobileFeatures) {
FeatureManagementDAOFactory.commitTransaction(); featureList.add(MobileDeviceManagementUtil.convertToFeature(mobileFeature));
return features; }
} catch (FeatureManagementDAOException e) { return featureList;
} catch (MobileDeviceManagementDAOException e) {
try { try {
FeatureManagementDAOFactory.rollbackTransaction(); mobileDeviceManagementDAOFactory.rollbackTransaction();
} catch (FeatureManagementDAOException e1) { } catch (MobileDeviceManagementDAOException e1) {
log.warn("Error occurred while roll-backing the transaction", e); log.warn("Error occurred while roll-backing the transaction", e);
} }
throw new DeviceManagementException("Error occurred while retrieving the list of features registered " + throw new DeviceManagementException("Error occurred while retrieving the list of features registered " +
@ -92,20 +104,22 @@ public class AndroidFeatureManager implements FeatureManager {
} }
@Override @Override
public boolean removeFeature(String name) throws DeviceManagementException { public boolean removeFeature(String code) throws DeviceManagementException {
boolean status = false;
try { try {
FeatureManagementDAOFactory.beginTransaction(); mobileDeviceManagementDAOFactory.beginTransaction();
featureDAO.removeFeature(name); featureDAO.deleteFeatureByCode(code);
FeatureManagementDAOFactory.commitTransaction(); mobileDeviceManagementDAOFactory.commitTransaction();
return true; status = true;
} catch (FeatureManagementDAOException e) { } catch (MobileDeviceManagementDAOException e) {
try { try {
FeatureManagementDAOFactory.rollbackTransaction(); mobileDeviceManagementDAOFactory.rollbackTransaction();
} catch (FeatureManagementDAOException e1) { } catch (MobileDeviceManagementDAOException e1) {
log.warn("Error occurred while roll-backing the transaction", e); log.warn("Error occurred while roll-backing the transaction", e);
} }
throw new DeviceManagementException("Error occurred while removing the feature", e); throw new DeviceManagementException("Error occurred while removing the feature", e);
} }
return status;
} }
} }

@ -20,24 +20,48 @@ package org.wso2.carbon.device.mgt.mobile.impl.android.dao;
import org.apache.commons.logging.Log; import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory; import org.apache.commons.logging.LogFactory;
import org.wso2.carbon.device.mgt.common.DeviceManagementConstants; import org.wso2.carbon.device.mgt.mobile.config.datasource.MobileDataSourceConfig;
import org.wso2.carbon.device.mgt.mobile.dao.MobileDeviceManagementDAOFactory; import org.wso2.carbon.device.mgt.mobile.dao.*;
import org.wso2.carbon.device.mgt.mobile.impl.android.dao.impl.FeatureDAOImpl;
import javax.sql.DataSource; import javax.sql.DataSource;
public class AndroidDAOFactory { public class AndroidDAOFactory extends MobileDeviceManagementDAOFactory
implements MobileDeviceManagementDAOFactoryInterface {
private static final Log log = LogFactory.getLog(AndroidDAOFactory.class); private static final Log log = LogFactory.getLog(AndroidDAOFactory.class);
private static DataSource dataSource; private static DataSource dataSource;
private static boolean isInitialized;
private static MobileDeviceManagementDAOFactory mobileDeviceManagementDAOFactory;
public static void init() { public static void init(MobileDataSourceConfig config) {
mobileDeviceManagementDAOFactory = new MobileDeviceManagementDAOFactory(DeviceManagementConstants dataSource = resolveDataSource(config);
.MobileDeviceTypes.MOBILE_DEVICE_TYPE_ANDROID);
} }
public static DataSource getDataSource() { @Override
return mobileDeviceManagementDAOFactory.getDataSource(); public MobileDeviceDAO getMobileDeviceDAO() {
return null;
} }
@Override
public MobileOperationDAO getMobileOperationDAO() {
return null;
}
@Override
public MobileOperationPropertyDAO getMobileOperationPropertyDAO() {
return null;
}
@Override
public MobileDeviceOperationMappingDAO getMobileDeviceOperationDAO() {
return null;
}
@Override public MobileFeatureDAO getMobileFeatureDao() {
return new FeatureDAOImpl();
}
public MobileFeaturePropertyDAO getFeaturePropertyDAO() {
return null;
}
} }

@ -19,17 +19,18 @@
package org.wso2.carbon.device.mgt.mobile.impl.android.dao; package org.wso2.carbon.device.mgt.mobile.impl.android.dao;
import org.wso2.carbon.device.mgt.common.Feature; import org.wso2.carbon.device.mgt.common.Feature;
import org.wso2.carbon.device.mgt.mobile.dto.MobileFeature;
import java.util.List; import java.util.List;
public interface FeatureDAO { public interface FeatureDAO {
void addFeature(Feature feature) throws FeatureManagementDAOException; void addFeature(MobileFeature feature) throws FeatureManagementDAOException;
void removeFeature(String name) throws FeatureManagementDAOException; void removeFeature(String name) throws FeatureManagementDAOException;
Feature getFeature(String name) throws FeatureManagementDAOException; MobileFeature getFeature(String name) throws FeatureManagementDAOException;
List<Feature> getFeatures() throws FeatureManagementDAOException; List<MobileFeature> getFeatures() throws FeatureManagementDAOException;
} }

@ -18,7 +18,9 @@
*/ */
package org.wso2.carbon.device.mgt.mobile.impl.android.dao; package org.wso2.carbon.device.mgt.mobile.impl.android.dao;
public class FeatureManagementDAOException extends Exception { import org.wso2.carbon.device.mgt.mobile.dao.MobileDeviceManagementDAOException;
public class FeatureManagementDAOException extends MobileDeviceManagementDAOException {
private String message; private String message;
private static final long serialVersionUID = 2021891706072918865L; private static final long serialVersionUID = 2021891706072918865L;

@ -20,10 +20,12 @@ 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.common.Feature;
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.MobileFeatureDAO;
import org.wso2.carbon.device.mgt.mobile.dao.util.MobileDeviceManagementDAOUtil; import org.wso2.carbon.device.mgt.mobile.dao.util.MobileDeviceManagementDAOUtil;
import org.wso2.carbon.device.mgt.mobile.impl.android.dao.FeatureDAO; 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.impl.android.dao.FeatureManagementDAOException;
import org.wso2.carbon.device.mgt.mobile.impl.android.dao.FeatureManagementDAOFactory; import org.wso2.carbon.device.mgt.mobile.util.MobileDeviceManagementUtil;
import java.sql.Connection; import java.sql.Connection;
import java.sql.PreparedStatement; import java.sql.PreparedStatement;
@ -32,53 +34,77 @@ import java.sql.SQLException;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
public class FeatureDAOImpl implements FeatureDAO { public class FeatureDAOImpl implements MobileFeatureDAO {
@Override @Override
public void addFeature(Feature feature) throws FeatureManagementDAOException { public boolean addFeature(MobileFeature mobileFeature) throws MobileDeviceManagementDAOException {
PreparedStatement stmt = null; PreparedStatement stmt = null;
boolean status = false;
try { try {
Connection conn = FeatureManagementDAOFactory.getConnection(); Connection conn = MobileDeviceManagementDAOFactory.getConnection();
String sql = "INSERT INTO AD_FEATURE(CODE, NAME, DESCRIPTION) VALUES (?, ?, ?)"; String sql = "INSERT INTO AD_FEATURE(CODE, NAME, DESCRIPTION) VALUES (?, ?, ?)";
stmt = conn.prepareStatement(sql); stmt = conn.prepareStatement(sql);
stmt.setString(1, feature.getCode()); stmt.setString(1, mobileFeature.getCode());
stmt.setString(2, feature.getName()); stmt.setString(2, mobileFeature.getName());
stmt.setString(3, feature.getDescription()); stmt.setString(3, mobileFeature.getDescription());
stmt.executeUpdate(); stmt.executeUpdate();
status = true;
status = true;
} catch (SQLException e) { } catch (SQLException e) {
throw new FeatureManagementDAOException("Error occurred while adding feature '" + throw new org.wso2.carbon.device.mgt.mobile.impl.ios.dao.FeatureManagementDAOException(
feature.getName() + "' into the metadata repository", e); "Error occurred while adding feature '" +
mobileFeature.getName() + "' into the metadata repository", e);
} finally { } finally {
MobileDeviceManagementDAOUtil.cleanupResources(stmt, null); MobileDeviceManagementDAOUtil.cleanupResources(stmt, null);
} }
return status;
} }
@Override @Override
public void removeFeature(String code) throws FeatureManagementDAOException { 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; PreparedStatement stmt = null;
boolean status = false;
try { try {
Connection conn = FeatureManagementDAOFactory.getConnection(); Connection conn = MobileDeviceManagementDAOFactory.getConnection();
String sql = "DELETE FROM AD_FEATURE WHERE CODE = ?"; String sql = "DELETE FROM AD_FEATURE WHERE CODE = ?";
stmt = conn.prepareStatement(sql); stmt = conn.prepareStatement(sql);
stmt.setString(1, code); stmt.setString(1, mblFeatureCode);
stmt.execute(); stmt.execute();
status = true;
} catch (SQLException e) { } catch (SQLException e) {
throw new FeatureManagementDAOException("Error occurred while adding feature '" + throw new org.wso2.carbon.device.mgt.mobile.impl.ios.dao.FeatureManagementDAOException(
code + "' into the metadata repository", e); "Error occurred while adding feature '" +
mblFeatureCode + "' into the metadata repository", e);
} finally { } finally {
MobileDeviceManagementDAOUtil.cleanupResources(stmt, null); MobileDeviceManagementDAOUtil.cleanupResources(stmt, null);
} }
return status;
}
@Override
public MobileFeature getFeatureById(int mblFeatureId) throws MobileDeviceManagementDAOException {
return null;
} }
@Override @Override
public Feature getFeature(String code) throws FeatureManagementDAOException { public MobileFeature getFeatureByCode(String mblFeatureCode) throws MobileDeviceManagementDAOException {
PreparedStatement stmt = null; PreparedStatement stmt = null;
ResultSet rs = null; ResultSet rs = null;
try { try {
Connection conn = FeatureManagementDAOFactory.getConnection(); Connection conn = MobileDeviceManagementDAOFactory.getConnection();
String sql = "SELECT ID, CODE, NAME, DESCRIPTION FROM AD_FEATURE WHERE CODE = ?"; String sql = "SELECT ID, CODE, NAME, DESCRIPTION FROM AD_FEATURE WHERE CODE = ?";
stmt = conn.prepareStatement(sql); stmt = conn.prepareStatement(sql);
stmt.setString(1, code); stmt.setString(1, mblFeatureCode);
rs = stmt.executeQuery(); rs = stmt.executeQuery();
Feature feature = null; Feature feature = null;
@ -89,25 +115,35 @@ public class FeatureDAOImpl implements FeatureDAO {
feature.setName(rs.getString("NAME")); feature.setName(rs.getString("NAME"));
feature.setDescription(rs.getString("DESCRIPTION")); feature.setDescription(rs.getString("DESCRIPTION"));
} }
return feature; MobileFeature mobileFeature = MobileDeviceManagementUtil.convertToMobileFeature(feature);
return mobileFeature;
} catch (SQLException e) { } catch (SQLException e) {
throw new FeatureManagementDAOException("Error occurred while retrieving feature metadata '" + throw new org.wso2.carbon.device.mgt.mobile.impl.ios.dao.FeatureManagementDAOException(
code + "' from the feature metadata repository", e); "Error occurred while retrieving feature metadata '" +
mblFeatureCode + "' from the feature metadata repository", e);
} finally { } finally {
MobileDeviceManagementDAOUtil.cleanupResources(stmt, rs); MobileDeviceManagementDAOUtil.cleanupResources(stmt, rs);
} }
} }
@Override @Override
public List<Feature> getFeatures() throws FeatureManagementDAOException { public List<MobileFeature> getFeatureByDeviceType(String deviceType)
throws MobileDeviceManagementDAOException {
return null;
}
@Override
public List<MobileFeature> getAllFeatures() throws MobileDeviceManagementDAOException {
PreparedStatement stmt = null; PreparedStatement stmt = null;
ResultSet rs = null; ResultSet rs = null;
List<Feature> features = new ArrayList<Feature>(); List<MobileFeature> features = new ArrayList<MobileFeature>();
try { try {
Connection conn = FeatureManagementDAOFactory.getConnection(); Connection conn = MobileDeviceManagementDAOFactory.getConnection();
String sql = "SELECT ID, CODE, NAME, DESCRIPTION FROM AD_FEATURE"; String sql = "SELECT ID, CODE, NAME, DESCRIPTION FROM AD_FEATURE";
stmt = conn.prepareStatement(sql); stmt = conn.prepareStatement(sql);
rs = stmt.executeQuery(); rs = stmt.executeQuery();
MobileFeature mobileFeature;
while (rs.next()) { while (rs.next()) {
Feature feature = new Feature(); Feature feature = new Feature();
@ -115,6 +151,8 @@ public class FeatureDAOImpl implements FeatureDAO {
feature.setCode(rs.getString("CODE")); feature.setCode(rs.getString("CODE"));
feature.setName(rs.getString("NAME")); feature.setName(rs.getString("NAME"));
feature.setDescription(rs.getString("DESCRIPTION")); feature.setDescription(rs.getString("DESCRIPTION"));
mobileFeature = MobileDeviceManagementUtil.convertToMobileFeature(feature);
features.add(mobileFeature);
} }
return features; return features;
} catch (SQLException e) { } catch (SQLException e) {
@ -124,5 +162,4 @@ public class FeatureDAOImpl implements FeatureDAO {
MobileDeviceManagementDAOUtil.cleanupResources(stmt, rs); MobileDeviceManagementDAOUtil.cleanupResources(stmt, rs);
} }
} }
} }

@ -25,6 +25,7 @@ import org.wso2.carbon.device.mgt.common.spi.DeviceManager;
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.dto.MobileDevice; import org.wso2.carbon.device.mgt.mobile.dto.MobileDevice;
import org.wso2.carbon.device.mgt.mobile.impl.ios.dao.IOSDAOFactory;
import org.wso2.carbon.device.mgt.mobile.util.MobileDeviceManagementUtil; import org.wso2.carbon.device.mgt.mobile.util.MobileDeviceManagementUtil;
import java.util.List; import java.util.List;
@ -44,8 +45,7 @@ public class IOSDeviceManager implements DeviceManager {
} }
public IOSDeviceManager() { public IOSDeviceManager() {
mobileDeviceManagementDAOFactory = new MobileDeviceManagementDAOFactory(DeviceManagementConstants mobileDeviceManagementDAOFactory = new IOSDAOFactory();
.MobileDeviceTypes.MOBILE_DEVICE_TYPE_IOS);
iosFeatureManager = new IOSFeatureManager(); iosFeatureManager = new IOSFeatureManager();
} }

@ -23,69 +23,75 @@ 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.impl.ios.dao.FeatureDAO; import org.wso2.carbon.device.mgt.mobile.dao.MobileDeviceManagementDAOException;
import org.wso2.carbon.device.mgt.mobile.impl.ios.dao.FeatureManagementDAOException; import org.wso2.carbon.device.mgt.mobile.dao.MobileDeviceManagementDAOFactory;
import org.wso2.carbon.device.mgt.mobile.impl.ios.dao.FeatureManagementDAOFactory; 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.impl.ios.dao.IOSDAOFactory;
import org.wso2.carbon.device.mgt.mobile.util.MobileDeviceManagementUtil;
import java.util.ArrayList;
import java.util.List; import java.util.List;
public class IOSFeatureManager implements FeatureManager { public class IOSFeatureManager implements FeatureManager {
private static final Log log = LogFactory.getLog(IOSFeatureManager.class); private static final Log log = LogFactory.getLog(IOSFeatureManager.class);
private MobileDeviceManagementDAOFactory mobileDeviceManagementDAOFactory;
private FeatureDAO featureDAO; private MobileFeatureDAO featureDAO;
public IOSFeatureManager() { public IOSFeatureManager() {
this.featureDAO = FeatureManagementDAOFactory.getFeatureDAO(); mobileDeviceManagementDAOFactory = new IOSDAOFactory();
this.featureDAO = mobileDeviceManagementDAOFactory.getMobileFeatureDao();
} }
@Override @Override
public boolean addFeature(Feature feature) throws DeviceManagementException { public boolean addFeature(Feature feature) throws DeviceManagementException {
try { try {
FeatureManagementDAOFactory.beginTransaction(); mobileDeviceManagementDAOFactory.beginTransaction();
featureDAO.addFeature(feature); MobileFeature mobileFeature = MobileDeviceManagementUtil.convertToMobileFeature(feature);
FeatureManagementDAOFactory.commitTransaction();
try {
featureDAO.addFeature(mobileFeature);
} catch (MobileDeviceManagementDAOException e) {
log.error("error in feature add ", e);
throw new DeviceManagementException("error in feature add", e);
}
mobileDeviceManagementDAOFactory.commitTransaction();
return true; return true;
} catch (FeatureManagementDAOException e) { } catch (MobileDeviceManagementDAOException e) {
try { try {
FeatureManagementDAOFactory.rollbackTransaction(); mobileDeviceManagementDAOFactory.rollbackTransaction();
} catch (FeatureManagementDAOException e1) { } catch (MobileDeviceManagementDAOException e1) {
log.warn("Error occurred while roll-backing the transaction", e); log.warn("Error occurred while roll-backing the transaction", e);
} }
throw new DeviceManagementException("Error occurred while adding the feature", e); throw new DeviceManagementException("DB transaction error occurred while add the feature", e);
} }
} }
@Override @Override
public Feature getFeature(String name) throws DeviceManagementException { public Feature getFeature(String code) throws DeviceManagementException {
try { try {
FeatureManagementDAOFactory.beginTransaction(); MobileFeature mobileFeature = featureDAO.getFeatureByCode(code);
Feature feature = featureDAO.getFeature(name); Feature feature = MobileDeviceManagementUtil.convertToFeature(mobileFeature);
FeatureManagementDAOFactory.commitTransaction();
return feature; return feature;
} catch (FeatureManagementDAOException e) { } catch (MobileDeviceManagementDAOException e) {
try {
FeatureManagementDAOFactory.rollbackTransaction();
} catch (FeatureManagementDAOException e1) {
log.warn("Error occurred while roll-backing the transaction", e);
}
throw new DeviceManagementException("Error occurred while retrieving the feature", e); throw new DeviceManagementException("Error occurred while retrieving the feature", e);
} }
} }
@Override @Override
public List<Feature> getFeatures() throws DeviceManagementException { public List<Feature> getFeatures() throws DeviceManagementException {
List<Feature> featureList = new ArrayList<Feature>();
try { try {
FeatureManagementDAOFactory.beginTransaction(); List<MobileFeature> mobileFeatures = featureDAO.getAllFeatures();
List<Feature> features = featureDAO.getFeatures();
FeatureManagementDAOFactory.commitTransaction(); for (MobileFeature mobileFeature : mobileFeatures) {
return features; featureList.add(MobileDeviceManagementUtil.convertToFeature(mobileFeature));
} catch (FeatureManagementDAOException e) {
try {
FeatureManagementDAOFactory.rollbackTransaction();
} catch (FeatureManagementDAOException e1) {
log.warn("Error occurred while roll-backing the transaction", e);
} }
return featureList;
} catch (MobileDeviceManagementDAOException e) {
throw new DeviceManagementException("Error occurred while retrieving the list of features registered " + throw new DeviceManagementException("Error occurred while retrieving the list of features registered " +
"for Android platform", e); "for Android platform", e);
} }
@ -94,14 +100,14 @@ public class IOSFeatureManager implements FeatureManager {
@Override @Override
public boolean removeFeature(String name) throws DeviceManagementException { public boolean removeFeature(String name) throws DeviceManagementException {
try { try {
FeatureManagementDAOFactory.beginTransaction(); mobileDeviceManagementDAOFactory.beginTransaction();
featureDAO.removeFeature(name); featureDAO.deleteFeatureByCode(name);
FeatureManagementDAOFactory.commitTransaction(); mobileDeviceManagementDAOFactory.commitTransaction();
return true; return true;
} catch (FeatureManagementDAOException e) { } catch (MobileDeviceManagementDAOException e) {
try { try {
FeatureManagementDAOFactory.rollbackTransaction(); mobileDeviceManagementDAOFactory.rollbackTransaction();
} catch (FeatureManagementDAOException e1) { } catch (MobileDeviceManagementDAOException e1) {
log.warn("Error occurred while roll-backing the transaction", e); log.warn("Error occurred while roll-backing the transaction", e);
} }
throw new DeviceManagementException("Error occurred while removing the feature", e); throw new DeviceManagementException("Error occurred while removing the feature", e);

@ -18,7 +18,9 @@
*/ */
package org.wso2.carbon.device.mgt.mobile.impl.ios.dao; package org.wso2.carbon.device.mgt.mobile.impl.ios.dao;
public class FeatureManagementDAOException extends Exception { import org.wso2.carbon.device.mgt.mobile.dao.MobileDeviceManagementDAOException;
public class FeatureManagementDAOException extends MobileDeviceManagementDAOException {
private String message; private String message;
private static final long serialVersionUID = 2021891706072918865L; private static final long serialVersionUID = 2021891706072918865L;

@ -19,24 +19,43 @@ package org.wso2.carbon.device.mgt.mobile.impl.ios.dao;
import org.apache.commons.logging.Log; import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory; import org.apache.commons.logging.LogFactory;
import org.wso2.carbon.device.mgt.common.DeviceManagementConstants; import org.wso2.carbon.device.mgt.mobile.config.datasource.MobileDataSourceConfig;
import org.wso2.carbon.device.mgt.mobile.dao.MobileDeviceManagementDAOFactory; import org.wso2.carbon.device.mgt.mobile.dao.*;
import javax.sql.DataSource; public class IOSDAOFactory extends MobileDeviceManagementDAOFactory {
public class IOSDAOFactory {
private static final Log log = LogFactory.getLog(IOSDAOFactory.class); private static final Log log = LogFactory.getLog(IOSDAOFactory.class);
private static DataSource dataSource;
private static boolean isInitialized;
private static MobileDeviceManagementDAOFactory mobileDeviceManagementDAOFactory;
public static void init() { public static void init(MobileDataSourceConfig config) {
mobileDeviceManagementDAOFactory = new MobileDeviceManagementDAOFactory(DeviceManagementConstants dataSource = resolveDataSource(config);
.MobileDeviceTypes.MOBILE_DEVICE_TYPE_IOS); }
@Override
public MobileDeviceDAO getMobileDeviceDAO() {
return null;
}
@Override
public MobileOperationDAO getMobileOperationDAO() {
return null;
}
@Override
public MobileOperationPropertyDAO getMobileOperationPropertyDAO() {
return null;
}
@Override
public MobileDeviceOperationMappingDAO getMobileDeviceOperationDAO() {
return null;
}
@Override
public MobileFeatureDAO getMobileFeatureDao() {
return null;
} }
public static DataSource getDataSource() { public MobileFeaturePropertyDAO getFeaturePropertyDAO() {
return mobileDeviceManagementDAOFactory.getDataSource(); return null;
} }
} }

@ -18,12 +18,12 @@
*/ */
package org.wso2.carbon.device.mgt.mobile.impl.ios.dao.impl; package org.wso2.carbon.device.mgt.mobile.impl.ios.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.dao.util.MobileDeviceManagementDAOUtil;
import org.wso2.carbon.device.mgt.mobile.impl.ios.dao.FeatureDAO; import org.wso2.carbon.device.mgt.mobile.dto.MobileFeature;
import org.wso2.carbon.device.mgt.mobile.impl.ios.dao.FeatureManagementDAOException; import org.wso2.carbon.device.mgt.mobile.impl.ios.dao.FeatureManagementDAOException;
import org.wso2.carbon.device.mgt.mobile.impl.ios.dao.FeatureManagementDAOFactory;
import java.sql.Connection; import java.sql.Connection;
import java.sql.PreparedStatement; import java.sql.PreparedStatement;
import java.sql.ResultSet; import java.sql.ResultSet;
@ -31,58 +31,79 @@ import java.sql.SQLException;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
public class FeatureDAOImpl implements FeatureDAO { public class FeatureDAOImpl implements MobileFeatureDAO {
@Override
public void addFeature(Feature feature) throws FeatureManagementDAOException { public boolean addFeature(MobileFeature feature) throws FeatureManagementDAOException {
PreparedStatement stmt = null; PreparedStatement stmt = null;
boolean status = false;
try { try {
Connection conn = FeatureManagementDAOFactory.getConnection(); Connection conn = MobileDeviceManagementDAOFactory.getConnection();
String sql = "INSERT INTO IOS_FEATURE(CODE, NAME, DESCRIPTION) VALUES (?, ?, ?)"; String sql = "INSERT INTO IOS_FEATURE(CODE, NAME, DESCRIPTION) VALUES (?, ?, ?)";
stmt = conn.prepareStatement(sql); stmt = conn.prepareStatement(sql);
stmt.setString(1, feature.getCode()); stmt.setString(1, feature.getCode());
stmt.setString(2, feature.getName()); stmt.setString(2, feature.getName());
stmt.setString(3, feature.getDescription()); stmt.setString(3, feature.getDescription());
stmt.executeUpdate(); stmt.executeUpdate();
status = true;
} catch (SQLException e) { } catch (SQLException e) {
throw new FeatureManagementDAOException("Error occurred while adding feature '" + throw new FeatureManagementDAOException("Error occurred while adding feature '" +
feature.getName() + "' into the metadata repository", e); feature.getName() + "' into the metadata repository", e);
} finally { } finally {
MobileDeviceManagementDAOUtil.cleanupResources(stmt, null); MobileDeviceManagementDAOUtil.cleanupResources(stmt, null);
} }
return status;
}
@Override
public boolean updateFeature(MobileFeature mobileFeature) throws MobileDeviceManagementDAOException {
return false;
} }
@Override @Override
public void removeFeature(String code) throws FeatureManagementDAOException { public boolean deleteFeatureById(int mblFeatureId) throws MobileDeviceManagementDAOException {
return false;
}
@Override
public boolean deleteFeatureByCode(String mblFeatureCode) throws MobileDeviceManagementDAOException {
PreparedStatement stmt = null; PreparedStatement stmt = null;
boolean status = false;
try { try {
Connection conn = FeatureManagementDAOFactory.getConnection(); Connection conn = MobileDeviceManagementDAOFactory.getConnection();
String sql = "DELETE FROM IOS_FEATURE WHERE CODE = ?"; String sql = "DELETE FROM IOS_FEATURE WHERE CODE = ?";
stmt = conn.prepareStatement(sql); stmt = conn.prepareStatement(sql);
stmt.setString(1, code); stmt.setString(1, mblFeatureCode);
stmt.execute(); stmt.execute();
status = true;
} catch (SQLException e) { } catch (SQLException e) {
throw new FeatureManagementDAOException("Error occurred while adding feature '" + throw new FeatureManagementDAOException("Error occurred while adding feature '" +
code + "' into the metadata repository", e); mblFeatureCode + "' into the metadata repository", e);
} finally { } finally {
MobileDeviceManagementDAOUtil.cleanupResources(stmt, null); MobileDeviceManagementDAOUtil.cleanupResources(stmt, null);
} }
return status;
}
@Override
public MobileFeature getFeatureById(int mblFeatureId) throws MobileDeviceManagementDAOException {
return null;
} }
@Override @Override
public Feature getFeature(String code) throws FeatureManagementDAOException { public MobileFeature getFeatureByCode(String mblFeatureCode) throws MobileDeviceManagementDAOException {
PreparedStatement stmt = null; PreparedStatement stmt = null;
ResultSet rs = null; ResultSet rs = null;
try { try {
Connection conn = FeatureManagementDAOFactory.getConnection(); Connection conn = MobileDeviceManagementDAOFactory.getConnection();
String sql = "SELECT ID, CODE, NAME, DESCRIPTION FROM IOS_FEATURE WHERE CODE = ?"; String sql = "SELECT ID, CODE, NAME, DESCRIPTION FROM IOS_FEATURE WHERE CODE = ?";
stmt = conn.prepareStatement(sql); stmt = conn.prepareStatement(sql);
stmt.setString(1, code); stmt.setString(1, mblFeatureCode);
rs = stmt.executeQuery(); rs = stmt.executeQuery();
Feature feature = null; MobileFeature feature = null;
if (rs.next()) { if (rs.next()) {
feature = new Feature(); feature = new MobileFeature();
feature.setId(rs.getInt("ID")); feature.setId(rs.getInt("ID"));
feature.setCode(rs.getString("CODE")); feature.setCode(rs.getString("CODE"));
feature.setName(rs.getString("NAME")); feature.setName(rs.getString("NAME"));
@ -91,25 +112,30 @@ public class FeatureDAOImpl implements FeatureDAO {
return feature; return feature;
} catch (SQLException e) { } catch (SQLException e) {
throw new FeatureManagementDAOException("Error occurred while retrieving feature metadata '" + throw new FeatureManagementDAOException("Error occurred while retrieving feature metadata '" +
code + "' from the feature metadata repository", e); mblFeatureCode + "' from the feature metadata repository", e);
} finally { } finally {
MobileDeviceManagementDAOUtil.cleanupResources(stmt, rs); MobileDeviceManagementDAOUtil.cleanupResources(stmt, rs);
} }
} }
@Override @Override
public List<Feature> getFeatures() throws FeatureManagementDAOException { public List<MobileFeature> getFeatureByDeviceType(String deviceType) throws MobileDeviceManagementDAOException {
return null;
}
@Override
public List<MobileFeature> getAllFeatures() throws MobileDeviceManagementDAOException {
PreparedStatement stmt = null; PreparedStatement stmt = null;
ResultSet rs = null; ResultSet rs = null;
List<Feature> features = new ArrayList<Feature>(); List<MobileFeature> features = new ArrayList<MobileFeature>();
try { try {
Connection conn = FeatureManagementDAOFactory.getConnection(); Connection conn = MobileDeviceManagementDAOFactory.getConnection();
String sql = "SELECT ID, CODE, NAME, DESCRIPTION FROM IOS_FEATURE"; String sql = "SELECT ID, CODE, NAME, DESCRIPTION FROM IOS_FEATURE";
stmt = conn.prepareStatement(sql); stmt = conn.prepareStatement(sql);
rs = stmt.executeQuery(); rs = stmt.executeQuery();
while (rs.next()) { while (rs.next()) {
Feature feature = new Feature(); MobileFeature feature = new MobileFeature();
feature.setId(rs.getInt("ID")); feature.setId(rs.getInt("ID"));
feature.setCode(rs.getString("CODE")); feature.setCode(rs.getString("CODE"));
feature.setName(rs.getString("NAME")); feature.setName(rs.getString("NAME"));

@ -25,6 +25,7 @@ import org.wso2.carbon.device.mgt.common.spi.DeviceManager;
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.dto.MobileDevice; import org.wso2.carbon.device.mgt.mobile.dto.MobileDevice;
import org.wso2.carbon.device.mgt.mobile.impl.windows.dao.WindowsDAOFactory;
import org.wso2.carbon.device.mgt.mobile.util.MobileDeviceManagementUtil; import org.wso2.carbon.device.mgt.mobile.util.MobileDeviceManagementUtil;
import java.util.List; import java.util.List;
@ -37,8 +38,7 @@ public class WindowsDeviceManager implements DeviceManager {
private MobileDeviceManagementDAOFactory mobileDeviceManagementDAOFactory; private MobileDeviceManagementDAOFactory mobileDeviceManagementDAOFactory;
public WindowsDeviceManager() { public WindowsDeviceManager() {
mobileDeviceManagementDAOFactory = new MobileDeviceManagementDAOFactory(DeviceManagementConstants mobileDeviceManagementDAOFactory = new WindowsDAOFactory();
.MobileDeviceTypes.MOBILE_DEVICE_TYPE_WINDOWS);
} }
private static final Log log = LogFactory.getLog(WindowsDeviceManager.class); private static final Log log = LogFactory.getLog(WindowsDeviceManager.class);

@ -32,6 +32,7 @@ import org.wso2.carbon.device.mgt.mobile.config.datasource.MobileDataSourceConfi
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.util.MobileDeviceManagementDAOUtil; import org.wso2.carbon.device.mgt.mobile.dao.util.MobileDeviceManagementDAOUtil;
import org.wso2.carbon.device.mgt.mobile.impl.android.AndroidDeviceManager; import org.wso2.carbon.device.mgt.mobile.impl.android.AndroidDeviceManager;
import org.wso2.carbon.device.mgt.mobile.impl.android.dao.AndroidDAOFactory;
import org.wso2.carbon.device.mgt.mobile.impl.ios.IOSDeviceManager; import org.wso2.carbon.device.mgt.mobile.impl.ios.IOSDeviceManager;
import org.wso2.carbon.device.mgt.mobile.impl.ios.dao.IOSDAOFactory; import org.wso2.carbon.device.mgt.mobile.impl.ios.dao.IOSDAOFactory;
import org.wso2.carbon.device.mgt.mobile.impl.windows.WindowsDeviceManager; import org.wso2.carbon.device.mgt.mobile.impl.windows.WindowsDeviceManager;
@ -77,8 +78,9 @@ public class MobileDeviceManagementServiceComponent {
Map<String, MobileDataSourceConfig> dsConfigMap = Map<String, MobileDataSourceConfig> dsConfigMap =
config.getMobileDeviceMgtRepository().getMobileDataSourceConfigMap(); config.getMobileDeviceMgtRepository().getMobileDataSourceConfigMap();
MobileDeviceManagementDAOFactory.setMobileDataSourceConfigMap(dsConfigMap); MobileDeviceManagementDAOFactory.setMobileDataSourceConfigMap(dsConfigMap);
MobileDeviceManagementDAOFactory.init(); IOSDAOFactory.init(dsConfigMap.get(DeviceManagementConstants.MobileDeviceTypes.MOBILE_DEVICE_TYPE_IOS));
IOSDAOFactory.init(); AndroidDAOFactory
.init(dsConfigMap.get(DeviceManagementConstants.MobileDeviceTypes.MOBILE_DEVICE_TYPE_ANDROID));
String setupOption = System.getProperty("setup"); String setupOption = System.getProperty("setup");
if (setupOption != null) { if (setupOption != null) {

@ -23,11 +23,9 @@ import org.apache.commons.logging.LogFactory;
import org.w3c.dom.Document; import org.w3c.dom.Document;
import org.wso2.carbon.device.mgt.common.Device; import org.wso2.carbon.device.mgt.common.Device;
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.operation.mgt.Operation; import org.wso2.carbon.device.mgt.common.operation.mgt.Operation;
import org.wso2.carbon.device.mgt.mobile.dto.MobileDevice; import org.wso2.carbon.device.mgt.mobile.dto.*;
import org.wso2.carbon.device.mgt.mobile.dto.MobileDeviceOperationMapping;
import org.wso2.carbon.device.mgt.mobile.dto.MobileOperation;
import org.wso2.carbon.device.mgt.mobile.dto.MobileOperationProperty;
import javax.xml.parsers.DocumentBuilder; import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory; import javax.xml.parsers.DocumentBuilderFactory;
@ -164,4 +162,24 @@ public class MobileDeviceManagementUtil {
operation.setProperties(properties); operation.setProperties(properties);
return operation; return operation;
} }
public static MobileFeature convertToMobileFeature(Feature feature) {
MobileFeature mobileFeature = new MobileFeature();
mobileFeature.setName(feature.getName());
mobileFeature.setCode(feature.getCode());
mobileFeature.setDescription(feature.getDescription());
mobileFeature.setDeviceType(feature.getDeviceType());
return mobileFeature;
}
public static Feature convertToFeature(MobileFeature mobileFeature) {
Feature feature = new Feature();
feature.setDescription(mobileFeature.getDescription());
feature.setDeviceType(mobileFeature.getDeviceType());
feature.setCode(mobileFeature.getCode());
feature.setName(mobileFeature.getName());
return feature;
}
} }

@ -87,7 +87,8 @@ public class MobileFeatureDAOTestSuite {
mobileFeature.setDescription(MBL_FEATURE_DESCRIPTION); mobileFeature.setDescription(MBL_FEATURE_DESCRIPTION);
mobileFeature.setName(MBL_FEATURE_NAME); mobileFeature.setName(MBL_FEATURE_NAME);
mobileFeature.setDeviceType(MBL_FEATURE_DEVICE_TYPE); mobileFeature.setDeviceType(MBL_FEATURE_DEVICE_TYPE);
int id = mblFeatureDAO.addMobileFeature(mobileFeature); mblFeatureDAO.addFeature(mobileFeature);
try { try {
conn = DriverManager.getConnection(testDBConfiguration.getConnectionURL()); conn = DriverManager.getConnection(testDBConfiguration.getConnectionURL());
String query = String query =
@ -110,7 +111,7 @@ public class MobileFeatureDAOTestSuite {
MobileDatabaseUtils.cleanupResources(conn, preparedStatement, null); MobileDatabaseUtils.cleanupResources(conn, preparedStatement, null);
} }
mblFeatureId = testMblFeature.getId(); mblFeatureId = testMblFeature.getId();
Assert.assertTrue(id > 0, "MobileFeature has added "); Assert.assertTrue(mblFeatureId > 0, "MobileFeature has added ");
Assert.assertEquals(MBL_FEATURE_CODE, testMblFeature.getCode(), Assert.assertEquals(MBL_FEATURE_CODE, testMblFeature.getCode(),
"MobileFeature code has persisted "); "MobileFeature code has persisted ");
Assert.assertEquals(MBL_FEATURE_NAME, testMblFeature.getName(), Assert.assertEquals(MBL_FEATURE_NAME, testMblFeature.getName(),
@ -125,7 +126,7 @@ public class MobileFeatureDAOTestSuite {
public void getMobileFeatureByCodeTest() public void getMobileFeatureByCodeTest()
throws MobileDeviceManagementDAOException { throws MobileDeviceManagementDAOException {
MobileFeature mobileFeature = mblFeatureDAO.getMobileFeatureByCode(MBL_FEATURE_CODE); MobileFeature mobileFeature = mblFeatureDAO.getFeatureByCode(MBL_FEATURE_CODE);
Assert.assertEquals(MBL_FEATURE_CODE, mobileFeature.getCode(), Assert.assertEquals(MBL_FEATURE_CODE, mobileFeature.getCode(),
"MobileFeature code has retrieved "); "MobileFeature code has retrieved ");
Assert.assertEquals(MBL_FEATURE_NAME, mobileFeature.getName(), Assert.assertEquals(MBL_FEATURE_NAME, mobileFeature.getName(),
@ -138,7 +139,7 @@ public class MobileFeatureDAOTestSuite {
public void getMobileFeatureByIdTest() public void getMobileFeatureByIdTest()
throws MobileDeviceManagementDAOException { throws MobileDeviceManagementDAOException {
MobileFeature mobileFeature = mblFeatureDAO.getMobileFeatureById(mblFeatureId); MobileFeature mobileFeature = mblFeatureDAO.getFeatureById(mblFeatureId);
Assert.assertEquals(MBL_FEATURE_CODE, mobileFeature.getCode(), Assert.assertEquals(MBL_FEATURE_CODE, mobileFeature.getCode(),
"MobileFeature code has retrieved "); "MobileFeature code has retrieved ");
Assert.assertEquals(MBL_FEATURE_NAME, mobileFeature.getName(), Assert.assertEquals(MBL_FEATURE_NAME, mobileFeature.getName(),
@ -151,7 +152,7 @@ public class MobileFeatureDAOTestSuite {
public void getAllMobileFeaturesTest() public void getAllMobileFeaturesTest()
throws MobileDeviceManagementDAOException { throws MobileDeviceManagementDAOException {
List<MobileFeature> mobileFeatures = mblFeatureDAO.getAllMobileFeatures(); List<MobileFeature> mobileFeatures = mblFeatureDAO.getAllFeatures();
Assert.assertNotNull(mobileFeatures, "MobileFeature list is not null"); Assert.assertNotNull(mobileFeatures, "MobileFeature list is not null");
Assert.assertTrue(mobileFeatures.size() > 0, "MobileFeature list has 1 MobileFeature"); Assert.assertTrue(mobileFeatures.size() > 0, "MobileFeature list has 1 MobileFeature");
} }
@ -170,7 +171,7 @@ public class MobileFeatureDAOTestSuite {
mobileFeature.setDescription(MBL_FEATURE_DESCRIPTION); mobileFeature.setDescription(MBL_FEATURE_DESCRIPTION);
mobileFeature.setName(MBL_FEATURE_NAME); mobileFeature.setName(MBL_FEATURE_NAME);
mobileFeature.setId(mblFeatureId); mobileFeature.setId(mblFeatureId);
boolean updated = mblFeatureDAO.updateMobileFeature(mobileFeature); boolean updated = mblFeatureDAO.updateFeature(mobileFeature);
try { try {
conn = DriverManager.getConnection(testDBConfiguration.getConnectionURL()); conn = DriverManager.getConnection(testDBConfiguration.getConnectionURL());
String query = String query =
@ -204,7 +205,7 @@ public class MobileFeatureDAOTestSuite {
Connection conn = null; Connection conn = null;
PreparedStatement stmt = null; PreparedStatement stmt = null;
boolean status = mblFeatureDAO.deleteMobileFeatureById(mblFeatureId); boolean status = mblFeatureDAO.deleteFeatureById(mblFeatureId);
try { try {
conn = DriverManager.getConnection(testDBConfiguration.getConnectionURL()); conn = DriverManager.getConnection(testDBConfiguration.getConnectionURL());
String query = "SELECT FEATURE_ID, CODE FROM AD_FEATURE WHERE FEATURE_ID = ?"; String query = "SELECT FEATURE_ID, CODE FROM AD_FEATURE WHERE FEATURE_ID = ?";
@ -236,8 +237,8 @@ public class MobileFeatureDAOTestSuite {
mobileFeature.setDescription(MBL_FEATURE_DESCRIPTION); mobileFeature.setDescription(MBL_FEATURE_DESCRIPTION);
mobileFeature.setName(MBL_FEATURE_NAME); mobileFeature.setName(MBL_FEATURE_NAME);
mobileFeature.setDeviceType(MBL_FEATURE_DEVICE_TYPE); mobileFeature.setDeviceType(MBL_FEATURE_DEVICE_TYPE);
mblFeatureDAO.addMobileFeature(mobileFeature); mblFeatureDAO.addFeature(mobileFeature);
boolean status = mblFeatureDAO.deleteMobileFeatureByCode(MBL_FEATURE_CODE); boolean status = mblFeatureDAO.deleteFeatureByCode(MBL_FEATURE_CODE);
try { try {
conn = DriverManager.getConnection(testDBConfiguration.getConnectionURL()); conn = DriverManager.getConnection(testDBConfiguration.getConnectionURL());
String query = "SELECT FEATURE_ID, CODE FROM AD_FEATURE WHERE CODE = ?"; String query = "SELECT FEATURE_ID, CODE FROM AD_FEATURE WHERE CODE = ?";

@ -45,194 +45,197 @@ import java.util.List;
* *
*/ */
public class MobileFeaturePropertyDAOTestSuite { public class MobileFeaturePropertyDAOTestSuite {
private static final Log log = LogFactory.getLog(MobileFeaturePropertyDAOTestSuite.class);
public static final String MBL_FEATURE_NAME = "WIFI"; private static final Log log = LogFactory.getLog(MobileFeaturePropertyDAOTestSuite.class);
private static final String MBL_FEATURE_CODE = "500A"; public static final String MBL_FEATURE_NAME = "WIFI";
public static final String MBL_FEATURE_DESCRIPTION = "Wifi config"; private static final String MBL_FEATURE_CODE = "500A";
public static final String MBL_FEATURE_DEVICE_TYPE = "Android"; public static final String MBL_FEATURE_DESCRIPTION = "Wifi config";
public static final String MBL_FEATURE_PROP_1 = "SSID"; public static final String MBL_FEATURE_DEVICE_TYPE = "Android";
public static final String MBL_FEATURE_PROP_2 = "PASSWORD"; public static final String MBL_FEATURE_PROP_1 = "SSID";
private TestDBConfiguration testDBConfiguration; public static final String MBL_FEATURE_PROP_2 = "PASSWORD";
private MobileFeatureDAOImpl mblFeatureDAO; private TestDBConfiguration testDBConfiguration;
private MobileFeaturePropertyDAOImpl mobileFeaturePropertyDAO; private MobileFeatureDAOImpl mblFeatureDAO;
private int mblFeatureId; private MobileFeaturePropertyDAOImpl mobileFeaturePropertyDAO;
private int mblFeatureId;
@BeforeClass
@Parameters("dbType") @BeforeClass
public void setUpDB(String dbTypeStr) throws Exception { @Parameters("dbType")
public void setUpDB(String dbTypeStr) throws Exception {
DBTypes dbType = DBTypes.valueOf(dbTypeStr);
testDBConfiguration = MobileDatabaseUtils.getTestDBConfiguration(dbType); DBTypes dbType = DBTypes.valueOf(dbTypeStr);
testDBConfiguration = MobileDatabaseUtils.getTestDBConfiguration(dbType);
switch (dbType) {
case H2: switch (dbType) {
MobileDatabaseUtils.createH2DB(testDBConfiguration); case H2:
DataSource testDataSource = new org.apache.tomcat.jdbc.pool.DataSource(); MobileDatabaseUtils.createH2DB(testDBConfiguration);
PoolProperties properties = new PoolProperties(); DataSource testDataSource = new org.apache.tomcat.jdbc.pool.DataSource();
properties.setUrl(testDBConfiguration.getConnectionURL()); PoolProperties properties = new PoolProperties();
properties.setDriverClassName(testDBConfiguration.getDriverClassName()); properties.setUrl(testDBConfiguration.getConnectionURL());
properties.setUsername(testDBConfiguration.getUsername()); properties.setDriverClassName(testDBConfiguration.getDriverClassName());
properties.setPassword(testDBConfiguration.getPassword()); properties.setUsername(testDBConfiguration.getUsername());
testDataSource.setPoolProperties(properties); properties.setPassword(testDBConfiguration.getPassword());
mblFeatureDAO = new MobileFeatureDAOImpl(testDataSource); testDataSource.setPoolProperties(properties);
mobileFeaturePropertyDAO = new MobileFeaturePropertyDAOImpl(testDataSource); mblFeatureDAO = new MobileFeatureDAOImpl(testDataSource);
default: mobileFeaturePropertyDAO = new MobileFeaturePropertyDAOImpl(testDataSource);
} default:
} }
}
@Test
public void addMobileFeaturePropertyTest() @Test
throws MobileDeviceManagementDAOException { public void addMobileFeaturePropertyTest()
throws MobileDeviceManagementDAOException {
Connection conn = null;
PreparedStatement preparedStatement = null; Connection conn = null;
List<MobileFeatureProperty> propertyList = new ArrayList<MobileFeatureProperty>(); PreparedStatement preparedStatement = null;
//Add a new MobileFeature to the database List<MobileFeatureProperty> propertyList = new ArrayList<MobileFeatureProperty>();
MobileFeature mobileFeature = new MobileFeature(); //Add a new MobileFeature to the database
mobileFeature.setCode(MBL_FEATURE_CODE); MobileFeature mobileFeature = new MobileFeature();
mobileFeature.setDescription(MBL_FEATURE_DESCRIPTION); mobileFeature.setCode(MBL_FEATURE_CODE);
mobileFeature.setName(MBL_FEATURE_NAME); mobileFeature.setDescription(MBL_FEATURE_DESCRIPTION);
mobileFeature.setDeviceType(MBL_FEATURE_DEVICE_TYPE); mobileFeature.setName(MBL_FEATURE_NAME);
mblFeatureId = mblFeatureDAO.addMobileFeature(mobileFeature); mobileFeature.setDeviceType(MBL_FEATURE_DEVICE_TYPE);
mblFeatureDAO.addFeature(mobileFeature);
//Add 1st property to the feature
MobileFeatureProperty mobileFeatureProperty = new MobileFeatureProperty(); MobileFeature persistMblFeature = mblFeatureDAO.getFeatureByCode(MBL_FEATURE_CODE);
mobileFeatureProperty.setFeatureID(mblFeatureId); mblFeatureId = persistMblFeature.getId();
mobileFeatureProperty.setProperty(MBL_FEATURE_PROP_1); //Add 1st property to the feature
boolean status1 = mobileFeaturePropertyDAO.addMobileFeatureProperty(mobileFeatureProperty); MobileFeatureProperty mobileFeatureProperty = new MobileFeatureProperty();
mobileFeatureProperty.setFeatureID(mblFeatureId);
//Add 2nd property to the feature mobileFeatureProperty.setProperty(MBL_FEATURE_PROP_1);
mobileFeatureProperty.setProperty(MBL_FEATURE_PROP_2); boolean status1 = mobileFeaturePropertyDAO.addMobileFeatureProperty(mobileFeatureProperty);
boolean status2 = mobileFeaturePropertyDAO.addMobileFeatureProperty(mobileFeatureProperty);
try { //Add 2nd property to the feature
conn = DriverManager.getConnection(testDBConfiguration.getConnectionURL()); mobileFeatureProperty.setProperty(MBL_FEATURE_PROP_2);
String query = boolean status2 = mobileFeaturePropertyDAO.addMobileFeatureProperty(mobileFeatureProperty);
"SELECT FEATURE_ID, PROPERTY FROM AD_FEATURE_PROPERTY WHERE FEATURE_ID = ?"; try {
preparedStatement = conn.prepareStatement(query); conn = DriverManager.getConnection(testDBConfiguration.getConnectionURL());
preparedStatement.setInt(1, mblFeatureId); String query =
ResultSet resultSet = preparedStatement.executeQuery(); "SELECT FEATURE_ID, PROPERTY FROM AD_FEATURE_PROPERTY WHERE FEATURE_ID = ?";
preparedStatement = conn.prepareStatement(query);
while (resultSet.next()) { preparedStatement.setInt(1, mblFeatureId);
mobileFeatureProperty = new MobileFeatureProperty(); ResultSet resultSet = preparedStatement.executeQuery();
mobileFeatureProperty.setFeatureID(resultSet.getInt(1));
mobileFeatureProperty.setProperty(resultSet.getString(2)); while (resultSet.next()) {
propertyList.add(mobileFeatureProperty); mobileFeatureProperty = new MobileFeatureProperty();
} mobileFeatureProperty.setFeatureID(resultSet.getInt(1));
} catch (SQLException e) { mobileFeatureProperty.setProperty(resultSet.getString(2));
String msg = "Error in retrieving Mobile Feature data "; propertyList.add(mobileFeatureProperty);
log.error(msg, e); }
throw new MobileDeviceManagementDAOException(msg, e); } catch (SQLException e) {
} finally { String msg = "Error in retrieving Mobile Feature data ";
MobileDatabaseUtils.cleanupResources(conn, preparedStatement, null); log.error(msg, e);
} throw new MobileDeviceManagementDAOException(msg, e);
Assert.assertTrue(status1, "MobileFeatureProperty1 has added "); } finally {
Assert.assertTrue(status2, "MobileFeatureProperty2 has added "); MobileDatabaseUtils.cleanupResources(conn, preparedStatement, null);
Assert.assertTrue(propertyList.size() == 2, "MobileFeatureProperties have retrieved "); }
Assert.assertTrue(status1, "MobileFeatureProperty1 has added ");
for (MobileFeatureProperty mblFeatureProperty : propertyList) { Assert.assertTrue(status2, "MobileFeatureProperty2 has added ");
Assert.assertNotNull(mblFeatureProperty.getProperty(), Assert.assertTrue(propertyList.size() == 2, "MobileFeatureProperties have retrieved ");
"MobileFeatureProperty property has persisted ");
Assert.assertNotNull(mblFeatureProperty.getFeatureID(), for (MobileFeatureProperty mblFeatureProperty : propertyList) {
"MobileFeatureProperty feature-id has persisted "); Assert.assertNotNull(mblFeatureProperty.getProperty(),
} "MobileFeatureProperty property has persisted ");
Assert.assertNotNull(mblFeatureProperty.getFeatureID(),
} "MobileFeatureProperty feature-id has persisted ");
}
@Test(dependsOnMethods = { "addMobileFeaturePropertyTest" })
public void getMobileFeaturePropertyTest() }
throws MobileDeviceManagementDAOException {
MobileFeatureProperty mobileFeatureProperty = @Test(dependsOnMethods = { "addMobileFeaturePropertyTest" })
mobileFeaturePropertyDAO.getMobileFeatureProperty(MBL_FEATURE_PROP_1); public void getMobileFeaturePropertyTest()
Assert.assertNotNull(mobileFeatureProperty, "MobileFeatureProperty has retrieved "); throws MobileDeviceManagementDAOException {
Assert.assertEquals(MBL_FEATURE_PROP_1, mobileFeatureProperty.getProperty(), MobileFeatureProperty mobileFeatureProperty =
"MobileFeatureProperty property has retrieved "); mobileFeaturePropertyDAO.getMobileFeatureProperty(MBL_FEATURE_PROP_1);
Assert.assertTrue(mblFeatureId == mobileFeatureProperty.getFeatureID(), Assert.assertNotNull(mobileFeatureProperty, "MobileFeatureProperty has retrieved ");
"MobileFeatureProperty featureId has retrieved "); Assert.assertEquals(MBL_FEATURE_PROP_1, mobileFeatureProperty.getProperty(),
} "MobileFeatureProperty property has retrieved ");
Assert.assertTrue(mblFeatureId == mobileFeatureProperty.getFeatureID(),
@Test(dependsOnMethods = { "addMobileFeaturePropertyTest" }) "MobileFeatureProperty featureId has retrieved ");
public void getFeaturePropertyOfFeatureTest() }
throws MobileDeviceManagementDAOException {
List<MobileFeatureProperty> mobileFeatureProperties = @Test(dependsOnMethods = { "addMobileFeaturePropertyTest" })
mobileFeaturePropertyDAO.getFeaturePropertiesOfFeature(mblFeatureId); public void getFeaturePropertyOfFeatureTest()
Assert.assertNotNull(mobileFeatureProperties, "MobileFeatureProperty list has retrieved "); throws MobileDeviceManagementDAOException {
Assert.assertTrue(mobileFeatureProperties.size() == 2, List<MobileFeatureProperty> mobileFeatureProperties =
"MobileFeatureProperties have fetched "); mobileFeaturePropertyDAO.getFeaturePropertiesOfFeature(mblFeatureId);
for (MobileFeatureProperty mblFeatureProperty : mobileFeatureProperties) { Assert.assertNotNull(mobileFeatureProperties, "MobileFeatureProperty list has retrieved ");
Assert.assertNotNull(mblFeatureProperty.getProperty(), Assert.assertTrue(mobileFeatureProperties.size() == 2,
"MobileFeatureProperty property has fetched "); "MobileFeatureProperties have fetched ");
Assert.assertNotNull(mblFeatureProperty.getFeatureID(), for (MobileFeatureProperty mblFeatureProperty : mobileFeatureProperties) {
"MobileFeatureProperty feature-id has fetched "); Assert.assertNotNull(mblFeatureProperty.getProperty(),
} "MobileFeatureProperty property has fetched ");
} Assert.assertNotNull(mblFeatureProperty.getFeatureID(),
"MobileFeatureProperty feature-id has fetched ");
@Test(dependsOnMethods = { "addMobileFeaturePropertyTest", "getMobileFeaturePropertyTest", }
"getFeaturePropertyOfFeatureTest" }, expectedExceptions = MobileDeviceManagementDAOException.class) }
public void updateMobileFeaturePropertyTest() throws MobileDeviceManagementDAOException {
//Update 1st property to a non-exist feature @Test(dependsOnMethods = { "addMobileFeaturePropertyTest", "getMobileFeaturePropertyTest",
MobileFeatureProperty mobileFeatureProperty = new MobileFeatureProperty(); "getFeaturePropertyOfFeatureTest" }, expectedExceptions = MobileDeviceManagementDAOException.class)
mobileFeatureProperty.setFeatureID(2); public void updateMobileFeaturePropertyTest() throws MobileDeviceManagementDAOException {
mobileFeatureProperty.setProperty(MBL_FEATURE_PROP_1); //Update 1st property to a non-exist feature
mobileFeaturePropertyDAO.updateMobileFeatureProperty(mobileFeatureProperty); MobileFeatureProperty mobileFeatureProperty = new MobileFeatureProperty();
} mobileFeatureProperty.setFeatureID(2);
mobileFeatureProperty.setProperty(MBL_FEATURE_PROP_1);
@Test(dependsOnMethods = { "addMobileFeaturePropertyTest", "getMobileFeaturePropertyTest", mobileFeaturePropertyDAO.updateMobileFeatureProperty(mobileFeatureProperty);
"getFeaturePropertyOfFeatureTest" }) }
public void deleteMobileFeaturePropertyTest()
throws MobileDeviceManagementDAOException { @Test(dependsOnMethods = { "addMobileFeaturePropertyTest", "getMobileFeaturePropertyTest",
Connection conn = null; "getFeaturePropertyOfFeatureTest" })
PreparedStatement preparedStatement = null; public void deleteMobileFeaturePropertyTest()
boolean status = throws MobileDeviceManagementDAOException {
mobileFeaturePropertyDAO.deleteMobileFeatureProperty(MBL_FEATURE_PROP_2); Connection conn = null;
try { PreparedStatement preparedStatement = null;
conn = DriverManager.getConnection(testDBConfiguration.getConnectionURL()); boolean status =
String query = mobileFeaturePropertyDAO.deleteMobileFeatureProperty(MBL_FEATURE_PROP_2);
"SELECT PROPERTY, FEATURE_ID FROM AD_FEATURE_PROPERTY WHERE PROPERTY = ?"; try {
preparedStatement = conn.prepareStatement(query); conn = DriverManager.getConnection(testDBConfiguration.getConnectionURL());
preparedStatement.setString(1, MBL_FEATURE_PROP_2); String query =
ResultSet resultSet = preparedStatement.executeQuery(); "SELECT PROPERTY, FEATURE_ID FROM AD_FEATURE_PROPERTY WHERE PROPERTY = ?";
preparedStatement = conn.prepareStatement(query);
if (resultSet.next()) { preparedStatement.setString(1, MBL_FEATURE_PROP_2);
status = false; ResultSet resultSet = preparedStatement.executeQuery();
}
} catch (SQLException e) { if (resultSet.next()) {
String msg = "Error in retrieving MobileFeatureProperty data "; status = false;
log.error(msg, e); }
throw new MobileDeviceManagementDAOException(msg, e); } catch (SQLException e) {
} finally { String msg = "Error in retrieving MobileFeatureProperty data ";
MobileDatabaseUtils.cleanupResources(conn, preparedStatement, null); log.error(msg, e);
} throw new MobileDeviceManagementDAOException(msg, e);
Assert.assertTrue(status, "MobileFeatureProperty has deleted "); } finally {
} MobileDatabaseUtils.cleanupResources(conn, preparedStatement, null);
}
@Test(dependsOnMethods = { "addMobileFeaturePropertyTest", "getMobileFeaturePropertyTest", Assert.assertTrue(status, "MobileFeatureProperty has deleted ");
"getFeaturePropertyOfFeatureTest" , "updateMobileFeaturePropertyTest", }
"deleteMobileFeaturePropertyTest"})
public void deleteMobileFeaturePropertiesOfFeatureTest() @Test(dependsOnMethods = { "addMobileFeaturePropertyTest", "getMobileFeaturePropertyTest",
throws MobileDeviceManagementDAOException { "getFeaturePropertyOfFeatureTest", "updateMobileFeaturePropertyTest",
Connection conn = null; "deleteMobileFeaturePropertyTest" })
PreparedStatement preparedStatement = null; public void deleteMobileFeaturePropertiesOfFeatureTest()
boolean status = throws MobileDeviceManagementDAOException {
mobileFeaturePropertyDAO.deleteMobileFeaturePropertiesOfFeature(mblFeatureId); Connection conn = null;
try { PreparedStatement preparedStatement = null;
conn = DriverManager.getConnection(testDBConfiguration.getConnectionURL()); boolean status =
String query = mobileFeaturePropertyDAO.deleteMobileFeaturePropertiesOfFeature(mblFeatureId);
"SELECT PROPERTY, FEATURE_ID FROM AD_FEATURE_PROPERTY WHERE FEATURE_ID = ?"; try {
preparedStatement = conn.prepareStatement(query); conn = DriverManager.getConnection(testDBConfiguration.getConnectionURL());
preparedStatement.setInt(1, mblFeatureId); String query =
ResultSet resultSet = preparedStatement.executeQuery(); "SELECT PROPERTY, FEATURE_ID FROM AD_FEATURE_PROPERTY WHERE FEATURE_ID = ?";
preparedStatement = conn.prepareStatement(query);
if (resultSet.next()) { preparedStatement.setInt(1, mblFeatureId);
status = false; ResultSet resultSet = preparedStatement.executeQuery();
}
} catch (SQLException e) { if (resultSet.next()) {
String msg = "Error in retrieving MobileFeatureProperty data "; status = false;
log.error(msg, e); }
throw new MobileDeviceManagementDAOException(msg, e); } catch (SQLException e) {
} finally { String msg = "Error in retrieving MobileFeatureProperty data ";
MobileDatabaseUtils.cleanupResources(conn, preparedStatement, null); log.error(msg, e);
} throw new MobileDeviceManagementDAOException(msg, e);
Assert.assertTrue(status, "MobileFeatureProperties has deleted "); } finally {
} MobileDatabaseUtils.cleanupResources(conn, preparedStatement, null);
}
Assert.assertTrue(status, "MobileFeatureProperties has deleted ");
}
} }

Loading…
Cancel
Save