コード例 #1
0
ファイル: DBTypeManager.cs プロジェクト: ipbi/sones
        public DBTypeManager(DBTypeManager dBTypeManager)
        {
            _DBContext                                      = dBTypeManager._DBContext;
            _UserID                                         = dBTypeManager._UserID;
            _DatabaseRootPath                               = dBTypeManager._DatabaseRootPath;
            _IGraphFSSession                                = dBTypeManager._IGraphFSSession;
            _ObjectLocationsOfAllUserDefinedDatabaseTypes   = dBTypeManager._ObjectLocationsOfAllUserDefinedDatabaseTypes;

            _SystemTypes                                    = dBTypeManager._SystemTypes;
            _BasicTypes                                     = dBTypeManager._BasicTypes;
            _GUIDTypeAttribute                              = dBTypeManager._GUIDTypeAttribute;

            //TODO: As soon as we have serialized Indices we can recomment these sections
            #region As soon as we have serialized Indices we can recomment these sections

            //_UserDefinedTypes                               = dBTypeManager._UserDefinedTypes;
            //_TypesNameLookUpTable                           = dBTypeManager._TypesNameLookUpTable;

            foreach (GraphDBType ptype in _SystemTypes.Values)
                _TypesNameLookUpTable.Add(ptype.Name, ptype);

            foreach (GraphDBType ptype in _BasicTypes.Values)
                _TypesNameLookUpTable.Add(ptype.Name, ptype);

            LoadUserDefinedDatabaseTypes(false);

            #endregion
        }
コード例 #2
0
ファイル: DBTypeManager.cs プロジェクト: ipbi/sones
 /// <summary>
 /// The constructor.
 /// </summary>
 /// <param name="myIGraphDBSession">The filesystem where the information is stored.</param>
 /// <param name="DatabaseRootPath">The database root path.</param>
 public DBTypeManager(IGraphFSSession myIGraphFS, ObjectLocation myDatabaseRootPath, EntityUUID myUserID, Dictionary<String, ADBSettingsBase> myDBSettings, DBContext dbContext)
 {
     _DBContext = dbContext;
     _UserID = myUserID;
     _DatabaseRootPath                               = myDatabaseRootPath;
     _IGraphFSSession                                = myIGraphFS;
     _ObjectLocationsOfAllUserDefinedDatabaseTypes   = LoadListOfTypeLocations(myDatabaseRootPath);
 }
コード例 #3
0
ファイル: ADBSettingsBase.cs プロジェクト: TheByte/sones
 public ADBSettingsBase(String myName, String myDescription, EntityUUID myOwnerID, TypeUUID myType, ADBBaseObject myDefault, ADBBaseObject myValue)
 {
     Name        = myName;
     Description = myDescription;
     OwnerID     = myOwnerID;
     Type        = myType;
     Default     = myDefault;
     _Value      = myValue;
 }
コード例 #4
0
ファイル: DBTypeManager.cs プロジェクト: TheByte/sones
        /// <summary>
        /// The constructor.
        /// </summary>
        /// <param name="myIGraphDBSession">The filesystem where the information is stored.</param>
        /// <param name="DatabaseRootPath">The database root path.</param>
        public DBTypeManager(IGraphFSSession myIGraphFS, ObjectLocation myDatabaseRootPath, EntityUUID myUserID, Dictionary<String, ADBSettingsBase> myDBSettings, DBContext dbContext)
        {
            _DBContext = dbContext;
            _UserID = myUserID;
            _DatabaseRootPath                               = myDatabaseRootPath;
            _IGraphFSSession                                = myIGraphFS;
            _ObjectLocationsOfAllUserDefinedDatabaseTypes   = LoadListOfTypeLocations(myDatabaseRootPath);

            dbContext.GraphAppSettings.Subscribe<ObjectsDirectoryShardsSetting>(GraphSettingChanged);
        }
