Exemplo n.º 1
0
        internal override bool MustWaitFor(SecurityActivity olderActivity)
        {
            if (olderActivity is MembershipActivity)
            {
                return(true);
            }

            // There aren't any valid scenarios if the olderActivity is ModifySecurityEntityOwnerActivity or MoveSecurityEntityActivity

            var createSecurityEntityActivity = olderActivity as CreateSecurityEntityActivity;

            if (createSecurityEntityActivity != null)
            {
                return(this.AllEntityIds.Contains(createSecurityEntityActivity.EntityId));
            }

            var deleteSecurityEntityActivity = olderActivity as DeleteSecurityEntityActivity;

            if (deleteSecurityEntityActivity != null)
            {
                return(DependencyTools.AnyIsInTree(this.Context, this.AllEntityIds, deleteSecurityEntityActivity.EntityId));
            }

            var setAclActivity = olderActivity as SetAclActivity;

            if (setAclActivity != null)
            {
                return(setAclActivity.AllEntityIds.Intersect(this.AllEntityIds).Any());
            }

            return(false);
        }
Exemplo n.º 2
0
        internal override bool MustWaitFor(SecurityActivity olderActivity)
        {
            if (olderActivity is MembershipActivity)
            {
                return(true);
            }

            var createSecurityEntityActivity = olderActivity as CreateSecurityEntityActivity;

            if (createSecurityEntityActivity != null)
            {
                return((createSecurityEntityActivity.EntityId == this.EntityId) ||
                       DependencyTools.IsInTree(this.Context, createSecurityEntityActivity.ParentEntityId, this.EntityId));
            }

            var deleteSecurityEntityActivity = olderActivity as DeleteSecurityEntityActivity;

            if (deleteSecurityEntityActivity != null)
            {
                return(DependencyTools.HasAncestorRelation(this.Context, this.EntityId, deleteSecurityEntityActivity.EntityId));
            }

            var modifySecurityEntityOwnerActivity = olderActivity as ModifySecurityEntityOwnerActivity;

            if (modifySecurityEntityOwnerActivity != null)
            {
                return(DependencyTools.IsInTree(this.Context, modifySecurityEntityOwnerActivity.EntityId, this.EntityId));
            }

            var moveSecurityEntityActivity = olderActivity as MoveSecurityEntityActivity;

            if (moveSecurityEntityActivity != null)
            {
                var ctx      = this.Context;
                var entities = SecurityEntity.PeekEntities(ctx, this.EntityId, moveSecurityEntityActivity.SourceId, moveSecurityEntityActivity.TargetId);

                var deleteTarget = entities[0];
                var moveSource   = entities[1];
                var moveTarget   = entities[2];

                if (DependencyTools.HasAncestorRelation(ctx, moveSource, deleteTarget))
                {
                    return(true);
                }
                if (DependencyTools.IsInTree(ctx, moveTarget, this.EntityId))
                {
                    return(true);
                }
            }

            var setAclActivity = olderActivity as SetAclActivity;

            if (setAclActivity != null)
            {
                return(DependencyTools.AnyIsInTree(this.Context, setAclActivity.AllEntityIds, this.EntityId));
            }

            return(false);
        }
Exemplo n.º 3
0
        internal override bool MustWaitFor(SecurityActivity olderActivity)
        {
            if (olderActivity is MembershipActivity)
            {
                return(true);
            }

            if (olderActivity is CreateSecurityEntityActivity createSecurityEntityActivity)
            {
                return(createSecurityEntityActivity.EntityId == EntityId ||
                       DependencyTools.IsInTree(Context, createSecurityEntityActivity.ParentEntityId, EntityId));
            }

            if (olderActivity is DeleteSecurityEntityActivity deleteSecurityEntityActivity)
            {
                return(DependencyTools.HasAncestorRelation(Context, EntityId, deleteSecurityEntityActivity.EntityId));
            }

            if (olderActivity is ModifySecurityEntityOwnerActivity modifySecurityEntityOwnerActivity)
            {
                return(DependencyTools.IsInTree(Context, modifySecurityEntityOwnerActivity.EntityId, EntityId));
            }

            if (olderActivity is MoveSecurityEntityActivity moveSecurityEntityActivity)
            {
                var ctx      = Context;
                var entities = ctx.SecuritySystem.EntityManager.PeekEntities(EntityId, moveSecurityEntityActivity.SourceId, moveSecurityEntityActivity.TargetId);

                var deleteTarget = entities[0];
                var moveSource   = entities[1];
                var moveTarget   = entities[2];

                if (DependencyTools.HasAncestorRelation(ctx, moveSource, deleteTarget))
                {
                    return(true);
                }
                if (DependencyTools.IsInTree(ctx, moveTarget, EntityId))
                {
                    return(true);
                }
            }

            if (olderActivity is SetAclActivity setAclActivity)
            {
                return(DependencyTools.AnyIsInTree(Context, setAclActivity.AllEntityIds, EntityId));
            }

            return(false);
        }