Interface ServerConnection
- All Superinterfaces:
- java.lang.AutoCloseable
public interface ServerConnection
extends java.lang.AutoCloseable
Encapsulates a connection to an RDFox server. All instances of this
 class are single-threaded — that is, no method should be called simultaneously on several threads. However, please note that there is
 no thread affinity — that is, methods on one connection can be called from different threads as long as the calls are serialised
 externally. externally. The 
interrupt(), duplicate(), and checkPassword(String password) methods are exceptions:
 they can be invoked in parallel with any other method apart from close(). Calling close() in parallel with any other
 method will almost certainly crash the JVM. Multiple connections should be used to access a server concurrently, in which case all access
 to the server is serialised. A connection must be closed after use to release the resources associated with it.- 
Field SummaryFields Modifier and Type Field Description static byteACCESS_TYPE_GRANTA flag specifying grant access to a resource.static byteACCESS_TYPE_NONEA flag specifying no access to a resource.static byteACCESS_TYPE_READA flag specifying read access to a resource.static byteACCESS_TYPE_STARA flag specifying all access types to a resource.static byteACCESS_TYPE_WRITEA flag specifying write access to a resource.
- 
Method SummaryModifier and Type Method Description voidchangeRolePassword(java.lang.String currentPassword, java.lang.String newPassword)Creates the password of the role that is associated with this connection.voidcheckPassword(java.lang.String password)Checks whether the supplied password is valid for the role associated with this connection.voidclose()Closes the data store connection by freeing all resources associated with it.booleancontainsDataStore(java.lang.String dataStoreName)Returnstrueif the connected server contains a data store with the given name.voidcreateDataStore(java.lang.String dataStoreName, java.util.Map<java.lang.String,java.lang.String> dataStoreParameters)Creates a data store with the given name.voidcreateRole(java.lang.String roleName, java.lang.String password)Creates a new role with the given name and password.voidcreateRole(java.lang.String roleName, java.lang.String passwordOrHash, boolean isHash)Creates a new role with the given name and password.voiddeleteDataStore(java.lang.String dataStoreName)Deletes a data store with the given name from the server.voiddeleteDataStore(java.lang.String dataStoreName, java.lang.String expectedDataStoreUniqueID, long expectedDataStoreVersion)Deletes a data store with the given name from the server if the data store's unique ID and version match the expected values.voiddeleteRole(java.lang.String roleName)Deletes a role with the given name.ServerConnectionduplicate()Creates a new connection to the same data store.ComponentInfogetComponentInfo(boolean extended)Returns diagnostic information about the server as a tree of objects each providing detailed information about the server.java.lang.StringgetGitSHA()Returns the string containing the Git SHA identifying the precise version of the RDFox instance code.intgetNumberOfThreads()Returns the number of threads that the server uses for various tasks such as reasoning and data importation.java.util.Map<java.lang.String,java.lang.String>getParameters()Returns the parameters that the server was created with.java.lang.StringgetRoleName()Returns the name of the role currently associated with this connection.java.lang.StringgetRolePasswordHash(java.lang.String roleName)Returns the password hash for the given role name.java.lang.StringgetVersion()Returns the version string of the RDFox instance.voidgrantPrivileges(java.lang.String roleName, java.lang.String resourceSpecifier, byte accessTypesToGrant)Grants privileges over a resource specifier to a role.voidgrantRole(java.lang.String roleName, java.lang.String superRoleName)Grants the membership of a role in another role.voidinterrupt()Tries to interrupt an operation that is running in parallel on this connection.booleanisMemberOf(java.lang.String roleName, java.lang.String superRoleName)Checks whether the given role is a member of another super-role.java.util.List<java.lang.String>listDataStores()Returns the list of names of data stores available at the connected server.java.util.Map<java.lang.String,java.lang.Byte>listPrivileges(java.lang.String roleName)Lists the privileges of a given role.java.util.List<java.lang.String>listRoleMembers(java.lang.String roleName)Lists the roles that are members of the given role.java.util.List<java.lang.String>listRoleMemberships(java.lang.String roleName)Lists the roles that the given role is a member of.java.util.List<java.lang.String>listRoles()Returns the list of all roles available at the server.voidloadDataStoreFromBinaryFormat(java.lang.String dataStoreName, java.io.File file)Loads a data store with the given name from a file containing the store saved in the standard or raw format.voidloadDataStoreFromBinaryFormat(java.lang.String dataStoreName, java.io.File file, java.util.Map<java.lang.String,java.lang.String> dataStoreParameters)Loads a data store with the given name from a file containing the store saved in the standard or raw format.voidloadDataStoreFromBinaryFormat(java.lang.String dataStoreName, java.io.InputStream inputStream)Loads a data store with the given name from an input stream containing the store saved in the standard or raw format.voidloadDataStoreFromBinaryFormat(java.lang.String dataStoreName, java.io.InputStream inputStream, java.util.Map<java.lang.String,java.lang.String> dataStoreParameters)Loads a data store with the given name from an input stream containing the store saved in the standard or raw format.DataStoreConnectionnewDataStoreConnection(java.lang.String dataStoreName)Creates a connection to the data store of this server with the given name.voidrevokePrivileges(java.lang.String roleName, java.lang.String resourceSpecifier, byte accessTypesToRevoke)Revokes privileges over a resource specifier from a role.voidrevokeRole(java.lang.String roleName, java.lang.String superRoleName)Revokes the membership of a role in another role.voidsaveDataStoreToBinaryFormat(java.lang.String dataStoreName, java.io.File file, BinaryDataStoreFormat format)Saves a data store into the specified binary format.voidsaveDataStoreToBinaryFormat(java.lang.String dataStoreName, java.io.OutputStream outputStream, BinaryDataStoreFormat format)Saves a data store into the specified binary format.voidsaveDataStoreToBinaryFormat(java.lang.String dataStoreName, java.lang.String expectedDataStoreUniqueID, long expectedDataStoreVersion, java.io.File file, BinaryDataStoreFormat format)Saves a data store into the specified binary format if the data store's unique ID and version match the expected values.voidsaveDataStoreToBinaryFormat(java.lang.String dataStoreName, java.lang.String expectedDataStoreUniqueID, long expectedDataStoreVersion, java.io.OutputStream outputStream, BinaryDataStoreFormat format)Saves a data store into the specified binary format if the data store's unique ID and version match the expected values.voidsetNumberOfThreads(int numberOfThreads)Sets the number of threads that the server should use for various tasks such as reasoning and data importation.
- 
Field Details- 
ACCESS_TYPE_NONEstatic final byte ACCESS_TYPE_NONEA flag specifying no access to a resource.- See Also:
- Constant Field Values
 