コード例 #5
0
ファイル: DBPluginManager.cs プロジェクト: TheByte/sones
        public DBPluginManager(EntityUUID myUserID, Boolean myIncludePrivateClasses = false)
        {
            _Functions       = new Dictionary<string, ABaseFunction>();
            _Aggregates      = new Dictionary<string, ABaseAggregate>();
            _Operators       = new Dictionary<string, ABinaryOperator>();
            _Settings        = new Dictionary<string, ADBSettingsBase>();
            _EdgeTypes       = new Dictionary<string, IEdgeType>();
            _Indices         = new Dictionary<string, IVersionedIndexObject<IndexKey, ObjectUUID>>();
            _GraphDBImporter = new Dictionary<string, AGraphDBImport>();
            _GraphDBExporter = new Dictionary<string, AGraphDBExport>();
            _UserID          = myUserID;

            FindAndFillReflections(myIncludePrivateClasses);
        }
コード例 #6
0
ファイル: DBContext.cs プロジェクト: ipbi/sones
        /// <summary>
        /// The constructor.
        /// </summary>
        /// <param name="myIGraphDBSession">The filesystem where the information is stored.</param>
        /// <param name="DatabaseRootPath">The database root path.</param>
        public DBContext(IGraphFSSession graphFSSession, ObjectLocation myDatabaseRootPath, EntityUUID myUserID, Dictionary<String, ADBSettingsBase> myDBSettings, Boolean myRebuildIndices, DBPluginManager myDBPluginManager, DBSessionSettings sessionSettings = null)
        {
            _DBPluginManager    = myDBPluginManager;

            _DBTypeManager      = new TypeManagement.DBTypeManager(graphFSSession, myDatabaseRootPath, myUserID, myDBSettings, this);
            _DBSettingsManager  = new DBSettingsManager(_DBPluginManager.Settings, myDBSettings, graphFSSession, new ObjectLocation(myDatabaseRootPath.Name, DBConstants.DBSettingsLocation));
            _DBObjectManager    = new DBObjectManager(this, graphFSSession);
            _DBIndexManager     = new DBIndexManager(graphFSSession, this);
            _SessionSettings    = sessionSettings;
            _DBObjectCache      = _DBObjectManager.GetSimpleDBObjectCache(this);
            _IGraphFSSession    = graphFSSession;

            //init types
            var initExcept = _DBTypeManager.Init(graphFSSession, myDatabaseRootPath, myRebuildIndices);

            if (initExcept.Failed())
            {
                throw new GraphDBException(initExcept.IErrors);
            }
        }
コード例 #7
0
ファイル: ADBSettingsBase.cs プロジェクト: TheByte/sones
        public void Deserialize(byte[] mySerializedData)
        {
            #region Data
            SerializationReader reader;

            reader = new SerializationReader(mySerializedData);

            #endregion

            #region Read Basics
            try
            {
                Name                = reader.ReadString();
                Description         = reader.ReadString();
                OwnerID             = new EntityUUID(reader.ReadByteArray());
                Type                = new TypeUUID(reader.ReadByteArray());
                Default.SetValue(reader.ReadObject());
                _Value.SetValue(reader.ReadObject());
            }
            catch (Exception e)
            {
                throw new GraphFSException_EntityCouldNotBeDeserialized("ADBSetting could not be deserialized!\n\n" + e);
            }
            #endregion
        }
コード例 #8
0
 public ANonPersistentSetting(String myName, String myDesc, EntityUUID myOwner, UUID myType, ADBBaseObject myDefault)
 {
 }
