// ================================================================================================ Private methods
/// <summary>
/// Get a post from clientId. If it is a manual post, it comes from repository.
/// If it is a journal post, it either comes from journal and a repository post is created, or is already persisted to repository.
/// </summary>
/// <param name="clientId"></param>
/// <param name="contextPath">New posts from journal items will be created under contextPath</param>
/// <returns></returns>
private static Node GetPostFromId(string clientId, string contextPath)
{
Node post = null;
var itemID = PostInfo.GetIdFromClientId(clientId);
if (PostInfo.IsJournalId(clientId))
{
// CRUD post, create a manual post
// only create it if it is not yet created!
post = ContentQuery.Query(string.Format("JournalId:{0}", itemID)).Nodes.FirstOrDefault();
if (post == null)
{
var item = Journals.GetSingleItem(itemID);
// lastpath is empty here: we wont use it from this scenario
var postInfo = new PostInfo(item, string.Empty);
var sharedContent = Node.LoadNode(item.NodeId);
post = CreatePost(contextPath, postInfo.Text, item.When, itemID, postInfo.Type, sharedContent, postInfo.Details);
}
}
else
{
post = Node.LoadNode(itemID);
}
return(post);
}