Exemplo n.º 1
0
        /// <summary>
        /// returns the content tree level for the given id
        /// </summary>
        private CompareContentTreeNode GetContentTree(ContentTreeModel data)
        {
            try
            {
                if (data.Id == null)
                {
                    data.Id = "";
                }
                var args = new RemoteContentTreeArgs(data.Id, data.Database, data.Server, data.Children);
                if (args.Server != null)
                {
                    return(_remoteContent.GetContentTreeNode(args));
                }
            }
            catch (RuntimeBinderException)
            {
            }
            Request.InputStream.Seek(0, SeekOrigin.Begin);
            string payload = new StreamReader(Request.InputStream).ReadToEnd();

            if (!_remoteContent.HmacServer.ValidateRequest(new HttpRequestWrapper(System.Web.HttpContext.Current.Request), x => new[] { new SignatureFactor("payload", payload) }))
            {
                System.Web.HttpContext.Current.Response.StatusCode = 403;
                return(null);
            }

            return(data.Id == "" ? ContentMigrationRegistration.Root : new CompareContentTreeNode(_sitecore.GetItemData(data.Id)));
        }
Exemplo n.º 2
0
        public ContentTreeNode GetRemoteContentTreeNode(RemoteContentTreeArgs args)
        {
            WebClient wc = new WebClient {
                Encoding = Encoding.UTF8
            };

            return(JsonConvert.DeserializeObject <ContentTreeNode>(wc.UploadString($"{args.server}/scs/cmcontenttree.scsvc", "POST", args.GetSerializedData())));
        }
Exemplo n.º 3
0
 public static ContentTreeNode GetRemoteItem(RemoteContentTreeArgs args, string itemId)
 {
     try
     {
         WebClient wc = new WebClient { Encoding = Encoding.UTF8 };
         var node = JsonConvert.DeserializeObject<ContentTreeNode>(wc.UploadString($"{args.server}/scs/cmcontenttree.scsvc", "POST",
                         $@"{{ ""id"": ""{itemId}"", ""database"": ""{args.database}""}}"));
         return node;
     }
     catch (Exception e)
     {
         Log.Error("Problem getting children of node " + itemId, e, args);
     }
     return null;
 }
        public CompareContentTreeNode GetContentTreeNode(RemoteContentTreeArgs args)
        {
            string url        = $"{args.Server}/scs/cm/cmcontenttree.scsvc";
            string parameters = $@"{{ ""id"": ""{args.Id}"", ""database"": ""{args.Database}""}}";

            string response = MakeRequest(url, parameters);

            var node = _jsonSerializationService.DeserializeObject <CompareContentTreeNode>(response);

            if (!string.IsNullOrWhiteSpace(args.Id))
            {
                node.SimpleCompare(args.Database, args.Id);
            }

            return(node);
        }
Exemplo n.º 5
0
 public static ContentTreeNode GetRemoteItem(RemoteContentTreeArgs args, string itemId)
 {
     try
     {
         WebClient wc = new WebClient {
             Encoding = Encoding.UTF8
         };
         var node = JsonConvert.DeserializeObject <ContentTreeNode>(wc.UploadString($"{args.server}/scs/cmcontenttree.scsvc", "POST",
                                                                                    $@"{{ ""id"": ""{itemId}"", ""database"": ""{args.database}""}}"));
         return(node);
     }
     catch (Exception e)
     {
         Log.Error("Problem getting children of node " + itemId, e, args);
     }
     return(null);
 }
Exemplo n.º 6
0
        /// <summary>
        /// returns the content tree level for the given id
        /// </summary>
        /// <param name="context"></param>
        /// <returns></returns>
        private static object GetContentTree(HttpContextBase context)
        {
            var data = GetPostData(context);

            try
            {
                var args = new RemoteContentTreeArgs(data);
                if (args.server != null)
                {
                    return(GetResources.GetRemoteItem(args, args.id));
                }
            }
            catch (RuntimeBinderException)
            {
            }
            using (new SecurityDisabler())
                return(string.IsNullOrWhiteSpace(data.id.ToString()) ? Root : new ContentTreeNode(Factory.GetDatabase(data.database.ToString()).GetItem(new ID(data.id))));
        }
 public ContentTreeNode GetRemoteContentTreeNode(RemoteContentTreeArgs args)
 {
     WebClient wc = new WebClient { Encoding = Encoding.UTF8 };
     return JsonConvert.DeserializeObject<ContentTreeNode>(wc.UploadString($"{args.server}/scs/cmcontenttree.scsvc", "POST", args.GetSerializedData()));
 }
Exemplo n.º 8
0
 public static IEnumerable <string> GetRemoteItemChildren(RemoteContentTreeArgs args, string itemId)
 {
     return(GetRemoteItem(args, itemId).Nodes.Select(x => x.Id));
 }
Exemplo n.º 9
0
 public static IEnumerable<string> GetRemoteItemChildren(RemoteContentTreeArgs args, string itemId)
 {
     return GetRemoteItem(args, itemId).Nodes.Select(x => x.Id);
 }