- 
ACCESS_TYPE_READstatic final byte ACCESS_TYPE_READA flag specifying read access to a resource.- See Also:
- Constant Field Values
 
- 
ACCESS_TYPE_WRITEstatic final byte ACCESS_TYPE_WRITEA flag specifying write access to a resource.- See Also:
- Constant Field Values
 
- 
ACCESS_TYPE_GRANTstatic final byte ACCESS_TYPE_GRANTA flag specifying grant access to a resource.- See Also:
- Constant Field Values
 
- 
ACCESS_TYPE_STARstatic final byte ACCESS_TYPE_STARA flag specifying all access types to a resource.- See Also:
- Constant Field Values
 
 
- 
- 
Method Details- 
closevoid close()Closes the data store connection by freeing all resources associated with it. Once a connection is closed, it cannot be used any further. Calling this method in parallel with any other method runs a very high risk of crashing the JVM.- Specified by:
- closein interface- java.lang.AutoCloseable
 
- 
duplicateCreates a new connection to the same data store. The new connection inherits the role name from this one. The main use of this method is to avoid having to specify the role credentials again.- Returns:
- a new connection to the same server
- Throws:
- JRDFoxException- thrown if an error is encountered
 
- 
interruptTries to interrupt an operation that is running in parallel on this connection. RDFox will make a best effort to interrupt an operation, but there are no guarantees that the operation will indeed be interrupted. An operation will throw anOperationInterruptedExceptionexception. This method can be called concurrently with any other method apart fromclose().- Throws:
- JRDFoxException- thrown if an error is encountered
 
