revert-70aa11f8
manoj 9 years ago
commit 302470ff8b

@ -36,6 +36,8 @@ public interface PolicyDAO {
Policy addPolicyToDevice(List<Device> devices, Policy policy) throws PolicyManagerDAOException;
boolean updatePolicyPriorities(List<Policy> policies) throws PolicyManagerDAOException;
// Policy addDatesToPolicy(Date startDate, Date endDate, Policy policy) throws PolicyManagerDAOException;
//
// Policy addTimesToPolicy(int startTime, int endTime, Policy policy) throws PolicyManagerDAOException;
@ -88,6 +90,8 @@ public interface PolicyDAO {
List<String> getPolicyAppliedRoles(int policyId) throws PolicyManagerDAOException;
List<String> getPolicyAppliedUsers(int policyId) throws PolicyManagerDAOException;
// PolicyTimes getTimesOfPolicy(Policy policy) throws PolicyManagerDAOException;
//
// PolicyDates getDatesOfPolicy(Policy policy) throws PolicyManagerDAOException;

@ -142,6 +142,36 @@ public class PolicyDAOImpl implements PolicyDAO {
return policy;
}
@Override
public boolean updatePolicyPriorities(List<Policy> policies) throws PolicyManagerDAOException {
/* 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();
} catch (SQLException e) {
String msg = "Error occurred while updating policy (" + policy.getPolicyName() + ") in database.";
log.error(msg, e);
throw new PolicyManagerDAOException(msg, e);
} finally {
PolicyManagementDAOUtil.cleanupResources(stmt, null);
}
return policy;*/
return false;
}
// @Override
// public Policy addDatesToPolicy(Date startDate, Date endDate, Policy policy) throws PolicyManagerDAOException {
//
@ -752,6 +782,36 @@ public class PolicyDAOImpl implements PolicyDAO {
}
}
@Override
public List<String> getPolicyAppliedUsers(int policyId) throws PolicyManagerDAOException {
Connection conn;
PreparedStatement stmt = null;
ResultSet resultSet = null;
List<String> users = new ArrayList<String>();
try {
conn = this.getConnection();
String query = "SELECT * FROM DM_USER_POLICY WHERE POLICY_ID = ?";
stmt = conn.prepareStatement(query);
stmt.setInt(1, policyId);
resultSet = stmt.executeQuery();
while (resultSet.next()) {
users.add(resultSet.getString("USERNAME"));
}
return users;
} catch (SQLException e) {
String msg = "Error occurred while getting the roles related to policies.";
log.error(msg, e);
throw new PolicyManagerDAOException(msg, e);
} finally {
PolicyManagementDAOUtil.cleanupResources(stmt, resultSet);
this.closeConnection();
}
}
// public PolicyTimes getTimesOfPolicy(Policy policy) throws PolicyManagerDAOException {
//

@ -88,7 +88,8 @@ public class PolicyAdministratorPointImpl implements PolicyAdministratorPoint {
return policyManager.getPolicies();
}
@Override public Policy getPolicy(int policyId) throws PolicyManagementException {
@Override
public Policy getPolicy(int policyId) throws PolicyManagementException {
return policyManager.getPolicy(policyId);
}
@ -184,34 +185,17 @@ public class PolicyAdministratorPointImpl implements PolicyAdministratorPoint {
@Override
public Feature addFeature(Feature feature) throws FeatureManagementException {
try {
return featureManager.addFeature(feature);
} catch (FeatureManagementException e) {
String msg = "Error occurred while persisting the feature.";
log.error(msg, e);
throw new FeatureManagementException(msg, e);
}
return featureManager.addFeature(feature);
}
@Override
public Feature updateFeature(Feature feature) throws FeatureManagementException {
try {
return featureManager.updateFeature(feature);
} catch (FeatureManagementException e) {
String msg = "Error occurred while persisting the feature.";
log.error(msg, e);
throw new FeatureManagementException(msg, e);
}
return featureManager.updateFeature(feature);
}
@Override
public boolean deleteFeature(int featureId) throws FeatureManagementException {
try {
return featureManager.deleteFeature(featureId);
} catch (FeatureManagementException e) {
String msg = "Error occurred while deleting the feature.";
log.error(msg, e);
throw new FeatureManagementException(msg, e);
}
return featureManager.deleteFeature(featureId);
}
}

@ -468,6 +468,7 @@ public class PolicyManagerImpl implements PolicyManager {
}
policy.setDevices(getPolicyAppliedDevicesIds(policy.getId()));
policy.setRoles(policyDAO.getPolicyAppliedRoles(policy.getId()));
policy.setUsers(policyDAO.getPolicyAppliedUsers(policy.getId()));
policy.setPolicyCriterias(policyDAO.getPolicyCriteria(policy.getId()));
// policyDAO.getDatesOfPolicy(policy);
// policyDAO.getTimesOfPolicy(policy);

@ -263,6 +263,17 @@ public class PolicyDAOTestCase {
for (Policy policy : policyList) {
log.debug("Policy Id : " + policy.getId() + " Policy Name : " + policy.getPolicyName());
log.debug("Policy Ownership type :" + policy.getOwnershipType());
List<String> users = policy.getUsers();
for (String user : users) {
log.debug("User of the policy : " + user);
}
List<String> roles = policy.getRoles();
for (String role : roles) {
log.debug("User of the policy : " + role);
}
}
}
@ -276,6 +287,17 @@ public class PolicyDAOTestCase {
for (Policy policy : policyList) {
log.debug("Policy Id : " + policy.getId() + " Policy Name : " + policy.getPolicyName());
log.debug("Policy Ownership type :" + policy.getOwnershipType());
List<String> users = policy.getUsers();
for (String user : users) {
log.debug("User of the policy : " + user);
}
List<String> roles = policy.getRoles();
for (String role : roles) {
log.debug("User of the policy : " + role);
}
}
}
@ -290,6 +312,17 @@ public class PolicyDAOTestCase {
for (Policy policy : policyList) {
log.debug("Policy Id : " + policy.getId() + " Policy Name : " + policy.getPolicyName());
log.debug("Policy Ownership type :" + policy.getOwnershipType());
List<String> users = policy.getUsers();
for (String user : users) {
log.debug("User of the policy : " + user);
}
List<String> roles = policy.getRoles();
for (String role : roles) {
log.debug("User of the policy : " + role);
}
}
}
@ -303,6 +336,8 @@ public class PolicyDAOTestCase {
for (Policy policy : policyList) {
log.debug("Policy Id : " + policy.getId() + " Policy Name : " + policy.getPolicyName());
log.debug("Policy Ownership type :" + policy.getOwnershipType());
}
}
@ -324,6 +359,8 @@ public class PolicyDAOTestCase {
for (Policy policy : policyList) {
log.debug("Policy Id : " + policy.getId() + " Policy Name : " + policy.getPolicyName());
log.debug("Policy Ownership type :" + policy.getOwnershipType());
List<ProfileFeature> profileFeatures = policy.getProfile().getProfileFeaturesList();
for (ProfileFeature profileFeature : profileFeatures) {

Loading…
Cancel
Save