/// <summary>
        /// Get the XML for a version of an item
        /// </summary>
        /// <param name="item"></param>
        /// <param name="versionQuery"></param>
        /// <returns></returns>
        private string GetXml(ContentItem item, string versionQuery)
        {
            int index;

            int.TryParse(versionQuery, out index);
            var ver = _versionRepository.GetVersion(item, index);

            return(ver != null ? ver.VersionDataXml : _versionRepository.Serialize(item));
        }
Esempio n. 2
0
 public static bool TryParseVersion(this ContentVersionRepository versionRepository, string versionIndexParameterValue, string versionKey, PathData path)
 {
     if (!path.IsEmpty() && !string.IsNullOrEmpty(versionIndexParameterValue))
     {
         int versionIndex = int.Parse(versionIndexParameterValue);
         var version      = versionRepository.GetVersion(path.CurrentPage, versionIndex);
         return(path.TryApplyVersion(version, versionKey));
     }
     return(false);
 }
        public void MasterVersion_CanBeSavedAsVersion_AndRetrieved()
        {
            var master = CreateOneItem <NormalPage>(0, "pageX", null);

            persister.Save(master);

            var draft = repository.Save(master);

            repository.Repository.Dispose();

            var savedDraft = repository.GetVersion(master);

            savedDraft.Published.ShouldBe(master.Published, TimeSpan.FromSeconds(10));
            //savedDraft.PublishedBy.ShouldBe(master.SavedBy);
            savedDraft.Saved.ShouldBe(N2.Utility.CurrentTime(), TimeSpan.FromSeconds(10));
            savedDraft.SavedBy.ShouldBe(draft.SavedBy);
            savedDraft.State.ShouldBe(master.State);
            savedDraft.VersionIndex.ShouldBe(master.VersionIndex);
            savedDraft.VersionDataXml.ShouldContain("pageX");
        }
Esempio n. 4
0
        public void UpgradeVersion_CopiesBuiltInProperties()
        {
            using (persister)
            {
                worker.UpgradeVersion(version);
            }

            var newVersion = repository.GetVersion(master, version.VersionIndex);

            //newVersion.Expired.ShouldBe(version.Expires);
            newVersion.FuturePublish.ShouldBe(version["FuturePublish"]);
            newVersion.ItemCount.ShouldBe(1);
            newVersion.Master.ID.ShouldBe(master.ID);
            newVersion.Published.ShouldBe(version.Published);
            //newVersion.PublishedBy.ShouldBe(version.SavedBy);
            newVersion.Saved.StripMilliseconds().ShouldBe(version.Updated.StripMilliseconds());
            newVersion.SavedBy.ShouldBe(version.SavedBy);
            newVersion.State.ShouldBe(version.State);
            newVersion.Title.ShouldBe(version.Title);
            newVersion.VersionIndex.ShouldBe(version.VersionIndex);
            var versionData = repository.DeserializeVersion(newVersion);

            versionData.ID.ShouldBe(0);
            versionData.Created.StripMilliseconds().ShouldBe(version.Created.StripMilliseconds());
            //versionData.Expires.ShouldBe(version.Expires);
            versionData.Name.ShouldBe(version.Name);
            versionData.Published.Value.StripMilliseconds().ShouldBe(version.Published.Value.StripMilliseconds());
            versionData.SavedBy.ShouldBe(version.SavedBy);
            versionData.SortOrder.ShouldBe(version.SortOrder);
            versionData.State.ShouldBe(version.State);
            versionData.TemplateKey.ShouldBe(version.TemplateKey);
            versionData.Title.ShouldBe(version.Title);
            versionData.TranslationKey.ShouldBe(version.TranslationKey);
            //versionData.Updated.ShouldBe(version.Updated);
            versionData.VersionIndex.ShouldBe(version.VersionIndex);
            versionData.Visible.ShouldBe(version.Visible);
            versionData.ZoneName.ShouldBe(version.ZoneName);
        }
Esempio n. 5
0
        public void CreateUrlProvider_CratesItems_WithoutEditables_AndRedirectsTo_DraftVersion()
        {
            request["discriminator"] = "DataItem";
            request["returnUrl"]     = "/back/to/here?edit=drag";
            request["below"]         = root.Path;
            request["zone"]          = "SomeZone";
            long initialCount = persister.Repository.Count();

            var response = creator.HandleRequest(request);

            response["dialog"].ShouldBe("no");
            response["redirect"].ShouldBe("/back/to/here?edit=drag&versionIndex=1");
            persister.Repository.Count().ShouldBe(initialCount);
            versionRepository.Repository.Count().ShouldBe(1);
            versionRepository.GetVersion(root).Version.Children.Single().ShouldBeTypeOf <Items.DataItem>();
        }