Controls the startup sequence of the Repository. This class is used as a parameter of the Repository.Start(RepositoryStartSettings) method. The startup control information is also available (in read only way) in the RepositoryInstace which the Repository.Start method returns to.
Ejemplo n.º 1
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();
        }
Ejemplo n.º 2
0
 /// <summary>
 /// Executes the boot sequence of the Repository by the passed <see cref="RepositoryStartSettings"/>.
 /// </summary>
 /// <example>
 /// Use the following code in your tool or other outer application:
 /// <code>
 /// var startSettings = new RepositoryStartSettings
 /// {
 ///     PluginsPath = pluginsPath, // Local directory path of plugins if it is different from your tool's path.
 ///     Console = Console.Out      // Startup sequence will be traced to given writer.
 /// };
 /// using (SenseNet.ContentRepository.Repository.Start(startSettings))
 /// {
 ///     // your code
 /// }
 /// </code>
 /// </example>
 /// <remarks>
 /// Repository will be stopped if the returned <see cref="RepositoryStartSettings"/> instance is disposed.
 /// </remarks>
 /// <returns>A new IDisposable <see cref="RepositoryInstance"/> instance.</returns>
 /// <returns></returns>
 public static RepositoryInstance Start(RepositoryStartSettings settings)
 {
     var instance = RepositoryInstance.Start(settings);
     AccessProvider.ChangeToSystemAccount();
     Repository._root = (PortalRoot)Node.LoadNode(RootPath);
     AccessProvider.RestoreOriginalUser();
     return instance;
 }
Ejemplo n.º 3
0
 internal ImmutableRepositoryStartSettings(RepositoryStartSettings settings)
 {
     _startLuceneManager = settings.StartLuceneManager;
     _backupIndexAtTheEnd = settings.BackupIndexAtTheEnd;
     var configRestoreIndex = RepositoryStartSettings.ConfigRestoreIndex;
     _restoreIndex = configRestoreIndex.HasValue ? configRestoreIndex.Value : settings.RestoreIndex;
     _startWorkflowEngine = settings.StartWorkflowEngine;
     _console = settings.Console;
     _pluginsPath = settings.PluginsPath;
     _indexPath = settings.IndexPath;
 }
Ejemplo n.º 4
0
        /// <summary>
        /// Executes the boot sequence of the Repository by the passed <see cref="RepositoryStartSettings"/>.
        /// </summary>
        /// <example>
        /// Use the following code in your tool or other outer application:
        /// <code>
        /// var startSettings = new RepositoryStartSettings
        /// {
        ///     PluginsPath = pluginsPath, // Local directory path of plugins if it is different from your tool's path.
        ///     Console = Console.Out      // Startup sequence will be traced to given writer.
        /// };
        /// using (SenseNet.ContentRepository.Repository.Start(startSettings))
        /// {
        ///     // your code
        /// }
        /// </code>
        /// </example>
        /// <remarks>
        /// Repository will be stopped if the returned <see cref="RepositoryStartSettings"/> instance is disposed.
        /// </remarks>
        /// <returns>A new IDisposable <see cref="RepositoryInstance"/> instance.</returns>
        /// <returns></returns>
        public static RepositoryInstance Start(RepositoryStartSettings settings)
        {
            if (!settings.ExecutingPatches)
            {
                // Switch ON this flag so that inner repository start operations
                // do not try to execute patches again recursively.
                settings.ExecutingPatches = true;

                //TODO: [auto-patch] this feature is not released yet
                //PackageManager.ExecuteAssemblyPatches(settings);
            }

            var instance = RepositoryInstance.Start(settings);
            SystemAccount.Execute(() => Root);
            return instance;
        }
Ejemplo n.º 5
0
        static void Main(string[] args)
        {
            var startSettings = new RepositoryStartSettings
            {
                Console = Console.Out,
                StartLuceneManager = true
            };
            using (Repository.Start(startSettings))
            {
                using (var traceOperation = Logger.TraceOperation("SyncPortal2AD", string.Empty, AdLog.AdSyncLogCategory))
                {
                    ADProvider.RetryAllFailedActions();

                    traceOperation.IsSuccessful = true;
                }
            }
        }
Ejemplo n.º 6
0
            internal ImmutableRepositoryStartSettings(RepositoryStartSettings settings)
            {
                IsWebContext        = settings.IsWebContext;
                ExecutingPatches    = settings.ExecutingPatches;
                StartIndexingEngine = settings.StartIndexingEngine;
                StartWorkflowEngine = settings.StartWorkflowEngine;
                Console             = settings.Console;
                PluginsPath         = settings.PluginsPath;
                IndexPath           = settings.IndexPath;

                TraceCategories = settings.TraceCategories;

                if (settings is RepositoryBuilder builder)
                {
                    Services = builder.Services;
                }
            }
Ejemplo n.º 7
0
        static void Main(string[] args)
        {
            var startSettings = new RepositoryStartSettings
            {
                Console = Console.Out,
                StartLuceneManager = true
            };
            using (var repo = Repository.Start(startSettings))
            {
                using (var traceOperation = Logger.TraceOperation("SyncAD2Portal", string.Empty, AdLog.AdSyncLogCategory))
                {
                    SyncAD2Portal directoryServices = new SyncAD2Portal();
                    directoryServices.SyncFromAD();

                    traceOperation.IsSuccessful = true;
                }
            }
        }
