SIP Communicator: the OpenSource Java VoIP and Instant Messaging client.

net.java.sip.communicator.impl.filehistory
Class FileHistoryServiceImpl

java.lang.Object
  extended by net.java.sip.communicator.impl.filehistory.FileHistoryServiceImpl
All Implemented Interfaces:
EventListener, FileHistoryService, FileTransferListener, FileTransferStatusListener, org.osgi.framework.ServiceListener

public class FileHistoryServiceImpl
extends Object
implements FileHistoryService, org.osgi.framework.ServiceListener, FileTransferStatusListener, FileTransferListener

File History Service stores info for file transfers from various protocols. Uses History Service.

Author:
Damian Minkov

Constructor Summary
FileHistoryServiceImpl()
           
 
Method Summary
 void fileTransferCreated(FileTransferCreatedEvent event)
          New file transfer was created.
 void fileTransferRequestCanceled(FileTransferRequestEvent event)
          Called when an IncomingFileTransferRequest has been canceled from the contact who sent it.
 void fileTransferRequestReceived(FileTransferRequestEvent event)
          We ignore filetransfer requests.
 void fileTransferRequestRejected(FileTransferRequestEvent event)
          Called when a new IncomingFileTransferRequest has been rejected.
 Collection<FileRecord> findByEndDate(MetaContact contact, Date endDate)
          Returns all the file transfers made before the given date
 Collection<FileRecord> findByKeyword(MetaContact contact, String keyword)
          Returns all the file transfers having the given keyword in the filename
 Collection<FileRecord> findByKeyword(MetaContact contact, String keyword, boolean caseSensitive)
          Returns all the file transfers having the given keyword in the filename
 Collection<FileRecord> findByKeywords(MetaContact contact, String[] keywords)
          Returns all the file transfers having the given keywords in the filename
 Collection<FileRecord> findByKeywords(MetaContact contact, String[] keywords, boolean caseSensitive)
          Returns all the file transfershaving the given keywords in the filename
 Collection<FileRecord> findByPeriod(MetaContact contact, Date startDate, Date endDate)
          Returns all the file transfers made between the given dates
 Collection<FileRecord> findByPeriod(MetaContact contact, Date startDate, Date endDate, String[] keywords)
          Returns all the file transfers made between the given dates and having the given keywords in the filename
 Collection<FileRecord> findByPeriod(MetaContact contact, Date startDate, Date endDate, String[] keywords, boolean caseSensitive)
          Returns all the file transfers made between the given dates and having the given keywords in the filename
 Collection<FileRecord> findByStartDate(MetaContact contact, Date startDate)
          Returns all the file transfers made after the given date
 Collection<FileRecord> findFirstRecordsAfter(MetaContact contact, Date date, int count)
          Returns the supplied number of recent file transfers after the given date
 Collection<FileRecord> findLast(MetaContact contact, int count)
          Returns the supplied number of file transfers
 Collection<FileRecord> findLastRecordsBefore(MetaContact contact, Date date, int count)
          Returns the supplied number of recent file transfers before the given date
 void serviceChanged(org.osgi.framework.ServiceEvent serviceEvent)
          When new protocol provider is registered we check does it supports FileTransfer and if so add a listener to it
 void setHistoryService(HistoryService historyService)
          Set the history service.
 void start(org.osgi.framework.BundleContext bc)
          Starts the service.
 void statusChanged(FileTransferStatusChangeEvent event)
          Listens for changes in file transfers.
 void stop(org.osgi.framework.BundleContext bc)
          Stops the service.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

FileHistoryServiceImpl

public FileHistoryServiceImpl()
Method Detail

start

public void start(org.osgi.framework.BundleContext bc)
Starts the service. Check the current registerd protocol providers which supports FileTransfer and adds a listener to them.

Parameters:
bc - BundleContext

stop

public void stop(org.osgi.framework.BundleContext bc)
Stops the service.

Parameters:
bc - BundleContext

setHistoryService

public void setHistoryService(HistoryService historyService)
Set the history service.

Parameters:
historyService - HistoryService

findByStartDate

public Collection<FileRecord> findByStartDate(MetaContact contact,
                                              Date startDate)
                                       throws RuntimeException
Returns all the file transfers made after the given date

Specified by:
findByStartDate in interface FileHistoryService
Parameters:
contact - MetaContact the receiver or sender of the file
startDate - Date the start date of the transfers
Returns:
Collection of FileRecords
Throws:
RuntimeException

findByEndDate

public Collection<FileRecord> findByEndDate(MetaContact contact,
                                            Date endDate)
                                     throws RuntimeException
Returns all the file transfers made before the given date

Specified by:
findByEndDate in interface FileHistoryService
Parameters:
contact - MetaContact the receiver or sender of the file
endDate - Date the end date of the transfers
Returns:
Collection of FileRecords
Throws:
RuntimeException

findByPeriod

public Collection<FileRecord> findByPeriod(MetaContact contact,
                                           Date startDate,
                                           Date endDate,
                                           String[] keywords)
                                    throws RuntimeException
Returns all the file transfers made between the given dates and having the given keywords in the filename

Specified by:
findByPeriod in interface FileHistoryService
Parameters:
contact - MetaContact the receiver or sender of the file
startDate - Date the start date of the transfers
endDate - Date the end date of the transfers
keywords - array of keywords
Returns:
Collection of FileRecords
Throws:
RuntimeException

findByPeriod

public Collection<FileRecord> findByPeriod(MetaContact contact,
                                           Date startDate,
                                           Date endDate,
                                           String[] keywords,
                                           boolean caseSensitive)
                                    throws RuntimeException
Returns all the file transfers made between the given dates and having the given keywords in the filename

