public bool EditPost(string blogId, BlogPost post, INewCategoryContext newCategoryContext, bool publish, out string etag, out XmlDocument remotePost) { if (!publish && !Options.SupportsPostAsDraft) { Trace.Fail("Static site does not support drafts, cannot post."); throw new BlogClientPostAsDraftUnsupportedException(); } remotePost = null; etag = ""; // Create a StaticSitePost on the provided post var ssgPost = new StaticSitePost(Config, post, !publish); if (ssgPost.FilePathById == null) { // If we are publishing and there exists a draft with this ID, delete it. if (publish) { var filePath = new StaticSitePost(Config, post, true).FilePathById; if (filePath != null) { File.Delete(filePath); } } // Existing post could not be found to edit, call NewPost instead; NewPost(blogId, post, newCategoryContext, publish, out etag, out remotePost); return(true); } // Set slug to existing slug on post ssgPost.Slug = post.Slug; return(DoEditItem(ssgPost)); }
public async Task <PostResult> EditPost(BlogPost post, INewCategoryContext newCategoryContext, bool publish) { // initialize result (for edits the id never changes) PostResult result = new PostResult(); var editpostResult = new EditPostResult(); result.PostId = post.Id; try { //apply any publishing filters and make the post using (new ContentFilterApplier(post, ClientOptions, ContentFilterMode.Publish)) { // make the post if (post.IsPage) { await BlogClient.EditPage(_settings.HostBlogId, post, publish, result.ETag, result.AtomRemotePost); } else { await BlogClient.EditPost(_settings.HostBlogId, post, newCategoryContext, publish, editpostResult); } } // note success _settings.LastPublishFailed = false; } catch (BlogClientProviderException ex) { if (ErrorIsInvalidPostId(ex)) { return(await NewPost(post, newCategoryContext, publish)); } else { throw; } } catch { _settings.LastPublishFailed = true; throw; } // determine the date-published based on whether there was an override if (post.HasDatePublishedOverride) { result.DatePublished = post.DatePublishedOverride; } else { result.DatePublished = DateTime.UtcNow; } // return result return(result); }
public string NewPost(string blogId, BlogPost post, INewCategoryContext newCategoryContext, bool publish, out string etag, out XmlDocument remotePost) { if (!publish && !Options.SupportsPostAsDraft) { Trace.Fail("Static site does not support drafts, cannot post."); throw new BlogClientPostAsDraftUnsupportedException(); } remotePost = null; etag = ""; // Create a StaticSitePost on the provided post return(DoNewItem(new StaticSitePost(Config, post, !publish))); }
public override async Task <bool> EditPost(string blogId, BlogPost post, INewCategoryContext newCategoryContext, bool publish) { if (!publish && !Options.SupportsPostAsDraft) { //Debug.Fail("Post to draft not supported on this provider"); throw new BlogClientPostAsDraftUnsupportedException(); } // call the method var result = await CallMethod("blogger.editPost", new XmlRpcString(APP_KEY), new XmlRpcString(post.Id), new XmlRpcString(Username), new XmlRpcString(Password, true), FormatBlogPost(post), new XmlRpcBoolean(publish)); return(result.InnerText.Trim() == "1"); }
public async Task <PostResult> NewPost(BlogPost post, INewCategoryContext newCategoryContext, bool publish) { // initialize result PostResult result = new PostResult(); try { using (new ContentFilterApplier(post, ClientOptions, ContentFilterMode.Publish)) { // make the post if (post.IsPage) { result.PostId = await BlogClient.NewPage(_settings.HostBlogId, post, publish, result.ETag, result.AtomRemotePost); } else { result.PostId = await BlogClient.NewPost(_settings.HostBlogId, post, newCategoryContext, publish, result); } } // note success _settings.LastPublishFailed = false; } catch { _settings.LastPublishFailed = true; throw; } // determine the date-published based on whether there was an override if (post.HasDatePublishedOverride) { result.DatePublished = post.DatePublishedOverride; } else { result.DatePublished = DateTime.UtcNow; } // return result return(result); }
public override string NewPost(string blogId, BlogPost post, INewCategoryContext newCategoryContext, bool publish) { if (!publish && !Options.SupportsPostAsDraft) { Trace.Fail("Post to draft not supported on this provider"); throw new BlogClientPostAsDraftUnsupportedException(); } // call the method XmlNode result = CallMethod("blogger.newPost", new XmlRpcString(APP_KEY), new XmlRpcString(blogId), new XmlRpcString(Username), new XmlRpcString(Password, true), FormatBlogPost(post), new XmlRpcBoolean(publish)); // return the blog-id return(result.InnerText); }
public bool EditPost(string blogId, BlogPost post, INewCategoryContext newCategoryContext, bool publish, out string etag, out XmlDocument remotePost) { // The remote post is only meant to be used for blogs that use the Atom protocol. remotePost = null; if (!publish && !Options.SupportsPostAsDraft) { Trace.Fail("Post to draft not supported on this provider"); throw new BlogClientPostAsDraftUnsupportedException(); } var bloggerPost = ConvertToGoogleBloggerPost(post); var updatePostRequest = GetService().Posts.Update(bloggerPost, blogId, post.Id); updatePostRequest.Publish = publish; var updatedPost = updatePostRequest.Execute(); etag = updatedPost.ETag; return(true); }
public async Task <bool> EditPost(string blogId, BlogPost post, INewCategoryContext newCategoryContext, bool publish, EditPostResult editPostResult) { // The remote post is only meant to be used for blogs that use the Atom protocol. editPostResult.remotePost = null; if (!publish && !Options.SupportsPostAsDraft) { Debug.Fail("Post to draft not supported on this provider"); throw new BlogClientPostAsDraftUnsupportedException(); } var bloggerPost = ConvertToGoogleBloggerPost(post); var updatePostRequest = (await GetService()).Posts.Update(bloggerPost, blogId, post.Id); updatePostRequest.Publish = publish; var updatedPost = await updatePostRequest.ExecuteAsync(); editPostResult.etag = updatedPost.ETag; return(true); }
public async Task <string> NewPost(string blogId, BlogPost post, INewCategoryContext newCategoryContext, bool publish, PostResult postResult) { // The remote post is only meant to be used for blogs that use the Atom protocol. postResult.AtomRemotePost = null; if (!publish && !Options.SupportsPostAsDraft) { Debug.Fail("Post to draft not supported on this provider"); throw new BlogClientPostAsDraftUnsupportedException(); } var bloggerPost = ConvertToGoogleBloggerPost(post); var newPostRequest = (await GetService()).Posts.Insert(bloggerPost, blogId); newPostRequest.IsDraft = !publish; var newPost = await newPostRequest.ExecuteAsync(); postResult.ETag = newPost.ETag; return(newPost.Id); }
public string NewPost(string blogId, BlogPost post, INewCategoryContext newCategoryContext, bool publish, out string etag, out XmlDocument remotePost) { if (!publish && !Options.SupportsPostAsDraft) { Trace.Fail("Post to draft not supported on this provider"); throw new BlogClientPostAsDraftUnsupportedException(); } Login(); FixupBlogId(ref blogId); XmlDocument doc = new XmlDocument(); XmlElement entryNode = doc.CreateElement(_atomNS.Prefix, "entry", _atomNS.Uri); doc.AppendChild(entryNode); Populate(post, null, entryNode, publish); string slug = null; if (Options.SupportsSlug) { slug = post.Slug; } WebHeaderCollection responseHeaders; Uri uri = new Uri(blogId); XmlDocument result = xmlRestRequestHelper.Post( ref uri, new HttpRequestFilter(new NewPostRequest(this, slug).RequestFilter), ENTRY_CONTENT_TYPE, doc, _clientOptions.CharacterSet, out responseHeaders); etag = FilterWeakEtag(responseHeaders["ETag"]); string location = responseHeaders["Location"]; if (string.IsNullOrEmpty(location)) { throw new BlogClientInvalidServerResponseException("POST", "The HTTP response was missing the required Location header.", ""); } if (location != responseHeaders["Content-Location"] || result == null) { Uri locationUri = new Uri(location); WebHeaderCollection getResponseHeaders; result = xmlRestRequestHelper.Get(ref locationUri, RequestFilter, out getResponseHeaders); etag = FilterWeakEtag(getResponseHeaders["ETag"]); } remotePost = (XmlDocument)result.Clone(); Parse(result.DocumentElement, true, uri); if (Options.SupportsNewCategories) { foreach (BlogPostCategory category in post.NewCategories) { newCategoryContext.NewCategoryAdded(category); } } return(PostUriToPostId(location)); }
protected virtual bool AttemptEditPostRecover(Exception e, string blogId, BlogPost post, INewCategoryContext newCategoryContext, bool publish, out string etag, out XmlDocument remotePost) { etag = null; remotePost = null; return(false); }
public virtual bool EditPost(string blogId, BlogPost post, INewCategoryContext newCategoryContext, bool publish, out string etag, out XmlDocument remotePost) { if (!publish && !Options.SupportsPostAsDraft) { Trace.Fail("Post to draft not supported on this provider"); throw new BlogClientPostAsDraftUnsupportedException(); } Login(); FixupBlogId(ref blogId); XmlDocument doc = post.AtomRemotePost; XmlElement entryNode = doc.SelectSingleNode("/atom:entry", _nsMgr) as XmlElement; // No documentUri is needed because we ensure xml:base is set on the root // when we retrieve from XmlRestRequestHelper Populate(post, null, entryNode, publish); string etagToMatch = FilterWeakEtag(post.ETag); try { retry: try { Uri uri = PostIdToPostUri(post.Id); WebHeaderCollection responseHeaders; xmlRestRequestHelper.Put(ref uri, etagToMatch, RequestFilter, ENTRY_CONTENT_TYPE, doc, _clientOptions.CharacterSet, true, out responseHeaders); } catch (WebException we) { if (we.Status == WebExceptionStatus.ProtocolError) { if (((HttpWebResponse)we.Response).StatusCode == HttpStatusCode.PreconditionFailed) { if (etagToMatch != null && etagToMatch.Length > 0) { HttpRequestHelper.LogException(we); string currentEtag = GetEtag(UrlHelper.SafeToAbsoluteUri(PostIdToPostUri(post.Id))); if (currentEtag != null && currentEtag.Length > 0 && currentEtag != etagToMatch) { if (ConfirmOverwrite()) { etagToMatch = currentEtag; goto retry; } else { throw new BlogClientOperationCancelledException(); } } } } } throw; } } catch (Exception e) { if (!AttemptEditPostRecover(e, blogId, post, newCategoryContext, publish, out etag, out remotePost)) { // convert to a provider exception if this is a 404 (allow us to // catch this case explicitly and attempt a new post to recover) if (e is WebException) { WebException webEx = e as WebException; HttpWebResponse response = webEx.Response as HttpWebResponse; if (response != null && response.StatusCode == HttpStatusCode.NotFound) { throw new BlogClientProviderException("404", e.Message); } } // no special handling, just re-throw throw; } } Uri getUri = PostIdToPostUri(post.Id); WebHeaderCollection getResponseHeaders; remotePost = xmlRestRequestHelper.Get(ref getUri, RequestFilter, out getResponseHeaders); etag = FilterWeakEtag(getResponseHeaders["ETag"]); Trace.Assert(remotePost != null, "After successful PUT, remote post could not be retrieved"); if (Options.SupportsNewCategories) { foreach (BlogPostCategory category in post.NewCategories) { newCategoryContext.NewCategoryAdded(category); } } return(true); }
protected virtual bool AttemptEditPostRecover(Exception e, string blogId, BlogPost post, INewCategoryContext newCategoryContext, bool publish, EditPostResult result) { result.etag = null; result.remotePost = null; return(false); }
/// <summary> /// Edit an existing entry /// </summary> /// <param name="blog">blog</param> /// <param name="postId">post id</param> /// <param name="account">account to post to</param> /// <param name="entry">entry to post</param> /// <param name="publish">publish now?</param> /// <returns>was the entry successfully edited</returns> public override bool EditPost(string blogId, BlogPost post, INewCategoryContext newCategoryContext, bool publish) { if (!publish && !Options.SupportsPostAsDraft) { Trace.Fail("Post to draft not supported on this provider"); throw new BlogClientPostAsDraftUnsupportedException(); } bool addCategoriesOutOfBand = AddCategoriesIfNecessary(blogId, post, newCategoryContext); bool result; if (Options.SupportsCategoriesInline) { result = MetaweblogEditPost(blogId, post, publish); if (Options.SupportsHierarchicalCategories) MovableTypeSetPostCategories(post.Id, ArrayHelper.Concat(post.Categories, post.NewCategories)); } else { result = MovableTypeEditPost(blogId, post, publish); } // if we succeeded then note addition of categories if appropriate if (!addCategoriesOutOfBand) { foreach (BlogPostCategory category in post.NewCategories) newCategoryContext.NewCategoryAdded(category); } return result; }
public bool EditPost(string blogId, BlogPost post, INewCategoryContext newCategoryContext, bool publish, out string etag, out XmlDocument remotePost) { // The remote post is only meant to be used for blogs that use the Atom protocol. remotePost = null; if (!publish && !Options.SupportsPostAsDraft) { Trace.Fail("Post to draft not supported on this provider"); throw new BlogClientPostAsDraftUnsupportedException(); } var bloggerPost = ConvertToGoogleBloggerPost(post); var updatePostRequest = GetService().Posts.Update(bloggerPost, blogId, post.Id); updatePostRequest.Publish = publish; var updatedPost = updatePostRequest.Execute(); etag = updatedPost.ETag; return true; }
public Task <bool> EditPost(string blogId, BlogPost post, INewCategoryContext newCategoryContext, bool publish, EditPostResult result) { result.etag = null; result.remotePost = null; return(EditPost(blogId, post, newCategoryContext, publish)); }
public virtual bool EditPost(string blogId, BlogPost post, INewCategoryContext newCategoryContext, bool publish, out string etag, out XmlDocument remotePost) { if (!publish && !Options.SupportsPostAsDraft) { Trace.Fail("Post to draft not supported on this provider"); throw new BlogClientPostAsDraftUnsupportedException(); } Login(); FixupBlogId(ref blogId); XmlDocument doc = post.AtomRemotePost; XmlElement entryNode = doc.SelectSingleNode("/atom:entry", _nsMgr) as XmlElement; // No documentUri is needed because we ensure xml:base is set on the root // when we retrieve from XmlRestRequestHelper Populate(post, null, entryNode, publish); string etagToMatch = FilterWeakEtag(post.ETag); try { retry: try { Uri uri = PostIdToPostUri(post.Id); WebHeaderCollection responseHeaders; xmlRestRequestHelper.Put(ref uri, etagToMatch, RequestFilter, ENTRY_CONTENT_TYPE, doc, _clientOptions.CharacterSet, true, out responseHeaders); } catch (WebException we) { if (we.Status == WebExceptionStatus.ProtocolError) { if (((HttpWebResponse)we.Response).StatusCode == HttpStatusCode.PreconditionFailed) { if (etagToMatch != null && etagToMatch.Length > 0) { HttpRequestHelper.LogException(we); string currentEtag = GetEtag(UrlHelper.SafeToAbsoluteUri(PostIdToPostUri(post.Id))); if (currentEtag != null && currentEtag.Length > 0 && currentEtag != etagToMatch) { if (ConfirmOverwrite()) { etagToMatch = currentEtag; goto retry; } else { throw new BlogClientOperationCancelledException(); } } } } } throw; } } catch (Exception e) { if (!AttemptEditPostRecover(e, blogId, post, newCategoryContext, publish, out etag, out remotePost)) { // convert to a provider exception if this is a 404 (allow us to // catch this case explicitly and attempt a new post to recover) if (e is WebException) { WebException webEx = e as WebException; HttpWebResponse response = webEx.Response as HttpWebResponse; if (response != null && response.StatusCode == HttpStatusCode.NotFound) throw new BlogClientProviderException("404", e.Message); } // no special handling, just re-throw throw; } } Uri getUri = PostIdToPostUri(post.Id); WebHeaderCollection getResponseHeaders; remotePost = xmlRestRequestHelper.Get(ref getUri, RequestFilter, out getResponseHeaders); etag = FilterWeakEtag(getResponseHeaders["ETag"]); Trace.Assert(remotePost != null, "After successful PUT, remote post could not be retrieved"); if (Options.SupportsNewCategories) foreach (BlogPostCategory category in post.NewCategories) newCategoryContext.NewCategoryAdded(category); return true; }
protected virtual bool AttemptEditPostRecover(Exception e, string blogId, BlogPost post, INewCategoryContext newCategoryContext, bool publish, out string etag, out XmlDocument remotePost) { etag = null; remotePost = null; return false; }
public abstract bool EditPost(string blogId, BlogPost post, INewCategoryContext newCategoryContext, bool publish);
public bool EditPost(string blogId, BlogPost post, INewCategoryContext newCategoryContext, bool publish, out string etag, out XmlDocument remotePost) { etag = null; remotePost = null; return(EditPost(blogId, post, newCategoryContext, publish)); }
public async Task <string> NewPost(string blogId, BlogPost post, INewCategoryContext newCategoryContext, bool publish, PostResult postResult) { if (!publish && !Options.SupportsPostAsDraft) { //Debug.Fail("Post to draft not supported on this provider"); throw new BlogClientPostAsDraftUnsupportedException(); } Login(); FixupBlogId(ref blogId); XmlDocument doc = new XmlDocument(); XmlElement entryNode = doc.CreateElementNS(_atomNS.Uri, _atomNS.Prefix + ":entry"); doc.AppendChild(entryNode); Populate(post, null, entryNode, publish); string slug = null; if (Options.SupportsSlug) { slug = post.Slug; } XmlRestRequestHelper.XmlRequestResult xmlResult2 = new XmlRestRequestHelper.XmlRequestResult(); xmlResult2.uri = new Uri(blogId); XmlDocument result = await xmlRestRequestHelper.Post( new HttpAsyncRequestFilter(new NewPostRequest(this, slug).RequestFilter), ENTRY_CONTENT_TYPE, doc, _clientOptions.CharacterSet, xmlResult2); postResult.ETag = FilterWeakEtag(xmlResult2.responseHeaders["ETag"]); string location = xmlResult2.responseHeaders["Location"]; if (string.IsNullOrEmpty(location)) { throw new BlogClientInvalidServerResponseException("POST", "The HTTP response was missing the required Location header.", ""); } if (location != xmlResult2.responseHeaders["Content-Location"] || result == null) { XmlRestRequestHelper.XmlRequestResult xmlResult = new XmlRestRequestHelper.XmlRequestResult(); xmlResult.uri = new Uri(location); result = await xmlRestRequestHelper.Get(RequestFilter, xmlResult); postResult.ETag = FilterWeakEtag(xmlResult.responseHeaders["ETag"]); } postResult.AtomRemotePost = (XmlDocument)result.CloneNode(true); Parse(result.DocumentElement, true, xmlResult2.uri); if (Options.SupportsNewCategories) { foreach (BlogPostCategory category in post.NewCategories) { newCategoryContext.NewCategoryAdded(category); } } return(PostUriToPostId(location)); }
protected override bool AttemptEditPostRecover(Exception e, string blogId, BlogPost post, INewCategoryContext newCategoryContext, bool publish, out string etag, out XmlDocument remotePost) { // There's a bug with Blogger Beta where their atom feeds are returning // edit URIs for entries that don't work for PUT and DELETE. However, if you do a GET on the // edit URI, you can get a different edit URI that DOES work for PUT and DELETE. if (inEditPostRecovery) { etag = null; remotePost = null; return false; } inEditPostRecovery = true; try { if (IsBadRequestError(e)) { BlogPost oldPost = GetPost(blogId, post.Id); if (post.Id != oldPost.Id) { // Temporarily change the ID to this alternate Edit URI. In order to // minimize the chance of unintended side effects, we revert the ID // back to the original value once we're done trying to edit. string originalId = post.Id; try { post.Id = oldPost.Id; if (EditPost(blogId, post, newCategoryContext, publish, out etag, out remotePost)) return true; } finally { post.Id = originalId; } } } } catch (Exception e1) { Trace.Fail(e1.ToString()); } finally { inEditPostRecovery = false; } etag = null; remotePost = null; return false; }
public abstract Task <string> NewPost(string blogId, BlogPost post, INewCategoryContext newCategoryContext, bool publish);
private bool AddCategoriesIfNecessary(string blogId, BlogPost post, INewCategoryContext newCategoryContext) { // this blog doesn't support adding categories if (!Options.SupportsNewCategories) return false; // no new categories to add if (post.NewCategories.Length == 0) return false; // we support inline category addition and we don't require a special // api for heirarchical categories (inline api can't handle parent specification) if (Options.SupportsNewCategoriesInline && !Options.SupportsHierarchicalCategories) return false; // add the categories and update their ids ArrayList newCategories = new ArrayList(); foreach (BlogPostCategory category in post.NewCategories) { string categoryId = AddCategory(blogId, category); BlogPostCategory newCategory = new BlogPostCategory(categoryId, category.Name, category.Parent); newCategories.Add(newCategory); newCategoryContext.NewCategoryAdded(newCategory); } post.NewCategories = newCategories.ToArray(typeof(BlogPostCategory)) as BlogPostCategory[]; return true; }
protected override bool AttemptEditPostRecover(Exception e, string blogId, BlogPost post, INewCategoryContext newCategoryContext, bool publish, out string etag, out XmlDocument remotePost) { // There's a bug with Blogger Beta where their atom feeds are returning // edit URIs for entries that don't work for PUT and DELETE. However, if you do a GET on the // edit URI, you can get a different edit URI that DOES work for PUT and DELETE. if (inEditPostRecovery) { etag = null; remotePost = null; return(false); } inEditPostRecovery = true; try { if (IsBadRequestError(e)) { BlogPost oldPost = GetPost(blogId, post.Id); if (post.Id != oldPost.Id) { // Temporarily change the ID to this alternate Edit URI. In order to // minimize the chance of unintended side effects, we revert the ID // back to the original value once we're done trying to edit. string originalId = post.Id; try { post.Id = oldPost.Id; if (EditPost(blogId, post, newCategoryContext, publish, out etag, out remotePost)) { return(true); } } finally { post.Id = originalId; } } } } catch (Exception e1) { Trace.Fail(e1.ToString()); } finally { inEditPostRecovery = false; } etag = null; remotePost = null; return(false); }
public PostResult NewPost(BlogPost post, INewCategoryContext newCategoryContext, bool publish) { // initialize result PostResult result = new PostResult(); try { using (new ContentFilterApplier(post, ClientOptions, ContentFilterMode.Publish)) { // make the post if (post.IsPage) result.PostId = BlogClient.NewPage(_settings.HostBlogId, post, publish, out result.ETag, out result.AtomRemotePost); else result.PostId = BlogClient.NewPost(_settings.HostBlogId, post, newCategoryContext, publish, out result.ETag, out result.AtomRemotePost); } // note success _settings.LastPublishFailed = false; } catch { _settings.LastPublishFailed = true; throw; } // determine the date-published based on whether there was an override if (post.HasDatePublishedOverride) result.DatePublished = post.DatePublishedOverride; else result.DatePublished = DateTimeHelper.UtcNow; // return result return result; }
public string NewPost(string blogId, BlogPost post, INewCategoryContext newCategoryContext, bool publish, out string etag, out XmlDocument remotePost) { if (!publish && !Options.SupportsPostAsDraft) { Trace.Fail("Post to draft not supported on this provider"); throw new BlogClientPostAsDraftUnsupportedException(); } Login(); FixupBlogId(ref blogId); XmlDocument doc = new XmlDocument(); XmlElement entryNode = doc.CreateElement(_atomNS.Prefix, "entry", _atomNS.Uri); doc.AppendChild(entryNode); Populate(post, null, entryNode, publish); string slug = null; if (Options.SupportsSlug) slug = post.Slug; WebHeaderCollection responseHeaders; Uri uri = new Uri(blogId); XmlDocument result = xmlRestRequestHelper.Post( ref uri, new HttpRequestFilter(new NewPostRequest(this, slug).RequestFilter), ENTRY_CONTENT_TYPE, doc, _clientOptions.CharacterSet, out responseHeaders); etag = FilterWeakEtag(responseHeaders["ETag"]); string location = responseHeaders["Location"]; if (string.IsNullOrEmpty(location)) { throw new BlogClientInvalidServerResponseException("POST", "The HTTP response was missing the required Location header.", ""); } if (location != responseHeaders["Content-Location"] || result == null) { Uri locationUri = new Uri(location); WebHeaderCollection getResponseHeaders; result = xmlRestRequestHelper.Get(ref locationUri, RequestFilter, out getResponseHeaders); etag = FilterWeakEtag(getResponseHeaders["ETag"]); } remotePost = (XmlDocument)result.Clone(); Parse(result.DocumentElement, true, uri); if (Options.SupportsNewCategories) foreach (BlogPostCategory category in post.NewCategories) newCategoryContext.NewCategoryAdded(category); return PostUriToPostId(location); }
public bool EditPost(string blogId, BlogPost post, INewCategoryContext newCategoryContext, bool publish, out string etag, out XmlDocument remotePost) { etag = null; remotePost = null; return EditPost(blogId, post, newCategoryContext, publish); }
public PostResult EditPost(BlogPost post, INewCategoryContext newCategoryContext, bool publish) { // initialize result (for edits the id never changes) PostResult result = new PostResult(); result.PostId = post.Id; try { //apply any publishing filters and make the post using (new ContentFilterApplier(post, ClientOptions, ContentFilterMode.Publish)) { // make the post if (post.IsPage) BlogClient.EditPage(_settings.HostBlogId, post, publish, out result.ETag, out result.AtomRemotePost); else BlogClient.EditPost(_settings.HostBlogId, post, newCategoryContext, publish, out result.ETag, out result.AtomRemotePost); } // note success _settings.LastPublishFailed = false; } catch (BlogClientProviderException ex) { if (ErrorIsInvalidPostId(ex)) return NewPost(post, newCategoryContext, publish); else throw; } catch { _settings.LastPublishFailed = true; throw; } // determine the date-published based on whether there was an override if (post.HasDatePublishedOverride) result.DatePublished = post.DatePublishedOverride; else result.DatePublished = DateTimeHelper.UtcNow; // return result return result; }
public override bool EditPost(string blogId, BlogPost post, INewCategoryContext newCategoryContext, bool publish) { if (!publish && !Options.SupportsPostAsDraft) { Trace.Fail("Post to draft not supported on this provider"); throw new BlogClientPostAsDraftUnsupportedException(); } // call the method XmlNode result = CallMethod("blogger.editPost", new XmlRpcString(APP_KEY), new XmlRpcString(post.Id), new XmlRpcString(Username), new XmlRpcString(Password, true), FormatBlogPost(post), new XmlRpcBoolean(publish)); return (result.InnerText == "1"); }
public Task <string> NewPost(string blogId, BlogPost post, INewCategoryContext newCategoryContext, bool publish, PostResult postResult) { postResult.ETag = null; postResult.AtomRemotePost = null; return(NewPost(blogId, post, newCategoryContext, publish)); }