Package org.opencms.importexport
Class CmsImportHelper
- java.lang.Object
-
- org.opencms.importexport.CmsImportHelper
-
public class CmsImportHelper extends java.lang.Object
Import helper.- Since:
- 7.0.4
-
-
Constructor Summary
Constructors Constructor Description CmsImportHelper(CmsImportParameters parameters)
Constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
cacheDtdSystemId(java.lang.String dtdSystemLocation, java.lang.String dtdFilename, java.lang.String dtdUrlPrefix)
Adds a new DTD system id prefix mapping for internal resolution of external URLs.void
closeFile()
Closes the zip file.protected java.io.File
getFile(java.lang.String filename)
Returns the file for the provided filename.byte[]
getFileBytes(java.lang.String filename)
Returns a byte array containing the content of the file.long
getFileModification(java.lang.String filename)
java.lang.String
getFileName()
Returns the name of the import file, without zip extension.java.io.InputStream
getFileStream(java.lang.String fileName)
Returns a stream for the content of the file.java.io.File
getFolder()
Returns the RFS folder to import from.java.lang.String
getLocation(java.lang.Class<?> clazz)
Returns the class system location.protected java.util.zip.ZipEntry
getZipEntry(java.lang.String filename)
Returns the zip entry for a file in the archive.java.util.zip.ZipFile
getZipFile()
Returns the RFS zip file to import from.void
openFile()
Opens the import file.
-
-
-
Constructor Detail
-
CmsImportHelper
public CmsImportHelper(CmsImportParameters parameters)
Constructor.- Parameters:
parameters
- the import parameters to use
-
-
Method Detail
-
cacheDtdSystemId
public void cacheDtdSystemId(java.lang.String dtdSystemLocation, java.lang.String dtdFilename, java.lang.String dtdUrlPrefix)
Adds a new DTD system id prefix mapping for internal resolution of external URLs.- Parameters:
dtdSystemLocation
- the internal system location of the DTD file, e.g.org/opencms/configuration/
dtdFilename
- the name of the DTD file, e.g.opencms-configuration.dtd
dtdUrlPrefix
- the external system id prefix of the DTD file, e.g.http://www.opencms.org/dtd/6.0/
- See Also:
I_CmsXmlConfiguration
-
closeFile
public void closeFile()
Closes the zip file.
-
getFileBytes
public byte[] getFileBytes(java.lang.String filename) throws CmsImportExportException
Returns a byte array containing the content of the file.- Parameters:
filename
- the name of the file to read, relative to the folder or zip file- Returns:
- a byte array containing the content of the file
- Throws:
CmsImportExportException
- if something goes wrong
-
getFileModification
public long getFileModification(java.lang.String filename) throws CmsImportExportException
- Throws:
CmsImportExportException
-
getFileName
public java.lang.String getFileName()
Returns the name of the import file, without zip extension.- Returns:
- the name of the import file, without zip extension
-
getFileStream
public java.io.InputStream getFileStream(java.lang.String fileName) throws CmsImportExportException
Returns a stream for the content of the file.- Parameters:
fileName
- the name of the file to stream, relative to the folder or zip file- Returns:
- an input stream for the content of the file, remember to close it after using
- Throws:
CmsImportExportException
- if something goes wrong
-
getFolder
public java.io.File getFolder()
Returns the RFS folder to import from.- Returns:
- the RFS folder to import from
-
getLocation
public java.lang.String getLocation(java.lang.Class<?> clazz)
Returns the class system location.i.e:
org/opencms/importexport
- Parameters:
clazz
- the class to get the location for- Returns:
- the class system location
-
getZipFile
public java.util.zip.ZipFile getZipFile()
Returns the RFS zip file to import from.- Returns:
- the RFS zip file to import from
-
openFile
public void openFile() throws java.io.IOException
Opens the import file.- Throws:
java.io.IOException
- if the file could not be opened
-
getFile
protected java.io.File getFile(java.lang.String filename)
Returns the file for the provided filename.- Parameters:
filename
- name of the file- Returns:
- the file.
-
getZipEntry
protected java.util.zip.ZipEntry getZipEntry(java.lang.String filename) throws java.util.zip.ZipException
Returns the zip entry for a file in the archive.- Parameters:
filename
- the file name- Returns:
- the zip entry for the file with the provided name
- Throws:
java.util.zip.ZipException
- thrown if the file is not in the zip archive
-
-