PageRenderTime 34ms CodeModel.GetById 0ms RepoModel.GetById 0ms app.codeStats 0ms

/BlogEngine/DotNetSlave.BusinessLogic/Providers/BlogProvider.cs

#
C# | 417 lines | 67 code | 51 blank | 299 comment | 0 complexity | 866e7f27d3c3c1e36b9919442c29ce8d MD5 | raw file
Possible License(s): LGPL-2.1, Apache-2.0, BSD-3-Clause
  1. namespace BlogEngine.Core.Providers
  2. {
  3. using System;
  4. using System.Collections.Generic;
  5. using System.Collections.Specialized;
  6. using System.Configuration.Provider;
  7. using DataStore;
  8. using Packaging;
  9. /// <summary>
  10. /// A base class for all custom providers to inherit from.
  11. /// </summary>
  12. public abstract class BlogProvider : ProviderBase
  13. {
  14. // Post
  15. #region Public Methods
  16. /// <summary>
  17. /// Deletes a BlogRoll from the data store specified by the provider.
  18. /// </summary>
  19. /// <param name="blogRollItem">
  20. /// The blog Roll Item to delete.
  21. /// </param>
  22. public abstract void DeleteBlogRollItem(BlogRollItem blogRollItem);
  23. /// <summary>
  24. /// Deletes a Blog from the data store specified by the provider.
  25. /// </summary>
  26. /// <param name="blog">
  27. /// The blog to delete.
  28. /// </param>
  29. public abstract void DeleteBlog(Blog blog);
  30. /// <summary>
  31. /// Deletes a Blog's storage container from the data store specified by the provider.
  32. /// </summary>
  33. /// <param name="blog">
  34. /// The blog to delete the storage container of.
  35. /// </param>
  36. public abstract bool DeleteBlogStorageContainer(Blog blog);
  37. /// <summary>
  38. /// Deletes a Category from the data store specified by the provider.
  39. /// </summary>
  40. /// <param name="category">
  41. /// The category to delete.
  42. /// </param>
  43. public abstract void DeleteCategory(Category category);
  44. /// <summary>
  45. /// Deletes a Page from the data store specified by the provider.
  46. /// </summary>
  47. /// <param name="page">
  48. /// The page to delete.
  49. /// </param>
  50. public abstract void DeletePage(Page page);
  51. /// <summary>
  52. /// Deletes a Post from the data store specified by the provider.
  53. /// </summary>
  54. /// <param name="post">
  55. /// The post to delete.
  56. /// </param>
  57. public abstract void DeletePost(Post post);
  58. /// <summary>
  59. /// Deletes a Page from the data store specified by the provider.
  60. /// </summary>
  61. /// <param name="profile">
  62. /// The profile to delete.
  63. /// </param>
  64. public abstract void DeleteProfile(AuthorProfile profile);
  65. /// <summary>
  66. /// Retrieves all BlogRolls from the provider and returns them in a list.
  67. /// </summary>
  68. /// <returns>A list of BlogRollItem.</returns>
  69. public abstract List<BlogRollItem> FillBlogRoll();
  70. /// <summary>
  71. /// Retrieves all Blogs from the provider and returns them in a list.
  72. /// </summary>
  73. /// <returns>A list of Blogs.</returns>
  74. public abstract List<Blog> FillBlogs();
  75. /// <summary>
  76. /// Retrieves all Categories from the provider and returns them in a List.
  77. /// </summary>
  78. /// <returns>A list of Category.</returns>
  79. public abstract List<Category> FillCategories();
  80. /// <summary>
  81. /// Retrieves all Pages from the provider and returns them in a List.
  82. /// </summary>
  83. /// <returns>A list of Page.</returns>
  84. public abstract List<Page> FillPages();
  85. /// <summary>
  86. /// Retrieves all Posts from the provider and returns them in a List.
  87. /// </summary>
  88. /// <returns>A list of Post.</returns>
  89. public abstract List<Post> FillPosts();
  90. /// <summary>
  91. /// Retrieves all Pages from the provider and returns them in a List.
  92. /// </summary>
  93. /// <returns>A list of AuthorProfile.</returns>
  94. public abstract List<AuthorProfile> FillProfiles();
  95. /// <summary>
  96. /// Deletes a Referrer from the data store specified by the provider.
  97. /// </summary>
  98. /// <returns>A list of Referrer.</returns>
  99. public abstract List<Referrer> FillReferrers();
  100. /// <summary>
  101. /// Returns a dictionary representing rights and the roles that allow them.
  102. /// </summary>
  103. /// <returns>
  104. ///
  105. /// The key must be a string of the name of the Rights enum of the represented Right.
  106. /// The value must be an IEnumerable of strings that includes only the role names of
  107. /// roles the right represents.
  108. ///
  109. /// Inheritors do not need to worry about verifying that the keys and values are valid.
  110. /// This is handled in the Right class.
  111. ///
  112. /// </returns>
  113. public abstract IDictionary<string, IEnumerable<String>> FillRights();
  114. /// <summary>
  115. /// Inserts a new BlogRoll into the data store specified by the provider.
  116. /// </summary>
  117. /// <param name="blogRollItem">
  118. /// The blog Roll Item.
  119. /// </param>
  120. public abstract void InsertBlogRollItem(BlogRollItem blogRollItem);
  121. /// <summary>
  122. /// Inserts a new Blog into the data store specified by the provider.
  123. /// </summary>
  124. /// <param name="blog">
  125. /// The blog.
  126. /// </param>
  127. public abstract void InsertBlog(Blog blog);
  128. /// <summary>
  129. /// Inserts a new Category into the data store specified by the provider.
  130. /// </summary>
  131. /// <param name="category">
  132. /// The category.
  133. /// </param>
  134. public abstract void InsertCategory(Category category);
  135. /// <summary>
  136. /// Inserts a new Page into the data store specified by the provider.
  137. /// </summary>
  138. /// <param name="page">
  139. /// The page to insert.
  140. /// </param>
  141. public abstract void InsertPage(Page page);
  142. /// <summary>
  143. /// Inserts a new Post into the data store specified by the provider.
  144. /// </summary>
  145. /// <param name="post">
  146. /// The post to insert.
  147. /// </param>
  148. public abstract void InsertPost(Post post);
  149. /// <summary>
  150. /// Inserts a new Page into the data store specified by the provider.
  151. /// </summary>
  152. /// <param name="profile">
  153. /// The profile to insert.
  154. /// </param>
  155. public abstract void InsertProfile(AuthorProfile profile);
  156. /// <summary>
  157. /// Inserts a new Referrer into the data store specified by the provider.
  158. /// </summary>
  159. /// <param name="referrer">
  160. /// The referrer to insert.
  161. /// </param>
  162. public abstract void InsertReferrer(Referrer referrer);
  163. /// <summary>
  164. /// Loads settings from data store
  165. /// </summary>
  166. /// <param name="extensionType">
  167. /// Extension Type
  168. /// </param>
  169. /// <param name="extensionId">
  170. /// Extensio Id
  171. /// </param>
  172. /// <returns>
  173. /// Settings as stream
  174. /// </returns>
  175. public abstract object LoadFromDataStore(ExtensionType extensionType, string extensionId);
  176. /// <summary>
  177. /// Loads the ping services.
  178. /// </summary>
  179. /// <returns>
  180. /// A StringCollection.
  181. /// </returns>
  182. public abstract StringCollection LoadPingServices();
  183. /// <summary>
  184. /// Loads the settings from the provider.
  185. /// </summary>
  186. /// <returns>A StringDictionary.</returns>
  187. public abstract StringDictionary LoadSettings();
  188. /// <summary>
  189. /// Loads the stop words used in the search feature.
  190. /// </summary>
  191. /// <returns>
  192. /// A StringCollection.
  193. /// </returns>
  194. public abstract StringCollection LoadStopWords();
  195. /// <summary>
  196. /// Removes settings from data store
  197. /// </summary>
  198. /// <param name="extensionType">
  199. /// Extension Type
  200. /// </param>
  201. /// <param name="extensionId">
  202. /// Extension Id
  203. /// </param>
  204. public abstract void RemoveFromDataStore(ExtensionType extensionType, string extensionId);
  205. /// <summary>
  206. /// Saves the ping services.
  207. /// </summary>
  208. /// <param name="services">
  209. /// The services.
  210. /// </param>
  211. public abstract void SavePingServices(StringCollection services);
  212. /// <summary>
  213. /// Saves all of the Rights and the roles that coorespond with them.
  214. /// </summary>
  215. /// <param name="rights"></param>
  216. public abstract void SaveRights(IEnumerable<Right> rights);
  217. /// <summary>
  218. /// Saves the settings to the provider.
  219. /// </summary>
  220. /// <param name="settings">
  221. /// The settings.
  222. /// </param>
  223. public abstract void SaveSettings(StringDictionary settings);
  224. /// <summary>
  225. /// Saves settings to data store
  226. /// </summary>
  227. /// <param name="extensionType">
  228. /// Extension Type
  229. /// </param>
  230. /// <param name="extensionId">
  231. /// Extension Id
  232. /// </param>
  233. /// <param name="settings">
  234. /// Settings object
  235. /// </param>
  236. public abstract void SaveToDataStore(ExtensionType extensionType, string extensionId, object settings);
  237. /// <summary>
  238. /// Retrieves a BlogRoll from the provider based on the specified id.
  239. /// </summary>
  240. /// <param name="id">The Blog Roll Item Id.</param>
  241. /// <returns>A BlogRollItem.</returns>
  242. public abstract BlogRollItem SelectBlogRollItem(Guid id);
  243. /// <summary>
  244. /// Retrieves a Blog from the provider based on the specified id.
  245. /// </summary>
  246. /// <param name="id">The Blog Id.</param>
  247. /// <returns>A Blog.</returns>
  248. public abstract Blog SelectBlog(Guid id);
  249. /// <summary>
  250. /// Retrieves a Category from the provider based on the specified id.
  251. /// </summary>
  252. /// <param name="id">The Category id.</param>
  253. /// <returns>A Category.</returns>
  254. public abstract Category SelectCategory(Guid id);
  255. /// <summary>
  256. /// Retrieves a Page from the provider based on the specified id.
  257. /// </summary>
  258. /// <param name="id">The Page id.</param>
  259. /// <returns>The Page object.</returns>
  260. public abstract Page SelectPage(Guid id);
  261. /// <summary>
  262. /// Retrieves a Post from the provider based on the specified id.
  263. /// </summary>
  264. /// <param name="id">The Post id.</param>
  265. /// <returns>A Post object.</returns>
  266. public abstract Post SelectPost(Guid id);
  267. /// <summary>
  268. /// Retrieves a Page from the provider based on the specified id.
  269. /// </summary>
  270. /// <param name="id">The AuthorProfile id.</param>
  271. /// <returns>An AuthorProfile.</returns>
  272. public abstract AuthorProfile SelectProfile(string id);
  273. /// <summary>
  274. /// Retrieves a Referrer from the provider based on the specified id.
  275. /// </summary>
  276. /// <param name="id">The Referrer Id.</param>
  277. /// <returns>A Referrer.</returns>
  278. public abstract Referrer SelectReferrer(Guid id);
  279. /// <summary>
  280. /// Sets up the required storage files/tables for a new Blog instance, from an existing blog instance.
  281. /// </summary>
  282. /// <param name="existingBlog">The existing blog instance to base the new blog instance off of.</param>
  283. /// <param name="newBlog">The new blog instance.</param>
  284. /// <returns>A boolean indicating if the setup process was successful.</returns>
  285. public abstract bool SetupBlogFromExistingBlog(Blog existingBlog, Blog newBlog);
  286. /// <summary>
  287. /// Updates an existing BlogRollItem in the data store specified by the provider.
  288. /// </summary>
  289. /// <param name="blogRollItem">
  290. /// The blogroll item to update.
  291. /// </param>
  292. public abstract void UpdateBlogRollItem(BlogRollItem blogRollItem);
  293. /// <summary>
  294. /// Updates an existing Blog in the data store specified by the provider.
  295. /// </summary>
  296. /// <param name="blog">
  297. /// The blog to update.
  298. /// </param>
  299. public abstract void UpdateBlog(Blog blog);
  300. /// <summary>
  301. /// Updates an existing Category in the data store specified by the provider.
  302. /// </summary>
  303. /// <param name="category">
  304. /// The category to update.
  305. /// </param>
  306. public abstract void UpdateCategory(Category category);
  307. /// <summary>
  308. /// Updates an existing Page in the data store specified by the provider.
  309. /// </summary>
  310. /// <param name="page">
  311. /// The page to update.
  312. /// </param>
  313. public abstract void UpdatePage(Page page);
  314. /// <summary>
  315. /// Updates an existing Post in the data store specified by the provider.
  316. /// </summary>
  317. /// <param name="post">
  318. /// The post to update.
  319. /// </param>
  320. public abstract void UpdatePost(Post post);
  321. /// <summary>
  322. /// Updates an existing Page in the data store specified by the provider.
  323. /// </summary>
  324. /// <param name="profile">
  325. /// The profile to update.
  326. /// </param>
  327. public abstract void UpdateProfile(AuthorProfile profile);
  328. /// <summary>
  329. /// Updates an existing Referrer in the data store specified by the provider.
  330. /// </summary>
  331. /// <param name="referrer">
  332. /// The referrer to update.
  333. /// </param>
  334. public abstract void UpdateReferrer(Referrer referrer);
  335. #region Packaging
  336. /// <summary>
  337. /// Save installed package id and version
  338. /// </summary>
  339. /// <param name="package">Intalled package</param>
  340. public abstract void SavePackage(InstalledPackage package);
  341. /// <summary>
  342. /// Log of all files for installed package
  343. /// </summary>
  344. /// <param name="packageFiles">List of intalled package files</param>
  345. public abstract void SavePackageFiles(List<PackageFile> packageFiles);
  346. /// <summary>
  347. /// Gets list of files for installed package
  348. /// </summary>
  349. /// <param name="packageId">Package ID</param>
  350. /// <returns>List of files for installed package</returns>
  351. public abstract List<PackageFile> FillPackageFiles(string packageId);
  352. /// <summary>
  353. /// Gets all installed from gallery packages
  354. /// </summary>
  355. /// <returns>List of installed packages</returns>
  356. public abstract List<InstalledPackage> FillPackages();
  357. /// <summary>
  358. /// Should delete package and remove all package files
  359. /// </summary>
  360. /// <param name="packageId">Package ID</param>
  361. /// <param name="version">Version</param>
  362. public abstract void DeletePackage(string packageId);
  363. #endregion
  364. #endregion
  365. }
  366. }