File Source: WeblogManager.java
/*
P/P * Method: org.apache.roller.weblogger.business.WeblogManager__static_init
*/
1 /*
2 * Licensed to the Apache Software Foundation (ASF) under one or more
3 * contributor license agreements. The ASF licenses this file to You
4 * under the Apache License, Version 2.0 (the "License"); you may not
5 * use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License. For additional information regarding
15 * copyright in this work, please see the NOTICE file in the top level
16 * directory of this distribution.
17 */
18
19 package org.apache.roller.weblogger.business;
20
21 import java.util.Date;
22 import java.util.List;
23 import java.util.Map;
24 import org.apache.roller.weblogger.WebloggerException;
25 import org.apache.roller.weblogger.pojos.WeblogEntryComment;
26 import org.apache.roller.weblogger.pojos.WeblogHitCount;
27 import org.apache.roller.weblogger.pojos.User;
28 import org.apache.roller.weblogger.pojos.WeblogCategory;
29 import org.apache.roller.weblogger.pojos.WeblogEntry;
30 import org.apache.roller.weblogger.pojos.Weblog;
31 import org.apache.roller.weblogger.util.RollerMessages;
32
33
34 /**
35 * Interface to weblog entry, category and comment management.
36 */
37 public interface WeblogManager {
38
39 public static final String DESCENDING = "DESCENDING";
40 public static final String ASCENDING = "ASCENDING";
41
42 /**
43 * Save weblog entry.
44 */
45 public void saveWeblogEntry(WeblogEntry entry) throws WebloggerException;
46
47 /**
48 * Remove weblog entry.
49 */
50 public void removeWeblogEntry(WeblogEntry entry) throws WebloggerException;
51
52 /**
53 * Get weblog entry by id.
54 */
55 public WeblogEntry getWeblogEntry(String id) throws WebloggerException;
56
57 /**
58 * Get weblog entry by anchor.
59 */
60 public WeblogEntry getWeblogEntryByAnchor(Weblog website, String anchor)
61 throws WebloggerException;
62
63 /**
64 * Get WeblogEntries by offset/length as list in reverse chronological order.
65 * The range offset and list arguments enable paging through query results.
66 * @param website Weblog or null to get for all weblogs.
67 * @param user User or null to get for all users.
68 * @param startDate Start date or null for no start date.
69 * @param endDate End date or null for no end date.
70 * @param catName Category path or null for all categories.
71 * @param status Status of DRAFT, PENDING, PUBLISHED or null for all
72 * @param text Text appearing in the text or summary, or null for all
73 * @param sortBy Sort by either 'pubTime' or 'updateTime' (null for pubTime)
74 * @param sortOrder Sort order of ASCENDING or DESCENDING (null for DESCENDING)
75 * @param offset Offset into results for paging
76 * @param length Max comments to return (or -1 for no limit)
77 * @return List of WeblogEntryData objects in reverse chrono order.
78 * @throws WebloggerException
79 */
80 public List getWeblogEntries(
81 Weblog website,
82 User user,
83 Date startDate,
84 Date endDate,
85 String catName,
86 List tags,
87 String status,
88 String text,
89 String sortBy,
90 String sortOrder,
91 String locale,
92 int offset,
93 int range)
94 throws WebloggerException;
95
96 /**
97 * Get Weblog Entries grouped by day. This method returns a Map that
98 * contains Lists, each List contains WeblogEntryData objects, and the
99 * Lists are keyed by Date objects.
100 * @param website Weblog or null to get for all weblogs.
101 * @param startDate Start date or null for no start date.
102 * @param endDate End date or null for no end date.
103 * @param catName Category path or null for all categories.
104 * @param status Status of DRAFT, PENDING, PUBLISHED or null for all
105 * @param offset Offset into results for paging
106 * @param length Max comments to return (or -1 for no limit)
107 * @return Map of Lists, keyed by Date, and containing WeblogEntryData.
108 * @throws WebloggerException
109 */
110 public Map getWeblogEntryObjectMap(
111 Weblog website,
112 Date startDate,
113 Date endDate,
114 String catName,
115 List tags,
116 String status,
117 String locale,
118 int offset,
119 int range)
120 throws WebloggerException;
121
122 /**
123 * Get Weblog Entry date strings grouped by day. This method returns a Map
124 * that contains Lists, each List contains YYYYMMDD date strings objects,
125 * and the Lists are keyed by Date objects.
126 * @param website Weblog or null to get for all weblogs.
127 * @param startDate Start date or null for no start date.
128 * @param endDate End date or null for no end date.
129 * @param catName Category path or null for all categories.
130 * @param status Status of DRAFT, PENDING, PUBLISHED or null for all
131 * @param offset Offset into results for paging
132 * @param length Max comments to return (or -1 for no limit)
133 * @return Map of Lists, keyed by Date, and containing date strings.
134 * @throws WebloggerException
135 */
136 public Map getWeblogEntryStringMap(
137 Weblog website,
138 Date startDate,
139 Date endDate,
140 String catName,
141 List tags,
142 String status,
143 String locale,
144 int offset,
145 int range)
146 throws WebloggerException;
147
148 /**
149 * Get weblog entries with given category or, optionally, any sub-category
150 * of that category.
151 * @param cat Category
152 * @param subcats True if sub-categories are to be fetched
153 * @return List of weblog entries in category
154 */
155 public List getWeblogEntries(WeblogCategory cat, boolean subcats)
156 throws WebloggerException;
157
158 /**
159 * Get weblog enties ordered by descending number of comments.
160 * @param website Weblog or null to get for all weblogs.
161 * @param startDate Start date or null for no start date.
162 * @param endDate End date or null for no end date.
163 * @param offset Offset into results for paging
164 * @param length Max comments to return (or -1 for no limit)
165 * @returns List of WeblogEntryData objects.
166 */
167 public List getMostCommentedWeblogEntries(
168 Weblog website,
169 Date startDate,
170 Date endDate,
171 int offset,
172 int length)
173 throws WebloggerException;
174
175 /**
176 * Get the WeblogEntry following, chronologically, the current entry.
177 * Restrict by the Category, if named.
178 * @param current The "current" WeblogEntryData
179 * @param catName The value of the requested Category Name
180 */
181 public WeblogEntry getNextEntry(WeblogEntry current,
182 String catName, String locale) throws WebloggerException;
183
184 /**
185 * Get the WeblogEntry prior to, chronologically, the current entry.
186 * Restrict by the Category, if named.
187 * @param current The "current" WeblogEntryData.
188 * @param catName The value of the requested Category Name.
189 */
190 public WeblogEntry getPreviousEntry(WeblogEntry current,
191 String catName, String locale) throws WebloggerException;
192
193
194 /**
195 * Get specified number of most recent pinned and published Weblog Entries.
196 * @param max Maximum number to return.
197 * @return Collection of WeblogEntryData objects.
198 */
199 public List getWeblogEntriesPinnedToMain(Integer max) throws WebloggerException;
200
201 /**
202 * Remove attribute with given name from given WeblogEntryData
203 * @param name Name of attribute to be removed
204 */
205 public void removeWeblogEntryAttribute(String name,WeblogEntry entry)
206 throws WebloggerException;
207
208 /**
209 * Remove tag with given name from given WeblogEntryData
210 * @param name Name of tag to be removed
211 */
212 public void removeWeblogEntryTag(String name,WeblogEntry entry)
213 throws WebloggerException;
214
215 /**
216 * Save weblog category.
217 */
218 public void saveWeblogCategory(WeblogCategory cat) throws WebloggerException;
219
220 /**
221 * Remove weblog category.
222 */
223 public void removeWeblogCategory(WeblogCategory cat) throws WebloggerException;
224
225 /**
226 * Get category by id.
227 */
228 public WeblogCategory getWeblogCategory(String id) throws WebloggerException;
229
230
231 /**
232 * Move a category under another category.
233 *
234 * This moves the src category itself and all children and associated entries.
235 */
236 public void moveWeblogCategory(WeblogCategory src, WeblogCategory dest)
237 throws WebloggerException;
238
239
240 /**
241 * Recategorize all entries with one category to another.
242 */
243 public void moveWeblogCategoryContents(WeblogCategory srcCat, WeblogCategory destCat)
244 throws WebloggerException;
245
246 /**
247 * Get top level categories for a website.
248 * @param website Website.
249 */
250 public WeblogCategory getRootWeblogCategory(Weblog website) throws WebloggerException;
251
252
253 /**
254 * Get category specified by website and categoryPath.
255 * @param website Website of WeblogCategory.
256 * @param categoryPath Path of WeblogCategory, relative to category root.
257 */
258 public WeblogCategory getWeblogCategoryByPath(Weblog website,
259 String categoryPath) throws WebloggerException;
260
261
262 /**
263 * Get WebLogCategory objects for a website.
264 */
265 public List getWeblogCategories(Weblog website, boolean includeRoot)
266 throws WebloggerException;
267
268
269 /**
270 * Save comment.
271 */
272 public void saveComment(WeblogEntryComment comment) throws WebloggerException;
273
274 /**
275 * Remove comment.
276 */
277 public void removeComment(WeblogEntryComment comment) throws WebloggerException;
278
279 /**
280 * Get comment by id.
281 */
282 public WeblogEntryComment getComment(String id) throws WebloggerException;
283
284 /**
285 * Generic comments query method.
286 * @param website Website or null for all comments on site
287 * @param entry Entry or null to include all comments
288 * @param startDate Start date or null for no restriction
289 * @param endDate End date or null for no restriction
290 * @param status The status of the comment, or null for any
291 * @param reverseChrono True for results in reverse chrono order
292 * @param offset Offset into results for paging
293 * @param length Max comments to return (or -1 for no limit)
294 */
295 public List getComments(
296
297 Weblog website,
298 WeblogEntry entry,
299 String searchString,
300 Date startDate,
301 Date endDate,
302 String status,
303 boolean reverseChrono,
304 int offset,
305 int length
306
307 ) throws WebloggerException;
308
309 /**
310 * Deletes comments that match paramters.
311 * @param website Website or null for all comments on site
312 * @param entry Entry or null to include all comments
313 * @param startDate Start date or null for no restriction
314 * @param endDate End date or null for no restriction
315 * @param status Status of comment
316 * @return Number of comments deleted
317 */
318 public int removeMatchingComments(
319
320 Weblog website,
321 WeblogEntry entry,
322 String searchString,
323 Date startDate,
324 Date endDate,
325 String status
326
327 ) throws WebloggerException;
328
329 /**
330 * Create unique anchor for weblog entry.
331 */
332 public String createAnchor(WeblogEntry data) throws WebloggerException;
333
334 /**
335 * Check for duplicate category name.
336 */
337 public boolean isDuplicateWeblogCategoryName(WeblogCategory data)
338 throws WebloggerException;
339
340 /**
341 * Check if weblog category is in use.
342 */
343 public boolean isWeblogCategoryInUse(WeblogCategory data)
344 throws WebloggerException;
345
346
347 /**
348 * Apply comment default settings from website to all of website's entries.
349 */
350 public void applyCommentDefaultsToEntries(Weblog website)
351 throws WebloggerException;
352
353 /**
354 * Release all resources held by manager.
355 */
356 public void release();
357
358 /**
359 * Get list of TagStat. There's no offset/length params just a limit.
360 * @param website Weblog or null to get for all weblogs.
361 * @param startDate Date or null of the most recent time a tag was used.
362 * @param limit Max TagStats to return (or -1 for no limit)
363 * @return
364 * @throws WebloggerException
365 */
366 public List getPopularTags(Weblog website, Date startDate, int limit)
367 throws WebloggerException;
368
369 /**
370 * Get list of TagStat. There's no offset/length params just a limit.
371 * @param website Weblog or null to get for all weblogs.
372 * @param sortBy Sort by either 'name' or 'count' (null for name)
373 * @param startsWith Prefix for tags to be returned (null or a string of length > 0)
374 * @param limit Max TagStats to return (or -1 for no limit)
375 * @return
376 * @throws WebloggerException
377 */
378 public List getTags(Weblog website, String sortBy, String startsWith, int limit)
379 throws WebloggerException;
380
381 /**
382 * Does the specified tag combination exist? Optionally confined to a specific weblog.
383 *
384 * This tests if the intersection of the tags listed will yield any results
385 * and returns a true/false value if so. This means that if the tags list
386 * is "foo", "bar" and only the tag "foo" has been used then this method
387 * should return false.
388 *
389 * @param tags The List of tags to check for.
390 * @param weblog The weblog to confine the check to.
391 * @return True if tags exist, false otherwise.
392 * @throws WebloggerException If there is any problem doing the operation.
393 */
394 public boolean getTagComboExists(List tags, Weblog weblog)
395 throws WebloggerException;
396
397 /**
398 * This method maintains the tag aggregate table up-to-date with total counts. More
399 * specifically every time this method is called it will act upon exactly two rows
400 * in the database (tag,website,count), one with website matching the argument passed
401 * and one where website is null. If the count ever reaches zero, the row must be deleted.
402 *
403 * @param name The tag name
404 * @param website The website to used when updating the stats.
405 * @param amount The amount to increment the tag count (it can be positive or negative).
406 * @throws WebloggerException
407 */
408 public void updateTagCount(String name, Weblog website, int amount)
409 throws WebloggerException;
410
411
412 /**
413 * Get a HitCountData by id.
414 *
415 * @param id The HitCountData id.
416 * @return The HitCountData object, or null if it wasn't found.
417 * @throws WebloggerException If there was a problem with the backend.
418 */
419 public WeblogHitCount getHitCount(String id) throws WebloggerException;
420
421
422 /**
423 * Get a HitCountData by weblog.
424 *
425 * @param weblog The WebsiteData that you want the hit count for.
426 * @return The HitCountData object, or null if it wasn't found.
427 * @throws WebloggerException If there was a problem with the backend.
428 */
429 public WeblogHitCount getHitCountByWeblog(Weblog weblog)
430 throws WebloggerException;
431
432
433 /**
434 * Get HitCountData objects for the hotest weblogs.
435 *
436 * The results may be constrained to a certain number of days back from the
437 * current time, as well as pagable via the offset and length params.
438 *
439 * The results are ordered by highest counts in descending order, and any
440 * weblogs which are not active or enabled are not included.
441 *
442 * @param sinceDays Number of days in the past to consider.
443 * @param offset What index in the results to begin from.
444 * @param length The number of results to return.
445 * @return The list of HitCountData objects ranked by hit count, descending.
446 * @throws WebloggerException If there was a problem with the backend.
447 */
448 public List getHotWeblogs(int sinceDays, int offset, int length)
449 throws WebloggerException;
450
451
452 /**
453 * Save a HitCountData object.
454 *
455 * @param hitCount The HitCountData object to save.
456 * @throws WebloggerException If there was a problem with the backend.
457 */
458 public void saveHitCount(WeblogHitCount hitCount) throws WebloggerException;
459
460
461 /**
462 * Remove a HitCountData object.
463 *
464 * @param hitCount The HitCountData object to remove.
465 * @throws WebloggerException If there was a problem with the backend.
466 */
467 public void removeHitCount(WeblogHitCount hitCount) throws WebloggerException;
468
469
470 /**
471 * Increment the hit count for a weblog by a certain amount.
472 *
473 * This is basically a convenience method for doing a lookup, modify, save
474 * of a HitCountData object.
475 *
476 * @param weblog The WebsiteData object to increment the count for.
477 * @param amount How much to increment by.
478 * @throws WebloggerException If there was a problem with the backend.
479 */
480 public void incrementHitCount(Weblog weblog, int amount)
481 throws WebloggerException;
482
483
484 /**
485 * Reset the hit counts for all weblogs. This sets the counts back to 0.
486 *
487 * @throws WebloggerException If there was a problem with the backend.
488 */
489 public void resetAllHitCounts() throws WebloggerException;
490
491
492 /**
493 * Reset the hit counts for a single weblog. This sets the count to 0.
494 *
495 * @param weblog The WebsiteData object to reset the count for.
496 * @throws WebloggerException If there was a problem with the backend.
497 */
498 public void resetHitCount(Weblog weblog) throws WebloggerException;
499
500
501 /**
502 * Get site-wide comment count
503 */
504 public long getCommentCount() throws WebloggerException;
505
506
507 /**
508 * Get weblog comment count
509 */
510 public long getCommentCount(Weblog websiteData) throws WebloggerException;
511
512
513 /**
514 * Get site-wide entry count
515 */
516 public long getEntryCount() throws WebloggerException;
517
518
519 /**
520 * Get weblog entry count
521 */
522 public long getEntryCount(Weblog websiteData) throws WebloggerException;
523
524 }
525
SofCheck Inspector Build Version : 2.18479
| WeblogManager.java |
2009-Jan-02 14:24:46 |
| WeblogManager.class |
2009-Sep-04 03:12:30 |