コード例 #9
0
ファイル: DBPluginManager.cs プロジェクト: Vadi/sones
        public DBPluginManager(EntityUUID myUserID, Boolean myIncludePrivateClasses = false)
        {
            #region lookup dictionaries

            _Functions = new Dictionary<string, ABaseFunction>();
            _Aggregates = new Dictionary<string, ABaseAggregate>();
            _Operators = new Dictionary<string, ABinaryOperator>();
            _Settings = new Dictionary<string, ADBSettingsBase>();
            _EdgeTypes = new Dictionary<string, IEdgeType>();
            _Indices = new Dictionary<string, AAttributeIndex>();
            _GraphDBImporter = new Dictionary<string, AGraphDBImport>();
            _GraphDBExporter = new Dictionary<string, AGraphDBExport>();
            _UserID = myUserID;

            #endregion

            #region Register & Discover

            //FindAndFillReflections(myIncludePrivateClasses);

            // Change the version if there are ANY changes which will prevent loading the plugin.
            // As long as there are still some plugins which does not have their own assembly you need to change the compatibility of ALL plugins of the GraphDB and GraphFSInterface assembly.
            // So, if any plugin in the GraphDB changes you need to change the AssemblyVersion of the GraphDB AND modify the compatibility version of the other plugins.
            _PluginManager = new PluginManager()
                .Register<IGraphDBFunction>(IGraphDBFunctionVersionCompatibility.MinVersion, IGraphDBFunctionVersionCompatibility.MaxVersion)
                .Register<IGraphDBAggregate>(IGraphDBAggregateVersionCompatibility.MinVersion, IGraphDBAggregateVersionCompatibility.MaxVersion)
                .Register<IGraphDBSetting>(IGraphDBSettingVersionCompatibility.MinVersion, IGraphDBSettingVersionCompatibility.MaxVersion)
                .Register<ABinaryOperator>(new Version("1.0.0.0"))  // GraphDB assembly
                .Register<IEdgeType>(new Version("1.0.0.0"))        // GraphDB assembly
                .Register<AGraphDBImport>(new Version("1.0.0.0"))   // GraphDB assembly
                .Register<AGraphDBExport>(new Version("1.0.0.0"))   // GraphDB assembly

                .Register<AAttributeIndex>(new Version("1.0.0.0")) // GraphDB assembly
                ;

            _PluginManager.Discover(true, !myIncludePrivateClasses)
                .FailedAction(e => { throw new Exception(e.GetIErrorsAsString()); });

            #endregion

            #region Get all plugins and fill the lookup dictionaries

            #region Functions

            foreach (var func in _PluginManager.GetPlugins<IGraphDBFunction>())
            {
                var funcname = (func as ABaseFunction).FunctionName.ToUpper();

                #region Verify that there is no aggregate with the same name if the current function has parameters

                if (_Aggregates.ContainsKey(funcname) && (func as ABaseFunction).GetParameters().IsNotNullOrEmpty())
                {
                    throw new GraphDBException(new Error_DuplicateAggregateOrFunction(funcname, false));
                }

                #endregion

                #region Add function if the name does not exist

                if (!_Functions.ContainsKey(funcname))
                {
                    _Functions.Add(funcname, (func as ABaseFunction));
                }
                else
                {
                    throw new GraphDBException(new Error_DuplicateAggregateOrFunction(funcname));
                }

                #endregion

            }

            #endregion

            #region Aggregates

            foreach (var aggr in _PluginManager.GetPlugins<IGraphDBAggregate>())
            {
                var aggrname = (aggr as ABaseAggregate).FunctionName.ToUpper();

                #region Verify that there is no function with parameters and the same name

                if (_Functions.ContainsKey(aggrname) && _Functions[aggrname].GetParameters().IsNotNullOrEmpty())
                {
                    throw new GraphDBException(new Error_DuplicateAggregateOrFunction(aggrname));
                }

                #endregion

                #region Add aggregate if it does not exist

                if (!_Aggregates.ContainsKey(aggrname))
                {
                    _Aggregates.Add(aggrname, (aggr as ABaseAggregate));
                }
                else
                {
                    throw new GraphDBException(new Error_DuplicateAggregateOrFunction(aggrname, false));
                }

                #endregion

            }

            #endregion

            #region BinaryOperators

            foreach (var plugin in _PluginManager.GetPlugins<ABinaryOperator>())
            {
                foreach (String sym in plugin.Symbol)
                {
                    if (!_Operators.ContainsKey(sym))
                    {
                        // not in the operator list
                        _Operators.Add(sym, plugin);
                    }
                }
            }

            #endregion

            #region Settings

            foreach (var plugin in _PluginManager.GetPlugins<IGraphDBSetting>())
            {
                var newSetting = plugin as ADBSettingsBase;
                if (!_Settings.ContainsKey(newSetting.Name))
                {
                    _Settings.Add(newSetting.Name, newSetting);
                }
            }

            #endregion

            #region EdgeType

            foreach (var plugin in _PluginManager.GetPlugins<IEdgeType>())
            {
                if (!_EdgeTypes.ContainsKey(plugin.EdgeTypeName.ToLower()))
                {
                    _EdgeTypes.Add(plugin.EdgeTypeName.ToLower(), plugin);
                }
            }

            #endregion

            #region AGraphDBImport

            foreach (var plugin in _PluginManager.GetPlugins<AGraphDBImport>())
            {
                if (!_GraphDBImporter.ContainsKey(plugin.ImportFormat.ToUpper()))
                {
                    _GraphDBImporter.Add(plugin.ImportFormat.ToUpper(), plugin);
                }
            }

            #endregion

            #region AGraphDBExport

            foreach (var plugin in _PluginManager.GetPlugins<AGraphDBExport>())
            {
                if (!_GraphDBExporter.ContainsKey(plugin.ExportFormat.ToUpper()))
                {
                    _GraphDBExporter.Add(plugin.ExportFormat.ToUpper(), plugin);
                }
            }

            #endregion

            #region Index

            //foreach (var plugin in _PluginManager.GetPlugins<IVersionedIndexObject<IndexKey, ObjectUUID>>())
            foreach (var plugin in _PluginManager.GetPlugins<AAttributeIndex>())
            {

                //var idx = (IVersionedIndexObject<IndexKey, ObjectUUID>)Activator.CreateInstance(type.MakeGenericType(typeof(IndexKey), typeof(ObjectUUID)));
                var idx = plugin;
                if (!_Indices.ContainsKey(idx.IndexType.ToUpper()))
                {
                    _Indices.Add(idx.IndexType.ToUpper(), idx);
                }
            }

            #endregion

            #endregion
        }
