Class AbstractAdminConnection
- java.lang.Object
-
- com.complexible.stardog.api.admin.AbstractAdminConnection
-
- All Implemented Interfaces:
AdminConnection
,java.lang.AutoCloseable
- Direct Known Subclasses:
KernelAdminConnection
public abstract class AbstractAdminConnection extends java.lang.Object implements AdminConnection
- Since:
- 5.0
- Version:
- 5.0
- Author:
- Michael Grove
-
-
Field Summary
-
Fields inherited from interface com.complexible.stardog.api.admin.AdminConnection
NO_TIMEOUT
-
-
Constructor Summary
Constructors Constructor Description AbstractAdminConnection(Views<AdminConnection> theViews)
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected abstract void
_close()
protected abstract Metadata
_get(java.lang.String theName, java.lang.Iterable<? extends MetaProperty<?>> theOptions)
protected abstract <T> java.lang.String
_set(java.lang.String theName, MetaProperty<T> theOption, T theValue)
<T extends AdminConnection>
Tas(java.lang.Class<T> theView)
Return this admin connection viewed as a different type of admin connection.protected void
assertOpen()
Assert that the client is currently logged into the Stardog serverprotected void
assertValidName(java.lang.String theName)
DatabaseBuilder
builder(Metadata theOptions)
Convenience method to create a database builder with the given options.void
close()
Log out of the Stardog server and close the client.DatabaseBuilder
disk(java.lang.String theName)
Create a new builder for creating disk databases<T> T
get(java.lang.String theName, MetaProperty<T> theOption)
Gets the value of the specified option in the given database.Metadata
get(java.lang.String theName, java.lang.Iterable<? extends MetaProperty<?>> theOptions)
Gets the values of the specified options in the given database.boolean
isOpen()
Return whether or not this connection is open.DatabaseBuilder
newDatabase(java.lang.String theName)
Create a builder for creating a new database.protected abstract DatabaseBuilder
newDatabaseBuilder()
java.lang.String
offline(java.lang.String theName)
Makes the database offline according to the default strategy and default timeout.<T> java.lang.String
set(java.lang.String theName, MetaProperty<T> theOption, T theValue)
Sets the value of the specified option for the database with the given name.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface com.complexible.stardog.api.admin.AdminConnection
backup, backup, backup, backup, backupAll, backupAll, backupAll, changeEncryptionPassword, checkpoint, createNewEncryptionKey, currentStatus, currentStatus, disableEncryption, drop, fileKeyList, generateDiagnosticReport, getPermissionManager, getProcessManager, getProperty, getQueryManager, getRoleManager, getStoredFunctions, getStoredQueries, getTokenManager, getUserManager, list, offline, online, optimize, optimize, removeEncryptionPassword, repair, restore, restore, setEncryptionPassword, setProperty, shutdown, verify
-
-
-
-
Constructor Detail
-
AbstractAdminConnection
public AbstractAdminConnection(Views<AdminConnection> theViews)
-
-
Method Detail
-
_close
protected abstract void _close()
-
newDatabaseBuilder
protected abstract DatabaseBuilder newDatabaseBuilder()
-
_set
protected abstract <T> java.lang.String _set(java.lang.String theName, MetaProperty<T> theOption, T theValue) throws StardogException
- Throws:
StardogException
-
_get
protected abstract Metadata _get(java.lang.String theName, java.lang.Iterable<? extends MetaProperty<?>> theOptions) throws StardogException
- Throws:
StardogException
-
disk
public DatabaseBuilder disk(java.lang.String theName) throws StardogException
Create a new builder for creating disk databases- Specified by:
disk
in interfaceAdminConnection
- Parameters:
theName
- the name of the disk database to create- Returns:
- a builder for a disk database
- Throws:
StardogException
- if the name of the database is invalid
-
builder
public DatabaseBuilder builder(Metadata theOptions) throws StardogException
Convenience method to create a database builder with the given options. The provided options should include at least two options: the name of the database and the index type.- Specified by:
builder
in interfaceAdminConnection
- Returns:
- a builder for a database
- Throws:
StardogException
- if there was an error while creating the db
-
close
public final void close()
Log out of the Stardog server and close the client.- Specified by:
close
in interfaceAdminConnection
- Specified by:
close
in interfacejava.lang.AutoCloseable
-
as
public final <T extends AdminConnection> T as(java.lang.Class<T> theView) throws StardogException
Return this admin connection viewed as a different type of admin connection.- Specified by:
as
in interfaceAdminConnection
- Type Parameters:
T
- the connection view to return- Parameters:
theView
- the type of connection to view this object as- Returns:
- the new view of the connection.
- Throws:
StardogException
- if the connection cannot be viewed as the provided type. This could be from the parent connection having been closed or it does not support the provided view.
-
isOpen
public final boolean isOpen()
Return whether or not this connection is open.- Specified by:
isOpen
in interfaceAdminConnection
- Returns:
- true if it is open, false otherwise
-
newDatabase
public final DatabaseBuilder newDatabase(java.lang.String theName) throws StardogException
Create a builder for creating a new database.- Specified by:
newDatabase
in interfaceAdminConnection
- Parameters:
theName
- the name of the database to create- Returns:
- a builder for a database
- Throws:
StardogException
- if the name of the database is invalid
-
get
public <T> T get(java.lang.String theName, MetaProperty<T> theOption) throws StardogException
Gets the value of the specified option in the given database. The function will returnnull
if the option is NOT aknown Stardog options
, or if it is NOTreadable
. The function may also returnnull
if the option is set tonull
value for the database. To differentiate these cases,AdminConnection.get(String, Iterable)
function can be used instead. This function will throw an exception if the user does not have read access to the database metadata.- Specified by:
get
in interfaceAdminConnection
- Type Parameters:
T
- type of the option value- Parameters:
theName
- name of the databasetheOption
- the option to get- Returns:
- current value of the option in the database or
null
as explained above - Throws:
StardogException
- if there was an error while getting the value
-
get
public final Metadata get(java.lang.String theName, java.lang.Iterable<? extends MetaProperty<?>> theOptions) throws StardogException
Gets the values of the specified options in the given database. The returned map is not guaranteed tocontain
all the specified options. Only the values forknown Stardog options
that are should bereadable
will be contained in the result. This function will throw an exception if the user does not have read access to the database metadata.- Specified by:
get
in interfaceAdminConnection
- Parameters:
theName
- database nametheOptions
- options for which values will be retrieved- Returns:
- metadata that contains values for the specified met properties
- Throws:
StardogException
- if an error occurs while retrieving option values
-
set
public final <T> java.lang.String set(java.lang.String theName, MetaProperty<T> theOption, T theValue) throws StardogException
Sets the value of the specified option for the database with the given name. For this function to complete without an exception, the logged in user should have write access to the database metadata for the specified database, the option should be aknown Stardog option
, the provided value should bevalid
, and either the option should bewritable online
or it should bewritable
and the database should NOT beonline
.- Specified by:
set
in interfaceAdminConnection
- Type Parameters:
T
- type of the option value- Parameters:
theName
- name of the databasetheOption
- option to settheValue
- option value- Throws:
StardogException
- if an error occurs trying to set the option value
-
offline
public java.lang.String offline(java.lang.String theName) throws StardogException
Makes the database offline according to the default strategy and default timeout. Offline databases cannot be queried or updated and will be inaccessible to users.- Specified by:
offline
in interfaceAdminConnection
- Returns:
- the server output of offline
- Throws:
StardogException
-
assertOpen
protected void assertOpen()
Assert that the client is currently logged into the Stardog server- Throws:
java.lang.IllegalStateException
- if the client is not connected
-
assertValidName
protected void assertValidName(java.lang.String theName) throws StardogException
- Throws:
StardogException
-
-