コード例 #1
0
        public static void Setup(out N2.Edit.IEditManager editor, out IVersionManager versions, IDefinitionManager definitions, IPersister persister, IItemFinder finder)
        {
            var changer = new N2.Edit.Workflow.StateChanger();

            versions = new VersionManager(persister.Repository, finder, changer, new N2.Configuration.EditSection());
            editor   = new EditManager(definitions, persister, versions, new SecurityManager(new ThreadContext(), new EditSection()), null, null, null, changer, new EditableHierarchyBuilder(new SecurityManager(new ThreadContext(), new EditSection()), new EngineSection()), null);
        }
コード例 #2
0
ファイル: VersionManager.cs プロジェクト: rohancragg/n2cms
		public VersionManager(ContentVersionRepository versionRepository, IContentItemRepository itemRepository, StateChanger stateChanger, EditSection config)
		{
			this.Repository = versionRepository;
			this.itemRepository = itemRepository;
			this.stateChanger = stateChanger;
			maximumVersionsPerItem = config.Versions.MaximumPerItem;
		}
コード例 #3
0
        public static ContentItem CloneForVersioningRecursive(this ContentItem item, StateChanger stateChanger = null, bool asPreviousVersion = true)
        {
            ContentItem clone = item.Clone(false);
            if (stateChanger != null)
            {
                if (item.State == ContentState.Published && asPreviousVersion)
                    stateChanger.ChangeTo(clone, ContentState.Unpublished);
                else if (item.State != ContentState.Unpublished || asPreviousVersion == false)
                    stateChanger.ChangeTo(clone, ContentState.Draft);
            }
            clone.Updated = Utility.CurrentTime().AddSeconds(-1);
            clone.Parent = null;
            clone.AncestralTrail = "/";
            clone.VersionOf = item.VersionOf.Value ?? item;

            CopyAutoImplementedProperties(item, clone);

            foreach (var child in item.Children.Where(c => !c.IsPage))
            {
                var childClone = child.CloneForVersioningRecursive(stateChanger, asPreviousVersion);
                childClone.AddTo(clone);
            }

            return clone;
        }
コード例 #4
0
ファイル: CommandFactory.cs プロジェクト: navneetccna/n2cms
        public CommandFactory(IPersister persister, ISecurityManager security, IVersionManager versionMaker, IEditUrlManager editUrlManager, IContentAdapterProvider adapters, StateChanger changer)
        {
            this.persister = persister;
            makeVersionOfMaster = On.Master(new MakeVersionCommand(versionMaker));
            replaceMaster = new ReplaceMasterCommand(versionMaker);
            makeVersion = new MakeVersionCommand(versionMaker);
            useNewVersion = new UseNewVersionCommand(versionMaker);
            updateObject = new UpdateObjectCommand();
            delete = new DeleteCommand(persister.Repository);
            showPreview = new RedirectToPreviewCommand(adapters);
            showEdit = new RedirectToEditCommand(editUrlManager);
            useMaster = new UseMasterCommand();
            clone = new CloneCommand();
            validate = new ValidateCommand();
            this.security = security;
            save = new SaveCommand(persister);
            incrementVersionIndex = new IncrementVersionIndexCommand(versionMaker);
            draftState = new UpdateContentStateCommand(changer, ContentState.Draft);
            publishedState = new UpdateContentStateCommand(changer, ContentState.Published);
            saveActiveContent = new ActiveContentSaveCommand();
			moveToPosition = new MoveToPositionCommand();
			unpublishedDate = new EnsureNotPublishedCommand();
			publishedDate = new EnsurePublishedCommand();
			updateReferences = new UpdateReferencesCommand();
        }
コード例 #5
0
 public VersionManager(IRepository<int, ContentItem> itemRepository, IItemFinder finder, StateChanger stateChanger, EditSection config)
 {
     this.itemRepository = itemRepository;
     this.finder = finder;
     this.stateChanger = stateChanger;
     maximumVersionsPerItem = config.Versions.MaximumPerItem;
 }
