예제 #1
0
        public void MovingPublishedItem_BetweenZones_CreatesDraft_ContainingChanges()
        {
            var part = CreateOneItem <Items.DataItem>(0, "part", root);

            part.ZoneName = "ZoneOne";

            request["item"]  = part.Path;
            request["below"] = root.Path;
            request["zone"]  = "ZoneTwo";

            var response = mover.HandleRequest(request);

            var draft = versionRepository.GetVersions(root).Single();

            draft.Version.Children.Single().ZoneName.ShouldBe("ZoneTwo");
        }
예제 #2
0
        public void CopyingPublishedItem_CreatesDraft_ContainingChanges()
        {
            var part = CreateOneItem <Items.DataItem>(0, "part", root);

            part.ZoneName = "ZoneOne";

            request[PathData.ItemQueryKey] = part.Path;
            request["below"] = root.Path;
            request["zone"]  = "ZoneTwo";

            var response = copyer.HandleRequest(request);

            var draft = versionRepository.GetVersions(root).Single();

            versionRepository.DeserializeVersion(draft).Children.Count.ShouldBe(2);
            versionRepository.DeserializeVersion(draft).Children[0].ZoneName.ShouldBe("ZoneOne");
            versionRepository.DeserializeVersion(draft).Children[1].ZoneName.ShouldBe("ZoneTwo");
        }
        public void Handle(HttpContextBase context)
        {
            var    found        = false;
            string path         = context.Request["path"];
            string versionQuery = context.Request.QueryString[PathData.VersionIndexQueryKey];
            //string versionKey = context.Request.QueryString[PathData.VersionKeyQueryKey];

            var item = _navigator.Navigate(path);

            // enforce security
            if (!_security.IsAuthorized(item, _webContext.User))
            {
                throw new UnauthorizedAccessException();
            }

            if (item != null)
            {
                if (string.IsNullOrEmpty(versionQuery))
                {
                    var versions = _versionRepository.GetVersions(item);
                    var children = versions.Select(ToJson).ToArray();
                    context.Response.Write("{\"path\":\"" + Encode(item.Path) + "\", \"children\":[" +
                                           string.Join(", ", children) + "]}");
                    context.Response.ContentType = "application/json";
                    found = true;
                }
                else
                {
                    var xml = GetXml(item, versionQuery);
                    if (xml != null)
                    {
#if XML_DIFF
                        string versionDiff = context.Request.QueryString["versionDiff"];
                        var    xml2        = string.IsNullOrEmpty(versionDiff) ? null : GetXml(item, versionDiff);
                        if (xml2 != null)
                        {
                            xml = GetXmlDiff(xml, xml2);
                        }
#endif
                        context.Response.ContentType = "application/xml";
                        context.Response.Write(xml);
                        found = true;
                    }
                }
            }

            if (!found)
            {
                context.Response.ContentType = "text/plain";
                context.Response.Write("version not found");
                context.Response.StatusCode = 404;
            }
        }
예제 #4
0
        private void DeleteRecursive(ContentItem itemToDelete, ContentVersionRepository versionRepository)
        {
            using (logger.Indent())
            {
                foreach (ContentItem child in itemToDelete.Children.ToList())
                {
                    DeleteRecursive(child, versionRepository);
                }
            }

            itemToDelete.AddTo(null);
            logger.InfoFormat("Deleting {0}", itemToDelete);

            //Delete item versions
            var itemVersions = versionRepository.GetVersions(itemToDelete).ToArray();

            foreach (var version in itemVersions)
            {
                versionRepository.Repository.Delete(version);
            }
            //Delete item
            repository.Delete(itemToDelete);
        }