diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/ios/IOSDeviceManager.java b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/ios/IOSDeviceManager.java index c96ede764..6bdd521b4 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/ios/IOSDeviceManager.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/ios/IOSDeviceManager.java @@ -34,8 +34,9 @@ import java.util.List; */ public class IOSDeviceManager implements DeviceManager { - private MobileDeviceManagementDAOFactory mobileDeviceManagementDAOFactory; - private static final Log log = LogFactory.getLog(IOSDeviceManager.class); + private static final Log log = LogFactory.getLog(IOSDeviceManager.class); + private MobileDeviceManagementDAOFactory mobileDeviceManagementDAOFactory; + private IOSFeatureManager iosFeatureManager; @Override public String getProviderType() { @@ -45,11 +46,12 @@ public class IOSDeviceManager implements DeviceManager { public IOSDeviceManager() { mobileDeviceManagementDAOFactory = new MobileDeviceManagementDAOFactory(DeviceManagementConstants .MobileDeviceTypes.MOBILE_DEVICE_TYPE_IOS); + iosFeatureManager = new IOSFeatureManager(); } @Override public FeatureManager getFeatureManager() { - return null; + return iosFeatureManager; } @Override diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/ios/IOSFeatureManager.java b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/ios/IOSFeatureManager.java index e4ab47ade..395695848 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/ios/IOSFeatureManager.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/ios/IOSFeatureManager.java @@ -18,16 +18,21 @@ */ package org.wso2.carbon.device.mgt.mobile.impl.ios; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; import org.wso2.carbon.device.mgt.common.DeviceManagementException; import org.wso2.carbon.device.mgt.common.Feature; 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.impl.ios.dao.FeatureManagementDAOException; import org.wso2.carbon.device.mgt.mobile.impl.ios.dao.FeatureManagementDAOFactory; import java.util.List; public class IOSFeatureManager implements FeatureManager { + private static final Log log = LogFactory.getLog(IOSFeatureManager.class); + private FeatureDAO featureDAO; public IOSFeatureManager() { @@ -36,22 +41,70 @@ public class IOSFeatureManager implements FeatureManager { @Override public boolean addFeature(Feature feature) throws DeviceManagementException { - return false; + try { + FeatureManagementDAOFactory.beginTransaction(); + featureDAO.addFeature(feature); + FeatureManagementDAOFactory.commitTransaction(); + return true; + } catch (FeatureManagementDAOException e) { + try { + FeatureManagementDAOFactory.rollbackTransaction(); + } catch (FeatureManagementDAOException e1) { + log.warn("Error occurred while roll-backing the transaction", e); + } + throw new DeviceManagementException("Error occurred while adding the feature", e); + } } @Override - public Feature getFeature(String s) throws DeviceManagementException { - return null; + public Feature getFeature(String name) throws DeviceManagementException { + try { + FeatureManagementDAOFactory.beginTransaction(); + Feature feature = featureDAO.getFeature(name); + FeatureManagementDAOFactory.commitTransaction(); + return feature; + } catch (FeatureManagementDAOException 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); + } } @Override public List getFeatures() throws DeviceManagementException { - return null; + try { + FeatureManagementDAOFactory.beginTransaction(); + List features = featureDAO.getFeatures(); + FeatureManagementDAOFactory.commitTransaction(); + return features; + } catch (FeatureManagementDAOException 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 list of features registered " + + "for Android platform", e); + } } @Override - public boolean removeFeature(String s) throws DeviceManagementException { - return false; + public boolean removeFeature(String name) throws DeviceManagementException { + try { + FeatureManagementDAOFactory.beginTransaction(); + featureDAO.removeFeature(name); + FeatureManagementDAOFactory.commitTransaction(); + return true; + } catch (FeatureManagementDAOException e) { + try { + FeatureManagementDAOFactory.rollbackTransaction(); + } catch (FeatureManagementDAOException e1) { + log.warn("Error occurred while roll-backing the transaction", e); + } + throw new DeviceManagementException("Error occurred while removing the feature", e); + } } - }