|
|
@ -653,7 +653,8 @@ public class PolicyManagerImpl implements PolicyManager {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
public void addAppliedPolicyToDevice(DeviceIdentifier deviceIdentifier, int policyId, List<ProfileFeature> profileFeatures) throws
|
|
|
|
public void addAppliedPolicyFeaturesToDevice(DeviceIdentifier deviceIdentifier, int policyId,
|
|
|
|
|
|
|
|
List<ProfileFeature> profileFeatures) throws
|
|
|
|
PolicyManagementException {
|
|
|
|
PolicyManagementException {
|
|
|
|
|
|
|
|
|
|
|
|
int deviceId = -1;
|
|
|
|
int deviceId = -1;
|
|
|
@ -687,6 +688,45 @@ public class PolicyManagerImpl implements PolicyManager {
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
|
|
|
public void addAppliedPolicyToDevice(DeviceIdentifier deviceIdentifier, Policy policy) throws
|
|
|
|
|
|
|
|
PolicyManagementException {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int deviceId = -1;
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
|
|
|
int tenantId = PolicyManagerUtil.getTenantId();
|
|
|
|
|
|
|
|
Device device = deviceDAO.getDevice(deviceIdentifier, tenantId);
|
|
|
|
|
|
|
|
deviceId = device.getId();
|
|
|
|
|
|
|
|
boolean exist = policyDAO.checkPolicyAvailable(deviceId);
|
|
|
|
|
|
|
|
PolicyManagementDAOFactory.beginTransaction();
|
|
|
|
|
|
|
|
if (exist) {
|
|
|
|
|
|
|
|
Policy policySaved = policyDAO.getAppliedPolicy(deviceId);
|
|
|
|
|
|
|
|
if (!policy.equals(policySaved)) {
|
|
|
|
|
|
|
|
policyDAO.updateEffectivePolicyToDevice(deviceId, policy.getId(), policy.getProfile().
|
|
|
|
|
|
|
|
getProfileFeaturesList());
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
policyDAO.addEffectivePolicyToDevice(deviceId, policy.getId(), policy.getProfile().
|
|
|
|
|
|
|
|
getProfileFeaturesList());
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
PolicyManagementDAOFactory.commitTransaction();
|
|
|
|
|
|
|
|
} catch (PolicyManagerDAOException e) {
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
|
|
|
PolicyManagementDAOFactory.rollbackTransaction();
|
|
|
|
|
|
|
|
} catch (PolicyManagerDAOException e1) {
|
|
|
|
|
|
|
|
log.warn("Error occurred while roll backing the transaction.");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
String msg = "Error occurred while adding the evaluated policy to device (" +
|
|
|
|
|
|
|
|
deviceId + " - " + policy.getId() + ")";
|
|
|
|
|
|
|
|
log.error(msg, e);
|
|
|
|
|
|
|
|
throw new PolicyManagementException(msg, e);
|
|
|
|
|
|
|
|
} catch (DeviceManagementDAOException e) {
|
|
|
|
|
|
|
|
String msg = "Error occurred while getting the device details (" + deviceIdentifier.getId() + ")";
|
|
|
|
|
|
|
|
log.error(msg, e);
|
|
|
|
|
|
|
|
throw new PolicyManagementException(msg, e);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
public boolean checkPolicyAvailable(DeviceIdentifier deviceIdentifier) throws PolicyManagementException {
|
|
|
|
public boolean checkPolicyAvailable(DeviceIdentifier deviceIdentifier) throws PolicyManagementException {
|
|
|
|
|
|
|
|
|
|
|
|