Add email type corrective action transform

4.x.x
Pahansith 4 years ago
parent 206f433a9f
commit 48e1241de6

@ -69,6 +69,9 @@ public final class PolicyManagementConstants {
public static final String POLICY_ACTIONS = "POLICY_ACTIONS";
public static final String CORRECTIVE_POLICY_FEATURE_CODE = "CORRECTIVE_POLICY";
public static final String GEOFENCE_POLICY = "GEOFENCE_POLICY";
public static final String EMAIL_CORRECTIVE_ACTION_TYPE = "EMAIL";
public static final String EMAIL_FEATURE_CODE = "EMAIL_ACTION";
public static final Integer EMAIL_ACTION_ID = 450;
/**
Caller would reference the constants using PolicyManagementConstants.DEVICE_CONFIG_XML_NAME,

@ -304,6 +304,9 @@ public class PolicyManagerUtil {
if (PolicyManagementConstants.POLICY_CORRECTIVE_ACTION_TYPE
.equals(correctiveAction.getActionType())) {
correctivePolicyIdSet.add(correctiveAction.getPolicyId());
} else if (PolicyManagementConstants.EMAIL_CORRECTIVE_ACTION_TYPE
.equals(correctiveAction.getActionType())) {
createEmailCorrectiveActions(correctiveProfileOperation);
}
//Add check for another action type in future implementation
}
@ -328,6 +331,20 @@ public class PolicyManagerUtil {
}
}
private static void createEmailCorrectiveActions(ProfileOperation correctiveProfileOperation) {
ProfileOperation profileOperation = new ProfileOperation();
profileOperation.setId(PolicyManagementConstants.EMAIL_ACTION_ID);
profileOperation.setCode(PolicyManagementConstants.EMAIL_FEATURE_CODE);
profileOperation.setEnabled(true);
profileOperation.setStatus(Operation.Status.PENDING);
profileOperation.setType(Operation.Type.PROFILE);
List<ProfileOperation> profileOperations = new ArrayList<>();
profileOperation.setPayLoad(profileOperations);
List<ProfileOperation> payLoad = new ArrayList<>();
payLoad.add(profileOperation);
correctiveProfileOperation.setPayLoad(payLoad);
}
/**
* This method is using for generate profile operations list which to be sent to the device.
* this method is only using multiple corrective actions
@ -376,12 +393,20 @@ public class PolicyManagerUtil {
if (profileOperation.getReactiveActionIds() == null) {
profileOperation.setReactiveActionIds(new ArrayList<>());
}
profileOperation.getReactiveActionIds().add(correctiveAction.getPolicyId());
if (correctiveAction.getActionType().equals(PolicyManagementConstants.EMAIL_CORRECTIVE_ACTION_TYPE)) {
profileOperation.getReactiveActionIds().add(PolicyManagementConstants.EMAIL_ACTION_ID);
} else if (correctiveAction.getActionType().equals(PolicyManagementConstants.POLICY_CORRECTIVE_ACTION_TYPE)){
profileOperation.getReactiveActionIds().add(correctiveAction.getPolicyId());
}
} else {
if (profileOperation.getCorrectiveActionIds() == null) {
profileOperation.setCorrectiveActionIds(new ArrayList<>());
}
profileOperation.getCorrectiveActionIds().add(correctiveAction.getPolicyId());
if (correctiveAction.getActionType().equals(PolicyManagementConstants.EMAIL_CORRECTIVE_ACTION_TYPE)) {
profileOperation.getCorrectiveActionIds().add(PolicyManagementConstants.EMAIL_ACTION_ID);
} else if (correctiveAction.getActionType().equals(PolicyManagementConstants.POLICY_CORRECTIVE_ACTION_TYPE)){
profileOperation.getCorrectiveActionIds().add(correctiveAction.getPolicyId());
}
}
}
}

Loading…
Cancel
Save