public class MessageHistoryServiceImpl extends java.lang.Object implements MessageHistoryService, MessageHistoryAdvancedService, MessageListener, ChatRoomMessageListener, AdHocChatRoomMessageListener, org.osgi.framework.ServiceListener, LocalUserChatRoomPresenceListener, LocalUserAdHocChatRoomPresenceListener
Modifier and Type | Class and Description |
---|---|
(package private) static class |
MessageHistoryServiceImpl.ChatRoomMemberImpl
Simple ChatRoomMember implementation.
|
Modifier and Type | Field and Description |
---|---|
(package private) static java.lang.String |
MSG_SUBTYPE_SMS
Subtype sms to mark sms messages.
|
(package private) static java.lang.String[] |
STRUCTURE_NAMES |
PNAME_IS_MESSAGE_HISTORY_ENABLED, PNAME_IS_MESSAGE_HISTORY_PER_CONTACT_ENABLED_PREFIX, PNAME_IS_RECENT_MESSAGES_DISABLED
Constructor and Description |
---|
MessageHistoryServiceImpl() |
Modifier and Type | Method and Description |
---|---|
void |
addSearchProgressListener(MessageHistorySearchProgressListener listener)
Adding progress listener for monitoring progress of search process
|
int |
countRecords(java.util.Map<?,HistoryReader> readers)
Total count of records for supplied history readers will read through
|
void |
eraseLocallyStoredHistory()
Permanently removes all locally stored message history.
|
void |
eraseLocallyStoredHistory(ChatRoom room)
Permanently removes locally stored message history for the chatroom.
|
void |
eraseLocallyStoredHistory(MetaContact contact)
Permanently removes locally stored message history for the metacontact.
|
java.util.Collection<java.util.EventObject> |
findByEndDate(ChatRoom room,
java.util.Date endDate)
Returns all the messages exchanged
in the supplied chat room before the given date
|
java.util.Collection<java.util.EventObject> |
findByEndDate(MetaContact contact,
java.util.Date endDate)
Returns all the messages exchanged by all the contacts
in the supplied metacontact before the given date
|
java.util.Collection<java.util.EventObject> |
findByKeyword(ChatRoom room,
java.lang.String keyword)
Returns all the messages exchanged
in the supplied room having the given keyword
|
java.util.Collection<java.util.EventObject> |
findByKeyword(ChatRoom room,
java.lang.String keyword,
boolean caseSensitive)
Returns all the messages exchanged
in the supplied chat room having the given keyword
|
java.util.Collection<java.util.EventObject> |
findByKeyword(MetaContact contact,
java.lang.String keyword)
Returns all the messages exchanged by all the contacts
in the supplied metacontact having the given keyword
|
java.util.Collection<java.util.EventObject> |
findByKeyword(MetaContact contact,
java.lang.String keyword,
boolean caseSensitive)
Returns all the messages exchanged by all the contacts
in the supplied metacontact having the given keyword
|
java.util.Collection<java.util.EventObject> |
findByKeywords(ChatRoom room,
java.lang.String[] keywords)
Returns all the messages exchanged
in the supplied chat room having the given keywords
|
java.util.Collection<java.util.EventObject> |
findByKeywords(ChatRoom room,
java.lang.String[] keywords,
boolean caseSensitive)
Returns all the messages exchanged
in the supplied chat room having the given keywords
|
java.util.Collection<java.util.EventObject> |
findByKeywords(MetaContact contact,
java.lang.String[] keywords)
Returns all the messages exchanged by all the contacts
in the supplied metacontact having the given keywords
|
java.util.Collection<java.util.EventObject> |
findByKeywords(MetaContact contact,
java.lang.String[] keywords,
boolean caseSensitive)
Returns all the messages exchanged by all the contacts
in the supplied metacontact having the given keywords
|
java.util.Collection<java.util.EventObject> |
findByPeriod(ChatRoom room,
java.util.Date startDate,
java.util.Date endDate)
Returns all the messages exchanged
in the supplied chat room between the given dates
|
java.util.Collection<java.util.EventObject> |
findByPeriod(ChatRoom room,
java.util.Date startDate,
java.util.Date endDate,
java.lang.String[] keywords)
Returns all the messages exchanged
in the supplied chat room between the given dates and having the given
keywords
|
java.util.Collection<java.util.EventObject> |
findByPeriod(ChatRoom room,
java.util.Date startDate,
java.util.Date endDate,
java.lang.String[] keywords,
boolean caseSensitive)
Returns all the messages exchanged
in the supplied chat room between the given dates and having the given
keywords
|
java.util.Collection<java.util.EventObject> |
findByPeriod(MetaContact contact,
java.util.Date startDate,
java.util.Date endDate)
Returns all the messages exchanged by all the contacts
in the supplied metacontact between the given dates
|
java.util.Collection<java.util.EventObject> |
findByPeriod(MetaContact contact,
java.util.Date startDate,
java.util.Date endDate,
java.lang.String[] keywords)
Returns all the messages exchanged by all the contacts
in the supplied metacontact between the given dates and having the given
keywords
|
java.util.Collection<java.util.EventObject> |
findByPeriod(MetaContact contact,
java.util.Date startDate,
java.util.Date endDate,
java.lang.String[] keywords,
boolean caseSensitive)
Returns all the messages exchanged by all the contacts
in the supplied metacontact between the given dates and having the given
keywords
|
java.util.Collection<java.util.EventObject> |
findByStartDate(ChatRoom room,
java.util.Date startDate)
Returns all the messages exchanged in the supplied
chat room after the given date
|
java.util.Collection<java.util.EventObject> |
findByStartDate(MetaContact contact,
java.util.Date startDate)
Returns all the messages exchanged by all the contacts
in the supplied metacontact after the given date
|
java.util.Collection<java.util.EventObject> |
findFirstMessagesAfter(ChatRoom room,
java.util.Date date,
int count)
Returns the supplied number of recent messages after the given date
exchanged in the supplied chat room
|
java.util.Collection<java.util.EventObject> |
findFirstMessagesAfter(MetaContact contact,
java.util.Date date,
int count)
Returns the supplied number of recent messages after the given date
exchanged by all the contacts in the supplied metacontact
|
java.util.Collection<java.util.EventObject> |
findLast(ChatRoom room,
int count)
Returns the supplied number of recent messages exchanged
in the supplied chat room
|
java.util.Collection<java.util.EventObject> |
findLast(MetaContact contact,
int count)
Returns the supplied number of recent messages exchanged by all the
contacts in the supplied metacontact
|
java.util.Collection<java.util.EventObject> |
findLastMessagesBefore(ChatRoom room,
java.util.Date date,
int count)
Returns the supplied number of recent messages before the given date
exchanged in the supplied chat room
|
java.util.Collection<java.util.EventObject> |
findLastMessagesBefore(MetaContact contact,
java.util.Date date,
int count)
Returns the supplied number of recent messages before the given date
exchanged by all the contacts in the supplied metacontact
|
(package private) java.util.Collection<java.util.EventObject> |
findRecentMessagesPerContact(int count,
java.lang.String providerToFilter,
java.lang.String contactToFilter,
boolean isSMSEnabled)
Returns the messages for the recently contacted count contacts.
|
(package private) java.util.List<ProtocolProviderService> |
getCurrentlyAvailableProviders()
Returns currently registered in osgi ProtocolProviderServices.
|
HistoryService |
getHistoryService()
Returns the history service.
|
void |
insertMessage(java.lang.String direction,
Contact source,
Contact destination,
Message message,
java.util.Date messageTimestamp,
boolean isSmsSubtype)
Inserts message to the history.
|
boolean |
isHistoryLoggingEnabled()
Returns
true if the "IS_MESSAGE_HISTORY_ENABLED"
property is true, otherwise - returns false . |
boolean |
isHistoryLoggingEnabled(java.lang.String id)
Returns
true if the "IS_MESSAGE_HISTORY_ENABLED"
property is true for the id, otherwise - returns
false . |
void |
localUserAdHocPresenceChanged(LocalUserAdHocChatRoomPresenceChangeEvent evt)
Called to notify interested parties that a change in our presence in
an ad-hoc chat room has occurred.
|
void |
localUserPresenceChanged(LocalUserChatRoomPresenceChangeEvent evt)
Called to notify interested parties that a change in our presence in
a chat room has occured.
|
void |
messageDelivered(AdHocChatRoomMessageDeliveredEvent evt)
Called when the underlying implementation has received an indication
that a message, sent earlier has been successfully received by the
destination.
|
void |
messageDelivered(ChatRoomMessageDeliveredEvent evt)
Called when the underlying implementation has received an indication
that a message, sent earlier has been successfully received by the
destination.
|
void |
messageDelivered(MessageDeliveredEvent evt)
Called when the underlying implementation has received an indication
that a message, sent earlier has been successfully received by the
destination.
|
void |
messageDeliveryFailed(AdHocChatRoomMessageDeliveryFailedEvent evt)
Called to indicate that delivery of a message sent earlier to the chat
room has failed.
|
void |
messageDeliveryFailed(ChatRoomMessageDeliveryFailedEvent evt)
Called to indicate that delivery of a message sent earlier to the chat
room has failed.
|
void |
messageDeliveryFailed(MessageDeliveryFailedEvent evt)
Called to indicated that delivery of a message sent earlier has failed.
|
void |
messageReceived(AdHocChatRoomMessageReceivedEvent evt)
Called when a new incoming Message has been received.
|
void |
messageReceived(ChatRoomMessageReceivedEvent evt)
Called when a new incoming Message has been received.
|
void |
messageReceived(MessageReceivedEvent evt)
Called when a new incoming Message has been received.
|
void |
removeSearchProgressListener(MessageHistorySearchProgressListener listener)
Removing progress listener
|
void |
serviceChanged(org.osgi.framework.ServiceEvent serviceEvent)
When new protocol provider is registered we check
does it supports BasicIM and if so add a listener to it
|
void |
setHistoryLoggingEnabled(boolean isEnabled)
Updates the "isHistoryLoggingEnabled" property through the
ConfigurationService.
|
void |
setHistoryLoggingEnabled(boolean isEnabled,
java.lang.String id)
Updates the "isHistoryLoggingEnabled" property through the
ConfigurationService for the contact.
|
void |
setHistoryService(HistoryService historyService)
Set the configuration service.
|
void |
start(org.osgi.framework.BundleContext bc)
Starts the service.
|
void |
stop(org.osgi.framework.BundleContext bc)
Stops the service.
|
void |
unsetHistoryService(HistoryService historyService)
Remove a configuration service.
|
static java.lang.String[] STRUCTURE_NAMES
static final java.lang.String MSG_SUBTYPE_SMS
public HistoryService getHistoryService()
public java.util.Collection<java.util.EventObject> findByStartDate(MetaContact contact, java.util.Date startDate) throws java.lang.RuntimeException
findByStartDate
in interface MessageHistoryService
contact
- MetaContactstartDate
- Date the start date of the conversationsjava.lang.RuntimeException
public java.util.Collection<java.util.EventObject> findByEndDate(MetaContact contact, java.util.Date endDate) throws java.lang.RuntimeException
findByEndDate
in interface MessageHistoryService
contact
- MetaContactendDate
- Date the end date of the conversationsjava.lang.RuntimeException
public java.util.Collection<java.util.EventObject> findByPeriod(MetaContact contact, java.util.Date startDate, java.util.Date endDate) throws java.lang.RuntimeException
findByPeriod
in interface MessageHistoryService
contact
- MetaContactstartDate
- Date the start date of the conversationsendDate
- Date the end date of the conversationsjava.lang.RuntimeException
public java.util.Collection<java.util.EventObject> findByPeriod(MetaContact contact, java.util.Date startDate, java.util.Date endDate, java.lang.String[] keywords) throws java.lang.RuntimeException
findByPeriod
in interface MessageHistoryService
contact
- MetaContactstartDate
- Date the start date of the conversationsendDate
- Date the end date of the conversationskeywords
- array of keywordsjava.lang.RuntimeException
public java.util.Collection<java.util.EventObject> findByKeyword(MetaContact contact, java.lang.String keyword) throws java.lang.RuntimeException
findByKeyword
in interface MessageHistoryService
contact
- MetaContactkeyword
- keywordjava.lang.RuntimeException
public java.util.Collection<java.util.EventObject> findByKeywords(MetaContact contact, java.lang.String[] keywords) throws java.lang.RuntimeException
findByKeywords
in interface MessageHistoryService
contact
- MetaContactkeywords
- keywordjava.lang.RuntimeException
public java.util.Collection<java.util.EventObject> findLast(MetaContact contact, int count) throws java.lang.RuntimeException
findLast
in interface MessageHistoryService
contact
- MetaContactcount
- messages countjava.lang.RuntimeException
java.util.Collection<java.util.EventObject> findRecentMessagesPerContact(int count, java.lang.String providerToFilter, java.lang.String contactToFilter, boolean isSMSEnabled) throws java.lang.RuntimeException
count
- contacts countproviderToFilter
- can be filtered by provider, or null to
search for all providerscontactToFilter
- can be filtered by contac, or null to
search for all contactsjava.lang.RuntimeException
public java.util.Collection<java.util.EventObject> findFirstMessagesAfter(MetaContact contact, java.util.Date date, int count) throws java.lang.RuntimeException
findFirstMessagesAfter
in interface MessageHistoryService
contact
- MetaContactdate
- messages after datecount
- messages countjava.lang.RuntimeException
public java.util.Collection<java.util.EventObject> findLastMessagesBefore(MetaContact contact, java.util.Date date, int count) throws java.lang.RuntimeException
findLastMessagesBefore
in interface MessageHistoryService
contact
- MetaContactdate
- messages before datecount
- messages countjava.lang.RuntimeException
public void start(org.osgi.framework.BundleContext bc)
bc
- BundleContextpublic void stop(org.osgi.framework.BundleContext bc)
bc
- BundleContextpublic void messageReceived(MessageReceivedEvent evt)
MessageListener
messageReceived
in interface MessageListener
evt
- the MessageReceivedEvent containing the newly
received message, its sender and other details.public void messageDelivered(MessageDeliveredEvent evt)
MessageListener
messageDelivered
in interface MessageListener
evt
- the MessageDeliveredEvent containing the id of the message
that has caused the event.public void messageDeliveryFailed(MessageDeliveryFailedEvent evt)
MessageListener
messageDeliveryFailed
in interface MessageListener
evt
- the MessageFailedEvent containing the ID of the
message whose delivery has failed.public void messageReceived(ChatRoomMessageReceivedEvent evt)
ChatRoomMessageListener
messageReceived
in interface ChatRoomMessageListener
evt
- the ChatRoomMessageReceivedEvent containing the newly
received message, its sender and other details.public void messageDelivered(ChatRoomMessageDeliveredEvent evt)
ChatRoomMessageListener
messageDelivered
in interface ChatRoomMessageListener
evt
- the ChatRoomMessageDeliveredEvent containing the id
of the message that has caused the event.public void messageDeliveryFailed(ChatRoomMessageDeliveryFailedEvent evt)
ChatRoomMessageListener
messageDeliveryFailed
in interface ChatRoomMessageListener
evt
- the ChatroomMessageDeliveryFailedEvent containing
the ID of the message whose delivery has failed.public void insertMessage(java.lang.String direction, Contact source, Contact destination, Message message, java.util.Date messageTimestamp, boolean isSmsSubtype)
insertMessage
in interface MessageHistoryAdvancedService
direction
- String direction of the message in or out.source
- The source Contactdestination
- The destination Contactmessage
- Message message to be writtenmessageTimestamp
- Date this is the timestamp when was message
received that came from the protocol providerisSmsSubtype
- whether message to write is an smspublic void setHistoryService(HistoryService historyService) throws java.lang.IllegalArgumentException, java.io.IOException
historyService
- HistoryServicejava.io.IOException
java.lang.IllegalArgumentException
public void unsetHistoryService(HistoryService historyService)
historyService
- HistoryServicepublic void serviceChanged(org.osgi.framework.ServiceEvent serviceEvent)
serviceChanged
in interface org.osgi.framework.ServiceListener
serviceEvent
- ServiceEventpublic void localUserPresenceChanged(LocalUserChatRoomPresenceChangeEvent evt)
localUserPresenceChanged
in interface LocalUserChatRoomPresenceListener
evt
- the LocalUserChatRoomPresenceChangeEvent instance
containing the chat room and the type, and reason of the changepublic void addSearchProgressListener(MessageHistorySearchProgressListener listener)
addSearchProgressListener
in interface MessageHistoryService
listener
- HistorySearchProgressListenerpublic void removeSearchProgressListener(MessageHistorySearchProgressListener listener)
removeSearchProgressListener
in interface MessageHistoryService
listener
- HistorySearchProgressListenerpublic java.util.Collection<java.util.EventObject> findByPeriod(MetaContact contact, java.util.Date startDate, java.util.Date endDate, java.lang.String[] keywords, boolean caseSensitive) throws java.lang.RuntimeException
findByPeriod
in interface MessageHistoryService
contact
- MetaContactstartDate
- Date the start date of the conversationsendDate
- Date the end date of the conversationskeywords
- array of keywordscaseSensitive
- is keywords search case sensitivejava.lang.RuntimeException
public java.util.Collection<java.util.EventObject> findByKeyword(MetaContact contact, java.lang.String keyword, boolean caseSensitive) throws java.lang.RuntimeException
findByKeyword
in interface MessageHistoryService
contact
- MetaContactkeyword
- keywordcaseSensitive
- is keywords search case sensitivejava.lang.RuntimeException
public java.util.Collection<java.util.EventObject> findByKeywords(MetaContact contact, java.lang.String[] keywords, boolean caseSensitive) throws java.lang.RuntimeException
findByKeywords
in interface MessageHistoryService
contact
- MetaContactkeywords
- keywordcaseSensitive
- is keywords search case sensitivejava.lang.RuntimeException
public int countRecords(java.util.Map<?,HistoryReader> readers)
readers
- hashtable with pairs contact <-> history readerjava.lang.UnsupportedOperationException
- Thrown if an exception occurs during the execution of the
query, such as internal IO error.public java.util.Collection<java.util.EventObject> findByStartDate(ChatRoom room, java.util.Date startDate) throws java.lang.RuntimeException
findByStartDate
in interface MessageHistoryService
room
- The chat roomstartDate
- Date the start date of the conversationsjava.lang.RuntimeException
public java.util.Collection<java.util.EventObject> findByEndDate(ChatRoom room, java.util.Date endDate) throws java.lang.RuntimeException
findByEndDate
in interface MessageHistoryService
room
- The chat roomendDate
- Date the end date of the conversationsjava.lang.RuntimeException
public java.util.Collection<java.util.EventObject> findByPeriod(ChatRoom room, java.util.Date startDate, java.util.Date endDate) throws java.lang.RuntimeException
findByPeriod
in interface MessageHistoryService
room
- The chat roomstartDate
- Date the start date of the conversationsendDate
- Date the end date of the conversationsjava.lang.RuntimeException
public java.util.Collection<java.util.EventObject> findByPeriod(ChatRoom room, java.util.Date startDate, java.util.Date endDate, java.lang.String[] keywords) throws java.lang.RuntimeException
findByPeriod
in interface MessageHistoryService
room
- The chat roomstartDate
- Date the start date of the conversationsendDate
- Date the end date of the conversationskeywords
- array of keywordsjava.lang.RuntimeException
public java.util.Collection<java.util.EventObject> findByPeriod(ChatRoom room, java.util.Date startDate, java.util.Date endDate, java.lang.String[] keywords, boolean caseSensitive) throws java.lang.RuntimeException
findByPeriod
in interface MessageHistoryService
room
- The chat roomstartDate
- Date the start date of the conversationsendDate
- Date the end date of the conversationskeywords
- array of keywordscaseSensitive
- is keywords search case sensitivejava.lang.RuntimeException
public java.util.Collection<java.util.EventObject> findByKeyword(ChatRoom room, java.lang.String keyword) throws java.lang.RuntimeException
findByKeyword
in interface MessageHistoryService
room
- The Chat roomkeyword
- keywordjava.lang.RuntimeException
public java.util.Collection<java.util.EventObject> findByKeyword(ChatRoom room, java.lang.String keyword, boolean caseSensitive) throws java.lang.RuntimeException
findByKeyword
in interface MessageHistoryService
room
- The chat roomkeyword
- keywordcaseSensitive
- is keywords search case sensitivejava.lang.RuntimeException
public java.util.Collection<java.util.EventObject> findByKeywords(ChatRoom room, java.lang.String[] keywords) throws java.lang.RuntimeException
findByKeywords
in interface MessageHistoryService
room
- The chat roomkeywords
- keywordjava.lang.RuntimeException
public java.util.Collection<java.util.EventObject> findByKeywords(ChatRoom room, java.lang.String[] keywords, boolean caseSensitive) throws java.lang.RuntimeException
findByKeywords
in interface MessageHistoryService
room
- The chat roomkeywords
- keywordcaseSensitive
- is keywords search case sensitivejava.lang.RuntimeException
public java.util.Collection<java.util.EventObject> findLast(ChatRoom room, int count) throws java.lang.RuntimeException
findLast
in interface MessageHistoryService
room
- The chat roomcount
- messages countjava.lang.RuntimeException
public java.util.Collection<java.util.EventObject> findFirstMessagesAfter(ChatRoom room, java.util.Date date, int count) throws java.lang.RuntimeException
findFirstMessagesAfter
in interface MessageHistoryService
room
- The chat roomdate
- messages after datecount
- messages countjava.lang.RuntimeException
public java.util.Collection<java.util.EventObject> findLastMessagesBefore(ChatRoom room, java.util.Date date, int count) throws java.lang.RuntimeException
findLastMessagesBefore
in interface MessageHistoryService
room
- The chat roomdate
- messages before datecount
- messages countjava.lang.RuntimeException
java.util.List<ProtocolProviderService> getCurrentlyAvailableProviders()
public void messageDelivered(AdHocChatRoomMessageDeliveredEvent evt)
AdHocChatRoomMessageListener
messageDelivered
in interface AdHocChatRoomMessageListener
evt
- the AdHocChatRoomMessageDeliveredEvent containing the
id of the message that has caused the event.public void messageDeliveryFailed(AdHocChatRoomMessageDeliveryFailedEvent evt)
AdHocChatRoomMessageListener
messageDeliveryFailed
in interface AdHocChatRoomMessageListener
evt
- the AdHocChatroomMessageDeliveryFailedEvent
containing the ID of the message whose delivery has failed.public void messageReceived(AdHocChatRoomMessageReceivedEvent evt)
AdHocChatRoomMessageListener
messageReceived
in interface AdHocChatRoomMessageListener
evt
- the AdHocChatRoomMessageReceivedEvent containing the
newly received message, its sender and other details.public void localUserAdHocPresenceChanged(LocalUserAdHocChatRoomPresenceChangeEvent evt)
localUserAdHocPresenceChanged
in interface LocalUserAdHocChatRoomPresenceListener
evt
- the LocalUserAdHocChatRoomPresenceChangeEvent
instance containing the ad-hoc chat room and the type, and reason of the
changepublic void eraseLocallyStoredHistory() throws java.io.IOException
eraseLocallyStoredHistory
in interface MessageHistoryService
java.io.IOException
- Thrown if the history could not be removed due to a IO error.public void eraseLocallyStoredHistory(MetaContact contact) throws java.io.IOException
eraseLocallyStoredHistory
in interface MessageHistoryService
java.io.IOException
- Thrown if the history could not be removed due to a IO error.public void eraseLocallyStoredHistory(ChatRoom room) throws java.io.IOException
eraseLocallyStoredHistory
in interface MessageHistoryService
java.io.IOException
- Thrown if the history could not be removed due to a IO error.public boolean isHistoryLoggingEnabled()
true
if the "IS_MESSAGE_HISTORY_ENABLED"
property is true, otherwise - returns false
.
Indicates to the user interface whether the history logging is enabled.isHistoryLoggingEnabled
in interface MessageHistoryService
true
if the "IS_MESSAGE_HISTORY_ENABLED"
property is true, otherwise - returns false
.public void setHistoryLoggingEnabled(boolean isEnabled)
setHistoryLoggingEnabled
in interface MessageHistoryService
isEnabled
- indicates if the history logging is
enabled.public boolean isHistoryLoggingEnabled(java.lang.String id)
true
if the "IS_MESSAGE_HISTORY_ENABLED"
property is true for the id, otherwise - returns
false
.
Indicates to the user interface whether the history logging is enabled
for the supplied id (id for metacontact or for chat room).isHistoryLoggingEnabled
in interface MessageHistoryService
true
if the "IS_MESSAGE_HISTORY_ENABLED"
property is true for the id, otherwise - returns
false
.public void setHistoryLoggingEnabled(boolean isEnabled, java.lang.String id)
setHistoryLoggingEnabled
in interface MessageHistoryService
isEnabled
- indicates if the history logging is
enabled for the contact.
Jitsi, the OpenSource Java VoIP and Instant Messaging client.
Distributable under Apache license.