use of controllers.util.FlashException in project coprhd-controller by CoprHD.
the class CustomConfigs method update.
@FlashException
public static void update(String id, String configType, String scopeType, String scopeValue, String value) {
CustomConfigRestRep customConfig = CustomConfigUtils.getCustomConfig(uri(id));
ScopeParam scope = customConfig.getScope();
try {
if (!scope.getType().equals(scopeType) || !scope.getValue().equals(scopeValue)) {
CustomConfigUtils.deleteCustomConfig(uri(id));
CustomConfigUtils.createCustomConfig(configType, scopeType, scopeValue, value);
} else {
CustomConfigUtils.updateCustomConfig(uri(id), value);
}
} catch (ServiceErrorException ex) {
flash.error(MessagesUtils.get("CustomConfigs.error.update", value, MessagesUtils.get("CustomConfigs.configType." + configType)));
}
}
use of controllers.util.FlashException in project coprhd-controller by CoprHD.
the class DataProtectionSystems method edit.
@FlashException("list")
public static void edit(String id) {
addReferenceData();
ProtectionSystemRestRep protectionSystem = ProtectionSystemUtils.getProtectionSystem(id);
if (protectionSystem != null) {
DataProtectionSystemForm dataProtectionSystem = new DataProtectionSystemForm(protectionSystem);
render(dataProtectionSystem);
} else {
flash.error(MessagesUtils.get(UNKNOWN, id));
list();
}
}
use of controllers.util.FlashException 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();
}
}
use of controllers.util.FlashException in project coprhd-controller by CoprHD.
the class FileProtectionPolicies method assign.
@FlashException(value = "list", keep = true)
public static void assign(String ids) {
FilePolicyRestRep filePolicyRestRep = getViprClient().fileProtectionPolicies().get(uri(ids));
if (filePolicyRestRep != null) {
AssignPolicyForm assignPolicy = new AssignPolicyForm().form(filePolicyRestRep);
addRenderApplyPolicysAt();
addProjectArgs(filePolicyRestRep);
addVpoolArgs(filePolicyRestRep);
render(assignPolicy);
} else {
flash.error(MessagesUtils.get(UNKNOWN, ids));
list();
}
}
use of controllers.util.FlashException in project coprhd-controller by CoprHD.
the class FileProtectionPolicies method save.
@FlashException(keep = true, referrer = { "create", "edit" })
public static void save(SchedulePolicyForm schedulePolicy) {
if (schedulePolicy == null) {
Logger.error("No policy parameters passed");
badRequest("No policy parameters passed");
return;
}
schedulePolicy.validate("schedulePolicy");
if (Validation.hasErrors()) {
Common.handleError();
}
schedulePolicy.id = params.get("id");
URI policyId = null;
if (schedulePolicy.isNew()) {
schedulePolicy.tenantId = Models.currentAdminTenant();
FilePolicyCreateParam policyParam = new FilePolicyCreateParam();
updatePolicyParam(schedulePolicy, policyParam, null);
policyParam.setPolicyType(schedulePolicy.policyType);
if (schedulePolicy.description != null && !schedulePolicy.description.isEmpty()) {
policyParam.setPolicyDescription(schedulePolicy.description);
}
FilePolicyCreateResp createdPolicy = getViprClient().fileProtectionPolicies().create(policyParam);
policyId = createdPolicy.getId();
} else {
FilePolicyRestRep schedulePolicyRestRep = getViprClient().fileProtectionPolicies().get(uri(schedulePolicy.id));
FilePolicyUpdateParam input = new FilePolicyUpdateParam();
updatePolicyParam(schedulePolicy, input, schedulePolicyRestRep.getType());
getViprClient().fileProtectionPolicies().update(schedulePolicyRestRep.getId(), input);
policyId = schedulePolicyRestRep.getId();
}
// Update the ACLs
com.emc.vipr.client.core.FileProtectionPolicies filePolicies = getViprClient().fileProtectionPolicies();
schedulePolicy.saveTenantACLs(filePolicies, policyId);
flash.success(MessagesUtils.get("schedulepolicies.saved", schedulePolicy.policyName));
if (StringUtils.isNotBlank(schedulePolicy.referrerUrl)) {
redirect(schedulePolicy.referrerUrl);
} else {
list();
}
}
Aggregations