public class DataTransporter extends Object
Modifier and Type | Field and Description |
---|---|
static String |
DOT |
static String |
GZ |
static String |
JCR_ROOT |
static String |
PROPERTIES |
static String |
SLASH |
static String |
UTF8 |
static String |
XML |
static String |
ZIP |
Constructor and Description |
---|
DataTransporter() |
Modifier and Type | Method and Description |
---|---|
static String |
createExportPath(String path)
Prior to 4.5 Magnolia used to produce export xml filenames where the / (slash) separating sub nodes was replaced by a dot.
|
static String |
decodePath(String path,
String enc)
decode a path (ex.
|
static String |
encodePath(String path,
String separator,
String enc) |
static void |
executeBootstrapImport(File xmlFile,
String repositoryName) |
static void |
executeExport(OutputStream baseOutputStream,
boolean keepVersionHistory,
boolean format,
javax.jcr.Session session,
String basepath,
String repository,
String ext) |
protected static InputStream |
getXslStreamForXmlFile(File file) |
static void |
importDocument(Document xmlDocument,
String repositoryName,
String basepath,
boolean keepVersionHistory,
int importMode,
boolean saveAfterImport,
boolean createBasepathIfNotExist)
Converts a xml document into a file.
|
static void |
importFile(File xmlFile,
String repositoryName,
String basepath,
boolean keepVersionHistory,
int importMode,
boolean saveAfterImport,
boolean createBasepathIfNotExist)
Creates an
InputStream backed by the specified xml file. |
static void |
importProperties(Properties properties,
String repositoryName)
Deprecated.
since 4.0 - use the PropertiesImportExport class instead.
|
static void |
importXmlStream(InputStream xmlStream,
String repositoryName,
String basepath,
String name,
boolean keepVersionHistory,
boolean forceUnpublishState,
int importMode,
boolean saveAfterImport,
boolean createBasepathIfNotExist)
Imports XML stream into repository.
|
static void |
importXmlStream(InputStream xmlStream,
String repositoryName,
String basepath,
String name,
boolean keepVersionHistory,
int importMode,
boolean saveAfterImport,
boolean createBasepathIfNotExist)
Imports XML stream into repository.
|
static void |
parseAndFormat(OutputStream stream,
XMLReader reader,
String repository,
String basepath,
javax.jcr.Session session,
boolean noRecurse)
Exports the content of the repository, and format it if necessary.
|
protected static void |
readFormatted(XMLReader reader,
File inputFile,
OutputStream outputStream) |
protected static void |
readFormatted(XMLReader reader,
InputStream inputStream,
OutputStream outputStream) |
static String |
revertExportPath(String exportPath)
The opposite of
createExportPath(String) . |
public static final String ZIP
public static final String GZ
public static final String XML
public static final String PROPERTIES
public static final String DOT
public static final String SLASH
public static final String UTF8
public static final String JCR_ROOT
public static void importDocument(Document xmlDocument, String repositoryName, String basepath, boolean keepVersionHistory, int importMode, boolean saveAfterImport, boolean createBasepathIfNotExist) throws IOException
xmlDocument
- uploaded filerepositoryName
- selected repositorybasepath
- base path in repositorykeepVersionHistory
- if false
version info will be stripped before importing the documentimportMode
- a valid value for ImportUUIDBehaviorIOException
ImportUUIDBehavior
public static void importFile(File xmlFile, String repositoryName, String basepath, boolean keepVersionHistory, int importMode, boolean saveAfterImport, boolean createBasepathIfNotExist) throws IOException
InputStream
backed by the specified xml file.xmlFile
- (zipped/gzipped) XML file to importrepositoryName
- selected repositorybasepath
- base path in repositorykeepVersionHistory
- if false
version info will be stripped before importing the documentimportMode
- a valid value for ImportUUIDBehaviorIOException
ImportUUIDBehavior
public static void executeBootstrapImport(File xmlFile, String repositoryName) throws IOException
IOException
@Deprecated public static void importProperties(Properties properties, String repositoryName)
public static void importXmlStream(InputStream xmlStream, String repositoryName, String basepath, String name, boolean keepVersionHistory, int importMode, boolean saveAfterImport, boolean createBasepathIfNotExist) throws IOException
MagnoliaV2Filter
, VersionFilter
and ImportXmlRootFilter
if keepVersionHistory
is set to false
xmlStream
- XML stream to importrepositoryName
- selected repositorybasepath
- base path in repositoryname
- (absolute path of File
)keepVersionHistory
- if false
version info will be stripped before importing the documentimportMode
- a valid value for ImportUUIDBehaviorIOException
ImportUUIDBehavior
,
ImportXmlRootFilter
,
VersionFilter
,
MagnoliaV2Filter
public static void importXmlStream(InputStream xmlStream, String repositoryName, String basepath, String name, boolean keepVersionHistory, boolean forceUnpublishState, int importMode, boolean saveAfterImport, boolean createBasepathIfNotExist) throws IOException
MagnoliaV2Filter
, VersionFilter
and ImportXmlRootFilter
if keepVersionHistory
is set to false
xmlStream
- XML stream to importrepositoryName
- selected repositorybasepath
- base path in repositoryname
- (absolute path of File
)keepVersionHistory
- if false
version info will be stripped before importing the documentforceUnpublishState
- if true
then activation state of node will be change to unpublished.importMode
- a valid value for ImportUUIDBehaviorIOException
ImportUUIDBehavior
,
ImportXmlRootFilter
,
VersionFilter
,
MagnoliaV2Filter
protected static InputStream getXslStreamForXmlFile(File file)
null
public static void executeExport(OutputStream baseOutputStream, boolean keepVersionHistory, boolean format, javax.jcr.Session session, String basepath, String repository, String ext) throws IOException
IOException
public static void parseAndFormat(OutputStream stream, XMLReader reader, String repository, String basepath, javax.jcr.Session session, boolean noRecurse) throws IOException, SAXException, ParserConfigurationException, TransformerConfigurationException, javax.jcr.PathNotFoundException, javax.jcr.RepositoryException
stream
- the stream to write the content toreader
- the reader to use to parse the xml content (so that we can perform filtering), if null instanciate
a default onerepository
- the repository to exportbasepath
- the basepath in the repositorysession
- the session to use to export the data from the repositoryIOException
SAXException
ParserConfigurationException
TransformerConfigurationException
javax.jcr.PathNotFoundException
javax.jcr.RepositoryException
protected static void readFormatted(XMLReader reader, File inputFile, OutputStream outputStream) throws FileNotFoundException, IOException, SAXException, TransformerConfigurationException
protected static void readFormatted(XMLReader reader, InputStream inputStream, OutputStream outputStream) throws FileNotFoundException, IOException, SAXException, TransformerConfigurationException
public static String encodePath(String path, String separator, String enc)
path
- path to encodeseparator
- "." (dot) or "/", it will be not encoded if foundenc
- charsetpublic static String decodePath(String path, String enc)
path
- path to decodeenc
- charsetpublic static String createExportPath(String path)
/foo/bar.baz/test../dir/baz..bar
, this method will produce
.foo.bar..baz.test.....dir.baz....bar
.public static String revertExportPath(String exportPath)
createExportPath(String)
.
I.e. given a path like this .foo.bar..baz.test.....dir.baz....bar
, this method will produce /foo/bar.baz/test../dir/baz..bar
.Copyright © 2003–2018 Magnolia International Ltd.. All rights reserved.