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