Search in sources :

Example 1 with ACLUpdateBuilder

use of util.builders.ACLUpdateBuilder in project coprhd-controller by CoprHD.

the class VirtualPoolCommonForm method saveTenantACLs.

/**
 * Saves the tenant ACL information using the provided ACLResources.
 *
 * @param resources
 *            the resources on which to save the tenant ACLs.
 */
protected void saveTenantACLs(ACLResources resources) {
    // Only allow a user than can read all tenants and update ACLs do this
    if (TenantUtils.canReadAllTenants() && VirtualPoolUtils.canUpdateACLs()) {
        URI virtualPoolId = ResourceUtils.uri(id);
        if (virtualPoolId != null) {
            Set<String> tenantIds = Sets.newHashSet();
            if (isTrue(enableTenants) && (tenants != null)) {
                tenantIds.addAll(tenants);
            }
            ACLUpdateBuilder builder = new ACLUpdateBuilder(resources.getACLs(virtualPoolId));
            builder.setTenants(tenantIds);
            resources.updateACLs(virtualPoolId, builder.getACLUpdate());
        }
    }
}
Also used : URI(java.net.URI) ACLUpdateBuilder(util.builders.ACLUpdateBuilder)

Example 2 with ACLUpdateBuilder

use of util.builders.ACLUpdateBuilder in project coprhd-controller by CoprHD.

the class VirtualArrays method saveTenantACLs.

/**
 * Saves tenant ACLs on the virtual array.
 *
 * @param virtualArrayId
 *            the virtual array ID.
 * @param tenants
 *            the tenant ACLs.
 */
private static void saveTenantACLs(String virtualArrayId, List<String> tenants) {
    Set<String> tenantIds = Sets.newHashSet();
    if (tenants != null) {
        tenantIds.addAll(tenants);
    }
    ACLUpdateBuilder builder = new ACLUpdateBuilder(VirtualArrayUtils.getACLs(virtualArrayId));
    builder.setTenants(tenantIds);
    try {
        VirtualArrayUtils.updateACLs(virtualArrayId, builder.getACLUpdate());
    } catch (ViPRException e) {
        Logger.error(e, "Failed to update Virtual Array ACLs");
        String errorDesc = e.getMessage();
        if (e instanceof ServiceErrorException) {
            errorDesc = ((ServiceErrorException) e).getDetailedMessage();
        }
        flash.error(MessagesUtils.get("varrays.updateVarrayACLs.failed", errorDesc));
    }
}
Also used : ViPRException(com.emc.vipr.client.exceptions.ViPRException) ServiceErrorException(com.emc.vipr.client.exceptions.ServiceErrorException) ACLUpdateBuilder(util.builders.ACLUpdateBuilder)

Example 3 with ACLUpdateBuilder

use of util.builders.ACLUpdateBuilder in project coprhd-controller by CoprHD.

the class ComputeVirtualPools method saveTenantACLs.

/**
 * Saves tenant ACLs on the virtual compute pool.
 *
 * @param vpoolId
 *            the virtual compute pool ID.
 * @param tenants
 *            the tenant ACLs.
 * @param enableTenants
 *            the checked status for "Grant Access to Tenants".
 */
private static void saveTenantACLs(String vpoolId, List<String> tenants, Boolean enableTenants) {
    Set<String> tenantIds = Sets.newHashSet();
    if (isTrue(enableTenants) && tenants != null) {
        tenantIds.addAll(tenants);
    }
    ACLUpdateBuilder builder = new ACLUpdateBuilder(ComputeVirtualPoolUtils.getComputeACLs(vpoolId));
    builder.setTenants(tenantIds);
    try {
        ComputeVirtualPoolUtils.updateComputeACLs(vpoolId, builder.getACLUpdate());
    } catch (ViPRException e) {
        Logger.error(e, "Failed to update Compute Virtual Pool ACLs");
        String errorDesc = e.getMessage();
        if (e instanceof ServiceErrorException) {
            errorDesc = ((ServiceErrorException) e).getDetailedMessage();
        }
        flash.error(MessagesUtils.get("computeVirtualPool.updateComputeVirtualPoolACLs.failed", errorDesc));
    }
}
Also used : ViPRException(com.emc.vipr.client.exceptions.ViPRException) ServiceErrorException(com.emc.vipr.client.exceptions.ServiceErrorException) ACLUpdateBuilder(util.builders.ACLUpdateBuilder)

Aggregations

ACLUpdateBuilder (util.builders.ACLUpdateBuilder)3 ServiceErrorException (com.emc.vipr.client.exceptions.ServiceErrorException)2 ViPRException (com.emc.vipr.client.exceptions.ViPRException)2 URI (java.net.URI)1