@Override
  public Feature addFeature(Feature feature) throws FeatureManagementException {
    try {
      PolicyManagementDAOFactory.beginTransaction();
      feature = featureDAO.addFeature(feature);
      PolicyManagementDAOFactory.commitTransaction();

    } catch (PolicyManagerDAOException e) {
      try {
        PolicyManagementDAOFactory.rollbackTransaction();
      } catch (PolicyManagerDAOException e1) {
        log.warn("Unable to roll back the transaction");
      }
      String msg = "Error occurred while adding feature (" + feature.getName() + ")";
      log.error(msg, e);
      throw new FeatureManagementException(msg, e);
    } catch (FeatureManagerDAOException e) {
      try {
        PolicyManagementDAOFactory.rollbackTransaction();
      } catch (PolicyManagerDAOException e1) {
        log.warn("Unable to roll back the transaction");
      }
      String msg = "Error occurred while adding feature (" + feature.getName() + ")";
      log.error(msg, e);
      throw new FeatureManagementException(msg, e);
    }
    return feature;
  }
 @Override
 public boolean deleteFeature(Feature feature) throws FeatureManagementException {
   boolean bool;
   try {
     PolicyManagementDAOFactory.beginTransaction();
     bool = featureDAO.deleteFeature(feature.getId());
     PolicyManagementDAOFactory.commitTransaction();
   } catch (FeatureManagerDAOException e) {
     try {
       PolicyManagementDAOFactory.rollbackTransaction();
     } catch (PolicyManagerDAOException e1) {
       log.warn("Unable to roll back the transaction");
     }
     String msg = "Error occurred while deleting the feature (" + feature.getName() + ")";
     log.error(msg, e);
     throw new FeatureManagementException(msg, e);
   } catch (PolicyManagerDAOException e) {
     try {
       PolicyManagementDAOFactory.rollbackTransaction();
     } catch (PolicyManagerDAOException e1) {
       log.warn("Unable to roll back the transaction");
     }
     String msg =
         "Error occurred while deleting the feature (" + feature.getName() + ") from database";
     log.error(msg, e);
     throw new FeatureManagementException(msg, e);
   }
   return bool;
 }
 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;
 }
 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 List<Feature> getMissingFeatures(
     List<Feature> supportedFeatures, List<Feature> existingFeatures) {
   HashMap<String, Feature> featureHashMap = new HashMap();
   for (Feature feature : existingFeatures) {
     featureHashMap.put(feature.getCode(), feature);
   }
   List<Feature> missingFeatures = new ArrayList<Feature>();
   for (Feature supportedFeature : supportedFeatures) {
     if (featureHashMap.get(supportedFeature.getCode()) != null) {
       continue;
     }
     missingFeatures.add(supportedFeature);
   }
   return missingFeatures;
 }