use of com.emc.storageos.model.file.policy.FilePolicyAssignParam in project coprhd-controller by CoprHD.
the class FileProtectionPolicies method saveAssignPolicy.
@FlashException(keep = true, referrer = { "assign" })
public static void saveAssignPolicy(AssignPolicyForm assignPolicy) {
if (assignPolicy == null) {
Logger.error("No assign policy parameters passed");
badRequest("No assign policy parameters passed");
return;
}
assignPolicy.validate("assignPolicy");
if (Validation.hasErrors()) {
Common.handleError();
}
assignPolicy.id = params.get("id");
FilePolicyRestRep policy = getViprClient().fileProtectionPolicies().getFilePolicy(uri(assignPolicy.id));
if (policy.getAppliedAt().equalsIgnoreCase(FilePolicyApplyLevel.file_system.name())) {
list();
}
FilePolicyAssignParam assignPolicyParam = new FilePolicyAssignParam();
if (assignPolicy.topologiesString == null || assignPolicy.topologiesString.equalsIgnoreCase("[]")) {
if (policy.getReplicationSettings() != null && policy.getReplicationSettings().getType().equalsIgnoreCase(FileReplicationType.REMOTE.name())) {
flash.error("No source and target varry parameters passed", policy.getName());
if (StringUtils.isNotBlank(assignPolicy.referrerUrl)) {
redirect(assignPolicy.referrerUrl);
} else {
list();
}
}
}
try {
updateAssignPolicyParam(assignPolicy, assignPolicyParam);
TaskResourceRep taskRes = getViprClient().fileProtectionPolicies().assignPolicy(uri(assignPolicy.id), assignPolicyParam);
if (isTaskSuccessful(assignPolicy.id, taskRes)) {
flash.success(MessagesUtils.get("assignPolicy.request.saved", assignPolicy.policyName));
}
} catch (Exception ex) {
flash.error(ex.getMessage(), assignPolicy.policyName);
}
if (StringUtils.isNotBlank(assignPolicy.referrerUrl)) {
redirect(assignPolicy.referrerUrl);
} else {
list();
}
}
Aggregations