Jitsi: the OpenSource Java VoIP and Instant Messaging client.

net.java.sip.communicator.impl.history
Class HistoryServiceImpl

java.lang.Object
  extended by net.java.sip.communicator.impl.history.HistoryServiceImpl
All Implemented Interfaces:
HistoryService

public class HistoryServiceImpl
extends Object
implements HistoryService

Author:
Alexander Pelov, Damian Minkov, Lubomir Marinov

Field Summary
static String DATA_DIRECTORY
          The data directory.
static String DATA_FILE
          The data file.
 
Fields inherited from interface net.java.sip.communicator.service.history.HistoryService
CACHE_ENABLED_PROPERTY
 
Constructor Summary
HistoryServiceImpl(org.osgi.framework.BundleContext bundleContext)
          Constructor.
 
Method Summary
 History createHistory(HistoryID id, HistoryRecordStructure recordStructure)
          Creates a new history for this ID.
protected  DocumentBuilder getDocumentBuilder()
           
 Iterator<HistoryID> getExistingIDs()
          Returns the IDs of all existing histories.
protected  FileAccessService getFileAccessService()
           
 History getHistory(HistoryID id)
          Returns the history associated with this ID.
protected  boolean isCacheEnabled()
          Returns whether caching of readed documents is enabled or desibled.
 boolean isHistoryCreated(HistoryID id)
          Checks whether a history is created and stored.
 boolean isHistoryExisting(HistoryID id)
          Tests if a history with the given ID exists and is loaded.
 void moveHistory(HistoryID oldId, HistoryID newId)
          Moves the content of oldId history to the content of the newId.
protected  Document parse(ByteArrayInputStream in)
          Parse documents.
protected  Document parse(File file)
          Parse documents.
 void purgeLocallyStoredHistory(HistoryID id)
          Permamently removes local stored History
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DATA_DIRECTORY

public static final String DATA_DIRECTORY
The data directory.

See Also:
Constant Field Values

DATA_FILE

public static final String DATA_FILE
The data file.

See Also:
Constant Field Values
Constructor Detail

HistoryServiceImpl

public HistoryServiceImpl(org.osgi.framework.BundleContext bundleContext)
                   throws Exception
Constructor.

Parameters:
bundleContext - OSGi bundle context
Throws:
Exception - if something went wrong during initialization
Method Detail

getExistingIDs

public Iterator<HistoryID> getExistingIDs()
Description copied from interface: HistoryService
Returns the IDs of all existing histories.

Specified by:
getExistingIDs in interface HistoryService
Returns:
An iterator to a list of IDs.

isHistoryExisting

public boolean isHistoryExisting(HistoryID id)
Description copied from interface: HistoryService
Tests if a history with the given ID exists and is loaded.

Specified by:
isHistoryExisting in interface HistoryService
Parameters:
id - The ID to test.
Returns:
True if a history with this ID exists. False otherwise.

getHistory

public History getHistory(HistoryID id)
                   throws IllegalArgumentException
Description copied from interface: HistoryService
Returns the history associated with this ID.

Specified by:
getHistory in interface HistoryService
Parameters:
id - The ID of the history.
Returns:
Returns the history with this ID.
Throws:
IllegalArgumentException - Thrown if there is no such history.

createHistory

public History createHistory(HistoryID id,
                             HistoryRecordStructure recordStructure)
                      throws IllegalArgumentException,
                             IOException
Description copied from interface: HistoryService
Creates a new history for this ID.

Specified by:
createHistory in interface HistoryService
Parameters:
id - The ID of the history to be created.
recordStructure - The structure of the data.
Returns:
Returns the history with this ID.
Throws:
IllegalArgumentException - Thrown if such history already exists.
IOException - Thrown if the history could not be created due to a IO error.

getFileAccessService

protected FileAccessService getFileAccessService()

getDocumentBuilder

protected DocumentBuilder getDocumentBuilder()

parse

protected Document parse(File file)
                  throws SAXException,
                         IOException
Parse documents. Synchronized to avoid exception when concurrently parsing with same DocumentBuilder

Parameters:
file - File the file to parse
Returns:
Document the result document
Throws:
SAXException - exception
IOException - exception

parse

protected Document parse(ByteArrayInputStream in)
                  throws SAXException,
                         IOException
Parse documents. Synchronized to avoid exception when concurrently parsing with same DocumentBuilder

Parameters:
in - ByteArrayInputStream the stream to parse
Returns:
Document the result document
Throws:
SAXException - exception
IOException - exception

isCacheEnabled

protected boolean isCacheEnabled()
Returns whether caching of readed documents is enabled or desibled.

Returns:
boolean

purgeLocallyStoredHistory

public void purgeLocallyStoredHistory(HistoryID id)
                               throws IOException
Permamently removes local stored History

Specified by:
purgeLocallyStoredHistory in interface HistoryService
Parameters:
id - HistoryID
Throws:
IOException

moveHistory

public void moveHistory(HistoryID oldId,
                        HistoryID newId)
                 throws IOException
Moves the content of oldId history to the content of the newId. Moves the content from the oldId folder to the newId folder. Old folder must exist.

Specified by:
moveHistory in interface HistoryService
Parameters:
oldId - old and existing history
newId - the place where content of oldId will be moved
Throws:
IOException - problem moving to newId

isHistoryCreated

public boolean isHistoryCreated(HistoryID id)
Checks whether a history is created and stored. Exists in the file system.

Specified by:
isHistoryCreated in interface HistoryService
Parameters:
id - the history to check
Returns:
whether a history is created and stored.

Jitsi: the OpenSource Java VoIP and Instant Messaging client.

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