com.atlassian.confluence.impl.journal
Interface JournalDao

All Known Implementing Classes:
HibernateJournalDao

public interface JournalDao

Provides access to JournalEntry objects.

Since:
5.6

Method Summary
 int countEntries(JournalIdentifier journalId, long afterId, long ignoreWithinMillis)
          Counts the number of entries in a journal.
 long enqueue(JournalEntry entry)
          Adds the given entry to a journal.
 java.util.List<JournalEntry> findEntries(JournalIdentifier journalId, long afterId, long ignoreWithinMillis, int maxEntries)
          Finds journal entries that were added after an entry with the given id but earlier than given milliseconds ago.
 com.atlassian.fugue.Option<JournalEntry> findLatestEntry(JournalIdentifier journalId, long ignoreWithinMillis)
          Finds the latest journal entry if any.
 com.atlassian.fugue.Option<JournalEntry> findMostRecentEntryByMessage(JournalIdentifier journalId, java.lang.String message)
          Finds the most recent journal entry (if any) for the given journal that exactly matches the given journal entry message.
 int removeEntriesOlderThan(java.util.Date date)
          Removes entries from all journals that were created before the given date.
 

Method Detail

enqueue

long enqueue(@Nonnull
             JournalEntry entry)
Adds the given entry to a journal.

Parameters:
entry - entry to persist
Returns:
id generated for the entry

findEntries

java.util.List<JournalEntry> findEntries(@Nonnull
                                         JournalIdentifier journalId,
                                         long afterId,
                                         long ignoreWithinMillis,
                                         int maxEntries)
Finds journal entries that were added after an entry with the given id but earlier than given milliseconds ago. Entries are returned in ascending order of their identifier.

This method can miss some entries due to identifier assignment and entry insertion not being an atomic operation. The risk of missed entries can be reduced in two ways:

  1. Create new entries as close to transaction commit as possible.
  2. Increase ignoreSinceMillis value.

Parameters:
journalId - only entries with this journal id will be returned
afterId - only entries with id higher than this will be returned
ignoreWithinMillis - only entries created this many milliseconds ago or earlier will be returned
maxEntries - maximum number of entries to process
Returns:
journal entries that were added after an entry with the given id

findMostRecentEntryByMessage

com.atlassian.fugue.Option<JournalEntry> findMostRecentEntryByMessage(@Nonnull
                                                                      JournalIdentifier journalId,
                                                                      java.lang.String message)
Finds the most recent journal entry (if any) for the given journal that exactly matches the given journal entry message. Note that this operation is likely to EXTREMELY SLOW when the journal gets above a certain size. Do not use in production code.

Parameters:
journalId - only entries with this journal id will be returned
message - the exact text of the journal entry message
Returns:
the Optional journal entry matching the search

removeEntriesOlderThan

int removeEntriesOlderThan(@Nonnull
                           java.util.Date date)
Removes entries from all journals that were created before the given date.

Parameters:
date - only entried with a date later than this will be returned
Returns:
number of removed entries

findLatestEntry

com.atlassian.fugue.Option<JournalEntry> findLatestEntry(@Nonnull
                                                         JournalIdentifier journalId,
                                                         long ignoreWithinMillis)
Finds the latest journal entry if any.

Parameters:
journalId - identifier of the journal
ignoreWithinMillis - only entry created this many milliseconds ago or earlier will be returned
Returns:
the latest journal entry

countEntries

int countEntries(@Nonnull
                 JournalIdentifier journalId,
                 long afterId,
                 long ignoreWithinMillis)
Counts the number of entries in a journal.

Parameters:
journalId - identifier of the journal
afterId - only entries with id higher than this will be returned
ignoreWithinMillis - only entries created this many milliseconds ago or earlier will be returned


Copyright © 2003-2014 Atlassian. All Rights Reserved.