- 
getRoleNameReturns the name of the role currently associated with this connection.- Returns:
- the name of the role currently associated with this connection
- Throws:
- JRDFoxException- thrown if there is an error
 
- 
checkPasswordChecks whether the supplied password is valid for the role associated with this connection. On failure, an exception is thrown and the connection remains valid.- Parameters:
- password- the password of the new user
- Throws:
- JRDFoxException- thrown if there is an error
 
- 
getParametersReturns the parameters that the server was created with.- Returns:
- the parameters of the server
- Throws:
- JRDFoxException- thrown if an error is encountered
 
- 
getVersionReturns the version string of the RDFox instance.- Returns:
- the version string of the RDFox instance
- Throws:
- JRDFoxException- thrown if an error is encountered
 
- 
getGitSHAReturns the string containing the Git SHA identifying the precise version of the RDFox instance code.- Returns:
- the Git SHA string of the RDFox instance
- Throws:
- JRDFoxException- thrown if an error is encountered
 
- 
getNumberOfThreadsReturns the number of threads that the server uses for various tasks such as reasoning and data importation.- Returns:
- the number of threads used by the server
- Throws:
- JRDFoxException- thrown if an error is encountered
 
- 
setNumberOfThreadsSets the number of threads that the server should use for various tasks such as reasoning and data importation. This operation can be invoked only if no transaction is active.- Parameters:
- numberOfThreads- the number of threads that the server should use
- Throws:
- JRDFoxException- thrown if an error is encountered
 
- 
getComponentInfoReturns diagnostic information about the server as a tree of objects each providing detailed information about the server. Note: This information should be used for diagnostics purposes only. The content ofComponentInfois subject to change in future version. Callers should not rely on named property or a specific subcomponent being present.- Parameters:
- extended- if- true, the information about all data stores will be returned as well
- Returns:
- information about the server
- Throws:
- JRDFoxException- thrown if an error is encountered
 
- 
listDataStoresReturns the list of names of data stores available at the connected server.- Returns:
- the list of names of data stores available at the server
- Throws:
- JRDFoxException- thrown if an error is encountered
 
- 
containsDataStoreReturnstrueif the connected server contains a data store with the given name.- Parameters:
- dataStoreName- the name of a data store
- Returns:
- trueif the server contains a data store with the name- dataStoreName
- Throws:
- JRDFoxException- thrown if an error is encountered
 
- 
createDataStorevoid createDataStore(java.lang.String dataStoreName, java.util.Map<java.lang.String,java.lang.String> dataStoreParameters) throws JRDFoxExceptionCreates a data store with the given name. The remaining parameters specify the data store type, as well as various data store parameters. The server should not contain a data store with the specified name.- Parameters:
- dataStoreName- the name of the newly created data store
- dataStoreParameters- the key-value pairs determining various data store parameters (see Data Store Parameters)
- Throws:
- JRDFoxException- thrown if an error is encountered (e.g., if the server already contains a data store with the given name, or if some of the parameters are incorrect)
 
- 
loadDataStoreFromBinaryFormatvoid loadDataStoreFromBinaryFormat(java.lang.String dataStoreName, java.io.InputStream inputStream) throws JRDFoxExceptionLoads a data store with the given name from an input stream containing the store saved in the standard or raw format. The loaded data store will be initialised using the parameters found in the input stream. The server should not contain a data store with the specified name.- Parameters:
- dataStoreName- the name of the newly created data store
- inputStream- contains the data store encoded using the standard or the raw format
- Throws:
- JRDFoxException- thrown if an error is encountered (e.g., if the server already contains a data store with the given name, or if the format is incorrect)
 
