Implementing FeatureDAO for iOS

revert-dabc3590
Dilshan Edirisuriya 10 years ago
parent a10d7ff04f
commit 951b9947d5

@ -34,8 +34,9 @@ import java.util.List;
*/ */
public class IOSDeviceManager implements DeviceManager { 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 @Override
public String getProviderType() { public String getProviderType() {
@ -45,11 +46,12 @@ public class IOSDeviceManager implements DeviceManager {
public IOSDeviceManager() { public IOSDeviceManager() {
mobileDeviceManagementDAOFactory = new MobileDeviceManagementDAOFactory(DeviceManagementConstants mobileDeviceManagementDAOFactory = new MobileDeviceManagementDAOFactory(DeviceManagementConstants
.MobileDeviceTypes.MOBILE_DEVICE_TYPE_IOS); .MobileDeviceTypes.MOBILE_DEVICE_TYPE_IOS);
iosFeatureManager = new IOSFeatureManager();
} }
@Override @Override
public FeatureManager getFeatureManager() { public FeatureManager getFeatureManager() {
return null; return iosFeatureManager;
} }
@Override @Override

@ -18,16 +18,21 @@
*/ */
package org.wso2.carbon.device.mgt.mobile.impl.ios; 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.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.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 org.wso2.carbon.device.mgt.mobile.impl.ios.dao.FeatureManagementDAOFactory;
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 FeatureDAO featureDAO; private FeatureDAO featureDAO;
public IOSFeatureManager() { public IOSFeatureManager() {
@ -36,22 +41,70 @@ public class IOSFeatureManager implements FeatureManager {
@Override @Override
public boolean addFeature(Feature feature) throws DeviceManagementException { 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 @Override
public Feature getFeature(String s) throws DeviceManagementException { public Feature getFeature(String name) throws DeviceManagementException {
return null; 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 @Override
public List<Feature> getFeatures() throws DeviceManagementException { public List<Feature> getFeatures() throws DeviceManagementException {
return null; try {
FeatureManagementDAOFactory.beginTransaction();
List<Feature> 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 @Override
public boolean removeFeature(String s) throws DeviceManagementException { public boolean removeFeature(String name) throws DeviceManagementException {
return false; 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);
}
} }
} }

Loading…
Cancel
Save