Search in sources :

Example 16 with Util

use of play.mvc.Util in project coprhd-controller by CoprHD.

the class Security method getUserInfo.

@Util
public static UserInfo getUserInfo() {
    String key = getUserInfoCacheKey();
    UserInfo user = (UserInfo) Cache.get(key);
    if (user == null) {
        user = new UserInfo(getViprClient().getUserInfo());
        Cache.set(key, user, CACHE_EXPR);
    }
    return user;
}
Also used : UserInfo(models.security.UserInfo) BourneUtil(util.BourneUtil) Util(play.mvc.Util)

Example 17 with Util

use of play.mvc.Util in project coprhd-controller by CoprHD.

the class Tenants method deleteRoleAssignments.

@Util
private static void deleteRoleAssignments(String[] ids) {
    if (ids != null && ids.length > 0) {
        boolean deletedRoleAssignment = false;
        for (String id : ids) {
            String name = TenantRoleAssignmentForm.extractNameFromId(id);
            RoleAssignmentType type = TenantRoleAssignmentForm.extractTypeFromId(id);
            String tenantId = TenantRoleAssignmentForm.extractTenantFromId(id);
            if (RoleAssignmentUtils.isRootUser(type, name)) {
                flash.put("warningMessage", MessagesUtils.get("roleAssignments.rootNotDeleted"));
            } else {
                deleteTenantRoleAssignment(tenantId, type, name);
                deletedRoleAssignment = true;
            }
        }
        if (deletedRoleAssignment) {
            flash.success(MessagesUtils.get("roleAssignments.deleted"));
        }
    }
}
Also used : RoleAssignmentType(models.RoleAssignmentType) Util(play.mvc.Util)

Example 18 with Util

use of play.mvc.Util in project coprhd-controller by CoprHD.

the class Models method currentAdminTenant.

@Util
public static String currentAdminTenant() {
    String sessionTenant = session.get(TENANT_ID);
    if (sessionTenant != null && canSelectTenant(sessionTenant)) {
        return validateSessionTenant(sessionTenant);
    } else {
        session.remove(TENANT_ID);
        UserInfo info = Security.getUserInfo();
        if (Security.isTenantAdmin() && !Security.isHomeTenantAdmin()) {
            for (URI tenant : info.getSubTenants()) {
                String tenantId = tenant.toString();
                if (info.hasSubTenantRole(tenantId, Security.TENANT_ADMIN)) {
                    return tenantId;
                }
            }
        }
        // fallback to the home tenant if nothing else matches
        return info.getTenant();
    }
}
Also used : UserInfo(models.security.UserInfo) URI(java.net.URI) Util(play.mvc.Util)

Example 19 with Util

use of play.mvc.Util in project coprhd-controller by CoprHD.

the class Models method currentAdminTenantForVcenter.

@Util
public static String currentAdminTenantForVcenter() {
    String sessionTenant = session.get(TENANT_ID);
    if (sessionTenant != null && canSelectTenantForVcenters(sessionTenant)) {
        return validateSessionTenantForVcenter(sessionTenant);
    } else {
        session.remove(TENANT_ID);
        UserInfo info = Security.getUserInfo();
        if (Security.isTenantAdmin() && !Security.isHomeTenantAdmin()) {
            for (URI tenant : info.getSubTenants()) {
                String tenantId = tenant.toString();
                if (info.hasSubTenantRole(tenantId, Security.TENANT_ADMIN)) {
                    return tenantId;
                }
            }
        }
        // fallback to the home tenant if nothing else matches
        return info.getTenant();
    }
}
Also used : UserInfo(models.security.UserInfo) URI(java.net.URI) Util(play.mvc.Util)

Example 20 with Util

use of play.mvc.Util in project coprhd-controller by CoprHD.

the class ExecutionWindows method isOverlapping.

@Util
public static boolean isOverlapping(ExecutionWindowForm executionWindowForm) {
    if (executionWindowForm.length == null) {
        return false;
    }
    ExecutionWindowRestRep tempExecutionWindow = new ExecutionWindowRestRep();
    tempExecutionWindow.setName(Messages.get("ExecutionWindows.tempWindowLabel"));
    executionWindowForm.writeTo(tempExecutionWindow);
    return ExecutionWindowUtils.isOverlapping(tempExecutionWindow);
}
Also used : ExecutionWindowRestRep(com.emc.vipr.model.catalog.ExecutionWindowRestRep) Util(play.mvc.Util)

Aggregations

Util (play.mvc.Util)23 BourneUtil (util.BourneUtil)7 URI (java.net.URI)4 CatalogServiceRestRep (com.emc.vipr.model.catalog.CatalogServiceRestRep)3 UserInfo (models.security.UserInfo)3 ResourceType (com.emc.sa.util.ResourceType)2 URIUtil (com.emc.storageos.db.client.URIUtil)2 TaskUtil (com.emc.vipr.client.core.impl.TaskUtil)2 ExecutionWindowRestRep (com.emc.vipr.model.catalog.ExecutionWindowRestRep)2 Parameter (com.emc.vipr.model.catalog.Parameter)2 ServiceFieldRestRep (com.emc.vipr.model.catalog.ServiceFieldRestRep)2 BreadCrumb (models.BreadCrumb)2 DataObjectRestRep (com.emc.storageos.model.DataObjectRestRep)1 RelatedResourceRep (com.emc.storageos.model.RelatedResourceRep)1 ACLAssignmentChanges (com.emc.storageos.model.auth.ACLAssignmentChanges)1 ACLEntry (com.emc.storageos.model.auth.ACLEntry)1 AuthnProviderRestRep (com.emc.storageos.model.auth.AuthnProviderRestRep)1 CopiesParam (com.emc.storageos.model.block.CopiesParam)1 Copy (com.emc.storageos.model.block.Copy)1 ProjectRestRep (com.emc.storageos.model.project.ProjectRestRep)1