- 
loadDataStoreFromBinaryFormatvoid loadDataStoreFromBinaryFormat(java.lang.String dataStoreName, java.io.File file) throws JRDFoxExceptionLoads a data store with the given name from a file containing the store saved in the standard or raw format. The loaded data store will be initialised using the parameters found in the file. The server should not contain a data store with the specified name.- Parameters:
- dataStoreName- the name of the newly created data store
- file- contains the data store encoded using the standard or the raw format
- Throws:
- JRDFoxException- thrown if an error is encountered (e.g., if the server already contains a data store with the given name, or if the format is incorrect)
 
- 
loadDataStoreFromBinaryFormatvoid loadDataStoreFromBinaryFormat(java.lang.String dataStoreName, java.io.InputStream inputStream, java.util.Map<java.lang.String,java.lang.String> dataStoreParameters) throws JRDFoxExceptionLoads a data store with the given name from an input stream containing the store saved in the standard or raw format. The loaded data store will be initialised using the specified parameters, which are the same as in thecreateDataStore(java.lang.String, java.util.Map<java.lang.String, java.lang.String>)method. Please note that, if the input contains a data store in the raw format, the parameters must be exactly the same as in the input. In contrast, if the input contains a data store in the standard format, most parameters (apart from the equality mode) can be overridden; hence, this method can be used to transfer the data from one data store to another. The server should not contain a data store with the specified name.- Parameters:
- dataStoreName- the name of the newly created data store
- inputStream- contains the data store encoded using the standard or the raw format
- dataStoreParameters- the key-value pairs determining various data store parameters (see Data Store Parameters)
- Throws:
- JRDFoxException- thrown if an error is encountered (e.g., if the server already contains a data store with the given name, or if the file format is incorrect)
 
- 
loadDataStoreFromBinaryFormatvoid loadDataStoreFromBinaryFormat(java.lang.String dataStoreName, java.io.File file, java.util.Map<java.lang.String,java.lang.String> dataStoreParameters) throws JRDFoxExceptionLoads a data store with the given name from a file containing the store saved in the standard or raw format. The loaded data store will be initialised using the specified parameters, which are the same as in thecreateDataStore(java.lang.String, java.util.Map<java.lang.String, java.lang.String>)method. Please note that, if the input contains a data store in the raw format, the parameters must be exactly the same as in the input. In contrast, if the input contains a data store in the standard format, most parameters (apart from the equality mode) can be overridden; hence, this method can be used to transfer the data from one data store to another. The server should not contain a data store with the specified name.- Parameters:
- dataStoreName- the name of the newly created data store
- file- contains the data store encoded using the standard or the raw format
- dataStoreParameters- the key-value pairs determining various data store parameters (see Data Store Parameters)
- Throws:
- JRDFoxException- thrown if an error is encountered (e.g., if the server already contains a data store with the given name, or if the file format is incorrect)
 
- 
saveDataStoreToBinaryFormatvoid saveDataStoreToBinaryFormat(java.lang.String dataStoreName, java.io.OutputStream outputStream, BinaryDataStoreFormat format) throws JRDFoxExceptionSaves a data store into the specified binary format. This operation can be invoked only if no transaction is active.- Parameters:
- dataStoreName- the name of the data store to save
- outputStream- receives the binary content of the data store
- format- specifies the format in which the store is saved
- Throws:
- JRDFoxException- thrown if an error is encountered
 
