Esempio n. 1
0
        // transformers ///////////////////////////////////////

        public static AuthorizationDto fromAuthorization(Authorization dbAuthorization, ProcessEngineConfiguration engineConfiguration)
        {
            AuthorizationDto authorizationDto = new AuthorizationDto();

            authorizationDto.Id   = dbAuthorization.Id;
            authorizationDto.Type = dbAuthorization.AuthorizationType;

            Permission[] dbPermissions = getPermissions(dbAuthorization, engineConfiguration);
            authorizationDto.Permissions = PermissionConverter.getNamesForPermissions(dbAuthorization, dbPermissions);

            authorizationDto.UserId       = dbAuthorization.UserId;
            authorizationDto.GroupId      = dbAuthorization.GroupId;
            authorizationDto.ResourceType = dbAuthorization.ResourceType;
            authorizationDto.ResourceId   = dbAuthorization.ResourceId;

            return(authorizationDto);
        }
Esempio n. 2
0
        public static void update(AuthorizationDto dto, Authorization dbAuthorization, ProcessEngineConfiguration engineConfiguration)
        {
            dbAuthorization.GroupId    = dto.GroupId;
            dbAuthorization.UserId     = dto.UserId;
            dbAuthorization.ResourceId = dto.ResourceId;

            // update optional fields

            if (dto.ResourceType != null)
            {
                dbAuthorization.ResourceType = dto.ResourceType.Value;
            }

            if (dto.Permissions != null)
            {
                dbAuthorization.Permissions = PermissionConverter.getPermissionsForNames(dto.Permissions, dto.ResourceType.Value, engineConfiguration);
            }
        }