|
|
|
@ -22,10 +22,7 @@ import io.entgra.device.mgt.core.device.mgt.common.PolicyPaginationRequest;
|
|
|
|
|
import io.entgra.device.mgt.core.device.mgt.extensions.logger.spi.EntgraLogger;
|
|
|
|
|
import io.entgra.device.mgt.core.notification.logger.PolicyLogContext;
|
|
|
|
|
import io.entgra.device.mgt.core.notification.logger.impl.EntgraPolicyLoggerImpl;
|
|
|
|
|
import io.entgra.device.mgt.core.notification.logger.impl.EntgraUserLoggerImpl;
|
|
|
|
|
import org.apache.commons.lang.StringUtils;
|
|
|
|
|
import org.apache.commons.logging.Log;
|
|
|
|
|
import org.apache.commons.logging.LogFactory;
|
|
|
|
|
import io.entgra.device.mgt.core.device.mgt.common.Device;
|
|
|
|
|
import io.entgra.device.mgt.core.device.mgt.common.DeviceIdentifier;
|
|
|
|
|
import io.entgra.device.mgt.core.device.mgt.common.DynamicTaskContext;
|
|
|
|
@ -96,6 +93,7 @@ public class PolicyManagerImpl implements PolicyManager {
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public Policy addPolicy(Policy policy) throws PolicyManagementException {
|
|
|
|
|
String tenantId = String.valueOf(PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId());
|
|
|
|
|
try {
|
|
|
|
|
PolicyManagementDAOFactory.beginTransaction();
|
|
|
|
|
if (policy.getProfile() != null && policy.getProfile().getProfileId() == 0) {
|
|
|
|
@ -177,6 +175,7 @@ public class PolicyManagerImpl implements PolicyManager {
|
|
|
|
|
} finally {
|
|
|
|
|
PolicyManagementDAOFactory.closeConnection();
|
|
|
|
|
}
|
|
|
|
|
log.info("Policy Created", policyLogContextBuilder.setPolicyName(policy.getPolicyName()).setPayloadVersion(policy.getPolicyPayloadVersion()).setTenantID(tenantId).setProfileID(String.valueOf(policy.getProfileId())).build());
|
|
|
|
|
return policy;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -324,7 +323,7 @@ public class PolicyManagerImpl implements PolicyManager {
|
|
|
|
|
} finally {
|
|
|
|
|
PolicyManagementDAOFactory.closeConnection();
|
|
|
|
|
}
|
|
|
|
|
log.info("Policy Update", policyLogContextBuilder.setPolicyName(policy.getPolicyName()).setPayloadVersion(policy.getPolicyPayloadVersion()).setTenantID(tenantId).setProfileID(String.valueOf(policy.getProfileId())).build());
|
|
|
|
|
log.info("Policy Updated", policyLogContextBuilder.setPolicyName(policy.getPolicyName()).setPayloadVersion(policy.getPolicyPayloadVersion()).setTenantID(tenantId).setProfileID(String.valueOf(policy.getProfileId())).build());
|
|
|
|
|
return policy;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|