- 
saveDataStoreToBinaryFormatvoid saveDataStoreToBinaryFormat(java.lang.String dataStoreName, java.lang.String expectedDataStoreUniqueID, long expectedDataStoreVersion, java.io.OutputStream outputStream, BinaryDataStoreFormat format) throws JRDFoxExceptionSaves a data store into the specified binary format if the data store's unique ID and version match the expected values. This operation can be invoked only if no transaction is active.- Parameters:
- dataStoreName- the name of the data store to save
- expectedDataStoreUniqueID- the expected unique ID of the data store
- expectedDataStoreVersion- the expected version of the data store
- outputStream- receives the binary content of the data store
- format- specifies the format in which the store is saved
- Throws:
- JRDFoxException- thrown if an error is encountered
 
- 
saveDataStoreToBinaryFormatvoid saveDataStoreToBinaryFormat(java.lang.String dataStoreName, java.io.File file, BinaryDataStoreFormat format) throws JRDFoxExceptionSaves a data store into the specified binary format. This operation can be invoked only if no transaction is active.- Parameters:
- dataStoreName- the name of the data store to save
- file- receives the binary content of the data store
- format- specifies the format in which the store is saved
- Throws:
- JRDFoxException- thrown if an error is encountered
 
- 
saveDataStoreToBinaryFormatvoid saveDataStoreToBinaryFormat(java.lang.String dataStoreName, java.lang.String expectedDataStoreUniqueID, long expectedDataStoreVersion, java.io.File file, BinaryDataStoreFormat format) throws JRDFoxExceptionSaves a data store into the specified binary format if the data store's unique ID and version match the expected values. This operation can be invoked only if no transaction is active.- Parameters:
- dataStoreName- the name of the data store to save
- expectedDataStoreUniqueID- the expected unique ID of the data store
- expectedDataStoreVersion- the expected version of the data store
- file- receives the binary content of the data store
- format- specifies the format in which the store is saved
- Throws:
- JRDFoxException- thrown if an error is encountered
 
- 
deleteDataStoreDeletes a data store with the given name from the server. A data store can be deleted only if no connections are open to it.- Parameters:
- dataStoreName- the name of the data store to delete
- Throws:
- JRDFoxException- thrown if an error is encountered (e.g., if the server does not contain a data store with the given name)
 
- 
deleteDataStorevoid deleteDataStore(java.lang.String dataStoreName, java.lang.String expectedDataStoreUniqueID, long expectedDataStoreVersion) throws JRDFoxExceptionDeletes a data store with the given name from the server if the data store's unique ID and version match the expected values. A data store can be deleted only if no connections are open to it.- Parameters:
- dataStoreName- the name of the data store to delete
- expectedDataStoreUniqueID- the expected unique ID of the data store
- expectedDataStoreVersion- the expected version of the data store
- Throws:
- JRDFoxException- thrown if an error is encountered (e.g., if the server does not contain a data store with the given name)
 
- 
newDataStoreConnectionCreates a connection to the data store of this server with the given name. The new data store connection uses the same credentials as this server connection.- Parameters:
- dataStoreName- the name of the data store to connect to
- Returns:
- a connection to the specified data store
- Throws:
- JRDFoxException- thrown if an error is encountered (e.g., if the server does not contain a data store with the given name)
 
- 
listRolesReturns the list of all roles available at the server.- Returns:
- the list of all roles available at the server.
- Throws:
- JRDFoxException- thrown if there is an error
 
- 
createRoleCreates a new role with the given name and password.- Parameters:
- roleName- the new role name
- password- the password of the new role
- Throws:
- JRDFoxException- thrown if there is an error
 
- 
createRolevoid createRole(java.lang.String roleName, java.lang.String passwordOrHash, boolean isHash) throws JRDFoxExceptionCreates a new role with the given name and password.- Parameters:
- roleName- the new role name
- passwordOrHash- the password or its hash of the new role
- isHash- if- true, then- passwordOrHashis interpreted as the hash of the password; otherwise,- passwordOrHashis interpreted as the verbatim password
- Throws:
- JRDFoxException- thrown if there is an error
 
