|
|
|
@ -122,7 +122,7 @@ public class PolicyManagerImpl implements PolicyManager {
|
|
|
|
|
log.warn("Error occurred while roll backing the transaction.");
|
|
|
|
|
}
|
|
|
|
|
String msg = "Error occurred while adding the policy (" +
|
|
|
|
|
policy.getId() + " - " + policy.getPolicyName() + ")";
|
|
|
|
|
policy.getId() + " - " + policy.getPolicyName() + ")";
|
|
|
|
|
log.error(msg, e);
|
|
|
|
|
throw new PolicyManagementException(msg, e);
|
|
|
|
|
|
|
|
|
@ -133,7 +133,7 @@ public class PolicyManagerImpl implements PolicyManager {
|
|
|
|
|
log.warn("Error occurred while roll backing the transaction.");
|
|
|
|
|
}
|
|
|
|
|
String msg = "Error occurred while adding the profile related to policy (" +
|
|
|
|
|
policy.getId() + " - " + policy.getPolicyName() + ")";
|
|
|
|
|
policy.getId() + " - " + policy.getPolicyName() + ")";
|
|
|
|
|
log.error(msg, e);
|
|
|
|
|
throw new PolicyManagementException(msg, e);
|
|
|
|
|
} catch (FeatureManagerDAOException e) {
|
|
|
|
@ -143,7 +143,7 @@ public class PolicyManagerImpl implements PolicyManager {
|
|
|
|
|
log.warn("Error occurred while roll backing the transaction.");
|
|
|
|
|
}
|
|
|
|
|
String msg = "Error occurred while adding the features of profile related to policy (" +
|
|
|
|
|
policy.getId() + " - " + policy.getPolicyName() + ")";
|
|
|
|
|
policy.getId() + " - " + policy.getPolicyName() + ")";
|
|
|
|
|
log.error(msg, e);
|
|
|
|
|
throw new PolicyManagementException(msg, e);
|
|
|
|
|
}
|
|
|
|
@ -206,7 +206,7 @@ public class PolicyManagerImpl implements PolicyManager {
|
|
|
|
|
log.warn("Error occurred while roll backing the transaction.");
|
|
|
|
|
}
|
|
|
|
|
String msg = "Error occurred while updating the policy ("
|
|
|
|
|
+ policy.getId() + " - " + policy.getPolicyName() + ")";
|
|
|
|
|
+ policy.getId() + " - " + policy.getPolicyName() + ")";
|
|
|
|
|
log.error(msg, e);
|
|
|
|
|
throw new PolicyManagementException(msg, e);
|
|
|
|
|
}
|
|
|
|
@ -236,12 +236,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();
|
|
|
|
@ -249,21 +251,51 @@ public class PolicyManagerImpl implements PolicyManager {
|
|
|
|
|
log.warn("Error occurred while roll backing the transaction.");
|
|
|
|
|
}
|
|
|
|
|
String msg = "Error occurred while deleting the policy ("
|
|
|
|
|
+ policy.getId() + " - " + policy.getPolicyName() + ")";
|
|
|
|
|
+ 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.");
|
|
|
|
|
}
|
|
|
|
|
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);
|
|
|
|
|
}
|
|
|
|
|
return bool;
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@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(policy.getProfileId() + " ----------------------------------");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
featureDAO.deleteFeaturesOfProfile(policy.getProfileId());
|
|
|
|
|
|
|
|
|
|
profileDAO.deleteProfile(policy.getProfileId());
|
|
|
|
|
PolicyManagementDAOFactory.commitTransaction();
|
|
|
|
|
return true;
|
|
|
|
|
|
|
|
|
|
} catch (PolicyManagerDAOException e) {
|
|
|
|
|
try {
|
|
|
|
@ -272,16 +304,35 @@ public class PolicyManagerImpl implements PolicyManager {
|
|
|
|
|
log.warn("Error occurred while roll backing the transaction.");
|
|
|
|
|
}
|
|
|
|
|
String msg = "Error occurred while deleting the policy ("
|
|
|
|
|
+ policyId + ")";
|
|
|
|
|
+ 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 {
|
|
|
|
|
PolicyManagementException {
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
PolicyManagementDAOFactory.beginTransaction();
|
|
|
|
@ -315,7 +366,7 @@ public class PolicyManagerImpl implements PolicyManager {
|
|
|
|
|
log.warn("Error occurred while roll backing the transaction.");
|
|
|
|
|
}
|
|
|
|
|
String msg = "Error occurred while adding the policy ("
|
|
|
|
|
+ policy.getId() + " - " + policy.getPolicyName() + ")";
|
|
|
|
|
+ policy.getId() + " - " + policy.getPolicyName() + ")";
|
|
|
|
|
log.error(msg, e);
|
|
|
|
|
throw new PolicyManagementException(msg, e);
|
|
|
|
|
} catch (DeviceManagementDAOException e) {
|
|
|
|
@ -362,7 +413,7 @@ public class PolicyManagerImpl implements PolicyManager {
|
|
|
|
|
log.warn("Error occurred while roll backing the transaction.");
|
|
|
|
|
}
|
|
|
|
|
String msg = "Error occurred while adding the policy ("
|
|
|
|
|
+ policy.getId() + " - " + policy.getPolicyName() + ")";
|
|
|
|
|
+ policy.getId() + " - " + policy.getPolicyName() + ")";
|
|
|
|
|
log.error(msg, e);
|
|
|
|
|
throw new PolicyManagementException(msg, e);
|
|
|
|
|
}
|
|
|
|
@ -400,7 +451,7 @@ public class PolicyManagerImpl implements PolicyManager {
|
|
|
|
|
log.warn("Error occurred while roll backing the transaction.");
|
|
|
|
|
}
|
|
|
|
|
String msg = "Error occurred while adding the policy ("
|
|
|
|
|
+ policy.getId() + " - " + policy.getPolicyName() + ") to user list.";
|
|
|
|
|
+ policy.getId() + " - " + policy.getPolicyName() + ") to user list.";
|
|
|
|
|
log.error(msg, e);
|
|
|
|
|
throw new PolicyManagementException(msg, e);
|
|
|
|
|
}
|
|
|
|
@ -534,12 +585,12 @@ public class PolicyManagerImpl implements PolicyManager {
|
|
|
|
|
Collections.sort(policies);
|
|
|
|
|
} catch (PolicyManagerDAOException e) {
|
|
|
|
|
String msg = "Error occurred while getting the policies for device identifier (" +
|
|
|
|
|
deviceIdentifier.getId() + " - " + deviceIdentifier.getType() + ")";
|
|
|
|
|
deviceIdentifier.getId() + " - " + deviceIdentifier.getType() + ")";
|
|
|
|
|
log.error(msg, e);
|
|
|
|
|
throw new PolicyManagementException(msg, e);
|
|
|
|
|
} catch (DeviceManagementDAOException e) {
|
|
|
|
|
String msg = "Error occurred while getting device related to device identifier (" +
|
|
|
|
|
deviceIdentifier.getId() + " - " + deviceIdentifier.getType() + ")";
|
|
|
|
|
deviceIdentifier.getId() + " - " + deviceIdentifier.getType() + ")";
|
|
|
|
|
log.error(msg, e);
|
|
|
|
|
throw new PolicyManagementException(msg, e);
|
|
|
|
|
}
|
|
|
|
@ -655,7 +706,7 @@ public class PolicyManagerImpl implements PolicyManager {
|
|
|
|
|
@Override
|
|
|
|
|
public void addAppliedPolicyFeaturesToDevice(DeviceIdentifier deviceIdentifier, int policyId,
|
|
|
|
|
List<ProfileFeature> profileFeatures) throws
|
|
|
|
|
PolicyManagementException {
|
|
|
|
|
PolicyManagementException {
|
|
|
|
|
|
|
|
|
|
int deviceId = -1;
|
|
|
|
|
try {
|
|
|
|
@ -677,7 +728,7 @@ public class PolicyManagerImpl implements PolicyManager {
|
|
|
|
|
log.warn("Error occurred while roll backing the transaction.");
|
|
|
|
|
}
|
|
|
|
|
String msg = "Error occurred while adding the evaluated policy to device (" +
|
|
|
|
|
deviceId + " - " + policyId + ")";
|
|
|
|
|
deviceId + " - " + policyId + ")";
|
|
|
|
|
log.error(msg, e);
|
|
|
|
|
throw new PolicyManagementException(msg, e);
|
|
|
|
|
} catch (DeviceManagementDAOException e) {
|
|
|
|
@ -690,7 +741,7 @@ public class PolicyManagerImpl implements PolicyManager {
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void addAppliedPolicyToDevice(DeviceIdentifier deviceIdentifier, Policy policy) throws
|
|
|
|
|
PolicyManagementException {
|
|
|
|
|
PolicyManagementException {
|
|
|
|
|
|
|
|
|
|
int deviceId = -1;
|
|
|
|
|
try {
|
|
|
|
@ -717,7 +768,7 @@ public class PolicyManagerImpl implements PolicyManager {
|
|
|
|
|
log.warn("Error occurred while roll backing the transaction.");
|
|
|
|
|
}
|
|
|
|
|
String msg = "Error occurred while adding the evaluated policy to device (" +
|
|
|
|
|
deviceId + " - " + policy.getId() + ")";
|
|
|
|
|
deviceId + " - " + policy.getId() + ")";
|
|
|
|
|
log.error(msg, e);
|
|
|
|
|
throw new PolicyManagementException(msg, e);
|
|
|
|
|
} catch (DeviceManagementDAOException e) {
|
|
|
|
@ -757,7 +808,7 @@ public class PolicyManagerImpl implements PolicyManager {
|
|
|
|
|
return true;
|
|
|
|
|
} catch (PolicyManagerDAOException e) {
|
|
|
|
|
String msg = "Error occurred while setting the policy has applied to device (" +
|
|
|
|
|
deviceIdentifier.getId() + ")";
|
|
|
|
|
deviceIdentifier.getId() + ")";
|
|
|
|
|
log.error(msg, e);
|
|
|
|
|
throw new PolicyManagementException(msg, e);
|
|
|
|
|
} catch (DeviceManagementDAOException e) {
|
|
|
|
|