Specified by:
findByPeriod in interface FileHistoryService
Parameters:
contact - MetaContact the receiver or sender of the file
startDate - Date the start date of the transfers
endDate - Date the end date of the transfers
keywords - array of keywords
caseSensitive - is keywords search case sensitive
Returns:
Collection of FileRecords
Throws:
RuntimeException

findByPeriod

public Collection<FileRecord> findByPeriod(MetaContact contact,
                                           Date startDate,
                                           Date endDate)
                                    throws RuntimeException
Returns all the file transfers made between the given dates

Specified by:
findByPeriod in interface FileHistoryService
Parameters:
contact - MetaContact the receiver or sender of the file
startDate - Date the start date of the transfers
endDate - Date the end date of the transfers
Returns:
Collection of FileRecords
Throws:
RuntimeException

findLast

public Collection<FileRecord> findLast(MetaContact contact,
                                       int count)
                                throws RuntimeException
Returns the supplied number of file transfers

Specified by:
findLast in interface FileHistoryService
Parameters:
contact - MetaContact the receiver or sender of the file
count - filetransfer count
Returns:
Collection of FileRecords
Throws:
RuntimeException

findByKeyword

public Collection<FileRecord> findByKeyword(MetaContact contact,
                                            String keyword)
                                     throws RuntimeException
Returns all the file transfers having the given keyword in the filename

Specified by:
findByKeyword in interface FileHistoryService
Parameters:
contact - MetaContact the receiver or sender of the file
keyword - keyword
Returns:
Collection of FileRecords
Throws:
RuntimeException

findByKeyword

public Collection<FileRecord> findByKeyword(MetaContact contact,
                                            String keyword,
                                            boolean caseSensitive)
                                     throws RuntimeException
Returns all the file transfers having the given keyword in the filename

Specified by:
findByKeyword in interface FileHistoryService
Parameters:
contact - MetaContact the receiver or sender of the file
keyword - keyword
caseSensitive - is keywords search case sensitive
Returns:
Collection of FileRecords
Throws:
RuntimeException

findByKeywords

public Collection<FileRecord> findByKeywords(MetaContact contact,
                                             String[] keywords)
                                      throws RuntimeException
Returns all the file transfers having the given keywords in the filename

Specified by:
findByKeywords in interface FileHistoryService
Parameters:
contact - MetaContact the receiver or sender of the file
keywords - keyword
Returns:
Collection of FileRecords
Throws:
RuntimeException

findByKeywords

public Collection<FileRecord> findByKeywords(MetaContact contact,
                                             String[] keywords,
                                             boolean caseSensitive)
                                      throws RuntimeException
Returns all the file transfershaving the given keywords in the filename

Specified by:
findByKeywords in interface FileHistoryService
Parameters:
contact - MetaContact the receiver or sender of the file
keywords - keyword
caseSensitive - is keywords search case sensitive
Returns:
Collection of FileRecords
Throws:
RuntimeException

findFirstRecordsAfter

public Collection<FileRecord> findFirstRecordsAfter(MetaContact contact,
                                                    Date date,
                                                    int count)
                                             throws RuntimeException
Returns the supplied number of recent file transfers after the given date

Specified by:
findFirstRecordsAfter in interface FileHistoryService
Parameters:
contact - MetaContact the receiver or sender of the file
date - transfers after date
count - transfers count
Returns:
Collection of FileRecords
Throws:
RuntimeException

findLastRecordsBefore

public Collection<FileRecord> findLastRecordsBefore(MetaContact contact,
                                                    Date date,
                                                    int count)
                                             throws RuntimeException
Returns the supplied number of recent file transfers before the given date

Specified by:
findLastRecordsBefore in interface FileHistoryService
Parameters:
contact - MetaContact the receiver or sender of the file
date - transfers before date
count - transfers count
Returns:
Collection of FileRecords
Throws:
RuntimeException

serviceChanged

public void serviceChanged(org.osgi.framework.ServiceEvent serviceEvent)
When new protocol provider is registered we check does it supports FileTransfer and if so add a listener to it

Specified by:
serviceChanged in interface org.osgi.framework.ServiceListener
Parameters:
serviceEvent - ServiceEvent

statusChanged

public void statusChanged(FileTransferStatusChangeEvent event)
Listens for changes in file transfers.

Specified by:
statusChanged in interface FileTransferStatusListener
Parameters:
event -

fileTransferRequestReceived

public void fileTransferRequestReceived(FileTransferRequestEvent event)
We ignore filetransfer requests.

Specified by:
fileTransferRequestReceived in interface FileTransferListener
Parameters:
event -

fileTransferCreated

public void fileTransferCreated(FileTransferCreatedEvent event)
New file transfer was created.

Specified by:
fileTransferCreated in interface FileTransferListener
Parameters:
event - fileTransfer

fileTransferRequestRejected

public void fileTransferRequestRejected(FileTransferRequestEvent event)
Called when a new IncomingFileTransferRequest has been rejected.

Specified by:
fileTransferRequestRejected in interface FileTransferListener
Parameters:
event - the FileTransferRequestEvent containing the received request which was rejected.

fileTransferRequestCanceled

public void fileTransferRequestCanceled(FileTransferRequestEvent event)
Description copied from interface: FileTransferListener
Called when an IncomingFileTransferRequest has been canceled from the contact who sent it.

Specified by:
fileTransferRequestCanceled in interface FileTransferListener
Parameters:
event - the FileTransferRequestEvent containing the request which was canceled.

SIP Communicator: the OpenSource Java VoIP and Instant Messaging client.

SIP Communicator, the OpenSource Java VoIP and Instant Messaging client.
Distributable under LGPL license.