Ejemplo n.º 8
0
 internal static RepositoryInstance Start(RepositoryStartSettings settings)
 {
     if (!_started)
     {
         lock (_startupSync)
         {
             if (!_started)
             {
                 var instance = new RepositoryInstance();
                 instance._settings = new RepositoryStartSettings.ImmutableRepositoryStartSettings(settings);
                 _instance = instance;
                 try
                 {
                     instance.DoStart();
                 }
                 catch (SqlException) //Workaround for VPN connectivity problem in LR office
                 {
                     Thread.Sleep(5000);
                     try
                     {
                         instance.DoStart();
                     }
                     catch (Exception)
                     {
                         _instance = null;
                         throw;
                     }
                 }
                 catch (Exception)
                 {
                     _instance = null;
                     throw;
                 }
                 _started = true;
             }
         }
     }
     return _instance;
 }
Ejemplo n.º 9
0
 internal static RepositoryInstance Start(RepositoryStartSettings settings)
 {
     if (!_started)
     {
         lock (_startupSync)
         {
             if (!_started)
             {
                 var instance = new RepositoryInstance();
                 instance._settings = new RepositoryStartSettings.ImmutableRepositoryStartSettings(settings);
                 _instance          = instance;
                 try
                 {
                     instance.DoStart();
                 }
                 catch (SqlException) //Workaround for VPN connectivity problem in LR office
                 {
                     Thread.Sleep(5000);
                     try
                     {
                         instance.DoStart();
                     }
                     catch (Exception)
                     {
                         _instance = null;
                         throw;
                     }
                 }
                 catch (Exception)
                 {
                     _instance = null;
                     throw;
                 }
                 _started = true;
             }
         }
     }
     return(_instance);
 }
Ejemplo n.º 10
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();
        }
Ejemplo n.º 11
0
        static void Main(string[] args)
        {
            Dictionary<string, string> parameters;
            string message;
            if (!ParseParameters(args, ArgNames, out parameters, out message))
            {
                Usage(message);
                return;
            }

            string repositoryPath = parameters.ContainsKey("SOURCE") ? parameters["SOURCE"] : "/Root";
            string asmPath = parameters.ContainsKey("ASM") ? parameters["ASM"] : null;
            string fsPath = parameters.ContainsKey("TARGET") ? parameters["TARGET"] : null;
            bool waitForAttach = parameters.ContainsKey("WAIT");
            string queryPath = parameters.ContainsKey("FILTER") ? parameters["FILTER"] : null;
            if (fsPath == null)
            {
                Usage("Missing -TARGET parameter" + CR);
                return;
            }

            try
            {
                CreateLog();
                if (waitForAttach)
                {
                    LogWriteLine("Running in wait mode - now you can attach to the process with a debugger.");
                    LogWriteLine("Press ENTER to continue.");
                    Console.ReadLine();
                }

                var startSettings = new RepositoryStartSettings
                {
                    Console = Console.Out,
                    StartLuceneManager = true,
                    StartWorkflowEngine = false
                };

                using (Repository.Start(startSettings))
                {
                    Export(repositoryPath, fsPath, queryPath);
                }
            }
            catch (Exception e)
            {
                LogWriteLine("Export ends with error:");
                LogWriteLine(e);
                LogWriteLine(e.StackTrace);
            }
        }
Ejemplo n.º 12
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();
        }
Ejemplo n.º 13
0
        internal static void Run(string ctdPath, string asmPath, string fsPath, string repositoryPath, bool validate)
        {
            if (String.IsNullOrEmpty(ctdPath) && String.IsNullOrEmpty(fsPath))
            {
                LogWriteLine("No changes");
                return;
            }

            var startSettings = new RepositoryStartSettings
            {
                Console = Console.Out,
                StartLuceneManager = StorageContext.Search.IsOuterEngineEnabled,
                PluginsPath = asmPath
            };
            using (Repository.Start(startSettings))
            {
                var installationMode = false;
                try
                {
                    installationMode = IsInstallationMode();
                }
                catch (Exception e)
                {
                    PrintException(e, null);
                    return;
                }

                //-- Install ContentTypes
                if (String.IsNullOrEmpty(ctdPath))
                {
                    LogWriteLine("ContentTypeDefinitions are not changed");
                }
                else
                {
                    if (installationMode)
                    {
                        StorageContext.Search.DisableOuterEngine();
                        LogWriteLine("Indexing is temporarily switched off." + CR);
                    }

                    InstallContentTypeDefinitions(ctdPath);

                    if (installationMode)
                    {
                        StorageContext.Search.EnableOuterEngine();
                        CreateInitialIndex();
                        LogWriteLine("Indexing is switched on." + CR);
                    }
                }

                //-- Create missing index documents
                SaveInitialIndexDocuments();

                //-- Import Contents
                if (!String.IsNullOrEmpty(fsPath))
                    ImportContents(fsPath, repositoryPath, validate);
                else
                    LogWriteLine("Contents are not changed");
            }
        }