コード例 #6
0
        public CommandFactory(IPersister persister, ISecurityManager security, IVersionManager versionMaker, IEditUrlManager editUrlManager, IContentAdapterProvider adapters, StateChanger changer)
        {
            //this.persister = persister;
            //makeVersionOfMaster = On.Master(new MakeVersionCommand(versionMaker));
            //showEdit = new RedirectToEditCommand(editUrlManager);
            //clone = new CloneCommand();
            //unpublishedDate = new EnsureNotPublishedCommand(); // moved to StateChanger
            //ensurePublishedDate = new EnsurePublishedCommand();  // moved to StateChanger

            this.security = security;
            
            save = new SaveCommand(persister);
            delete = new DeleteCommand(persister.Repository);

            replaceMaster = new ReplaceMasterCommand(versionMaker);
            makeVersion = new MakeVersionCommand(versionMaker);
            useDraftCmd = new UseDraftCommand(versionMaker);
            saveOnPageVersion = new SaveOnPageVersionCommand(versionMaker);

            draftState = new UpdateContentStateCommand(changer, ContentState.Draft);
            publishedState = new UpdateContentStateCommand(changer, ContentState.Published);

            updateObject = new UpdateObjectCommand();
            useMaster = new UseMasterCommand();
            validate = new ValidateCommand();
            saveActiveContent = new ActiveContentSaveCommand();
			moveToPosition = new MoveToPositionCommand();
			updateReferences = new UpdateReferencesCommand();
        }
コード例 #7
0
		public PublishScheduledAction(ContentVersionRepository versionRepository, IVersionManager versioner, IPersister persister, ISecurityManager security, StateChanger changer)
		{
			this.versionRepository = versionRepository;
			this.versioner = versioner;
			this.persister = persister;
			this.security = security;
			this.changer = changer;
		}
コード例 #8
0
 public override void SetUp()
 {
     base.SetUp();
     var changer = new StateChanger();
     definitions = TestSupport.SetupDefinitions(typeof(StatefulPage), typeof(StatefulPart));
     versions = new FakeVersionManager(repository, changer, typeof(StatefulPage), typeof(StatefulPart));
     var editManager = new EditUrlManager(null, new EditSection());
     var security = new SecurityManager(new FakeWebContextWrapper(), new EditSection());
     commands = new CommandFactory(persister, security, versions, editManager, null, changer);
     dispatcher = new CommandDispatcher(commands, persister);
     item = CreateOneItem<StatefulPage>(1, "first", null);
     child = CreateOneItem<StatefulPage>(2, "child", item);
 }
コード例 #9
0
        public override void SetUp()
        {
            base.SetUp();

            root = CreateOneItem<RegularPage>(1, "root", null);
            about = CreateOneItem<AboutUsSectionPage>(2, "about", root);
            executives = CreateOneItem<ExecutiveTeamPage>(3, "executives", about);
            search = CreateOneItem<SearchPage>(4, "search", root);

            var typeFinder = new FakeTypeFinder2();
            typeFinder.typeMap[typeof(ContentItem)] = this.NearbyTypes()
                .BelowNamespace("N2.Extensions.Tests.Mvc.Models").AssignableTo<ContentItem>().Union(typeof(ContentItem)).ToArray();
            typeFinder.typeMap[typeof(IController)] = this.NearbyTypes()
                .BelowNamespace("N2.Extensions.Tests.Mvc.Controllers").AssignableTo<IController>().Except(typeof(AnotherRegularController))
                .ToArray();

            var changer = new StateChanger();
            var definitions = new DefinitionManager(new[] { new DefinitionProvider(new DefinitionBuilder(new DefinitionMap(), typeFinder, new TransformerBase<IUniquelyNamed>[0], TestSupport.SetupEngineSection())) }, new ITemplateProvider[0], new ContentActivator(changer, null, new EmptyProxyFactory()), changer);
            httpContext = new FakeHttpContext();
            var webContext = new FakeWebContextWrapper(httpContext);
            var host = new Host(webContext, root.ID, root.ID);
            var parser = TestSupport.Setup(persister, webContext, host);
            controllerMapper = new ControllerMapper(typeFinder, definitions);
            Url.DefaultExtension = "";
            N2.Web.Url.ApplicationPath = "/";

            engine = mocks.DynamicMock<IEngine>();
            SetupResult.For(engine.Resolve<ITypeFinder>()).Return(typeFinder);
            SetupResult.For(engine.Definitions).Return(definitions);
            SetupResult.For(engine.UrlParser).Return(parser);
            SetupResult.For(engine.Persister).Return(persister);
            SetupResult.For(engine.Resolve<RequestPathProvider>()).Return(new RequestPathProvider(webContext, parser, new ErrorNotifier(), new HostSection()));
            var editUrlManager = new FakeEditUrlManager();
            SetupResult.For(engine.ManagementPaths).Return(editUrlManager);
            engine.Replay();

            route = new ContentRoute(engine, new MvcRouteHandler(), controllerMapper, null);

            routes = new RouteCollection { route };
        }
