Package de.julielab.concepts.db.core
Class DataExporterImpl
- java.lang.Object
-
- de.julielab.concepts.db.core.DataExporterImpl
-
- All Implemented Interfaces:
DatabaseConnected,DataExporter,de.julielab.jssf.commons.spi.ExtensionPoint,de.julielab.jssf.commons.spi.ParameterExposing
- Direct Known Subclasses:
CypherBoltExporter,CypherFileDBExporter,CypherHttpExporter
public abstract class DataExporterImpl extends Object implements DataExporter
-
-
Constructor Summary
Constructors Constructor Description DataExporterImpl(org.slf4j.Logger log)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected InputStreamdecode(InputStream inputData, org.apache.commons.configuration2.HierarchicalConfiguration<org.apache.commons.configuration2.tree.ImmutableNode> decodingConfig)Decodes data that has been encoded into a string.protected StringgetResourceHeader(org.apache.commons.configuration2.HierarchicalConfiguration<org.apache.commons.configuration2.tree.ImmutableNode> connectionConfiguration)Creates a small header to be applied to exported resource files.protected voidwriteData(File outputFile, String resourceHeader, InputStream decodedResponse)-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface de.julielab.concepts.db.core.spi.DatabaseConnected
setConnection
-
Methods inherited from interface de.julielab.concepts.db.core.spi.DataExporter
exportData
-
-
-
-
Method Detail
-
getResourceHeader
protected String getResourceHeader(org.apache.commons.configuration2.HierarchicalConfiguration<org.apache.commons.configuration2.tree.ImmutableNode> connectionConfiguration) throws VersionRetrievalException, IOException
Creates a small header to be applied to exported resource files. The header contains the database and Concept Manager application versions. Thus should help to avoid confusion about versioning of resources. The lines are prepended with the '#' character. Thus, reading applications should accept this character as a comment indicator.- Parameters:
connectionConfiguration- Connection configuration to retrieve the database version.- Returns:
- A string representing the header.
- Throws:
VersionRetrievalException- If the database version cannot be retrieved.IOException- If the application version cannot be read (it is stored in a auto-generated file).
-
decode
protected InputStream decode(InputStream inputData, org.apache.commons.configuration2.HierarchicalConfiguration<org.apache.commons.configuration2.tree.ImmutableNode> decodingConfig) throws IOException
Decodes data that has been encoded into a string. The decodingConfig determines which decodings are applied in which order. The following decodings are available:- base64
- Base64 is an algorithm to encode arbitrary byte sequences into strings.
- gzip
- If the data contains a byte array that has been compressed with GZIP and then encoded into a string using base64, this decoding decompresses the byte array. Requires the base64 encoding to be applied before.
- json2bytearray
- While less performant than using base64, a byte array may also be encoded as a JSON array carrying the byte values.
- Parameters:
inputData-decodingConfig-- Returns:
- Throws:
IOException
-
writeData
protected void writeData(File outputFile, String resourceHeader, InputStream decodedResponse) throws IOException
- Throws:
IOException
-
-