Exemplo n.º 1
0
        public override object InternalExecute(Program program, object[] arguments)
        {
            Schema.CatalogObject objectValue = Compiler.ResolveCatalogIdentifier(program.Plan, (string)arguments[0], false) as Schema.CatalogObject;
            if (objectValue == null)
            {
                throw new Schema.SchemaException(Schema.SchemaException.Codes.CatalogObjectExpected, objectValue.Name);
            }

            Schema.User user = ((ServerCatalogDeviceSession)program.CatalogDeviceSession).ResolveUser((string)arguments[1]);
            if (program.Plan.User.ID != user.ID)
            {
                program.Plan.CheckAuthorized(user.ID);
            }
            if (!objectValue.IsOwner(program.Plan.User))
            {
                throw new ServerException(ServerException.Codes.UnauthorizedUser, ErrorSeverity.Environment, program.Plan.User.ID);
            }
            ChangeObjectOwner(program, objectValue, user);

            return(null);
        }
Exemplo n.º 2
0
        private void ChangeObjectOwner(Program program, Schema.CatalogObject objectValue, Schema.User user)
        {
            if (objectValue != null)
            {
                objectValue.Owner = user;
                ((ServerCatalogDeviceSession)program.CatalogDeviceSession).SetCatalogObjectOwner(objectValue.ID, user.ID);

                if (objectValue is Schema.ScalarType)
                {
                    Schema.ScalarType scalarType = (Schema.ScalarType)objectValue;

                    if (scalarType.EqualityOperator != null)
                    {
                        ChangeObjectOwner(program, scalarType.EqualityOperator, user);
                    }

                    if (scalarType.ComparisonOperator != null)
                    {
                        ChangeObjectOwner(program, scalarType.ComparisonOperator, user);
                    }

                    if (scalarType.IsSpecialOperator != null)
                    {
                        ChangeObjectOwner(program, scalarType.IsSpecialOperator, user);
                    }

                    foreach (Schema.Special special in scalarType.Specials)
                    {
                        ChangeObjectOwner(program, special.Selector, user);
                        ChangeObjectOwner(program, special.Comparer, user);
                    }

                                        #if USETYPEINHERITANCE
                    foreach (Schema.Operator operatorValue in scalarType.ExplicitCastOperators)
                    {
                        ChangeObjectOwner(AProgram, operatorValue, AUser);
                    }
                                        #endif

                    foreach (Schema.Representation representation in scalarType.Representations)
                    {
                        if (representation.Selector != null)
                        {
                            ChangeObjectOwner(program, representation.Selector, user);
                        }

                        foreach (Schema.Property property in representation.Properties)
                        {
                            if (property.ReadAccessor != null)
                            {
                                ChangeObjectOwner(program, property.ReadAccessor, user);
                            }
                            if (property.WriteAccessor != null)
                            {
                                ChangeObjectOwner(program, property.WriteAccessor, user);
                            }
                        }
                    }
                }
            }
        }