org.openrdf.sesame.repository.local
Class LocalService

java.lang.Object
  extended byorg.openrdf.sesame.repository.local.LocalService
All Implemented Interfaces:
SesameService

public class LocalService
extends Object
implements SesameService

A Sesame service for local repositories.

Author:
Jeen Broekstra, Arjohn Kampman

Constructor Summary
LocalService()
          Creates a new LocalService that does not administer any repositories yet.
LocalService(SystemConfig systemConfig)
          Creates a new LocalService for all repositories defined in the supplied SystemConfig object.
 
Method Summary
 void addRepository(RepositoryConfig repConfig)
          Defines a new repository.
 LocalRepository createRepository(RepositoryConfig repConfig)
          Adds a new repository definition to this LocalService and creates a SesameRepository object for it.
 LocalRepository createRepository(String repositoryId, boolean inferencing)
          Adds a new repository with the supplied ID to this LocalService and creates a LocalRepository object for it.
 File createTmpFile(String prefix, String suffix)
          Creates a new file with the supplied prefix and suffix in the configured tmp directory.
 SesameRepository getRepository(String repositoryId)
          Gets a SesameRepository object for the specified repository ID.
 RepositoryList getRepositoryList()
          Gets a list of all repositories that are accessible by the currently logged in user.
 SystemConfig getSystemConfig()
          Gets the system configuration that is used by this service.
 File getTmpDir()
           
 boolean hasReadAccess(String repository)
          Checks whether the user that has logged in has read access on the specified repository.
 boolean hasWriteAccess(String repository)
          Checks whether the user that has logged in has write access on the specified repository.
 void login(String user, String password)
          Log in to a Sesame service.
 void logout()
          Log out from a Sesame service.
 void removeRepository(String repositoryId)
          Removes a repository definition.
 void setSystemConfig(SystemConfig newConfig)
          Sets or updates the system configuration that is used by this service.
 void shutDown()
          Shuts down all repositories that are configured for this service.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

LocalService

public LocalService()
Creates a new LocalService that does not administer any repositories yet.


LocalService

public LocalService(SystemConfig systemConfig)
Creates a new LocalService for all repositories defined in the supplied SystemConfig object.

Parameters:
systemConfig - A SystemConfig object containing repository definitions.
Method Detail

setSystemConfig

public void setSystemConfig(SystemConfig newConfig)
Sets or updates the system configuration that is used by this service.


getSystemConfig

public SystemConfig getSystemConfig()
Gets the system configuration that is used by this service.


login

public void login(String user,
                  String password)
           throws AccessDeniedException
Log in to a Sesame service. As the login process is Thread-based, the login will only apply to the thread executing this method.

Specified by:
login in interface SesameService
Throws:
AccessDeniedException - If the attempt to log in failed.
IOException - If an I/O error occurred.
IllegalArgumentException - If the supplied username is not a legal username.

logout

public void logout()
Description copied from interface: SesameService
Log out from a Sesame service.

Specified by:
logout in interface SesameService

getRepositoryList

public RepositoryList getRepositoryList()
Description copied from interface: SesameService
Gets a list of all repositories that are accessible by the currently logged in user. If no user is logged in, all repositories that are world-accessible are retrieved.

Specified by:
getRepositoryList in interface SesameService
Returns:
A RepositoryListImpl

getRepository

public SesameRepository getRepository(String repositoryId)
                               throws UnknownRepositoryException,
                                      ConfigurationException
Description copied from interface: SesameService
Gets a SesameRepository object for the specified repository ID.

Specified by:
getRepository in interface SesameService
Parameters:
repositoryId - A repository ID.
Throws:
ConfigurationException - If the requested repository was not configured properly.
UnknownRepositoryException - If the specified repository ID is unknown.

addRepository

public void addRepository(RepositoryConfig repConfig)
                   throws ConfigurationException
Defines a new repository.

Parameters:
repConfig - The new repository's configuration.
Throws:
ConfigurationException - If a repository with an identical ID is already defined.

removeRepository

public void removeRepository(String repositoryId)
Removes a repository definition.

Parameters:
repositoryId - The ID of the repository to remove.

createRepository

public LocalRepository createRepository(RepositoryConfig repConfig)
                                 throws ConfigurationException
Adds a new repository definition to this LocalService and creates a SesameRepository object for it.

Parameters:
repConfig - A repository configuration.
Returns:
A SesameRepository matching the supplied configuration.
Throws:
ConfigurationException - If the supplied configuration cannot be added for some reason.

createRepository

public LocalRepository createRepository(String repositoryId,
                                        boolean inferencing)
                                 throws ConfigurationException
Adds a new repository with the supplied ID to this LocalService and creates a LocalRepository object for it. The repository will be a world-readable/writeable, synchronized in-memory repository, without persistence.

Parameters:
repositoryId - the ID for this repository.
inferencing - indicates if the repository should be an inferencing repository.
Returns:
A SesameRepository using the in-memory sail, and a synchronization layer.
Throws:
ConfigurationException - If a repository with the supplied ID cannot be added for some reason, e.g. if the ID was already in use.

shutDown

public void shutDown()
Shuts down all repositories that are configured for this service.


hasReadAccess

public boolean hasReadAccess(String repository)
                      throws UnknownRepositoryException
Checks whether the user that has logged in has read access on the specified repository. If no user has been logged in, this method will only return true if the repository is world-readable.

Parameters:
repository - A repository ID.
Returns:
true if the user has read access, false otherwise.
Throws:
UnknownRepositoryException

hasWriteAccess

public boolean hasWriteAccess(String repository)
                       throws UnknownRepositoryException
Checks whether the user that has logged in has write access on the specified repository. If no user has been logged in, this method will only return true if the repository is world-writeable.

Parameters:
repository - A repository ID.
Returns:
true if the user has write access, false otherwise.
Throws:
UnknownRepositoryException

getTmpDir

public File getTmpDir()
               throws IOException
Throws:
IOException

createTmpFile

public File createTmpFile(String prefix,
                          String suffix)
                   throws IOException
Creates a new file with the supplied prefix and suffix in the configured tmp directory.

Parameters:
prefix - The prefix string to be used in generating the file's name; must be at least three characters long.
suffix - The suffix string to be used in generating the file's name; may be null, in which case the suffix ".tmp" will be used
Returns:
A new tmp file, or null if no tmp directory has been configured.
Throws:
IOException - If an I/O error occured during the creation of the tmp file.


Copyright © 2002-2006 Aduna BV, GNU LGPL License applies.