コード例 #10
0
ファイル: AccessControlObject.cs プロジェクト: ipbi/sones
        /// <summary>
        /// Removes an entity from the AllowACL
        /// </summary>
        /// <param name="myEntityUUID">The UUID which references the entity.</param>
        /// <param name="myRightUUID">The UUID which references the right to be denied.</param>
        public void RemoveFromDenyACL(EntityUUID myEntityUUID, RightUUID myRightUUID)
        {
            if (myEntityUUID == null)
                throw new ArgumentNullException("The EntityUUID must not be null!");

            if (myRightUUID == null)
                throw new ArgumentNullException("The RightUUID must not be null!");

            lock (_DenyACL)
            {

                if (_DenyACL.ContainsKey(myRightUUID))
                    _DenyACL[myRightUUID].Remove(myEntityUUID);

            }

            isDirty = true;
        }
コード例 #11
0
ファイル: AccessControlObject.cs プロジェクト: ipbi/sones
        public override void Deserialize(ref SerializationReader mySerializationReader)
        {
            #region Data

            UInt64               _NumberOfACLs;
            RightUUID            _RightUUID;
            EntityUUID           _EntityUUID;
            UInt64               _NumberOfEntityUUIDs;
            HashSet<EntityUUID>  _EntityUUIDHashSet;

            #endregion

            try
            {

                #region NotificationHandling

                _NotificationHandling = (NHAccessControlObject)mySerializationReader.ReadOptimizedByte();

                #endregion

                #region DefaultRule

                _DefaultRule = (DefaultRuleTypes)mySerializationReader.ReadOptimizedByte();

                #endregion

                #region AllowACL

                _AllowACL = new Dictionary<RightUUID, HashSet<EntityUUID>>();

                _NumberOfACLs = mySerializationReader.ReadUInt64();

                for (UInt64 i=0; i<_NumberOfACLs; i++)
                {

                    #region KEY

                    _RightUUID = new RightUUID(mySerializationReader.ReadByteArray());

                    #endregion

                    #region VALUE

                    _EntityUUIDHashSet = new HashSet<EntityUUID>();

                    _NumberOfEntityUUIDs = mySerializationReader.ReadUInt64();

                    for (UInt64 j=0; j<_NumberOfEntityUUIDs; j++)
                    {
                        _EntityUUID = new EntityUUID(mySerializationReader.ReadByteArray());
                        _EntityUUIDHashSet.Add(_EntityUUID);
                    }

                    // Finally... add it to the AllowACL!
                    _AllowACL.Add(_RightUUID, _EntityUUIDHashSet);

                    #endregion

                }

                #endregion

                #region DenyACL

                _DenyACL = new Dictionary<RightUUID, HashSet<EntityUUID>>();

                _NumberOfACLs = mySerializationReader.ReadUInt64();

                for (UInt64 i=0; i<_NumberOfACLs; i++)
                {

                    #region KEY

                    _RightUUID = new RightUUID(mySerializationReader.ReadByteArray());

                    #endregion

                    #region VALUE

                    _EntityUUIDHashSet = new HashSet<EntityUUID>();

                    _NumberOfEntityUUIDs = mySerializationReader.ReadUInt64();

                    for (UInt64 j=0; j<_NumberOfEntityUUIDs; j++)
                    {
                        _EntityUUID = new EntityUUID(mySerializationReader.ReadByteArray());
                        _EntityUUIDHashSet.Add(_EntityUUID);
                    }

                    // Finally... add it to the DenyACL!
                    _DenyACL.Add(_RightUUID, _EntityUUIDHashSet);

                    #endregion

                }

                #endregion

            }

            catch (Exception e)
            {
                throw new GraphFSException_AccessControlObjectCouldNotBeDeserialized("AccessControlObject could not be deserialized!\n\n" + e);
            }
        }
