Esempio n. 1
0
        public override void OnAfterRepositoryStart(RepositoryInstance repository)
        {
            var state = DistributedIndexingActivityQueue.GetCurrentState();

            DistributedIndexingActivityQueue._setCurrentExecutionState(IndexingActivityStatus.Startup);
            base.OnAfterRepositoryStart(repository);
        }
Esempio n. 2
0
        protected virtual void Application_Start(object sender, EventArgs e, HttpApplication application)
        {
            using (var op = SnTrace.Repository.StartOperation("Application_Start. Process: {0}, AppDomain: {1}, ",
                                                              System.Diagnostics.Process.GetCurrentProcess().Id, AppDomain.CurrentDomain.Id))
            {
                var runOnceMarkerPath = application.Server.MapPath("/" + RunOnceGuid);
                var firstRun          = File.Exists(runOnceMarkerPath);
                var startConfig       = new RepositoryStartSettings {
                    StartLuceneManager = !firstRun, IsWebContext = true
                };

                RepositoryInstance.WaitForWriterLockFileIsReleased(RepositoryInstance.WaitForLockFileType.OnStart);

                Repository.Start(startConfig);

                RepositoryVersionInfo.CheckComponentVersions();

                StorageContext.L2Cache = new L2CacheImpl();

                RegisterRoutes(RouteTable.Routes, application);
                RepositoryPathProvider.Register();

                op.Successful = true;
            }
        }
Esempio n. 3
0
        /* ============================================================================================================ static handlers */
        protected static void ApplicationStartHandler(object sender, EventArgs e, HttpApplication application)
        {
            var runOnceMarkerPath = application.Server.MapPath("/" + RunOnceGuid);
            var firstRun          = File.Exists(runOnceMarkerPath);
            var startConfig       = new SenseNet.ContentRepository.RepositoryStartSettings {
                StartLuceneManager = !firstRun
            };

            RepositoryInstance.WaitForWriterLockFileIsReleased(RepositoryInstance.WaitForLockFileType.OnStart);

            Repository.Start(startConfig);

            //-- <L2Cache>
            StorageContext.L2Cache = new L2CacheImpl();
            //-- </L2Cache>

            RegisterRoutes(RouteTable.Routes);
            RepositoryPathProvider.Register();

            //Database.SetInitializer(new InDocContextInitializer());

            //using (var context = DependencyResolver.Current.GetService<InDocContext>())
            //{
            //    context.Database.Initialize(false);
            //}

            //preload
            WarmUp.Preload();
        }
Esempio n. 4
0
        protected virtual void Application_Start(object sender, EventArgs e, HttpApplication application)
        {
            var op = DetailedLogger.CreateOperation();   // category: general

            DetailedLogger.Log(op, "Application_Start"); // category: general

            var runOnceMarkerPath = application.Server.MapPath("/" + RunOnceGuid);
            var firstRun          = File.Exists(runOnceMarkerPath);
            var startConfig       = new ContentRepository.RepositoryStartSettings {
                StartLuceneManager = !firstRun
            };

            RepositoryInstance.WaitForWriterLockFileIsReleased(RepositoryInstance.WaitForLockFileType.OnStart);

            Repository.Start(startConfig);

            //-- <L2Cache>
            StorageContext.L2Cache = new L2CacheImpl();
            //-- </L2Cache>

            GlobalConfiguration.Configure(WebApiConfiguration.Register);
            RegisterRoutes(RouteTable.Routes, application);
            RepositoryPathProvider.Register();

            //preload
            WarmUp.Preload();

            op.Finish(); // category: general
        }
Esempio n. 5
0
        public static void InitializeRepositoryInstance(TestContext context)
        {
            Cache.Reset();
            ContentTypeManager.Reset();
            var portalContextAcc = new PrivateType(typeof(PortalContext));

            portalContextAcc.SetStaticField("_sites", new Dictionary <string, Site>());

            var builder = CreateRepositoryBuilderForTest();

            Indexing.IsOuterSearchEngineEnabled = true;

            _repository = Repository.Start(builder);

            Cache.Reset();
            ContentTypeManager.Reset();

            using (new SystemAccount())
            {
                SecurityHandler.CreateAclEditor()
                .Allow(Identifiers.PortalRootId, Identifiers.AdministratorsGroupId, false, PermissionType.BuiltInPermissionTypes)
                .Allow(Identifiers.PortalRootId, Identifiers.AdministratorUserId, false, PermissionType.BuiltInPermissionTypes)
                .Apply();
            }
        }
