Package org.opencms.importexport
Class CmsExportHelper
java.lang.Object
org.opencms.importexport.CmsExportHelper
Wrapper to write exported OpenCms resources either to a .ZIP file or to the file system.
- Since:
- 7.5.1
-
Constructor Summary
ConstructorDescriptionCmsExportHelper
(String exportPath, boolean exportAsFiles, boolean validateXml) Creates a new export helper. -
Method Summary
Modifier and TypeMethodDescriptionvoid
Ensures the zip stream is closed (if there is one).protected String
getRfsFileName
(String name) Returns the RFS file name for the given OpenCms VFS file name.org.dom4j.io.SAXWriter
Returns the SAX writer for the Manifest file.protected void
removeOldExport
(String exportPath) Removes the old export output, which may be an existing file or directory.void
Writes a single OpenCms VFS file to the export.protected void
writeFile2Rfs
(CmsFile file, String name) Writes a single OpenCms VFS file to the RFS export.protected void
writeFile2Zip
(CmsFile file, String name) Writes a single OpenCms VFS file to the ZIP export.void
writeManifest
(CmsXmlSaxWriter xmlSaxWriter) Writes the OpenCms manifest.xml file to the export.protected void
writeManifest2Rfs
(CmsXmlSaxWriter xmlSaxWriter) Writes the OpenCms manifest.xml file to the RFS export.protected void
writeManifest2Zip
(CmsXmlSaxWriter xmlSaxWriter) Writes the OpenCms manifest.xml file to the ZIP export.
-
Constructor Details
-
CmsExportHelper
public CmsExportHelper(String exportPath, boolean exportAsFiles, boolean validateXml) throws SAXException, IOException Creates a new export helper.- Parameters:
exportPath
- the export pathexportAsFiles
- indicates if the resources should be exported as individual files or in one big ZIP filevalidateXml
- indicates of the manifest.xml should be validated- Throws:
SAXException
- in case of issues creating the manifest.xmlIOException
- in case of file access issues
-
-
Method Details
-
ensureZipStreamClosed
Ensures the zip stream is closed (if there is one). -
getSaxWriter
Returns the SAX writer for the Manifest file.- Returns:
- the SAX writer for the Manifest file
-
writeFile
Writes a single OpenCms VFS file to the export.- Parameters:
file
- the OpenCms VFS file to writename
- the name of the file in the export- Throws:
IOException
- in case of file access issues
-
writeManifest
Writes the OpenCms manifest.xml file to the export.- Parameters:
xmlSaxWriter
- the SAX writer to use- Throws:
SAXException
- in case of issues creating the manifest.xmlIOException
- in case of file access issues
-
getRfsFileName
Returns the RFS file name for the given OpenCms VFS file name.- Parameters:
name
- the OpenCms VFS file name- Returns:
- the RFS file name for the given OpenCms VFS file name
-
removeOldExport
Removes the old export output, which may be an existing file or directory.- Parameters:
exportPath
- the export output path
-
writeFile2Rfs
Writes a single OpenCms VFS file to the RFS export.- Parameters:
file
- the OpenCms VFS file to writename
- the name of the file in the export- Throws:
IOException
- in case of file access issues
-
writeFile2Zip
Writes a single OpenCms VFS file to the ZIP export.- Parameters:
file
- the OpenCms VFS file to writename
- the name of the file in the export- Throws:
IOException
- in case of file access issues
-
writeManifest2Rfs
Writes the OpenCms manifest.xml file to the RFS export.In case of the RFS export the file is directly written to a file output stream, so calling this method just closes the XML and finishes the stream.
- Parameters:
xmlSaxWriter
- the SAX writer to use- Throws:
SAXException
- in case of issues creating the manifest.xmlIOException
- in case of issues closing the file writer
-
writeManifest2Zip
Writes the OpenCms manifest.xml file to the ZIP export.In case of the ZIP export the manifest is written to an internal StringBuffer first, which is then stored in the ZIP file when this method is called.
- Parameters:
xmlSaxWriter
- the SAX writer to use- Throws:
SAXException
- in case of issues creating the manifest.xmlIOException
- in case of file access issues
-