コード例 #10
0
ファイル: IntegrityTests.cs プロジェクト: amarwadi/n2cms
        public override void SetUp()
        {
            base.SetUp();

            CreatePersister();

            parser = mocks.StrictMock <IUrlParser>();

            ITypeFinder       typeFinder = CreateTypeFinder();
            DefinitionBuilder builder    = new DefinitionBuilder(new DefinitionMap(), typeFinder, new EngineSection());
            IItemNotifier     notifier   = mocks.DynamicMock <IItemNotifier>();

            mocks.Replay(notifier);
            var changer = new N2.Edit.Workflow.StateChanger();

            activator       = new ContentActivator(changer, notifier, new EmptyProxyFactory());
            definitions     = new DefinitionManager(new[] { new DefinitionProvider(builder) }, new ITemplateProvider[0], activator, changer);
            finder          = new FakeItemFinder(() => Enumerable.Empty <ContentItem>());
            integrityManger = new IntegrityManager(definitions, finder, parser);
            IntegrityEnforcer enforcer = new IntegrityEnforcer(persister, integrityManger, activator);

            enforcer.Start();
        }
コード例 #11
0
ファイル: FakeVersionManager.cs プロジェクト: Biswo/n2cms
 public FakeVersionManager(FakeContentItemRepository itemRepository, StateChanger stateChanger, params Type[] definitionTypes)
     : base(TestSupport.CreateVersionRepository(definitionTypes), itemRepository, stateChanger, new N2.Configuration.EditSection())
 {
     this.itemRepository = itemRepository;
 }
コード例 #12
0
ファイル: VersionManager.cs プロジェクト: spmason/n2cms
 public VersionManager(IRepository<int, ContentItem> itemRepository, IItemFinder finder, StateChanger stateChanger)
 {
     this.itemRepository = itemRepository;
     this.finder = finder;
     this.stateChanger = stateChanger;
 }
コード例 #13
0
 public FakeVersionManager(FakeRepository<ContentItem> itemRepository, StateChanger stateChanger)
     : base(itemRepository, null, stateChanger, new N2.Configuration.EditSection())
 {
     this.itemRepository = itemRepository;
 }
コード例 #14
0
ファイル: FakeVersionManager.cs プロジェクト: spmason/n2cms
 public FakeVersionManager(FakeRepository<ContentItem> itemRepository, StateChanger stateChanger)
 {
     this.itemRepository = itemRepository;
     original = new VersionManager(itemRepository, null, stateChanger);
 }
コード例 #15
0
        public override void SetUp()
        {
            base.SetUp();

            CreatePersister();

            parser = mocks.StrictMock<IUrlParser>();

            ITypeFinder typeFinder = CreateTypeFinder();
            DefinitionBuilder builder = new DefinitionBuilder(new DefinitionMap(), typeFinder, new EngineSection());
            IItemNotifier notifier = mocks.DynamicMock<IItemNotifier>();
            mocks.Replay(notifier);
            var changer = new N2.Edit.Workflow.StateChanger();
            activator = new ContentActivator(changer, notifier, new EmptyProxyFactory());
            definitions = new DefinitionManager(new[] { new DefinitionProvider(builder) }, new ITemplateProvider[0], activator, changer);
            finder = new FakeItemFinder(() => Enumerable.Empty<ContentItem>());
            integrityManger = new IntegrityManager(definitions, finder, parser);
            IntegrityEnforcer enforcer = new IntegrityEnforcer(persister, integrityManger, activator);
            enforcer.Start();
        }
コード例 #16
0
ファイル: CommandFactory.cs プロジェクト: nikita239/Aspect
        public CommandFactory(IPersister persister, ISecurityManager security, IVersionManager versionMaker, IEditUrlManager editUrlManager, IContentAdapterProvider adapters, StateChanger changer)
        {
            this.persister = persister;
            this.security  = security;

            makeVersionOfMaster = On.Master(new MakeVersionCommand(versionMaker));
            replaceMaster       = new ReplaceMasterCommand(versionMaker);
            makeVersion         = new MakeVersionCommand(versionMaker);
            useNewVersion       = new UseDraftCommand(versionMaker);
            updateObject        = new UpdateObjectCommand();
            delete              = new DeleteCommand(persister.Repository);
            showEdit            = new RedirectToEditCommand(editUrlManager);
            useMaster           = new UseMasterCommand();
            clone               = new CloneCommand();
            validate            = new ValidateCommand();
            save                = new SaveCommand(persister);
            draftState          = new UpdateContentStateCommand(changer, ContentState.Draft);
            publishedState      = new UpdateContentStateCommand(changer, ContentState.Published);
            saveActiveContent   = new ActiveContentSaveCommand();
            moveToPosition      = new MoveToPositionCommand();
            unpublishedDate     = new EnsureNotPublishedCommand();
            ensurePublishedDate = new EnsurePublishedCommand();
            updateReferences    = new UpdateReferencesCommand();
            saveOnPageVersion   = new SaveOnPageVersionCommand(versionMaker);
        }