Esempio n. 6
0
 public Controller(IXSocketClient client, string controller)
 {
     this.Subscriptions = new RepositoryInstance<string, ISubscription>();
     this.Listeners = new RepositoryInstance<string, IListener>();
     this.AddDefaultSubscriptions();
     this.ClientInfo = new ClientInfo{PersistentId = client.PersistentId, Controller = controller};
     this.XSocketClient = client;
 }
Esempio n. 7
0
        /// <summary>
        /// Sets the items database and feeds.db database files to non-deployed paths
        /// </summary>
        public void UnitTestMode()
        {
            var feedDatabaseConnection = string.Format("Data Source={0}/Feeds.db;Version=3;", "/Volumes/Public/Monotouch/ReallySimple/ReallySimple.UI");
            var userDatabaseFilePath   = string.Format("{0}/User.db", "/tmp");

            string itemsDbFilePath        = string.Format("{0}/{1}", Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments), Settings.Current.ItemsDatabaseFilename);
            var    userDatabaseConnection = string.Format("Data Source={0};Version=3;", itemsDbFilePath);

            RepositoryInstance.WipeUserDatabase();
        }
Esempio n. 8
0
 public Controller(IXSocketClient client, string controller)
 {
     this.queuedFrames  = new List <byte>();
     this.Subscriptions = new RepositoryInstance <string, ISubscription>();
     this.Listeners     = new RepositoryInstance <string, IListener>();
     this.AddDefaultSubscriptions();
     this.ClientInfo = new ClientInfo {
         PersistentId = client.PersistentId, Controller = controller
     };
     this.XSocketClient = client;
 }
Esempio n. 9
0
        private async Task IntegrationTestAsync(bool isolated, Func <Task> callback, Func <SystemFolder, Task> callbackWithSandbox)
        {
            var platformName   = Platform.GetType().Name;
            var needToStartNew = isolated || _repositoryInstance == null || platformName != _lastPlatformName;

            if (needToStartNew)
            {
                Logger.Log("  (cleanup repository)");
                _repositoryInstance?.Dispose();
                _repositoryInstance = null;
                _lastPlatformName   = null;

                var builder = Platform.CreateRepositoryBuilder();

                Logger.Log("  start new repository");
                _repositoryInstance = Repository.Start(builder);
                _lastPlatformName   = platformName;

                //PrepareRepository();
            }

            SystemFolder sandbox = null;

            try
            {
                using (new SystemAccount())
                {
                    if (callback != null)
                    {
                        await callback();
                    }
                    else
                    {
                        await callbackWithSandbox(sandbox = CreateSandbox());
                    }
                }
            }
            finally
            {
                if (sandbox != null)
                {
                    using (new SystemAccount())
                        sandbox.ForceDelete();
                }

                if (isolated)
                {
                    Logger.Log("  cleanup repository");
                    _repositoryInstance?.Dispose();
                    _repositoryInstance = null;
                    _lastPlatformName   = null;
                }
            }
        }
Esempio n. 10
0
        private void IntegrationTest <T>(bool isolated, Action callback, Action <T> callbackWithSandbox) where T : GenericContent
        {
            var platformName   = Platform.GetType().Name;
            var needToStartNew = isolated || _repositoryInstance == null || platformName != _lastPlatformName;

            if (needToStartNew)
            {
                Logger.Log("  (cleanup repository)");
                _repositoryInstance?.Dispose();
                _repositoryInstance = null;
                _lastPlatformName   = null;

                var builder = Platform.CreateRepositoryBuilder();

                Logger.Log("  start new repository");
                _repositoryInstance = Repository.Start(builder);
                _lastPlatformName   = platformName;

                //PrepareRepository();
            }

            T sandbox = null;

            try
            {
                using (new SystemAccount())
                    if (callback != null)
                    {
                        callback();
                    }
                    else
                    {
                        callbackWithSandbox(sandbox = CreateSandbox <T>());
                    }
            }
            finally
            {
                if (sandbox != null)
                {
                    using (new SystemAccount())
                        sandbox.ForceDelete();
                }

                if (isolated)
                {
                    Logger.Log("  cleanup repository");
                    _repositoryInstance?.Dispose();
                    _repositoryInstance = null;
                    _lastPlatformName   = null;
                }
            }
        }
