Package com.complexible.stardog.api

# Interface Exporter

public interface Exporter

API for exporting RDF data in bulk from the server. By default this will export the entire database in TriG format, but specific contexts for export can be provided as well as where and how the export is done.

Care should be taken when constructing an export action. You can export the contents of a single named graph in a format that does not support contexts, such as Turtle, but you cannot export multiple named graphs, or similarly a database which has one or more named graphs, to Turtle or any other format which does not support named graphs.

Since:
  2.1.2
Version:
  6.0
Author:
  Michael Grove

- ## Field Summary

  Fields
  Modifier and Type
  Field
  Description
  `static final File`
  `DEFAULT_OBFUSCATION`

- ## Method Summary

  Modifier and Type
  Method
  Description
  `Exporter`
  `context(Resource theNG, Resource... theOtherNamedGraphs)`
  Specify which contexts should be exported.
  `Exporter`
  `context(Collection<Resource> theNamedGraphs)`
  Specify which contexts should be exported.
  `Exporter`
  `format(RDFFormat theFormat)`
  Specify the RDF format the export should use.
  `Exporter`
  `obfuscated(File theObfuscationConfig)`
  Export the RDF using the specified obfuscation configuration, or `DEFAULT_OBFUSCATION` to use the default configuration.
  `void`
  `to(OutputStream theOutput)`
  Export the data back to the client and write it to the provided output.
  `String`
  `toServer()`
  Export the RDF to a file on the server.

- ## Field Details

  - ### DEFAULT_OBFUSCATION

    static final File DEFAULT_OBFUSCATION

- ## Method Details

  - ### context

    Exporter context(Resource theNG, Resource... theOtherNamedGraphs)
    Specify which contexts should be exported.
    Parameters:
      `theNG` - the context to export
      `theOtherNamedGraphs` - other contexts to export
    Returns:
      this exporter

  - ### context

    Exporter context(Collection<Resource> theNamedGraphs)
    Specify which contexts should be exported. If an empty list is provided, `Contexts.LOCAL` will be assumed.
    Parameters:
      `theNamedGraphs` - the named graphs to export
    Returns:
      this exporter

  - ### format

    Exporter format(RDFFormat theFormat)
    Specify the RDF format the export should use. When no format is specified, TriG will be used
    Parameters:
      `theFormat` - the format
    Returns:
      this exporter

  - ### obfuscated

    Exporter obfuscated(File theObfuscationConfig)
    Export the RDF using the specified obfuscation configuration, or `DEFAULT_OBFUSCATION` to use the default configuration. When a file other than the `default` is used, it must exist on the client.
    Parameters:
      `theObfuscationConfig` - the file to the configuration
    Returns:
      this exporter

  - ### toServer

    String toServer() throws StardogException
    Export the RDF to a file on the server. Server side exports are saved to the `export.dir` as specified in the Stardog configuration file. This defaults to the `.exports` directory in `$STARDOG_HOME`. The name of exported file is `$DB_NAME-$DATE` with an optional numeric postfix, such as .1, if there are multiple exports of a database in the same day.
    Returns:
      the informational output from the server
    Throws:
      `StardogException` - if an error occurred while performing the export
      `IllegalArgumentException` - if the file does not exist, cannot be written to, etc.
      `IllegalStateException` - if a `format` is `specified` which does not support contexts and named graphs have been `specified` for the export or the entire database is to be exported and it contains one or more named graphs.

  - ### to

    void to(OutputStream theOutput) throws StardogException

    Export the data back to the client and write it to the provided output.

    The `OutputStream` provided to this method will be closed once the export is complete. If you are using a stream that you do not want closed, such as `System.out`, you can wrap the stream with `UncloseableOutputStream`.

    Parameters:
      `theOutput` - the stream to send the export to
    Throws:
      `StardogException` - if an error occurred while performing the export
      `IllegalStateException` - if a `format` is `specified` which does not support contexts and named graphs have been `specified` for the export or the entire database is to be exported and it contains one or more named graphs.