コード例 #12
0
ファイル: AccessControlObject.cs プロジェクト: ipbi/sones
        /// <summary>
        /// Add an entity to the DenyACL
        /// </summary>
        /// <param name="myEntityUUID">The UUID which references the entity.</param>
        /// <param name="myRightUUID">The UUID which references the right to be granted.</param>
        public void AddToDenyACL(EntityUUID myEntityUUID, RightUUID myRightUUID)
        {
            if (myEntityUUID == null)
                throw new ArgumentNullException("The EntityUUID must not be null!");

            if (myRightUUID == null)
                throw new ArgumentNullException("The RightUUID must not be null!");

            lock (_DenyACL)
            {

                if (_DenyACL.ContainsKey(myRightUUID))
                    _DenyACL[myRightUUID].Add(myEntityUUID);

                else
                {
                    // Create new RightKey and empty HashSet within the AllowACL
                    HashSet<EntityUUID> _HashSet = new HashSet<EntityUUID>();
                    _HashSet.Add(myEntityUUID);
                    _DenyACL.Add(myRightUUID, _HashSet);
                }

            }

            isDirty = true;
        }
コード例 #13
0
ファイル: AccessControlObject.cs プロジェクト: TheByte/sones
        /// <summary>
        /// Removes an entity from the AllowACL
        /// </summary>
        /// <param name="myEntityUUID">The UUID which references the entity.</param>
        /// <param name="myRightUUID">The UUID which references the right to be denied.</param>
        public void RemoveFromDenyACL(EntityUUID myEntityUUID, RightUUID myRightUUID)
        {
            if (myEntityUUID == null)
                throw new ArgumentNullException("The EntityUUID must not be null!");

            if (myRightUUID == null)
                throw new ArgumentNullException("The RightUUID must not be null!");

            lock (_DenyACL)
            {

                if (_DenyACL.ContainsKey(myRightUUID))
                {
                    if (_DenyACL[myRightUUID].Remove(myEntityUUID))
                    {
                        _estimatedSize -= EstimatedSizeConstants.CalcUUIDSize(myEntityUUID);
                    }
                }

            }

            isDirty = true;
        }
コード例 #14
0
ファイル: AccessControlObject.cs プロジェクト: TheByte/sones
        /// <summary>
        /// Add an entity to the AllowACL
        /// </summary>
        /// <param name="myEntityUUID">The UUID which references the entity.</param>
        /// <param name="myRightUUID">The UUID which references the right to be granted.</param>
        public void AddToAllowACL(EntityUUID myEntityUUID, RightUUID myRightUUID)
        {
            if (myEntityUUID == null)
                throw new ArgumentNullException("The EntityUUID must not be null!");

            if (myRightUUID == null)
                throw new ArgumentNullException("The RightUUID must not be null!");

            lock (_AllowACL)
            {

                if (_AllowACL.ContainsKey(myRightUUID))
                {
                    _AllowACL[myRightUUID].Add(myEntityUUID);
                }
                else
                {
                    // Create new RightKey and empty HashSet within the AllowACL
                    HashSet<EntityUUID> _HashSet = new HashSet<EntityUUID>();
                    _HashSet.Add(myEntityUUID);
                    _AllowACL.Add(myRightUUID, _HashSet);

                    _estimatedSize += EstimatedSizeConstants.HashSet;
                    _estimatedSize += EstimatedSizeConstants.CalcUUIDSize(myRightUUID);
                }

                _estimatedSize += EstimatedSizeConstants.CalcUUIDSize(myEntityUUID);

            }

            isDirty = true;
        }