Esempio n. 11
0
        public void InitializeTest()
        {
            // workaround for having a half-started repository
            if (RepositoryInstance.Started())
            {
                RepositoryInstance.Shutdown();
            }

            // the original collector default value is a class that is not available in this context
            Providers.PropertyCollectorClassName = typeof(EventPropertyCollector).FullName;

            SnTrace.Test.Enabled = true;
            SnTrace.Test.Write("START test: {0}", TestContext.TestName);
        }
Esempio n. 12
0
        public void ClearCache(bool deleteImages)
        {
            ImageDownloader.Current.TryStop();
            RepositoryInstance.WipeUserDatabase();
            ItemCache.Current.Clear();

            LastUpdate       = DateTime.Now.AddDays(-1);
            LastControllerId = "";
            LastItemId       = "";

            if (deleteImages)
            {
                ClearImageCache();
            }
        }
Esempio n. 13
0
        private async Task ODataTestAsync(IUser user, Action <RepositoryBuilder> initialize, Func <Task> callback, bool reused)
        {
            Cache.Reset();

            if (!reused || _repository == null)
            {
                _repository?.Dispose();
                _repository = null;

                var repoBuilder = CreateRepositoryBuilder();
                if (initialize != null)
                {
                    initialize(repoBuilder);
                }

                Indexing.IsOuterSearchEngineEnabled = true;
                _repository = Repository.Start(repoBuilder);
            }

            if (user == null)
            {
                using (new SystemAccount())
                    await callback().ConfigureAwait(false);
            }
            else
            {
                IUser backup = null;
                try
                {
                    backup       = User.Current;
                    User.Current = user;
                    await callback().ConfigureAwait(false);
                }
                finally
                {
                    User.Current = backup;
                }
            }

            if (!reused)
            {
                _repository?.Dispose();
                _repository = null;
            }
        }
Esempio n. 14
0
        public void InitializeTest()
        {
            // workaround for having a half-started repository
            if (RepositoryInstance.Started())
            {
                RepositoryInstance.Shutdown();
            }

            SnTrace.Test.Enabled = true;

            if (_testMethodOperation != null)
            {
                SnTrace.Test.Write("The operation was forced to close.");
                _testMethodOperation.Successful = false;
                _testMethodOperation.Dispose();
            }
            _testMethodOperation = SnTrace.Test.StartOperation("TESTMETHOD: " + TestContext.TestName);
        }
Esempio n. 15
0
        public static void InitializeRepositoryInstance(TestContext context)
        {
            DistributedApplication.Cache.Reset();
            ContentTypeManager.Reset();

            var builder = CreateRepositoryBuilderForTest();

            Indexing.IsOuterSearchEngineEnabled = true;

            _repository = Repository.Start(builder);

            using (new SystemAccount())
            {
                SecurityHandler.CreateAclEditor()
                .Allow(Identifiers.PortalRootId, Identifiers.AdministratorsGroupId, false, PermissionType.BuiltInPermissionTypes)
                .Allow(Identifiers.PortalRootId, Identifiers.AdministratorUserId, false, PermissionType.BuiltInPermissionTypes)
                .Apply();
            }
        }
Esempio n. 16
0
        protected virtual void Application_Start(object sender, EventArgs e, HttpApplication application)
        {
            var runOnceMarkerPath = application.Server.MapPath("/" + RunOnceGuid);
            var firstRun          = File.Exists(runOnceMarkerPath);
            var startConfig       = new SenseNet.ContentRepository.RepositoryStartSettings {
                StartLuceneManager = !firstRun
            };

            RepositoryInstance.WaitForWriterLockFileIsReleased(RepositoryInstance.WaitForLockFileType.OnStart);

            Repository.Start(startConfig);

            //-- <L2Cache>
            StorageContext.L2Cache = new L2CacheImpl();
            //-- </L2Cache>

            RegisterRoutes(RouteTable.Routes, application);
            RepositoryPathProvider.Register();

            //preload
            WarmUp.Preload();
        }
Esempio n. 17
0
 public static void CleanupClass()
 {
     Logger.Log("  ((cleanup repository))");
     _repositoryInstance?.Dispose();
     _repositoryInstance = null;
 }
Esempio n. 18
0
 public virtual void OnAfterRepositoryStart(RepositoryInstance repository)
 {
 }