|
|
|
@ -19,6 +19,7 @@
|
|
|
|
|
package io.entgra.device.mgt.core.policy.mgt.core.mgt.impl;
|
|
|
|
|
|
|
|
|
|
import io.entgra.device.mgt.core.device.mgt.common.PolicyPaginationRequest;
|
|
|
|
|
import io.entgra.device.mgt.core.policy.mgt.core.cache.guava.impl.GuavaPolicyCacheManagerImpl;
|
|
|
|
|
import org.apache.commons.lang.StringUtils;
|
|
|
|
|
import org.apache.commons.logging.Log;
|
|
|
|
|
import org.apache.commons.logging.LogFactory;
|
|
|
|
@ -511,7 +512,8 @@ public class PolicyManagerImpl implements PolicyManager {
|
|
|
|
|
try {
|
|
|
|
|
List<Policy> existingPolicies;
|
|
|
|
|
if (policyConfiguration.getCacheEnable()) {
|
|
|
|
|
existingPolicies = PolicyCacheManagerImpl.getInstance().getAllPolicies();
|
|
|
|
|
//existingPolicies = PolicyCacheManagerImpl.getInstance().getAllPolicies();
|
|
|
|
|
existingPolicies = GuavaPolicyCacheManagerImpl.getInstance().getAllPolicies();
|
|
|
|
|
} else {
|
|
|
|
|
existingPolicies = this.getPolicies();
|
|
|
|
|
}
|
|
|
|
@ -795,11 +797,22 @@ public class PolicyManagerImpl implements PolicyManager {
|
|
|
|
|
try {
|
|
|
|
|
PolicyManagementDAOFactory.openConnection();
|
|
|
|
|
policy = policyDAO.getPolicy(policyId);
|
|
|
|
|
|
|
|
|
|
if(policy == null) {
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
roleNames = policyDAO.getPolicyAppliedRoles(policyId);
|
|
|
|
|
userNames = policyDAO.getPolicyAppliedUsers(policyId);
|
|
|
|
|
policy.setRoles(roleNames);
|
|
|
|
|
policy.setUsers(userNames);
|
|
|
|
|
|
|
|
|
|
policy.setPolicyCriterias(policyDAO.getPolicyCriteria(policyId));
|
|
|
|
|
List<DeviceGroupWrapper> deviceGroupWrappers = policyDAO.getDeviceGroupsOfPolicy(policyId);
|
|
|
|
|
if(!deviceGroupWrappers.isEmpty()) {
|
|
|
|
|
deviceGroupWrappers = this.getDeviceGroupNames(deviceGroupWrappers);
|
|
|
|
|
}
|
|
|
|
|
policy.setDeviceGroups(deviceGroupWrappers);
|
|
|
|
|
if (log.isDebugEnabled()) {
|
|
|
|
|
log.debug("Retrieving corrective actions of policy " + policy.getPolicyName() +
|
|
|
|
|
" having policy id " + policy.getId());
|
|
|
|
@ -810,6 +823,8 @@ public class PolicyManagerImpl implements PolicyManager {
|
|
|
|
|
policyId + ")", e);
|
|
|
|
|
} catch (SQLException e) {
|
|
|
|
|
throw new PolicyManagementException("Error occurred while opening a connection to the data source", e);
|
|
|
|
|
} catch (GroupManagementException e) {
|
|
|
|
|
throw new PolicyManagementException("Error occurred while getting device groups", e);
|
|
|
|
|
} finally {
|
|
|
|
|
PolicyManagementDAOFactory.closeConnection();
|
|
|
|
|
}
|
|
|
|
@ -915,7 +930,8 @@ public class PolicyManagerImpl implements PolicyManager {
|
|
|
|
|
|
|
|
|
|
List<Policy> tempPolicyList;
|
|
|
|
|
if (policyConfiguration.getCacheEnable()) {
|
|
|
|
|
tempPolicyList = PolicyCacheManagerImpl.getInstance().getAllPolicies();
|
|
|
|
|
//tempPolicyList = PolicyCacheManagerImpl.getInstance().getAllPolicies();
|
|
|
|
|
tempPolicyList = GuavaPolicyCacheManagerImpl.getInstance().getAllPolicies();
|
|
|
|
|
} else {
|
|
|
|
|
tempPolicyList = this.getPolicies();
|
|
|
|
|
}
|
|
|
|
@ -937,7 +953,8 @@ public class PolicyManagerImpl implements PolicyManager {
|
|
|
|
|
List<Policy> policies = new ArrayList<>();
|
|
|
|
|
List<Policy> allPolicies;
|
|
|
|
|
if (policyConfiguration.getCacheEnable()) {
|
|
|
|
|
allPolicies = PolicyCacheManagerImpl.getInstance().getAllPolicies();
|
|
|
|
|
//allPolicies = PolicyCacheManagerImpl.getInstance().getAllPolicies();
|
|
|
|
|
allPolicies = GuavaPolicyCacheManagerImpl.getInstance().getAllPolicies();
|
|
|
|
|
} else {
|
|
|
|
|
allPolicies = this.getPolicies();
|
|
|
|
|
}
|
|
|
|
@ -968,7 +985,8 @@ public class PolicyManagerImpl implements PolicyManager {
|
|
|
|
|
|
|
|
|
|
List<Policy> tempPolicyList;
|
|
|
|
|
if (policyConfiguration.getCacheEnable()) {
|
|
|
|
|
tempPolicyList = PolicyCacheManagerImpl.getInstance().getAllPolicies();
|
|
|
|
|
//tempPolicyList = PolicyCacheManagerImpl.getInstance().getAllPolicies();
|
|
|
|
|
tempPolicyList = GuavaPolicyCacheManagerImpl.getInstance().getAllPolicies();
|
|
|
|
|
} else {
|
|
|
|
|
tempPolicyList = this.getPolicies();
|
|
|
|
|
}
|
|
|
|
@ -1000,7 +1018,8 @@ public class PolicyManagerImpl implements PolicyManager {
|
|
|
|
|
}
|
|
|
|
|
List<Policy> tempPolicyList;
|
|
|
|
|
if (policyConfiguration.getCacheEnable()) {
|
|
|
|
|
tempPolicyList = PolicyCacheManagerImpl.getInstance().getAllPolicies();
|
|
|
|
|
//tempPolicyList = PolicyCacheManagerImpl.getInstance().getAllPolicies();
|
|
|
|
|
tempPolicyList = GuavaPolicyCacheManagerImpl.getInstance().getAllPolicies();
|
|
|
|
|
} else {
|
|
|
|
|
tempPolicyList = this.getPolicies();
|
|
|
|
|
}
|
|
|
|
@ -1098,7 +1117,8 @@ public class PolicyManagerImpl implements PolicyManager {
|
|
|
|
|
try {
|
|
|
|
|
List<Policy> allPolicies;
|
|
|
|
|
if (policyConfiguration.getCacheEnable()) {
|
|
|
|
|
allPolicies = PolicyCacheManagerImpl.getInstance().getAllPolicies();
|
|
|
|
|
//allPolicies = PolicyCacheManagerImpl.getInstance().getAllPolicies();
|
|
|
|
|
allPolicies = GuavaPolicyCacheManagerImpl.getInstance().getAllPolicies();
|
|
|
|
|
} else {
|
|
|
|
|
allPolicies = this.getPolicies();
|
|
|
|
|
}
|
|
|
|
|