Search in sources :

Example 1 with BaseEntity

use of com.ctrip.framework.apollo.common.entity.BaseEntity in project apollo by ctripcorp.

the class DefaultRoleInitializationService method createAppMasterRole.

private void createAppMasterRole(String appId, String operator) {
    Set<Permission> appPermissions = Stream.of(PermissionType.CREATE_CLUSTER, PermissionType.CREATE_NAMESPACE, PermissionType.ASSIGN_ROLE).map(permissionType -> createPermission(appId, permissionType, operator)).collect(Collectors.toSet());
    Set<Permission> createdAppPermissions = rolePermissionService.createPermissions(appPermissions);
    Set<Long> appPermissionIds = createdAppPermissions.stream().map(BaseEntity::getId).collect(Collectors.toSet());
    // create app master role
    Role appMasterRole = createRole(RoleUtils.buildAppMasterRoleName(appId), operator);
    rolePermissionService.createRoleWithPermissions(appMasterRole, appPermissionIds);
}
Also used : ConfigConsts(com.ctrip.framework.apollo.core.ConfigConsts) PortalConfig(com.ctrip.framework.apollo.portal.component.config.PortalConfig) PermissionType(com.ctrip.framework.apollo.portal.constant.PermissionType) Env(com.ctrip.framework.apollo.portal.environment.Env) SystemRoleManagerService(com.ctrip.framework.apollo.portal.service.SystemRoleManagerService) Role(com.ctrip.framework.apollo.portal.entity.po.Role) Autowired(org.springframework.beans.factory.annotation.Autowired) Set(java.util.Set) RoleType(com.ctrip.framework.apollo.portal.constant.RoleType) Permission(com.ctrip.framework.apollo.portal.entity.po.Permission) Collectors(java.util.stream.Collectors) RoleInitializationService(com.ctrip.framework.apollo.portal.service.RoleInitializationService) Sets(com.google.common.collect.Sets) BaseEntity(com.ctrip.framework.apollo.common.entity.BaseEntity) RoleUtils(com.ctrip.framework.apollo.portal.util.RoleUtils) HashSet(java.util.HashSet) List(java.util.List) Stream(java.util.stream.Stream) PermissionRepository(com.ctrip.framework.apollo.portal.repository.PermissionRepository) App(com.ctrip.framework.apollo.common.entity.App) RolePermissionService(com.ctrip.framework.apollo.portal.service.RolePermissionService) Transactional(org.springframework.transaction.annotation.Transactional) Role(com.ctrip.framework.apollo.portal.entity.po.Role) Permission(com.ctrip.framework.apollo.portal.entity.po.Permission)

Aggregations

App (com.ctrip.framework.apollo.common.entity.App)1 BaseEntity (com.ctrip.framework.apollo.common.entity.BaseEntity)1 ConfigConsts (com.ctrip.framework.apollo.core.ConfigConsts)1 PortalConfig (com.ctrip.framework.apollo.portal.component.config.PortalConfig)1 PermissionType (com.ctrip.framework.apollo.portal.constant.PermissionType)1 RoleType (com.ctrip.framework.apollo.portal.constant.RoleType)1 Permission (com.ctrip.framework.apollo.portal.entity.po.Permission)1 Role (com.ctrip.framework.apollo.portal.entity.po.Role)1 Env (com.ctrip.framework.apollo.portal.environment.Env)1 PermissionRepository (com.ctrip.framework.apollo.portal.repository.PermissionRepository)1 RoleInitializationService (com.ctrip.framework.apollo.portal.service.RoleInitializationService)1 RolePermissionService (com.ctrip.framework.apollo.portal.service.RolePermissionService)1 SystemRoleManagerService (com.ctrip.framework.apollo.portal.service.SystemRoleManagerService)1 RoleUtils (com.ctrip.framework.apollo.portal.util.RoleUtils)1 Sets (com.google.common.collect.Sets)1 HashSet (java.util.HashSet)1 List (java.util.List)1 Set (java.util.Set)1 Collectors (java.util.stream.Collectors)1 Stream (java.util.stream.Stream)1