Search in sources :

Example 66 with FlashException

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)));
    }
}
Also used : CustomConfigRestRep(com.emc.storageos.model.customconfig.CustomConfigRestRep) ConfigTypeScopeParam(com.emc.storageos.model.customconfig.ConfigTypeScopeParam) ScopeParam(com.emc.storageos.model.customconfig.ScopeParam) ServiceErrorException(com.emc.vipr.client.exceptions.ServiceErrorException) FlashException(controllers.util.FlashException)

Example 67 with FlashException

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();
    }
}
Also used : ProtectionSystemRestRep(com.emc.storageos.model.protection.ProtectionSystemRestRep) FlashException(controllers.util.FlashException)

Example 68 with FlashException

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();
    }
}
Also used : FilePolicyAssignParam(com.emc.storageos.model.file.policy.FilePolicyAssignParam) FilePolicyRestRep(com.emc.storageos.model.file.policy.FilePolicyRestRep) TaskResourceRep(com.emc.storageos.model.TaskResourceRep) FlashException(controllers.util.FlashException) FlashException(controllers.util.FlashException)

Example 69 with FlashException

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();
    }
}
Also used : FilePolicyRestRep(com.emc.storageos.model.file.policy.FilePolicyRestRep) FlashException(controllers.util.FlashException)

Example 70 with FlashException

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();
    }
}
Also used : FilePolicyUpdateParam(com.emc.storageos.model.file.policy.FilePolicyUpdateParam) FilePolicyCreateParam(com.emc.storageos.model.file.policy.FilePolicyCreateParam) FilePolicyCreateResp(com.emc.storageos.model.file.policy.FilePolicyCreateResp) FilePolicyRestRep(com.emc.storageos.model.file.policy.FilePolicyRestRep) URI(java.net.URI) FlashException(controllers.util.FlashException)

Aggregations

FlashException (controllers.util.FlashException)122 ViPRCoreClient (com.emc.vipr.client.ViPRCoreClient)45 ExportGroupRestRep (com.emc.storageos.model.block.export.ExportGroupRestRep)9 VirtualArrayRestRep (com.emc.storageos.model.varray.VirtualArrayRestRep)9 URI (java.net.URI)9 ExportUpdateParam (com.emc.storageos.model.block.export.ExportUpdateParam)8 Restrictions (controllers.deadbolt.Restrictions)8 ArrayList (java.util.ArrayList)7 FilePolicyRestRep (com.emc.storageos.model.file.policy.FilePolicyRestRep)6 VolumeRestRep (com.emc.storageos.model.block.VolumeRestRep)5 CopiesParam (com.emc.storageos.model.block.CopiesParam)4 SiteRestRep (com.emc.storageos.model.dr.SiteRestRep)4 ExportRule (com.emc.storageos.model.file.ExportRule)4 ExportRules (com.emc.storageos.model.file.ExportRules)4 FileShareRestRep (com.emc.storageos.model.file.FileShareRestRep)4 ProjectRestRep (com.emc.storageos.model.project.ProjectRestRep)4 ServiceErrorException (com.emc.vipr.client.exceptions.ServiceErrorException)4 JsonArray (com.google.gson.JsonArray)3 JsonObject (com.google.gson.JsonObject)3 TaskResourceRep (com.emc.storageos.model.TaskResourceRep)2