- 
deleteRoleDeletes a role with the given name.- Parameters:
- roleName- the name of the role to delete
- Throws:
- JRDFoxException- thrown if there is an error
 
- 
changeRolePasswordvoid changeRolePassword(java.lang.String currentPassword, java.lang.String newPassword) throws JRDFoxExceptionCreates the password of the role that is associated with this connection. The change is performed only if the current password matches.- Parameters:
- currentPassword- the current password of the role associated with this connection
- newPassword- the new password for the role associated with this connection
- Throws:
- JRDFoxException- thrown if there is an error
 
- 
getRolePasswordHashReturns the password hash for the given role name.- Parameters:
- roleName- the name of the role for which the password hash should be returned
- Returns:
- the password hash
- Throws:
- JRDFoxException- thrown if there is an error
 
- 
listRoleMembershipsjava.util.List<java.lang.String> listRoleMemberships(java.lang.String roleName) throws JRDFoxExceptionLists the roles that the given role is a member of.- Parameters:
- roleName- the name of the role for which the memberships should be returned
- Returns:
- the list of roles that the given role is a member of
- Throws:
- JRDFoxException- thrown if there is an error
 
- 
listRoleMembersLists the roles that are members of the given role.- Parameters:
- roleName- the name of the role for which the members should be returned
- Returns:
- the list of roles that are members of the given role
- Throws:
- JRDFoxException- thrown if there is an error
 
- 
isMemberOfboolean isMemberOf(java.lang.String roleName, java.lang.String superRoleName) throws JRDFoxExceptionChecks whether the given role is a member of another super-role.- Parameters:
- roleName- the name of the role for which the check is performed
- superRoleName- the name of the potential super-role for which the check is performed
- Returns:
- trueif the given role is a member of another super-role.
- Throws:
- JRDFoxException- thrown if there is an error
 
- 
grantRoleGrants the membership of a role in another role.- Parameters:
- roleName- the name of the role that is to be made member of- superRoleName
- superRoleName- the name of the role that should get- roleNameas member
- Throws:
- JRDFoxException- thrown if there is an error
 
- 
revokeRoleRevokes the membership of a role in another role.- Parameters:
- roleName- the name of the role that should stop being member of- superRoleName
- superRoleName- the name of the role that for which- roleNameshould stop being a member
- Throws:
- JRDFoxException- thrown if there is an error
 
- 
listPrivilegesjava.util.Map<java.lang.String,java.lang.Byte> listPrivileges(java.lang.String roleName) throws JRDFoxExceptionLists the privileges of a given role. The result is a map of resource specifiers to the access types that the role currently has.- Parameters:
- roleName- the name of the role whose privileges are being listed
- Returns:
- the map of resource specifiers to the access types (specified as a bit-mask of ACCESS_TYPE_*values)
- Throws:
- JRDFoxException- thrown if there is an error
 
- 
grantPrivilegesvoid grantPrivileges(java.lang.String roleName, java.lang.String resourceSpecifier, byte accessTypesToGrant) throws JRDFoxExceptionGrants privileges over a resource specifier to a role.- Parameters:
- roleName- the name of the role to which the privileges are being granted
- resourceSpecifier- identifies a resource to which the privileges are being granted
- accessTypesToGrant- the access types (specified as a bit-mask of- ACCESS_TYPE_*values) that are to be granted
- Throws:
- JRDFoxException- thrown if there is an error
 
- 
revokePrivilegesvoid revokePrivileges(java.lang.String roleName, java.lang.String resourceSpecifier, byte accessTypesToRevoke) throws JRDFoxExceptionRevokes privileges over a resource specifier from a role.- Parameters:
- roleName- the name of the role to which the privileges are being granted
- resourceSpecifier- identifies a resource to which the privileges are being granted
- accessTypesToRevoke- the access types (specified as a bit-mask of- ACCESS_TYPE_*values) that are to be revoked
- Throws:
- JRDFoxException- thrown if there is an error
 
 
-