|
|
|
@ -240,12 +240,14 @@ public class PolicyManagerImpl implements PolicyManager {
|
|
|
|
|
@Override
|
|
|
|
|
public boolean deletePolicy(Policy policy) throws PolicyManagementException {
|
|
|
|
|
|
|
|
|
|
boolean bool;
|
|
|
|
|
try {
|
|
|
|
|
PolicyManagementDAOFactory.beginTransaction();
|
|
|
|
|
bool = policyDAO.deletePolicy(policy);
|
|
|
|
|
policyDAO.deleteAllPolicyRelatedConfigs(policy.getId());
|
|
|
|
|
policyDAO.deletePolicy(policy.getId());
|
|
|
|
|
featureDAO.deleteFeaturesOfProfile(policy.getProfileId());
|
|
|
|
|
profileDAO.deleteProfile(policy.getProfileId());
|
|
|
|
|
PolicyManagementDAOFactory.commitTransaction();
|
|
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
} catch (PolicyManagerDAOException e) {
|
|
|
|
|
try {
|
|
|
|
|
PolicyManagementDAOFactory.rollbackTransaction();
|
|
|
|
@ -256,18 +258,48 @@ public class PolicyManagerImpl implements PolicyManager {
|
|
|
|
|
+ policy.getId() + " - " + policy.getPolicyName() + ")";
|
|
|
|
|
log.error(msg, e);
|
|
|
|
|
throw new PolicyManagementException(msg, e);
|
|
|
|
|
} catch (ProfileManagerDAOException e) {
|
|
|
|
|
try {
|
|
|
|
|
PolicyManagementDAOFactory.rollbackTransaction();
|
|
|
|
|
} catch (PolicyManagerDAOException e1) {
|
|
|
|
|
log.warn("Error occurred while roll backing the transaction.");
|
|
|
|
|
}
|
|
|
|
|
return bool;
|
|
|
|
|
String msg = "Error occurred while deleting the profile for policy ("
|
|
|
|
|
+ policy.getId() + ")";
|
|
|
|
|
log.error(msg, e);
|
|
|
|
|
throw new PolicyManagementException(msg, e);
|
|
|
|
|
} catch (FeatureManagerDAOException e) {
|
|
|
|
|
try {
|
|
|
|
|
PolicyManagementDAOFactory.rollbackTransaction();
|
|
|
|
|
} catch (PolicyManagerDAOException e1) {
|
|
|
|
|
log.warn("Error occurred while roll backing the transaction.");
|
|
|
|
|
}
|
|
|
|
|
String msg = "Error occurred while deleting the profile features for policy ("
|
|
|
|
|
+ policy.getId() + ")";
|
|
|
|
|
log.error(msg, e);
|
|
|
|
|
throw new PolicyManagementException(msg, e);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public boolean deletePolicy(int policyId) throws PolicyManagementException {
|
|
|
|
|
boolean bool;
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
PolicyManagementDAOFactory.beginTransaction();
|
|
|
|
|
Policy policy = policyDAO.getPolicy(policyId);
|
|
|
|
|
policyDAO.deleteAllPolicyRelatedConfigs(policyId);
|
|
|
|
|
bool = policyDAO.deletePolicy(policyId);
|
|
|
|
|
policyDAO.deletePolicy(policyId);
|
|
|
|
|
|
|
|
|
|
if (log.isDebugEnabled()) {
|
|
|
|
|
log.debug("Profile ID: " + policy.getProfileId());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
featureDAO.deleteFeaturesOfProfile(policy.getProfileId());
|
|
|
|
|
|
|
|
|
|
profileDAO.deleteProfile(policy.getProfileId());
|
|
|
|
|
PolicyManagementDAOFactory.commitTransaction();
|
|
|
|
|
return true;
|
|
|
|
|
|
|
|
|
|
} catch (PolicyManagerDAOException e) {
|
|
|
|
|
try {
|
|
|
|
@ -279,13 +311,32 @@ public class PolicyManagerImpl implements PolicyManager {
|
|
|
|
|
+ policyId + ")";
|
|
|
|
|
log.error(msg, e);
|
|
|
|
|
throw new PolicyManagementException(msg, e);
|
|
|
|
|
} catch (ProfileManagerDAOException e) {
|
|
|
|
|
try {
|
|
|
|
|
PolicyManagementDAOFactory.rollbackTransaction();
|
|
|
|
|
} catch (PolicyManagerDAOException e1) {
|
|
|
|
|
log.warn("Error occurred while roll backing the transaction.");
|
|
|
|
|
}
|
|
|
|
|
String msg = "Error occurred while deleting the profile for policy ("
|
|
|
|
|
+ policyId + ")";
|
|
|
|
|
log.error(msg, e);
|
|
|
|
|
throw new PolicyManagementException(msg, e);
|
|
|
|
|
} catch (FeatureManagerDAOException e) {
|
|
|
|
|
try {
|
|
|
|
|
PolicyManagementDAOFactory.rollbackTransaction();
|
|
|
|
|
} catch (PolicyManagerDAOException e1) {
|
|
|
|
|
log.warn("Error occurred while roll backing the transaction.");
|
|
|
|
|
}
|
|
|
|
|
String msg = "Error occurred while deleting the profile features for policy ("
|
|
|
|
|
+ policyId + ")";
|
|
|
|
|
log.error(msg, e);
|
|
|
|
|
throw new PolicyManagementException(msg, e);
|
|
|
|
|
}
|
|
|
|
|
return bool;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public Policy addPolicyToDevice(List<DeviceIdentifier> deviceIdentifierList, Policy policy) throws
|
|
|
|
|
PolicyManagementException {
|
|
|
|
|
public Policy addPolicyToDevice(List<DeviceIdentifier> deviceIdentifierList, Policy policy)
|
|
|
|
|
throws PolicyManagementException {
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
PolicyManagementDAOFactory.beginTransaction();
|
|
|
|
@ -658,8 +709,7 @@ public class PolicyManagerImpl implements PolicyManager {
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void addAppliedPolicyFeaturesToDevice(DeviceIdentifier deviceIdentifier, int policyId,
|
|
|
|
|
List<ProfileFeature> profileFeatures) throws
|
|
|
|
|
PolicyManagementException {
|
|
|
|
|
List<ProfileFeature> profileFeatures) throws PolicyManagementException {
|
|
|
|
|
|
|
|
|
|
int deviceId = -1;
|
|
|
|
|
try {
|
|
|
|
@ -693,8 +743,8 @@ public class PolicyManagerImpl implements PolicyManager {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void addAppliedPolicyToDevice(DeviceIdentifier deviceIdentifier, Policy policy) throws
|
|
|
|
|
PolicyManagementException {
|
|
|
|
|
public void addAppliedPolicyToDevice(DeviceIdentifier deviceIdentifier, Policy policy)
|
|
|
|
|
throws PolicyManagementException {
|
|
|
|
|
|
|
|
|
|
int deviceId = -1;
|
|
|
|
|
try {
|
|
|
|
|