|
|
@ -19,12 +19,11 @@
|
|
|
|
package io.entgra.device.mgt.core.policy.mgt.core.impl;
|
|
|
|
package io.entgra.device.mgt.core.policy.mgt.core.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.logging.Log;
|
|
|
|
import org.apache.commons.logging.Log;
|
|
|
|
import org.apache.commons.logging.LogFactory;
|
|
|
|
import org.apache.commons.logging.LogFactory;
|
|
|
|
import org.wso2.carbon.context.PrivilegedCarbonContext;
|
|
|
|
import org.wso2.carbon.context.PrivilegedCarbonContext;
|
|
|
|
import io.entgra.device.mgt.core.device.mgt.common.DeviceIdentifier;
|
|
|
|
import io.entgra.device.mgt.core.device.mgt.common.DeviceIdentifier;
|
|
|
|
import io.entgra.device.mgt.core.device.mgt.common.DynamicTaskContext;
|
|
|
|
|
|
|
|
import io.entgra.device.mgt.core.device.mgt.common.PaginationRequest;
|
|
|
|
|
|
|
|
import io.entgra.device.mgt.core.device.mgt.common.policy.mgt.Policy;
|
|
|
|
import io.entgra.device.mgt.core.device.mgt.common.policy.mgt.Policy;
|
|
|
|
import io.entgra.device.mgt.core.device.mgt.common.policy.mgt.Profile;
|
|
|
|
import io.entgra.device.mgt.core.device.mgt.common.policy.mgt.Profile;
|
|
|
|
import io.entgra.device.mgt.core.device.mgt.core.config.DeviceConfigurationManager;
|
|
|
|
import io.entgra.device.mgt.core.device.mgt.core.config.DeviceConfigurationManager;
|
|
|
@ -34,8 +33,6 @@ import org.wso2.carbon.ntask.core.TaskInfo;
|
|
|
|
import org.wso2.carbon.ntask.core.TaskManager;
|
|
|
|
import org.wso2.carbon.ntask.core.TaskManager;
|
|
|
|
import org.wso2.carbon.ntask.core.service.TaskService;
|
|
|
|
import org.wso2.carbon.ntask.core.service.TaskService;
|
|
|
|
import io.entgra.device.mgt.core.policy.mgt.common.*;
|
|
|
|
import io.entgra.device.mgt.core.policy.mgt.common.*;
|
|
|
|
import io.entgra.device.mgt.core.policy.mgt.core.cache.PolicyCacheManager;
|
|
|
|
|
|
|
|
import io.entgra.device.mgt.core.policy.mgt.core.cache.impl.PolicyCacheManagerImpl;
|
|
|
|
|
|
|
|
import io.entgra.device.mgt.core.policy.mgt.core.internal.PolicyManagementDataHolder;
|
|
|
|
import io.entgra.device.mgt.core.policy.mgt.core.internal.PolicyManagementDataHolder;
|
|
|
|
import io.entgra.device.mgt.core.policy.mgt.core.mgt.PolicyManager;
|
|
|
|
import io.entgra.device.mgt.core.policy.mgt.core.mgt.PolicyManager;
|
|
|
|
import io.entgra.device.mgt.core.policy.mgt.core.mgt.ProfileManager;
|
|
|
|
import io.entgra.device.mgt.core.policy.mgt.core.mgt.ProfileManager;
|
|
|
@ -67,7 +64,8 @@ public class PolicyAdministratorPointImpl implements PolicyAdministratorPoint {
|
|
|
|
public Policy addPolicy(Policy policy) throws PolicyManagementException {
|
|
|
|
public Policy addPolicy(Policy policy) throws PolicyManagementException {
|
|
|
|
Policy resultantPolicy = policyManager.addPolicy(policy);
|
|
|
|
Policy resultantPolicy = policyManager.addPolicy(policy);
|
|
|
|
if (policyConfiguration.getCacheEnable()) {
|
|
|
|
if (policyConfiguration.getCacheEnable()) {
|
|
|
|
PolicyCacheManagerImpl.getInstance().rePopulateCache();
|
|
|
|
//PolicyCacheManagerImpl.getInstance().rePopulateCache();
|
|
|
|
|
|
|
|
GuavaPolicyCacheManagerImpl.getInstance().addPolicy(resultantPolicy);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return resultantPolicy;
|
|
|
|
return resultantPolicy;
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -76,7 +74,8 @@ public class PolicyAdministratorPointImpl implements PolicyAdministratorPoint {
|
|
|
|
public Policy updatePolicy(Policy policy) throws PolicyManagementException {
|
|
|
|
public Policy updatePolicy(Policy policy) throws PolicyManagementException {
|
|
|
|
Policy resultantPolicy = policyManager.updatePolicy(policy);
|
|
|
|
Policy resultantPolicy = policyManager.updatePolicy(policy);
|
|
|
|
if (policyConfiguration.getCacheEnable()) {
|
|
|
|
if (policyConfiguration.getCacheEnable()) {
|
|
|
|
PolicyCacheManagerImpl.getInstance().rePopulateCache();
|
|
|
|
//PolicyCacheManagerImpl.getInstance().rePopulateCache();
|
|
|
|
|
|
|
|
GuavaPolicyCacheManagerImpl.getInstance().updatePolicy(resultantPolicy);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return resultantPolicy;
|
|
|
|
return resultantPolicy;
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -85,7 +84,10 @@ public class PolicyAdministratorPointImpl implements PolicyAdministratorPoint {
|
|
|
|
public boolean updatePolicyPriorities(List<Policy> policies) throws PolicyManagementException {
|
|
|
|
public boolean updatePolicyPriorities(List<Policy> policies) throws PolicyManagementException {
|
|
|
|
boolean bool = policyManager.updatePolicyPriorities(policies);
|
|
|
|
boolean bool = policyManager.updatePolicyPriorities(policies);
|
|
|
|
if (policyConfiguration.getCacheEnable()) {
|
|
|
|
if (policyConfiguration.getCacheEnable()) {
|
|
|
|
PolicyCacheManagerImpl.getInstance().rePopulateCache();
|
|
|
|
//PolicyCacheManagerImpl.getInstance().rePopulateCache();
|
|
|
|
|
|
|
|
if(bool) {
|
|
|
|
|
|
|
|
GuavaPolicyCacheManagerImpl.getInstance().updatePolicies(policies);
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return bool;
|
|
|
|
return bool;
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -94,7 +96,8 @@ public class PolicyAdministratorPointImpl implements PolicyAdministratorPoint {
|
|
|
|
public void activatePolicy(int policyId) throws PolicyManagementException {
|
|
|
|
public void activatePolicy(int policyId) throws PolicyManagementException {
|
|
|
|
policyManager.activatePolicy(policyId);
|
|
|
|
policyManager.activatePolicy(policyId);
|
|
|
|
if (policyConfiguration.getCacheEnable()) {
|
|
|
|
if (policyConfiguration.getCacheEnable()) {
|
|
|
|
PolicyCacheManagerImpl.getInstance().rePopulateCache();
|
|
|
|
//PolicyCacheManagerImpl.getInstance().rePopulateCache();
|
|
|
|
|
|
|
|
GuavaPolicyCacheManagerImpl.getInstance().refreshPolicy(policyId);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -102,7 +105,8 @@ public class PolicyAdministratorPointImpl implements PolicyAdministratorPoint {
|
|
|
|
public void inactivatePolicy(int policyId) throws PolicyManagementException {
|
|
|
|
public void inactivatePolicy(int policyId) throws PolicyManagementException {
|
|
|
|
policyManager.inactivatePolicy(policyId);
|
|
|
|
policyManager.inactivatePolicy(policyId);
|
|
|
|
if (policyConfiguration.getCacheEnable()) {
|
|
|
|
if (policyConfiguration.getCacheEnable()) {
|
|
|
|
PolicyCacheManagerImpl.getInstance().rePopulateCache();
|
|
|
|
//PolicyCacheManagerImpl.getInstance().rePopulateCache();
|
|
|
|
|
|
|
|
GuavaPolicyCacheManagerImpl.getInstance().refreshPolicy(policyId);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -110,8 +114,11 @@ public class PolicyAdministratorPointImpl implements PolicyAdministratorPoint {
|
|
|
|
public boolean deletePolicy(Policy policy) throws PolicyManagementException {
|
|
|
|
public boolean deletePolicy(Policy policy) throws PolicyManagementException {
|
|
|
|
boolean bool = policyManager.deletePolicy(policy);
|
|
|
|
boolean bool = policyManager.deletePolicy(policy);
|
|
|
|
if (policyConfiguration.getCacheEnable()) {
|
|
|
|
if (policyConfiguration.getCacheEnable()) {
|
|
|
|
PolicyCacheManager policyCacheManager = PolicyCacheManagerImpl.getInstance();
|
|
|
|
//PolicyCacheManager policyCacheManager = PolicyCacheManagerImpl.getInstance();
|
|
|
|
policyCacheManager.rePopulateCache();
|
|
|
|
//policyCacheManager.rePopulateCache();
|
|
|
|
|
|
|
|
if(bool) {
|
|
|
|
|
|
|
|
GuavaPolicyCacheManagerImpl.getInstance().invalidatePolicy(policy);
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return bool;
|
|
|
|
return bool;
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -120,8 +127,11 @@ public class PolicyAdministratorPointImpl implements PolicyAdministratorPoint {
|
|
|
|
public boolean deletePolicy(int policyId) throws PolicyManagementException {
|
|
|
|
public boolean deletePolicy(int policyId) throws PolicyManagementException {
|
|
|
|
boolean bool = policyManager.deletePolicy(policyId);
|
|
|
|
boolean bool = policyManager.deletePolicy(policyId);
|
|
|
|
if (policyConfiguration.getCacheEnable()) {
|
|
|
|
if (policyConfiguration.getCacheEnable()) {
|
|
|
|
PolicyCacheManager policyCacheManager = PolicyCacheManagerImpl.getInstance();
|
|
|
|
//PolicyCacheManager policyCacheManager = PolicyCacheManagerImpl.getInstance();
|
|
|
|
policyCacheManager.rePopulateCache();
|
|
|
|
//policyCacheManager.rePopulateCache();
|
|
|
|
|
|
|
|
if(bool) {
|
|
|
|
|
|
|
|
GuavaPolicyCacheManagerImpl.getInstance().invalidatePolicy(policyId);
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return bool;
|
|
|
|
return bool;
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -190,7 +200,8 @@ public class PolicyAdministratorPointImpl implements PolicyAdministratorPoint {
|
|
|
|
PolicyManagementException {
|
|
|
|
PolicyManagementException {
|
|
|
|
policy = policyManager.addPolicyToDevice(deviceIdentifierList, policy);
|
|
|
|
policy = policyManager.addPolicyToDevice(deviceIdentifierList, policy);
|
|
|
|
if (policyConfiguration.getCacheEnable()) {
|
|
|
|
if (policyConfiguration.getCacheEnable()) {
|
|
|
|
PolicyCacheManagerImpl.getInstance().rePopulateCache();
|
|
|
|
//PolicyCacheManagerImpl.getInstance().rePopulateCache();
|
|
|
|
|
|
|
|
GuavaPolicyCacheManagerImpl.getInstance().updatePolicy(policy);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return policy;
|
|
|
|
return policy;
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -199,7 +210,8 @@ public class PolicyAdministratorPointImpl implements PolicyAdministratorPoint {
|
|
|
|
public Policy addPolicyToRole(List<String> roleNames, Policy policy) throws PolicyManagementException {
|
|
|
|
public Policy addPolicyToRole(List<String> roleNames, Policy policy) throws PolicyManagementException {
|
|
|
|
policy = policyManager.addPolicyToRole(roleNames, policy);
|
|
|
|
policy = policyManager.addPolicyToRole(roleNames, policy);
|
|
|
|
if (policyConfiguration.getCacheEnable()) {
|
|
|
|
if (policyConfiguration.getCacheEnable()) {
|
|
|
|
PolicyCacheManagerImpl.getInstance().rePopulateCache();
|
|
|
|
//PolicyCacheManagerImpl.getInstance().rePopulateCache();
|
|
|
|
|
|
|
|
GuavaPolicyCacheManagerImpl.getInstance().updatePolicy(policy);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return policy;
|
|
|
|
return policy;
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -207,7 +219,8 @@ public class PolicyAdministratorPointImpl implements PolicyAdministratorPoint {
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
public List<Policy> getPolicies() throws PolicyManagementException {
|
|
|
|
public List<Policy> getPolicies() throws PolicyManagementException {
|
|
|
|
if (policyConfiguration.getCacheEnable()) {
|
|
|
|
if (policyConfiguration.getCacheEnable()) {
|
|
|
|
return PolicyCacheManagerImpl.getInstance().getAllPolicies();
|
|
|
|
//return PolicyCacheManagerImpl.getInstance().getAllPolicies();
|
|
|
|
|
|
|
|
return GuavaPolicyCacheManagerImpl.getInstance().getAllPolicies();
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
return policyManager.getPolicies();
|
|
|
|
return policyManager.getPolicies();
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -216,7 +229,8 @@ public class PolicyAdministratorPointImpl implements PolicyAdministratorPoint {
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
public Policy getPolicy(int policyId) throws PolicyManagementException {
|
|
|
|
public Policy getPolicy(int policyId) throws PolicyManagementException {
|
|
|
|
if (policyConfiguration.getCacheEnable()) {
|
|
|
|
if (policyConfiguration.getCacheEnable()) {
|
|
|
|
return PolicyCacheManagerImpl.getInstance().getPolicy(policyId);
|
|
|
|
//return PolicyCacheManagerImpl.getInstance().getPolicy(policyId);
|
|
|
|
|
|
|
|
return GuavaPolicyCacheManagerImpl.getInstance().getPolicy(policyId);
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
return policyManager.getPolicy(policyId);
|
|
|
|
return policyManager.getPolicy(policyId);
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -319,17 +333,19 @@ public class PolicyAdministratorPointImpl implements PolicyAdministratorPoint {
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
public int getPolicyCount() throws PolicyManagementException {
|
|
|
|
public int getPolicyCount() throws PolicyManagementException {
|
|
|
|
if (policyConfiguration.getCacheEnable()) {
|
|
|
|
//if (policyConfiguration.getCacheEnable()) {
|
|
|
|
return PolicyCacheManagerImpl.getInstance().getAllPolicies().size();
|
|
|
|
//return PolicyCacheManagerImpl.getInstance().getAllPolicies().size();
|
|
|
|
} else {
|
|
|
|
//return GuavaPolicyCacheManagerImpl.getInstance().getAllPoliciesCount();
|
|
|
|
return policyManager.getPolicyCount();
|
|
|
|
//} else {
|
|
|
|
}
|
|
|
|
return policyManager.getAllPolicyIds().size();
|
|
|
|
|
|
|
|
//}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
public List<Policy> getPolicies(String policyType) throws PolicyManagementException {
|
|
|
|
public List<Policy> getPolicies(String policyType) throws PolicyManagementException {
|
|
|
|
if (policyConfiguration.getCacheEnable()) {
|
|
|
|
if (policyConfiguration.getCacheEnable()) {
|
|
|
|
return PolicyCacheManagerImpl.getInstance().getAllPolicies(policyType);
|
|
|
|
//return PolicyCacheManagerImpl.getInstance().getAllPolicies(policyType);
|
|
|
|
|
|
|
|
return GuavaPolicyCacheManagerImpl.getInstance().getAllPolicies(policyType);
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
return policyManager.getPolicies(policyType);
|
|
|
|
return policyManager.getPolicies(policyType);
|
|
|
|
}
|
|
|
|
}
|
|
|
|