Adding the policy priority changing dao methods

revert-70aa11f8
geethkokila 10 years ago
parent 29066134db
commit 6e18b7c11a

@ -38,6 +38,8 @@ public interface PolicyAdministratorPoint {
Policy updatePolicy(Policy policy) throws PolicyManagementException;
boolean updatePolicyPriorities(List<Policy> policies) throws PolicyManagementException;
boolean deletePolicy(Policy policy) throws PolicyManagementException;
boolean deletePolicy(int policyId) throws PolicyManagementException;

@ -145,31 +145,28 @@ public class PolicyDAOImpl implements PolicyDAO {
@Override
public boolean updatePolicyPriorities(List<Policy> policies) throws PolicyManagerDAOException {
/* Connection conn;
Connection conn;
PreparedStatement stmt = null;
try {
conn = this.getConnection();
String query = "UPDATE DM_POLICY SET PRIORITY = ? WHERE ID = ?";
stmt = conn.prepareStatement(query);
stmt.setString(1, policy.getPolicyName());
stmt.setInt(2, policy.getTenantId());
stmt.setInt(3, policy.getProfile().getProfileId());
stmt.setInt(4, policy.getPriorityId());
stmt.setString(5, policy.getCompliance());
stmt.setInt(6, policy.getId());
stmt.executeUpdate();
for (Policy policy : policies) {
stmt.setInt(1, policy.getPriorityId());
stmt.setInt(2, policy.getId());
stmt.addBatch();
}
stmt.executeBatch();
} catch (SQLException e) {
String msg = "Error occurred while updating policy (" + policy.getPolicyName() + ") in database.";
String msg = "Error occurred while updating policy priorities in database.";
log.error(msg, e);
throw new PolicyManagerDAOException(msg, e);
} finally {
PolicyManagementDAOUtil.cleanupResources(stmt, null);
}
return policy;*/
return false;
return true;
}
// @Override

@ -63,6 +63,11 @@ public class PolicyAdministratorPointImpl implements PolicyAdministratorPoint {
return policyManager.updatePolicy(policy);
}
@Override
public boolean updatePolicyPriorities(List<Policy> policies) throws PolicyManagementException {
return policyManager.updatePolicyPriorities(policies);
}
@Override
public boolean deletePolicy(Policy policy) throws PolicyManagementException {
return policyManager.deletePolicy(policy);
@ -198,4 +203,6 @@ public class PolicyAdministratorPointImpl implements PolicyAdministratorPoint {
public boolean deleteFeature(int featureId) throws FeatureManagementException {
return featureManager.deleteFeature(featureId);
}
}

@ -32,6 +32,8 @@ public interface PolicyManager {
Policy updatePolicy(Policy policy) throws PolicyManagementException;
boolean updatePolicyPriorities(List<Policy> policies) throws PolicyManagementException;
boolean deletePolicy(Policy policy) throws PolicyManagementException;
boolean deletePolicy(int policyId) throws PolicyManagementException;

@ -210,6 +210,26 @@ public class PolicyManagerImpl implements PolicyManager {
return policy;
}
@Override
public boolean updatePolicyPriorities(List<Policy> policies) throws PolicyManagementException {
boolean bool;
try {
PolicyManagementDAOFactory.beginTransaction();
bool = policyDAO.updatePolicyPriorities(policies);
PolicyManagementDAOFactory.commitTransaction();
} catch (PolicyManagerDAOException e) {
try {
PolicyManagementDAOFactory.rollbackTransaction();
} catch (PolicyManagerDAOException e1) {
log.warn("Error occurred while roll backing the transaction.");
}
String msg = "Error occurred while updating the policy priorities";
log.error(msg, e);
throw new PolicyManagementException(msg, e);
}
return bool;
}
@Override
public boolean deletePolicy(Policy policy) throws PolicyManagementException {

Loading…
Cancel
Save