org.opencms.importexport
Class CmsImportHelper

java.lang.Object
  extended by org.opencms.importexport.CmsImportHelper

public class CmsImportHelper
extends java.lang.Object

Import helper.

Since:
7.0.4
Version:
$Revision: 1.6 $
Author:
Michael Moossen

Constructor Summary
CmsImportHelper(CmsImportParameters parameters)
          Constructor.
 
Method Summary
 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.
 byte[] getFileBytes(java.lang.String filename)
          Returns a byte array containing the content of the file.
 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.
 java.util.zip.ZipFile getZipFile()
          Returns the RFS zip file to import from.
 void openFile()
          Opens the import file.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

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

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