mirror of
https://repository.entgra.net/community/device-mgt-core.git
synced 2025-10-06 02:01:45 +00:00
Adding the user list to policies
This commit is contained in:
parent
3382686d52
commit
e8255e45c6
@ -36,6 +36,8 @@ public interface PolicyDAO {
|
|||||||
|
|
||||||
Policy addPolicyToDevice(List<Device> devices, Policy policy) throws PolicyManagerDAOException;
|
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 addDatesToPolicy(Date startDate, Date endDate, Policy policy) throws PolicyManagerDAOException;
|
||||||
//
|
//
|
||||||
// Policy addTimesToPolicy(int startTime, int endTime, 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> getPolicyAppliedRoles(int policyId) throws PolicyManagerDAOException;
|
||||||
|
|
||||||
|
List<String> getPolicyAppliedUsers(int policyId) throws PolicyManagerDAOException;
|
||||||
|
|
||||||
// PolicyTimes getTimesOfPolicy(Policy policy) throws PolicyManagerDAOException;
|
// PolicyTimes getTimesOfPolicy(Policy policy) throws PolicyManagerDAOException;
|
||||||
//
|
//
|
||||||
// PolicyDates getDatesOfPolicy(Policy policy) throws PolicyManagerDAOException;
|
// PolicyDates getDatesOfPolicy(Policy policy) throws PolicyManagerDAOException;
|
||||||
|
|||||||
@ -142,6 +142,36 @@ public class PolicyDAOImpl implements PolicyDAO {
|
|||||||
return policy;
|
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
|
// @Override
|
||||||
// public Policy addDatesToPolicy(Date startDate, Date endDate, Policy policy) throws PolicyManagerDAOException {
|
// 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 {
|
// public PolicyTimes getTimesOfPolicy(Policy policy) throws PolicyManagerDAOException {
|
||||||
//
|
//
|
||||||
|
|||||||
@ -468,6 +468,7 @@ public class PolicyManagerImpl implements PolicyManager {
|
|||||||
}
|
}
|
||||||
policy.setDevices(getPolicyAppliedDevicesIds(policy.getId()));
|
policy.setDevices(getPolicyAppliedDevicesIds(policy.getId()));
|
||||||
policy.setRoles(policyDAO.getPolicyAppliedRoles(policy.getId()));
|
policy.setRoles(policyDAO.getPolicyAppliedRoles(policy.getId()));
|
||||||
|
policy.setUsers(policyDAO.getPolicyAppliedUsers(policy.getId()));
|
||||||
policy.setPolicyCriterias(policyDAO.getPolicyCriteria(policy.getId()));
|
policy.setPolicyCriterias(policyDAO.getPolicyCriteria(policy.getId()));
|
||||||
// policyDAO.getDatesOfPolicy(policy);
|
// policyDAO.getDatesOfPolicy(policy);
|
||||||
// policyDAO.getTimesOfPolicy(policy);
|
// policyDAO.getTimesOfPolicy(policy);
|
||||||
|
|||||||
@ -263,6 +263,17 @@ public class PolicyDAOTestCase {
|
|||||||
|
|
||||||
for (Policy policy : policyList) {
|
for (Policy policy : policyList) {
|
||||||
log.debug("Policy Id : " + policy.getId() + " Policy Name : " + policy.getPolicyName());
|
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) {
|
for (Policy policy : policyList) {
|
||||||
log.debug("Policy Id : " + policy.getId() + " Policy Name : " + policy.getPolicyName());
|
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) {
|
for (Policy policy : policyList) {
|
||||||
log.debug("Policy Id : " + policy.getId() + " Policy Name : " + policy.getPolicyName());
|
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) {
|
for (Policy policy : policyList) {
|
||||||
log.debug("Policy Id : " + policy.getId() + " Policy Name : " + policy.getPolicyName());
|
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) {
|
for (Policy policy : policyList) {
|
||||||
log.debug("Policy Id : " + policy.getId() + " Policy Name : " + policy.getPolicyName());
|
log.debug("Policy Id : " + policy.getId() + " Policy Name : " + policy.getPolicyName());
|
||||||
|
|
||||||
|
log.debug("Policy Ownership type :" + policy.getOwnershipType());
|
||||||
|
|
||||||
List<ProfileFeature> profileFeatures = policy.getProfile().getProfileFeaturesList();
|
List<ProfileFeature> profileFeatures = policy.getProfile().getProfileFeaturesList();
|
||||||
|
|
||||||
for (ProfileFeature profileFeature : profileFeatures) {
|
for (ProfileFeature profileFeature : profileFeatures) {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user