Class 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
    • Constructor Detail

    • Method Detail

      • _close

        protected abstract void _close()
      • newDatabaseBuilder

        protected abstract DatabaseBuilder newDatabaseBuilder()
      • disk

        public DatabaseBuilder disk​(java.lang.String theName)
                             throws StardogException
        Create a new builder for creating disk databases
        Specified by:
        disk in interface AdminConnection
        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 interface AdminConnection
        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 interface AdminConnection
        Specified by:
        close in interface java.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 interface AdminConnection
        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 interface AdminConnection
        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 interface AdminConnection
        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 return null if the option is NOT a known Stardog options, or if it is NOT readable. The function may also return null if the option is set to null 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 interface AdminConnection
        Type Parameters:
        T - type of the option value
        Parameters:
        theName - name of the database
        theOption - 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 to contain all the specified options. Only the values for known Stardog options that are should be readable 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 interface AdminConnection
        Parameters:
        theName - database name
        theOptions - 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 a known Stardog option, the provided value should be valid, and either the option should be writable online or it should be writable and the database should NOT be online.
        Specified by:
        set in interface AdminConnection
        Type Parameters:
        T - type of the option value
        Parameters:
        theName - name of the database
        theOption - option to set
        theValue - 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 interface AdminConnection
        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