@Override
 public boolean deleteFeaturesOfProfile(Profile profile) throws FeatureManagementException {
   boolean bool;
   try {
     PolicyManagementDAOFactory.beginTransaction();
     bool = featureDAO.deleteFeaturesOfProfile(profile);
     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 of - profile ("
             + profile.getProfileName()
             + ")";
     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 of - profile ("
             + profile.getProfileName()
             + ") from database";
     log.error(msg, e);
     throw new FeatureManagementException(msg, e);
   }
   return bool;
 }
  @Override
  public List<Feature> addFeatures(List<Feature> features) throws FeatureManagementException {
    try {
      PolicyManagementDAOFactory.beginTransaction();
      features = featureDAO.addFeatures(features);
      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 (" + features.size() + ")";
      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 (" + features.size() + ")";
      log.error(msg, e);
      throw new FeatureManagementException(msg, e);
    }

    return features;
  }
 @Override
 public boolean deleteFeature(int featureId) throws FeatureManagementException {
   boolean bool;
   try {
     PolicyManagementDAOFactory.beginTransaction();
     bool = featureDAO.deleteFeature(featureId);
     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 - id (" + featureId + ")";
     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 - id (" + featureId + ") from database.";
     log.error(msg, e);
     throw new FeatureManagementException(msg, e);
   }
   return bool;
 }
 @Override
 public List<ProfileFeature> updateProfileFeatures(List<ProfileFeature> features, int profileId)
     throws FeatureManagementException {
   try {
     PolicyManagementDAOFactory.beginTransaction();
     features = featureDAO.updateProfileFeatures(features, profileId);
     PolicyManagementDAOFactory.commitTransaction();
   } catch (FeatureManagerDAOException e) {
     try {
       PolicyManagementDAOFactory.rollbackTransaction();
     } catch (PolicyManagerDAOException e1) {
       log.warn("Unable to roll back the transaction");
     }
     String msg = "Error occurred while updating the features to profile id (" + profileId + ")";
     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 updating the features to profile id ("
             + profileId
             + ") to the database";
     log.error(msg, e);
     throw new FeatureManagementException(msg, e);
   }
   return features;
 }
  @Override
  public ProfileFeature addProfileFeature(ProfileFeature feature, int profileId)
      throws FeatureManagementException {
    try {
      PolicyManagementDAOFactory.beginTransaction();
      feature = featureDAO.addProfileFeature(feature, profileId);
      PolicyManagementDAOFactory.commitTransaction();

    } catch (PolicyManagerDAOException e) {
      String msg =
          "Error occurred while adding profile feature ("
              + feature.getFeatureCode()
              + " - "
              + profileId
              + ")";
      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 profile feature ("
              + feature.getFeatureCode()
              + " - "
              + profileId
              + ") to database.";
      log.error(msg, e);
      throw new FeatureManagementException(msg, e);
    }
    return feature;
  }
  @Override
  public Feature updateFeature(Feature feature) throws FeatureManagementException {
    try {
      PolicyManagementDAOFactory.beginTransaction();
      feature = featureDAO.updateFeature(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 updating 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 updating feature (" + feature.getName() + ")";
      log.error(msg, e);
      throw new FeatureManagementException(msg, e);
    }
    return feature;
  }
 public FeatureManagerImpl() {
   featureDAO = PolicyManagementDAOFactory.getFeatureDAO();
 }